From cb9cadad578297ffd78fa8a33670bdf1ab669e7e Mon Sep 17 00:00:00 2001 From: Ed Warnicke Date: Tue, 8 Dec 2015 15:45:58 -0700 Subject: Initial commit of vpp code. Change-Id: Ib246f1fbfce93274020ee93ce461e3d8bd8b9f17 Signed-off-by: Ed Warnicke --- build-data/platforms/vpp.mk | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 build-data/platforms/vpp.mk (limited to 'build-data/platforms/vpp.mk') diff --git a/build-data/platforms/vpp.mk b/build-data/platforms/vpp.mk new file mode 100644 index 00000000..1975a868 --- /dev/null +++ b/build-data/platforms/vpp.mk @@ -0,0 +1,38 @@ +# Copyright (c) 2015 Cisco and/or its affiliates. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# vector packet processor +vpp_arch = native +vpp_native_tools = vppapigen vppversion + +vpp_root_packages = vpp vlib vlib-api vnet svm dpdk vpp-api-test \ + vpp-japi + +vpp_configure_args_vpp = --with-dpdk +vnet_configure_args_vpp = --with-dpdk + +# Set these parameters carefully. The vlib_buffer_t is 128 bytes, i.e. +# dpdk_headroom = uiotarball_headroom = vlib_pre_data + 128 +dpdk_configure_args_vpp = --with-headroom=256 +vlib_configure_args_vpp = --with-pre-data=128 + + +vpp_debug_TAG_CFLAGS = -g -O0 -DCLIB_DEBUG -DFORTIFY_SOURCE=2 -march=$(MARCH) \ + -fstack-protector-all -fPIC +vpp_debug_TAG_LDFLAGS = -g -O0 -DCLIB_DEBUG -DFORTIFY_SOURCE=2 -march=$(MARCH) \ + -fstack-protector-all -fPIC + +vpp_TAG_CFLAGS = -g -O2 -DFORTIFY_SOURCE=2 -march=$(MARCH) \ + -fstack-protector -fPIC +vpp_TAG_LDFLAGS = -g -O2 -DFORTIFY_SOURCE=2 -march=$(MARCH) \ + -fstack-protector -fPIC -- cgit 1.2.3-korg From 29b6af9f97b0002a4ba495eade7727c1ecb4f3c2 Mon Sep 17 00:00:00 2001 From: Damjan Marion Date: Sun, 13 Dec 2015 21:17:07 +0100 Subject: Remove vppversion subtree, move elftool to vppinfra Change-Id: I26b29a0f53f81a28cbf264f5299f9a3978735574 Signed-off-by: Damjan Marion --- build-data/platforms/virl.mk | 2 +- build-data/platforms/vpp.mk | 2 +- build-root/bootstrap.sh | 4 +- build-root/packages/vppversion.mk | 5 - vppinfra/Makefile.am | 6 + vppinfra/Makefile.in | 212 +- vppinfra/aclocal.m4 | 67 +- vppinfra/config/compile | 2 +- vppinfra/config/config.guess | 192 +- vppinfra/config/config.sub | 30 +- vppinfra/config/depcomp | 2 +- vppinfra/config/install-sh | 366 +- vppinfra/config/ltmain.sh | 4 +- vppinfra/config/missing | 2 +- vppinfra/config/test-driver | 15 +- vppinfra/configure | 13 +- vppinfra/tools/elftool.c | 459 ++ vppversion/.gitignore | 2 - vppversion/Makefile.am | 20 - vppversion/Makefile.in | 816 -- vppversion/aclocal.m4 | 9771 ------------------------ vppversion/compile | 347 - vppversion/config.guess | 1558 ---- vppversion/config.sub | 1791 ----- vppversion/configure | 14439 ------------------------------------ vppversion/configure.ac | 8 - vppversion/depcomp | 791 -- vppversion/elftool.c | 459 -- vppversion/install-sh | 527 -- vppversion/ltmain.sh | 9661 ------------------------ vppversion/missing | 215 - 31 files changed, 901 insertions(+), 40887 deletions(-) delete mode 100644 build-root/packages/vppversion.mk create mode 100644 vppinfra/tools/elftool.c delete mode 100644 vppversion/.gitignore delete mode 100644 vppversion/Makefile.am delete mode 100644 vppversion/Makefile.in delete mode 100644 vppversion/aclocal.m4 delete mode 100755 vppversion/compile delete mode 100755 vppversion/config.guess delete mode 100755 vppversion/config.sub delete mode 100755 vppversion/configure delete mode 100644 vppversion/configure.ac delete mode 100755 vppversion/depcomp delete mode 100644 vppversion/elftool.c delete mode 100755 vppversion/install-sh delete mode 100644 vppversion/ltmain.sh delete mode 100755 vppversion/missing (limited to 'build-data/platforms/vpp.mk') diff --git a/build-data/platforms/virl.mk b/build-data/platforms/virl.mk index b65318c1..40f79418 100644 --- a/build-data/platforms/virl.mk +++ b/build-data/platforms/virl.mk @@ -13,7 +13,7 @@ # vector packet processor virl_arch = native -virl_native_tools = vppapigen vppversion +virl_native_tools = vppapigen virl_root_packages = vpp vlib vlib-api vnet svm dpdk vpp-api-test \ vpp-japi diff --git a/build-data/platforms/vpp.mk b/build-data/platforms/vpp.mk index 1975a868..a09b0307 100644 --- a/build-data/platforms/vpp.mk +++ b/build-data/platforms/vpp.mk @@ -13,7 +13,7 @@ # vector packet processor vpp_arch = native -vpp_native_tools = vppapigen vppversion +vpp_native_tools = vppapigen vpp_root_packages = vpp vlib vlib-api vnet svm dpdk vpp-api-test \ vpp-japi diff --git a/build-root/bootstrap.sh b/build-root/bootstrap.sh index 3ae94098..bc833f12 100755 --- a/build-root/bootstrap.sh +++ b/build-root/bootstrap.sh @@ -41,7 +41,7 @@ done cd $wsroot -for dir in vppapigen vppinfra sample-plugin vppversion svm vlib vlib-api vnet \ +for dir in vppapigen vppinfra sample-plugin svm vlib vlib-api vnet \ vpp vpp-api-test vpp-japi do cd $dir @@ -52,7 +52,7 @@ done cd $build_root echo Compile native tools -for tool in vppapigen vppversion +for tool in vppapigen do make V=0 is_build_tool=yes $tool-install done diff --git a/build-root/packages/vppversion.mk b/build-root/packages/vppversion.mk deleted file mode 100644 index 3ccde62b..00000000 --- a/build-root/packages/vppversion.mk +++ /dev/null @@ -1,5 +0,0 @@ -vppversion_configure_depend = vppinfra-install - -vppversion_CPPFLAGS = $(call installed_includes_fn, vppinfra) - -vppversion_LDFLAGS = $(call installed_libs_fn, vppinfra) diff --git a/vppinfra/Makefile.am b/vppinfra/Makefile.am index 388845a4..e3a7d46d 100644 --- a/vppinfra/Makefile.am +++ b/vppinfra/Makefile.am @@ -266,3 +266,9 @@ libvppinfra_la_SOURCES = \ vppinfra/timer.c \ vppinfra/unix-formats.c \ vppinfra/unix-misc.c + +bin_PROGRAMS = elftool + +elftool_SOURCES = tools/elftool.c +elftool_CPPFLAGS = -Wall +elftool_LDADD = libvppinfra.la -lpthread -lrt -lm diff --git a/vppinfra/Makefile.in b/vppinfra/Makefile.in index 6801be17..ec6847a1 100644 --- a/vppinfra/Makefile.in +++ b/vppinfra/Makefile.in @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.14.1 from Makefile.am. +# Makefile.in generated by automake 1.15 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2013 Free Software Foundation, Inc. +# Copyright (C) 1994-2014 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -18,7 +18,17 @@ VPATH = @srcdir@ -am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' +am__is_gnu_make = { \ + if test -z '$(MAKELEVEL)'; then \ + false; \ + elif test -n '$(MAKE_HOST)'; then \ + true; \ + elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ + true; \ + else \ + false; \ + fi; \ +} am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ @@ -94,22 +104,15 @@ TESTS = test_bihash_template$(EXEEXT) test_elog$(EXEEXT) \ test_zvec$(EXEEXT) noinst_PROGRAMS = $(am__EXEEXT_1) check_PROGRAMS = $(am__EXEEXT_1) +bin_PROGRAMS = elftool$(EXEEXT) subdir = . -DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ - $(top_srcdir)/configure $(am__configure_deps) \ - $(top_srcdir)/config/config.h.in $(top_srcdir)/config/depcomp \ - $(nobase_include_HEADERS) $(top_srcdir)/config/test-driver \ - INSTALL README compile config/compile config/config.guess \ - config/config.sub config/depcomp config/install-sh \ - config/missing mkinstalldirs ltmain.sh config/ltmain.sh \ - $(top_srcdir)/config/compile $(top_srcdir)/config/config.guess \ - $(top_srcdir)/config/config.sub \ - $(top_srcdir)/config/install-sh $(top_srcdir)/config/ltmain.sh \ - $(top_srcdir)/config/missing ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) +DIST_COMMON = $(srcdir)/Makefile.am $(top_srcdir)/configure \ + $(am__configure_deps) $(nobase_include_HEADERS) \ + $(am__DIST_COMMON) am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ configure.lineno config.status.lineno mkinstalldirs = $(install_sh) -d @@ -144,7 +147,7 @@ am__uninstall_files_from_dir = { \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(libdir)" \ - "$(DESTDIR)$(includedir)" + "$(DESTDIR)$(bindir)" "$(DESTDIR)$(includedir)" LIBRARIES = $(lib_LIBRARIES) LTLIBRARIES = $(lib_LTLIBRARIES) libvppinfra_la_LIBADD = @@ -182,7 +185,10 @@ am__EXEEXT_1 = test_bihash_template$(EXEEXT) test_elog$(EXEEXT) \ test_socket$(EXEEXT) test_time$(EXEEXT) \ test_timing_wheel$(EXEEXT) test_vec$(EXEEXT) \ test_zvec$(EXEEXT) -PROGRAMS = $(noinst_PROGRAMS) +PROGRAMS = $(bin_PROGRAMS) $(noinst_PROGRAMS) +am_elftool_OBJECTS = tools/elftool-elftool.$(OBJEXT) +elftool_OBJECTS = $(am_elftool_OBJECTS) +elftool_DEPENDENCIES = libvppinfra.la am_test_bihash_template_OBJECTS = \ vppinfra/test_bihash_template-test_bihash_template.$(OBJEXT) test_bihash_template_OBJECTS = $(am_test_bihash_template_OBJECTS) @@ -382,8 +388,9 @@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = -SOURCES = $(libvppinfra_la_SOURCES) $(test_bihash_template_SOURCES) \ - $(test_elf_SOURCES) $(test_elog_SOURCES) $(test_fifo_SOURCES) \ +SOURCES = $(libvppinfra_la_SOURCES) $(elftool_SOURCES) \ + $(test_bihash_template_SOURCES) $(test_elf_SOURCES) \ + $(test_elog_SOURCES) $(test_fifo_SOURCES) \ $(test_format_SOURCES) $(test_hash_SOURCES) \ $(test_heap_SOURCES) $(test_longjmp_SOURCES) \ $(test_macros_SOURCES) $(test_md5_SOURCES) \ @@ -394,7 +401,7 @@ SOURCES = $(libvppinfra_la_SOURCES) $(test_bihash_template_SOURCES) \ $(test_slist_SOURCES) $(test_socket_SOURCES) \ $(test_time_SOURCES) $(test_timing_wheel_SOURCES) \ $(test_vec_SOURCES) $(test_zvec_SOURCES) -DIST_SOURCES = $(libvppinfra_la_SOURCES) \ +DIST_SOURCES = $(libvppinfra_la_SOURCES) $(elftool_SOURCES) \ $(test_bihash_template_SOURCES) $(test_elf_SOURCES) \ $(test_elog_SOURCES) $(test_fifo_SOURCES) \ $(test_format_SOURCES) $(test_hash_SOURCES) \ @@ -610,6 +617,15 @@ TEST_LOGS = $(am__test_logs2:.test.log=.log) TEST_LOG_DRIVER = $(SHELL) $(top_srcdir)/config/test-driver TEST_LOG_COMPILE = $(TEST_LOG_COMPILER) $(AM_TEST_LOG_FLAGS) \ $(TEST_LOG_FLAGS) +am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/config/compile \ + $(top_srcdir)/config/config.guess \ + $(top_srcdir)/config/config.h.in \ + $(top_srcdir)/config/config.sub $(top_srcdir)/config/depcomp \ + $(top_srcdir)/config/install-sh $(top_srcdir)/config/ltmain.sh \ + $(top_srcdir)/config/missing $(top_srcdir)/config/test-driver \ + INSTALL README compile config/compile config/config.guess \ + config/config.sub config/depcomp config/install-sh \ + config/ltmain.sh config/missing ltmain.sh mkinstalldirs DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) distdir = $(PACKAGE)-$(VERSION) top_distdir = $(distdir) @@ -979,6 +995,9 @@ libvppinfra_la_SOURCES = \ vppinfra/unix-formats.c \ vppinfra/unix-misc.c +elftool_SOURCES = tools/elftool.c +elftool_CPPFLAGS = -Wall +elftool_LDADD = libvppinfra.la -lpthread -lrt -lm all: all-am .SUFFIXES: @@ -998,7 +1017,6 @@ $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) 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*) \ @@ -1187,6 +1205,55 @@ vppinfra/unix-misc.lo: vppinfra/$(am__dirstamp) \ libvppinfra.la: $(libvppinfra_la_OBJECTS) $(libvppinfra_la_DEPENDENCIES) $(EXTRA_libvppinfra_la_DEPENDENCIES) $(AM_V_CCLD)$(LINK) $(am_libvppinfra_la_rpath) $(libvppinfra_la_OBJECTS) $(libvppinfra_la_LIBADD) $(LIBS) +install-binPROGRAMS: $(bin_PROGRAMS) + @$(NORMAL_INSTALL) + @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(bindir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(bindir)" || exit 1; \ + fi; \ + 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 clean-checkPROGRAMS: @list='$(check_PROGRAMS)'; test -n "$$list" || exit 0; \ @@ -1205,6 +1272,18 @@ clean-noinstPROGRAMS: list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ echo " rm -f" $$list; \ rm -f $$list +tools/$(am__dirstamp): + @$(MKDIR_P) tools + @: > tools/$(am__dirstamp) +tools/$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) tools/$(DEPDIR) + @: > tools/$(DEPDIR)/$(am__dirstamp) +tools/elftool-elftool.$(OBJEXT): tools/$(am__dirstamp) \ + tools/$(DEPDIR)/$(am__dirstamp) + +elftool$(EXEEXT): $(elftool_OBJECTS) $(elftool_DEPENDENCIES) $(EXTRA_elftool_DEPENDENCIES) + @rm -f elftool$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(elftool_OBJECTS) $(elftool_LDADD) $(LIBS) vppinfra/test_bihash_template-test_bihash_template.$(OBJEXT): \ vppinfra/$(am__dirstamp) vppinfra/$(DEPDIR)/$(am__dirstamp) @@ -1352,12 +1431,14 @@ test_zvec$(EXEEXT): $(test_zvec_OBJECTS) $(test_zvec_DEPENDENCIES) $(EXTRA_test_ mostlyclean-compile: -rm -f *.$(OBJEXT) + -rm -f tools/*.$(OBJEXT) -rm -f vppinfra/*.$(OBJEXT) -rm -f vppinfra/*.lo distclean-compile: -rm -f *.tab.c +@AMDEP_TRUE@@am__include@ @am__quote@tools/$(DEPDIR)/elftool-elftool.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@vppinfra/$(DEPDIR)/asm_x86.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@vppinfra/$(DEPDIR)/backtrace.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@vppinfra/$(DEPDIR)/elf.Plo@am__quote@ @@ -1471,6 +1552,20 @@ distclean-compile: @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< +tools/elftool-elftool.o: tools/elftool.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(elftool_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT tools/elftool-elftool.o -MD -MP -MF tools/$(DEPDIR)/elftool-elftool.Tpo -c -o tools/elftool-elftool.o `test -f 'tools/elftool.c' || echo '$(srcdir)/'`tools/elftool.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) tools/$(DEPDIR)/elftool-elftool.Tpo tools/$(DEPDIR)/elftool-elftool.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='tools/elftool.c' object='tools/elftool-elftool.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(elftool_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o tools/elftool-elftool.o `test -f 'tools/elftool.c' || echo '$(srcdir)/'`tools/elftool.c + +tools/elftool-elftool.obj: tools/elftool.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(elftool_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT tools/elftool-elftool.obj -MD -MP -MF tools/$(DEPDIR)/elftool-elftool.Tpo -c -o tools/elftool-elftool.obj `if test -f 'tools/elftool.c'; then $(CYGPATH_W) 'tools/elftool.c'; else $(CYGPATH_W) '$(srcdir)/tools/elftool.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) tools/$(DEPDIR)/elftool-elftool.Tpo tools/$(DEPDIR)/elftool-elftool.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='tools/elftool.c' object='tools/elftool-elftool.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(elftool_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o tools/elftool-elftool.obj `if test -f 'tools/elftool.c'; then $(CYGPATH_W) 'tools/elftool.c'; else $(CYGPATH_W) '$(srcdir)/tools/elftool.c'; fi` + vppinfra/test_bihash_template-test_bihash_template.o: vppinfra/test_bihash_template.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_bihash_template_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT vppinfra/test_bihash_template-test_bihash_template.o -MD -MP -MF vppinfra/$(DEPDIR)/test_bihash_template-test_bihash_template.Tpo -c -o vppinfra/test_bihash_template-test_bihash_template.o `test -f 'vppinfra/test_bihash_template.c' || echo '$(srcdir)/'`vppinfra/test_bihash_template.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) vppinfra/$(DEPDIR)/test_bihash_template-test_bihash_template.Tpo vppinfra/$(DEPDIR)/test_bihash_template-test_bihash_template.Po @@ -1930,7 +2025,7 @@ $(TEST_SUITE_LOG): $(TEST_LOGS) if test -n "$$am__remaking_logs"; then \ echo "fatal: making $(TEST_SUITE_LOG): possible infinite" \ "recursion detected" >&2; \ - else \ + elif test -n "$$redo_logs"; then \ am__remaking_logs=yes $(MAKE) $(AM_MAKEFLAGS) $$redo_logs; \ fi; \ if $(am__make_dryrun); then :; else \ @@ -2279,15 +2374,15 @@ dist-xz: distdir $(am__post_remove_distdir) dist-tarZ: distdir - @echo WARNING: "Support for shar distribution archives is" \ - "deprecated." >&2 + @echo WARNING: "Support for distribution archives compressed with" \ + "legacy program 'compress' is deprecated." >&2 @echo WARNING: "It will be removed altogether in Automake 2.0" >&2 tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z $(am__post_remove_distdir) dist-shar: distdir - @echo WARNING: "Support for distribution archives compressed with" \ - "legacy program 'compress' is deprecated." >&2 + @echo WARNING: "Support for shar distribution archives is" \ + "deprecated." >&2 @echo WARNING: "It will be removed altogether in Automake 2.0" >&2 shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz $(am__post_remove_distdir) @@ -2323,17 +2418,17 @@ distcheck: dist esac chmod -R a-w $(distdir) chmod u+w $(distdir) - mkdir $(distdir)/_build $(distdir)/_inst + mkdir $(distdir)/_build $(distdir)/_build/sub $(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 \ + && $(am__cd) $(distdir)/_build/sub \ + && ../../configure \ $(AM_DISTCHECK_CONFIGURE_FLAGS) \ $(DISTCHECK_CONFIGURE_FLAGS) \ - --srcdir=.. --prefix="$$dc_install_base" \ + --srcdir=../.. --prefix="$$dc_install_base" \ && $(MAKE) $(AM_MAKEFLAGS) \ && $(MAKE) $(AM_MAKEFLAGS) dvi \ && $(MAKE) $(AM_MAKEFLAGS) check \ @@ -2391,8 +2486,10 @@ check-am: all-am $(MAKE) $(AM_MAKEFLAGS) check-TESTS check: check-am all-am: Makefile $(LIBRARIES) $(LTLIBRARIES) $(PROGRAMS) $(HEADERS) +install-binPROGRAMS: install-libLTLIBRARIES + installdirs: - for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(libdir)" "$(DESTDIR)$(includedir)"; do \ + for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(libdir)" "$(DESTDIR)$(bindir)" "$(DESTDIR)$(includedir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am @@ -2424,6 +2521,8 @@ 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) + -rm -f tools/$(DEPDIR)/$(am__dirstamp) + -rm -f tools/$(am__dirstamp) -rm -f vppinfra/$(DEPDIR)/$(am__dirstamp) -rm -f vppinfra/$(am__dirstamp) @@ -2432,13 +2531,13 @@ maintainer-clean-generic: @echo "it deletes files that may require special tools to rebuild." clean: clean-am -clean-am: clean-checkPROGRAMS clean-generic clean-libLIBRARIES \ - clean-libLTLIBRARIES clean-libtool clean-noinstPROGRAMS \ - mostlyclean-am +clean-am: clean-binPROGRAMS clean-checkPROGRAMS clean-generic \ + clean-libLIBRARIES clean-libLTLIBRARIES clean-libtool \ + clean-noinstPROGRAMS mostlyclean-am distclean: distclean-am -rm -f $(am__CONFIG_DISTCLEAN_FILES) - -rm -rf vppinfra/$(DEPDIR) + -rm -rf tools/$(DEPDIR) vppinfra/$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-hdr distclean-libtool distclean-tags @@ -2461,7 +2560,8 @@ install-dvi: install-dvi-am install-dvi-am: -install-exec-am: install-libLIBRARIES install-libLTLIBRARIES +install-exec-am: install-binPROGRAMS install-libLIBRARIES \ + install-libLTLIBRARIES install-html: install-html-am @@ -2486,7 +2586,7 @@ installcheck-am: maintainer-clean: maintainer-clean-am -rm -f $(am__CONFIG_DISTCLEAN_FILES) -rm -rf $(top_srcdir)/autom4te.cache - -rm -rf vppinfra/$(DEPDIR) + -rm -rf tools/$(DEPDIR) vppinfra/$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic @@ -2503,32 +2603,34 @@ ps: ps-am ps-am: -uninstall-am: uninstall-libLIBRARIES uninstall-libLTLIBRARIES \ - uninstall-nobase_includeHEADERS +uninstall-am: uninstall-binPROGRAMS uninstall-libLIBRARIES \ + uninstall-libLTLIBRARIES uninstall-nobase_includeHEADERS .MAKE: check-am install-am install-strip .PHONY: CTAGS GTAGS TAGS all all-am am--refresh check check-TESTS \ - check-am clean clean-checkPROGRAMS clean-cscope clean-generic \ - clean-libLIBRARIES clean-libLTLIBRARIES clean-libtool \ - clean-noinstPROGRAMS cscope cscopelist-am ctags ctags-am dist \ - dist-all dist-bzip2 dist-gzip dist-lzip dist-shar dist-tarZ \ - dist-xz dist-zip distcheck distclean distclean-compile \ - distclean-generic distclean-hdr distclean-libtool \ - 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-libLIBRARIES \ - install-libLTLIBRARIES install-man \ - install-nobase_includeHEADERS install-pdf install-pdf-am \ - install-ps install-ps-am install-strip installcheck \ - installcheck-am installdirs maintainer-clean \ + check-am clean clean-binPROGRAMS clean-checkPROGRAMS \ + clean-cscope clean-generic clean-libLIBRARIES \ + clean-libLTLIBRARIES clean-libtool clean-noinstPROGRAMS cscope \ + cscopelist-am ctags ctags-am dist dist-all dist-bzip2 \ + dist-gzip dist-lzip dist-shar dist-tarZ dist-xz dist-zip \ + distcheck distclean distclean-compile distclean-generic \ + distclean-hdr distclean-libtool distclean-tags distcleancheck \ + distdir distuninstallcheck 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-libLIBRARIES install-libLTLIBRARIES \ + install-man install-nobase_includeHEADERS 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 \ recheck tags tags-am uninstall uninstall-am \ - uninstall-libLIBRARIES uninstall-libLTLIBRARIES \ - uninstall-nobase_includeHEADERS + uninstall-binPROGRAMS uninstall-libLIBRARIES \ + uninstall-libLTLIBRARIES uninstall-nobase_includeHEADERS + +.PRECIOUS: Makefile # Tell versions [3.59,3.63) of GNU make to not export all variables. diff --git a/vppinfra/aclocal.m4 b/vppinfra/aclocal.m4 index b08df583..5eb2d306 100644 --- a/vppinfra/aclocal.m4 +++ b/vppinfra/aclocal.m4 @@ -1,6 +1,6 @@ -# generated automatically by aclocal 1.14.1 -*- Autoconf -*- +# generated automatically by aclocal 1.15 -*- Autoconf -*- -# Copyright (C) 1996-2013 Free Software Foundation, Inc. +# Copyright (C) 1996-2014 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -8622,7 +8622,7 @@ m4_ifndef([_LT_PROG_F77], [AC_DEFUN([_LT_PROG_F77])]) m4_ifndef([_LT_PROG_FC], [AC_DEFUN([_LT_PROG_FC])]) m4_ifndef([_LT_PROG_CXX], [AC_DEFUN([_LT_PROG_CXX])]) -# Copyright (C) 2002-2013 Free Software Foundation, Inc. +# Copyright (C) 2002-2014 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -8634,10 +8634,10 @@ m4_ifndef([_LT_PROG_CXX], [AC_DEFUN([_LT_PROG_CXX])]) # 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.14' +[am__api_version='1.15' 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.14.1], [], +m4_if([$1], [1.15], [], [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl ]) @@ -8653,14 +8653,14 @@ m4_define([_AM_AUTOCONF_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.14.1])dnl +[AM_AUTOMAKE_VERSION([1.15])dnl m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))]) # Figure out how to run the assembler. -*- Autoconf -*- -# Copyright (C) 2001-2013 Free Software Foundation, Inc. +# Copyright (C) 2001-2014 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -8680,7 +8680,7 @@ _AM_IF_OPTION([no-dependencies],, [_AM_DEPENDENCIES([CCAS])])dnl # AM_AUX_DIR_EXPAND -*- Autoconf -*- -# Copyright (C) 2001-2013 Free Software Foundation, Inc. +# Copyright (C) 2001-2014 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -8725,15 +8725,14 @@ _AM_IF_OPTION([no-dependencies],, [_AM_DEPENDENCIES([CCAS])])dnl # 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` +[AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl +# Expand $ac_aux_dir to an absolute path. +am_aux_dir=`cd "$ac_aux_dir" && pwd` ]) # AM_CONDITIONAL -*- Autoconf -*- -# Copyright (C) 1997-2013 Free Software Foundation, Inc. +# Copyright (C) 1997-2014 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -8764,7 +8763,7 @@ AC_CONFIG_COMMANDS_PRE( Usually this means the macro was only invoked conditionally.]]) fi])]) -# Copyright (C) 1999-2013 Free Software Foundation, Inc. +# Copyright (C) 1999-2014 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -8955,7 +8954,7 @@ _AM_SUBST_NOTMAKE([am__nodep])dnl # Generate code to set up dependency tracking. -*- Autoconf -*- -# Copyright (C) 1999-2013 Free Software Foundation, Inc. +# Copyright (C) 1999-2014 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -9031,7 +9030,7 @@ AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS], # Do all the work for Automake. -*- Autoconf -*- -# Copyright (C) 1996-2013 Free Software Foundation, Inc. +# Copyright (C) 1996-2014 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -9121,8 +9120,8 @@ AC_REQUIRE([AC_PROG_MKDIR_P])dnl # # AC_SUBST([mkdir_p], ['$(MKDIR_P)']) -# We need awk for the "check" target. The system "awk" is bad on -# some platforms. +# We need awk for the "check" target (and possibly the TAP driver). 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 @@ -9195,7 +9194,11 @@ to "yes", and re-run configure. END AC_MSG_ERROR([Your 'rm' program is bad, sorry.]) fi -fi]) +fi +dnl The trailing newline in this macro's definition is deliberate, for +dnl backward compatibility and to allow trailing 'dnl'-style comments +dnl after the AM_INIT_AUTOMAKE invocation. See automake bug#16841. +]) 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 @@ -9224,7 +9227,7 @@ for _am_header in $config_headers :; do done echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count]) -# Copyright (C) 2001-2013 Free Software Foundation, Inc. +# Copyright (C) 2001-2014 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -9235,7 +9238,7 @@ echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_co # Define $install_sh. AC_DEFUN([AM_PROG_INSTALL_SH], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl -if test x"${install_sh}" != xset; then +if test x"${install_sh+set}" != xset; then case $am_aux_dir in *\ * | *\ *) install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; @@ -9245,7 +9248,7 @@ if test x"${install_sh}" != xset; then fi AC_SUBST([install_sh])]) -# Copyright (C) 2003-2013 Free Software Foundation, Inc. +# Copyright (C) 2003-2014 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -9266,7 +9269,7 @@ AC_SUBST([am__leading_dot])]) # Check to see how 'make' treats includes. -*- Autoconf -*- -# Copyright (C) 2001-2013 Free Software Foundation, Inc. +# Copyright (C) 2001-2014 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -9316,7 +9319,7 @@ rm -f confinc confmf # Fake the existence of programs that GNU maintainers use. -*- Autoconf -*- -# Copyright (C) 1997-2013 Free Software Foundation, Inc. +# Copyright (C) 1997-2014 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -9355,7 +9358,7 @@ fi # Helper functions for option handling. -*- Autoconf -*- -# Copyright (C) 2001-2013 Free Software Foundation, Inc. +# Copyright (C) 2001-2014 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -9384,7 +9387,7 @@ AC_DEFUN([_AM_SET_OPTIONS], AC_DEFUN([_AM_IF_OPTION], [m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])]) -# Copyright (C) 1999-2013 Free Software Foundation, Inc. +# Copyright (C) 1999-2014 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -9431,7 +9434,7 @@ AC_LANG_POP([C])]) # For backward compatibility. AC_DEFUN_ONCE([AM_PROG_CC_C_O], [AC_REQUIRE([AC_PROG_CC])]) -# Copyright (C) 2001-2013 Free Software Foundation, Inc. +# Copyright (C) 2001-2014 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -9450,7 +9453,7 @@ AC_DEFUN([AM_RUN_LOG], # Check to make sure that the build environment is sane. -*- Autoconf -*- -# Copyright (C) 1996-2013 Free Software Foundation, Inc. +# Copyright (C) 1996-2014 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -9531,7 +9534,7 @@ AC_CONFIG_COMMANDS_PRE( rm -f conftest.file ]) -# Copyright (C) 2009-2013 Free Software Foundation, Inc. +# Copyright (C) 2009-2014 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -9591,7 +9594,7 @@ AC_SUBST([AM_BACKSLASH])dnl _AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl ]) -# Copyright (C) 2001-2013 Free Software Foundation, Inc. +# Copyright (C) 2001-2014 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -9619,7 +9622,7 @@ fi INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" AC_SUBST([INSTALL_STRIP_PROGRAM])]) -# Copyright (C) 2006-2013 Free Software Foundation, Inc. +# Copyright (C) 2006-2014 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -9638,7 +9641,7 @@ AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)]) # Check how to create a tarball. -*- Autoconf -*- -# Copyright (C) 2004-2013 Free Software Foundation, Inc. +# Copyright (C) 2004-2014 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, diff --git a/vppinfra/config/compile b/vppinfra/config/compile index 531136b0..a85b723c 100755 --- a/vppinfra/config/compile +++ b/vppinfra/config/compile @@ -3,7 +3,7 @@ scriptversion=2012-10-14.11; # UTC -# Copyright (C) 1999-2013 Free Software Foundation, Inc. +# Copyright (C) 1999-2014 Free Software Foundation, Inc. # Written by Tom Tromey . # # This program is free software; you can redistribute it and/or modify diff --git a/vppinfra/config/config.guess b/vppinfra/config/config.guess index b79252d6..1f5c50c0 100755 --- a/vppinfra/config/config.guess +++ b/vppinfra/config/config.guess @@ -1,8 +1,8 @@ #! /bin/sh # Attempt to guess a canonical system name. -# Copyright 1992-2013 Free Software Foundation, Inc. +# Copyright 1992-2014 Free Software Foundation, Inc. -timestamp='2013-06-10' +timestamp='2014-03-23' # 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 @@ -50,7 +50,7 @@ version="\ GNU config.guess ($timestamp) Originally written by Per Bothner. -Copyright 1992-2013 Free Software Foundation, Inc. +Copyright 1992-2014 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." @@ -149,7 +149,7 @@ Linux|GNU|GNU/*) LIBC=gnu #endif EOF - eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC'` + eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC' | sed 's, ,,g'` ;; esac @@ -826,7 +826,7 @@ EOF *:MINGW*:*) echo ${UNAME_MACHINE}-pc-mingw32 exit ;; - i*:MSYS*:*) + *:MSYS*:*) echo ${UNAME_MACHINE}-pc-msys exit ;; i*:windows32*:*) @@ -969,10 +969,10 @@ EOF eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'` test x"${CPU}" != x && { echo "${CPU}-unknown-linux-${LIBC}"; exit; } ;; - or1k:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + openrisc*:Linux:*:*) + echo or1k-unknown-linux-${LIBC} exit ;; - or32:Linux:*:*) + or32:Linux:*:* | or1k*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; padre:Linux:*:*) @@ -1260,16 +1260,26 @@ EOF if test "$UNAME_PROCESSOR" = unknown ; then UNAME_PROCESSOR=powerpc fi - 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 - case $UNAME_PROCESSOR in - i386) UNAME_PROCESSOR=x86_64 ;; - powerpc) UNAME_PROCESSOR=powerpc64 ;; - esac + if test `echo "$UNAME_RELEASE" | sed -e 's/\..*//'` -le 10 ; then + 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 + case $UNAME_PROCESSOR in + i386) UNAME_PROCESSOR=x86_64 ;; + powerpc) UNAME_PROCESSOR=powerpc64 ;; + esac + fi fi + elif test "$UNAME_PROCESSOR" = i386 ; then + # Avoid executing cc on OS X 10.9, as it ships with a stub + # that puts up a graphical alert prompting to install + # developer tools. Any system running Mac OS X 10.7 or + # later (Darwin 11 and later) is required to have a 64-bit + # processor. This is not true of the ARM version of Darwin + # that Apple uses in portable devices. + UNAME_PROCESSOR=x86_64 fi echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} exit ;; @@ -1361,154 +1371,6 @@ EOF exit ;; esac -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 <." version="\ GNU config.sub ($timestamp) -Copyright 1992-2013 Free Software Foundation, Inc. +Copyright 1992-2014 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." @@ -265,6 +265,7 @@ case $basic_machine in | hexagon \ | i370 | i860 | i960 | ia64 \ | ip2k | iq2000 \ + | k1om \ | le32 | le64 \ | lm32 \ | m32c | m32r | m32rle | m68000 | m68k | m88k \ @@ -282,8 +283,10 @@ case $basic_machine in | mips64vr5900 | mips64vr5900el \ | mipsisa32 | mipsisa32el \ | mipsisa32r2 | mipsisa32r2el \ + | mipsisa32r6 | mipsisa32r6el \ | mipsisa64 | mipsisa64el \ | mipsisa64r2 | mipsisa64r2el \ + | mipsisa64r6 | mipsisa64r6el \ | mipsisa64sb1 | mipsisa64sb1el \ | mipsisa64sr71k | mipsisa64sr71kel \ | mipsr5900 | mipsr5900el \ @@ -295,11 +298,11 @@ case $basic_machine in | nds32 | nds32le | nds32be \ | nios | nios2 | nios2eb | nios2el \ | ns16k | ns32k \ - | open8 \ - | or1k | or32 \ + | open8 | or1k | or1knd | or32 \ | pdp10 | pdp11 | pj | pjl \ | powerpc | powerpc64 | powerpc64le | powerpcle \ | pyramid \ + | riscv32 | riscv64 \ | rl78 | rx \ | score \ | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ @@ -324,7 +327,7 @@ case $basic_machine in c6x) basic_machine=tic6x-unknown ;; - m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | picochip) + m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | nvptx | picochip) basic_machine=$basic_machine-unknown os=-none ;; @@ -381,6 +384,7 @@ case $basic_machine in | hexagon-* \ | i*86-* | i860-* | i960-* | ia64-* \ | ip2k-* | iq2000-* \ + | k1om-* \ | le32-* | le64-* \ | lm32-* \ | m32c-* | m32r-* | m32rle-* \ @@ -400,8 +404,10 @@ case $basic_machine in | mips64vr5900-* | mips64vr5900el-* \ | mipsisa32-* | mipsisa32el-* \ | mipsisa32r2-* | mipsisa32r2el-* \ + | mipsisa32r6-* | mipsisa32r6el-* \ | mipsisa64-* | mipsisa64el-* \ | mipsisa64r2-* | mipsisa64r2el-* \ + | mipsisa64r6-* | mipsisa64r6el-* \ | mipsisa64sb1-* | mipsisa64sb1el-* \ | mipsisa64sr71k-* | mipsisa64sr71kel-* \ | mipsr5900-* | mipsr5900el-* \ @@ -413,6 +419,7 @@ case $basic_machine in | nios-* | nios2-* | nios2eb-* | nios2el-* \ | none-* | np1-* | ns16k-* | ns32k-* \ | open8-* \ + | or1k*-* \ | orion-* \ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \ @@ -822,6 +829,10 @@ case $basic_machine in basic_machine=powerpc-unknown os=-morphos ;; + moxiebox) + basic_machine=moxie-unknown + os=-moxiebox + ;; msdos) basic_machine=i386-pc os=-msdos @@ -1367,14 +1378,14 @@ case $os in | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \ | -linux-newlib* | -linux-musl* | -linux-uclibc* \ - | -uxpv* | -beos* | -mpeix* | -udk* \ + | -uxpv* | -beos* | -mpeix* | -udk* | -moxiebox* \ | -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*) + | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es* | -tirtos*) # Remember, each alternative MUST END IN *, to match a version number. ;; -qnx*) @@ -1592,9 +1603,6 @@ case $basic_machine in mips*-*) os=-elf ;; - or1k-*) - os=-elf - ;; or32-*) os=-coff ;; diff --git a/vppinfra/config/depcomp b/vppinfra/config/depcomp index 4ebd5b3a..fc98710e 100755 --- a/vppinfra/config/depcomp +++ b/vppinfra/config/depcomp @@ -3,7 +3,7 @@ scriptversion=2013-05-30.07; # UTC -# Copyright (C) 1999-2013 Free Software Foundation, Inc. +# Copyright (C) 1999-2014 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 diff --git a/vppinfra/config/install-sh b/vppinfra/config/install-sh index 377bb868..0b0fdcbb 100755 --- a/vppinfra/config/install-sh +++ b/vppinfra/config/install-sh @@ -1,7 +1,7 @@ #!/bin/sh # install - install a program, script, or datafile -scriptversion=2011-11-20.07; # UTC +scriptversion=2013-12-25.23; # UTC # This originates from X11R5 (mit/util/scripts/install.sh), which was # later released in X11R6 (xc/config/util/install.sh) with the @@ -41,19 +41,15 @@ scriptversion=2011-11-20.07; # UTC # This script is compatible with the BSD install script, but was written # from scratch. +tab=' ' nl=' ' -IFS=" "" $nl" +IFS=" $tab$nl" -# set DOITPROG to echo to test this script +# Set DOITPROG to "echo" to test this script. -# Don't use :- since 4.3BSD and earlier shells don't like it. doit=${DOITPROG-} -if test -z "$doit"; then - doit_exec=exec -else - doit_exec=$doit -fi +doit_exec=${doit:-exec} # Put in absolute file names if you don't have them in your path; # or use environment vars. @@ -68,17 +64,6 @@ mvprog=${MVPROG-mv} rmprog=${RMPROG-rm} stripprog=${STRIPPROG-strip} -posix_glob='?' -initialize_posix_glob=' - test "$posix_glob" != "?" || { - if (set -f) 2>/dev/null; then - posix_glob= - else - posix_glob=: - fi - } -' - posix_mkdir= # Desired mode of installed file. @@ -97,7 +82,7 @@ dir_arg= dst_arg= copy_on_change=false -no_target_directory= +is_target_a_directory=possibly usage="\ Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE @@ -137,46 +122,57 @@ while test $# -ne 0; do -d) dir_arg=true;; -g) chgrpcmd="$chgrpprog $2" - shift;; + shift;; --help) echo "$usage"; exit $?;; -m) mode=$2 - case $mode in - *' '* | *' '* | *' -'* | *'*'* | *'?'* | *'['*) - echo "$0: invalid mode: $mode" >&2 - exit 1;; - esac - shift;; + case $mode in + *' '* | *"$tab"* | *"$nl"* | *'*'* | *'?'* | *'['*) + echo "$0: invalid mode: $mode" >&2 + exit 1;; + esac + shift;; -o) chowncmd="$chownprog $2" - shift;; + shift;; -s) stripcmd=$stripprog;; - -t) dst_arg=$2 - # Protect names problematic for 'test' and other utilities. - case $dst_arg in - -* | [=\(\)!]) dst_arg=./$dst_arg;; - esac - shift;; + -t) + is_target_a_directory=always + dst_arg=$2 + # Protect names problematic for 'test' and other utilities. + case $dst_arg in + -* | [=\(\)!]) dst_arg=./$dst_arg;; + esac + shift;; - -T) no_target_directory=true;; + -T) is_target_a_directory=never;; --version) echo "$0 $scriptversion"; exit $?;; - --) shift - break;; + --) shift + break;; - -*) echo "$0: invalid option: $1" >&2 - exit 1;; + -*) echo "$0: invalid option: $1" >&2 + exit 1;; *) break;; esac shift done +# We allow the use of options -d and -T together, by making -d +# take the precedence; this is for compatibility with GNU install. + +if test -n "$dir_arg"; then + if test -n "$dst_arg"; then + echo "$0: target directory not allowed when installing a directory." >&2 + exit 1 + fi +fi + if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then # When -d is used, all remaining arguments are directories to create. # When -t is used, the destination is already specified. @@ -207,6 +203,15 @@ if test $# -eq 0; then exit 0 fi +if test -z "$dir_arg"; then + if test $# -gt 1 || test "$is_target_a_directory" = always; then + if test ! -d "$dst_arg"; then + echo "$0: $dst_arg: Is not a directory." >&2 + exit 1 + fi + fi +fi + if test -z "$dir_arg"; then do_exit='(exit $ret); exit $ret' trap "ret=129; $do_exit" 1 @@ -223,16 +228,16 @@ if test -z "$dir_arg"; then *[0-7]) if test -z "$stripcmd"; then - u_plus_rw= + u_plus_rw= else - u_plus_rw='% 200' + u_plus_rw='% 200' fi cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;; *) if test -z "$stripcmd"; then - u_plus_rw= + u_plus_rw= else - u_plus_rw=,u+rw + u_plus_rw=,u+rw fi cp_umask=$mode$u_plus_rw;; esac @@ -269,41 +274,15 @@ do # If destination is a directory, append the input filename; won't work # if double slashes aren't ignored. if test -d "$dst"; then - if test -n "$no_target_directory"; then - echo "$0: $dst_arg: Is a directory" >&2 - exit 1 + if test "$is_target_a_directory" = never; then + echo "$0: $dst_arg: Is a directory" >&2 + exit 1 fi dstdir=$dst dst=$dstdir/`basename "$src"` dstdir_status=0 else - # Prefer dirname, but fall back on a substitute if dirname fails. - dstdir=` - (dirname "$dst") 2>/dev/null || - expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$dst" : 'X\(//\)[^/]' \| \ - X"$dst" : 'X\(//\)$' \| \ - X"$dst" : 'X\(/\)' \| . 2>/dev/null || - echo X"$dst" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q' - ` - + dstdir=`dirname "$dst"` test -d "$dstdir" dstdir_status=$? fi @@ -314,74 +293,74 @@ do if test $dstdir_status != 0; then case $posix_mkdir in '') - # Create intermediate dirs using mode 755 as modified by the umask. - # This is like FreeBSD 'install' as of 1997-10-28. - umask=`umask` - case $stripcmd.$umask in - # Optimize common cases. - *[2367][2367]) mkdir_umask=$umask;; - .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;; - - *[0-7]) - mkdir_umask=`expr $umask + 22 \ - - $umask % 100 % 40 + $umask % 20 \ - - $umask % 10 % 4 + $umask % 2 - `;; - *) mkdir_umask=$umask,go-w;; - esac - - # With -d, create the new directory with the user-specified mode. - # Otherwise, rely on $mkdir_umask. - if test -n "$dir_arg"; then - mkdir_mode=-m$mode - else - mkdir_mode= - fi - - posix_mkdir=false - case $umask in - *[123567][0-7][0-7]) - # POSIX mkdir -p sets u+wx bits regardless of umask, which - # is incompatible with FreeBSD 'install' when (umask & 300) != 0. - ;; - *) - tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ - trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0 - - if (umask $mkdir_umask && - exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1 - then - if test -z "$dir_arg" || { - # Check for POSIX incompatibilities with -m. - # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or - # other-writable bit of parent directory when it shouldn't. - # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. - ls_ld_tmpdir=`ls -ld "$tmpdir"` - case $ls_ld_tmpdir in - d????-?r-*) different_mode=700;; - d????-?--*) different_mode=755;; - *) false;; - esac && - $mkdirprog -m$different_mode -p -- "$tmpdir" && { - ls_ld_tmpdir_1=`ls -ld "$tmpdir"` - test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" - } - } - then posix_mkdir=: - fi - rmdir "$tmpdir/d" "$tmpdir" - else - # Remove any dirs left behind by ancient mkdir implementations. - rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null - fi - trap '' 0;; - esac;; + # Create intermediate dirs using mode 755 as modified by the umask. + # This is like FreeBSD 'install' as of 1997-10-28. + umask=`umask` + case $stripcmd.$umask in + # Optimize common cases. + *[2367][2367]) mkdir_umask=$umask;; + .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;; + + *[0-7]) + mkdir_umask=`expr $umask + 22 \ + - $umask % 100 % 40 + $umask % 20 \ + - $umask % 10 % 4 + $umask % 2 + `;; + *) mkdir_umask=$umask,go-w;; + esac + + # With -d, create the new directory with the user-specified mode. + # Otherwise, rely on $mkdir_umask. + if test -n "$dir_arg"; then + mkdir_mode=-m$mode + else + mkdir_mode= + fi + + posix_mkdir=false + case $umask in + *[123567][0-7][0-7]) + # POSIX mkdir -p sets u+wx bits regardless of umask, which + # is incompatible with FreeBSD 'install' when (umask & 300) != 0. + ;; + *) + tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ + trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0 + + if (umask $mkdir_umask && + exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1 + then + if test -z "$dir_arg" || { + # Check for POSIX incompatibilities with -m. + # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or + # other-writable bit of parent directory when it shouldn't. + # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. + ls_ld_tmpdir=`ls -ld "$tmpdir"` + case $ls_ld_tmpdir in + d????-?r-*) different_mode=700;; + d????-?--*) different_mode=755;; + *) false;; + esac && + $mkdirprog -m$different_mode -p -- "$tmpdir" && { + ls_ld_tmpdir_1=`ls -ld "$tmpdir"` + test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" + } + } + then posix_mkdir=: + fi + rmdir "$tmpdir/d" "$tmpdir" + else + # Remove any dirs left behind by ancient mkdir implementations. + rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null + fi + trap '' 0;; + esac;; esac if $posix_mkdir && ( - umask $mkdir_umask && - $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir" + umask $mkdir_umask && + $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir" ) then : else @@ -391,53 +370,51 @@ do # directory the slow way, step by step, checking for races as we go. case $dstdir in - /*) prefix='/';; - [-=\(\)!]*) prefix='./';; - *) prefix='';; + /*) prefix='/';; + [-=\(\)!]*) prefix='./';; + *) prefix='';; esac - eval "$initialize_posix_glob" - oIFS=$IFS IFS=/ - $posix_glob set -f + set -f set fnord $dstdir shift - $posix_glob set +f + set +f IFS=$oIFS prefixes= for d do - test X"$d" = X && continue - - prefix=$prefix$d - if test -d "$prefix"; then - prefixes= - else - if $posix_mkdir; then - (umask=$mkdir_umask && - $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break - # Don't fail if two instances are running concurrently. - test -d "$prefix" || exit 1 - else - case $prefix in - *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;; - *) qprefix=$prefix;; - esac - prefixes="$prefixes '$qprefix'" - fi - fi - prefix=$prefix/ + test X"$d" = X && continue + + prefix=$prefix$d + if test -d "$prefix"; then + prefixes= + else + if $posix_mkdir; then + (umask=$mkdir_umask && + $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break + # Don't fail if two instances are running concurrently. + test -d "$prefix" || exit 1 + else + case $prefix in + *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;; + *) qprefix=$prefix;; + esac + prefixes="$prefixes '$qprefix'" + fi + fi + prefix=$prefix/ done if test -n "$prefixes"; then - # Don't fail if two instances are running concurrently. - (umask $mkdir_umask && - eval "\$doit_exec \$mkdirprog $prefixes") || - test -d "$dstdir" || exit 1 - obsolete_mkdir_used=true + # Don't fail if two instances are running concurrently. + (umask $mkdir_umask && + eval "\$doit_exec \$mkdirprog $prefixes") || + test -d "$dstdir" || exit 1 + obsolete_mkdir_used=true fi fi fi @@ -472,15 +449,12 @@ do # If -C, don't bother to copy if it wouldn't change the file. if $copy_on_change && - old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` && - new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` && - - eval "$initialize_posix_glob" && - $posix_glob set -f && + old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` && + new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` && + set -f && set X $old && old=:$2:$4:$5:$6 && set X $new && new=:$2:$4:$5:$6 && - $posix_glob set +f && - + set +f && test "$old" = "$new" && $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1 then @@ -493,24 +467,24 @@ do # 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. - { - test ! -f "$dst" || - $doit $rmcmd -f "$dst" 2>/dev/null || - { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null && - { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; } - } || - { echo "$0: cannot unlink or rename $dst" >&2 - (exit 1); exit 1 - } - } && - - # Now rename the file to the real destination. - $doit $mvcmd "$dsttmp" "$dst" + # 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. + { + test ! -f "$dst" || + $doit $rmcmd -f "$dst" 2>/dev/null || + { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null && + { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; } + } || + { echo "$0: cannot unlink or rename $dst" >&2 + (exit 1); exit 1 + } + } && + + # Now rename the file to the real destination. + $doit $mvcmd "$dsttmp" "$dst" } fi || exit 1 diff --git a/vppinfra/config/ltmain.sh b/vppinfra/config/ltmain.sh index a356acaf..bffda541 100644 --- a/vppinfra/config/ltmain.sh +++ b/vppinfra/config/ltmain.sh @@ -70,7 +70,7 @@ # compiler: $LTCC # compiler flags: $LTCFLAGS # linker: $LD (gnu? $with_gnu_ld) -# $progname: (GNU libtool) 2.4.2 Debian-2.4.2-1.7ubuntu1 +# $progname: (GNU libtool) 2.4.2 Debian-2.4.2-1.11 # automake: $automake_version # autoconf: $autoconf_version # @@ -80,7 +80,7 @@ PROGRAM=libtool PACKAGE=libtool -VERSION="2.4.2 Debian-2.4.2-1.7ubuntu1" +VERSION="2.4.2 Debian-2.4.2-1.11" TIMESTAMP="" package_revision=1.3337 diff --git a/vppinfra/config/missing b/vppinfra/config/missing index db98974f..f62bbae3 100755 --- a/vppinfra/config/missing +++ b/vppinfra/config/missing @@ -3,7 +3,7 @@ scriptversion=2013-10-28.13; # UTC -# Copyright (C) 1996-2013 Free Software Foundation, Inc. +# Copyright (C) 1996-2014 Free Software Foundation, Inc. # Originally written by Fran,cois Pinard , 1996. # This program is free software; you can redistribute it and/or modify diff --git a/vppinfra/config/test-driver b/vppinfra/config/test-driver index d3060566..8e575b01 100755 --- a/vppinfra/config/test-driver +++ b/vppinfra/config/test-driver @@ -3,7 +3,7 @@ scriptversion=2013-07-13.22; # UTC -# Copyright (C) 2011-2013 Free Software Foundation, Inc. +# Copyright (C) 2011-2014 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 @@ -106,11 +106,14 @@ trap "st=143; $do_exit" 15 # Test script is run here. "$@" >$log_file 2>&1 estatus=$? + if test $enable_hard_errors = no && test $estatus -eq 99; then - estatus=1 + tweaked_estatus=1 +else + tweaked_estatus=$estatus fi -case $estatus:$expect_failure in +case $tweaked_estatus:$expect_failure in 0:yes) col=$red res=XPASS recheck=yes gcopy=yes;; 0:*) col=$grn res=PASS recheck=no gcopy=no;; 77:*) col=$blu res=SKIP recheck=no gcopy=yes;; @@ -119,6 +122,12 @@ case $estatus:$expect_failure in *:*) col=$red res=FAIL recheck=yes gcopy=yes;; esac +# Report the test outcome and exit status in the logs, so that one can +# know whether the test passed or failed simply by looking at the '.log' +# file, without the need of also peaking into the corresponding '.trs' +# file (automake bug#11814). +echo "$res $test_name (exit status: $estatus)" >>$log_file + # Report outcome to console. echo "${col}${res}${std}: $test_name" diff --git a/vppinfra/configure b/vppinfra/configure index 21bcba22..bb32295c 100755 --- a/vppinfra/configure +++ b/vppinfra/configure @@ -2231,7 +2231,7 @@ IFS=$ac_save_IFS case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac -am__api_version='1.14' +am__api_version='1.15' # Find a good install program. We prefer a C program (faster), # so one script is as good as another. But avoid the broken or @@ -2403,8 +2403,8 @@ test "$program_suffix" != NONE && 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` +# 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 @@ -2423,7 +2423,7 @@ else $as_echo "$as_me: WARNING: 'missing' script is too old or missing" >&2;} fi -if test x"${install_sh}" != xset; then +if test x"${install_sh+set}" != xset; then case $am_aux_dir in *\ * | *\ *) install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; @@ -2751,8 +2751,8 @@ MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"} # mkdir_p='$(MKDIR_P)' -# We need awk for the "check" target. The system "awk" is bad on -# some platforms. +# We need awk for the "check" target (and possibly the TAP driver). The +# system "awk" is bad on some platforms. # Always define AMTAR for backward compatibility. Yes, it's still used # in the wild :-( We should find a proper way to deprecate it ... AMTAR='$${TAR-tar}' @@ -2809,6 +2809,7 @@ END as_fn_error $? "Your 'rm' program is bad, sorry." "$LINENO" 5 fi fi + # Check whether --enable-silent-rules was given. if test "${enable_silent_rules+set}" = set; then : enableval=$enable_silent_rules; diff --git a/vppinfra/tools/elftool.c b/vppinfra/tools/elftool.c new file mode 100644 index 00000000..c0184b5c --- /dev/null +++ b/vppinfra/tools/elftool.c @@ -0,0 +1,459 @@ +/* + * Copyright (c) 2015 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/* + Copyright (c) 2008 Eliot Dresselhaus + + 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 AUTHORS OR COPYRIGHT HOLDERS BE + LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#include + +#include +#include +#include + +#ifndef CLIB_UNIX +#error "unix only" +#endif + +typedef struct { + elf_main_t elf_main; + char * input_file; + char * output_file; + char * set_interpreter; + char * set_rpath; + int unset_rpath; + int verbose; + int quiet; + int allow_elf_shared; + /* for use in the optimized / simplified case */ + u64 file_size; + u64 interpreter_offset; + u64 rpath_offset; +} elf_tool_main_t; + +static clib_error_t * elf_set_interpreter (elf_main_t * em, + elf_tool_main_t * tm) +{ + elf_segment_t * g; + elf_section_t * s; + clib_error_t * error; + char * interp = tm->set_interpreter; + + switch (em->first_header.file_type) + { + case ELF_EXEC: + break; + + case ELF_SHARED: + if (tm->allow_elf_shared) + break; + /* Note flowthrough */ + default: + return clib_error_return (0, "unacceptable file_type"); + } + + vec_foreach (g, em->segments) + { + if (g->header.type == ELF_SEGMENT_INTERP) + break; + } + + if (g >= vec_end (em->segments)) + return clib_error_return (0, "interpreter not found"); + + if (g->header.memory_size < 1 + strlen (interp)) + return clib_error_return (0, "given interpreter does not fit; must be less than %d bytes (`%s' given)", + g->header.memory_size, interp); + + error = elf_get_section_by_start_address (em, g->header.virtual_address, &s); + if (error) + return error; + + /* Put in new null terminated string. */ + memset (s->contents, 0, vec_len (s->contents)); + memcpy (s->contents, interp, strlen (interp)); + + return 0; +} + +static void +delete_rpath_for_section (elf_main_t * em, elf_section_t * s) +{ + elf64_dynamic_entry_t * e; + elf64_dynamic_entry_t * new_es = 0; + + vec_foreach (e, em->dynamic_entries) + { + switch (e->type) + { + case ELF_DYNAMIC_ENTRY_RPATH: + case ELF_DYNAMIC_ENTRY_RUN_PATH: + break; + + default: + vec_add1 (new_es, e[0]); + break; + } + } + + /* Pad so as to keep section size constant. */ + { + elf64_dynamic_entry_t e_end; + e_end.type = ELF_DYNAMIC_ENTRY_END; + e_end.data = 0; + while (vec_len (new_es) < vec_len (em->dynamic_entries)) + vec_add1 (new_es, e_end); + } + + vec_free (em->dynamic_entries); + em->dynamic_entries = new_es; + + elf_set_dynamic_entries (em); +} + +static void delete_rpath (elf_main_t * em) +{ + elf_section_t * s; + + vec_foreach (s, em->sections) + { + switch (s->header.type) + { + case ELF_SECTION_DYNAMIC: + delete_rpath_for_section (em, s); + break; + + default: + break; + } + } +} + +static clib_error_t * +set_rpath_for_section (elf_main_t * em, elf_section_t * s, char * new_rpath) +{ + elf64_dynamic_entry_t * e; + char * old_rpath; + int old_len, new_len = strlen (new_rpath); + u8 * new_string_table = vec_dup (em->dynamic_string_table); + + vec_foreach (e, em->dynamic_entries) + { + switch (e->type) + { + case ELF_DYNAMIC_ENTRY_RPATH: + case ELF_DYNAMIC_ENTRY_RUN_PATH: + old_rpath = (char *) new_string_table + e->data; + old_len = strlen (old_rpath); + if (old_len < new_len) + return clib_error_return (0, "rpath of `%s' does not fit (old rpath `%s')", + new_rpath, old_rpath); + strcpy (old_rpath, new_rpath); + break; + + default: + break; + } + } + + elf_set_section_contents (em, em->dynamic_string_table_section_index, + new_string_table, + vec_bytes (new_string_table)); + + return 0; +} + +static clib_error_t * +set_rpath (elf_main_t * em, char * rpath) +{ + clib_error_t * error = 0; + elf_section_t * s; + + vec_foreach (s, em->sections) + { + switch (s->header.type) + { + case ELF_SECTION_DYNAMIC: + error = set_rpath_for_section (em, s, rpath); + if (error) + return error; + break; + + default: + break; + } + } + + return error; +} + +static clib_error_t * +set_interpreter_rpath (elf_tool_main_t * tm) +{ + int ifd = -1, ofd = -1; + struct stat fd_stat; + u8 *idp = 0; /* warning be gone */ + u64 mmap_length = 0, i; + u32 run_length; + u8 in_run; + u64 offset0 = 0, offset1 = 0; + clib_error_t * error; + int fix_in_place = 0; + + if (!strcmp (tm->input_file, tm->output_file)) + fix_in_place = 1; + + ifd = open (tm->input_file, O_RDWR); + if (ifd < 0) + { + error = clib_error_return_unix (0, "open `%s'", tm->input_file); + goto done; + } + + if (fstat (ifd, &fd_stat) < 0) + { + error = clib_error_return_unix (0, "fstat `%s'", tm->input_file); + goto done; + } + + if (!(fd_stat.st_mode & S_IFREG)) + { + error = clib_error_return (0, "%s is not a regular file", tm->input_file); + goto done; + } + + mmap_length = fd_stat.st_size; + if (mmap_length < 4) + { + error = clib_error_return (0, "%s too short", tm->input_file); + goto done; + } + + /* COW-mapping, since we intend to write the fixups */ + if (fix_in_place) + idp = mmap (0, mmap_length, PROT_READ | PROT_WRITE, MAP_SHARED, + ifd, /* offset */ 0); + else + idp = mmap (0, mmap_length, PROT_READ | PROT_WRITE, MAP_PRIVATE, + ifd, /* offset */ 0); + if (~pointer_to_uword (idp) == 0) + { + mmap_length = 0; + error = clib_error_return_unix (0, "mmap `%s'", tm->input_file); + goto done; + } + + if (idp[0] != 0x7f || idp[1] != 'E' || idp[2] != 'L' || idp[3] != 'F') + { + error = clib_error_return (0, "not an ELF file '%s'", tm->input_file); + goto done; + } + + in_run = 0; + run_length = 0; + + for (i = 0; i < mmap_length; i++) + { + if (idp[i] == '/') + { + if (in_run) + run_length++; + else + { + in_run = 1; + run_length = 1; + } + } + else + { + if (in_run && run_length >= 16) + { + if (offset0 == 0) + offset0 = (i - run_length); + else if (offset1 == 0) + { + offset1 = (i - run_length); + goto found_both; + } + } + in_run = 0; + run_length = 0; + } + } + + if (offset0 == 0) + { + error = clib_error_return (0, "no fixup markers in %s", + tm->input_file); + goto done; + } + + found_both: + if (0) + clib_warning ("offset0 %lld (0x%llx), offset1 %lld (0x%llx)", + offset0, offset0, offset1, offset1); + + /* Executable file case */ + if (offset0 && offset1) + { + tm->interpreter_offset = offset0; + tm->rpath_offset = offset1; + } + else /* shared library case */ + { + tm->interpreter_offset = 0; + tm->rpath_offset = offset0; + } + + if (tm->interpreter_offset) + memcpy (&idp[tm->interpreter_offset], tm->set_interpreter, + strlen (tm->set_interpreter)+1); + + if (tm->rpath_offset) + memcpy (&idp[tm->rpath_offset], tm->set_rpath, + strlen (tm->set_rpath)+1); + + /* Write the output file... */ + if (fix_in_place == 0) + { + ofd = open (tm->output_file, O_RDWR | O_CREAT | O_TRUNC, 0644); + if (ofd < 0) + { + error = clib_error_return_unix (0, "create `%s'", tm->output_file); + goto done; + } + + if (write (ofd, idp, mmap_length) != mmap_length) + error = clib_error_return_unix (0, "write `%s'", tm->output_file); + } + + done: + if (mmap_length > 0) + munmap (idp, mmap_length); + close (ifd); + close (ofd); + return error; +} + + +int main (int argc, char * argv[]) +{ + elf_tool_main_t _tm, * tm = &_tm; + elf_main_t * em = &tm->elf_main; + unformat_input_t i; + clib_error_t * error = 0; + + memset (tm, 0, sizeof (tm[0])); + unformat_init_command_line (&i, argv); + + while (unformat_check_input (&i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (&i, "in %s", &tm->input_file)) + ; + else if (unformat (&i, "out %s", &tm->output_file)) + ; + else if (unformat (&i, "set-interpreter %s", &tm->set_interpreter)) + ; + else if (unformat (&i, "set-rpath %s", &tm->set_rpath)) + ; + else if (unformat (&i, "unset-rpath")) + tm->unset_rpath = 1; + else if (unformat (&i, "verbose")) + tm->verbose = ~0; + else if (unformat (&i, "verbose-symbols")) + tm->verbose |= FORMAT_ELF_MAIN_SYMBOLS; + else if (unformat (&i, "verbose-relocations")) + tm->verbose |= FORMAT_ELF_MAIN_RELOCATIONS; + else if (unformat (&i, "verbose-dynamic")) + tm->verbose |= FORMAT_ELF_MAIN_DYNAMIC; + else if (unformat (&i, "quiet")) + tm->quiet = 1; + else if (unformat (&i, "allow-elf-shared")) + tm->allow_elf_shared = 1; + else + { + error = unformat_parse_error (&i); + goto done; + } + } + + if (! tm->input_file) + clib_error ("no input file"); + + /* Do the typical case a stone-simple way... */ + if (tm->quiet && tm->set_interpreter && tm->set_rpath && tm->output_file) + { + error = set_interpreter_rpath (tm); + goto done; + } + + error = elf_read_file (em, tm->input_file); + + if (error) + goto done; + + if (tm->verbose) + fformat (stdout, "%U", format_elf_main, em, tm->verbose); + + if (tm->set_interpreter) + { + error = elf_set_interpreter (em, tm); + if (error) + goto done; + } + + if (tm->set_rpath) + { + error = set_rpath (em, tm->set_rpath); + if (error) + goto done; + } + + if (tm->unset_rpath) + delete_rpath (em); + + if (tm->output_file) + error = elf_write_file (em, tm->output_file); + + elf_main_free (em); + + done: + if (error) + { + if (tm->quiet == 0) + clib_error_report (error); + return 1; + } + else + return 0; +} diff --git a/vppversion/.gitignore b/vppversion/.gitignore deleted file mode 100644 index c4e0b5bc..00000000 --- a/vppversion/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -*~ -auto4mte.cache/* diff --git a/vppversion/Makefile.am b/vppversion/Makefile.am deleted file mode 100644 index 0296cdff..00000000 --- a/vppversion/Makefile.am +++ /dev/null @@ -1,20 +0,0 @@ -# Copyright (c) 2015 Cisco and/or its affiliates. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at: -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -AUTOMAKE_OPTIONS = foreign - -bin_PROGRAMS = elftool - -elftool_SOURCES = elftool.c -elftool_CPPFLAGS = -Wall -elftool_LDADD = -lvppinfra -lpthread -lrt -lm diff --git a/vppversion/Makefile.in b/vppversion/Makefile.in deleted file mode 100644 index 88857ba4..00000000 --- a/vppversion/Makefile.in +++ /dev/null @@ -1,816 +0,0 @@ -# Makefile.in generated by automake 1.14.1 from Makefile.am. -# @configure_input@ - -# Copyright (C) 1994-2013 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@ - -# Copyright (c) 2015 Cisco and/or its affiliates. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at: -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -VPATH = @srcdir@ -am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' -am__make_running_with_option = \ - case $${target_option-} in \ - ?) ;; \ - *) echo "am__make_running_with_option: internal error: invalid" \ - "target option '$${target_option-}' specified" >&2; \ - exit 1;; \ - esac; \ - has_opt=no; \ - sane_makeflags=$$MAKEFLAGS; \ - if $(am__is_gnu_make); then \ - sane_makeflags=$$MFLAGS; \ - else \ - case $$MAKEFLAGS in \ - *\\[\ \ ]*) \ - bs=\\; \ - sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ - | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ - esac; \ - fi; \ - skip_next=no; \ - strip_trailopt () \ - { \ - flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ - }; \ - for flg in $$sane_makeflags; do \ - test $$skip_next = yes && { skip_next=no; continue; }; \ - case $$flg in \ - *=*|--*) continue;; \ - -*I) strip_trailopt 'I'; skip_next=yes;; \ - -*I?*) strip_trailopt 'I';; \ - -*O) strip_trailopt 'O'; skip_next=yes;; \ - -*O?*) strip_trailopt 'O';; \ - -*l) strip_trailopt 'l'; skip_next=yes;; \ - -*l?*) strip_trailopt 'l';; \ - -[dEDm]) skip_next=yes;; \ - -[JT]) skip_next=yes;; \ - esac; \ - case $$flg in \ - *$$target_option*) has_opt=yes; break;; \ - esac; \ - done; \ - test $$has_opt = yes -am__make_dryrun = (target_option=n; $(am__make_running_with_option)) -am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) -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@ -bin_PROGRAMS = elftool$(EXEEXT) -subdir = . -DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ - $(top_srcdir)/configure $(am__configure_deps) depcomp compile \ - config.guess config.sub install-sh missing ltmain.sh -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(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 = $(install_sh) -d -CONFIG_CLEAN_FILES = -CONFIG_CLEAN_VPATH_FILES = -am__installdirs = "$(DESTDIR)$(bindir)" -PROGRAMS = $(bin_PROGRAMS) -am_elftool_OBJECTS = elftool-elftool.$(OBJEXT) -elftool_OBJECTS = $(am_elftool_OBJECTS) -elftool_DEPENDENCIES = -AM_V_lt = $(am__v_lt_@AM_V@) -am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) -am__v_lt_0 = --silent -am__v_lt_1 = -AM_V_P = $(am__v_P_@AM_V@) -am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) -am__v_P_0 = false -am__v_P_1 = : -AM_V_GEN = $(am__v_GEN_@AM_V@) -am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) -am__v_GEN_0 = @echo " GEN " $@; -am__v_GEN_1 = -AM_V_at = $(am__v_at_@AM_V@) -am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) -am__v_at_0 = @ -am__v_at_1 = -DEFAULT_INCLUDES = -I.@am__isrc@ -depcomp = $(SHELL) $(top_srcdir)/depcomp -am__depfiles_maybe = depfiles -am__mv = mv -f -COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ - $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ - $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ - $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ - $(AM_CFLAGS) $(CFLAGS) -AM_V_CC = $(am__v_CC_@AM_V@) -am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) -am__v_CC_0 = @echo " CC " $@; -am__v_CC_1 = -CCLD = $(CC) -LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ - $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ - $(AM_LDFLAGS) $(LDFLAGS) -o $@ -AM_V_CCLD = $(am__v_CCLD_@AM_V@) -am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) -am__v_CCLD_0 = @echo " CCLD " $@; -am__v_CCLD_1 = -SOURCES = $(elftool_SOURCES) -DIST_SOURCES = $(elftool_SOURCES) -am__can_run_installinfo = \ - case $$AM_UPDATE_INFO_DIR in \ - n|no|NO) false;; \ - *) (install-info --version) >/dev/null 2>&1;; \ - esac -am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) -# Read a list of newline-separated strings from the standard input, -# and print each of them once, without duplicates. Input order is -# *not* preserved. -am__uniquify_input = $(AWK) '\ - BEGIN { nonempty = 0; } \ - { items[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in items) print i; }; } \ -' -# Make sure the list of sources is unique. This is necessary because, -# e.g., the same source file might be shared among _SOURCES variables -# for different programs/libraries. -am__define_uniq_tagged_files = \ - list='$(am__tagged_files)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | $(am__uniquify_input)` -ETAGS = etags -CTAGS = ctags -CSCOPE = cscope -AM_RECURSIVE_TARGETS = cscope -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -distdir = $(PACKAGE)-$(VERSION) -top_distdir = $(distdir) -am__remove_distdir = \ - if test -d "$(distdir)"; then \ - find "$(distdir)" -type d ! -perm -200 -exec chmod u+w {} ';' \ - && rm -rf "$(distdir)" \ - || { sleep 5 && rm -rf "$(distdir)"; }; \ - else :; fi -am__post_remove_distdir = $(am__remove_distdir) -DIST_ARCHIVES = $(distdir).tar.gz -GZIP_ENV = --best -DIST_TARGETS = dist-gzip -distuninstallcheck_listfiles = find . -type f -print -am__distuninstallcheck_listfiles = $(distuninstallcheck_listfiles) \ - | sed 's|^\./|$(prefix)/|' | grep -v '$(infodir)/dir$$' -distcleancheck_listfiles = find . -type f -print -ACLOCAL = @ACLOCAL@ -AMTAR = @AMTAR@ -AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ -AR = @AR@ -AUTOCONF = @AUTOCONF@ -AUTOHEADER = @AUTOHEADER@ -AUTOMAKE = @AUTOMAKE@ -AWK = @AWK@ -CC = @CC@ -CCAS = @CCAS@ -CCASDEPMODE = @CCASDEPMODE@ -CCASFLAGS = @CCASFLAGS@ -CCDEPMODE = @CCDEPMODE@ -CFLAGS = @CFLAGS@ -CPP = @CPP@ -CPPFLAGS = @CPPFLAGS@ -CYGPATH_W = @CYGPATH_W@ -DEFS = @DEFS@ -DEPDIR = @DEPDIR@ -DLLTOOL = @DLLTOOL@ -DSYMUTIL = @DSYMUTIL@ -DUMPBIN = @DUMPBIN@ -ECHO_C = @ECHO_C@ -ECHO_N = @ECHO_N@ -ECHO_T = @ECHO_T@ -EGREP = @EGREP@ -EXEEXT = @EXEEXT@ -FGREP = @FGREP@ -GREP = @GREP@ -INSTALL = @INSTALL@ -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -LD = @LD@ -LDFLAGS = @LDFLAGS@ -LIBOBJS = @LIBOBJS@ -LIBS = @LIBS@ -LIBTOOL = @LIBTOOL@ -LIPO = @LIPO@ -LN_S = @LN_S@ -LTLIBOBJS = @LTLIBOBJS@ -MAKEINFO = @MAKEINFO@ -MANIFEST_TOOL = @MANIFEST_TOOL@ -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@ -RANLIB = @RANLIB@ -SED = @SED@ -SET_MAKE = @SET_MAKE@ -SHELL = @SHELL@ -STRIP = @STRIP@ -VERSION = @VERSION@ -abs_builddir = @abs_builddir@ -abs_srcdir = @abs_srcdir@ -abs_top_builddir = @abs_top_builddir@ -abs_top_srcdir = @abs_top_srcdir@ -ac_ct_AR = @ac_ct_AR@ -ac_ct_CC = @ac_ct_CC@ -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@ -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@ -mandir = @mandir@ -mkdir_p = @mkdir_p@ -oldincludedir = @oldincludedir@ -pdfdir = @pdfdir@ -prefix = @prefix@ -program_transform_name = @program_transform_name@ -psdir = @psdir@ -sbindir = @sbindir@ -sharedstatedir = @sharedstatedir@ -srcdir = @srcdir@ -sysconfdir = @sysconfdir@ -target_alias = @target_alias@ -top_build_prefix = @top_build_prefix@ -top_builddir = @top_builddir@ -top_srcdir = @top_srcdir@ -AUTOMAKE_OPTIONS = foreign -elftool_SOURCES = elftool.c -elftool_CPPFLAGS = -Wall -elftool_LDADD = -lvppinfra -lpthread -lrt -lm -all: all-am - -.SUFFIXES: -.SUFFIXES: .c .lo .o .obj -am--refresh: Makefile - @: -$(srcdir)/Makefile.in: $(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: $(am__configure_deps) - $(am__cd) $(srcdir) && $(AUTOCONF) -$(ACLOCAL_M4): $(am__aclocal_m4_deps) - $(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) -$(am__aclocal_m4_deps): -install-binPROGRAMS: $(bin_PROGRAMS) - @$(NORMAL_INSTALL) - @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ - if test -n "$$list"; then \ - echo " $(MKDIR_P) '$(DESTDIR)$(bindir)'"; \ - $(MKDIR_P) "$(DESTDIR)$(bindir)" || exit 1; \ - fi; \ - 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 - -elftool$(EXEEXT): $(elftool_OBJECTS) $(elftool_DEPENDENCIES) $(EXTRA_elftool_DEPENDENCIES) - @rm -f elftool$(EXEEXT) - $(AM_V_CCLD)$(LINK) $(elftool_OBJECTS) $(elftool_LDADD) $(LIBS) - -mostlyclean-compile: - -rm -f *.$(OBJEXT) - -distclean-compile: - -rm -f *.tab.c - -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elftool-elftool.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vlib_version.Po@am__quote@ - -.c.o: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< - -.c.obj: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` - -.c.lo: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< - -elftool-elftool.o: elftool.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(elftool_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT elftool-elftool.o -MD -MP -MF $(DEPDIR)/elftool-elftool.Tpo -c -o elftool-elftool.o `test -f 'elftool.c' || echo '$(srcdir)/'`elftool.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/elftool-elftool.Tpo $(DEPDIR)/elftool-elftool.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='elftool.c' object='elftool-elftool.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(elftool_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o elftool-elftool.o `test -f 'elftool.c' || echo '$(srcdir)/'`elftool.c - -elftool-elftool.obj: elftool.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(elftool_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT elftool-elftool.obj -MD -MP -MF $(DEPDIR)/elftool-elftool.Tpo -c -o elftool-elftool.obj `if test -f 'elftool.c'; then $(CYGPATH_W) 'elftool.c'; else $(CYGPATH_W) '$(srcdir)/elftool.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/elftool-elftool.Tpo $(DEPDIR)/elftool-elftool.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='elftool.c' object='elftool-elftool.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(elftool_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o elftool-elftool.obj `if test -f 'elftool.c'; then $(CYGPATH_W) 'elftool.c'; else $(CYGPATH_W) '$(srcdir)/elftool.c'; fi` - -mostlyclean-libtool: - -rm -f *.lo - -clean-libtool: - -rm -rf .libs _libs - -distclean-libtool: - -rm -f libtool config.lt - -ID: $(am__tagged_files) - $(am__define_uniq_tagged_files); mkid -fID $$unique -tags: tags-am -TAGS: tags - -tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) - set x; \ - here=`pwd`; \ - $(am__define_uniq_tagged_files); \ - 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-am - -CTAGS: ctags -ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) - $(am__define_uniq_tagged_files); \ - 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" -cscope: cscope.files - test ! -s cscope.files \ - || $(CSCOPE) -b -q $(AM_CSCOPEFLAGS) $(CSCOPEFLAGS) -i cscope.files $(CSCOPE_ARGS) -clean-cscope: - -rm -f cscope.files -cscope.files: clean-cscope cscopelist -cscopelist: cscopelist-am - -cscopelist-am: $(am__tagged_files) - list='$(am__tagged_files)'; \ - case "$(srcdir)" in \ - [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ - *) sdir=$(subdir)/$(srcdir) ;; \ - esac; \ - for i in $$list; do \ - if test -f "$$i"; then \ - echo "$(subdir)/$$i"; \ - else \ - echo "$$sdir/$$i"; \ - fi; \ - done >> $(top_builddir)/cscope.files - -distclean-tags: - -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags - -rm -f cscope.out cscope.in.out cscope.po.out cscope.files - -distdir: $(DISTFILES) - $(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 - -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__post_remove_distdir) - -dist-bzip2: distdir - tardir=$(distdir) && $(am__tar) | BZIP2=$${BZIP2--9} bzip2 -c >$(distdir).tar.bz2 - $(am__post_remove_distdir) - -dist-lzip: distdir - tardir=$(distdir) && $(am__tar) | lzip -c $${LZIP_OPT--9} >$(distdir).tar.lz - $(am__post_remove_distdir) - -dist-xz: distdir - tardir=$(distdir) && $(am__tar) | XZ_OPT=$${XZ_OPT--e} xz -c >$(distdir).tar.xz - $(am__post_remove_distdir) - -dist-tarZ: distdir - @echo WARNING: "Support for shar distribution archives is" \ - "deprecated." >&2 - @echo WARNING: "It will be removed altogether in Automake 2.0" >&2 - tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z - $(am__post_remove_distdir) - -dist-shar: distdir - @echo WARNING: "Support for distribution archives compressed with" \ - "legacy program 'compress' is deprecated." >&2 - @echo WARNING: "It will be removed altogether in Automake 2.0" >&2 - shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz - $(am__post_remove_distdir) - -dist-zip: distdir - -rm -f $(distdir).zip - zip -rq $(distdir).zip $(distdir) - $(am__post_remove_distdir) - -dist dist-all: - $(MAKE) $(AM_MAKEFLAGS) $(DIST_TARGETS) am__post_remove_distdir='@:' - $(am__post_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.lz*) \ - lzip -dc $(distdir).tar.lz | $(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 u+w $(distdir) - mkdir $(distdir)/_build $(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 \ - $(AM_DISTCHECK_CONFIGURE_FLAGS) \ - $(DISTCHECK_CONFIGURE_FLAGS) \ - --srcdir=.. --prefix="$$dc_install_base" \ - && $(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__post_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: - @test -n '$(distuninstallcheck_dir)' || { \ - echo 'ERROR: trying to run $@ with an empty' \ - '$$(distuninstallcheck_dir)' >&2; \ - exit 1; \ - }; \ - $(am__cd) '$(distuninstallcheck_dir)' || { \ - echo 'ERROR: cannot chdir into $(distuninstallcheck_dir)' >&2; \ - exit 1; \ - }; \ - test `$(am__distuninstallcheck_listfiles) | wc -l` -eq 0 \ - || { 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-am -all-am: Makefile $(PROGRAMS) -installdirs: - for dir in "$(DESTDIR)$(bindir)"; 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: - if test -z '$(STRIP)'; then \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - install; \ - else \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ - fi -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: clean-am - -clean-am: clean-binPROGRAMS clean-generic clean-libtool mostlyclean-am - -distclean: distclean-am - -rm -f $(am__CONFIG_DISTCLEAN_FILES) - -rm -rf ./$(DEPDIR) - -rm -f Makefile -distclean-am: clean-am distclean-compile distclean-generic \ - distclean-libtool 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-binPROGRAMS - -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 $(am__CONFIG_DISTCLEAN_FILES) - -rm -rf $(top_srcdir)/autom4te.cache - -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-binPROGRAMS - -.MAKE: install-am install-strip - -.PHONY: CTAGS GTAGS TAGS all all-am am--refresh check check-am clean \ - clean-binPROGRAMS clean-cscope clean-generic clean-libtool \ - cscope cscopelist-am ctags ctags-am dist dist-all dist-bzip2 \ - dist-gzip dist-lzip dist-shar dist-tarZ dist-xz dist-zip \ - distcheck distclean distclean-compile distclean-generic \ - distclean-libtool distclean-tags distcleancheck distdir \ - distuninstallcheck 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-pdf install-pdf-am \ - install-ps install-ps-am install-strip installcheck \ - installcheck-am installdirs maintainer-clean \ - maintainer-clean-generic mostlyclean mostlyclean-compile \ - mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ - tags tags-am uninstall uninstall-am uninstall-binPROGRAMS - - -# 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/vppversion/aclocal.m4 b/vppversion/aclocal.m4 deleted file mode 100644 index b08df583..00000000 --- a/vppversion/aclocal.m4 +++ /dev/null @@ -1,9771 +0,0 @@ -# generated automatically by aclocal 1.14.1 -*- Autoconf -*- - -# Copyright (C) 1996-2013 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_CONFIG_MACRO_DIRS], [m4_defun([_AM_CONFIG_MACRO_DIRS], [])m4_defun([AC_CONFIG_MACRO_DIRS], [_AM_CONFIG_MACRO_DIRS($@)])]) -m4_ifndef([AC_AUTOCONF_VERSION], - [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl -m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.69],, -[m4_warning([this file was generated for autoconf 2.69. -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, 2009, 2010, 2011 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, 2009, 2010, 2011 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 57 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_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl -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 - -_LT_SHELL_INIT([SHELL=${CONFIG_SHELL-/bin/sh}]) - -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 "$cc_temp" | $SED "s%.*/%%; 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 -AC_REQUIRE([_LT_PREPARE_SED_QUOTE_VARS])dnl -AC_REQUIRE([_LT_PROG_ECHO_BACKSLASH])dnl - -_LT_DECL([], [PATH_SEPARATOR], [1], [The PATH separator for the build system])dnl -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_PATH_CONVERSION_FUNCTIONS])dnl -m4_require([_LT_CMD_RELOAD])dnl -m4_require([_LT_CHECK_MAGIC_METHOD])dnl -m4_require([_LT_CHECK_SHAREDLIB_FROM_LINKLIB])dnl -m4_require([_LT_CMD_OLD_ARCHIVE])dnl -m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl -m4_require([_LT_WITH_SYSROOT])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 - -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 - -# 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_PREPARE_SED_QUOTE_VARS -# -------------------------- -# Define a few sed substitution that help us do robust quoting. -m4_defun([_LT_PREPARE_SED_QUOTE_VARS], -[# Backslashify 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' -]) - -# _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 "$][$1" | $SED "$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 "$" | $SED "$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' - -# A function that is used when there is no print builtin or printf. -func_fallback_echo () -{ - eval 'cat <<_LTECHO_EOF -\$[]1 -_LTECHO_EOF' -} - -# Quote evaled strings. -for var in lt_decl_all_varnames([[ \ -]], lt_decl_quote_varnames); do - case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in - *[[\\\\\\\`\\"\\\$]]*) - eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED \\"\\\$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 \\\\""\\\\\$\$var"\\\\"\` in - *[[\\\\\\\`\\"\\\$]]*) - eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\"" - ;; - *) - eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" - ;; - esac -done - -_LT_OUTPUT_LIBTOOL_INIT -]) - -# _LT_GENERATED_FILE_INIT(FILE, [COMMENT]) -# ------------------------------------ -# Generate a child script FILE with all initialization necessary to -# reuse the environment learned by the parent script, and make the -# file executable. If COMMENT is supplied, it is inserted after the -# `#!' sequence but before initialization text begins. After this -# macro, additional text can be appended to FILE to form the body of -# the child script. The macro ends with non-zero status if the -# file could not be fully written (such as if the disk is full). -m4_ifdef([AS_INIT_GENERATED], -[m4_defun([_LT_GENERATED_FILE_INIT],[AS_INIT_GENERATED($@)])], -[m4_defun([_LT_GENERATED_FILE_INIT], -[m4_require([AS_PREPARE])]dnl -[m4_pushdef([AS_MESSAGE_LOG_FD])]dnl -[lt_write_fail=0 -cat >$1 <<_ASEOF || lt_write_fail=1 -#! $SHELL -# Generated by $as_me. -$2 -SHELL=\${CONFIG_SHELL-$SHELL} -export SHELL -_ASEOF -cat >>$1 <<\_ASEOF || lt_write_fail=1 -AS_SHELL_SANITIZE -_AS_PREPARE -exec AS_MESSAGE_FD>&1 -_ASEOF -test $lt_write_fail = 0 && chmod +x $1[]dnl -m4_popdef([AS_MESSAGE_LOG_FD])])])# _LT_GENERATED_FILE_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]) -_LT_GENERATED_FILE_INIT(["$CONFIG_LT"], -[# Run this file to recreate a libtool stub with the current configuration.]) - -cat >>"$CONFIG_LT" <<\_LTEOF -lt_cl_silent=false -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) 2011 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. -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) -])# 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 '$q' "$ltmain" >> "$cfgfile" \ - || (rm -f "$cfgfile"; exit 1) - - _LT_PROG_REPLACE_SHELLFNS - - 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)], - [Go], [_LT_LANG(GO)], - [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 - - -m4_ifndef([AC_PROG_GO], [ -# NOTE: This macro has been submitted for inclusion into # -# GNU Autoconf as AC_PROG_GO. When it is available in # -# a released version of Autoconf we should remove this # -# macro and use it instead. # -m4_defun([AC_PROG_GO], -[AC_LANG_PUSH(Go)dnl -AC_ARG_VAR([GOC], [Go compiler command])dnl -AC_ARG_VAR([GOFLAGS], [Go compiler flags])dnl -_AC_ARG_VAR_LDFLAGS()dnl -AC_CHECK_TOOL(GOC, gccgo) -if test -z "$GOC"; then - if test -n "$ac_tool_prefix"; then - AC_CHECK_PROG(GOC, [${ac_tool_prefix}gccgo], [${ac_tool_prefix}gccgo]) - fi -fi -if test -z "$GOC"; then - AC_CHECK_PROG(GOC, gccgo, gccgo, false) -fi -])#m4_defun -])#m4_ifndef - - -# _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([AC_PROG_GO], - [LT_LANG(GO)], - [m4_define([AC_PROG_GO], defn([AC_PROG_GO])[LT_LANG(GO)])]) - -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)]) -AU_DEFUN([AC_LIBTOOL_RC], [LT_LANG(Windows Resource)]) -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], []) -dnl AC_DEFUN([AC_LIBTOOL_RC], []) - - -# _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 there is a non-empty error log, and "single_module" - # appears in it, assume the flag caused a linker warning - if test -s conftest.err && $GREP single_module conftest.err; then - cat conftest.err >&AS_MESSAGE_LOG_FD - # Otherwise, if the output was created with a 0 exit code from - # the compiler, it worked. - elif test -f libconftest.dylib && test $_lt_result -eq 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" - ]) - - AC_CACHE_CHECK([for -force_load linker flag],[lt_cv_ld_force_load], - [lt_cv_ld_force_load=no - cat > conftest.c << _LT_EOF -int forced_loaded() { return 2;} -_LT_EOF - echo "$LTCC $LTCFLAGS -c -o conftest.o conftest.c" >&AS_MESSAGE_LOG_FD - $LTCC $LTCFLAGS -c -o conftest.o conftest.c 2>&AS_MESSAGE_LOG_FD - echo "$AR cru libconftest.a conftest.o" >&AS_MESSAGE_LOG_FD - $AR cru libconftest.a conftest.o 2>&AS_MESSAGE_LOG_FD - echo "$RANLIB libconftest.a" >&AS_MESSAGE_LOG_FD - $RANLIB libconftest.a 2>&AS_MESSAGE_LOG_FD - cat > conftest.c << _LT_EOF -int main() { return 0;} -_LT_EOF - echo "$LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a" >&AS_MESSAGE_LOG_FD - $LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a 2>conftest.err - _lt_result=$? - if test -s conftest.err && $GREP force_load conftest.err; then - cat conftest.err >&AS_MESSAGE_LOG_FD - elif test -f conftest && test $_lt_result -eq 0 && $GREP forced_load conftest >/dev/null 2>&1 ; then - lt_cv_ld_force_load=yes - else - cat conftest.err >&AS_MESSAGE_LOG_FD - fi - rm -f conftest.err libconftest.a conftest conftest.c - rm -rf conftest.dSYM - ]) - 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" != ":" && test "$lt_cv_ld_force_load" = "no"; then - _lt_dsymutil='~$DSYMUTIL $lib || :' - else - _lt_dsymutil= - fi - ;; - esac -]) - - -# _LT_DARWIN_LINKER_FEATURES([TAG]) -# --------------------------------- -# 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 - if test "$lt_cv_ld_force_load" = "yes"; then - _LT_TAGVAR(whole_archive_flag_spec, $1)='`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience ${wl}-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`' - m4_case([$1], [F77], [_LT_TAGVAR(compiler_needs_object, $1)=yes], - [FC], [_LT_TAGVAR(compiler_needs_object, $1)=yes]) - else - _LT_TAGVAR(whole_archive_flag_spec, $1)='' - fi - _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=func_echo_all - _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([TAGNAME]) -# ---------------------------------- -# 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. -# Store the results from the different compilers for each TAGNAME. -# Allow to override them for all tags through lt_cv_aix_libpath. -m4_defun([_LT_SYS_MODULE_PATH_AIX], -[m4_require([_LT_DECL_SED])dnl -if test "${lt_cv_aix_libpath+set}" = set; then - aix_libpath=$lt_cv_aix_libpath -else - AC_CACHE_VAL([_LT_TAGVAR([lt_cv_aix_libpath_], [$1])], - [AC_LINK_IFELSE([AC_LANG_PROGRAM],[ - lt_aix_libpath_sed='[ - /Import File Strings/,/^$/ { - /^0/ { - s/^0 *\([^ ]*\) *$/\1/ - p - } - }]' - _LT_TAGVAR([lt_cv_aix_libpath_], [$1])=`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 "$_LT_TAGVAR([lt_cv_aix_libpath_], [$1])"; then - _LT_TAGVAR([lt_cv_aix_libpath_], [$1])=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` - fi],[]) - if test -z "$_LT_TAGVAR([lt_cv_aix_libpath_], [$1])"; then - _LT_TAGVAR([lt_cv_aix_libpath_], [$1])="/usr/lib:/lib" - fi - ]) - aix_libpath=$_LT_TAGVAR([lt_cv_aix_libpath_], [$1]) -fi -])# _LT_SYS_MODULE_PATH_AIX - - -# _LT_SHELL_INIT(ARG) -# ------------------- -m4_define([_LT_SHELL_INIT], -[m4_divert_text([M4SH-INIT], [$1 -])])# _LT_SHELL_INIT - - - -# _LT_PROG_ECHO_BACKSLASH -# ----------------------- -# Find how we can fake an echo command that does not interpret backslash. -# In particular, with Autoconf 2.60 or later we add some code to the start -# of the generated configure script which will find a shell with a builtin -# printf (which we can use as an echo command). -m4_defun([_LT_PROG_ECHO_BACKSLASH], -[ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' -ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO -ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO - -AC_MSG_CHECKING([how to print strings]) -# Test print first, because it will be a builtin if present. -if test "X`( print -r -- -n ) 2>/dev/null`" = X-n && \ - test "X`print -r -- $ECHO 2>/dev/null`" = "X$ECHO"; then - ECHO='print -r --' -elif test "X`printf %s $ECHO 2>/dev/null`" = "X$ECHO"; then - ECHO='printf %s\n' -else - # Use this function as a fallback that always works. - func_fallback_echo () - { - eval 'cat <<_LTECHO_EOF -$[]1 -_LTECHO_EOF' - } - ECHO='func_fallback_echo' -fi - -# func_echo_all arg... -# Invoke $ECHO with all args, space-separated. -func_echo_all () -{ - $ECHO "$*" -} - -case "$ECHO" in - printf*) AC_MSG_RESULT([printf]) ;; - print*) AC_MSG_RESULT([print -r]) ;; - *) AC_MSG_RESULT([cat]) ;; -esac - -m4_ifdef([_AS_DETECT_SUGGESTED], -[_AS_DETECT_SUGGESTED([ - test -n "${ZSH_VERSION+set}${BASH_VERSION+set}" || ( - ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' - ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO - ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO - PATH=/empty FPATH=/empty; export PATH FPATH - test "X`printf %s $ECHO`" = "X$ECHO" \ - || test "X`print -r -- $ECHO`" = "X$ECHO" )])]) - -_LT_DECL([], [SHELL], [1], [Shell to use when invoking shell scripts]) -_LT_DECL([], [ECHO], [1], [An echo program that protects backslashes]) -])# _LT_PROG_ECHO_BACKSLASH - - -# _LT_WITH_SYSROOT -# ---------------- -AC_DEFUN([_LT_WITH_SYSROOT], -[AC_MSG_CHECKING([for sysroot]) -AC_ARG_WITH([sysroot], -[ --with-sysroot[=DIR] Search for dependent libraries within DIR - (or the compiler's sysroot if not specified).], -[], [with_sysroot=no]) - -dnl lt_sysroot will always be passed unquoted. We quote it here -dnl in case the user passed a directory name. -lt_sysroot= -case ${with_sysroot} in #( - yes) - if test "$GCC" = yes; then - lt_sysroot=`$CC --print-sysroot 2>/dev/null` - fi - ;; #( - /*) - lt_sysroot=`echo "$with_sysroot" | sed -e "$sed_quote_subst"` - ;; #( - no|'') - ;; #( - *) - AC_MSG_RESULT([${with_sysroot}]) - AC_MSG_ERROR([The sysroot must be an absolute path.]) - ;; -esac - - AC_MSG_RESULT([${lt_sysroot:-no}]) -_LT_DECL([], [lt_sysroot], [0], [The root where to search for ]dnl -[dependent libraries, and in which our libraries should be installed.])]) - -# _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 '$LINENO' "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*|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*) - case `/usr/bin/file conftest.o` in - *x86-64*) - LD="${LD-ld} -m elf32_x86_64" - ;; - *) - LD="${LD-ld} -m elf_i386" - ;; - esac - ;; - powerpc64le-*) - LD="${LD-ld} -m elf32lppclinux" - ;; - powerpc64-*) - 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" - ;; - powerpcle-*) - LD="${LD-ld} -m elf64lppc" - ;; - powerpc-*) - 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 - ;; -*-*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*) - case $host in - i?86-*-solaris*) - LD="${LD-ld} -m elf_x86_64" - ;; - sparc*-*-solaris*) - LD="${LD-ld} -m elf64_sparc" - ;; - esac - # GNU ld 2.21 introduced _sol2 emulations. Use them if available. - if ${LD-ld} -V | grep _sol2 >/dev/null 2>&1; then - LD="${LD-ld}_sol2" - fi - ;; - *) - 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_PROG_AR -# ----------- -m4_defun([_LT_PROG_AR], -[AC_CHECK_TOOLS(AR, [ar], false) -: ${AR=ar} -: ${AR_FLAGS=cru} -_LT_DECL([], [AR], [1], [The archiver]) -_LT_DECL([], [AR_FLAGS], [1], [Flags to create an archive]) - -AC_CACHE_CHECK([for archiver @FILE support], [lt_cv_ar_at_file], - [lt_cv_ar_at_file=no - AC_COMPILE_IFELSE([AC_LANG_PROGRAM], - [echo conftest.$ac_objext > conftest.lst - lt_ar_try='$AR $AR_FLAGS libconftest.a @conftest.lst >&AS_MESSAGE_LOG_FD' - AC_TRY_EVAL([lt_ar_try]) - if test "$ac_status" -eq 0; then - # Ensure the archiver fails upon bogus file names. - rm -f conftest.$ac_objext libconftest.a - AC_TRY_EVAL([lt_ar_try]) - if test "$ac_status" -ne 0; then - lt_cv_ar_at_file=@ - fi - fi - rm -f conftest.* libconftest.a - ]) - ]) - -if test "x$lt_cv_ar_at_file" = xno; then - archiver_list_spec= -else - archiver_list_spec=$lt_cv_ar_at_file -fi -_LT_DECL([], [archiver_list_spec], [1], - [How to feed a file listing to the archiver]) -])# _LT_PROG_AR - - -# _LT_CMD_OLD_ARCHIVE -# ------------------- -m4_defun([_LT_CMD_OLD_ARCHIVE], -[_LT_PROG_AR - -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 \$tool_oldlib" - ;; - *) - old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$tool_oldlib" - ;; - esac - old_archive_cmds="$old_archive_cmds~\$RANLIB \$tool_oldlib" -fi - -case $host_os in - darwin*) - lock_old_archive_extraction=yes ;; - *) - lock_old_archive_extraction=no ;; -esac -_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_DECL([], [lock_old_archive_extraction], [0], - [Whether to use a lock for old archive extraction]) -])# _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:$LINENO: $lt_compile\"" >&AS_MESSAGE_LOG_FD) - (eval "$lt_compile" 2>conftest.err) - ac_status=$? - cat conftest.err >&AS_MESSAGE_LOG_FD - echo "$as_me:$LINENO: \$? = $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 "$_lt_compiler_boilerplate" | $SED '/^$/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 "$_lt_linker_boilerplate" | $SED '/^$/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; - ;; - - mint*) - # On MiNT this can take a long time and run out of memory. - 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 - ;; - - os2*) - # The test takes a long time on OS/2. - lt_cv_sys_max_cmd_len=8192 - ;; - - 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" && \ - test undefined != "$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"`env echo "$teststring$teststring" 2>/dev/null` \ - = "X$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 $LINENO "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 - -/* When -fvisbility=hidden is used, assume the code has been annotated - correspondingly for the symbols needed. */ -#if defined(__GNUC__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3)) -int fnord () __attribute__((visibility("default"))); -#endif - -int fnord () { return 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; - else puts (dlerror ()); - } - /* 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:$LINENO: $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:$LINENO: \$? = $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 "$_lt_compiler_boilerplate" | $SED '/^$/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 -m4_require([_LT_CHECK_SHELL_FEATURES])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 - case $host_os in - mingw* | cegcc*) lt_sed_strip_eq="s,=\([[A-Za-z]]:\),\1,g" ;; - *) lt_sed_strip_eq="s,=/,/,g" ;; - esac - lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e $lt_sed_strip_eq` - case $lt_search_path_spec in - *\;*) - # 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 's/;/ /g'` - ;; - *) - lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED "s/$PATH_SEPARATOR/ /g"` - ;; - esac - # 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; } -}'` - # AWK program above erroneously prepends '/' to C:/dos/paths - # for these hosts. - case $host_os in - mingw* | cegcc*) lt_search_path_spec=`$ECHO "$lt_search_path_spec" |\ - $SED 's,/\([[A-Za-z]]:\),\1,g'` ;; - esac - sys_lib_search_path_spec=`$ECHO "$lt_search_path_spec" | $lt_NL2SP` -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 # correct to gnu/linux during the next big refactor - 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 # correct to gnu/linux during the next big refactor - 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=`func_echo_all "$lib" | $SED '\''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 # correct to gnu/linux during the next big refactor - 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,$cc_basename in - yes,*) - # gcc - 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}' -m4_if([$1], [],[ - sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api"]) - ;; - mingw* | cegcc*) - # MinGW DLLs use traditional 'lib' prefix - soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' - ;; - 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 - dynamic_linker='Win32 ld.exe' - ;; - - *,cl*) - # Native MSVC - libname_spec='$name' - soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' - library_names_spec='${libname}.dll.lib' - - case $build_os in - mingw*) - sys_lib_search_path_spec= - lt_save_ifs=$IFS - IFS=';' - for lt_path in $LIB - do - IFS=$lt_save_ifs - # Let DOS variable expansion print the short 8.3 style file name. - lt_path=`cd "$lt_path" 2>/dev/null && cmd //C "for %i in (".") do @echo %~si"` - sys_lib_search_path_spec="$sys_lib_search_path_spec $lt_path" - done - IFS=$lt_save_ifs - # Convert to MSYS style. - sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | sed -e 's|\\\\|/|g' -e 's| \\([[a-zA-Z]]\\):| /\\1|g' -e 's|^ ||'` - ;; - cygwin*) - # Convert to unix form, then to dos form, then back to unix form - # but this time dos style (no spaces!) so that the unix form looks - # like /cygdrive/c/PROGRA~1:/cygdr... - sys_lib_search_path_spec=`cygpath --path --unix "$LIB"` - sys_lib_search_path_spec=`cygpath --path --dos "$sys_lib_search_path_spec" 2>/dev/null` - sys_lib_search_path_spec=`cygpath --path --unix "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` - ;; - *) - sys_lib_search_path_spec="$LIB" - if $ECHO "$sys_lib_search_path_spec" | [$GREP ';[c-zC-Z]:/' >/dev/null]; then - # It is most probably a Windows format PATH. - 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 - # FIXME: find the short name or the path components, as spaces are - # common. (e.g. "Program Files" -> "PROGRA~1") - ;; - esac - - # 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' - postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ - dlpath=$dir/\$dldll~ - $RM \$dlpath' - shlibpath_overrides_runpath=yes - dynamic_linker='Win32 link.exe' - ;; - - *) - # Assume MSVC wrapper - library_names_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext} $libname.lib' - dynamic_linker='Win32 ld.exe' - ;; - esac - # 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 # correct to gnu/linux during the next big refactor - 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 - ;; - -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[[23]].*) 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 - ;; - -haiku*) - version_type=linux # correct to gnu/linux during the next big refactor - need_lib_prefix=no - need_version=no - dynamic_linker="$host_os runtime_loader" - 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=LIBRARY_PATH - shlibpath_overrides_runpath=yes - sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib' - 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' - # or fails outright, so override atomically: - install_override_mode=555 - ;; - -interix[[3-9]]*) - version_type=linux # correct to gnu/linux during the next big refactor - 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 # correct to gnu/linux during the next big refactor - 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 glibc/ELF. -linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) - version_type=linux # correct to gnu/linux during the next big refactor - 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 - AC_CACHE_VAL([lt_cv_shlibpath_overrides_runpath], - [lt_cv_shlibpath_overrides_runpath=no - 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], - [lt_cv_shlibpath_overrides_runpath=yes])]) - LDFLAGS=$save_LDFLAGS - libdir=$save_libdir - ]) - shlibpath_overrides_runpath=$lt_cv_shlibpath_overrides_runpath - - # 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;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' - ;; - -netbsdelf*-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 - shlibpath_overrides_runpath=no - hardcode_into_libs=yes - dynamic_linker='NetBSD ld.elf_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 # correct to gnu/linux during the next big refactor - 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 # correct to gnu/linux during the next big refactor - 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 # correct to gnu/linux during the next big refactor - 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 # correct to gnu/linux during the next big refactor - 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 # correct to gnu/linux during the next big refactor - 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 # correct to gnu/linux during the next big refactor - 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([], [install_override_mode], [1], - [Permission mode override for installation of shared libraries]) -_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 -m4_require([_LT_PROG_ECHO_BACKSLASH])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 - # Keep this pattern in sync with the one in func_win32_libid. - lt_cv_deplibs_check_method='file_magic file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' - 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 - ;; - -haiku*) - 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])(-bit)?( [LM]SB)? 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 glibc/ELF. -linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) - lt_cv_deplibs_check_method=pass_all - ;; - -netbsd* | netbsdelf*-gnu) - 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_glob= -want_nocaseglob=no -if test "$build" = "$host"; then - case $host_os in - mingw* | pw32*) - if ( shopt | grep nocaseglob ) >/dev/null 2>&1; then - want_nocaseglob=yes - else - file_magic_glob=`echo aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ | $SED -e "s/\(..\)/s\/[[\1]]\/[[\1]]\/g;/g"` - fi - ;; - esac -fi - -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_DECL([], [file_magic_glob], [1], - [How to find potential files when deplibs_check_method = "file_magic"]) -_LT_DECL([], [want_nocaseglob], [1], - [Find potential files using nocaseglob 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. - if test -n "$DUMPBIN"; then : - # Let the user override the test. - else - AC_CHECK_TOOLS(DUMPBIN, [dumpbin "link -dump"], :) - case `$DUMPBIN -symbols /dev/null 2>&1 | sed '1q'` in - *COFF*) - DUMPBIN="$DUMPBIN -symbols" - ;; - *) - DUMPBIN=: - ;; - esac - fi - 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:$LINENO: $ac_compile\"" >&AS_MESSAGE_LOG_FD) - (eval "$ac_compile" 2>conftest.err) - cat conftest.err >&AS_MESSAGE_LOG_FD - (eval echo "\"\$as_me:$LINENO: $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:$LINENO: 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_CHECK_SHAREDLIB_FROM_LINKLIB -# -------------------------------- -# how to determine the name of the shared library -# associated with a specific link library. -# -- PORTME fill in with the dynamic library characteristics -m4_defun([_LT_CHECK_SHAREDLIB_FROM_LINKLIB], -[m4_require([_LT_DECL_EGREP]) -m4_require([_LT_DECL_OBJDUMP]) -m4_require([_LT_DECL_DLLTOOL]) -AC_CACHE_CHECK([how to associate runtime and link libraries], -lt_cv_sharedlib_from_linklib_cmd, -[lt_cv_sharedlib_from_linklib_cmd='unknown' - -case $host_os in -cygwin* | mingw* | pw32* | cegcc*) - # two different shell functions defined in ltmain.sh - # decide which to use based on capabilities of $DLLTOOL - case `$DLLTOOL --help 2>&1` in - *--identify-strict*) - lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib - ;; - *) - lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib_fallback - ;; - esac - ;; -*) - # fallback: assume linklib IS sharedlib - lt_cv_sharedlib_from_linklib_cmd="$ECHO" - ;; -esac -]) -sharedlib_from_linklib_cmd=$lt_cv_sharedlib_from_linklib_cmd -test -z "$sharedlib_from_linklib_cmd" && sharedlib_from_linklib_cmd=$ECHO - -_LT_DECL([], [sharedlib_from_linklib_cmd], [1], - [Command to associate shared and link libraries]) -])# _LT_CHECK_SHAREDLIB_FROM_LINKLIB - - -# _LT_PATH_MANIFEST_TOOL -# ---------------------- -# locate the manifest tool -m4_defun([_LT_PATH_MANIFEST_TOOL], -[AC_CHECK_TOOL(MANIFEST_TOOL, mt, :) -test -z "$MANIFEST_TOOL" && MANIFEST_TOOL=mt -AC_CACHE_CHECK([if $MANIFEST_TOOL is a manifest tool], [lt_cv_path_mainfest_tool], - [lt_cv_path_mainfest_tool=no - echo "$as_me:$LINENO: $MANIFEST_TOOL '-?'" >&AS_MESSAGE_LOG_FD - $MANIFEST_TOOL '-?' 2>conftest.err > conftest.out - cat conftest.err >&AS_MESSAGE_LOG_FD - if $GREP 'Manifest Tool' conftest.out > /dev/null; then - lt_cv_path_mainfest_tool=yes - fi - rm -f conftest*]) -if test "x$lt_cv_path_mainfest_tool" != xyes; then - MANIFEST_TOOL=: -fi -_LT_DECL([], [MANIFEST_TOOL], [1], [Manifest tool])dnl -])# _LT_PATH_MANIFEST_TOOL - - -# LT_LIB_M -# -------- -# check for math library -AC_DEFUN([LT_LIB_M], -[AC_REQUIRE([AC_CANONICAL_HOST])dnl -LIBM= -case $host in -*-*-beos* | *-*-cegcc* | *-*-cygwin* | *-*-haiku* | *-*-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 - case $cc_basename in - nvcc*) - _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -Xcompiler -fno-builtin' ;; - *) - _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin' ;; - esac - - _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([AC_PROG_AWK])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};"\ -" /^COFF SYMBOL TABLE/{for(i in hide) delete hide[i]};"\ -" /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 - lt_cv_sys_global_symbol_pipe="$lt_cv_sys_global_symbol_pipe | sed '/ __gnu_lto/d'" - - # 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 -/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ -#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE) -/* DATA imports from DLLs on WIN32 con't be const, because runtime - relocations are performed -- see ld's documentation on pseudo-relocs. */ -# define LT@&t@_DLSYM_CONST -#elif defined(__osf__) -/* This system does not cope well with relocations in const data. */ -# define LT@&t@_DLSYM_CONST -#else -# define LT@&t@_DLSYM_CONST const -#endif - -#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. */ -LT@&t@_DLSYM_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_globsym_save_LIBS=$LIBS - lt_globsym_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_globsym_save_LIBS - CFLAGS=$lt_globsym_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 - -# Response file support. -if test "$lt_cv_nm_interface" = "MS dumpbin"; then - nm_file_list_spec='@' -elif $NM --help 2>/dev/null | grep '[[@]]FILE' >/dev/null; then - nm_file_list_spec='@' -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_DECL([], [nm_file_list_spec], [1], - [Specify filename containing input files for $NM]) -]) # _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)= - -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)= - ;; - haiku*) - # PIC is the default for Haiku. - # The "-static" flag exists, but is broken. - _LT_TAGVAR(lt_prog_compiler_static, $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 - ;; - 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). - m4_if([$1], [GCJ], [], - [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) - ;; - 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 | kopensolaris*-gnu | 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* | bgxl[[cC]]* | mpixl[[cC]]*) - # IBM XL 8.0, 9.0 on PPC and BlueGene - _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* | netbsdelf*-gnu) - ;; - *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* | sunCC*) - # 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' - ;; - - haiku*) - # PIC is the default for Haiku. - # The "-static" flag exists, but is broken. - _LT_TAGVAR(lt_prog_compiler_static, $1)= - ;; - - 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 - - case $cc_basename in - nvcc*) # Cuda Compiler Driver 2.2 - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Xlinker ' - if test -n "$_LT_TAGVAR(lt_prog_compiler_pic, $1)"; then - _LT_TAGVAR(lt_prog_compiler_pic, $1)="-Xcompiler $_LT_TAGVAR(lt_prog_compiler_pic, $1)" - fi - ;; - 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 | kopensolaris*-gnu | 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' - ;; - nagfor*) - # NAG Fortran compiler - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,-Wl,,' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - ;; - pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*) - # 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* | bgxl* | bgf* | mpixl*) - # IBM XL C 8.0/Fortran 10.1, 11.1 on PPC and BlueGene - _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\ Ceres\ Fortran* | *Sun*Fortran*\ [[1-7]].* | *Sun*Fortran*\ 8.[[0-3]]*) - # 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)='' - ;; - *Sun\ F* | *Sun*Fortran*) - _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 ' - ;; - *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,' - ;; - *Intel*\ [[CF]]*Compiler*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' - ;; - *Portland\ Group*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - ;; - 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* | sunf77* | sunf90* | sunf95*) - _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_CACHE_CHECK([for $compiler option to produce PIC], - [_LT_TAGVAR(lt_cv_prog_compiler_pic, $1)], - [_LT_TAGVAR(lt_cv_prog_compiler_pic, $1)=$_LT_TAGVAR(lt_prog_compiler_pic, $1)]) -_LT_TAGVAR(lt_prog_compiler_pic, $1)=$_LT_TAGVAR(lt_cv_prog_compiler_pic, $1) - -# -# 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]) - -_LT_TAGDECL([wl], [lt_prog_compiler_wl], [1], - [How to pass a linker flag through the compiler]) -# -# 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_PATH_MANIFEST_TOOL])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' - _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'] - 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 - # Also, AIX nm treats weak defined symbols like other global defined - # symbols, whereas GNU nm marks them as "W". - 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") || (\$ 2 == "W")) && ([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*) - case $cc_basename in - cl*) - _LT_TAGVAR(exclude_expsyms, $1)='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*' - ;; - *) - _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/;s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.* //'\'' | sort | uniq > $export_symbols' - _LT_TAGVAR(exclude_expsyms, $1)=['[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname'] - ;; - esac - ;; - linux* | k*bsd*-gnu | gnu*) - _LT_TAGVAR(link_all_deplibs, $1)=no - ;; - *) - _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' - ;; - esac -], [ - 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_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 - ;; - linux* | k*bsd*-gnu | gnu*) - _LT_TAGVAR(link_all_deplibs, $1)=no - ;; - esac - - _LT_TAGVAR(ld_shlibs, $1)=yes - - # On some targets, GNU ld is compatible enough with the native linker - # that we're better off using the native interface for both. - lt_use_gnu_ld_interface=no - if test "$with_gnu_ld" = yes; then - case $host_os in - aix*) - # The AIX port of GNU ld has always aspired to compatibility - # with the native linker. However, as the warning in the GNU ld - # block says, versions before 2.19.5* couldn't really create working - # shared libraries, regardless of the interface used. - case `$LD -v 2>&1` in - *\ \(GNU\ Binutils\)\ 2.19.5*) ;; - *\ \(GNU\ Binutils\)\ 2.[[2-9]]*) ;; - *\ \(GNU\ Binutils\)\ [[3-9]]*) ;; - *) - lt_use_gnu_ld_interface=yes - ;; - esac - ;; - *) - lt_use_gnu_ld_interface=yes - ;; - esac - fi - - if test "$lt_use_gnu_ld_interface" = 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 - *GNU\ gold*) supports_anon_versioning=yes ;; - *\ [[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.19, 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 install binutils -*** 2.20 or above, or modify your PATH so that a non-GNU linker is found. -*** You will then need to restart the configuration process. - -_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(export_dynamic_flag_spec, $1)='${wl}--export-all-symbols' - _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/;s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.* //'\'' | sort | uniq > $export_symbols' - _LT_TAGVAR(exclude_expsyms, $1)=['[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname'] - - 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 - ;; - - haiku*) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - _LT_TAGVAR(link_all_deplibs, $1)=yes - ;; - - 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 | kopensolaris*-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=' $pic_flag' - 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; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' - tmp_addflag=' $pic_flag' - ;; - pgf77* | pgf90* | pgf95* | pgfortran*) - # 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; func_echo_all \"$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]]* | bgxl[[cC]]* | mpixl[[cC]]*) # IBM XL C 8.0 on PPC (deal with xlf below) - tmp_sharedflag='-qmkshrobj' - tmp_addflag= ;; - nvcc*) # Cuda Compiler Driver 2.2 - _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' - _LT_TAGVAR(compiler_needs_object, $1)=yes - ;; - 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; func_echo_all \"$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* | bgf* | bgxlf* | mpixlf*) - # 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)='${wl}-rpath ${wl}$libdir' - _LT_TAGVAR(archive_cmds, $1)='$LD -shared $libobjs $deplibs $linker_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 $linker_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib' - fi - ;; - esac - else - _LT_TAGVAR(ld_shlibs, $1)=no - fi - ;; - - netbsd* | netbsdelf*-gnu) - 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 $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $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 $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $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 $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $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 - # Also, AIX nm treats weak defined symbols like other global - # defined symbols, whereas GNU nm marks them as "W". - 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") || (\$ 2 == "W")) && ([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 - _LT_TAGVAR(link_all_deplibs, $1)=no - 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([$1]) - _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 func_echo_all "${wl}${allow_undefined_flag}"; 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([$1]) - _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' - if test "$with_gnu_ld" = yes; then - # We only use this code for GNU lds that support --whole-archive. - _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive' - else - # Exported symbols can be pulled into shared objects from archives - _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience' - fi - _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. - case $cc_basename in - cl*) - # Native MSVC - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' - _LT_TAGVAR(allow_undefined_flag, $1)=unsupported - _LT_TAGVAR(always_export_symbols, $1)=yes - _LT_TAGVAR(file_list_spec, $1)='@' - # 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 $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames=' - _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then - sed -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp; - else - sed -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp; - fi~ - $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~ - linknames=' - # The linker will not automatically build a static lib if we build a DLL. - # _LT_TAGVAR(old_archive_from_new_cmds, $1)='true' - _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes - _LT_TAGVAR(exclude_expsyms, $1)='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*' - _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' - # Don't use ranlib - _LT_TAGVAR(old_postinstall_cmds, $1)='chmod 644 $oldlib' - _LT_TAGVAR(postlink_cmds, $1)='lt_outputfile="@OUTPUT@"~ - lt_tool_outputfile="@TOOL_OUTPUT@"~ - case $lt_outputfile in - *.exe|*.EXE) ;; - *) - lt_outputfile="$lt_outputfile.exe" - lt_tool_outputfile="$lt_tool_outputfile.exe" - ;; - esac~ - if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then - $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1; - $RM "$lt_outputfile.manifest"; - fi' - ;; - *) - # Assume MSVC wrapper - _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 `func_echo_all "$deplibs" | $SED '\''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(enable_shared_with_static_runtimes, $1)=yes - ;; - esac - ;; - - 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 - ;; - - # 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 $pic_flag -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 $pic_flag ${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 && test "$with_gnu_ld" = no; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${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_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 && test "$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 $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' - ;; - *) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${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' - ;; - *) - m4_if($1, [], [ - # Older versions of the 11.00 compiler do not understand -b yet - # (HP92453-01 A.11.01.20 doesn't, HP92453-01 B.11.X.35175-35176.GP does) - _LT_LINKER_OPTION([if $CC understands -b], - _LT_TAGVAR(lt_cv_prog_compiler__b, $1), [-b], - [_LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'], - [_LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_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 $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${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. - # This should be the same for all languages, so no per-tag cache variable. - AC_CACHE_CHECK([whether the $host_os linker accepts -exported_symbol], - [lt_cv_irix_exported_symbol], - [save_LDFLAGS="$LDFLAGS" - LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null" - AC_LINK_IFELSE( - [AC_LANG_SOURCE( - [AC_LANG_CASE([C], [[int foo (void) { return 0; }]], - [C++], [[int foo (void) { return 0; }]], - [Fortran 77], [[ - subroutine foo - end]], - [Fortran], [[ - subroutine foo - end]])])], - [lt_cv_irix_exported_symbol=yes], - [lt_cv_irix_exported_symbol=no]) - LDFLAGS="$save_LDFLAGS"]) - if test "$lt_cv_irix_exported_symbol" = yes; then - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib' - fi - else - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -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" && func_echo_all "-set_version $verstring"` -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* | netbsdelf*-gnu) - 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" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${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" && func_echo_all "-set_version $verstring"` -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} $pic_flag $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${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" && func_echo_all "-set_version $verstring"` -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 "-set_version $verstring"` -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 $pic_flag ${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 $pic_flag ${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_CACHE_CHECK([whether -lc should be explicitly linked in], - [lt_cv_]_LT_TAGVAR(archive_cmds_need_lc, $1), - [$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_cv_[]_LT_TAGVAR(archive_cmds_need_lc, $1)=no - else - lt_cv_[]_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* - ]) - _LT_TAGVAR(archive_cmds_need_lc, $1)=$lt_cv_[]_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_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([], [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([], [postlink_cmds], [2], - [Commands necessary for finishing linking programs]) -_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_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], -[m4_require([_LT_FILEUTILS_DEFAULTS])dnl -m4_require([_LT_DECL_EGREP])dnl -m4_require([_LT_PATH_MANIFEST_TOOL])dnl -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 - -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_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(reload_flag, $1)=$reload_flag -_LT_TAGVAR(reload_cmds, $1)=$reload_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_CFLAGS=$CFLAGS - 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++"} - CFLAGS=$CXXFLAGS - 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 $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC $pic_flag -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 -v "^Configured with:" | $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([$1]) - _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 func_echo_all "${wl}${allow_undefined_flag}"; 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([$1]) - _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' - if test "$with_gnu_ld" = yes; then - # We only use this code for GNU lds that support --whole-archive. - _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive' - else - # Exported symbols can be pulled into shared objects from archives - _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience' - fi - _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*) - case $GXX,$cc_basename in - ,cl* | no,cl*) - # Native MSVC - # 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 - _LT_TAGVAR(always_export_symbols, $1)=yes - _LT_TAGVAR(file_list_spec, $1)='@' - # 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 $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames=' - _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then - $SED -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp; - else - $SED -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp; - fi~ - $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~ - linknames=' - # The linker will not automatically build a static lib if we build a DLL. - # _LT_TAGVAR(old_archive_from_new_cmds, $1)='true' - _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes - # Don't use ranlib - _LT_TAGVAR(old_postinstall_cmds, $1)='chmod 644 $oldlib' - _LT_TAGVAR(postlink_cmds, $1)='lt_outputfile="@OUTPUT@"~ - lt_tool_outputfile="@TOOL_OUTPUT@"~ - case $lt_outputfile in - *.exe|*.EXE) ;; - *) - lt_outputfile="$lt_outputfile.exe" - lt_tool_outputfile="$lt_tool_outputfile.exe" - ;; - esac~ - func_to_tool_file "$lt_outputfile"~ - if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then - $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1; - $RM "$lt_outputfile.manifest"; - fi' - ;; - *) - # g++ - # _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(export_dynamic_flag_spec, $1)='${wl}--export-all-symbols' - _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 - ;; - esac - ;; - 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 - ;; - - freebsd2.*) - # 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 - ;; - - haiku*) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - _LT_TAGVAR(link_all_deplibs, $1)=yes - ;; - - 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; func_echo_all "$list"' - ;; - *) - if test "$GXX" = yes; then - _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared -nostdlib $pic_flag ${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; func_echo_all "$list"' - ;; - *) - 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 $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' - ;; - *) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $pic_flag ${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" && func_echo_all "-set_version $verstring"` -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 $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' - else - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` -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 | kopensolaris*-gnu | 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; func_echo_all "$list"' - - _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 | sort | $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 | sort | $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 | sort | $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 | sort | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib' - ;; - *) # Version 6 and above 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; func_echo_all \"$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=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "X$list" | $Xsed' - ;; - xl* | mpixl* | bgxl*) - # 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; func_echo_all \"$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='func_echo_all' - - # 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=func_echo_all - 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" && func_echo_all "${wl}-set_version $verstring"` -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" && func_echo_all "-set_version $verstring"` -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 "-set_version $verstring"` -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=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' - ;; - *) - if test "$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" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' - ;; - *) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${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 -v "^Configured with:" | $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* | sunCC*) - # 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='func_echo_all' - - # 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 $pic_flag -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 $pic_flag -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 -v "^Configured with:" | $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 -v "^Configured with:" | $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(old_archive_cmds, $1)='$CC -Tprelink_objects $oldobjs~ - '"$_LT_TAGVAR(old_archive_cmds, $1)" - _LT_TAGVAR(reload_cmds, $1)='$CC -Tprelink_objects $reload_objs~ - '"$_LT_TAGVAR(reload_cmds, $1)" - ;; - *) - _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 - CFLAGS=$lt_save_CFLAGS - 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_FUNC_STRIPNAME_CNF -# ---------------------- -# func_stripname_cnf 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). -# -# This function is identical to the (non-XSI) version of func_stripname, -# except this one can be used by m4 code that may be executed by configure, -# rather than the libtool script. -m4_defun([_LT_FUNC_STRIPNAME_CNF],[dnl -AC_REQUIRE([_LT_DECL_SED]) -AC_REQUIRE([_LT_PROG_ECHO_BACKSLASH]) -func_stripname_cnf () -{ - case ${2} in - .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;; - *) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;; - esac -} # func_stripname_cnf -])# _LT_FUNC_STRIPNAME_CNF - -# _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 -AC_REQUIRE([_LT_FUNC_STRIPNAME_CNF])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 -], [$1], [GO], [cat > conftest.$ac_ext <<_LT_EOF -package foo -func foo() { -} -_LT_EOF -]) - -_lt_libdeps_save_CFLAGS=$CFLAGS -case "$CC $CFLAGS " in #( -*\ -flto*\ *) CFLAGS="$CFLAGS -fno-lto" ;; -*\ -fwhopr*\ *) CFLAGS="$CFLAGS -fno-whopr" ;; -*\ -fuse-linker-plugin*\ *) CFLAGS="$CFLAGS -fno-use-linker-plugin" ;; -esac - -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 ${prev}${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 - fi - - # Expand the sysroot to ease extracting the directories later. - if test -z "$prev"; then - case $p in - -L*) func_stripname_cnf '-L' '' "$p"; prev=-L; p=$func_stripname_result ;; - -R*) func_stripname_cnf '-R' '' "$p"; prev=-R; p=$func_stripname_result ;; - -l*) func_stripname_cnf '-l' '' "$p"; prev=-l; p=$func_stripname_result ;; - esac - fi - case $p in - =*) func_stripname_cnf '=' '' "$p"; p=$lt_sysroot$func_stripname_result ;; - esac - if test "$pre_test_object_deps_done" = no; then - case ${prev} 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 - prev= - ;; - - *.lto.$objext) ;; # Ignore GCC LTO objects - *.$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 -CFLAGS=$_lt_libdeps_save_CFLAGS - -# 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* | sunCC*) - # 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_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_LANG_PUSH(Fortran 77) -if test -z "$F77" || test "X$F77" = "Xno"; then - _lt_disable_F77=yes -fi - -_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_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(reload_flag, $1)=$reload_flag -_LT_TAGVAR(reload_cmds, $1)=$reload_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 - lt_save_CFLAGS=$CFLAGS - CC=${F77-"f77"} - CFLAGS=$FFLAGS - 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" - CFLAGS="$lt_save_CFLAGS" -fi # test "$_lt_disable_F77" != yes - -AC_LANG_POP -])# _LT_LANG_F77_CONFIG - - -# _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_LANG_PUSH(Fortran) - -if test -z "$FC" || test "X$FC" = "Xno"; then - _lt_disable_FC=yes -fi - -_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_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(reload_flag, $1)=$reload_flag -_LT_TAGVAR(reload_cmds, $1)=$reload_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 - lt_save_CFLAGS=$CFLAGS - CC=${FC-"f95"} - CFLAGS=$FCFLAGS - 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 - CFLAGS=$lt_save_CFLAGS -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_CFLAGS=$CFLAGS -lt_save_GCC=$GCC -GCC=yes -CC=${GCJ-"gcj"} -CFLAGS=$GCJFLAGS -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 -_LT_TAGVAR(reload_flag, $1)=$reload_flag -_LT_TAGVAR(reload_cmds, $1)=$reload_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 -CFLAGS=$lt_save_CFLAGS -])# _LT_LANG_GCJ_CONFIG - - -# _LT_LANG_GO_CONFIG([TAG]) -# -------------------------- -# Ensure that the configuration variables for the GNU Go compiler -# are suitably defined. These variables are subsequently used by _LT_CONFIG -# to write the compiler configuration to `libtool'. -m4_defun([_LT_LANG_GO_CONFIG], -[AC_REQUIRE([LT_PROG_GO])dnl -AC_LANG_SAVE - -# Source file extension for Go test sources. -ac_ext=go - -# Object file extension for compiled Go test sources. -objext=o -_LT_TAGVAR(objext, $1)=$objext - -# Code to be used in simple compile tests -lt_simple_compile_test_code="package main; func main() { }" - -# Code to be used in simple link tests -lt_simple_link_test_code='package main; func main() { }' - -# 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_CFLAGS=$CFLAGS -lt_save_GCC=$GCC -GCC=yes -CC=${GOC-"gccgo"} -CFLAGS=$GOFLAGS -compiler=$CC -_LT_TAGVAR(compiler, $1)=$CC -_LT_TAGVAR(LD, $1)="$LD" -_LT_CC_BASENAME([$compiler]) - -# Go 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 -_LT_TAGVAR(reload_flag, $1)=$reload_flag -_LT_TAGVAR(reload_cmds, $1)=$reload_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 -CFLAGS=$lt_save_CFLAGS -])# _LT_LANG_GO_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_CFLAGS=$CFLAGS -lt_save_GCC=$GCC -GCC= -CC=${RC-"windres"} -CFLAGS= -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 -CFLAGS=$lt_save_CFLAGS -])# _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_GO -# ---------- -AC_DEFUN([LT_PROG_GO], -[AC_CHECK_TOOL(GOC, gccgo,) -]) - - -# 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_DLLTOOL -# ---------------- -# Ensure DLLTOOL variable is set. -m4_defun([_LT_DECL_DLLTOOL], -[AC_CHECK_TOOL(DLLTOOL, dlltool, false) -test -z "$DLLTOOL" && DLLTOOL=dlltool -_LT_DECL([], [DLLTOOL], [1], [DLL creation program]) -AC_SUBST([DLLTOOL]) -]) - -# _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%"$_lt_dummy"}, \ - = c,a/b,b/c, \ - && 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_FUNCTION_REPLACE (FUNCNAME, REPLACEMENT-BODY) -# ------------------------------------------------------ -# In `$cfgfile', look for function FUNCNAME delimited by `^FUNCNAME ()$' and -# '^} FUNCNAME ', and replace its body with REPLACEMENT-BODY. -m4_defun([_LT_PROG_FUNCTION_REPLACE], -[dnl { -sed -e '/^$1 ()$/,/^} # $1 /c\ -$1 ()\ -{\ -m4_bpatsubsts([$2], [$], [\\], [^\([ ]\)], [\\\1]) -} # Extended-shell $1 implementation' "$cfgfile" > $cfgfile.tmp \ - && mv -f "$cfgfile.tmp" "$cfgfile" \ - || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") -test 0 -eq $? || _lt_function_replace_fail=: -]) - - -# _LT_PROG_REPLACE_SHELLFNS -# ------------------------- -# Replace existing portable implementations of several shell functions with -# equivalent extended shell implementations where those features are available.. -m4_defun([_LT_PROG_REPLACE_SHELLFNS], -[if test x"$xsi_shell" = xyes; then - _LT_PROG_FUNCTION_REPLACE([func_dirname], [dnl - case ${1} in - */*) func_dirname_result="${1%/*}${2}" ;; - * ) func_dirname_result="${3}" ;; - esac]) - - _LT_PROG_FUNCTION_REPLACE([func_basename], [dnl - func_basename_result="${1##*/}"]) - - _LT_PROG_FUNCTION_REPLACE([func_dirname_and_basename], [dnl - case ${1} in - */*) func_dirname_result="${1%/*}${2}" ;; - * ) func_dirname_result="${3}" ;; - esac - func_basename_result="${1##*/}"]) - - _LT_PROG_FUNCTION_REPLACE([func_stripname], [dnl - # 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}"}]) - - _LT_PROG_FUNCTION_REPLACE([func_split_long_opt], [dnl - func_split_long_opt_name=${1%%=*} - func_split_long_opt_arg=${1#*=}]) - - _LT_PROG_FUNCTION_REPLACE([func_split_short_opt], [dnl - func_split_short_opt_arg=${1#??} - func_split_short_opt_name=${1%"$func_split_short_opt_arg"}]) - - _LT_PROG_FUNCTION_REPLACE([func_lo2o], [dnl - case ${1} in - *.lo) func_lo2o_result=${1%.lo}.${objext} ;; - *) func_lo2o_result=${1} ;; - esac]) - - _LT_PROG_FUNCTION_REPLACE([func_xform], [ func_xform_result=${1%.*}.lo]) - - _LT_PROG_FUNCTION_REPLACE([func_arith], [ func_arith_result=$(( $[*] ))]) - - _LT_PROG_FUNCTION_REPLACE([func_len], [ func_len_result=${#1}]) -fi - -if test x"$lt_shell_append" = xyes; then - _LT_PROG_FUNCTION_REPLACE([func_append], [ eval "${1}+=\\${2}"]) - - _LT_PROG_FUNCTION_REPLACE([func_append_quoted], [dnl - func_quote_for_eval "${2}" -dnl m4 expansion turns \\\\ into \\, and then the shell eval turns that into \ - eval "${1}+=\\\\ \\$func_quote_for_eval_result"]) - - # Save a `func_append' function call where possible by direct use of '+=' - sed -e 's%func_append \([[a-zA-Z_]]\{1,\}\) "%\1+="%g' $cfgfile > $cfgfile.tmp \ - && mv -f "$cfgfile.tmp" "$cfgfile" \ - || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") - test 0 -eq $? || _lt_function_replace_fail=: -else - # Save a `func_append' function call even when '+=' is not available - sed -e 's%func_append \([[a-zA-Z_]]\{1,\}\) "%\1="$\1%g' $cfgfile > $cfgfile.tmp \ - && mv -f "$cfgfile.tmp" "$cfgfile" \ - || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") - test 0 -eq $? || _lt_function_replace_fail=: -fi - -if test x"$_lt_function_replace_fail" = x":"; then - AC_MSG_WARN([Unable to substitute extended shell functions in $ofile]) -fi -]) - -# _LT_PATH_CONVERSION_FUNCTIONS -# ----------------------------- -# Determine which file name conversion functions should be used by -# func_to_host_file (and, implicitly, by func_to_host_path). These are needed -# for certain cross-compile configurations and native mingw. -m4_defun([_LT_PATH_CONVERSION_FUNCTIONS], -[AC_REQUIRE([AC_CANONICAL_HOST])dnl -AC_REQUIRE([AC_CANONICAL_BUILD])dnl -AC_MSG_CHECKING([how to convert $build file names to $host format]) -AC_CACHE_VAL(lt_cv_to_host_file_cmd, -[case $host in - *-*-mingw* ) - case $build in - *-*-mingw* ) # actually msys - lt_cv_to_host_file_cmd=func_convert_file_msys_to_w32 - ;; - *-*-cygwin* ) - lt_cv_to_host_file_cmd=func_convert_file_cygwin_to_w32 - ;; - * ) # otherwise, assume *nix - lt_cv_to_host_file_cmd=func_convert_file_nix_to_w32 - ;; - esac - ;; - *-*-cygwin* ) - case $build in - *-*-mingw* ) # actually msys - lt_cv_to_host_file_cmd=func_convert_file_msys_to_cygwin - ;; - *-*-cygwin* ) - lt_cv_to_host_file_cmd=func_convert_file_noop - ;; - * ) # otherwise, assume *nix - lt_cv_to_host_file_cmd=func_convert_file_nix_to_cygwin - ;; - esac - ;; - * ) # unhandled hosts (and "normal" native builds) - lt_cv_to_host_file_cmd=func_convert_file_noop - ;; -esac -]) -to_host_file_cmd=$lt_cv_to_host_file_cmd -AC_MSG_RESULT([$lt_cv_to_host_file_cmd]) -_LT_DECL([to_host_file_cmd], [lt_cv_to_host_file_cmd], - [0], [convert $build file names to $host format])dnl - -AC_MSG_CHECKING([how to convert $build file names to toolchain format]) -AC_CACHE_VAL(lt_cv_to_tool_file_cmd, -[#assume ordinary cross tools, or native build. -lt_cv_to_tool_file_cmd=func_convert_file_noop -case $host in - *-*-mingw* ) - case $build in - *-*-mingw* ) # actually msys - lt_cv_to_tool_file_cmd=func_convert_file_msys_to_w32 - ;; - esac - ;; -esac -]) -to_tool_file_cmd=$lt_cv_to_tool_file_cmd -AC_MSG_RESULT([$lt_cv_to_tool_file_cmd]) -_LT_DECL([to_tool_file_cmd], [lt_cv_to_tool_file_cmd], - [0], [convert $build files to toolchain format])dnl -])# _LT_PATH_CONVERSION_FUNCTIONS - -# Helper functions for option handling. -*- Autoconf -*- -# -# Copyright (C) 2004, 2005, 2007, 2008, 2009 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 7 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], [1], [Assembler program])dnl - -test -z "$DLLTOOL" && DLLTOOL=dlltool -_LT_DECL([], [DLLTOOL], [1], [DLL creation program])dnl - -test -z "$OBJDUMP" && OBJDUMP=objdump -_LT_DECL([], [OBJDUMP], [1], [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@<:@=PKGS@:>@], - [try to use only PIC/non-PIC objects @<:@default=use both@:>@])], - [lt_p=${PACKAGE-default} - case $withval in - yes|no) pic_mode=$withval ;; - *) - pic_mode=default - # Look at the argument we got. We use all the common list separators. - lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," - for lt_pkg in $withval; do - IFS="$lt_save_ifs" - if test "X$lt_pkg" = "X$lt_p"; then - pic_mode=yes - fi - done - IFS="$lt_save_ifs" - ;; - esac], - [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. - -# @configure_input@ - -# serial 3337 ltversion.m4 -# This file is part of GNU Libtool - -m4_define([LT_PACKAGE_VERSION], [2.4.2]) -m4_define([LT_PACKAGE_REVISION], [1.3337]) - -AC_DEFUN([LTVERSION_VERSION], -[macro_version='2.4.2' -macro_revision='1.3337' -_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, 2009 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 5 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_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])]) -m4_ifndef([_LT_REQUIRED_DARWIN_CHECKS], [AC_DEFUN([_LT_REQUIRED_DARWIN_CHECKS])]) -m4_ifndef([_LT_AC_PROG_CXXCPP], [AC_DEFUN([_LT_AC_PROG_CXXCPP])]) -m4_ifndef([_LT_PREPARE_SED_QUOTE_VARS], [AC_DEFUN([_LT_PREPARE_SED_QUOTE_VARS])]) -m4_ifndef([_LT_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_PROG_ECHO_BACKSLASH])]) -m4_ifndef([_LT_PROG_F77], [AC_DEFUN([_LT_PROG_F77])]) -m4_ifndef([_LT_PROG_FC], [AC_DEFUN([_LT_PROG_FC])]) -m4_ifndef([_LT_PROG_CXX], [AC_DEFUN([_LT_PROG_CXX])]) - -# Copyright (C) 2002-2013 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.14' -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.14.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.14.1])dnl -m4_ifndef([AC_AUTOCONF_VERSION], - [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl -_AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))]) - -# Figure out how to run the assembler. -*- Autoconf -*- - -# Copyright (C) 2001-2013 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_AS -# ---------- -AC_DEFUN([AM_PROG_AS], -[# By default we simply use the C compiler to build assembly code. -AC_REQUIRE([AC_PROG_CC]) -test "${CCAS+set}" = set || CCAS=$CC -test "${CCASFLAGS+set}" = set || CCASFLAGS=$CFLAGS -AC_ARG_VAR([CCAS], [assembler compiler command (defaults to CC)]) -AC_ARG_VAR([CCASFLAGS], [assembler compiler flags (defaults to CFLAGS)]) -_AM_IF_OPTION([no-dependencies],, [_AM_DEPENDENCIES([CCAS])])dnl -]) - -# AM_AUX_DIR_EXPAND -*- Autoconf -*- - -# Copyright (C) 2001-2013 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-2013 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_CONDITIONAL(NAME, SHELL-CONDITION) -# ------------------------------------- -# Define a conditional. -AC_DEFUN([AM_CONDITIONAL], -[AC_PREREQ([2.52])dnl - m4_if([$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-2013 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. - - -# 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", "OBJC", "OBJCXX", "UPC", or "GJC". -# 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 - -m4_if([$1], [CC], [depcc="$CC" am_compiler_list=], - [$1], [CXX], [depcc="$CXX" am_compiler_list=], - [$1], [OBJC], [depcc="$OBJC" am_compiler_list='gcc3 gcc'], - [$1], [OBJCXX], [depcc="$OBJCXX" 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". - rm -rf conftest.dir - 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 10 /bin/sh. - echo '/* dummy */' > 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 - ;; - msvc7 | msvc7msys | 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], [dnl -AS_HELP_STRING( - [--enable-dependency-tracking], - [do not reject slow dependency extractors]) -AS_HELP_STRING( - [--disable-dependency-tracking], - [speeds up one-time build])]) -if test "x$enable_dependency_tracking" != xno; then - am_depcomp="$ac_aux_dir/depcomp" - AMDEPBACKSLASH='\' - am__nodep='_no' -fi -AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno]) -AC_SUBST([AMDEPBACKSLASH])dnl -_AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl -AC_SUBST([am__nodep])dnl -_AM_SUBST_NOTMAKE([am__nodep])dnl -]) - -# Generate code to set up dependency tracking. -*- Autoconf -*- - -# Copyright (C) 1999-2013 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_OUTPUT_DEPENDENCY_COMMANDS -# ------------------------------ -AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS], -[{ - # Older Autoconf 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"` - # 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'`; 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"]) -]) - -# Do all the work for Automake. -*- Autoconf -*- - -# Copyright (C) 1996-2013 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 macro actually does too much. Some checks are only needed if -# your package does certain things. But this isn't really a big deal. - -dnl Redefine AC_PROG_CC to automatically invoke _AM_PROG_CC_C_O. -m4_define([AC_PROG_CC], -m4_defn([AC_PROG_CC]) -[_AM_PROG_CC_C_O -]) - -# 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.65])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], -[AC_DIAGNOSE([obsolete], - [$0: two- and three-arguments forms are deprecated.]) -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], [ok]):m4_ifdef([AC_PACKAGE_VERSION], [ok]), - [ok:ok],, - [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([AC_PROG_MKDIR_P])dnl -# For better backward compatibility. To be removed once Automake 1.9.x -# dies out for good. For more background, see: -# -# -AC_SUBST([mkdir_p], ['$(MKDIR_P)']) -# 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])], - [m4_define([AC_PROG_CC], - m4_defn([AC_PROG_CC])[_AM_DEPENDENCIES([CC])])])dnl -AC_PROVIDE_IFELSE([AC_PROG_CXX], - [_AM_DEPENDENCIES([CXX])], - [m4_define([AC_PROG_CXX], - m4_defn([AC_PROG_CXX])[_AM_DEPENDENCIES([CXX])])])dnl -AC_PROVIDE_IFELSE([AC_PROG_OBJC], - [_AM_DEPENDENCIES([OBJC])], - [m4_define([AC_PROG_OBJC], - m4_defn([AC_PROG_OBJC])[_AM_DEPENDENCIES([OBJC])])])dnl -AC_PROVIDE_IFELSE([AC_PROG_OBJCXX], - [_AM_DEPENDENCIES([OBJCXX])], - [m4_define([AC_PROG_OBJCXX], - m4_defn([AC_PROG_OBJCXX])[_AM_DEPENDENCIES([OBJCXX])])])dnl -]) -AC_REQUIRE([AM_SILENT_RULES])dnl -dnl The testsuite driver may need to know about EXEEXT, so add the -dnl 'am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen. This -dnl macro 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 - -# POSIX will say in a future version that running "rm -f" with no argument -# is OK; and we want to be able to make that assumption in our Makefile -# recipes. So use an aggressive probe to check that the usage we want is -# actually supported "in the wild" to an acceptable degree. -# See automake bug#10828. -# To make any issue more visible, cause the running configure to be aborted -# by default if the 'rm' program in use doesn't match our expectations; the -# user can still override this though. -if rm -f && rm -fr && rm -rf; then : OK; else - cat >&2 <<'END' -Oops! - -Your 'rm' program seems unable to run without file operands specified -on the command line, even when the '-f' option is present. This is contrary -to the behaviour of most rm programs out there, and not conforming with -the upcoming POSIX standard: - -Please tell bug-automake@gnu.org about your system, including the value -of your $PATH and any error possibly output before this message. This -can help us improve future automake versions. - -END - if test x"$ACCEPT_INFERIOR_RM_PROGRAM" = x"yes"; then - echo 'Configuration will proceed anyway, since you have set the' >&2 - echo 'ACCEPT_INFERIOR_RM_PROGRAM variable to "yes"' >&2 - echo >&2 - else - cat >&2 <<'END' -Aborting the configuration process, to ensure you take notice of the issue. - -You can download and install GNU coreutils to get an 'rm' implementation -that behaves properly: . - -If you want to complete the configuration process using your problematic -'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM -to "yes", and re-run configure. - -END - AC_MSG_ERROR([Your 'rm' program is bad, sorry.]) - fi -fi]) - -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-2013 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-2013 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. - -# 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])]) - -# Check to see how 'make' treats includes. -*- Autoconf -*- - -# Copyright (C) 2001-2013 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_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 -]) - -# Fake the existence of programs that GNU maintainers use. -*- Autoconf -*- - -# Copyright (C) 1997-2013 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_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 is modern enough. -# If it is, 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 --is-lightweight"; then - am_missing_run="$MISSING " -else - am_missing_run= - AC_MSG_WARN(['missing' script is too old or missing]) -fi -]) - -# Helper functions for option handling. -*- Autoconf -*- - -# Copyright (C) 2001-2013 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_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])]) - -# Copyright (C) 1999-2013 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_CC_C_O -# --------------- -# Like AC_PROG_CC_C_O, but changed for automake. We rewrite AC_PROG_CC -# to automatically call this. -AC_DEFUN([_AM_PROG_CC_C_O], -[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl -AC_REQUIRE_AUX_FILE([compile])dnl -AC_LANG_PUSH([C])dnl -AC_CACHE_CHECK( - [whether $CC understands -c and -o together], - [am_cv_prog_cc_c_o], - [AC_LANG_CONFTEST([AC_LANG_PROGRAM([])]) - # Make sure it works both with $CC and with simple cc. - # Following AC_PROG_CC_C_O, we do the test twice because some - # compilers refuse to overwrite an existing .o file with -o, - # though they will create one. - am_cv_prog_cc_c_o=yes - for am_i in 1 2; do - if AM_RUN_LOG([$CC -c conftest.$ac_ext -o conftest2.$ac_objext]) \ - && test -f conftest2.$ac_objext; then - : OK - else - am_cv_prog_cc_c_o=no - break - fi - done - rm -f core conftest* - unset am_i]) -if test "$am_cv_prog_cc_c_o" != 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 -AC_LANG_POP([C])]) - -# For backward compatibility. -AC_DEFUN_ONCE([AM_PROG_CC_C_O], [AC_REQUIRE([AC_PROG_CC])]) - -# Copyright (C) 2001-2013 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_RUN_LOG(COMMAND) -# ------------------- -# Run COMMAND, save the exit status in ac_status, and log it. -# (This has been adapted from Autoconf's _AC_RUN_LOG macro.) -AC_DEFUN([AM_RUN_LOG], -[{ echo "$as_me:$LINENO: $1" >&AS_MESSAGE_LOG_FD - ($1) >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD - (exit $ac_status); }]) - -# Check to make sure that the build environment is sane. -*- Autoconf -*- - -# Copyright (C) 1996-2013 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_SANITY_CHECK -# --------------- -AC_DEFUN([AM_SANITY_CHECK], -[AC_MSG_CHECKING([whether build environment is sane]) -# 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 ( - am_has_slept=no - for am_try in 1 2; do - echo "timestamp, slept: $am_has_slept" > conftest.file - 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 - 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 - if test "$[2]" = conftest.file || test $am_try -eq 2; then - break - fi - # Just in case. - sleep 1 - am_has_slept=yes - done - 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]) -# If we didn't sleep, we still need to ensure time stamps of config.status and -# generated files are strictly newer. -am_sleep_pid= -if grep 'slept: no' conftest.file >/dev/null 2>&1; then - ( sleep 1 ) & - am_sleep_pid=$! -fi -AC_CONFIG_COMMANDS_PRE( - [AC_MSG_CHECKING([that generated files are newer than configure]) - if test -n "$am_sleep_pid"; then - # Hide warnings about reused PIDs. - wait $am_sleep_pid 2>/dev/null - fi - AC_MSG_RESULT([done])]) -rm -f conftest.file -]) - -# Copyright (C) 2009-2013 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_SILENT_RULES([DEFAULT]) -# -------------------------- -# Enable less verbose build rules; with the default set to DEFAULT -# ("yes" being less verbose, "no" or empty being verbose). -AC_DEFUN([AM_SILENT_RULES], -[AC_ARG_ENABLE([silent-rules], [dnl -AS_HELP_STRING( - [--enable-silent-rules], - [less verbose build output (undo: "make V=1")]) -AS_HELP_STRING( - [--disable-silent-rules], - [verbose build output (undo: "make V=0")])dnl -]) -case $enable_silent_rules in @%:@ ((( - yes) AM_DEFAULT_VERBOSITY=0;; - no) AM_DEFAULT_VERBOSITY=1;; - *) AM_DEFAULT_VERBOSITY=m4_if([$1], [yes], [0], [1]);; -esac -dnl -dnl A few 'make' implementations (e.g., NonStop OS and NextStep) -dnl do not support nested variable expansions. -dnl See automake bug#9928 and bug#10237. -am_make=${MAKE-make} -AC_CACHE_CHECK([whether $am_make supports nested variables], - [am_cv_make_support_nested_variables], - [if AS_ECHO([['TRUE=$(BAR$(V)) -BAR0=false -BAR1=true -V=1 -am__doit: - @$(TRUE) -.PHONY: am__doit']]) | $am_make -f - >/dev/null 2>&1; then - am_cv_make_support_nested_variables=yes -else - am_cv_make_support_nested_variables=no -fi]) -if test $am_cv_make_support_nested_variables = yes; then - dnl Using '$V' instead of '$(V)' breaks IRIX make. - AM_V='$(V)' - AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)' -else - AM_V=$AM_DEFAULT_VERBOSITY - AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY -fi -AC_SUBST([AM_V])dnl -AM_SUBST_NOTMAKE([AM_V])dnl -AC_SUBST([AM_DEFAULT_V])dnl -AM_SUBST_NOTMAKE([AM_DEFAULT_V])dnl -AC_SUBST([AM_DEFAULT_VERBOSITY])dnl -AM_BACKSLASH='\' -AC_SUBST([AM_BACKSLASH])dnl -_AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl -]) - -# Copyright (C) 2001-2013 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-2013 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_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-2013 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_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. Yes, it's still used -# in the wild :-( We should find a proper way to deprecate it ... -AC_SUBST([AMTAR], ['$${TAR-tar}']) - -# We'll loop over all known methods to create a tar archive until one works. -_am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none' - -m4_if([$1], [v7], - [am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'], - - [m4_case([$1], - [ustar], - [# The POSIX 1988 'ustar' format is defined with fixed-size fields. - # There is notably a 21 bits limit for the UID and the GID. In fact, - # the 'pax' utility can hang on bigger UID/GID (see automake bug#8343 - # and bug#13588). - am_max_uid=2097151 # 2^21 - 1 - am_max_gid=$am_max_uid - # The $UID and $GID variables are not portable, so we need to resort - # to the POSIX-mandated id(1) utility. Errors in the 'id' calls - # below are definitely unexpected, so allow the users to see them - # (that is, avoid stderr redirection). - am_uid=`id -u || echo unknown` - am_gid=`id -g || echo unknown` - AC_MSG_CHECKING([whether UID '$am_uid' is supported by ustar format]) - if test $am_uid -le $am_max_uid; then - AC_MSG_RESULT([yes]) - else - AC_MSG_RESULT([no]) - _am_tools=none - fi - AC_MSG_CHECKING([whether GID '$am_gid' is supported by ustar format]) - if test $am_gid -le $am_max_gid; then - AC_MSG_RESULT([yes]) - else - AC_MSG_RESULT([no]) - _am_tools=none - fi], - - [pax], - [], - - [m4_fatal([Unknown tar format])]) - - AC_MSG_CHECKING([how to create a $1 tar archive]) - - # Go ahead even if we have the value already cached. We do so because we - # need to set the values for the 'am__tar' and 'am__untar' variables. - _am_tools=${am_cv_prog_tar_$1-$_am_tools} - - 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 - diff --git a/vppversion/compile b/vppversion/compile deleted file mode 100755 index 531136b0..00000000 --- a/vppversion/compile +++ /dev/null @@ -1,347 +0,0 @@ -#! /bin/sh -# Wrapper for compilers which do not understand '-c -o'. - -scriptversion=2012-10-14.11; # UTC - -# Copyright (C) 1999-2013 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, see . - -# 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 -# . - -nl=' -' - -# We need space, tab and new line, in precisely that order. Quoting is -# there to prevent tools from complaining about whitespace usage. -IFS=" "" $nl" - -file_conv= - -# func_file_conv build_file lazy -# Convert a $build file to $host form and store it in $file -# Currently only supports Windows hosts. If the determined conversion -# type is listed in (the comma separated) LAZY, no conversion will -# take place. -func_file_conv () -{ - file=$1 - case $file in - / | /[!/]*) # absolute file, and not a UNC file - if test -z "$file_conv"; then - # lazily determine how to convert abs files - case `uname -s` in - MINGW*) - file_conv=mingw - ;; - CYGWIN*) - file_conv=cygwin - ;; - *) - file_conv=wine - ;; - esac - fi - case $file_conv/,$2, in - *,$file_conv,*) - ;; - mingw/*) - file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'` - ;; - cygwin/*) - file=`cygpath -m "$file" || echo "$file"` - ;; - wine/*) - file=`winepath -w "$file" || echo "$file"` - ;; - esac - ;; - esac -} - -# func_cl_dashL linkdir -# Make cl look for libraries in LINKDIR -func_cl_dashL () -{ - func_file_conv "$1" - if test -z "$lib_path"; then - lib_path=$file - else - lib_path="$lib_path;$file" - fi - linker_opts="$linker_opts -LIBPATH:$file" -} - -# func_cl_dashl library -# Do a library search-path lookup for cl -func_cl_dashl () -{ - lib=$1 - found=no - save_IFS=$IFS - IFS=';' - for dir in $lib_path $LIB - do - IFS=$save_IFS - if $shared && test -f "$dir/$lib.dll.lib"; then - found=yes - lib=$dir/$lib.dll.lib - break - fi - if test -f "$dir/$lib.lib"; then - found=yes - lib=$dir/$lib.lib - break - fi - if test -f "$dir/lib$lib.a"; then - found=yes - lib=$dir/lib$lib.a - break - fi - done - IFS=$save_IFS - - if test "$found" != yes; then - lib=$lib.lib - fi -} - -# func_cl_wrapper cl arg... -# Adjust compile command to suit cl -func_cl_wrapper () -{ - # Assume a capable shell - lib_path= - shared=: - linker_opts= - for arg - do - if test -n "$eat"; then - eat= - else - case $1 in - -o) - # configure might choose to run compile as 'compile cc -o foo foo.c'. - eat=1 - case $2 in - *.o | *.[oO][bB][jJ]) - func_file_conv "$2" - set x "$@" -Fo"$file" - shift - ;; - *) - func_file_conv "$2" - set x "$@" -Fe"$file" - shift - ;; - esac - ;; - -I) - eat=1 - func_file_conv "$2" mingw - set x "$@" -I"$file" - shift - ;; - -I*) - func_file_conv "${1#-I}" mingw - set x "$@" -I"$file" - shift - ;; - -l) - eat=1 - func_cl_dashl "$2" - set x "$@" "$lib" - shift - ;; - -l*) - func_cl_dashl "${1#-l}" - set x "$@" "$lib" - shift - ;; - -L) - eat=1 - func_cl_dashL "$2" - ;; - -L*) - func_cl_dashL "${1#-L}" - ;; - -static) - shared=false - ;; - -Wl,*) - arg=${1#-Wl,} - save_ifs="$IFS"; IFS=',' - for flag in $arg; do - IFS="$save_ifs" - linker_opts="$linker_opts $flag" - done - IFS="$save_ifs" - ;; - -Xlinker) - eat=1 - linker_opts="$linker_opts $2" - ;; - -*) - set x "$@" "$1" - shift - ;; - *.cc | *.CC | *.cxx | *.CXX | *.[cC]++) - func_file_conv "$1" - set x "$@" -Tp"$file" - shift - ;; - *.c | *.cpp | *.CPP | *.lib | *.LIB | *.Lib | *.OBJ | *.obj | *.[oO]) - func_file_conv "$1" mingw - set x "$@" "$file" - shift - ;; - *) - set x "$@" "$1" - shift - ;; - esac - fi - shift - done - if test -n "$linker_opts"; then - linker_opts="-link$linker_opts" - fi - exec "$@" $linker_opts - exit 1 -} - -eat= - -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 $? - ;; - -v | --v*) - echo "compile $scriptversion" - exit $? - ;; - cl | *[/\\]cl | cl.exe | *[/\\]cl.exe ) - func_cl_wrapper "$@" # Doesn't return... - ;; -esac - -ofile= -cfile= - -for arg -do - if test -n "$eat"; then - eat= - else - case $1 in - -o) - # configure might choose to run compile as 'compile cc -o foo foo.c'. - # So we strip '-o arg' only if arg is an object. - eat=1 - case $2 in - *.o | *.obj) - ofile=$2 - ;; - *) - set x "$@" -o "$2" - shift - ;; - esac - ;; - *.c) - cfile=$1 - set x "$@" "$1" - shift - ;; - *) - set x "$@" "$1" - shift - ;; - esac - fi - 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 "$@" -fi - -# Name of file we expect compiler to create. -cofile=`echo "$cfile" | sed 's|^.*[\\/]||; s|^[a-zA-Z]:||; 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. -"$@" -ret=$? - -if test -f "$cofile"; then - test "$cofile" = "$ofile" || mv "$cofile" "$ofile" -elif test -f "${cofile}bj"; then - test "${cofile}bj" = "$ofile" || mv "${cofile}bj" "$ofile" -fi - -rmdir "$lockdir" -exit $ret - -# 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-time-zone: "UTC" -# time-stamp-end: "; # UTC" -# End: diff --git a/vppversion/config.guess b/vppversion/config.guess deleted file mode 100755 index b79252d6..00000000 --- a/vppversion/config.guess +++ /dev/null @@ -1,1558 +0,0 @@ -#! /bin/sh -# Attempt to guess a canonical system name. -# Copyright 1992-2013 Free Software Foundation, Inc. - -timestamp='2013-06-10' - -# 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 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 . -# -# 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 Exception is an additional permission under section 7 -# of the GNU General Public License, version 3 ("GPLv3"). -# -# Originally written by Per Bothner. -# -# 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 -# -# Please send patches with a ChangeLog entry to config-patches@gnu.org. - - -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 1992-2013 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 - -case "${UNAME_SYSTEM}" in -Linux|GNU|GNU/*) - # If the system lacks a compiler, then just pick glibc. - # We could probably try harder. - LIBC=gnu - - eval $set_cc_for_build - cat <<-EOF > $dummy.c - #include - #if defined(__UCLIBC__) - LIBC=uclibc - #elif defined(__dietlibc__) - LIBC=dietlibc - #else - LIBC=gnu - #endif - EOF - eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC'` - ;; -esac - -# 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 tuples: *-*-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 ;; - *:Bitrig:*:*) - UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'` - echo ${UNAME_MACHINE_ARCH}-unknown-bitrig${UNAME_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'` - # Reset EXIT trap before exiting to avoid spurious non-zero exit code. - exitcode=$? - trap '' 0 - exit $exitcode ;; - 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:*:[4567]) - 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:*:*) - UNAME_PROCESSOR=`/usr/bin/uname -p` - case ${UNAME_PROCESSOR} in - amd64) - echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; - *) - echo ${UNAME_PROCESSOR}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; - esac - exit ;; - i*:CYGWIN*:*) - echo ${UNAME_MACHINE}-pc-cygwin - exit ;; - *:MINGW64*:*) - echo ${UNAME_MACHINE}-pc-mingw64 - exit ;; - *:MINGW*:*) - echo ${UNAME_MACHINE}-pc-mingw32 - exit ;; - i*:MSYS*:*) - echo ${UNAME_MACHINE}-pc-msys - 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-${LIBC}`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/[-(].*//'`-${LIBC} - exit ;; - i*86:Minix:*:*) - echo ${UNAME_MACHINE}-pc-minix - exit ;; - aarch64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - aarch64_be:Linux:*:*) - UNAME_MACHINE=aarch64_be - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - 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="gnulibc1" ; fi - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - arc:Linux:*:* | arceb:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${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-${LIBC} - else - if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ - | grep -q __ARM_PCS_VFP - then - echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabi - else - echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabihf - fi - fi - exit ;; - avr32*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - cris:Linux:*:*) - echo ${UNAME_MACHINE}-axis-linux-${LIBC} - exit ;; - crisv32:Linux:*:*) - echo ${UNAME_MACHINE}-axis-linux-${LIBC} - exit ;; - frv:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - hexagon:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - i*86:Linux:*:*) - echo ${UNAME_MACHINE}-pc-linux-${LIBC} - exit ;; - ia64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - m32r*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - m68*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - 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-${LIBC}"; exit; } - ;; - or1k:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - or32:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - padre:Linux:*:*) - echo sparc-unknown-linux-${LIBC} - exit ;; - parisc64:Linux:*:* | hppa64:Linux:*:*) - echo hppa64-unknown-linux-${LIBC} - 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-${LIBC} ;; - PA8*) echo hppa2.0-unknown-linux-${LIBC} ;; - *) echo hppa-unknown-linux-${LIBC} ;; - esac - exit ;; - ppc64:Linux:*:*) - echo powerpc64-unknown-linux-${LIBC} - exit ;; - ppc:Linux:*:*) - echo powerpc-unknown-linux-${LIBC} - exit ;; - ppc64le:Linux:*:*) - echo powerpc64le-unknown-linux-${LIBC} - exit ;; - ppcle:Linux:*:*) - echo powerpcle-unknown-linux-${LIBC} - exit ;; - s390:Linux:*:* | s390x:Linux:*:*) - echo ${UNAME_MACHINE}-ibm-linux-${LIBC} - exit ;; - sh64*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - sh*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - sparc:Linux:*:* | sparc64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - tile*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - vax:Linux:*:*) - echo ${UNAME_MACHINE}-dec-linux-${LIBC} - exit ;; - x86_64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - xtensa*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - 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 ;; - x86_64:Haiku:*:*) - echo x86_64-unknown-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 - eval $set_cc_for_build - if test "$UNAME_PROCESSOR" = unknown ; then - UNAME_PROCESSOR=powerpc - fi - 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 - case $UNAME_PROCESSOR in - i386) UNAME_PROCESSOR=x86_64 ;; - powerpc) UNAME_PROCESSOR=powerpc64 ;; - esac - fi - fi - 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 ;; - NEO-?:NONSTOP_KERNEL:*:*) - echo neo-tandem-nsk${UNAME_RELEASE} - 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 ;; - x86_64:VMkernel:*:*) - echo ${UNAME_MACHINE}-unknown-esx - exit ;; -esac - -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/vppversion/config.sub b/vppversion/config.sub deleted file mode 100755 index 9633db70..00000000 --- a/vppversion/config.sub +++ /dev/null @@ -1,1791 +0,0 @@ -#! /bin/sh -# Configuration validation subroutine script. -# Copyright 1992-2013 Free Software Foundation, Inc. - -timestamp='2013-08-10' - -# 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 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 . -# -# 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 Exception is an additional permission under section 7 -# of the GNU General Public License, version 3 ("GPLv3"). - - -# Please send patches with a ChangeLog entry to config-patches@gnu.org. -# -# 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 1992-2013 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-android* | linux-dietlibc | linux-newlib* | \ - linux-musl* | 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/'` - ;; - android-linux) - os=-linux-android - basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown - ;; - *) - 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*178) - os=-lynxos178 - ;; - -lynx*5) - os=-lynxos5 - ;; - -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 \ - | aarch64 | aarch64_be \ - | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ - | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ - | am33_2.0 \ - | arc | arceb \ - | arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \ - | avr | avr32 \ - | be32 | be64 \ - | bfin \ - | c4x | c8051 | clipper \ - | d10v | d30v | dlx | dsp16xx \ - | epiphany \ - | fido | fr30 | frv \ - | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ - | hexagon \ - | i370 | i860 | i960 | ia64 \ - | ip2k | iq2000 \ - | le32 | le64 \ - | lm32 \ - | m32c | m32r | m32rle | m68000 | m68k | m88k \ - | maxq | mb | microblaze | microblazeel | 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 \ - | mipsr5900 | mipsr5900el \ - | mipstx39 | mipstx39el \ - | mn10200 | mn10300 \ - | moxie \ - | mt \ - | msp430 \ - | nds32 | nds32le | nds32be \ - | nios | nios2 | nios2eb | nios2el \ - | ns16k | ns32k \ - | open8 \ - | or1k | or32 \ - | pdp10 | pdp11 | pj | pjl \ - | powerpc | powerpc64 | powerpc64le | powerpcle \ - | pyramid \ - | rl78 | 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 \ - | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \ - | ubicom32 \ - | v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \ - | we32k \ - | x86 | xc16x | xstormy16 | xtensa \ - | z8k | z80) - basic_machine=$basic_machine-unknown - ;; - c54x) - basic_machine=tic54x-unknown - ;; - c55x) - basic_machine=tic55x-unknown - ;; - c6x) - basic_machine=tic6x-unknown - ;; - m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | picochip) - basic_machine=$basic_machine-unknown - os=-none - ;; - m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) - ;; - ms1) - basic_machine=mt-unknown - ;; - - strongarm | thumb | xscale) - basic_machine=arm-unknown - ;; - xgate) - basic_machine=$basic_machine-unknown - os=-none - ;; - xscaleeb) - basic_machine=armeb-unknown - ;; - - xscaleel) - basic_machine=armel-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-* \ - | aarch64-* | aarch64_be-* \ - | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ - | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ - | alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \ - | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ - | avr-* | avr32-* \ - | be32-* | be64-* \ - | bfin-* | bs2000-* \ - | c[123]* | c30-* | [cjt]90-* | c4x-* \ - | c8051-* | 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-* \ - | hexagon-* \ - | i*86-* | i860-* | i960-* | ia64-* \ - | ip2k-* | iq2000-* \ - | le32-* | le64-* \ - | lm32-* \ - | m32c-* | m32r-* | m32rle-* \ - | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ - | m88110-* | m88k-* | maxq-* | mcore-* | metag-* \ - | microblaze-* | microblazeel-* \ - | 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-* \ - | mipsr5900-* | mipsr5900el-* \ - | mipstx39-* | mipstx39el-* \ - | mmix-* \ - | mt-* \ - | msp430-* \ - | nds32-* | nds32le-* | nds32be-* \ - | nios-* | nios2-* | nios2eb-* | nios2el-* \ - | none-* | np1-* | ns16k-* | ns32k-* \ - | open8-* \ - | orion-* \ - | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ - | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \ - | pyramid-* \ - | rl78-* | 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-* | sv1-* | sx?-* \ - | tahoe-* \ - | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ - | tile*-* \ - | tron-* \ - | ubicom32-* \ - | v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \ - | vax-* \ - | we32k-* \ - | x86-* | x86_64-* | xc16x-* | xps100-* \ - | 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 - ;; - c54x-*) - basic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - c55x-*) - basic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - c6x-*) - basic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - 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 | 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*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 - ;; - mingw64) - basic_machine=x86_64-pc - os=-mingw64 - ;; - mingw32) - basic_machine=i686-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-/'` - ;; - msys) - basic_machine=i686-pc - os=-msys - ;; - mvs) - basic_machine=i370-ibm - os=-mvs - ;; - nacl) - basic_machine=le32-unknown - os=-nacl - ;; - 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 - ;; - neo-tandem) - basic_machine=neo-tandem - ;; - nse-tandem) - basic_machine=nse-tandem - ;; - 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 | ppcbe) basic_machine=powerpc-unknown - ;; - ppc-* | ppcbe-*) - 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 | rdos64) - basic_machine=x86_64-pc - os=-rdos - ;; - rdos32) - 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 - ;; - strongarm-* | thumb-*) - basic_machine=arm-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - 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 - ;; - tile*) - basic_machine=$basic_machine-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 - ;; - xscale-* | xscalee[bl]-*) - basic_machine=`echo $basic_machine | sed 's/^xscale/arm/'` - ;; - ymp) - basic_machine=ymp-cray - os=-unicos - ;; - z8k-*-coff) - basic_machine=z8k-unknown - os=-sim - ;; - z80-*-coff) - basic_machine=z80-unknown - os=-sim - ;; - none) - basic_machine=none-none - os=-none - ;; - -# 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* | -plan9* \ - | -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* \ - | -bitrig* | -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* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ - | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \ - | -linux-newlib* | -linux-musl* | -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 - ;; - -zvmoe) - os=-zvmoe - ;; - -dicos*) - os=-dicos - ;; - -nacl*) - ;; - -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 - ;; - c8051-*) - os=-elf - ;; - hexagon-*) - os=-elf - ;; - tic54x-*) - os=-coff - ;; - tic55x-*) - os=-coff - ;; - tic6x-*) - 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 - ;; - m68*-cisco) - os=-aout - ;; - mep-*) - os=-elf - ;; - mips*-cisco) - os=-elf - ;; - mips*-*) - os=-elf - ;; - or1k-*) - 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/vppversion/configure b/vppversion/configure deleted file mode 100755 index 8a42993e..00000000 --- a/vppversion/configure +++ /dev/null @@ -1,14439 +0,0 @@ -#! /bin/sh -# Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for sign 1.0. -# -# -# 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 -n \"\${ZSH_VERSION+set}\${BASH_VERSION+set}\" || ( - ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' - ECHO=\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO - ECHO=\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO - PATH=/empty FPATH=/empty; export PATH FPATH - test \"X\`printf %s \$ECHO\`\" = \"X\$ECHO\" \\ - || test \"X\`print -r -- \$ECHO\`\" = \"X\$ECHO\" ) || 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'" - -SHELL=${CONFIG_SHELL-/bin/sh} - - -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='sign' -PACKAGE_TARNAME='sign' -PACKAGE_VERSION='1.0' -PACKAGE_STRING='sign 1.0' -PACKAGE_BUGREPORT='' -PACKAGE_URL='' - -# 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 -LIBOBJS -CPP -OTOOL64 -OTOOL -LIPO -NMEDIT -DSYMUTIL -MANIFEST_TOOL -RANLIB -ac_ct_AR -AR -DLLTOOL -OBJDUMP -LN_S -NM -ac_ct_DUMPBIN -DUMPBIN -LD -FGREP -EGREP -GREP -SED -host_os -host_vendor -host_cpu -host -build_os -build_vendor -build_cpu -build -LIBTOOL -am__fastdepCCAS_FALSE -am__fastdepCCAS_TRUE -CCASDEPMODE -CCASFLAGS -CCAS -am__fastdepCC_FALSE -am__fastdepCC_TRUE -CCDEPMODE -am__nodep -AMDEPBACKSLASH -AMDEP_FALSE -AMDEP_TRUE -am__quote -am__include -DEPDIR -OBJEXT -EXEEXT -ac_ct_CC -CPPFLAGS -LDFLAGS -CFLAGS -CC -AM_BACKSLASH -AM_DEFAULT_VERBOSITY -AM_DEFAULT_V -AM_V -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_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_silent_rules -enable_dependency_tracking -enable_shared -enable_static -with_pic -enable_fast_install -with_gnu_ld -with_sysroot -enable_libtool_lock -' - ac_precious_vars='build_alias -host_alias -target_alias -CC -CFLAGS -LDFLAGS -LIBS -CPPFLAGS -CCAS -CCASFLAGS -CPP' - - -# 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_TARNAME}' -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 sign 1.0 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/sign] - --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] -_ACEOF -fi - -if test -n "$ac_init_help"; then - case $ac_init_help in - short | recursive ) echo "Configuration of sign 1.0:";; - esac - 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-silent-rules less verbose build output (undo: "make V=1") - --disable-silent-rules verbose build output (undo: "make V=0") - --enable-dependency-tracking - do not reject slow dependency extractors - --disable-dependency-tracking - speeds up one-time build - --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-libtool-lock avoid locking (might break parallel builds) - -Optional Packages: - --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] - --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) - --with-pic[=PKGS] try to use only PIC/non-PIC objects [default=use - both] - --with-gnu-ld assume the C compiler uses GNU ld [default=no] - --with-sysroot=DIR Search for dependent libraries within DIR - (or the compiler's sysroot if not specified). - -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 - CCAS assembler compiler command (defaults to CC) - CCASFLAGS assembler compiler flags (defaults to CFLAGS) - CPP 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 -sign configure 1.0 -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 -cat >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 sign $as_me 1.0, 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 - - -am__api_version='1.14' - -ac_aux_dir= -for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; 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 \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$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. - - -# 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; } -# 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 ( - am_has_slept=no - for am_try in 1 2; do - echo "timestamp, slept: $am_has_slept" > conftest.file - 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 - 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 - if test "$2" = conftest.file || test $am_try -eq 2; then - break - fi - # Just in case. - sleep 1 - am_has_slept=yes - done - 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; } -# If we didn't sleep, we still need to ensure time stamps of config.status and -# generated files are strictly newer. -am_sleep_pid= -if grep 'slept: no' conftest.file >/dev/null 2>&1; then - ( sleep 1 ) & - am_sleep_pid=$! -fi - -rm -f conftest.file - -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 --is-lightweight"; then - am_missing_run="$MISSING " -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; } - -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 - -# Check whether --enable-silent-rules was given. -if test "${enable_silent_rules+set}" = set; then : - enableval=$enable_silent_rules; -fi - -case $enable_silent_rules in # ((( - yes) AM_DEFAULT_VERBOSITY=0;; - no) AM_DEFAULT_VERBOSITY=1;; - *) AM_DEFAULT_VERBOSITY=1;; -esac -am_make=${MAKE-make} -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $am_make supports nested variables" >&5 -$as_echo_n "checking whether $am_make supports nested variables... " >&6; } -if ${am_cv_make_support_nested_variables+:} false; then : - $as_echo_n "(cached) " >&6 -else - if $as_echo 'TRUE=$(BAR$(V)) -BAR0=false -BAR1=true -V=1 -am__doit: - @$(TRUE) -.PHONY: am__doit' | $am_make -f - >/dev/null 2>&1; then - am_cv_make_support_nested_variables=yes -else - am_cv_make_support_nested_variables=no -fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_make_support_nested_variables" >&5 -$as_echo "$am_cv_make_support_nested_variables" >&6; } -if test $am_cv_make_support_nested_variables = yes; then - AM_V='$(V)' - AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)' -else - AM_V=$AM_DEFAULT_VERBOSITY - AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY -fi -AM_BACKSLASH='\' - -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='sign' - VERSION='1.0' - - -cat >>confdefs.h <<_ACEOF -#define PACKAGE "$PACKAGE" -_ACEOF - - -cat >>confdefs.h <<_ACEOF -#define VERSION "$VERSION" -_ACEOF - -# 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"} - -# For better backward compatibility. To be removed once Automake 1.9.x -# dies out for good. For more background, see: -# -# -mkdir_p='$(MKDIR_P)' - -# We need awk for the "check" target. The system "awk" is bad on -# some platforms. -# Always define AMTAR for backward compatibility. Yes, it's still used -# in the wild :-( We should find a proper way to deprecate it ... -AMTAR='$${TAR-tar}' - - -# We'll loop over all known methods to create a tar archive until one works. -_am_tools='gnutar pax cpio none' - -am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -' - - - - - - -# POSIX will say in a future version that running "rm -f" with no argument -# is OK; and we want to be able to make that assumption in our Makefile -# recipes. So use an aggressive probe to check that the usage we want is -# actually supported "in the wild" to an acceptable degree. -# See automake bug#10828. -# To make any issue more visible, cause the running configure to be aborted -# by default if the 'rm' program in use doesn't match our expectations; the -# user can still override this though. -if rm -f && rm -fr && rm -rf; then : OK; else - cat >&2 <<'END' -Oops! - -Your 'rm' program seems unable to run without file operands specified -on the command line, even when the '-f' option is present. This is contrary -to the behaviour of most rm programs out there, and not conforming with -the upcoming POSIX standard: - -Please tell bug-automake@gnu.org about your system, including the value -of your $PATH and any error possibly output before this message. This -can help us improve future automake versions. - -END - if test x"$ACCEPT_INFERIOR_RM_PROGRAM" = x"yes"; then - echo 'Configuration will proceed anyway, since you have set the' >&2 - echo 'ACCEPT_INFERIOR_RM_PROGRAM variable to "yes"' >&2 - echo >&2 - else - cat >&2 <<'END' -Aborting the configuration process, to ensure you take notice of the issue. - -You can download and install GNU coreutils to get an 'rm' implementation -that behaves properly: . - -If you want to complete the configuration process using your problematic -'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM -to "yes", and re-run configure. - -END - as_fn_error $? "Your 'rm' program is bad, sorry." "$LINENO" 5 - fi -fi - -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='\' - am__nodep='_no' -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 - -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 $CC understands -c and -o together" >&5 -$as_echo_n "checking whether $CC understands -c and -o together... " >&6; } -if ${am_cv_prog_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. - # Following AC_PROG_CC_C_O, we do the test twice because some - # compilers refuse to overwrite an existing .o file with -o, - # though they will create one. - am_cv_prog_cc_c_o=yes - for am_i in 1 2; do - if { echo "$as_me:$LINENO: $CC -c conftest.$ac_ext -o conftest2.$ac_objext" >&5 - ($CC -c conftest.$ac_ext -o conftest2.$ac_objext) >&5 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } \ - && test -f conftest2.$ac_objext; then - : OK - else - am_cv_prog_cc_c_o=no - break - fi - done - rm -f core conftest* - unset am_i -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_prog_cc_c_o" >&5 -$as_echo "$am_cv_prog_cc_c_o" >&6; } -if test "$am_cv_prog_cc_c_o" != 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 -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". - rm -rf conftest.dir - 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 10 /bin/sh. - echo '/* dummy */' > 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 - ;; - msvc7 | msvc7msys | 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 - - -# By default we simply use the C compiler to build assembly code. - -test "${CCAS+set}" = set || CCAS=$CC -test "${CCASFLAGS+set}" = set || CCASFLAGS=$CFLAGS - - - -depcc="$CCAS" 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_CCAS_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". - rm -rf conftest.dir - 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_CCAS_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 - - - 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 10 /bin/sh. - echo '/* dummy */' > 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 - ;; - msvc7 | msvc7msys | 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_CCAS_dependencies_compiler_type=$depmode - break - fi - fi - done - - cd .. - rm -rf conftest.dir -else - am_cv_CCAS_dependencies_compiler_type=none -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CCAS_dependencies_compiler_type" >&5 -$as_echo "$am_cv_CCAS_dependencies_compiler_type" >&6; } -CCASDEPMODE=depmode=$am_cv_CCAS_dependencies_compiler_type - - if - test "x$enable_dependency_tracking" != xno \ - && test "$am_cv_CCAS_dependencies_compiler_type" = gcc3; then - am__fastdepCCAS_TRUE= - am__fastdepCCAS_FALSE='#' -else - am__fastdepCCAS_TRUE='#' - am__fastdepCCAS_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 - -{ $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 - -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 $CC understands -c and -o together" >&5 -$as_echo_n "checking whether $CC understands -c and -o together... " >&6; } -if ${am_cv_prog_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. - # Following AC_PROG_CC_C_O, we do the test twice because some - # compilers refuse to overwrite an existing .o file with -o, - # though they will create one. - am_cv_prog_cc_c_o=yes - for am_i in 1 2; do - if { echo "$as_me:$LINENO: $CC -c conftest.$ac_ext -o conftest2.$ac_objext" >&5 - ($CC -c conftest.$ac_ext -o conftest2.$ac_objext) >&5 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } \ - && test -f conftest2.$ac_objext; then - : OK - else - am_cv_prog_cc_c_o=no - break - fi - done - rm -f core conftest* - unset am_i -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_prog_cc_c_o" >&5 -$as_echo "$am_cv_prog_cc_c_o" >&6; } -if test "$am_cv_prog_cc_c_o" != 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 -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". - rm -rf conftest.dir - 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 10 /bin/sh. - echo '/* dummy */' > 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 - ;; - msvc7 | msvc7msys | 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 - - -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.4.2' -macro_revision='1.3337' - - - - - - - - - - - - - -ltmain="$ac_aux_dir/ltmain.sh" - -# 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 - - -# Backslashify 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' - -ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' -ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO -ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to print strings" >&5 -$as_echo_n "checking how to print strings... " >&6; } -# Test print first, because it will be a builtin if present. -if test "X`( print -r -- -n ) 2>/dev/null`" = X-n && \ - test "X`print -r -- $ECHO 2>/dev/null`" = "X$ECHO"; then - ECHO='print -r --' -elif test "X`printf %s $ECHO 2>/dev/null`" = "X$ECHO"; then - ECHO='printf %s\n' -else - # Use this function as a fallback that always works. - func_fallback_echo () - { - eval 'cat <<_LTECHO_EOF -$1 -_LTECHO_EOF' - } - ECHO='func_fallback_echo' -fi - -# func_echo_all arg... -# Invoke $ECHO with all args, space-separated. -func_echo_all () -{ - $ECHO "" -} - -case "$ECHO" in - printf*) { $as_echo "$as_me:${as_lineno-$LINENO}: result: printf" >&5 -$as_echo "printf" >&6; } ;; - print*) { $as_echo "$as_me:${as_lineno-$LINENO}: result: print -r" >&5 -$as_echo "print -r" >&6; } ;; - *) { $as_echo "$as_me:${as_lineno-$LINENO}: result: cat" >&5 -$as_echo "cat" >&6; } ;; -esac - - - - - - - - - - - - - - -{ $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 "$DUMPBIN"; then : - # Let the user override the test. - else - if test -n "$ac_tool_prefix"; then - for ac_prog in dumpbin "link -dump" - 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 "link -dump" -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 - - case `$DUMPBIN -symbols /dev/null 2>&1 | sed '1q'` in - *COFF*) - DUMPBIN="$DUMPBIN -symbols" - ;; - *) - DUMPBIN=: - ;; - esac - 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:$LINENO: $ac_compile\"" >&5) - (eval "$ac_compile" 2>conftest.err) - cat conftest.err >&5 - (eval echo "\"\$as_me:$LINENO: $NM \\\"conftest.$ac_objext\\\"\"" >&5) - (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) - cat conftest.err >&5 - (eval echo "\"\$as_me:$LINENO: 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; - ;; - - mint*) - # On MiNT this can take a long time and run out of memory. - 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 - ;; - - os2*) - # The test takes a long time on OS/2. - lt_cv_sys_max_cmd_len=8192 - ;; - - 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" && \ - test undefined != "$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"`env echo "$teststring$teststring" 2>/dev/null` \ - = "X$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%"$_lt_dummy"}, \ - = c,a/b,b/c, \ - && 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 how to convert $build file names to $host format" >&5 -$as_echo_n "checking how to convert $build file names to $host format... " >&6; } -if ${lt_cv_to_host_file_cmd+:} false; then : - $as_echo_n "(cached) " >&6 -else - case $host in - *-*-mingw* ) - case $build in - *-*-mingw* ) # actually msys - lt_cv_to_host_file_cmd=func_convert_file_msys_to_w32 - ;; - *-*-cygwin* ) - lt_cv_to_host_file_cmd=func_convert_file_cygwin_to_w32 - ;; - * ) # otherwise, assume *nix - lt_cv_to_host_file_cmd=func_convert_file_nix_to_w32 - ;; - esac - ;; - *-*-cygwin* ) - case $build in - *-*-mingw* ) # actually msys - lt_cv_to_host_file_cmd=func_convert_file_msys_to_cygwin - ;; - *-*-cygwin* ) - lt_cv_to_host_file_cmd=func_convert_file_noop - ;; - * ) # otherwise, assume *nix - lt_cv_to_host_file_cmd=func_convert_file_nix_to_cygwin - ;; - esac - ;; - * ) # unhandled hosts (and "normal" native builds) - lt_cv_to_host_file_cmd=func_convert_file_noop - ;; -esac - -fi - -to_host_file_cmd=$lt_cv_to_host_file_cmd -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_to_host_file_cmd" >&5 -$as_echo "$lt_cv_to_host_file_cmd" >&6; } - - - - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to convert $build file names to toolchain format" >&5 -$as_echo_n "checking how to convert $build file names to toolchain format... " >&6; } -if ${lt_cv_to_tool_file_cmd+:} false; then : - $as_echo_n "(cached) " >&6 -else - #assume ordinary cross tools, or native build. -lt_cv_to_tool_file_cmd=func_convert_file_noop -case $host in - *-*-mingw* ) - case $build in - *-*-mingw* ) # actually msys - lt_cv_to_tool_file_cmd=func_convert_file_msys_to_w32 - ;; - esac - ;; -esac - -fi - -to_tool_file_cmd=$lt_cv_to_tool_file_cmd -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_to_tool_file_cmd" >&5 -$as_echo "$lt_cv_to_tool_file_cmd" >&6; } - - - - - -{ $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 - cygwin* | mingw* | pw32* | cegcc*) - if test "$GCC" != yes; then - reload_cmds=false - fi - ;; - 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. - # func_win32_libid assumes BSD nm, so disallow it if using MS dumpbin. - if ( test "$lt_cv_nm_interface" = "BSD nm" && 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 - # Keep this pattern in sync with the one in func_win32_libid. - lt_cv_deplibs_check_method='file_magic file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' - 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 - ;; - -haiku*) - 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])(-bit)?( [LM]SB)? 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 glibc/ELF. -linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) - lt_cv_deplibs_check_method=pass_all - ;; - -netbsd* | netbsdelf*-gnu) - 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_glob= -want_nocaseglob=no -if test "$build" = "$host"; then - case $host_os in - mingw* | pw32*) - if ( shopt | grep nocaseglob ) >/dev/null 2>&1; then - want_nocaseglob=yes - else - file_magic_glob=`echo aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ | $SED -e "s/\(..\)/s\/[\1]\/[\1]\/g;/g"` - fi - ;; - esac -fi - -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}dlltool", so it can be a program name with args. -set dummy ${ac_tool_prefix}dlltool; 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_DLLTOOL+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$DLLTOOL"; then - ac_cv_prog_DLLTOOL="$DLLTOOL" # 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_DLLTOOL="${ac_tool_prefix}dlltool" - $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 -DLLTOOL=$ac_cv_prog_DLLTOOL -if test -n "$DLLTOOL"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DLLTOOL" >&5 -$as_echo "$DLLTOOL" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_DLLTOOL"; then - ac_ct_DLLTOOL=$DLLTOOL - # Extract the first word of "dlltool", so it can be a program name with args. -set dummy dlltool; 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_DLLTOOL+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_DLLTOOL"; then - ac_cv_prog_ac_ct_DLLTOOL="$ac_ct_DLLTOOL" # 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_DLLTOOL="dlltool" - $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_DLLTOOL=$ac_cv_prog_ac_ct_DLLTOOL -if test -n "$ac_ct_DLLTOOL"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DLLTOOL" >&5 -$as_echo "$ac_ct_DLLTOOL" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_DLLTOOL" = x; then - DLLTOOL="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 - DLLTOOL=$ac_ct_DLLTOOL - fi -else - DLLTOOL="$ac_cv_prog_DLLTOOL" -fi - -test -z "$DLLTOOL" && DLLTOOL=dlltool - - - - - - - - - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to associate runtime and link libraries" >&5 -$as_echo_n "checking how to associate runtime and link libraries... " >&6; } -if ${lt_cv_sharedlib_from_linklib_cmd+:} false; then : - $as_echo_n "(cached) " >&6 -else - lt_cv_sharedlib_from_linklib_cmd='unknown' - -case $host_os in -cygwin* | mingw* | pw32* | cegcc*) - # two different shell functions defined in ltmain.sh - # decide which to use based on capabilities of $DLLTOOL - case `$DLLTOOL --help 2>&1` in - *--identify-strict*) - lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib - ;; - *) - lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib_fallback - ;; - esac - ;; -*) - # fallback: assume linklib IS sharedlib - lt_cv_sharedlib_from_linklib_cmd="$ECHO" - ;; -esac - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sharedlib_from_linklib_cmd" >&5 -$as_echo "$lt_cv_sharedlib_from_linklib_cmd" >&6; } -sharedlib_from_linklib_cmd=$lt_cv_sharedlib_from_linklib_cmd -test -z "$sharedlib_from_linklib_cmd" && sharedlib_from_linklib_cmd=$ECHO - - - - - - - - -if test -n "$ac_tool_prefix"; then - for ac_prog in ar - 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_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$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 -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 - - - test -n "$AR" && break - done -fi -if test -z "$AR"; then - ac_ct_AR=$AR - for ac_prog in ar -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_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="$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_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 - - - test -n "$ac_ct_AR" && break -done - - 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 -fi - -: ${AR=ar} -: ${AR_FLAGS=cru} - - - - - - - - - - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for archiver @FILE support" >&5 -$as_echo_n "checking for archiver @FILE support... " >&6; } -if ${lt_cv_ar_at_file+:} false; then : - $as_echo_n "(cached) " >&6 -else - lt_cv_ar_at_file=no - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - echo conftest.$ac_objext > conftest.lst - lt_ar_try='$AR $AR_FLAGS libconftest.a @conftest.lst >&5' - { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$lt_ar_try\""; } >&5 - (eval $lt_ar_try) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - if test "$ac_status" -eq 0; then - # Ensure the archiver fails upon bogus file names. - rm -f conftest.$ac_objext libconftest.a - { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$lt_ar_try\""; } >&5 - (eval $lt_ar_try) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - if test "$ac_status" -ne 0; then - lt_cv_ar_at_file=@ - fi - fi - rm -f conftest.* libconftest.a - -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ar_at_file" >&5 -$as_echo "$lt_cv_ar_at_file" >&6; } - -if test "x$lt_cv_ar_at_file" = xno; then - archiver_list_spec= -else - archiver_list_spec=$lt_cv_ar_at_file -fi - - - - - - - -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 \$tool_oldlib" - ;; - *) - old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$tool_oldlib" - ;; - esac - old_archive_cmds="$old_archive_cmds~\$RANLIB \$tool_oldlib" -fi - -case $host_os in - darwin*) - lock_old_archive_extraction=yes ;; - *) - lock_old_archive_extraction=no ;; -esac - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# 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};"\ -" /^COFF SYMBOL TABLE/{for(i in hide) delete hide[i]};"\ -" /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 - lt_cv_sys_global_symbol_pipe="$lt_cv_sys_global_symbol_pipe | sed '/ __gnu_lto/d'" - - # 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 -/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ -#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE) -/* DATA imports from DLLs on WIN32 con't be const, because runtime - relocations are performed -- see ld's documentation on pseudo-relocs. */ -# define LT_DLSYM_CONST -#elif defined(__osf__) -/* This system does not cope well with relocations in const data. */ -# define LT_DLSYM_CONST -#else -# define LT_DLSYM_CONST const -#endif - -#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. */ -LT_DLSYM_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_globsym_save_LIBS=$LIBS - lt_globsym_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_globsym_save_LIBS - CFLAGS=$lt_globsym_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 - -# Response file support. -if test "$lt_cv_nm_interface" = "MS dumpbin"; then - nm_file_list_spec='@' -elif $NM --help 2>/dev/null | grep '[@]FILE' >/dev/null; then - nm_file_list_spec='@' -fi - - - - - - - - - - - - - - - - - - - - - - - - - - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for sysroot" >&5 -$as_echo_n "checking for sysroot... " >&6; } - -# Check whether --with-sysroot was given. -if test "${with_sysroot+set}" = set; then : - withval=$with_sysroot; -else - with_sysroot=no -fi - - -lt_sysroot= -case ${with_sysroot} in #( - yes) - if test "$GCC" = yes; then - lt_sysroot=`$CC --print-sysroot 2>/dev/null` - fi - ;; #( - /*) - lt_sysroot=`echo "$with_sysroot" | sed -e "$sed_quote_subst"` - ;; #( - no|'') - ;; #( - *) - { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${with_sysroot}" >&5 -$as_echo "${with_sysroot}" >&6; } - as_fn_error $? "The sysroot must be an absolute path." "$LINENO" 5 - ;; -esac - - { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${lt_sysroot:-no}" >&5 -$as_echo "${lt_sysroot:-no}" >&6; } - - - - - -# 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 '$LINENO' "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*|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*) - case `/usr/bin/file conftest.o` in - *x86-64*) - LD="${LD-ld} -m elf32_x86_64" - ;; - *) - LD="${LD-ld} -m elf_i386" - ;; - esac - ;; - powerpc64le-*) - LD="${LD-ld} -m elf32lppclinux" - ;; - powerpc64-*) - 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" - ;; - powerpcle-*) - LD="${LD-ld} -m elf64lppc" - ;; - powerpc-*) - 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 - ;; -*-*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*) - case $host in - i?86-*-solaris*) - LD="${LD-ld} -m elf_x86_64" - ;; - sparc*-*-solaris*) - LD="${LD-ld} -m elf64_sparc" - ;; - esac - # GNU ld 2.21 introduced _sol2 emulations. Use them if available. - if ${LD-ld} -V | grep _sol2 >/dev/null 2>&1; then - LD="${LD-ld}_sol2" - fi - ;; - *) - 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" - -if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}mt", so it can be a program name with args. -set dummy ${ac_tool_prefix}mt; 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_MANIFEST_TOOL+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$MANIFEST_TOOL"; then - ac_cv_prog_MANIFEST_TOOL="$MANIFEST_TOOL" # 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_MANIFEST_TOOL="${ac_tool_prefix}mt" - $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 -MANIFEST_TOOL=$ac_cv_prog_MANIFEST_TOOL -if test -n "$MANIFEST_TOOL"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MANIFEST_TOOL" >&5 -$as_echo "$MANIFEST_TOOL" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_MANIFEST_TOOL"; then - ac_ct_MANIFEST_TOOL=$MANIFEST_TOOL - # Extract the first word of "mt", so it can be a program name with args. -set dummy mt; 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_MANIFEST_TOOL+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_MANIFEST_TOOL"; then - ac_cv_prog_ac_ct_MANIFEST_TOOL="$ac_ct_MANIFEST_TOOL" # 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_MANIFEST_TOOL="mt" - $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_MANIFEST_TOOL=$ac_cv_prog_ac_ct_MANIFEST_TOOL -if test -n "$ac_ct_MANIFEST_TOOL"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_MANIFEST_TOOL" >&5 -$as_echo "$ac_ct_MANIFEST_TOOL" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_MANIFEST_TOOL" = x; then - MANIFEST_TOOL=":" - 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 - MANIFEST_TOOL=$ac_ct_MANIFEST_TOOL - fi -else - MANIFEST_TOOL="$ac_cv_prog_MANIFEST_TOOL" -fi - -test -z "$MANIFEST_TOOL" && MANIFEST_TOOL=mt -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if $MANIFEST_TOOL is a manifest tool" >&5 -$as_echo_n "checking if $MANIFEST_TOOL is a manifest tool... " >&6; } -if ${lt_cv_path_mainfest_tool+:} false; then : - $as_echo_n "(cached) " >&6 -else - lt_cv_path_mainfest_tool=no - echo "$as_me:$LINENO: $MANIFEST_TOOL '-?'" >&5 - $MANIFEST_TOOL '-?' 2>conftest.err > conftest.out - cat conftest.err >&5 - if $GREP 'Manifest Tool' conftest.out > /dev/null; then - lt_cv_path_mainfest_tool=yes - fi - rm -f conftest* -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_mainfest_tool" >&5 -$as_echo "$lt_cv_path_mainfest_tool" >&6; } -if test "x$lt_cv_path_mainfest_tool" != xyes; then - MANIFEST_TOOL=: -fi - - - - - - - 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 there is a non-empty error log, and "single_module" - # appears in it, assume the flag caused a linker warning - if test -s conftest.err && $GREP single_module conftest.err; then - cat conftest.err >&5 - # Otherwise, if the output was created with a 0 exit code from - # the compiler, it worked. - elif test -f libconftest.dylib && test $_lt_result -eq 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; } - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -force_load linker flag" >&5 -$as_echo_n "checking for -force_load linker flag... " >&6; } -if ${lt_cv_ld_force_load+:} false; then : - $as_echo_n "(cached) " >&6 -else - lt_cv_ld_force_load=no - cat > conftest.c << _LT_EOF -int forced_loaded() { return 2;} -_LT_EOF - echo "$LTCC $LTCFLAGS -c -o conftest.o conftest.c" >&5 - $LTCC $LTCFLAGS -c -o conftest.o conftest.c 2>&5 - echo "$AR cru libconftest.a conftest.o" >&5 - $AR cru libconftest.a conftest.o 2>&5 - echo "$RANLIB libconftest.a" >&5 - $RANLIB libconftest.a 2>&5 - cat > conftest.c << _LT_EOF -int main() { return 0;} -_LT_EOF - echo "$LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a" >&5 - $LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a 2>conftest.err - _lt_result=$? - if test -s conftest.err && $GREP force_load conftest.err; then - cat conftest.err >&5 - elif test -f conftest && test $_lt_result -eq 0 && $GREP forced_load conftest >/dev/null 2>&1 ; then - lt_cv_ld_force_load=yes - else - cat conftest.err >&5 - fi - rm -f conftest.err libconftest.a conftest conftest.c - rm -rf conftest.dSYM - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_force_load" >&5 -$as_echo "$lt_cv_ld_force_load" >&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" != ":" && test "$lt_cv_ld_force_load" = "no"; 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; lt_p=${PACKAGE-default} - case $withval in - yes|no) pic_mode=$withval ;; - *) - pic_mode=default - # Look at the argument we got. We use all the common list separators. - lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," - for lt_pkg in $withval; do - IFS="$lt_save_ifs" - if test "X$lt_pkg" = "X$lt_p"; then - pic_mode=yes - fi - done - IFS="$lt_save_ifs" - ;; - esac -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 - -# 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 "$cc_temp" | $SED "s%.*/%%; 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 - case $cc_basename in - nvcc*) - lt_prog_compiler_no_builtin_flag=' -Xcompiler -fno-builtin' ;; - *) - lt_prog_compiler_no_builtin_flag=' -fno-builtin' ;; - esac - - { $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:$LINENO: $lt_compile\"" >&5) - (eval "$lt_compile" 2>conftest.err) - ac_status=$? - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $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 "$_lt_compiler_boilerplate" | $SED '/^$/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= - - - 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' - ;; - - haiku*) - # PIC is the default for Haiku. - # The "-static" flag exists, but is broken. - lt_prog_compiler_static= - ;; - - 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 - - case $cc_basename in - nvcc*) # Cuda Compiler Driver 2.2 - lt_prog_compiler_wl='-Xlinker ' - if test -n "$lt_prog_compiler_pic"; then - lt_prog_compiler_pic="-Xcompiler $lt_prog_compiler_pic" - fi - ;; - 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 | kopensolaris*-gnu | 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' - ;; - nagfor*) - # NAG Fortran compiler - lt_prog_compiler_wl='-Wl,-Wl,,' - lt_prog_compiler_pic='-PIC' - lt_prog_compiler_static='-Bstatic' - ;; - pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*) - # 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* | bgxl* | bgf* | mpixl*) - # IBM XL C 8.0/Fortran 10.1, 11.1 on PPC and BlueGene - lt_prog_compiler_wl='-Wl,' - lt_prog_compiler_pic='-qpic' - lt_prog_compiler_static='-qstaticlink' - ;; - *) - case `$CC -V 2>&1 | sed 5q` in - *Sun\ Ceres\ Fortran* | *Sun*Fortran*\ [1-7].* | *Sun*Fortran*\ 8.[0-3]*) - # 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='' - ;; - *Sun\ F* | *Sun*Fortran*) - lt_prog_compiler_pic='-KPIC' - lt_prog_compiler_static='-Bstatic' - lt_prog_compiler_wl='-Qoption ld ' - ;; - *Sun\ C*) - # Sun C 5.9 - lt_prog_compiler_pic='-KPIC' - lt_prog_compiler_static='-Bstatic' - lt_prog_compiler_wl='-Wl,' - ;; - *Intel*\ [CF]*Compiler*) - lt_prog_compiler_wl='-Wl,' - lt_prog_compiler_pic='-fPIC' - lt_prog_compiler_static='-static' - ;; - *Portland\ Group*) - lt_prog_compiler_wl='-Wl,' - lt_prog_compiler_pic='-fpic' - lt_prog_compiler_static='-Bstatic' - ;; - 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* | sunf77* | sunf90* | sunf95*) - 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}: checking for $compiler option to produce PIC" >&5 -$as_echo_n "checking for $compiler option to produce PIC... " >&6; } -if ${lt_cv_prog_compiler_pic+:} false; then : - $as_echo_n "(cached) " >&6 -else - lt_cv_prog_compiler_pic=$lt_prog_compiler_pic -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic" >&5 -$as_echo "$lt_cv_prog_compiler_pic" >&6; } -lt_prog_compiler_pic=$lt_cv_prog_compiler_pic - -# -# 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:$LINENO: $lt_compile\"" >&5) - (eval "$lt_compile" 2>conftest.err) - ac_status=$? - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $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 "$_lt_compiler_boilerplate" | $SED '/^$/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 "$_lt_linker_boilerplate" | $SED '/^$/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:$LINENO: $lt_compile\"" >&5) - (eval "$lt_compile" 2>out/conftest.err) - ac_status=$? - cat out/conftest.err >&5 - echo "$as_me:$LINENO: \$? = $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 "$_lt_compiler_boilerplate" | $SED '/^$/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:$LINENO: $lt_compile\"" >&5) - (eval "$lt_compile" 2>out/conftest.err) - ac_status=$? - cat out/conftest.err >&5 - echo "$as_me:$LINENO: \$? = $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 "$_lt_compiler_boilerplate" | $SED '/^$/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_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 - ;; - linux* | k*bsd*-gnu | gnu*) - link_all_deplibs=no - ;; - esac - - ld_shlibs=yes - - # On some targets, GNU ld is compatible enough with the native linker - # that we're better off using the native interface for both. - lt_use_gnu_ld_interface=no - if test "$with_gnu_ld" = yes; then - case $host_os in - aix*) - # The AIX port of GNU ld has always aspired to compatibility - # with the native linker. However, as the warning in the GNU ld - # block says, versions before 2.19.5* couldn't really create working - # shared libraries, regardless of the interface used. - case `$LD -v 2>&1` in - *\ \(GNU\ Binutils\)\ 2.19.5*) ;; - *\ \(GNU\ Binutils\)\ 2.[2-9]*) ;; - *\ \(GNU\ Binutils\)\ [3-9]*) ;; - *) - lt_use_gnu_ld_interface=yes - ;; - esac - ;; - *) - lt_use_gnu_ld_interface=yes - ;; - esac - fi - - if test "$lt_use_gnu_ld_interface" = 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 - *GNU\ gold*) supports_anon_versioning=yes ;; - *\ [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.19, 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 install binutils -*** 2.20 or above, or modify your PATH so that a non-GNU linker is found. -*** You will then need to restart the configuration process. - -_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' - export_dynamic_flag_spec='${wl}--export-all-symbols' - 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/;s/^.*[ ]__nm__\([^ ]*\)[ ][^ ]*/\1 DATA/;/^I[ ]/d;/^[AITW][ ]/s/.* //'\'' | sort | uniq > $export_symbols' - exclude_expsyms='[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname' - - 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 - ;; - - haiku*) - archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - link_all_deplibs=yes - ;; - - 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 | kopensolaris*-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=' $pic_flag' - 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; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' - tmp_addflag=' $pic_flag' - ;; - pgf77* | pgf90* | pgf95* | pgfortran*) - # 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; func_echo_all \"$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]* | bgxl[cC]* | mpixl[cC]*) # IBM XL C 8.0 on PPC (deal with xlf below) - tmp_sharedflag='-qmkshrobj' - tmp_addflag= ;; - nvcc*) # Cuda Compiler Driver 2.2 - whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' - compiler_needs_object=yes - ;; - 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; func_echo_all \"$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* | bgf* | bgxlf* | mpixlf*) - # 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='${wl}-rpath ${wl}$libdir' - archive_cmds='$LD -shared $libobjs $deplibs $linker_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 $linker_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib' - fi - ;; - esac - else - ld_shlibs=no - fi - ;; - - netbsd* | netbsdelf*-gnu) - 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 $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - archive_expsym_cmds='$CC -shared $pic_flag $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 $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - archive_expsym_cmds='$CC -shared $pic_flag $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 $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - archive_expsym_cmds='$CC -shared $pic_flag $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 - # Also, AIX nm treats weak defined symbols like other global - # defined symbols, whereas GNU nm marks them as "W". - 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") || (\$ 2 == "W")) && (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 - link_all_deplibs=no - 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. - if test "${lt_cv_aix_libpath+set}" = set; then - aix_libpath=$lt_cv_aix_libpath -else - if ${lt_cv_aix_libpath_+:} false; then : - $as_echo_n "(cached) " >&6 -else - 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 - } - }' - lt_cv_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 "$lt_cv_aix_libpath_"; then - lt_cv_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 "$lt_cv_aix_libpath_"; then - lt_cv_aix_libpath_="/usr/lib:/lib" - fi - -fi - - aix_libpath=$lt_cv_aix_libpath_ -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 func_echo_all "${wl}${allow_undefined_flag}"; 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. - if test "${lt_cv_aix_libpath+set}" = set; then - aix_libpath=$lt_cv_aix_libpath -else - if ${lt_cv_aix_libpath_+:} false; then : - $as_echo_n "(cached) " >&6 -else - 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 - } - }' - lt_cv_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 "$lt_cv_aix_libpath_"; then - lt_cv_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 "$lt_cv_aix_libpath_"; then - lt_cv_aix_libpath_="/usr/lib:/lib" - fi - -fi - - aix_libpath=$lt_cv_aix_libpath_ -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' - if test "$with_gnu_ld" = yes; then - # We only use this code for GNU lds that support --whole-archive. - whole_archive_flag_spec='${wl}--whole-archive$convenience ${wl}--no-whole-archive' - else - # Exported symbols can be pulled into shared objects from archives - whole_archive_flag_spec='$convenience' - fi - 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. - case $cc_basename in - cl*) - # Native MSVC - hardcode_libdir_flag_spec=' ' - allow_undefined_flag=unsupported - always_export_symbols=yes - file_list_spec='@' - # 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 $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames=' - archive_expsym_cmds='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then - sed -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp; - else - sed -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp; - fi~ - $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~ - linknames=' - # The linker will not automatically build a static lib if we build a DLL. - # _LT_TAGVAR(old_archive_from_new_cmds, )='true' - enable_shared_with_static_runtimes=yes - exclude_expsyms='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*' - export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1,DATA/'\'' | $SED -e '\''/^[AITW][ ]/s/.*[ ]//'\'' | sort | uniq > $export_symbols' - # Don't use ranlib - old_postinstall_cmds='chmod 644 $oldlib' - postlink_cmds='lt_outputfile="@OUTPUT@"~ - lt_tool_outputfile="@TOOL_OUTPUT@"~ - case $lt_outputfile in - *.exe|*.EXE) ;; - *) - lt_outputfile="$lt_outputfile.exe" - lt_tool_outputfile="$lt_tool_outputfile.exe" - ;; - esac~ - if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then - $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1; - $RM "$lt_outputfile.manifest"; - fi' - ;; - *) - # Assume MSVC wrapper - 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 `func_echo_all "$deplibs" | $SED '\''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' - enable_shared_with_static_runtimes=yes - ;; - esac - ;; - - darwin* | rhapsody*) - - - archive_cmds_need_lc=no - hardcode_direct=no - hardcode_automatic=yes - hardcode_shlibpath_var=unsupported - if test "$lt_cv_ld_force_load" = "yes"; then - whole_archive_flag_spec='`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience ${wl}-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`' - - else - whole_archive_flag_spec='' - fi - 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=func_echo_all - 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 - ;; - - # 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 $pic_flag -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 $pic_flag ${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 && test "$with_gnu_ld" = no; then - archive_cmds='$CC -shared $pic_flag ${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_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 && test "$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 $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' - ;; - *) - archive_cmds='$CC -shared $pic_flag ${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' - ;; - *) - - # Older versions of the 11.00 compiler do not understand -b yet - # (HP92453-01 A.11.01.20 doesn't, HP92453-01 B.11.X.35175-35176.GP does) - { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC understands -b" >&5 -$as_echo_n "checking if $CC understands -b... " >&6; } -if ${lt_cv_prog_compiler__b+:} false; then : - $as_echo_n "(cached) " >&6 -else - lt_cv_prog_compiler__b=no - save_LDFLAGS="$LDFLAGS" - LDFLAGS="$LDFLAGS -b" - 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 "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp - $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 - if diff conftest.exp conftest.er2 >/dev/null; then - lt_cv_prog_compiler__b=yes - fi - else - lt_cv_prog_compiler__b=yes - fi - fi - $RM -r conftest* - LDFLAGS="$save_LDFLAGS" - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler__b" >&5 -$as_echo "$lt_cv_prog_compiler__b" >&6; } - -if test x"$lt_cv_prog_compiler__b" = xyes; then - archive_cmds='$CC -b ${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 - - ;; - 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 $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${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. - # This should be the same for all languages, so no per-tag cache variable. - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $host_os linker accepts -exported_symbol" >&5 -$as_echo_n "checking whether the $host_os linker accepts -exported_symbol... " >&6; } -if ${lt_cv_irix_exported_symbol+:} false; then : - $as_echo_n "(cached) " >&6 -else - 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) { return 0; } -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - lt_cv_irix_exported_symbol=yes -else - lt_cv_irix_exported_symbol=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_irix_exported_symbol" >&5 -$as_echo "$lt_cv_irix_exported_symbol" >&6; } - if test "$lt_cv_irix_exported_symbol" = yes; then - archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib' - fi - else - archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' - archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -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* | netbsdelf*-gnu) - 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" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${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" && func_echo_all "-set_version $verstring"` -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} $pic_flag $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${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" && func_echo_all "-set_version $verstring"` -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 "-set_version $verstring"` -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 $pic_flag ${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 $pic_flag ${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; } -if ${lt_cv_archive_cmds_need_lc+:} false; then : - $as_echo_n "(cached) " >&6 -else - $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 - lt_cv_archive_cmds_need_lc=no - else - lt_cv_archive_cmds_need_lc=yes - fi - allow_undefined_flag=$lt_save_allow_undefined_flag - else - cat conftest.err 1>&5 - fi - $RM conftest* - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_archive_cmds_need_lc" >&5 -$as_echo "$lt_cv_archive_cmds_need_lc" >&6; } - archive_cmds_need_lc=$lt_cv_archive_cmds_need_lc - ;; - 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 - case $host_os in - mingw* | cegcc*) lt_sed_strip_eq="s,=\([A-Za-z]:\),\1,g" ;; - *) lt_sed_strip_eq="s,=/,/,g" ;; - esac - lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e $lt_sed_strip_eq` - case $lt_search_path_spec in - *\;*) - # 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 's/;/ /g'` - ;; - *) - lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED "s/$PATH_SEPARATOR/ /g"` - ;; - esac - # 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; } -}'` - # AWK program above erroneously prepends '/' to C:/dos/paths - # for these hosts. - case $host_os in - mingw* | cegcc*) lt_search_path_spec=`$ECHO "$lt_search_path_spec" |\ - $SED 's,/\([A-Za-z]:\),\1,g'` ;; - esac - sys_lib_search_path_spec=`$ECHO "$lt_search_path_spec" | $lt_NL2SP` -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 # correct to gnu/linux during the next big refactor - 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 # correct to gnu/linux during the next big refactor - 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=`func_echo_all "$lib" | $SED '\''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 # correct to gnu/linux during the next big refactor - 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,$cc_basename in - yes,*) - # gcc - 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="$sys_lib_search_path_spec /usr/lib/w32api" - ;; - mingw* | cegcc*) - # MinGW DLLs use traditional 'lib' prefix - soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' - ;; - 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 - dynamic_linker='Win32 ld.exe' - ;; - - *,cl*) - # Native MSVC - libname_spec='$name' - soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' - library_names_spec='${libname}.dll.lib' - - case $build_os in - mingw*) - sys_lib_search_path_spec= - lt_save_ifs=$IFS - IFS=';' - for lt_path in $LIB - do - IFS=$lt_save_ifs - # Let DOS variable expansion print the short 8.3 style file name. - lt_path=`cd "$lt_path" 2>/dev/null && cmd //C "for %i in (".") do @echo %~si"` - sys_lib_search_path_spec="$sys_lib_search_path_spec $lt_path" - done - IFS=$lt_save_ifs - # Convert to MSYS style. - sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | sed -e 's|\\\\|/|g' -e 's| \\([a-zA-Z]\\):| /\\1|g' -e 's|^ ||'` - ;; - cygwin*) - # Convert to unix form, then to dos form, then back to unix form - # but this time dos style (no spaces!) so that the unix form looks - # like /cygdrive/c/PROGRA~1:/cygdr... - sys_lib_search_path_spec=`cygpath --path --unix "$LIB"` - sys_lib_search_path_spec=`cygpath --path --dos "$sys_lib_search_path_spec" 2>/dev/null` - sys_lib_search_path_spec=`cygpath --path --unix "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` - ;; - *) - sys_lib_search_path_spec="$LIB" - if $ECHO "$sys_lib_search_path_spec" | $GREP ';[c-zC-Z]:/' >/dev/null; then - # It is most probably a Windows format PATH. - 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 - # FIXME: find the short name or the path components, as spaces are - # common. (e.g. "Program Files" -> "PROGRA~1") - ;; - esac - - # 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' - postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ - dlpath=$dir/\$dldll~ - $RM \$dlpath' - shlibpath_overrides_runpath=yes - dynamic_linker='Win32 link.exe' - ;; - - *) - # Assume MSVC wrapper - library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib' - dynamic_linker='Win32 ld.exe' - ;; - esac - # 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 # correct to gnu/linux during the next big refactor - 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 - ;; - -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[23].*) 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 - ;; - -haiku*) - version_type=linux # correct to gnu/linux during the next big refactor - need_lib_prefix=no - need_version=no - dynamic_linker="$host_os runtime_loader" - 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=LIBRARY_PATH - shlibpath_overrides_runpath=yes - sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib' - 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' - # or fails outright, so override atomically: - install_override_mode=555 - ;; - -interix[3-9]*) - version_type=linux # correct to gnu/linux during the next big refactor - 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 # correct to gnu/linux during the next big refactor - 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 glibc/ELF. -linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) - version_type=linux # correct to gnu/linux during the next big refactor - 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 - if ${lt_cv_shlibpath_overrides_runpath+:} false; then : - $as_echo_n "(cached) " >&6 -else - lt_cv_shlibpath_overrides_runpath=no - 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 : - lt_cv_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 - -fi - - shlibpath_overrides_runpath=$lt_cv_shlibpath_overrides_runpath - - # 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;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' - ;; - -netbsdelf*-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 - shlibpath_overrides_runpath=no - hardcode_into_libs=yes - dynamic_linker='NetBSD ld.elf_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 # correct to gnu/linux during the next big refactor - 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 # correct to gnu/linux during the next big refactor - 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 # correct to gnu/linux during the next big refactor - 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 # correct to gnu/linux during the next big refactor - 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 # correct to gnu/linux during the next big refactor - 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 # correct to gnu/linux during the next big refactor - 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 $LINENO "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 - -/* When -fvisbility=hidden is used, assume the code has been annotated - correspondingly for the symbols needed. */ -#if defined(__GNUC__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3)) -int fnord () __attribute__((visibility("default"))); -#endif - -int fnord () { return 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; - else puts (dlerror ()); - } - /* 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 $LINENO "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 - -/* When -fvisbility=hidden is used, assume the code has been annotated - correspondingly for the symbols needed. */ -#if defined(__GNUC__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3)) -int fnord () __attribute__((visibility("default"))); -#endif - -int fnord () { return 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; - else puts (dlerror ()); - } - /* 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: - - - -ac_config_files="$ac_config_files 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}' - -# Transform confdefs.h into DEFS. -# Protect against shell expansion while executing Makefile rules. -# Protect against Makefile macro expansion. -# -# If the first sed substitution is executed (which looks for macros that -# take arguments), then branch to the quote section. Otherwise, -# look for a macro that doesn't take arguments. -ac_script=' -:mline -/\\$/{ - N - s,\\\n,, - b mline -} -t clear -:clear -s/^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*([^)]*)\)[ ]*\(.*\)/-D\1=\2/g -t quote -s/^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\)/-D\1=\2/g -t quote -b any -:quote -s/[ `~#$^&*(){}\\|;'\''"<>?]/\\&/g -s/\[/\\&/g -s/\]/\\&/g -s/\$/$$/g -H -:any -${ - g - s/^\n// - s/\n/ /g - p -} -' -DEFS=`sed -n "$ac_script" confdefs.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 - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking that generated files are newer than configure" >&5 -$as_echo_n "checking that generated files are newer than configure... " >&6; } - if test -n "$am_sleep_pid"; then - # Hide warnings about reused PIDs. - wait $am_sleep_pid 2>/dev/null - fi - { $as_echo "$as_me:${as_lineno-$LINENO}: result: done" >&5 -$as_echo "done" >&6; } - 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__fastdepCCAS_TRUE}" && test -z "${am__fastdepCCAS_FALSE}"; then - as_fn_error $? "conditional \"am__fastdepCCAS\" 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 - -: "${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 sign $as_me 1.0, 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 - - - -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -# Files that config.status was made for. -config_files="$ac_config_files" -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 - -Configuration files: -$config_files - -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="\\ -sign config.status 1.0 -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;; - --he | --h | --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 "$macro_version" | $SED "$delay_single_quote_subst"`' -macro_revision='`$ECHO "$macro_revision" | $SED "$delay_single_quote_subst"`' -enable_shared='`$ECHO "$enable_shared" | $SED "$delay_single_quote_subst"`' -enable_static='`$ECHO "$enable_static" | $SED "$delay_single_quote_subst"`' -pic_mode='`$ECHO "$pic_mode" | $SED "$delay_single_quote_subst"`' -enable_fast_install='`$ECHO "$enable_fast_install" | $SED "$delay_single_quote_subst"`' -SHELL='`$ECHO "$SHELL" | $SED "$delay_single_quote_subst"`' -ECHO='`$ECHO "$ECHO" | $SED "$delay_single_quote_subst"`' -PATH_SEPARATOR='`$ECHO "$PATH_SEPARATOR" | $SED "$delay_single_quote_subst"`' -host_alias='`$ECHO "$host_alias" | $SED "$delay_single_quote_subst"`' -host='`$ECHO "$host" | $SED "$delay_single_quote_subst"`' -host_os='`$ECHO "$host_os" | $SED "$delay_single_quote_subst"`' -build_alias='`$ECHO "$build_alias" | $SED "$delay_single_quote_subst"`' -build='`$ECHO "$build" | $SED "$delay_single_quote_subst"`' -build_os='`$ECHO "$build_os" | $SED "$delay_single_quote_subst"`' -SED='`$ECHO "$SED" | $SED "$delay_single_quote_subst"`' -Xsed='`$ECHO "$Xsed" | $SED "$delay_single_quote_subst"`' -GREP='`$ECHO "$GREP" | $SED "$delay_single_quote_subst"`' -EGREP='`$ECHO "$EGREP" | $SED "$delay_single_quote_subst"`' -FGREP='`$ECHO "$FGREP" | $SED "$delay_single_quote_subst"`' -LD='`$ECHO "$LD" | $SED "$delay_single_quote_subst"`' -NM='`$ECHO "$NM" | $SED "$delay_single_quote_subst"`' -LN_S='`$ECHO "$LN_S" | $SED "$delay_single_quote_subst"`' -max_cmd_len='`$ECHO "$max_cmd_len" | $SED "$delay_single_quote_subst"`' -ac_objext='`$ECHO "$ac_objext" | $SED "$delay_single_quote_subst"`' -exeext='`$ECHO "$exeext" | $SED "$delay_single_quote_subst"`' -lt_unset='`$ECHO "$lt_unset" | $SED "$delay_single_quote_subst"`' -lt_SP2NL='`$ECHO "$lt_SP2NL" | $SED "$delay_single_quote_subst"`' -lt_NL2SP='`$ECHO "$lt_NL2SP" | $SED "$delay_single_quote_subst"`' -lt_cv_to_host_file_cmd='`$ECHO "$lt_cv_to_host_file_cmd" | $SED "$delay_single_quote_subst"`' -lt_cv_to_tool_file_cmd='`$ECHO "$lt_cv_to_tool_file_cmd" | $SED "$delay_single_quote_subst"`' -reload_flag='`$ECHO "$reload_flag" | $SED "$delay_single_quote_subst"`' -reload_cmds='`$ECHO "$reload_cmds" | $SED "$delay_single_quote_subst"`' -OBJDUMP='`$ECHO "$OBJDUMP" | $SED "$delay_single_quote_subst"`' -deplibs_check_method='`$ECHO "$deplibs_check_method" | $SED "$delay_single_quote_subst"`' -file_magic_cmd='`$ECHO "$file_magic_cmd" | $SED "$delay_single_quote_subst"`' -file_magic_glob='`$ECHO "$file_magic_glob" | $SED "$delay_single_quote_subst"`' -want_nocaseglob='`$ECHO "$want_nocaseglob" | $SED "$delay_single_quote_subst"`' -DLLTOOL='`$ECHO "$DLLTOOL" | $SED "$delay_single_quote_subst"`' -sharedlib_from_linklib_cmd='`$ECHO "$sharedlib_from_linklib_cmd" | $SED "$delay_single_quote_subst"`' -AR='`$ECHO "$AR" | $SED "$delay_single_quote_subst"`' -AR_FLAGS='`$ECHO "$AR_FLAGS" | $SED "$delay_single_quote_subst"`' -archiver_list_spec='`$ECHO "$archiver_list_spec" | $SED "$delay_single_quote_subst"`' -STRIP='`$ECHO "$STRIP" | $SED "$delay_single_quote_subst"`' -RANLIB='`$ECHO "$RANLIB" | $SED "$delay_single_quote_subst"`' -old_postinstall_cmds='`$ECHO "$old_postinstall_cmds" | $SED "$delay_single_quote_subst"`' -old_postuninstall_cmds='`$ECHO "$old_postuninstall_cmds" | $SED "$delay_single_quote_subst"`' -old_archive_cmds='`$ECHO "$old_archive_cmds" | $SED "$delay_single_quote_subst"`' -lock_old_archive_extraction='`$ECHO "$lock_old_archive_extraction" | $SED "$delay_single_quote_subst"`' -CC='`$ECHO "$CC" | $SED "$delay_single_quote_subst"`' -CFLAGS='`$ECHO "$CFLAGS" | $SED "$delay_single_quote_subst"`' -compiler='`$ECHO "$compiler" | $SED "$delay_single_quote_subst"`' -GCC='`$ECHO "$GCC" | $SED "$delay_single_quote_subst"`' -lt_cv_sys_global_symbol_pipe='`$ECHO "$lt_cv_sys_global_symbol_pipe" | $SED "$delay_single_quote_subst"`' -lt_cv_sys_global_symbol_to_cdecl='`$ECHO "$lt_cv_sys_global_symbol_to_cdecl" | $SED "$delay_single_quote_subst"`' -lt_cv_sys_global_symbol_to_c_name_address='`$ECHO "$lt_cv_sys_global_symbol_to_c_name_address" | $SED "$delay_single_quote_subst"`' -lt_cv_sys_global_symbol_to_c_name_address_lib_prefix='`$ECHO "$lt_cv_sys_global_symbol_to_c_name_address_lib_prefix" | $SED "$delay_single_quote_subst"`' -nm_file_list_spec='`$ECHO "$nm_file_list_spec" | $SED "$delay_single_quote_subst"`' -lt_sysroot='`$ECHO "$lt_sysroot" | $SED "$delay_single_quote_subst"`' -objdir='`$ECHO "$objdir" | $SED "$delay_single_quote_subst"`' -MAGIC_CMD='`$ECHO "$MAGIC_CMD" | $SED "$delay_single_quote_subst"`' -lt_prog_compiler_no_builtin_flag='`$ECHO "$lt_prog_compiler_no_builtin_flag" | $SED "$delay_single_quote_subst"`' -lt_prog_compiler_pic='`$ECHO "$lt_prog_compiler_pic" | $SED "$delay_single_quote_subst"`' -lt_prog_compiler_wl='`$ECHO "$lt_prog_compiler_wl" | $SED "$delay_single_quote_subst"`' -lt_prog_compiler_static='`$ECHO "$lt_prog_compiler_static" | $SED "$delay_single_quote_subst"`' -lt_cv_prog_compiler_c_o='`$ECHO "$lt_cv_prog_compiler_c_o" | $SED "$delay_single_quote_subst"`' -need_locks='`$ECHO "$need_locks" | $SED "$delay_single_quote_subst"`' -MANIFEST_TOOL='`$ECHO "$MANIFEST_TOOL" | $SED "$delay_single_quote_subst"`' -DSYMUTIL='`$ECHO "$DSYMUTIL" | $SED "$delay_single_quote_subst"`' -NMEDIT='`$ECHO "$NMEDIT" | $SED "$delay_single_quote_subst"`' -LIPO='`$ECHO "$LIPO" | $SED "$delay_single_quote_subst"`' -OTOOL='`$ECHO "$OTOOL" | $SED "$delay_single_quote_subst"`' -OTOOL64='`$ECHO "$OTOOL64" | $SED "$delay_single_quote_subst"`' -libext='`$ECHO "$libext" | $SED "$delay_single_quote_subst"`' -shrext_cmds='`$ECHO "$shrext_cmds" | $SED "$delay_single_quote_subst"`' -extract_expsyms_cmds='`$ECHO "$extract_expsyms_cmds" | $SED "$delay_single_quote_subst"`' -archive_cmds_need_lc='`$ECHO "$archive_cmds_need_lc" | $SED "$delay_single_quote_subst"`' -enable_shared_with_static_runtimes='`$ECHO "$enable_shared_with_static_runtimes" | $SED "$delay_single_quote_subst"`' -export_dynamic_flag_spec='`$ECHO "$export_dynamic_flag_spec" | $SED "$delay_single_quote_subst"`' -whole_archive_flag_spec='`$ECHO "$whole_archive_flag_spec" | $SED "$delay_single_quote_subst"`' -compiler_needs_object='`$ECHO "$compiler_needs_object" | $SED "$delay_single_quote_subst"`' -old_archive_from_new_cmds='`$ECHO "$old_archive_from_new_cmds" | $SED "$delay_single_quote_subst"`' -old_archive_from_expsyms_cmds='`$ECHO "$old_archive_from_expsyms_cmds" | $SED "$delay_single_quote_subst"`' -archive_cmds='`$ECHO "$archive_cmds" | $SED "$delay_single_quote_subst"`' -archive_expsym_cmds='`$ECHO "$archive_expsym_cmds" | $SED "$delay_single_quote_subst"`' -module_cmds='`$ECHO "$module_cmds" | $SED "$delay_single_quote_subst"`' -module_expsym_cmds='`$ECHO "$module_expsym_cmds" | $SED "$delay_single_quote_subst"`' -with_gnu_ld='`$ECHO "$with_gnu_ld" | $SED "$delay_single_quote_subst"`' -allow_undefined_flag='`$ECHO "$allow_undefined_flag" | $SED "$delay_single_quote_subst"`' -no_undefined_flag='`$ECHO "$no_undefined_flag" | $SED "$delay_single_quote_subst"`' -hardcode_libdir_flag_spec='`$ECHO "$hardcode_libdir_flag_spec" | $SED "$delay_single_quote_subst"`' -hardcode_libdir_separator='`$ECHO "$hardcode_libdir_separator" | $SED "$delay_single_quote_subst"`' -hardcode_direct='`$ECHO "$hardcode_direct" | $SED "$delay_single_quote_subst"`' -hardcode_direct_absolute='`$ECHO "$hardcode_direct_absolute" | $SED "$delay_single_quote_subst"`' -hardcode_minus_L='`$ECHO "$hardcode_minus_L" | $SED "$delay_single_quote_subst"`' -hardcode_shlibpath_var='`$ECHO "$hardcode_shlibpath_var" | $SED "$delay_single_quote_subst"`' -hardcode_automatic='`$ECHO "$hardcode_automatic" | $SED "$delay_single_quote_subst"`' -inherit_rpath='`$ECHO "$inherit_rpath" | $SED "$delay_single_quote_subst"`' -link_all_deplibs='`$ECHO "$link_all_deplibs" | $SED "$delay_single_quote_subst"`' -always_export_symbols='`$ECHO "$always_export_symbols" | $SED "$delay_single_quote_subst"`' -export_symbols_cmds='`$ECHO "$export_symbols_cmds" | $SED "$delay_single_quote_subst"`' -exclude_expsyms='`$ECHO "$exclude_expsyms" | $SED "$delay_single_quote_subst"`' -include_expsyms='`$ECHO "$include_expsyms" | $SED "$delay_single_quote_subst"`' -prelink_cmds='`$ECHO "$prelink_cmds" | $SED "$delay_single_quote_subst"`' -postlink_cmds='`$ECHO "$postlink_cmds" | $SED "$delay_single_quote_subst"`' -file_list_spec='`$ECHO "$file_list_spec" | $SED "$delay_single_quote_subst"`' -variables_saved_for_relink='`$ECHO "$variables_saved_for_relink" | $SED "$delay_single_quote_subst"`' -need_lib_prefix='`$ECHO "$need_lib_prefix" | $SED "$delay_single_quote_subst"`' -need_version='`$ECHO "$need_version" | $SED "$delay_single_quote_subst"`' -version_type='`$ECHO "$version_type" | $SED "$delay_single_quote_subst"`' -runpath_var='`$ECHO "$runpath_var" | $SED "$delay_single_quote_subst"`' -shlibpath_var='`$ECHO "$shlibpath_var" | $SED "$delay_single_quote_subst"`' -shlibpath_overrides_runpath='`$ECHO "$shlibpath_overrides_runpath" | $SED "$delay_single_quote_subst"`' -libname_spec='`$ECHO "$libname_spec" | $SED "$delay_single_quote_subst"`' -library_names_spec='`$ECHO "$library_names_spec" | $SED "$delay_single_quote_subst"`' -soname_spec='`$ECHO "$soname_spec" | $SED "$delay_single_quote_subst"`' -install_override_mode='`$ECHO "$install_override_mode" | $SED "$delay_single_quote_subst"`' -postinstall_cmds='`$ECHO "$postinstall_cmds" | $SED "$delay_single_quote_subst"`' -postuninstall_cmds='`$ECHO "$postuninstall_cmds" | $SED "$delay_single_quote_subst"`' -finish_cmds='`$ECHO "$finish_cmds" | $SED "$delay_single_quote_subst"`' -finish_eval='`$ECHO "$finish_eval" | $SED "$delay_single_quote_subst"`' -hardcode_into_libs='`$ECHO "$hardcode_into_libs" | $SED "$delay_single_quote_subst"`' -sys_lib_search_path_spec='`$ECHO "$sys_lib_search_path_spec" | $SED "$delay_single_quote_subst"`' -sys_lib_dlsearch_path_spec='`$ECHO "$sys_lib_dlsearch_path_spec" | $SED "$delay_single_quote_subst"`' -hardcode_action='`$ECHO "$hardcode_action" | $SED "$delay_single_quote_subst"`' -enable_dlopen='`$ECHO "$enable_dlopen" | $SED "$delay_single_quote_subst"`' -enable_dlopen_self='`$ECHO "$enable_dlopen_self" | $SED "$delay_single_quote_subst"`' -enable_dlopen_self_static='`$ECHO "$enable_dlopen_self_static" | $SED "$delay_single_quote_subst"`' -old_striplib='`$ECHO "$old_striplib" | $SED "$delay_single_quote_subst"`' -striplib='`$ECHO "$striplib" | $SED "$delay_single_quote_subst"`' - -LTCC='$LTCC' -LTCFLAGS='$LTCFLAGS' -compiler='$compiler_DEFAULT' - -# A function that is used when there is no print builtin or printf. -func_fallback_echo () -{ - eval 'cat <<_LTECHO_EOF -\$1 -_LTECHO_EOF' -} - -# Quote evaled strings. -for var in SHELL \ -ECHO \ -PATH_SEPARATOR \ -SED \ -GREP \ -EGREP \ -FGREP \ -LD \ -NM \ -LN_S \ -lt_SP2NL \ -lt_NL2SP \ -reload_flag \ -OBJDUMP \ -deplibs_check_method \ -file_magic_cmd \ -file_magic_glob \ -want_nocaseglob \ -DLLTOOL \ -sharedlib_from_linklib_cmd \ -AR \ -AR_FLAGS \ -archiver_list_spec \ -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 \ -nm_file_list_spec \ -lt_prog_compiler_no_builtin_flag \ -lt_prog_compiler_pic \ -lt_prog_compiler_wl \ -lt_prog_compiler_static \ -lt_cv_prog_compiler_c_o \ -need_locks \ -MANIFEST_TOOL \ -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_separator \ -exclude_expsyms \ -include_expsyms \ -file_list_spec \ -variables_saved_for_relink \ -libname_spec \ -library_names_spec \ -soname_spec \ -install_override_mode \ -finish_eval \ -old_striplib \ -striplib; do - case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in - *[\\\\\\\`\\"\\\$]*) - eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED \\"\\\$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 \ -postlink_cmds \ -postinstall_cmds \ -postuninstall_cmds \ -finish_cmds \ -sys_lib_search_path_spec \ -sys_lib_dlsearch_path_spec; do - case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in - *[\\\\\\\`\\"\\\$]*) - eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\"" - ;; - *) - eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" - ;; - esac -done - -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 - "depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;; - "libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;; - "Makefile") CONFIG_FILES="$CONFIG_FILES 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_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" - - -eval set X " :F $CONFIG_FILES :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 - ;; - - - :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"" || { - # Older Autoconf 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"` - # 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'`; 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, 2009, 2010, 2011 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="" - -# ### 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 - -# Shell to use when invoking shell scripts. -SHELL=$lt_SHELL - -# An echo program that protects backslashes. -ECHO=$lt_ECHO - -# The PATH separator for the build system. -PATH_SEPARATOR=$lt_PATH_SEPARATOR - -# 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 - -# convert \$build file names to \$host format. -to_host_file_cmd=$lt_cv_to_host_file_cmd - -# convert \$build files to toolchain format. -to_tool_file_cmd=$lt_cv_to_tool_file_cmd - -# 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 - -# How to find potential files when deplibs_check_method = "file_magic". -file_magic_glob=$lt_file_magic_glob - -# Find potential files using nocaseglob when deplibs_check_method = "file_magic". -want_nocaseglob=$lt_want_nocaseglob - -# DLL creation program. -DLLTOOL=$lt_DLLTOOL - -# Command to associate shared and link libraries. -sharedlib_from_linklib_cmd=$lt_sharedlib_from_linklib_cmd - -# The archiver. -AR=$lt_AR - -# Flags to create an archive. -AR_FLAGS=$lt_AR_FLAGS - -# How to feed a file listing to the archiver. -archiver_list_spec=$lt_archiver_list_spec - -# 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 - -# Whether to use a lock for old archive extraction. -lock_old_archive_extraction=$lock_old_archive_extraction - -# 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 - -# Specify filename containing input files for \$NM. -nm_file_list_spec=$lt_nm_file_list_spec - -# The root where to search for dependent libraries,and in which our libraries should be installed. -lt_sysroot=$lt_sysroot - -# The name of the directory that contains temporary libtool files. -objdir=$objdir - -# 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 - -# Manifest tool. -MANIFEST_TOOL=$lt_MANIFEST_TOOL - -# 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 - -# Permission mode override for installation of shared libraries. -install_override_mode=$lt_install_override_mode - -# 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 - -# How to create reloadable object files. -reload_flag=$lt_reload_flag -reload_cmds=$lt_reload_cmds - -# 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 - -# Additional compiler flags for building library objects. -pic_flag=$lt_lt_prog_compiler_pic - -# How to pass a linker flag through the compiler. -wl=$lt_lt_prog_compiler_wl - -# 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 - -# 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 - -# 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 - -# Commands necessary for finishing linking programs. -postlink_cmds=$lt_postlink_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 - -# ### 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 '$q' "$ltmain" >> "$cfgfile" \ - || (rm -f "$cfgfile"; exit 1) - - if test x"$xsi_shell" = xyes; then - sed -e '/^func_dirname ()$/,/^} # func_dirname /c\ -func_dirname ()\ -{\ -\ case ${1} in\ -\ */*) func_dirname_result="${1%/*}${2}" ;;\ -\ * ) func_dirname_result="${3}" ;;\ -\ esac\ -} # Extended-shell func_dirname implementation' "$cfgfile" > $cfgfile.tmp \ - && mv -f "$cfgfile.tmp" "$cfgfile" \ - || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") -test 0 -eq $? || _lt_function_replace_fail=: - - - sed -e '/^func_basename ()$/,/^} # func_basename /c\ -func_basename ()\ -{\ -\ func_basename_result="${1##*/}"\ -} # Extended-shell func_basename implementation' "$cfgfile" > $cfgfile.tmp \ - && mv -f "$cfgfile.tmp" "$cfgfile" \ - || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") -test 0 -eq $? || _lt_function_replace_fail=: - - - sed -e '/^func_dirname_and_basename ()$/,/^} # func_dirname_and_basename /c\ -func_dirname_and_basename ()\ -{\ -\ case ${1} in\ -\ */*) func_dirname_result="${1%/*}${2}" ;;\ -\ * ) func_dirname_result="${3}" ;;\ -\ esac\ -\ func_basename_result="${1##*/}"\ -} # Extended-shell func_dirname_and_basename implementation' "$cfgfile" > $cfgfile.tmp \ - && mv -f "$cfgfile.tmp" "$cfgfile" \ - || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") -test 0 -eq $? || _lt_function_replace_fail=: - - - sed -e '/^func_stripname ()$/,/^} # func_stripname /c\ -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}"}\ -} # Extended-shell func_stripname implementation' "$cfgfile" > $cfgfile.tmp \ - && mv -f "$cfgfile.tmp" "$cfgfile" \ - || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") -test 0 -eq $? || _lt_function_replace_fail=: - - - sed -e '/^func_split_long_opt ()$/,/^} # func_split_long_opt /c\ -func_split_long_opt ()\ -{\ -\ func_split_long_opt_name=${1%%=*}\ -\ func_split_long_opt_arg=${1#*=}\ -} # Extended-shell func_split_long_opt implementation' "$cfgfile" > $cfgfile.tmp \ - && mv -f "$cfgfile.tmp" "$cfgfile" \ - || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") -test 0 -eq $? || _lt_function_replace_fail=: - - - sed -e '/^func_split_short_opt ()$/,/^} # func_split_short_opt /c\ -func_split_short_opt ()\ -{\ -\ func_split_short_opt_arg=${1#??}\ -\ func_split_short_opt_name=${1%"$func_split_short_opt_arg"}\ -} # Extended-shell func_split_short_opt implementation' "$cfgfile" > $cfgfile.tmp \ - && mv -f "$cfgfile.tmp" "$cfgfile" \ - || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") -test 0 -eq $? || _lt_function_replace_fail=: - - - sed -e '/^func_lo2o ()$/,/^} # func_lo2o /c\ -func_lo2o ()\ -{\ -\ case ${1} in\ -\ *.lo) func_lo2o_result=${1%.lo}.${objext} ;;\ -\ *) func_lo2o_result=${1} ;;\ -\ esac\ -} # Extended-shell func_lo2o implementation' "$cfgfile" > $cfgfile.tmp \ - && mv -f "$cfgfile.tmp" "$cfgfile" \ - || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") -test 0 -eq $? || _lt_function_replace_fail=: - - - sed -e '/^func_xform ()$/,/^} # func_xform /c\ -func_xform ()\ -{\ - func_xform_result=${1%.*}.lo\ -} # Extended-shell func_xform implementation' "$cfgfile" > $cfgfile.tmp \ - && mv -f "$cfgfile.tmp" "$cfgfile" \ - || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") -test 0 -eq $? || _lt_function_replace_fail=: - - - sed -e '/^func_arith ()$/,/^} # func_arith /c\ -func_arith ()\ -{\ - func_arith_result=$(( $* ))\ -} # Extended-shell func_arith implementation' "$cfgfile" > $cfgfile.tmp \ - && mv -f "$cfgfile.tmp" "$cfgfile" \ - || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") -test 0 -eq $? || _lt_function_replace_fail=: - - - sed -e '/^func_len ()$/,/^} # func_len /c\ -func_len ()\ -{\ - func_len_result=${#1}\ -} # Extended-shell func_len implementation' "$cfgfile" > $cfgfile.tmp \ - && mv -f "$cfgfile.tmp" "$cfgfile" \ - || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") -test 0 -eq $? || _lt_function_replace_fail=: - -fi - -if test x"$lt_shell_append" = xyes; then - sed -e '/^func_append ()$/,/^} # func_append /c\ -func_append ()\ -{\ - eval "${1}+=\\${2}"\ -} # Extended-shell func_append implementation' "$cfgfile" > $cfgfile.tmp \ - && mv -f "$cfgfile.tmp" "$cfgfile" \ - || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") -test 0 -eq $? || _lt_function_replace_fail=: - - - sed -e '/^func_append_quoted ()$/,/^} # func_append_quoted /c\ -func_append_quoted ()\ -{\ -\ func_quote_for_eval "${2}"\ -\ eval "${1}+=\\\\ \\$func_quote_for_eval_result"\ -} # Extended-shell func_append_quoted implementation' "$cfgfile" > $cfgfile.tmp \ - && mv -f "$cfgfile.tmp" "$cfgfile" \ - || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") -test 0 -eq $? || _lt_function_replace_fail=: - - - # Save a `func_append' function call where possible by direct use of '+=' - sed -e 's%func_append \([a-zA-Z_]\{1,\}\) "%\1+="%g' $cfgfile > $cfgfile.tmp \ - && mv -f "$cfgfile.tmp" "$cfgfile" \ - || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") - test 0 -eq $? || _lt_function_replace_fail=: -else - # Save a `func_append' function call even when '+=' is not available - sed -e 's%func_append \([a-zA-Z_]\{1,\}\) "%\1="$\1%g' $cfgfile > $cfgfile.tmp \ - && mv -f "$cfgfile.tmp" "$cfgfile" \ - || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") - test 0 -eq $? || _lt_function_replace_fail=: -fi - -if test x"$_lt_function_replace_fail" = x":"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Unable to substitute extended shell functions in $ofile" >&5 -$as_echo "$as_me: WARNING: Unable to substitute extended shell functions in $ofile" >&2;} -fi - - - mv -f "$cfgfile" "$ofile" || - (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile") - chmod +x "$ofile" - - ;; - - 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 - diff --git a/vppversion/configure.ac b/vppversion/configure.ac deleted file mode 100644 index 7bbe6fc5..00000000 --- a/vppversion/configure.ac +++ /dev/null @@ -1,8 +0,0 @@ -AC_INIT(sign, 1.0) -AM_INIT_AUTOMAKE - -AM_PROG_AS -AC_PROG_CC -AC_PROG_LIBTOOL - -AC_OUTPUT([Makefile]) diff --git a/vppversion/depcomp b/vppversion/depcomp deleted file mode 100755 index 4ebd5b3a..00000000 --- a/vppversion/depcomp +++ /dev/null @@ -1,791 +0,0 @@ -#! /bin/sh -# depcomp - compile a program generating dependencies as side-effects - -scriptversion=2013-05-30.07; # UTC - -# Copyright (C) 1999-2013 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, see . - -# 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'. - DEPDIR directory where to store dependencies. - depfile Dependency file to output. - tmpdepfile Temporary file to use when outputting dependencies. - libtool Whether libtool is used (yes/no). - -Report bugs to . -EOF - exit $? - ;; - -v | --v*) - echo "depcomp $scriptversion" - exit $? - ;; -esac - -# Get the directory component of the given path, and save it in the -# global variables '$dir'. Note that this directory component will -# be either empty or ending with a '/' character. This is deliberate. -set_dir_from () -{ - case $1 in - */*) dir=`echo "$1" | sed -e 's|/[^/]*$|/|'`;; - *) dir=;; - esac -} - -# Get the suffix-stripped basename of the given path, and save it the -# global variable '$base'. -set_base_from () -{ - base=`echo "$1" | sed -e 's|^.*/||' -e 's/\.[^.]*$//'` -} - -# If no dependency file was actually created by the compiler invocation, -# we still have to create a dummy depfile, to avoid errors with the -# Makefile "include basename.Plo" scheme. -make_dummy_depfile () -{ - echo "#dummy" > "$depfile" -} - -# Factor out some common post-processing of the generated depfile. -# Requires the auxiliary global variable '$tmpdepfile' to be set. -aix_post_process_depfile () -{ - # If the compiler actually managed to produce a dependency file, - # post-process it. - if test -f "$tmpdepfile"; then - # Each line is of the form 'foo.o: dependency.h'. - # Do two passes, one to just change these to - # $object: dependency.h - # and one to simply output - # dependency.h: - # which is needed to avoid the deleted-header problem. - { sed -e "s,^.*\.[$lower]*:,$object:," < "$tmpdepfile" - sed -e "s,^.*\.[$lower]*:[$tab ]*,," -e 's,$,:,' < "$tmpdepfile" - } > "$depfile" - rm -f "$tmpdepfile" - else - make_dummy_depfile - fi -} - -# A tabulation character. -tab=' ' -# A newline character. -nl=' -' -# Character ranges might be problematic outside the C locale. -# These definitions help. -upper=ABCDEFGHIJKLMNOPQRSTUVWXYZ -lower=abcdefghijklmnopqrstuvwxyz -digits=0123456789 -alpha=${upper}${lower} - -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 - -# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. -depfile=${depfile-`echo "$object" | - sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} -tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} - -rm -f "$tmpdepfile" - -# Avoid interferences from the environment. -gccflag= dashmflag= - -# 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 - -cygpath_u="cygpath -u -f -" -if test "$depmode" = msvcmsys; then - # This is just like msvisualcpp but w/o cygpath translation. - # Just convert the backslash-escaped backslashes to single forward - # slashes to satisfy depend.m4 - cygpath_u='sed s,\\\\,/,g' - depmode=msvisualcpp -fi - -if test "$depmode" = msvc7msys; then - # This is just like msvc7 but w/o cygpath translation. - # Just convert the backslash-escaped backslashes to single forward - # slashes to satisfy depend.m4 - cygpath_u='sed s,\\\\,/,g' - depmode=msvc7 -fi - -if test "$depmode" = xlc; then - # IBM C/C++ Compilers xlc/xlC can output gcc-like dependency information. - gccflag=-qmakedep=gcc,-MF - depmode=gcc -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. -## Unfortunately, FreeBSD c89 acceptance of flags depends upon -## the command line argument order; so add the flags where they -## appear in depend2.am. Note that the slowdown incurred here -## affects only configure: in makefiles, %FASTDEP% shortcuts this. - for arg - do - case $arg in - -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;; - *) set fnord "$@" "$arg" ;; - esac - shift # fnord - shift # $arg - done - "$@" - stat=$? - if test $stat -ne 0; then - rm -f "$tmpdepfile" - exit $stat - fi - mv "$tmpdepfile" "$depfile" - ;; - -gcc) -## Note that this doesn't just cater to obsosete pre-3.x GCC compilers. -## but also to in-use compilers like IMB xlc/xlC and the HP C compiler. -## (see the conditional assignment to $gccflag above). -## 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). Also, it might not be -## supported by the other compilers which use the 'gcc' depmode. -## - 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 -ne 0; then - rm -f "$tmpdepfile" - exit $stat - fi - rm -f "$depfile" - echo "$object : \\" > "$depfile" - # 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. -## 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. hp depmode also adds that space, but also prefixes the VPATH -## to the object. Take care to not repeat it in the output. -## Some versions of the HPUX 10.20 sed can't process this invocation -## correctly. Breaking it into two sed invocations is a workaround. - tr ' ' "$nl" < "$tmpdepfile" \ - | sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -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 -ne 0; then - 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 ' ' "$nl" < "$tmpdepfile" \ - | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' \ - | tr "$nl" ' ' >> "$depfile" - echo >> "$depfile" - # The second pass generates a dummy entry for each header file. - tr ' ' "$nl" < "$tmpdepfile" \ - | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ - >> "$depfile" - else - make_dummy_depfile - fi - rm -f "$tmpdepfile" - ;; - -xlc) - # 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 - ;; - -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. - set_dir_from "$object" - set_base_from "$object" - if test "$libtool" = yes; then - tmpdepfile1=$dir$base.u - tmpdepfile2=$base.u - tmpdepfile3=$dir.libs/$base.u - "$@" -Wc,-M - else - tmpdepfile1=$dir$base.u - tmpdepfile2=$dir$base.u - tmpdepfile3=$dir$base.u - "$@" -M - fi - stat=$? - if test $stat -ne 0; then - rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" - exit $stat - fi - - for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" - do - test -f "$tmpdepfile" && break - done - aix_post_process_depfile - ;; - -tcc) - # tcc (Tiny C Compiler) understand '-MD -MF file' since version 0.9.26 - # FIXME: That version still under development at the moment of writing. - # Make that this statement remains true also for stable, released - # versions. - # It will wrap lines (doesn't matter whether long or short) with a - # trailing '\', as in: - # - # foo.o : \ - # foo.c \ - # foo.h \ - # - # It will put a trailing '\' even on the last line, and will use leading - # spaces rather than leading tabs (at least since its commit 0394caf7 - # "Emit spaces for -MD"). - "$@" -MD -MF "$tmpdepfile" - stat=$? - if test $stat -ne 0; then - rm -f "$tmpdepfile" - exit $stat - fi - rm -f "$depfile" - # Each non-empty line is of the form 'foo.o : \' or ' dep.h \'. - # We have to change lines of the first kind to '$object: \'. - sed -e "s|.*:|$object :|" < "$tmpdepfile" > "$depfile" - # And for each line of the second kind, we have to emit a 'dep.h:' - # dummy dependency, to avoid the deleted-header problem. - sed -n -e 's|^ *\(.*\) *\\$|\1:|p' < "$tmpdepfile" >> "$depfile" - rm -f "$tmpdepfile" - ;; - -## The order of this option in the case statement is important, since the -## shell code in configure will try each of these formats in the order -## listed in this file. A plain '-MD' option would be understood by many -## compilers, so we must ensure this comes after the gcc and icc options. -pgcc) - # Portland's C compiler understands '-MD'. - # Will always output deps to 'file.d' where file is the root name of the - # source file under compilation, even if file resides in a subdirectory. - # The object file name does not affect the name of the '.d' file. - # pgcc 10.2 will output - # foo.o: sub/foo.c sub/foo.h - # and will wrap long lines using '\' : - # foo.o: sub/foo.c ... \ - # sub/foo.h ... \ - # ... - set_dir_from "$object" - # Use the source, not the object, to determine the base name, since - # that's sadly what pgcc will do too. - set_base_from "$source" - tmpdepfile=$base.d - - # For projects that build the same source file twice into different object - # files, the pgcc approach of using the *source* file root name can cause - # problems in parallel builds. Use a locking strategy to avoid stomping on - # the same $tmpdepfile. - lockdir=$base.d-lock - trap " - echo '$0: caught signal, cleaning up...' >&2 - rmdir '$lockdir' - exit 1 - " 1 2 13 15 - numtries=100 - i=$numtries - while test $i -gt 0; do - # mkdir is a portable test-and-set. - if mkdir "$lockdir" 2>/dev/null; then - # This process acquired the lock. - "$@" -MD - stat=$? - # Release the lock. - rmdir "$lockdir" - break - else - # If the lock is being held by a different process, wait - # until the winning process is done or we timeout. - while test -d "$lockdir" && test $i -gt 0; do - sleep 1 - i=`expr $i - 1` - done - fi - i=`expr $i - 1` - done - trap - 1 2 13 15 - if test $i -le 0; then - echo "$0: failed to acquire lock after $numtries attempts" >&2 - echo "$0: check lockdir '$lockdir'" >&2 - exit 1 - fi - - if test $stat -ne 0; then - 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" - ;; - -hp2) - # The "hp" stanza above does not work with aCC (C++) and HP's ia64 - # compilers, which have integrated preprocessors. The correct option - # to use with these is +Maked; it writes dependencies to a file named - # 'foo.d', which lands next to the object file, wherever that - # happens to be. - # Much of this is similar to the tru64 case; see comments there. - set_dir_from "$object" - set_base_from "$object" - if test "$libtool" = yes; then - tmpdepfile1=$dir$base.d - tmpdepfile2=$dir.libs/$base.d - "$@" -Wc,+Maked - else - tmpdepfile1=$dir$base.d - tmpdepfile2=$dir$base.d - "$@" +Maked - fi - stat=$? - if test $stat -ne 0; then - rm -f "$tmpdepfile1" "$tmpdepfile2" - exit $stat - fi - - for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" - do - test -f "$tmpdepfile" && break - done - if test -f "$tmpdepfile"; then - sed -e "s,^.*\.[$lower]*:,$object:," "$tmpdepfile" > "$depfile" - # Add 'dependent.h:' lines. - sed -ne '2,${ - s/^ *// - s/ \\*$// - s/$/:/ - p - }' "$tmpdepfile" >> "$depfile" - else - make_dummy_depfile - fi - rm -f "$tmpdepfile" "$tmpdepfile2" - ;; - -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. - set_dir_from "$object" - set_base_from "$object" - - if test "$libtool" = yes; then - # Libtool generates 2 separate objects for the 2 libraries. These - # two compilations output dependencies in $dir.libs/$base.o.d and - # in $dir$base.o.d. We have to check for both files, because - # one of the two compilations can be disabled. We should prefer - # $dir$base.o.d over $dir.libs/$base.o.d because the latter is - # automatically cleaned when .libs/ is deleted, while ignoring - # the former would cause a distcleancheck panic. - tmpdepfile1=$dir$base.o.d # libtool 1.5 - tmpdepfile2=$dir.libs/$base.o.d # Likewise. - tmpdepfile3=$dir.libs/$base.d # Compaq CCC V6.2-504 - "$@" -Wc,-MD - else - tmpdepfile1=$dir$base.d - tmpdepfile2=$dir$base.d - tmpdepfile3=$dir$base.d - "$@" -MD - fi - - stat=$? - if test $stat -ne 0; then - rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" - exit $stat - fi - - for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" - do - test -f "$tmpdepfile" && break - done - # Same post-processing that is required for AIX mode. - aix_post_process_depfile - ;; - -msvc7) - if test "$libtool" = yes; then - showIncludes=-Wc,-showIncludes - else - showIncludes=-showIncludes - fi - "$@" $showIncludes > "$tmpdepfile" - stat=$? - grep -v '^Note: including file: ' "$tmpdepfile" - if test $stat -ne 0; then - rm -f "$tmpdepfile" - exit $stat - fi - rm -f "$depfile" - echo "$object : \\" > "$depfile" - # The first sed program below extracts the file names and escapes - # backslashes for cygpath. The second sed program outputs the file - # name when reading, but also accumulates all include files in the - # hold buffer in order to output them again at the end. This only - # works with sed implementations that can handle large buffers. - sed < "$tmpdepfile" -n ' -/^Note: including file: *\(.*\)/ { - s//\1/ - s/\\/\\\\/g - p -}' | $cygpath_u | sort -u | sed -n ' -s/ /\\ /g -s/\(.*\)/'"$tab"'\1 \\/p -s/.\(.*\) \\/\1:/ -H -$ { - s/.*/'"$tab"'/ - G - p -}' >> "$depfile" - echo >> "$depfile" # make sure the fragment doesn't end with a backslash - rm -f "$tmpdepfile" - ;; - -msvc7msys) - # 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 - ;; - -#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 "X$1" != 'X--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|^[$tab ]*[^:$tab ][^:][^:]*:[$tab ]*|$object: |" > "$tmpdepfile" - rm -f "$depfile" - cat < "$tmpdepfile" > "$depfile" - # Some versions of the HPUX 10.20 sed can't process this sed invocation - # correctly. Breaking it into two sed invocations is a workaround. - tr ' ' "$nl" < "$tmpdepfile" \ - | 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 "X$1" != 'X--mode=compile'; do - shift - done - shift - fi - # X makedepend - shift - cleared=no eat=no - for arg - do - case $cleared in - no) - set ""; shift - cleared=yes ;; - esac - if test $eat = yes; then - eat=no - continue - fi - 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. - -arch) - eat=yes ;; - -*|$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" - # makedepend may prepend the VPATH from the source file name to the object. - # No need to regex-escape $object, excess matching of '.' is harmless. - sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile" - # Some versions of the HPUX 10.20 sed can't process the last invocation - # correctly. Breaking it into two sed invocations is a workaround. - sed '1,2d' "$tmpdepfile" \ - | tr ' ' "$nl" \ - | 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 "X$1" != 'X--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 -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ - -e '/^#line [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. - "$@" || exit $? - - # Remove the call to Libtool. - if test "$libtool" = yes; then - while test "X$1" != 'X--mode=compile'; do - shift - done - shift - fi - - IFS=" " - for arg - do - case "$arg" in - -o) - shift - ;; - $object) - shift - ;; - "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") - set fnord "$@" - shift - shift - ;; - *) - set fnord "$@" "$arg" - shift - shift - ;; - esac - done - "$@" -E 2>/dev/null | - sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile" - rm -f "$depfile" - echo "$object : \\" > "$depfile" - sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::'"$tab"'\1 \\:p' >> "$depfile" - echo "$tab" >> "$depfile" - sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile" - rm -f "$tmpdepfile" - ;; - -msvcmsys) - # 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 - ;; - -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-time-zone: "UTC" -# time-stamp-end: "; # UTC" -# End: diff --git a/vppversion/elftool.c b/vppversion/elftool.c deleted file mode 100644 index c0184b5c..00000000 --- a/vppversion/elftool.c +++ /dev/null @@ -1,459 +0,0 @@ -/* - * Copyright (c) 2015 Cisco and/or its affiliates. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - Copyright (c) 2008 Eliot Dresselhaus - - 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 AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -#include - -#include -#include -#include - -#ifndef CLIB_UNIX -#error "unix only" -#endif - -typedef struct { - elf_main_t elf_main; - char * input_file; - char * output_file; - char * set_interpreter; - char * set_rpath; - int unset_rpath; - int verbose; - int quiet; - int allow_elf_shared; - /* for use in the optimized / simplified case */ - u64 file_size; - u64 interpreter_offset; - u64 rpath_offset; -} elf_tool_main_t; - -static clib_error_t * elf_set_interpreter (elf_main_t * em, - elf_tool_main_t * tm) -{ - elf_segment_t * g; - elf_section_t * s; - clib_error_t * error; - char * interp = tm->set_interpreter; - - switch (em->first_header.file_type) - { - case ELF_EXEC: - break; - - case ELF_SHARED: - if (tm->allow_elf_shared) - break; - /* Note flowthrough */ - default: - return clib_error_return (0, "unacceptable file_type"); - } - - vec_foreach (g, em->segments) - { - if (g->header.type == ELF_SEGMENT_INTERP) - break; - } - - if (g >= vec_end (em->segments)) - return clib_error_return (0, "interpreter not found"); - - if (g->header.memory_size < 1 + strlen (interp)) - return clib_error_return (0, "given interpreter does not fit; must be less than %d bytes (`%s' given)", - g->header.memory_size, interp); - - error = elf_get_section_by_start_address (em, g->header.virtual_address, &s); - if (error) - return error; - - /* Put in new null terminated string. */ - memset (s->contents, 0, vec_len (s->contents)); - memcpy (s->contents, interp, strlen (interp)); - - return 0; -} - -static void -delete_rpath_for_section (elf_main_t * em, elf_section_t * s) -{ - elf64_dynamic_entry_t * e; - elf64_dynamic_entry_t * new_es = 0; - - vec_foreach (e, em->dynamic_entries) - { - switch (e->type) - { - case ELF_DYNAMIC_ENTRY_RPATH: - case ELF_DYNAMIC_ENTRY_RUN_PATH: - break; - - default: - vec_add1 (new_es, e[0]); - break; - } - } - - /* Pad so as to keep section size constant. */ - { - elf64_dynamic_entry_t e_end; - e_end.type = ELF_DYNAMIC_ENTRY_END; - e_end.data = 0; - while (vec_len (new_es) < vec_len (em->dynamic_entries)) - vec_add1 (new_es, e_end); - } - - vec_free (em->dynamic_entries); - em->dynamic_entries = new_es; - - elf_set_dynamic_entries (em); -} - -static void delete_rpath (elf_main_t * em) -{ - elf_section_t * s; - - vec_foreach (s, em->sections) - { - switch (s->header.type) - { - case ELF_SECTION_DYNAMIC: - delete_rpath_for_section (em, s); - break; - - default: - break; - } - } -} - -static clib_error_t * -set_rpath_for_section (elf_main_t * em, elf_section_t * s, char * new_rpath) -{ - elf64_dynamic_entry_t * e; - char * old_rpath; - int old_len, new_len = strlen (new_rpath); - u8 * new_string_table = vec_dup (em->dynamic_string_table); - - vec_foreach (e, em->dynamic_entries) - { - switch (e->type) - { - case ELF_DYNAMIC_ENTRY_RPATH: - case ELF_DYNAMIC_ENTRY_RUN_PATH: - old_rpath = (char *) new_string_table + e->data; - old_len = strlen (old_rpath); - if (old_len < new_len) - return clib_error_return (0, "rpath of `%s' does not fit (old rpath `%s')", - new_rpath, old_rpath); - strcpy (old_rpath, new_rpath); - break; - - default: - break; - } - } - - elf_set_section_contents (em, em->dynamic_string_table_section_index, - new_string_table, - vec_bytes (new_string_table)); - - return 0; -} - -static clib_error_t * -set_rpath (elf_main_t * em, char * rpath) -{ - clib_error_t * error = 0; - elf_section_t * s; - - vec_foreach (s, em->sections) - { - switch (s->header.type) - { - case ELF_SECTION_DYNAMIC: - error = set_rpath_for_section (em, s, rpath); - if (error) - return error; - break; - - default: - break; - } - } - - return error; -} - -static clib_error_t * -set_interpreter_rpath (elf_tool_main_t * tm) -{ - int ifd = -1, ofd = -1; - struct stat fd_stat; - u8 *idp = 0; /* warning be gone */ - u64 mmap_length = 0, i; - u32 run_length; - u8 in_run; - u64 offset0 = 0, offset1 = 0; - clib_error_t * error; - int fix_in_place = 0; - - if (!strcmp (tm->input_file, tm->output_file)) - fix_in_place = 1; - - ifd = open (tm->input_file, O_RDWR); - if (ifd < 0) - { - error = clib_error_return_unix (0, "open `%s'", tm->input_file); - goto done; - } - - if (fstat (ifd, &fd_stat) < 0) - { - error = clib_error_return_unix (0, "fstat `%s'", tm->input_file); - goto done; - } - - if (!(fd_stat.st_mode & S_IFREG)) - { - error = clib_error_return (0, "%s is not a regular file", tm->input_file); - goto done; - } - - mmap_length = fd_stat.st_size; - if (mmap_length < 4) - { - error = clib_error_return (0, "%s too short", tm->input_file); - goto done; - } - - /* COW-mapping, since we intend to write the fixups */ - if (fix_in_place) - idp = mmap (0, mmap_length, PROT_READ | PROT_WRITE, MAP_SHARED, - ifd, /* offset */ 0); - else - idp = mmap (0, mmap_length, PROT_READ | PROT_WRITE, MAP_PRIVATE, - ifd, /* offset */ 0); - if (~pointer_to_uword (idp) == 0) - { - mmap_length = 0; - error = clib_error_return_unix (0, "mmap `%s'", tm->input_file); - goto done; - } - - if (idp[0] != 0x7f || idp[1] != 'E' || idp[2] != 'L' || idp[3] != 'F') - { - error = clib_error_return (0, "not an ELF file '%s'", tm->input_file); - goto done; - } - - in_run = 0; - run_length = 0; - - for (i = 0; i < mmap_length; i++) - { - if (idp[i] == '/') - { - if (in_run) - run_length++; - else - { - in_run = 1; - run_length = 1; - } - } - else - { - if (in_run && run_length >= 16) - { - if (offset0 == 0) - offset0 = (i - run_length); - else if (offset1 == 0) - { - offset1 = (i - run_length); - goto found_both; - } - } - in_run = 0; - run_length = 0; - } - } - - if (offset0 == 0) - { - error = clib_error_return (0, "no fixup markers in %s", - tm->input_file); - goto done; - } - - found_both: - if (0) - clib_warning ("offset0 %lld (0x%llx), offset1 %lld (0x%llx)", - offset0, offset0, offset1, offset1); - - /* Executable file case */ - if (offset0 && offset1) - { - tm->interpreter_offset = offset0; - tm->rpath_offset = offset1; - } - else /* shared library case */ - { - tm->interpreter_offset = 0; - tm->rpath_offset = offset0; - } - - if (tm->interpreter_offset) - memcpy (&idp[tm->interpreter_offset], tm->set_interpreter, - strlen (tm->set_interpreter)+1); - - if (tm->rpath_offset) - memcpy (&idp[tm->rpath_offset], tm->set_rpath, - strlen (tm->set_rpath)+1); - - /* Write the output file... */ - if (fix_in_place == 0) - { - ofd = open (tm->output_file, O_RDWR | O_CREAT | O_TRUNC, 0644); - if (ofd < 0) - { - error = clib_error_return_unix (0, "create `%s'", tm->output_file); - goto done; - } - - if (write (ofd, idp, mmap_length) != mmap_length) - error = clib_error_return_unix (0, "write `%s'", tm->output_file); - } - - done: - if (mmap_length > 0) - munmap (idp, mmap_length); - close (ifd); - close (ofd); - return error; -} - - -int main (int argc, char * argv[]) -{ - elf_tool_main_t _tm, * tm = &_tm; - elf_main_t * em = &tm->elf_main; - unformat_input_t i; - clib_error_t * error = 0; - - memset (tm, 0, sizeof (tm[0])); - unformat_init_command_line (&i, argv); - - while (unformat_check_input (&i) != UNFORMAT_END_OF_INPUT) - { - if (unformat (&i, "in %s", &tm->input_file)) - ; - else if (unformat (&i, "out %s", &tm->output_file)) - ; - else if (unformat (&i, "set-interpreter %s", &tm->set_interpreter)) - ; - else if (unformat (&i, "set-rpath %s", &tm->set_rpath)) - ; - else if (unformat (&i, "unset-rpath")) - tm->unset_rpath = 1; - else if (unformat (&i, "verbose")) - tm->verbose = ~0; - else if (unformat (&i, "verbose-symbols")) - tm->verbose |= FORMAT_ELF_MAIN_SYMBOLS; - else if (unformat (&i, "verbose-relocations")) - tm->verbose |= FORMAT_ELF_MAIN_RELOCATIONS; - else if (unformat (&i, "verbose-dynamic")) - tm->verbose |= FORMAT_ELF_MAIN_DYNAMIC; - else if (unformat (&i, "quiet")) - tm->quiet = 1; - else if (unformat (&i, "allow-elf-shared")) - tm->allow_elf_shared = 1; - else - { - error = unformat_parse_error (&i); - goto done; - } - } - - if (! tm->input_file) - clib_error ("no input file"); - - /* Do the typical case a stone-simple way... */ - if (tm->quiet && tm->set_interpreter && tm->set_rpath && tm->output_file) - { - error = set_interpreter_rpath (tm); - goto done; - } - - error = elf_read_file (em, tm->input_file); - - if (error) - goto done; - - if (tm->verbose) - fformat (stdout, "%U", format_elf_main, em, tm->verbose); - - if (tm->set_interpreter) - { - error = elf_set_interpreter (em, tm); - if (error) - goto done; - } - - if (tm->set_rpath) - { - error = set_rpath (em, tm->set_rpath); - if (error) - goto done; - } - - if (tm->unset_rpath) - delete_rpath (em); - - if (tm->output_file) - error = elf_write_file (em, tm->output_file); - - elf_main_free (em); - - done: - if (error) - { - if (tm->quiet == 0) - clib_error_report (error); - return 1; - } - else - return 0; -} diff --git a/vppversion/install-sh b/vppversion/install-sh deleted file mode 100755 index 377bb868..00000000 --- a/vppversion/install-sh +++ /dev/null @@ -1,527 +0,0 @@ -#!/bin/sh -# install - install a program, script, or datafile - -scriptversion=2011-11-20.07; # UTC - -# 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. - -nl=' -' -IFS=" "" $nl" - -# set DOITPROG to echo to test this script - -# Don't use :- since 4.3BSD and earlier shells don't like it. -doit=${DOITPROG-} -if test -z "$doit"; then - doit_exec=exec -else - doit_exec=$doit -fi - -# Put in absolute file names if you don't have them in your path; -# or use environment vars. - -chgrpprog=${CHGRPPROG-chgrp} -chmodprog=${CHMODPROG-chmod} -chownprog=${CHOWNPROG-chown} -cmpprog=${CMPPROG-cmp} -cpprog=${CPPROG-cp} -mkdirprog=${MKDIRPROG-mkdir} -mvprog=${MVPROG-mv} -rmprog=${RMPROG-rm} -stripprog=${STRIPPROG-strip} - -posix_glob='?' -initialize_posix_glob=' - test "$posix_glob" != "?" || { - if (set -f) 2>/dev/null; then - posix_glob= - else - posix_glob=: - fi - } -' - -posix_mkdir= - -# Desired mode of installed file. -mode=0755 - -chgrpcmd= -chmodcmd=$chmodprog -chowncmd= -mvcmd=$mvprog -rmcmd="$rmprog -f" -stripcmd= - -src= -dst= -dir_arg= -dst_arg= - -copy_on_change=false -no_target_directory= - -usage="\ -Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE - or: $0 [OPTION]... SRCFILES... DIRECTORY - or: $0 [OPTION]... -t DIRECTORY SRCFILES... - or: $0 [OPTION]... -d DIRECTORIES... - -In the 1st form, copy SRCFILE to DSTFILE. -In the 2nd and 3rd, copy all SRCFILES to DIRECTORY. -In the 4th, create DIRECTORIES. - -Options: - --help display this help and exit. - --version display version info and exit. - - -c (ignored) - -C install only if different (preserve the last data modification time) - -d create directories instead of installing files. - -g GROUP $chgrpprog installed files to GROUP. - -m MODE $chmodprog installed files to MODE. - -o USER $chownprog installed files to USER. - -s $stripprog installed files. - -t DIRECTORY install into DIRECTORY. - -T report an error if DSTFILE is a directory. - -Environment variables override the default commands: - CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG - RMPROG STRIPPROG -" - -while test $# -ne 0; do - case $1 in - -c) ;; - - -C) copy_on_change=true;; - - -d) dir_arg=true;; - - -g) chgrpcmd="$chgrpprog $2" - shift;; - - --help) echo "$usage"; exit $?;; - - -m) mode=$2 - case $mode in - *' '* | *' '* | *' -'* | *'*'* | *'?'* | *'['*) - echo "$0: invalid mode: $mode" >&2 - exit 1;; - esac - shift;; - - -o) chowncmd="$chownprog $2" - shift;; - - -s) stripcmd=$stripprog;; - - -t) dst_arg=$2 - # Protect names problematic for 'test' and other utilities. - case $dst_arg in - -* | [=\(\)!]) dst_arg=./$dst_arg;; - esac - shift;; - - -T) no_target_directory=true;; - - --version) echo "$0 $scriptversion"; exit $?;; - - --) shift - break;; - - -*) echo "$0: invalid option: $1" >&2 - exit 1;; - - *) break;; - esac - shift -done - -if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then - # When -d is used, all remaining arguments are directories to create. - # When -t is used, the destination is already specified. - # Otherwise, the last argument is the destination. Remove it from $@. - for arg - do - if test -n "$dst_arg"; then - # $@ is not empty: it contains at least $arg. - set fnord "$@" "$dst_arg" - shift # fnord - fi - shift # arg - dst_arg=$arg - # Protect names problematic for 'test' and other utilities. - case $dst_arg in - -* | [=\(\)!]) dst_arg=./$dst_arg;; - esac - done -fi - -if test $# -eq 0; 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 - -if test -z "$dir_arg"; then - do_exit='(exit $ret); exit $ret' - trap "ret=129; $do_exit" 1 - trap "ret=130; $do_exit" 2 - trap "ret=141; $do_exit" 13 - trap "ret=143; $do_exit" 15 - - # Set umask so as not to create temps with too-generous modes. - # However, 'strip' requires both read and write access to temps. - case $mode in - # Optimize common cases. - *644) cp_umask=133;; - *755) cp_umask=22;; - - *[0-7]) - if test -z "$stripcmd"; then - u_plus_rw= - else - u_plus_rw='% 200' - fi - cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;; - *) - if test -z "$stripcmd"; then - u_plus_rw= - else - u_plus_rw=,u+rw - fi - cp_umask=$mode$u_plus_rw;; - esac -fi - -for src -do - # Protect names problematic for 'test' and other utilities. - case $src in - -* | [=\(\)!]) src=./$src;; - esac - - if test -n "$dir_arg"; then - dst=$src - dstdir=$dst - test -d "$dstdir" - dstdir_status=$? - else - - # Waiting for this to be detected by the "$cpprog $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 "$dst_arg"; then - echo "$0: no destination specified." >&2 - exit 1 - fi - dst=$dst_arg - - # If destination is a directory, append the input filename; won't work - # if double slashes aren't ignored. - if test -d "$dst"; then - if test -n "$no_target_directory"; then - echo "$0: $dst_arg: Is a directory" >&2 - exit 1 - fi - dstdir=$dst - dst=$dstdir/`basename "$src"` - dstdir_status=0 - else - # Prefer dirname, but fall back on a substitute if dirname fails. - dstdir=` - (dirname "$dst") 2>/dev/null || - expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$dst" : 'X\(//\)[^/]' \| \ - X"$dst" : 'X\(//\)$' \| \ - X"$dst" : 'X\(/\)' \| . 2>/dev/null || - echo X"$dst" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q' - ` - - test -d "$dstdir" - dstdir_status=$? - fi - fi - - obsolete_mkdir_used=false - - if test $dstdir_status != 0; then - case $posix_mkdir in - '') - # Create intermediate dirs using mode 755 as modified by the umask. - # This is like FreeBSD 'install' as of 1997-10-28. - umask=`umask` - case $stripcmd.$umask in - # Optimize common cases. - *[2367][2367]) mkdir_umask=$umask;; - .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;; - - *[0-7]) - mkdir_umask=`expr $umask + 22 \ - - $umask % 100 % 40 + $umask % 20 \ - - $umask % 10 % 4 + $umask % 2 - `;; - *) mkdir_umask=$umask,go-w;; - esac - - # With -d, create the new directory with the user-specified mode. - # Otherwise, rely on $mkdir_umask. - if test -n "$dir_arg"; then - mkdir_mode=-m$mode - else - mkdir_mode= - fi - - posix_mkdir=false - case $umask in - *[123567][0-7][0-7]) - # POSIX mkdir -p sets u+wx bits regardless of umask, which - # is incompatible with FreeBSD 'install' when (umask & 300) != 0. - ;; - *) - tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ - trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0 - - if (umask $mkdir_umask && - exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1 - then - if test -z "$dir_arg" || { - # Check for POSIX incompatibilities with -m. - # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or - # other-writable bit of parent directory when it shouldn't. - # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. - ls_ld_tmpdir=`ls -ld "$tmpdir"` - case $ls_ld_tmpdir in - d????-?r-*) different_mode=700;; - d????-?--*) different_mode=755;; - *) false;; - esac && - $mkdirprog -m$different_mode -p -- "$tmpdir" && { - ls_ld_tmpdir_1=`ls -ld "$tmpdir"` - test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" - } - } - then posix_mkdir=: - fi - rmdir "$tmpdir/d" "$tmpdir" - else - # Remove any dirs left behind by ancient mkdir implementations. - rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null - fi - trap '' 0;; - esac;; - esac - - if - $posix_mkdir && ( - umask $mkdir_umask && - $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir" - ) - then : - else - - # The umask is ridiculous, or mkdir does not conform to POSIX, - # or it failed possibly due to a race condition. Create the - # directory the slow way, step by step, checking for races as we go. - - case $dstdir in - /*) prefix='/';; - [-=\(\)!]*) prefix='./';; - *) prefix='';; - esac - - eval "$initialize_posix_glob" - - oIFS=$IFS - IFS=/ - $posix_glob set -f - set fnord $dstdir - shift - $posix_glob set +f - IFS=$oIFS - - prefixes= - - for d - do - test X"$d" = X && continue - - prefix=$prefix$d - if test -d "$prefix"; then - prefixes= - else - if $posix_mkdir; then - (umask=$mkdir_umask && - $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break - # Don't fail if two instances are running concurrently. - test -d "$prefix" || exit 1 - else - case $prefix in - *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;; - *) qprefix=$prefix;; - esac - prefixes="$prefixes '$qprefix'" - fi - fi - prefix=$prefix/ - done - - if test -n "$prefixes"; then - # Don't fail if two instances are running concurrently. - (umask $mkdir_umask && - eval "\$doit_exec \$mkdirprog $prefixes") || - test -d "$dstdir" || exit 1 - obsolete_mkdir_used=true - fi - fi - fi - - if test -n "$dir_arg"; then - { test -z "$chowncmd" || $doit $chowncmd "$dst"; } && - { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } && - { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false || - test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1 - else - - # 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 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 - - # Copy the file name to the temp name. - (umask $cp_umask && $doit_exec $cpprog "$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 $cpprog $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 $mode "$dsttmp"; } && - - # If -C, don't bother to copy if it wouldn't change the file. - if $copy_on_change && - old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` && - new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` && - - eval "$initialize_posix_glob" && - $posix_glob set -f && - set X $old && old=:$2:$4:$5:$6 && - set X $new && new=:$2:$4:$5:$6 && - $posix_glob set +f && - - test "$old" = "$new" && - $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1 - then - rm -f "$dsttmp" - else - # Rename the file to the real destination. - $doit $mvcmd -f "$dsttmp" "$dst" 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. - { - test ! -f "$dst" || - $doit $rmcmd -f "$dst" 2>/dev/null || - { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null && - { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; } - } || - { echo "$0: cannot unlink or rename $dst" >&2 - (exit 1); exit 1 - } - } && - - # Now rename the file to the real destination. - $doit $mvcmd "$dsttmp" "$dst" - } - fi || exit 1 - - trap '' 0 - fi -done - -# Local variables: -# eval: (add-hook 'write-file-hooks 'time-stamp) -# time-stamp-start: "scriptversion=" -# time-stamp-format: "%:y-%02m-%02d.%02H" -# time-stamp-time-zone: "UTC" -# time-stamp-end: "; # UTC" -# End: diff --git a/vppversion/ltmain.sh b/vppversion/ltmain.sh deleted file mode 100644 index a356acaf..00000000 --- a/vppversion/ltmain.sh +++ /dev/null @@ -1,9661 +0,0 @@ - -# libtool (GNU libtool) 2.4.2 -# Written by Gordon Matzigkeit , 1996 - -# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, -# 2007, 2008, 2009, 2010, 2011 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 -# --no-quiet, --no-silent -# print informational messages (default) -# --no-warn don't display warning messages -# --tag=TAG use configuration variables from tag TAG -# -v, --verbose print more informational messages than default -# --no-verbose don't print the extra informational messages -# --version print version information -# -h, --help, --help-all print short, long, or detailed 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. When passed as first option, -# `--mode=MODE' may be abbreviated as `MODE' or a unique abbreviation of that. -# 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.4.2 Debian-2.4.2-1.7ubuntu1 -# automake: $automake_version -# autoconf: $autoconf_version -# -# Report bugs to . -# GNU libtool home page: . -# General help using GNU software: . - -PROGRAM=libtool -PACKAGE=libtool -VERSION="2.4.2 Debian-2.4.2-1.7ubuntu1" -TIMESTAMP="" -package_revision=1.3337 - -# 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 - -# A function that is used when there is no print builtin or printf. -func_fallback_echo () -{ - eval 'cat <<_LTECHO_EOF -$1 -_LTECHO_EOF' -} - -# NLS nuisances: We save the old values to restore during execute mode. -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 -LC_ALL=C -LANGUAGE=C -export LANGUAGE LC_ALL - -$lt_unset CDPATH - - -# 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" - - - -: ${CP="cp -f"} -test "${ECHO+set}" = set || ECHO=${as_echo-'printf %s\n'} -: ${MAKE="make"} -: ${MKDIR="mkdir"} -: ${MV="mv -f"} -: ${RM="rm -f"} -: ${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 file append nondir_replacement -# Compute the dirname of FILE. If nonempty, add APPEND to the result, -# otherwise set result to NONDIR_REPLACEMENT. -func_dirname () -{ - func_dirname_result=`$ECHO "${1}" | $SED "$dirname"` - if test "X$func_dirname_result" = "X${1}"; then - func_dirname_result="${3}" - else - func_dirname_result="$func_dirname_result${2}" - fi -} # func_dirname may be replaced by extended shell implementation - - -# func_basename file -func_basename () -{ - func_basename_result=`$ECHO "${1}" | $SED "$basename"` -} # func_basename may be replaced by extended shell implementation - - -# 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 "${1}" | $SED -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 "${1}" | $SED -e "$basename"` -} # func_dirname_and_basename may be replaced by extended shell implementation - - -# 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 "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;; - *) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;; - esac -} # func_stripname may be replaced by extended shell implementation - - -# These SED scripts presuppose an absolute path with a trailing slash. -pathcar='s,^/\([^/]*\).*$,\1,' -pathcdr='s,^/[^/]*,,' -removedotparts=':dotsl - s@/\./@/@g - t dotsl - s,/\.$,/,' -collapseslashes='s@/\{1,\}@/@g' -finalslash='s,/*$,/,' - -# func_normal_abspath PATH -# Remove doubled-up and trailing slashes, "." path components, -# and cancel out any ".." path components in PATH after making -# it an absolute path. -# value returned in "$func_normal_abspath_result" -func_normal_abspath () -{ - # Start from root dir and reassemble the path. - func_normal_abspath_result= - func_normal_abspath_tpath=$1 - func_normal_abspath_altnamespace= - case $func_normal_abspath_tpath in - "") - # Empty path, that just means $cwd. - func_stripname '' '/' "`pwd`" - func_normal_abspath_result=$func_stripname_result - return - ;; - # The next three entries are used to spot a run of precisely - # two leading slashes without using negated character classes; - # we take advantage of case's first-match behaviour. - ///*) - # Unusual form of absolute path, do nothing. - ;; - //*) - # Not necessarily an ordinary path; POSIX reserves leading '//' - # and for example Cygwin uses it to access remote file shares - # over CIFS/SMB, so we conserve a leading double slash if found. - func_normal_abspath_altnamespace=/ - ;; - /*) - # Absolute path, do nothing. - ;; - *) - # Relative path, prepend $cwd. - func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath - ;; - esac - # Cancel out all the simple stuff to save iterations. We also want - # the path to end with a slash for ease of parsing, so make sure - # there is one (and only one) here. - func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ - -e "$removedotparts" -e "$collapseslashes" -e "$finalslash"` - while :; do - # Processed it all yet? - if test "$func_normal_abspath_tpath" = / ; then - # If we ascended to the root using ".." the result may be empty now. - if test -z "$func_normal_abspath_result" ; then - func_normal_abspath_result=/ - fi - break - fi - func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \ - -e "$pathcar"` - func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ - -e "$pathcdr"` - # Figure out what to do with it - case $func_normal_abspath_tcomponent in - "") - # Trailing empty path component, ignore it. - ;; - ..) - # Parent dir; strip last assembled component from result. - func_dirname "$func_normal_abspath_result" - func_normal_abspath_result=$func_dirname_result - ;; - *) - # Actual path component, append it. - func_normal_abspath_result=$func_normal_abspath_result/$func_normal_abspath_tcomponent - ;; - esac - done - # Restore leading double-slash if one was found on entry. - func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result -} - -# func_relative_path SRCDIR DSTDIR -# generates a relative path from SRCDIR to DSTDIR, with a trailing -# slash if non-empty, suitable for immediately appending a filename -# without needing to append a separator. -# value returned in "$func_relative_path_result" -func_relative_path () -{ - func_relative_path_result= - func_normal_abspath "$1" - func_relative_path_tlibdir=$func_normal_abspath_result - func_normal_abspath "$2" - func_relative_path_tbindir=$func_normal_abspath_result - - # Ascend the tree starting from libdir - while :; do - # check if we have found a prefix of bindir - case $func_relative_path_tbindir in - $func_relative_path_tlibdir) - # found an exact match - func_relative_path_tcancelled= - break - ;; - $func_relative_path_tlibdir*) - # found a matching prefix - func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir" - func_relative_path_tcancelled=$func_stripname_result - if test -z "$func_relative_path_result"; then - func_relative_path_result=. - fi - break - ;; - *) - func_dirname $func_relative_path_tlibdir - func_relative_path_tlibdir=${func_dirname_result} - if test "x$func_relative_path_tlibdir" = x ; then - # Have to descend all the way to the root! - func_relative_path_result=../$func_relative_path_result - func_relative_path_tcancelled=$func_relative_path_tbindir - break - fi - func_relative_path_result=../$func_relative_path_result - ;; - esac - done - - # Now calculate path; take care to avoid doubling-up slashes. - func_stripname '' '/' "$func_relative_path_result" - func_relative_path_result=$func_stripname_result - func_stripname '/' '/' "$func_relative_path_tcancelled" - if test "x$func_stripname_result" != x ; then - func_relative_path_result=${func_relative_path_result}/${func_stripname_result} - fi - - # Normalisation. If bindir is libdir, return empty string, - # else relative path ending with a slash; either way, target - # file name can be directly appended. - if test ! -z "$func_relative_path_result"; then - func_stripname './' '' "$func_relative_path_result/" - func_relative_path_result=$func_stripname_result - fi -} - -# The name of this program: -func_dirname_and_basename "$progpath" -progname=$func_basename_result - -# 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=${PATH_SEPARATOR-:} - 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' - -# Sed substitution that turns a string into a regex matching for the -# string literally. -sed_make_literal_regex='s,[].[^$\\*\/],\\&,g' - -# Sed substitution that converts a w32 file name or path -# which contains forward slashes, into one that contains -# (escaped) backslashes. A very naive implementation. -lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|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: ${opt_mode+$opt_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_echo_all arg... -# Invoke $ECHO with all args, space-separated. -func_echo_all () -{ - $ECHO "$*" -} - -# func_error arg... -# Echo program name prefixed message to standard error. -func_error () -{ - $ECHO "$progname: ${opt_mode+$opt_mode: }"${1+"$@"} 1>&2 -} - -# func_warning arg... -# Echo program name prefixed warning message to standard error. -func_warning () -{ - $opt_warning && $ECHO "$progname: ${opt_mode+$opt_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 "$my_directory_path" | $SED -e "$dirname"` - done - my_dir_list=`$ECHO "$my_dir_list" | $SED '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 "$my_tmpdir" -} - - -# 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 "$1" | $SED "$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 "$1" | $SED \ - -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_tr_sh -# Turn $1 into a string suitable for a shell variable name. -# Result is stored in $func_tr_sh_result. All characters -# not in the set a-zA-Z0-9_ are replaced with '_'. Further, -# if $1 begins with a digit, a '_' is prepended as well. -func_tr_sh () -{ - case $1 in - [0-9]* | *[!a-zA-Z0-9_]*) - func_tr_sh_result=`$ECHO "$1" | $SED 's/^\([0-9]\)/_\1/; s/[^a-zA-Z0-9_]/_/g'` - ;; - * ) - func_tr_sh_result=$1 - ;; - esac -} - - -# func_version -# Echo version message to standard output and exit. -func_version () -{ - $opt_debug - - $SED -n '/(C)/!b go - :more - /\./!{ - N - s/\n# / / - b more - } - :go - /^# '$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 () -{ - $opt_debug - - $SED -n '/^# Usage:/,/^# *.*--help/ { - s/^# // - s/^# *$// - s/\$progname/'$progname'/ - p - }' < "$progpath" - echo - $ECHO "run \`$progname --help | more' for full usage" - exit $? -} - -# func_help [NOEXIT] -# Echo long help message to standard output and exit, -# unless 'noexit' is passed as argument. -func_help () -{ - $opt_debug - - $SED -n '/^# Usage:/,/# Report bugs to/ { - :print - 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-automake} --version) 2>/dev/null |$SED 1q`"'/ - s/\$autoconf_version/'"`(${AUTOCONF-autoconf} --version) 2>/dev/null |$SED 1q`"'/ - p - d - } - /^# .* home page:/b print - /^# General help using/b print - ' < "$progpath" - ret=$? - if test -z "$1"; then - exit $ret - fi -} - -# func_missing_arg argname -# Echo program name prefixed message to standard error and set global -# exit_cmd. -func_missing_arg () -{ - $opt_debug - - func_error "missing argument for $1." - exit_cmd=exit -} - - -# func_split_short_opt shortopt -# Set func_split_short_opt_name and func_split_short_opt_arg shell -# variables after splitting SHORTOPT after the 2nd character. -func_split_short_opt () -{ - my_sed_short_opt='1s/^\(..\).*$/\1/;q' - my_sed_short_rest='1s/^..\(.*\)$/\1/;q' - - func_split_short_opt_name=`$ECHO "$1" | $SED "$my_sed_short_opt"` - func_split_short_opt_arg=`$ECHO "$1" | $SED "$my_sed_short_rest"` -} # func_split_short_opt may be replaced by extended shell implementation - - -# func_split_long_opt longopt -# Set func_split_long_opt_name and func_split_long_opt_arg shell -# variables after splitting LONGOPT at the `=' sign. -func_split_long_opt () -{ - my_sed_long_opt='1s/^\(--[^=]*\)=.*/\1/;q' - my_sed_long_arg='1s/^--[^=]*=//' - - func_split_long_opt_name=`$ECHO "$1" | $SED "$my_sed_long_opt"` - func_split_long_opt_arg=`$ECHO "$1" | $SED "$my_sed_long_arg"` -} # func_split_long_opt may be replaced by extended shell implementation - -exit_cmd=: - - - - - -magic="%%%MAGIC variable%%%" -magic_exe="%%%MAGIC EXE variable%%%" - -# Global variables. -nonopt= -preserve_args= -lo2o="s/\\.lo\$/.${objext}/" -o2lo="s/\\.${objext}\$/.lo/" -extracted_archives= -extracted_serial=0 - -# If this variable is set in any of the actions, the command in it -# will be execed at the end. This prevents here-documents from being -# left over by shells. -exec_cmd= - -# func_append var value -# Append VALUE to the end of shell variable VAR. -func_append () -{ - eval "${1}=\$${1}\${2}" -} # func_append may be replaced by extended shell implementation - -# func_append_quoted var value -# Quote VALUE and append to the end of shell variable VAR, separated -# by a space. -func_append_quoted () -{ - func_quote_for_eval "${2}" - eval "${1}=\$${1}\\ \$func_quote_for_eval_result" -} # func_append_quoted may be replaced by extended shell implementation - - -# func_arith arithmetic-term... -func_arith () -{ - func_arith_result=`expr "${@}"` -} # func_arith may be replaced by extended shell implementation - - -# func_len string -# STRING may not start with a hyphen. -func_len () -{ - func_len_result=`expr "${1}" : ".*" 2>/dev/null || echo $max_cmd_len` -} # func_len may be replaced by extended shell implementation - - -# func_lo2o object -func_lo2o () -{ - func_lo2o_result=`$ECHO "${1}" | $SED "$lo2o"` -} # func_lo2o may be replaced by extended shell implementation - - -# func_xform libobj-or-source -func_xform () -{ - func_xform_result=`$ECHO "${1}" | $SED 's/\.[^.]*$/.lo/'` -} # func_xform may be replaced by extended shell implementation - - -# func_fatal_configuration arg... -# Echo program name prefixed message to standard error, followed by -# a configuration failure hint, and exit. -func_fatal_configuration () -{ - func_error ${1+"$@"} - func_error "See the $PACKAGE documentation for more information." - func_fatal_error "Fatal configuration error." -} - - -# func_config -# Display the configuration for all the tags in this script. -func_config () -{ - re_begincf='^# ### BEGIN LIBTOOL' - re_endcf='^# ### END LIBTOOL' - - # Default configuration. - $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath" - - # Now print the configurations for the tags. - for tagname in $taglist; do - $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath" - done - - exit $? -} - -# func_features -# Display the features supported by this script. -func_features () -{ - echo "host: $host" - if test "$build_libtool_libs" = yes; then - echo "enable shared libraries" - else - echo "disable shared libraries" - fi - if test "$build_old_libs" = yes; then - echo "enable static libraries" - else - echo "disable static libraries" - fi - - exit $? -} - -# func_enable_tag tagname -# Verify that TAGNAME is valid, and either flag an error and exit, or -# enable the TAGNAME tag. We also add TAGNAME to the global $taglist -# variable here. -func_enable_tag () -{ - # Global variable: - tagname="$1" - - re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" - re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" - sed_extractcf="/$re_begincf/,/$re_endcf/p" - - # Validate tagname. - case $tagname in - *[!-_A-Za-z0-9,/]*) - func_fatal_error "invalid tag name: $tagname" - ;; - esac - - # Don't test for the "default" C tag, as we know it's - # there but not specially marked. - case $tagname in - CC) ;; - *) - if $GREP "$re_begincf" "$progpath" >/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 -} - -# 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 -} - - -# 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 - - - -# Option defaults: -opt_debug=: -opt_dry_run=false -opt_config=false -opt_preserve_dup_deps=false -opt_features=false -opt_finish=false -opt_help=false -opt_help_all=false -opt_silent=: -opt_warning=: -opt_verbose=: -opt_silent=false -opt_verbose=false - - -# Parse options once, thoroughly. This comes as soon as possible in the -# script to make things like `--version' happen as quickly as we can. -{ - # this just eases exit handling - while test $# -gt 0; do - opt="$1" - shift - case $opt in - --debug|-x) opt_debug='set -x' - func_echo "enabling shell trace mode" - $opt_debug - ;; - --dry-run|--dryrun|-n) - opt_dry_run=: - ;; - --config) - opt_config=: -func_config - ;; - --dlopen|-dlopen) - optarg="$1" - opt_dlopen="${opt_dlopen+$opt_dlopen -}$optarg" - shift - ;; - --preserve-dup-deps) - opt_preserve_dup_deps=: - ;; - --features) - opt_features=: -func_features - ;; - --finish) - opt_finish=: -set dummy --mode finish ${1+"$@"}; shift - ;; - --help) - opt_help=: - ;; - --help-all) - opt_help_all=: -opt_help=': help-all' - ;; - --mode) - test $# = 0 && func_missing_arg $opt && break - optarg="$1" - opt_mode="$optarg" -case $optarg 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 - shift - ;; - --no-silent|--no-quiet) - opt_silent=false -func_append preserve_args " $opt" - ;; - --no-warning|--no-warn) - opt_warning=false -func_append preserve_args " $opt" - ;; - --no-verbose) - opt_verbose=false -func_append preserve_args " $opt" - ;; - --silent|--quiet) - opt_silent=: -func_append preserve_args " $opt" - opt_verbose=false - ;; - --verbose|-v) - opt_verbose=: -func_append preserve_args " $opt" -opt_silent=false - ;; - --tag) - test $# = 0 && func_missing_arg $opt && break - optarg="$1" - opt_tag="$optarg" -func_append preserve_args " $opt $optarg" -func_enable_tag "$optarg" - shift - ;; - - -\?|-h) func_usage ;; - --help) func_help ;; - --version) func_version ;; - - # Separate optargs to long options: - --*=*) - func_split_long_opt "$opt" - set dummy "$func_split_long_opt_name" "$func_split_long_opt_arg" ${1+"$@"} - shift - ;; - - # Separate non-argument short options: - -\?*|-h*|-n*|-v*) - func_split_short_opt "$opt" - set dummy "$func_split_short_opt_name" "-$func_split_short_opt_arg" ${1+"$@"} - shift - ;; - - --) break ;; - -*) func_fatal_help "unrecognized option \`$opt'" ;; - *) set dummy "$opt" ${1+"$@"}; shift; break ;; - esac - done - - # Validate options: - - # save first non-option argument - if test "$#" -gt 0; then - nonopt="$opt" - shift - fi - - # preserve --debug - test "$opt_debug" = : || func_append preserve_args " --debug" - - 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_preserve_dup_deps - ;; - esac - - $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 - - # Darwin sucks - eval std_shrext=\"$shrext_cmds\" - - # Only execute mode is allowed to have -dlopen flags. - if test -n "$opt_dlopen" && test "$opt_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=$opt_mode' for more information." - } - - - # Bail if the options were screwed - $exit_cmd $EXIT_FAILURE -} - - - - -## ----------- ## -## Main. ## -## ----------- ## - -# 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_dirname_and_basename "$1" "" "." - func_stripname '' '.exe' "$func_basename_result" - func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper" -} - -# 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_resolve_sysroot PATH -# Replace a leading = in PATH with a sysroot. Store the result into -# func_resolve_sysroot_result -func_resolve_sysroot () -{ - func_resolve_sysroot_result=$1 - case $func_resolve_sysroot_result in - =*) - func_stripname '=' '' "$func_resolve_sysroot_result" - func_resolve_sysroot_result=$lt_sysroot$func_stripname_result - ;; - esac -} - -# func_replace_sysroot PATH -# If PATH begins with the sysroot, replace it with = and -# store the result into func_replace_sysroot_result. -func_replace_sysroot () -{ - case "$lt_sysroot:$1" in - ?*:"$lt_sysroot"*) - func_stripname "$lt_sysroot" '' "$1" - func_replace_sysroot_result="=$func_stripname_result" - ;; - *) - # Including no sysroot. - func_replace_sysroot_result=$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_append_quoted CC_quoted "$arg" - done - CC_expanded=`func_echo_all $CC` - CC_quoted_expanded=`func_echo_all $CC_quoted` - 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 "* | " $CC_expanded "* | "$CC_expanded "* | \ - " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;; - # 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_append_quoted CC_quoted "$arg" - done - CC_expanded=`func_echo_all $CC` - CC_quoted_expanded=`func_echo_all $CC_quoted` - case "$@ " in - " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ - " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) - # 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 </dev/null` - if test "$?" -eq 0 && test -n "${func_convert_core_file_wine_to_w32_tmp}"; then - func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" | - $SED -e "$lt_sed_naive_backslashify"` - else - func_convert_core_file_wine_to_w32_result= - fi - fi -} -# end: func_convert_core_file_wine_to_w32 - - -# func_convert_core_path_wine_to_w32 ARG -# Helper function used by path conversion functions when $build is *nix, and -# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly -# configured wine environment available, with the winepath program in $build's -# $PATH. Assumes ARG has no leading or trailing path separator characters. -# -# ARG is path to be converted from $build format to win32. -# Result is available in $func_convert_core_path_wine_to_w32_result. -# Unconvertible file (directory) names in ARG are skipped; if no directory names -# are convertible, then the result may be empty. -func_convert_core_path_wine_to_w32 () -{ - $opt_debug - # unfortunately, winepath doesn't convert paths, only file names - func_convert_core_path_wine_to_w32_result="" - if test -n "$1"; then - oldIFS=$IFS - IFS=: - for func_convert_core_path_wine_to_w32_f in $1; do - IFS=$oldIFS - func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f" - if test -n "$func_convert_core_file_wine_to_w32_result" ; then - if test -z "$func_convert_core_path_wine_to_w32_result"; then - func_convert_core_path_wine_to_w32_result="$func_convert_core_file_wine_to_w32_result" - else - func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result" - fi - fi - done - IFS=$oldIFS - fi -} -# end: func_convert_core_path_wine_to_w32 - - -# func_cygpath ARGS... -# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when -# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2) -# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or -# (2), returns the Cygwin file name or path in func_cygpath_result (input -# file name or path is assumed to be in w32 format, as previously converted -# from $build's *nix or MSYS format). In case (3), returns the w32 file name -# or path in func_cygpath_result (input file name or path is assumed to be in -# Cygwin format). Returns an empty string on error. -# -# ARGS are passed to cygpath, with the last one being the file name or path to -# be converted. -# -# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH -# environment variable; do not put it in $PATH. -func_cygpath () -{ - $opt_debug - if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then - func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null` - if test "$?" -ne 0; then - # on failure, ensure result is empty - func_cygpath_result= - fi - else - func_cygpath_result= - func_error "LT_CYGPATH is empty or specifies non-existent file: \`$LT_CYGPATH'" - fi -} -#end: func_cygpath - - -# func_convert_core_msys_to_w32 ARG -# Convert file name or path ARG from MSYS format to w32 format. Return -# result in func_convert_core_msys_to_w32_result. -func_convert_core_msys_to_w32 () -{ - $opt_debug - # awkward: cmd appends spaces to result - func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null | - $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"` -} -#end: func_convert_core_msys_to_w32 - - -# func_convert_file_check ARG1 ARG2 -# Verify that ARG1 (a file name in $build format) was converted to $host -# format in ARG2. Otherwise, emit an error message, but continue (resetting -# func_to_host_file_result to ARG1). -func_convert_file_check () -{ - $opt_debug - if test -z "$2" && test -n "$1" ; then - func_error "Could not determine host file name corresponding to" - func_error " \`$1'" - func_error "Continuing, but uninstalled executables may not work." - # Fallback: - func_to_host_file_result="$1" - fi -} -# end func_convert_file_check - - -# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH -# Verify that FROM_PATH (a path in $build format) was converted to $host -# format in TO_PATH. Otherwise, emit an error message, but continue, resetting -# func_to_host_file_result to a simplistic fallback value (see below). -func_convert_path_check () -{ - $opt_debug - if test -z "$4" && test -n "$3"; then - func_error "Could not determine the host path corresponding to" - func_error " \`$3'" - func_error "Continuing, but uninstalled executables may not work." - # Fallback. This is a deliberately simplistic "conversion" and - # should not be "improved". See libtool.info. - if test "x$1" != "x$2"; then - lt_replace_pathsep_chars="s|$1|$2|g" - func_to_host_path_result=`echo "$3" | - $SED -e "$lt_replace_pathsep_chars"` - else - func_to_host_path_result="$3" - fi - fi -} -# end func_convert_path_check - - -# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG -# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT -# and appending REPL if ORIG matches BACKPAT. -func_convert_path_front_back_pathsep () -{ - $opt_debug - case $4 in - $1 ) func_to_host_path_result="$3$func_to_host_path_result" - ;; - esac - case $4 in - $2 ) func_append func_to_host_path_result "$3" - ;; - esac -} -# end func_convert_path_front_back_pathsep - - -################################################## -# $build to $host FILE NAME CONVERSION FUNCTIONS # -################################################## -# invoked via `$to_host_file_cmd ARG' -# -# In each case, ARG is the path to be converted from $build to $host format. -# Result will be available in $func_to_host_file_result. - - -# func_to_host_file ARG -# Converts the file name ARG from $build format to $host format. Return result -# in func_to_host_file_result. -func_to_host_file () -{ - $opt_debug - $to_host_file_cmd "$1" -} -# end func_to_host_file - - -# func_to_tool_file ARG LAZY -# converts the file name ARG from $build format to toolchain format. Return -# result in func_to_tool_file_result. If the conversion in use is listed -# in (the comma separated) LAZY, no conversion takes place. -func_to_tool_file () -{ - $opt_debug - case ,$2, in - *,"$to_tool_file_cmd",*) - func_to_tool_file_result=$1 - ;; - *) - $to_tool_file_cmd "$1" - func_to_tool_file_result=$func_to_host_file_result - ;; - esac -} -# end func_to_tool_file - - -# func_convert_file_noop ARG -# Copy ARG to func_to_host_file_result. -func_convert_file_noop () -{ - func_to_host_file_result="$1" -} -# end func_convert_file_noop - - -# func_convert_file_msys_to_w32 ARG -# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic -# conversion to w32 is not available inside the cwrapper. Returns result in -# func_to_host_file_result. -func_convert_file_msys_to_w32 () -{ - $opt_debug - func_to_host_file_result="$1" - if test -n "$1"; then - func_convert_core_msys_to_w32 "$1" - func_to_host_file_result="$func_convert_core_msys_to_w32_result" - fi - func_convert_file_check "$1" "$func_to_host_file_result" -} -# end func_convert_file_msys_to_w32 - - -# func_convert_file_cygwin_to_w32 ARG -# Convert file name ARG from Cygwin to w32 format. Returns result in -# func_to_host_file_result. -func_convert_file_cygwin_to_w32 () -{ - $opt_debug - func_to_host_file_result="$1" - if test -n "$1"; then - # because $build is cygwin, we call "the" cygpath in $PATH; no need to use - # LT_CYGPATH in this case. - func_to_host_file_result=`cygpath -m "$1"` - fi - func_convert_file_check "$1" "$func_to_host_file_result" -} -# end func_convert_file_cygwin_to_w32 - - -# func_convert_file_nix_to_w32 ARG -# Convert file name ARG from *nix to w32 format. Requires a wine environment -# and a working winepath. Returns result in func_to_host_file_result. -func_convert_file_nix_to_w32 () -{ - $opt_debug - func_to_host_file_result="$1" - if test -n "$1"; then - func_convert_core_file_wine_to_w32 "$1" - func_to_host_file_result="$func_convert_core_file_wine_to_w32_result" - fi - func_convert_file_check "$1" "$func_to_host_file_result" -} -# end func_convert_file_nix_to_w32 - - -# func_convert_file_msys_to_cygwin ARG -# Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. -# Returns result in func_to_host_file_result. -func_convert_file_msys_to_cygwin () -{ - $opt_debug - func_to_host_file_result="$1" - if test -n "$1"; then - func_convert_core_msys_to_w32 "$1" - func_cygpath -u "$func_convert_core_msys_to_w32_result" - func_to_host_file_result="$func_cygpath_result" - fi - func_convert_file_check "$1" "$func_to_host_file_result" -} -# end func_convert_file_msys_to_cygwin - - -# func_convert_file_nix_to_cygwin ARG -# Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed -# in a wine environment, working winepath, and LT_CYGPATH set. Returns result -# in func_to_host_file_result. -func_convert_file_nix_to_cygwin () -{ - $opt_debug - func_to_host_file_result="$1" - if test -n "$1"; then - # convert from *nix to w32, then use cygpath to convert from w32 to cygwin. - func_convert_core_file_wine_to_w32 "$1" - func_cygpath -u "$func_convert_core_file_wine_to_w32_result" - func_to_host_file_result="$func_cygpath_result" - fi - func_convert_file_check "$1" "$func_to_host_file_result" -} -# end func_convert_file_nix_to_cygwin - - -############################################# -# $build to $host PATH CONVERSION FUNCTIONS # -############################################# -# invoked via `$to_host_path_cmd ARG' -# -# In each case, ARG is the path to be converted from $build to $host format. -# The result will be available in $func_to_host_path_result. -# -# 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. -# -# All path conversion functions are named using the following convention: -# file name conversion function : func_convert_file_X_to_Y () -# path conversion function : func_convert_path_X_to_Y () -# where, for any given $build/$host combination the 'X_to_Y' value is the -# same. If conversion functions are added for new $build/$host combinations, -# the two new functions must follow this pattern, or func_init_to_host_path_cmd -# will break. - - -# func_init_to_host_path_cmd -# Ensures that function "pointer" variable $to_host_path_cmd is set to the -# appropriate value, based on the value of $to_host_file_cmd. -to_host_path_cmd= -func_init_to_host_path_cmd () -{ - $opt_debug - if test -z "$to_host_path_cmd"; then - func_stripname 'func_convert_file_' '' "$to_host_file_cmd" - to_host_path_cmd="func_convert_path_${func_stripname_result}" - fi -} - - -# func_to_host_path ARG -# Converts the path ARG from $build format to $host format. Return result -# in func_to_host_path_result. -func_to_host_path () -{ - $opt_debug - func_init_to_host_path_cmd - $to_host_path_cmd "$1" -} -# end func_to_host_path - - -# func_convert_path_noop ARG -# Copy ARG to func_to_host_path_result. -func_convert_path_noop () -{ - func_to_host_path_result="$1" -} -# end func_convert_path_noop - - -# func_convert_path_msys_to_w32 ARG -# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic -# conversion to w32 is not available inside the cwrapper. Returns result in -# func_to_host_path_result. -func_convert_path_msys_to_w32 () -{ - $opt_debug - func_to_host_path_result="$1" - if test -n "$1"; then - # 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_stripname : : "$1" - func_to_host_path_tmp1=$func_stripname_result - func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" - func_to_host_path_result="$func_convert_core_msys_to_w32_result" - func_convert_path_check : ";" \ - "$func_to_host_path_tmp1" "$func_to_host_path_result" - func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" - fi -} -# end func_convert_path_msys_to_w32 - - -# func_convert_path_cygwin_to_w32 ARG -# Convert path ARG from Cygwin to w32 format. Returns result in -# func_to_host_file_result. -func_convert_path_cygwin_to_w32 () -{ - $opt_debug - func_to_host_path_result="$1" - if test -n "$1"; then - # See func_convert_path_msys_to_w32: - func_stripname : : "$1" - func_to_host_path_tmp1=$func_stripname_result - func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"` - func_convert_path_check : ";" \ - "$func_to_host_path_tmp1" "$func_to_host_path_result" - func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" - fi -} -# end func_convert_path_cygwin_to_w32 - - -# func_convert_path_nix_to_w32 ARG -# Convert path ARG from *nix to w32 format. Requires a wine environment and -# a working winepath. Returns result in func_to_host_file_result. -func_convert_path_nix_to_w32 () -{ - $opt_debug - func_to_host_path_result="$1" - if test -n "$1"; then - # See func_convert_path_msys_to_w32: - func_stripname : : "$1" - func_to_host_path_tmp1=$func_stripname_result - func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" - func_to_host_path_result="$func_convert_core_path_wine_to_w32_result" - func_convert_path_check : ";" \ - "$func_to_host_path_tmp1" "$func_to_host_path_result" - func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" - fi -} -# end func_convert_path_nix_to_w32 - - -# func_convert_path_msys_to_cygwin ARG -# Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. -# Returns result in func_to_host_file_result. -func_convert_path_msys_to_cygwin () -{ - $opt_debug - func_to_host_path_result="$1" - if test -n "$1"; then - # See func_convert_path_msys_to_w32: - func_stripname : : "$1" - func_to_host_path_tmp1=$func_stripname_result - func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" - func_cygpath -u -p "$func_convert_core_msys_to_w32_result" - func_to_host_path_result="$func_cygpath_result" - func_convert_path_check : : \ - "$func_to_host_path_tmp1" "$func_to_host_path_result" - func_convert_path_front_back_pathsep ":*" "*:" : "$1" - fi -} -# end func_convert_path_msys_to_cygwin - - -# func_convert_path_nix_to_cygwin ARG -# Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a -# a wine environment, working winepath, and LT_CYGPATH set. Returns result in -# func_to_host_file_result. -func_convert_path_nix_to_cygwin () -{ - $opt_debug - func_to_host_path_result="$1" - if test -n "$1"; then - # 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_stripname : : "$1" - func_to_host_path_tmp1=$func_stripname_result - func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" - func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result" - func_to_host_path_result="$func_cygpath_result" - func_convert_path_check : : \ - "$func_to_host_path_tmp1" "$func_to_host_path_result" - func_convert_path_front_back_pathsep ":*" "*:" : "$1" - fi -} -# end func_convert_path_nix_to_cygwin - - -# func_mode_compile arg... -func_mode_compile () -{ - $opt_debug - # Get the compilation command and the source file. - base_compile= - srcfile="$nonopt" # always keep a non-empty value in "srcfile" - suppress_opt=yes - suppress_output= - arg_mode=normal - libobj= - later= - pie_flag= - - for arg - do - case $arg_mode in - arg ) - # do not "continue". Instead, add this to base_compile - lastarg="$arg" - arg_mode=normal - ;; - - target ) - libobj="$arg" - arg_mode=normal - continue - ;; - - normal ) - # Accept any command-line options. - case $arg in - -o) - test -n "$libobj" && \ - func_fatal_error "you cannot specify \`-o' more than once" - arg_mode=target - continue - ;; - - -pie | -fpie | -fPIE) - func_append pie_flag " $arg" - continue - ;; - - -shared | -static | -prefer-pic | -prefer-non-pic) - func_append later " $arg" - continue - ;; - - -no-suppress) - suppress_opt=no - continue - ;; - - -Xcompiler) - arg_mode=arg # the next one goes into the "base_compile" arg list - continue # The current "srcfile" will either be retained or - ;; # replaced later. I would guess that would be a bug. - - -Wc,*) - func_stripname '-Wc,' '' "$arg" - args=$func_stripname_result - lastarg= - save_ifs="$IFS"; IFS=',' - for arg in $args; do - IFS="$save_ifs" - func_append_quoted lastarg "$arg" - done - IFS="$save_ifs" - func_stripname ' ' '' "$lastarg" - lastarg=$func_stripname_result - - # Add the arguments to base_compile. - func_append base_compile " $lastarg" - continue - ;; - - *) - # Accept the current argument as the source file. - # The previous "srcfile" becomes the current argument. - # - lastarg="$srcfile" - srcfile="$arg" - ;; - esac # case $arg - ;; - esac # case $arg_mode - - # Aesthetically quote the previous argument. - func_append_quoted base_compile "$lastarg" - done # for arg - - case $arg_mode in - arg) - func_fatal_error "you must specify an argument for -Xcompile" - ;; - target) - func_fatal_error "you must specify a target with \`-o'" - ;; - *) - # Get the name of the library object. - test -z "$libobj" && { - func_basename "$srcfile" - libobj="$func_basename_result" - } - ;; - esac - - # Recognize several different file suffixes. - # If the user specifies -o file.o, it is replaced with file.lo - case $libobj in - *.[cCFSifmso] | \ - *.ada | *.adb | *.ads | *.asm | \ - *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \ - *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup) - func_xform "$libobj" - libobj=$func_xform_result - ;; - esac - - case $libobj in - *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;; - *) - func_fatal_error "cannot determine name of library object from \`$libobj'" - ;; - esac - - func_infer_tag $base_compile - - for arg in $later; do - case $arg in - -shared) - test "$build_libtool_libs" != yes && \ - func_fatal_configuration "can not build a shared library" - build_old_libs=no - continue - ;; - - -static) - build_libtool_libs=no - build_old_libs=yes - continue - ;; - - -prefer-pic) - pic_mode=yes - continue - ;; - - -prefer-non-pic) - pic_mode=no - continue - ;; - esac - done - - func_quote_for_eval "$libobj" - test "X$libobj" != "X$func_quote_for_eval_result" \ - && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ - && 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 "$srcfile" | $SED 's%^.*/%%; 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 - func_append removelist " $output_obj" - $ECHO "$srcfile" > "$lockfile" - fi - - $opt_dry_run || $RM $removelist - func_append removelist " $lockfile" - trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 - - func_to_tool_file "$srcfile" func_convert_file_msys_to_w32 - srcfile=$func_to_tool_file_result - 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 - func_append 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 - func_append command " -o $obj" - fi - - # Suppress compiler output if we already did a PIC compilation. - func_append 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 "$opt_mode" = compile && func_mode_compile ${1+"$@"} -} - -func_mode_help () -{ - # We need to display help for each of the modes. - case $opt_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 build PIC objects only - -prefer-non-pic try to build 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 - -Wc,FLAG pass FLAG directly to the compiler - -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-dir 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 - -bindir BINDIR specify path to binaries directory (for systems where - libraries must be found in the PATH setting at runtime) - -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 - -Wc,FLAG - -Xcompiler FLAG pass linker-specific FLAG directly to the compiler - -Wl,FLAG - -Xlinker FLAG pass linker-specific FLAG directly to the linker - -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) - -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 \`$opt_mode'" - ;; - esac - - echo - $ECHO "Try \`$progname --help' for more information about other modes." -} - -# Now that we've collected a possible --mode arg, show help if necessary -if $opt_help; then - if test "$opt_help" = :; then - func_mode_help - else - { - func_help noexit - for opt_mode in compile link execute install finish uninstall clean; do - func_mode_help - done - } | sed -n '1p; 2,$s/^Usage:/ or: /p' - { - func_help noexit - for opt_mode in compile link execute install finish uninstall clean; do - echo - func_mode_help - done - } | - sed '1d - /^When reporting/,/^Report/{ - H - d - } - $x - /information about other modes/d - /more detailed .*MODE/d - s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/' - fi - exit $? -fi - - -# 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 $opt_dlopen; do - test -f "$file" \ - || func_fatal_help "\`$file' is not a file" - - dir= - case $file in - *.la) - func_resolve_sysroot "$file" - file=$func_resolve_sysroot_result - - # 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 - func_append 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 - -* | *.la | *.lo ) ;; - *) - # 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_append_quoted args "$file" - 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 "$opt_mode" = execute && func_mode_execute ${1+"$@"} - - -# func_mode_finish arg... -func_mode_finish () -{ - $opt_debug - libs= - libdirs= - admincmds= - - for opt in "$nonopt" ${1+"$@"} - do - if test -d "$opt"; then - func_append libdirs " $opt" - - elif test -f "$opt"; then - if func_lalib_unsafe_p "$opt"; then - func_append libs " $opt" - else - func_warning "\`$opt' is not a valid libtool archive" - fi - - else - func_fatal_error "invalid argument \`$opt'" - fi - done - - if test -n "$libs"; then - if test -n "$lt_sysroot"; then - sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"` - sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;" - else - sysroot_cmd= - fi - - # Remove sysroot references - if $opt_dry_run; then - for lib in $libs; do - echo "removing references to $lt_sysroot and \`=' prefixes from $lib" - done - else - tmpdir=`func_mktempdir` - for lib in $libs; do - sed -e "${sysroot_cmd} s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \ - > $tmpdir/tmp-la - mv -f $tmpdir/tmp-la $lib - done - ${RM}r "$tmpdir" - fi - fi - - if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then - 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" || func_append admincmds " - $cmds" - fi - done - fi - - # Exit here if they wanted silent mode. - $opt_silent && exit $EXIT_SUCCESS - - if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then - echo "----------------------------------------------------------------------" - 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 "----------------------------------------------------------------------" - fi - exit $EXIT_SUCCESS -} - -test "$opt_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. - case $nonopt in *shtool*) :;; *) false;; esac; 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" - func_append install_prog "$func_quote_for_eval_result" - install_shared_prog=$install_prog - case " $install_prog " in - *[\\\ /]cp\ *) install_cp=: ;; - *) install_cp=false ;; - esac - - # We need to accept at least all the BSD install flags. - dest= - files= - opts= - prev= - install_type= - isdir=no - stripme= - no_mode=: - for arg - do - arg2= - if test -n "$dest"; then - func_append files " $dest" - dest=$arg - continue - fi - - case $arg in - -d) isdir=yes ;; - -f) - if $install_cp; then :; else - prev=$arg - fi - ;; - -g | -m | -o) - prev=$arg - ;; - -s) - stripme=" -s" - continue - ;; - -*) - ;; - *) - # If the previous option needed an argument, then skip it. - if test -n "$prev"; then - if test "x$prev" = x-m && test -n "$install_override_mode"; then - arg2=$install_override_mode - no_mode=false - fi - prev= - else - dest=$arg - continue - fi - ;; - esac - - # Aesthetically quote the argument. - func_quote_for_eval "$arg" - func_append install_prog " $func_quote_for_eval_result" - if test -n "$arg2"; then - func_quote_for_eval "$arg2" - fi - func_append install_shared_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 -n "$install_override_mode" && $no_mode; then - if $install_cp; then :; else - func_quote_for_eval "$install_override_mode" - func_append install_shared_prog " -m $func_quote_for_eval_result" - fi - fi - - 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. - func_append staticlibs " $file" - ;; - - *.la) - func_resolve_sysroot "$file" - file=$func_resolve_sysroot_result - - # 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 "*) ;; - *) func_append current_libdirs " $libdir" ;; - esac - else - # Note the libdir as a future libdir. - case "$future_libdirs " in - *" $libdir "*) ;; - *) func_append future_libdirs " $libdir" ;; - esac - fi - - func_dirname "$file" "/" "" - dir="$func_dirname_result" - func_append dir "$objdir" - - if test -n "$relink_command"; then - # Determine the prefix the user has applied to our future dir. - inst_prefix_dir=`$ECHO "$destdir" | $SED -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 "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` - else - relink_command=`$ECHO "$relink_command" | $SED "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_shared_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" && func_append 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 "$lib" | $SED '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 "$relink_command" | $SED '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 "$file$stripped_ext" | $SED "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_to_tool_file "$oldlib" func_convert_file_msys_to_w32 - tool_oldlib=$func_to_tool_file_result - - func_show_eval "$install_prog \$file \$oldlib" 'exit $?' - - if test -n "$stripme" && test -n "$old_striplib"; then - func_show_eval "$old_striplib $tool_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 "$opt_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 - -#if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) -#pragma GCC diagnostic ignored \"-Wstrict-prototypes\" -#endif - -/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ -#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE) -/* DATA imports from DLLs on WIN32 con't be const, because runtime - relocations are performed -- see ld's documentation on pseudo-relocs. */ -# define LT_DLSYM_CONST -#elif defined(__osf__) -/* This system does not cope well with relocations in const data. */ -# define LT_DLSYM_CONST -#else -# define LT_DLSYM_CONST const -#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 "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP` - for progfile in $progfiles; do - func_to_tool_file "$progfile" func_convert_file_msys_to_w32 - func_verbose "extracting global C symbols from \`$func_to_tool_file_result'" - $opt_dry_run || eval "$NM $func_to_tool_file_result | $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" - case $host in - *cygwin* | *mingw* | *cegcc* ) - # if an import library, we need to obtain dlname - if func_win32_import_lib_p "$dlprefile"; then - func_tr_sh "$dlprefile" - eval "curr_lafile=\$libfile_$func_tr_sh_result" - dlprefile_dlbasename="" - if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then - # Use subshell, to avoid clobbering current variable values - dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"` - if test -n "$dlprefile_dlname" ; then - func_basename "$dlprefile_dlname" - dlprefile_dlbasename="$func_basename_result" - else - # no lafile. user explicitly requested -dlpreopen . - $sharedlib_from_linklib_cmd "$dlprefile" - dlprefile_dlbasename=$sharedlib_from_linklib_result - fi - fi - $opt_dry_run || { - if test -n "$dlprefile_dlbasename" ; then - eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"' - else - func_warning "Could not compute DLL name from $name" - eval '$ECHO ": $name " >> "$nlist"' - fi - func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 - eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe | - $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'" - } - else # not an import lib - $opt_dry_run || { - eval '$ECHO ": $name " >> "$nlist"' - func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 - eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" - } - fi - ;; - *) - $opt_dry_run || { - eval '$ECHO ": $name " >> "$nlist"' - func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 - eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" - } - ;; - esac - 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; -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) ;; - *) func_append 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 "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` - finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` - else - compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` - finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` - fi - ;; - *) - compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` - finalize_command=`$ECHO "$finalize_command" | $SED "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 "$compile_command" | $SED "s% @SYMFILE@%%"` - finalize_command=`$ECHO "$finalize_command" | $SED "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. -# Despite the name, also deal with 64 bit binaries. -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 - # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. - if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | - $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then - func_to_tool_file "$1" func_convert_file_msys_to_w32 - win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" | - $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_cygming_dll_for_implib ARG -# -# Platform-specific function to extract the -# name of the DLL associated with the specified -# import library ARG. -# Invoked by eval'ing the libtool variable -# $sharedlib_from_linklib_cmd -# Result is available in the variable -# $sharedlib_from_linklib_result -func_cygming_dll_for_implib () -{ - $opt_debug - sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"` -} - -# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs -# -# The is the core of a fallback implementation of a -# platform-specific function to extract the name of the -# DLL associated with the specified import library LIBNAME. -# -# SECTION_NAME is either .idata$6 or .idata$7, depending -# on the platform and compiler that created the implib. -# -# Echos the name of the DLL associated with the -# specified import library. -func_cygming_dll_for_implib_fallback_core () -{ - $opt_debug - match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"` - $OBJDUMP -s --section "$1" "$2" 2>/dev/null | - $SED '/^Contents of section '"$match_literal"':/{ - # Place marker at beginning of archive member dllname section - s/.*/====MARK====/ - p - d - } - # These lines can sometimes be longer than 43 characters, but - # are always uninteresting - /:[ ]*file format pe[i]\{,1\}-/d - /^In archive [^:]*:/d - # Ensure marker is printed - /^====MARK====/p - # Remove all lines with less than 43 characters - /^.\{43\}/!d - # From remaining lines, remove first 43 characters - s/^.\{43\}//' | - $SED -n ' - # Join marker and all lines until next marker into a single line - /^====MARK====/ b para - H - $ b para - b - :para - x - s/\n//g - # Remove the marker - s/^====MARK====// - # Remove trailing dots and whitespace - s/[\. \t]*$// - # Print - /./p' | - # we now have a list, one entry per line, of the stringified - # contents of the appropriate section of all members of the - # archive which possess that section. Heuristic: eliminate - # all those which have a first or second character that is - # a '.' (that is, objdump's representation of an unprintable - # character.) This should work for all archives with less than - # 0x302f exports -- but will fail for DLLs whose name actually - # begins with a literal '.' or a single character followed by - # a '.'. - # - # Of those that remain, print the first one. - $SED -e '/^\./d;/^.\./d;q' -} - -# func_cygming_gnu_implib_p ARG -# This predicate returns with zero status (TRUE) if -# ARG is a GNU/binutils-style import library. Returns -# with nonzero status (FALSE) otherwise. -func_cygming_gnu_implib_p () -{ - $opt_debug - func_to_tool_file "$1" func_convert_file_msys_to_w32 - func_cygming_gnu_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $EGREP ' (_head_[A-Za-z0-9_]+_[ad]l*|[A-Za-z0-9_]+_[ad]l*_iname)$'` - test -n "$func_cygming_gnu_implib_tmp" -} - -# func_cygming_ms_implib_p ARG -# This predicate returns with zero status (TRUE) if -# ARG is an MS-style import library. Returns -# with nonzero status (FALSE) otherwise. -func_cygming_ms_implib_p () -{ - $opt_debug - func_to_tool_file "$1" func_convert_file_msys_to_w32 - func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'` - test -n "$func_cygming_ms_implib_tmp" -} - -# func_cygming_dll_for_implib_fallback ARG -# Platform-specific function to extract the -# name of the DLL associated with the specified -# import library ARG. -# -# This fallback implementation is for use when $DLLTOOL -# does not support the --identify-strict option. -# Invoked by eval'ing the libtool variable -# $sharedlib_from_linklib_cmd -# Result is available in the variable -# $sharedlib_from_linklib_result -func_cygming_dll_for_implib_fallback () -{ - $opt_debug - if func_cygming_gnu_implib_p "$1" ; then - # binutils import library - sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"` - elif func_cygming_ms_implib_p "$1" ; then - # ms-generated import library - sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"` - else - # unknown - sharedlib_from_linklib_result="" - fi -} - - -# 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" - if test "$lock_old_archive_extraction" = yes; then - lockfile=$f_ex_an_ar_oldlib.lock - until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do - func_echo "Waiting for $lockfile to be removed" - sleep 2 - done - fi - func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \ - 'stat=$?; rm -f "$lockfile"; exit $stat' - if test "$lock_old_archive_extraction" = yes; then - $opt_dry_run || rm -f "$lockfile" - fi - 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 | sort | $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 | sort | $NL2SP` - done - - func_extract_archives_result="$my_oldobjs" -} - - -# 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=${1-no} - - $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. -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 - file=\"\$0\"" - - qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"` - $ECHO "\ - -# A function that is used when there is no print builtin or printf. -func_fallback_echo () -{ - eval 'cat <<_LTECHO_EOF -\$1 -_LTECHO_EOF' -} - ECHO=\"$qECHO\" - fi - -# Very basic option parsing. These options are (a) specific to -# the libtool wrapper, (b) are identical between the wrapper -# /script/ and the wrapper /executable/ which is used only on -# windows platforms, and (c) all begin with the string "--lt-" -# (application programs are unlikely to have options which match -# this pattern). -# -# There are only two supported options: --lt-debug and -# --lt-dump-script. There is, deliberately, no --lt-help. -# -# The first argument to this parsing function should be the -# script's $0 value, followed by "$@". -lt_option_debug= -func_parse_lt_options () -{ - lt_script_arg0=\$0 - shift - for lt_opt - do - case \"\$lt_opt\" in - --lt-debug) lt_option_debug=1 ;; - --lt-dump-script) - lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\` - test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=. - lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\` - cat \"\$lt_dump_D/\$lt_dump_F\" - exit 0 - ;; - --lt-*) - \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2 - exit 1 - ;; - esac - done - - # Print the debug banner immediately: - if test -n \"\$lt_option_debug\"; then - echo \"${outputname}:${output}:\${LINENO}: libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\" 1>&2 - fi -} - -# Used when --lt-debug. Prints its arguments to stdout -# (redirection is the responsibility of the caller) -func_lt_dump_args () -{ - lt_dump_args_N=1; - for lt_arg - do - \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[\$lt_dump_args_N]: \$lt_arg\" - lt_dump_args_N=\`expr \$lt_dump_args_N + 1\` - done -} - -# Core function for launching the target application -func_exec_program_core () -{ -" - case $host in - # Backslashes separate directories on plain windows - *-*-mingw | *-*-os2* | *-cegcc*) - $ECHO "\ - if test -n \"\$lt_option_debug\"; then - \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir\\\\\$program\" 1>&2 - func_lt_dump_args \${1+\"\$@\"} 1>&2 - fi - exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} -" - ;; - - *) - $ECHO "\ - if test -n \"\$lt_option_debug\"; then - \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir/\$program\" 1>&2 - func_lt_dump_args \${1+\"\$@\"} 1>&2 - fi - exec \"\$progdir/\$program\" \${1+\"\$@\"} -" - ;; - esac - $ECHO "\ - \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 - exit 1 -} - -# A function to encapsulate launching the target application -# Strips options in the --lt-* namespace from \$@ and -# launches target application with the remaining arguments. -func_exec_program () -{ - case \" \$* \" in - *\\ --lt-*) - for lt_wr_arg - do - case \$lt_wr_arg in - --lt-*) ;; - *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; - esac - shift - done ;; - esac - func_exec_program_core \${1+\"\$@\"} -} - - # Parse options - func_parse_lt_options \"\$0\" \${1+\"\$@\"} - - # Find the directory that this script lives in. - thisdir=\`\$ECHO \"\$file\" | $SED '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 \"\$file\" | $SED '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 \"\$file\" | $SED 's%^.*/%%'\` - file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` - done - - # Usually 'no', except on cygwin/mingw when embedded into - # the cwrapper. - WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_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 \"\$thisdir\" | $SED '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" - - # fixup the dll searchpath if we need to. - # - # Fix the DLL searchpath if we need to. Do this before prepending - # to shlibpath, because on Windows, both are PATH and uninstalled - # libraries must come first. - if test -n "$dllsearchpath"; then - $ECHO "\ - # Add the dll search path components to the executable PATH - PATH=$dllsearchpath:\$PATH -" - fi - - # 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 \"\$$shlibpath_var\" | $SED 's/::*\$//'\` - - export $shlibpath_var -" - fi - - $ECHO "\ - if test \"\$libtool_execute_magic\" != \"$magic\"; then - # Run the actual program with our arguments. - func_exec_program \${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\ -" -} - - -# 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 -#else -# include -# include -# ifdef __CYGWIN__ -# include -# endif -#endif -#include -#include -#include -#include -#include -#include -#include -#include - -/* declarations of non-ANSI functions */ -#if defined(__MINGW32__) -# ifdef __STRICT_ANSI__ -int _putenv (const char *); -# endif -#elif defined(__CYGWIN__) -# ifdef __STRICT_ANSI__ -char *realpath (const char *, char *); -int putenv (char *); -int setenv (const char *, const char *, int); -# endif -/* #elif defined (other platforms) ... */ -#endif - -/* portability defines, excluding path handling macros */ -#if defined(_MSC_VER) -# define setmode _setmode -# define stat _stat -# define chmod _chmod -# define getcwd _getcwd -# define putenv _putenv -# define S_IXUSR _S_IEXEC -# ifndef _INTPTR_T_DEFINED -# define _INTPTR_T_DEFINED -# define intptr_t int -# endif -#elif defined(__MINGW32__) -# define setmode _setmode -# define stat _stat -# define chmod _chmod -# define getcwd _getcwd -# define putenv _putenv -#elif defined(__CYGWIN__) -# define HAVE_SETENV -# define FOPEN_WB "wb" -/* #elif defined (other platforms) ... */ -#endif - -#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 - -/* path handling portability macros */ -#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 */ - -#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) - -#if defined(LT_DEBUGWRAPPER) -static int lt_debug = 1; -#else -static int lt_debug = 0; -#endif - -const char *program_name = "libtool-wrapper"; /* in case xstrdup fails */ - -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_debugprintf (const char *file, int line, const char *fmt, ...); -void lt_fatal (const char *file, int line, const char *message, ...); -static const char *nonnull (const char *s); -static const char *nonempty (const char *s); -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_update_exe_path (const char *name, const char *value); -void lt_update_lib_path (const char *name, const char *value); -char **prepare_spawn (char **argv); -void lt_dump_script (FILE *f); -EOF - - cat <= 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; - - lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n", - nonempty (path)); - 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; - - lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n", - nonempty (wrapper)); - - 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 (__FILE__, __LINE__, "getcwd failed: %s", - nonnull (strerror (errno))); - 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 (__FILE__, __LINE__, "getcwd failed: %s", - nonnull (strerror (errno))); - 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) - { - lt_debugprintf (__FILE__, __LINE__, - "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 - { - lt_fatal (__FILE__, __LINE__, - "error accessing file \"%s\": %s", - tmp_pathspec, nonnull (strerror (errno))); - } - } - XFREE (tmp_pathspec); - - if (!has_symlinks) - { - return xstrdup (pathspec); - } - - tmp_pathspec = realpath (pathspec, buf); - if (tmp_pathspec == 0) - { - lt_fatal (__FILE__, __LINE__, - "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; -} - -void -lt_debugprintf (const char *file, int line, const char *fmt, ...) -{ - va_list args; - if (lt_debug) - { - (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line); - va_start (args, fmt); - (void) vfprintf (stderr, fmt, args); - va_end (args); - } -} - -static void -lt_error_core (int exit_status, const char *file, - int line, const char *mode, - const char *message, va_list ap) -{ - fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode); - vfprintf (stderr, message, ap); - fprintf (stderr, ".\n"); - - if (exit_status >= 0) - exit (exit_status); -} - -void -lt_fatal (const char *file, int line, const char *message, ...) -{ - va_list ap; - va_start (ap, message); - lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap); - va_end (ap); -} - -static const char * -nonnull (const char *s) -{ - return s ? s : "(null)"; -} - -static const char * -nonempty (const char *s) -{ - return (s && !*s) ? "(empty)" : nonnull (s); -} - -void -lt_setenv (const char *name, const char *value) -{ - lt_debugprintf (__FILE__, __LINE__, - "(lt_setenv) setting '%s' to '%s'\n", - nonnull (name), nonnull (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; -} - -void -lt_update_exe_path (const char *name, const char *value) -{ - lt_debugprintf (__FILE__, __LINE__, - "(lt_update_exe_path) modifying '%s' by prepending '%s'\n", - nonnull (name), nonnull (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) -{ - lt_debugprintf (__FILE__, __LINE__, - "(lt_update_lib_path) modifying '%s' by prepending '%s'\n", - nonnull (name), nonnull (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 - case $host_os in - mingw*) - cat <<"EOF" - -/* Prepares an argument vector before calling spawn(). - Note that spawn() does not by itself call the command interpreter - (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") : - ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); - GetVersionEx(&v); - v.dwPlatformId == VER_PLATFORM_WIN32_NT; - }) ? "cmd.exe" : "command.com"). - Instead it simply concatenates the arguments, separated by ' ', and calls - CreateProcess(). We must quote the arguments since Win32 CreateProcess() - interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a - special way: - - Space and tab are interpreted as delimiters. They are not treated as - delimiters if they are surrounded by double quotes: "...". - - Unescaped double quotes are removed from the input. Their only effect is - that within double quotes, space and tab are treated like normal - characters. - - Backslashes not followed by double quotes are not special. - - But 2*n+1 backslashes followed by a double quote become - n backslashes followed by a double quote (n >= 0): - \" -> " - \\\" -> \" - \\\\\" -> \\" - */ -#define SHELL_SPECIAL_CHARS "\"\\ \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037" -#define SHELL_SPACE_CHARS " \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037" -char ** -prepare_spawn (char **argv) -{ - size_t argc; - char **new_argv; - size_t i; - - /* Count number of arguments. */ - for (argc = 0; argv[argc] != NULL; argc++) - ; - - /* Allocate new argument vector. */ - new_argv = XMALLOC (char *, argc + 1); - - /* Put quoted arguments into the new argument vector. */ - for (i = 0; i < argc; i++) - { - const char *string = argv[i]; - - if (string[0] == '\0') - new_argv[i] = xstrdup ("\"\""); - else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) - { - int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); - size_t length; - unsigned int backslashes; - const char *s; - char *quoted_string; - char *p; - - length = 0; - backslashes = 0; - if (quote_around) - length++; - for (s = string; *s != '\0'; s++) - { - char c = *s; - if (c == '"') - length += backslashes + 1; - length++; - if (c == '\\') - backslashes++; - else - backslashes = 0; - } - if (quote_around) - length += backslashes + 1; - - quoted_string = XMALLOC (char, length + 1); - - p = quoted_string; - backslashes = 0; - if (quote_around) - *p++ = '"'; - for (s = string; *s != '\0'; s++) - { - char c = *s; - if (c == '"') - { - unsigned int j; - for (j = backslashes + 1; j > 0; j--) - *p++ = '\\'; - } - *p++ = c; - if (c == '\\') - backslashes++; - else - backslashes = 0; - } - if (quote_around) - { - unsigned int j; - for (j = backslashes; j > 0; j--) - *p++ = '\\'; - *p++ = '"'; - } - *p = '\0'; - - new_argv[i] = quoted_string; - } - else - new_argv[i] = (char *) string; - } - new_argv[argc] = NULL; - - return new_argv; -} -EOF - ;; - esac - - cat <<"EOF" -void lt_dump_script (FILE* f) -{ -EOF - func_emit_wrapper yes | - $SED -n -e ' -s/^\(.\{79\}\)\(..*\)/\1\ -\2/ -h -s/\([\\"]\)/\\\1/g -s/$/\\n/ -s/\([^\n]*\).*/ fputs ("\1", f);/p -g -D' - cat <<"EOF" -} -EOF -} -# end: func_emit_cwrapperexe_src - -# func_win32_import_lib_p ARG -# True if ARG is an import lib, as indicated by $file_magic_cmd -func_win32_import_lib_p () -{ - $opt_debug - case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in - *import*) : ;; - *) false ;; - esac -} - -# 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 - bindir= - 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 - bindir) - bindir="$arg" - prev= - continue - ;; - 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 - func_append dlfiles " $arg" - else - func_append 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 "*) ;; - *) func_append 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 -# func_append 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 - func_append 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. - func_append 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 "*) ;; - *) func_append rpath " $arg" ;; - esac - else - case "$xrpath " in - *" $arg "*) ;; - *) func_append xrpath " $arg" ;; - esac - fi - prev= - continue - ;; - shrext) - shrext_cmds="$arg" - prev= - continue - ;; - weak) - func_append weak_libs " $arg" - prev= - continue - ;; - xcclinker) - func_append linker_flags " $qarg" - func_append compiler_flags " $qarg" - prev= - func_append compile_command " $qarg" - func_append finalize_command " $qarg" - continue - ;; - xcompiler) - func_append compiler_flags " $qarg" - prev= - func_append compile_command " $qarg" - func_append finalize_command " $qarg" - continue - ;; - xlinker) - func_append linker_flags " $qarg" - func_append 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 - ;; - - -bindir) - prev=bindir - 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" - if test -z "$func_stripname_result"; 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 - func_resolve_sysroot "$func_stripname_result" - dir=$func_resolve_sysroot_result - # 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 "* | *" $arg "*) - # Will only happen for absolute or sysroot arguments - ;; - *) - # Preserve sysroot, but never include relative directories - case $dir in - [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;; - *) func_append deplibs " -L$dir" ;; - esac - func_append lib_search_path " $dir" - ;; - esac - case $host in - *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) - testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` - case :$dllsearchpath: in - *":$dir:"*) ;; - ::) dllsearchpath=$dir;; - *) func_append dllsearchpath ":$dir";; - esac - case :$dllsearchpath: in - *":$testbindir:"*) ;; - ::) dllsearchpath=$testbindir;; - *) func_append 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* | *-*-haiku*) - # 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 - func_append 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 - func_append 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|--sysroot) - func_append 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|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) - func_append compiler_flags " $arg" - func_append compile_command " $arg" - func_append finalize_command " $arg" - case "$new_inherited_linker_flags " in - *" $arg "*) ;; - * ) func_append 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_stripname '=' '' "$dir" - dir=$lt_sysroot$func_stripname_result - ;; - *) - func_fatal_error "only absolute run-paths are allowed" - ;; - esac - case "$xrpath " in - *" $dir "*) ;; - *) func_append 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" - func_append arg " $func_quote_for_eval_result" - func_append 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" - func_append arg " $wl$func_quote_for_eval_result" - func_append compiler_flags " $wl$func_quote_for_eval_result" - func_append 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" - ;; - - # Flags to be passed through unchanged, with rationale: - # -64, -mips[0-9] enable 64-bit mode for the SGI compiler - # -r[0-9][0-9]* specify processor for the SGI compiler - # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler - # +DA*, +DD* enable 64-bit mode for the HP compiler - # -q* compiler args for the IBM compiler - # -m*, -t[45]*, -txscale* architecture-specific flags for GCC - # -F/path path to uninstalled frameworks, gcc on darwin - # -p, -pg, --coverage, -fprofile-* profiling flags for GCC - # @file GCC response files - # -tp=* Portland pgcc target processor selection - # --sysroot=* for sysroot support - # -O*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization - -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ - -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ - -O*|-flto*|-fwhopr*|-fuse-linker-plugin) - func_quote_for_eval "$arg" - arg="$func_quote_for_eval_result" - func_append compile_command " $arg" - func_append finalize_command " $arg" - func_append compiler_flags " $arg" - continue - ;; - - # Some other compiler flag. - -* | +*) - func_quote_for_eval "$arg" - arg="$func_quote_for_eval_result" - ;; - - *.$objext) - # A standard object. - func_append 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 - func_append 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. - func_append 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. - func_append deplibs " $arg" - func_append old_deplibs " $arg" - continue - ;; - - *.la) - # A libtool-controlled library. - - func_resolve_sysroot "$arg" - if test "$prev" = dlfiles; then - # This library was specified with -dlopen. - func_append dlfiles " $func_resolve_sysroot_result" - prev= - elif test "$prev" = dlprefiles; then - # The library was specified with -dlpreopen. - func_append dlprefiles " $func_resolve_sysroot_result" - prev= - else - func_append deplibs " $func_resolve_sysroot_result" - 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 \"\${$shlibpath_var}\" \| \$SED \'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" - func_to_tool_file "$output_objdir/" - tool_output_objdir=$func_to_tool_file_result - # 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_preserve_dup_deps ; then - case "$libs " in - *" $deplib "*) func_append specialdeplibs " $deplib" ;; - esac - fi - func_append 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 "*) func_append specialdeplibs " $pre_post_deps" ;; - esac - func_append 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%" - test "X$link_all_deplibs" != Xno && libs="$libs $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= - func_resolve_sysroot "$lib" - case $lib in - *.la) func_source "$func_resolve_sysroot_result" ;; - esac - - # Collect preopened libtool deplibs, except any this library - # has declared as weak libs - for deplib in $dependency_libs; do - func_basename "$deplib" - deplib_base=$func_basename_result - case " $weak_libs " in - *" $deplib_base "*) ;; - *) func_append 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|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) - if test "$linkmode,$pass" = "prog,link"; then - compile_deplibs="$deplib $compile_deplibs" - finalize_deplibs="$deplib $finalize_deplibs" - else - func_append compiler_flags " $deplib" - if test "$linkmode" = lib ; then - case "$new_inherited_linker_flags " in - *" $deplib "*) ;; - * ) func_append 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 "*) ;; - * ) func_append 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" - func_resolve_sysroot "$func_stripname_result" - func_append newlib_search_path " $func_resolve_sysroot_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" - func_resolve_sysroot "$func_stripname_result" - func_append newlib_search_path " $func_resolve_sysroot_result" - ;; - *) - func_warning "\`-L' is ignored for archives/objects" - ;; - esac # linkmode - continue - ;; # -L - -R*) - if test "$pass" = link; then - func_stripname '-R' '' "$deplib" - func_resolve_sysroot "$func_stripname_result" - dir=$func_resolve_sysroot_result - # Make sure the xrpath contains only unique directories. - case "$xrpath " in - *" $dir "*) ;; - *) func_append xrpath " $dir" ;; - esac - fi - deplibs="$deplib $deplibs" - continue - ;; - *.la) - func_resolve_sysroot "$deplib" - lib=$func_resolve_sysroot_result - ;; - *.$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 \"$deplib\"" 2>/dev/null | $SED 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. - func_append newdlprefiles " $deplib" - compile_deplibs="$deplib $compile_deplibs" - finalize_deplibs="$deplib $finalize_deplibs" - else - func_append 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 "$inherited_linker_flags" | $SED '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 "*) ;; - *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";; - esac - done - fi - dependency_libs=`$ECHO " $dependency_libs" | $SED '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" && func_append dlfiles " $dlopen" - test -n "$dlpreopen" && func_append 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. - func_append convenience " $ladir/$objdir/$old_library" - func_append old_convenience " $ladir/$objdir/$old_library" - tmp_libs= - for deplib in $dependency_libs; do - deplibs="$deplib $deplibs" - if $opt_preserve_dup_deps ; then - case "$tmp_libs " in - *" $deplib "*) func_append specialdeplibs " $deplib" ;; - esac - fi - func_append tmp_libs " $deplib" - done - elif test "$linkmode" != prog && test "$linkmode" != lib; then - func_fatal_error "\`$lib' is not a convenience library" - fi - continue - fi # $pass = conv - - - # Get the name of the library we link against. - linklib= - if test -n "$old_library" && - { test "$prefer_static_libs" = yes || - test "$prefer_static_libs,$installed" = "built,no"; }; then - linklib=$old_library - else - for l in $old_library $library_names; do - linklib="$l" - done - fi - 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. - func_append dlprefiles " $lib $dependency_libs" - else - func_append 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 "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then - func_warning "library \`$lib' was moved." - dir="$ladir" - absdir="$abs_ladir" - libdir="$abs_ladir" - else - dir="$lt_sysroot$libdir" - absdir="$lt_sysroot$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 - func_append notinst_path " $abs_ladir" - else - dir="$ladir/$objdir" - absdir="$abs_ladir/$objdir" - # Remove this search path later - func_append 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 - case "$host" in - # special handling for platforms with PE-DLLs. - *cygwin* | *mingw* | *cegcc* ) - # Linker will automatically link against shared library if both - # static and shared are present. Therefore, ensure we extract - # symbols from the import library if a shared library is present - # (otherwise, the dlopen module name will be incorrect). We do - # this by putting the import library name into $newdlprefiles. - # We recover the dlopen module name by 'saving' the la file - # name in a special purpose variable, and (later) extracting the - # dlname from the la file. - if test -n "$dlname"; then - func_tr_sh "$dir/$linklib" - eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname" - func_append newdlprefiles " $dir/$linklib" - else - func_append 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" && \ - func_append dlpreconveniencelibs " $dir/$old_library" - fi - ;; - * ) - # Prefer using a static library (so that no silly _DYNAMIC symbols - # are required to link). - if test -n "$old_library"; then - func_append 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" && \ - func_append dlpreconveniencelibs " $dir/$old_library" - # Otherwise, use the dlname, so that lt_dlopen finds it. - elif test -n "$dlname"; then - func_append newdlprefiles " $dir/$dlname" - else - func_append newdlprefiles " $dir/$linklib" - fi - ;; - esac - 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 - func_append 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" - func_resolve_sysroot "$func_stripname_result" - func_append newlib_search_path " $func_resolve_sysroot_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_preserve_dup_deps ; then - case "$tmp_libs " in - *" $deplib "*) func_append specialdeplibs " $deplib" ;; - esac - fi - func_append 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:"*) ;; - *) func_append 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 "*) ;; - *) func_append compile_rpath " $absdir" ;; - esac - ;; - esac - case " $sys_lib_dlsearch_path " in - *" $libdir "*) ;; - *) - case "$finalize_rpath " in - *" $libdir "*) ;; - *) func_append 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 - func_append notinst_deplibs " $lib" - need_relink=no - ;; - *) - if test "$installed" = no; then - func_append 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 "*) ;; - *) func_append compile_rpath " $absdir" ;; - esac - ;; - esac - case " $sys_lib_dlsearch_path " in - *" $libdir "*) ;; - *) - case "$finalize_rpath " in - *" $libdir "*) ;; - *) func_append 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 "$opt_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$absdir" - # Try looking first in the location we're being installed to. - if test -n "$inst_prefix_dir"; then - case $libdir in - [\\/]*) - func_append 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:"*) ;; - *) func_append 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:"*) ;; - *) func_append finalize_shlibpath "$libdir:" ;; - esac - fi - fi - fi - - if test "$linkmode" = prog || test "$opt_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:"*) ;; - *) func_append 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 - [\\/]*) - func_append 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 "*) ;; - *) func_append xrpath " $temp_xrpath";; - esac;; - *) func_append temp_deplibs " $libdir";; - esac - done - dependency_libs="$temp_deplibs" - fi - - func_append 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" - case $deplib in - -L*) func_stripname '-L' '' "$deplib" - func_resolve_sysroot "$func_stripname_result";; - *) func_resolve_sysroot "$deplib" ;; - esac - if $opt_preserve_dup_deps ; then - case "$tmp_libs " in - *" $func_resolve_sysroot_result "*) - func_append specialdeplibs " $func_resolve_sysroot_result" ;; - esac - fi - func_append tmp_libs " $func_resolve_sysroot_result" - done - - if test "$link_all_deplibs" != no; then - # Add the search paths of all dependency libraries - for deplib in $dependency_libs; do - path= - case $deplib in - -L*) path="$deplib" ;; - *.la) - func_resolve_sysroot "$deplib" - deplib=$func_resolve_sysroot_result - 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 - func_append compiler_flags " ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}" - func_append 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 " $new_inherited_linker_flags" | $SED '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 "*) ;; - *) func_append 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 "*) ;; - *) func_append tmp_libs " $deplib" ;; - esac - ;; - *) func_append 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 - func_append 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" - func_append 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!" - func_append 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 - # correct linux to gnu/linux during the next big refactor - 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|qnx|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 - ;; - *) - func_fatal_configuration "$modename: unknown library version type \`$version_type'" - ;; - 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) # correct to gnu/linux during the next big refactor - 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. - func_append 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" - func_append libobjs " $symfileobj" - test "X$libobjs" = "X " && libobjs= - - if test "$opt_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 - func_append 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 - func_append oldlibs " $output_objdir/$libname.$libext" - - # Transform .lo files to .o files. - oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; $lo2o" | $NL2SP` - fi - - # Eliminate all temporary directories. - #for path in $notinst_path; do - # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"` - # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"` - # dependency_libs=`$ECHO "$dependency_libs " | $SED "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 - func_replace_sysroot "$libdir" - func_append temp_xrpath " -R$func_replace_sysroot_result" - case "$finalize_rpath " in - *" $libdir "*) ;; - *) func_append 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 "*) ;; - *) func_append 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 "*) ;; - *) func_append 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* | *-*-haiku*) - # these systems don't actually have a c library (as such)! - ;; - *-*-rhapsody* | *-*-darwin1.[012]) - # Rhapsody C library is in the System framework - func_append 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 - func_append 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` - $nocaseglob - else - potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` - fi - 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 "$potlib" | $SED 's,[^/]*$,,'`"$potliblink";; - esac - done - if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | - $SED -e 10q | - $EGREP "$file_magic_regex" > /dev/null; then - func_append 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. - func_append 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 "*) - func_append 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 \"$potent_lib\"" 2>/dev/null | $SED 10q | \ - $EGREP "$match_pattern_regex" > /dev/null; then - func_append 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. - func_append newdeplibs " $a_deplib" - ;; - esac - done # Gone through all deplibs. - ;; - none | unknown | *) - newdeplibs="" - tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; 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 " $tmp_deplibs" | $SED "s,$i,,"` - done - fi - case $tmp_deplibs in - *[!\ \ ]*) - 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 - ;; - esac - ;; - 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 " $newdeplibs" | $SED '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 " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` - new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` - deplibs=`$ECHO " $deplibs" | $SED '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 "*) - func_append new_libs " -L$path/$objdir" ;; - esac - ;; - esac - done - for deplib in $deplibs; do - case $deplib in - -L*) - case " $new_libs " in - *" $deplib "*) ;; - *) func_append new_libs " $deplib" ;; - esac - ;; - *) func_append 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 - # Remove ${wl} instances when linking with ld. - # FIXME: should test the right _cmds variable. - case $archive_cmds in - *\$LD\ *) wl= ;; - esac - if test "$hardcode_into_libs" = yes; then - # Hardcode the library paths - hardcode_libdirs= - dep_rpath= - rpath="$finalize_rpath" - test "$opt_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 - func_replace_sysroot "$libdir" - libdir=$func_replace_sysroot_result - 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"*) - ;; - *) - func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" - ;; - esac - fi - else - eval flag=\"$hardcode_libdir_flag_spec\" - func_append dep_rpath " $flag" - fi - elif test -n "$runpath_var"; then - case "$perm_rpath " in - *" $libdir "*) ;; - *) func_append 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 "dep_rpath=\"$hardcode_libdir_flag_spec\"" - fi - if test -n "$runpath_var" && test -n "$perm_rpath"; then - # We should set the runpath_var. - rpath= - for dir in $perm_rpath; do - func_append 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 "$opt_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 - func_append linknames " $link" - done - - # Use standard objects if they are pic - test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$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" - func_append 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 cmd1 in $cmds; do - IFS="$save_ifs" - # Take the normal branch if the nm_file_list_spec branch - # doesn't work or if tool conversion is not needed. - case $nm_file_list_spec~$to_tool_file_cmd in - *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*) - try_normal_branch=yes - eval cmd=\"$cmd1\" - func_len " $cmd" - len=$func_len_result - ;; - *) - try_normal_branch=no - ;; - esac - if test "$try_normal_branch" = yes \ - && { test "$len" -lt "$max_cmd_len" \ - || test "$max_cmd_len" -le -1; } - then - func_show_eval "$cmd" 'exit $?' - skipped_export=false - elif test -n "$nm_file_list_spec"; then - func_basename "$output" - output_la=$func_basename_result - save_libobjs=$libobjs - save_output=$output - output=${output_objdir}/${output_la}.nm - func_to_tool_file "$output" - libobjs=$nm_file_list_spec$func_to_tool_file_result - func_append delfiles " $output" - func_verbose "creating $NM input file list: $output" - for obj in $save_libobjs; do - func_to_tool_file "$obj" - $ECHO "$func_to_tool_file_result" - done > "$output" - eval cmd=\"$cmd1\" - func_show_eval "$cmd" 'exit $?' - output=$save_output - libobjs=$save_libobjs - 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 "$include_expsyms" | $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 - func_append 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 "*) ;; - *) - func_append 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" - func_append generated " $gentop" - - func_extract_archives $gentop $convenience - func_append 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\" - func_append linker_flags " $flag" - fi - - # Make a backup of the uninstalled library when relinking - if test "$opt_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 - func_basename "$output" - output_la=$func_basename_result - - # 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 - func_to_tool_file "$obj" - $ECHO "$func_to_tool_file_result" >> $output - done - echo ')' >> $output - func_append delfiles " $output" - func_to_tool_file "$output" - output=$func_to_tool_file_result - 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 - func_to_tool_file "$obj" - $ECHO "$func_to_tool_file_result" >> $output - done - func_append delfiles " $output" - func_to_tool_file "$output" - output=$firstobj\"$file_list_spec$func_to_tool_file_result\" - 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. - reload_objs=$objlist - eval concat_cmds=\"$reload_cmds\" - else - # All subsequent reloadable object files will link in - # the last one created. - reload_objs="$objlist $last_robj" - eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$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~ - reload_objs="$objlist $last_robj" - eval concat_cmds=\"\${concat_cmds}$reload_cmds\" - if test -n "$last_robj"; then - eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\" - fi - func_append 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 "$opt_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 "$include_expsyms" | $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 - func_append 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" - func_append generated " $gentop" - - func_extract_archives $gentop $dlprefiles - func_append 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 "$opt_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 "$opt_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 "$tmp_whole_archive_flags" | $SED 's|,| |g'` - else - gentop="$output_objdir/${obj}x" - func_append generated " $gentop" - - func_extract_archives $gentop $convenience - reload_conv_objs="$reload_objs $func_extract_archives_result" - fi - fi - - # If we're not building shared, we need to use non_pic_objs - test "$build_libtool_libs" != yes && libobjs="$non_pic_objects" - - # Create the old-style object. - reload_objs="$objs$old_deplibs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; /\.lib$/d; $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 " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'` - finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED '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]) - func_append compile_command " ${wl}-bind_at_load" - func_append finalize_command " ${wl}-bind_at_load" - ;; - esac - fi - # Time to change all our "foo.ltframework" stuff back to "-framework foo" - compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` - finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED '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 "*) - func_append new_libs " -L$path/$objdir" ;; - esac - ;; - esac - done - for deplib in $compile_deplibs; do - case $deplib in - -L*) - case " $new_libs " in - *" $deplib "*) ;; - *) func_append new_libs " $deplib" ;; - esac - ;; - *) func_append new_libs " $deplib" ;; - esac - done - compile_deplibs="$new_libs" - - - func_append compile_command " $compile_deplibs" - func_append 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 "*) ;; - *) func_append 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"*) - ;; - *) - func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" - ;; - esac - fi - else - eval flag=\"$hardcode_libdir_flag_spec\" - func_append rpath " $flag" - fi - elif test -n "$runpath_var"; then - case "$perm_rpath " in - *" $libdir "*) ;; - *) func_append 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;; - *) func_append dllsearchpath ":$libdir";; - esac - case :$dllsearchpath: in - *":$testbindir:"*) ;; - ::) dllsearchpath=$testbindir;; - *) func_append 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"*) - ;; - *) - func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" - ;; - esac - fi - else - eval flag=\"$hardcode_libdir_flag_spec\" - func_append rpath " $flag" - fi - elif test -n "$runpath_var"; then - case "$finalize_perm_rpath " in - *" $libdir "*) ;; - *) func_append 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 "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP` - finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$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 - *cegcc* | *mingw32ce*) - # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. - wrappers_required=no - ;; - *cygwin* | *mingw* ) - if test "$build_libtool_libs" != yes; then - wrappers_required=no - fi - ;; - *) - 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 "$compile_command" | $SED '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=$?' - - if test -n "$postlink_cmds"; then - func_to_tool_file "$output" - postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` - func_execute_cmds "$postlink_cmds" 'exit $?' - fi - - # 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 - func_append 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 - func_append 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 "$link_command" | $SED '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 $?' - - if test -n "$postlink_cmds"; then - func_to_tool_file "$output" - postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` - func_execute_cmds "$postlink_cmds" 'exit $?' - fi - - 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 "$compile_var$compile_command$compile_rpath" | $SED '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 "$link_command" | $SED '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 $?' - - if test -n "$postlink_cmds"; then - func_to_tool_file "$output_objdir/$outputname" - postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` - func_execute_cmds "$postlink_cmds" 'exit $?' - fi - - # 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 "$relink_command" | $SED "$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 - func_append oldobjs " $symfileobj" - fi - fi - addlibs="$old_convenience" - fi - - if test -n "$addlibs"; then - gentop="$output_objdir/${outputname}x" - func_append generated " $gentop" - - func_extract_archives $gentop $addlibs - func_append 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" - func_append generated " $gentop" - - func_extract_archives $gentop $dlprefiles - func_append 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" - func_append 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" - func_append oldobjs " $gentop/$newobj" - ;; - *) func_append oldobjs " $obj" ;; - esac - done - fi - func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 - tool_oldlib=$func_to_tool_file_result - 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 - elif test -n "$archiver_list_spec"; then - func_verbose "using command file archive linking..." - for obj in $oldobjs - do - func_to_tool_file "$obj" - $ECHO "$func_to_tool_file_result" - done > $output_objdir/$libname.libcmd - func_to_tool_file "$output_objdir/$libname.libcmd" - oldobjs=" $archiver_list_spec$func_to_tool_file_result" - 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 "$relink_command" | $SED "$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" - func_resolve_sysroot "$deplib" - eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result` - test -z "$libdir" && \ - func_fatal_error "\`$deplib' is not a valid libtool archive" - func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name" - ;; - -L*) - func_stripname -L '' "$deplib" - func_replace_sysroot "$func_stripname_result" - func_append newdependency_libs " -L$func_replace_sysroot_result" - ;; - -R*) - func_stripname -R '' "$deplib" - func_replace_sysroot "$func_stripname_result" - func_append newdependency_libs " -R$func_replace_sysroot_result" - ;; - *) func_append 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" - func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name" - ;; - *) func_append 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" - func_append newdlprefiles " ${lt_sysroot:+=}$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 - func_append newdlfiles " $abs" - done - dlfiles="$newdlfiles" - newdlprefiles= - for lib in $dlprefiles; do - case $lib in - [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; - *) abs=`pwd`"/$lib" ;; - esac - func_append newdlprefiles " $abs" - done - dlprefiles="$newdlprefiles" - fi - $RM $output - # place dlname in correct position for cygwin - # In fact, it would be nice if we could use this code for all target - # systems that can't hard-code library paths into their executables - # and that have no shared library path variable independent of PATH, - # but it turns out we can't easily determine that from inspecting - # libtool variables, so we have to hard-code the OSs to which it - # applies here; at the moment, that means platforms that use the PE - # object format with DLL files. See the long comment at the top of - # tests/bindir.at for full details. - tdlname=$dlname - case $host,$output,$installed,$module,$dlname in - *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) - # If a -bindir argument was supplied, place the dll there. - if test "x$bindir" != x ; - then - func_relative_path "$install_libdir" "$bindir" - tdlname=$func_relative_path_result$dlname - else - # Otherwise fall back on heuristic. - tdlname=../bin/$dlname - fi - ;; - 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 "$opt_mode" = link || test "$opt_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) func_append RM " $arg"; rmforce=yes ;; - -*) func_append RM " $arg" ;; - *) func_append files " $arg" ;; - esac - done - - test -z "$RM" && \ - func_fatal_help "you must specify an RM program" - - rmdirs= - - for file in $files; do - func_dirname "$file" "" "." - dir="$func_dirname_result" - if test "X$dir" = X.; then - odir="$objdir" - else - odir="$dir/$objdir" - fi - func_basename "$file" - name="$func_basename_result" - test "$opt_mode" = uninstall && odir="$dir" - - # Remember odir for removal later, being careful to avoid duplicates - if test "$opt_mode" = clean; then - case " $rmdirs " in - *" $odir "*) ;; - *) func_append rmdirs " $odir" ;; - 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 - func_append rmfiles " $odir/$n" - done - test -n "$old_library" && func_append rmfiles " $odir/$old_library" - - case "$opt_mode" in - clean) - case " $library_names " in - *" $dlname "*) ;; - *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;; - esac - test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${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 - func_append 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 - func_append rmfiles " $dir/$non_pic_object" - fi - fi - ;; - - *) - if test "$opt_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 - func_append 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 - func_append 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 - func_append rmfiles " $odir/$name $odir/${name}S.${objext}" - if test "$fast_install" = yes && test -n "$relink_command"; then - func_append rmfiles " $odir/lt-$name" - fi - if test "X$noexename" != "X$name" ; then - func_append rmfiles " $odir/lt-${noexename}.c" - fi - fi - fi - ;; - esac - func_show_eval "$RM $rmfiles" 'exit_status=1' - done - - # 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 "$opt_mode" = uninstall || test "$opt_mode" = clean; } && - func_mode_uninstall ${1+"$@"} - -test -z "$opt_mode" && { - help="$generic_help" - func_fatal_help "you must specify a MODE" -} - -test -z "$exec_cmd" && \ - func_fatal_help "invalid operation mode \`$opt_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/vppversion/missing b/vppversion/missing deleted file mode 100755 index db98974f..00000000 --- a/vppversion/missing +++ /dev/null @@ -1,215 +0,0 @@ -#! /bin/sh -# Common wrapper for a few potentially missing GNU programs. - -scriptversion=2013-10-28.13; # UTC - -# Copyright (C) 1996-2013 Free Software Foundation, Inc. -# Originally written 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, see . - -# 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 - -case $1 in - - --is-lightweight) - # Used by our autoconf macros to check whether the available missing - # script is modern enough. - exit 0 - ;; - - --run) - # Back-compat with the calling convention used by older automake. - shift - ;; - - -h|--h|--he|--hel|--help) - echo "\ -$0 [OPTION]... PROGRAM [ARGUMENT]... - -Run 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due -to PROGRAM being missing or too old. - -Options: - -h, --help display this help and exit - -v, --version output version information and exit - -Supported PROGRAM values: - aclocal autoconf autoheader autom4te automake makeinfo - bison yacc flex lex help2man - -Version suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and -'g' are ignored when checking the name. - -Send bug reports to ." - exit $? - ;; - - -v|--v|--ve|--ver|--vers|--versi|--versio|--version) - echo "missing $scriptversion (GNU Automake)" - exit $? - ;; - - -*) - echo 1>&2 "$0: unknown '$1' option" - echo 1>&2 "Try '$0 --help' for more information" - exit 1 - ;; - -esac - -# Run the given program, remember its exit status. -"$@"; st=$? - -# If it succeeded, we are done. -test $st -eq 0 && exit 0 - -# Also exit now if we it failed (or wasn't found), and '--version' was -# passed; such an option is passed most likely to detect whether the -# program is present and works. -case $2 in --version|--help) exit $st;; esac - -# Exit code 63 means version mismatch. This often happens when the user -# tries to use an ancient version of a tool on a file that requires a -# minimum version. -if test $st -eq 63; then - msg="probably too old" -elif test $st -eq 127; then - # Program was missing. - msg="missing on your system" -else - # Program was found and executed, but failed. Give up. - exit $st -fi - -perl_URL=http://www.perl.org/ -flex_URL=http://flex.sourceforge.net/ -gnu_software_URL=http://www.gnu.org/software - -program_details () -{ - case $1 in - aclocal|automake) - echo "The '$1' program is part of the GNU Automake package:" - echo "<$gnu_software_URL/automake>" - echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:" - echo "<$gnu_software_URL/autoconf>" - echo "<$gnu_software_URL/m4/>" - echo "<$perl_URL>" - ;; - autoconf|autom4te|autoheader) - echo "The '$1' program is part of the GNU Autoconf package:" - echo "<$gnu_software_URL/autoconf/>" - echo "It also requires GNU m4 and Perl in order to run:" - echo "<$gnu_software_URL/m4/>" - echo "<$perl_URL>" - ;; - esac -} - -give_advice () -{ - # Normalize program name to check for. - normalized_program=`echo "$1" | sed ' - s/^gnu-//; t - s/^gnu//; t - s/^g//; t'` - - printf '%s\n' "'$1' is $msg." - - configure_deps="'configure.ac' or m4 files included by 'configure.ac'" - case $normalized_program in - autoconf*) - echo "You should only need it if you modified 'configure.ac'," - echo "or m4 files included by it." - program_details 'autoconf' - ;; - autoheader*) - echo "You should only need it if you modified 'acconfig.h' or" - echo "$configure_deps." - program_details 'autoheader' - ;; - automake*) - echo "You should only need it if you modified 'Makefile.am' or" - echo "$configure_deps." - program_details 'automake' - ;; - aclocal*) - echo "You should only need it if you modified 'acinclude.m4' or" - echo "$configure_deps." - program_details 'aclocal' - ;; - autom4te*) - echo "You might have modified some maintainer files that require" - echo "the 'autom4te' program to be rebuilt." - program_details 'autom4te' - ;; - bison*|yacc*) - echo "You should only need it if you modified a '.y' file." - echo "You may want to install the GNU Bison package:" - echo "<$gnu_software_URL/bison/>" - ;; - lex*|flex*) - echo "You should only need it if you modified a '.l' file." - echo "You may want to install the Fast Lexical Analyzer package:" - echo "<$flex_URL>" - ;; - help2man*) - echo "You should only need it if you modified a dependency" \ - "of a man page." - echo "You may want to install the GNU Help2man package:" - echo "<$gnu_software_URL/help2man/>" - ;; - makeinfo*) - echo "You should only need it if you modified a '.texi' file, or" - echo "any other file indirectly affecting the aspect of the manual." - echo "You might want to install the Texinfo package:" - echo "<$gnu_software_URL/texinfo/>" - echo "The spurious makeinfo call might also be the consequence of" - echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might" - echo "want to install GNU make:" - echo "<$gnu_software_URL/make/>" - ;; - *) - echo "You might have modified some files without having the proper" - echo "tools for further handling them. Check the 'README' file, it" - echo "often tells you about the needed prerequisites for installing" - echo "this package. You may also peek at any GNU archive site, in" - echo "case some other package contains this missing '$1' program." - ;; - esac -} - -give_advice "$1" | sed -e '1s/^/WARNING: /' \ - -e '2,$s/^/ /' >&2 - -# Propagate the correct exit status (expected to be 127 for a program -# not found, 63 for a program that failed due to version mismatch). -exit $st - -# Local variables: -# eval: (add-hook 'write-file-hooks 'time-stamp) -# time-stamp-start: "scriptversion=" -# time-stamp-format: "%:y-%02m-%02d.%02H" -# time-stamp-time-zone: "UTC" -# time-stamp-end: "; # UTC" -# End: -- cgit 1.2.3-korg From c72cbf80d0674a745fef2effb3c2f6dbcf5bf98e Mon Sep 17 00:00:00 2001 From: Ed Warnicke Date: Tue, 15 Dec 2015 15:08:54 -0800 Subject: Add vppctl as a simple cli interface to vpp This patch provides a pretty simple hack on top of vpe_api_test to give users a cli interface to vpp. Example: sudo vppctl show api client sudo vppctl show int It has the advantage that users can use bash shell scripting and history with it. Change-Id: I621dd8e29269e14a83b4887f20adcfbe5f946b99 Signed-off-by: Ed Warnicke --- build-data/packages/vppctl.mk | 11 +++++++++++ build-data/platforms/vpp.mk | 2 +- vppctl/Makefile.am | 2 ++ vppctl/configure.ac | 4 ++++ vppctl/vppctl | 2 ++ 5 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 build-data/packages/vppctl.mk create mode 100644 vppctl/Makefile.am create mode 100644 vppctl/configure.ac create mode 100755 vppctl/vppctl (limited to 'build-data/platforms/vpp.mk') diff --git a/build-data/packages/vppctl.mk b/build-data/packages/vppctl.mk new file mode 100644 index 00000000..a5f8757b --- /dev/null +++ b/build-data/packages/vppctl.mk @@ -0,0 +1,11 @@ +vppctl_configure_depend = \ + vppinfra-install \ + dpdk-install \ + svm-install \ + vlib-api-install \ + vlib-install \ + vnet-install \ + vpp-install \ + vpp-api-test-install + + diff --git a/build-data/platforms/vpp.mk b/build-data/platforms/vpp.mk index a09b0307..b84fc976 100644 --- a/build-data/platforms/vpp.mk +++ b/build-data/platforms/vpp.mk @@ -16,7 +16,7 @@ vpp_arch = native vpp_native_tools = vppapigen vpp_root_packages = vpp vlib vlib-api vnet svm dpdk vpp-api-test \ - vpp-japi + vpp-japi vppctl vpp_configure_args_vpp = --with-dpdk vnet_configure_args_vpp = --with-dpdk diff --git a/vppctl/Makefile.am b/vppctl/Makefile.am new file mode 100644 index 00000000..d556cb2a --- /dev/null +++ b/vppctl/Makefile.am @@ -0,0 +1,2 @@ + +dist_bin_SCRIPTS = vppctl diff --git a/vppctl/configure.ac b/vppctl/configure.ac new file mode 100644 index 00000000..04210194 --- /dev/null +++ b/vppctl/configure.ac @@ -0,0 +1,4 @@ +AC_INIT([vppctl], [1.0]) +AM_INIT_AUTOMAKE([foreign -Wall -Werror]) +AC_CONFIG_FILES([Makefile]) +AC_OUTPUT diff --git a/vppctl/vppctl b/vppctl/vppctl new file mode 100755 index 00000000..b789493f --- /dev/null +++ b/vppctl/vppctl @@ -0,0 +1,2 @@ +#!/bin/bash +echo exec ${@} | vpe_api_test | sed 's/vat# //g' -- cgit 1.2.3-korg From f750ac2b79fa150f5ff4d57281d04024658f3f42 Mon Sep 17 00:00:00 2001 From: Damjan Marion Date: Wed, 16 Dec 2015 20:52:23 +0100 Subject: Move vppctl to vpp-api-test Change-Id: I4af0eb9c09d14a1a9803cf1b25bc3d7b814c82cc Signed-off-by: Damjan Marion --- build-data/packages/vppctl.mk | 11 ----------- build-data/platforms/vpp.mk | 2 +- vpp-api-test/Makefile.am | 1 + vpp-api-test/scripts/vppctl | 2 ++ vppctl/Makefile.am | 2 -- vppctl/configure.ac | 4 ---- vppctl/vppctl | 2 -- 7 files changed, 4 insertions(+), 20 deletions(-) delete mode 100644 build-data/packages/vppctl.mk create mode 100644 vpp-api-test/scripts/vppctl delete mode 100644 vppctl/Makefile.am delete mode 100644 vppctl/configure.ac delete mode 100755 vppctl/vppctl (limited to 'build-data/platforms/vpp.mk') diff --git a/build-data/packages/vppctl.mk b/build-data/packages/vppctl.mk deleted file mode 100644 index a5f8757b..00000000 --- a/build-data/packages/vppctl.mk +++ /dev/null @@ -1,11 +0,0 @@ -vppctl_configure_depend = \ - vppinfra-install \ - dpdk-install \ - svm-install \ - vlib-api-install \ - vlib-install \ - vnet-install \ - vpp-install \ - vpp-api-test-install - - diff --git a/build-data/platforms/vpp.mk b/build-data/platforms/vpp.mk index b84fc976..a09b0307 100644 --- a/build-data/platforms/vpp.mk +++ b/build-data/platforms/vpp.mk @@ -16,7 +16,7 @@ vpp_arch = native vpp_native_tools = vppapigen vpp_root_packages = vpp vlib vlib-api vnet svm dpdk vpp-api-test \ - vpp-japi vppctl + vpp-japi vpp_configure_args_vpp = --with-dpdk vnet_configure_args_vpp = --with-dpdk diff --git a/vpp-api-test/Makefile.am b/vpp-api-test/Makefile.am index a818d831..ae071bce 100644 --- a/vpp-api-test/Makefile.am +++ b/vpp-api-test/Makefile.am @@ -32,3 +32,4 @@ vpe_json_test_LDADD = -lvppinfra -lm nobase_include_HEADERS = vat/vat.h vat/json_format.h +dist_bin_SCRIPTS = scripts/vppctl diff --git a/vpp-api-test/scripts/vppctl b/vpp-api-test/scripts/vppctl new file mode 100644 index 00000000..b789493f --- /dev/null +++ b/vpp-api-test/scripts/vppctl @@ -0,0 +1,2 @@ +#!/bin/bash +echo exec ${@} | vpe_api_test | sed 's/vat# //g' diff --git a/vppctl/Makefile.am b/vppctl/Makefile.am deleted file mode 100644 index d556cb2a..00000000 --- a/vppctl/Makefile.am +++ /dev/null @@ -1,2 +0,0 @@ - -dist_bin_SCRIPTS = vppctl diff --git a/vppctl/configure.ac b/vppctl/configure.ac deleted file mode 100644 index 04210194..00000000 --- a/vppctl/configure.ac +++ /dev/null @@ -1,4 +0,0 @@ -AC_INIT([vppctl], [1.0]) -AM_INIT_AUTOMAKE([foreign -Wall -Werror]) -AC_CONFIG_FILES([Makefile]) -AC_OUTPUT diff --git a/vppctl/vppctl b/vppctl/vppctl deleted file mode 100755 index b789493f..00000000 --- a/vppctl/vppctl +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -echo exec ${@} | vpe_api_test | sed 's/vat# //g' -- cgit 1.2.3-korg From b10277dedc04da0c4334fadf2ac6b18a453f6491 Mon Sep 17 00:00:00 2001 From: Dave Barach Date: Tue, 2 Feb 2016 10:57:15 -0500 Subject: Enable ganglia module integration build Change-Id: Ia49e9f246e8318ba74195c3397472fb0c102389b Signed-off-by: Dave Barach --- build-data/packages/gmod.mk | 2 +- build-data/platforms/vpp.mk | 2 +- build-root/vagrant/bootstrap.centos7.sh | 8 ++++++++ 3 files changed, 10 insertions(+), 2 deletions(-) (limited to 'build-data/platforms/vpp.mk') diff --git a/build-data/packages/gmod.mk b/build-data/packages/gmod.mk index 3f9a9f7f..a6ba42d0 100644 --- a/build-data/packages/gmod.mk +++ b/build-data/packages/gmod.mk @@ -3,7 +3,7 @@ gmod_configure_depend = vppinfra-install svm-install gmod_configure_args = --libdir=$(PACKAGE_INSTALL_DIR)/$(arch_lib_dir)/ganglia gmod_CPPFLAGS = $(call installed_includes_fn, vppinfra svm) -gmod_CPPFLAGS += -I/usr/include/apr-1.0 -I/usr/include +gmod_CPPFLAGS += -I/usr/include/apr-1.0 -I/usr/include/apr-1 -I/usr/include gmod_LDFLAGS = $(call installed_libs_fn, vppinfra svm) gmod_image_include = echo $(arch_lib_dir)/ganglia/libgmodvpp.so etc diff --git a/build-data/platforms/vpp.mk b/build-data/platforms/vpp.mk index a09b0307..4c75d74d 100644 --- a/build-data/platforms/vpp.mk +++ b/build-data/platforms/vpp.mk @@ -16,7 +16,7 @@ vpp_arch = native vpp_native_tools = vppapigen vpp_root_packages = vpp vlib vlib-api vnet svm dpdk vpp-api-test \ - vpp-japi + vpp-japi gmod vpp_configure_args_vpp = --with-dpdk vnet_configure_args_vpp = --with-dpdk diff --git a/build-root/vagrant/bootstrap.centos7.sh b/build-root/vagrant/bootstrap.centos7.sh index f55e68a2..d874d3c3 100644 --- a/build-root/vagrant/bootstrap.centos7.sh +++ b/build-root/vagrant/bootstrap.centos7.sh @@ -11,6 +11,14 @@ yum install glibc-static -y # Install jdk and maven yum install -y java-1.8.0-openjdk-devel +# Install EPEL +yum install -y epel-release + +# Install components to build Ganglia modules +yum install -y apr-devel +yum install -y --enablerepo=epel libconfuse-devel +yum install -y --enablerepo=epel ganglia-devel + # Load the uio kernel module modprobe uio_pci_generic -- cgit 1.2.3-korg From 20abdd9b02595aec1d64574e59b24998dd51c31c Mon Sep 17 00:00:00 2001 From: Dave Barach Date: Wed, 10 Feb 2016 09:13:23 -0500 Subject: Compile with -Werror, so Jenkins will catch warnings Change-Id: I9255c75b6c6cbc638cdcc411632a924cb06f28c0 Signed-off-by: Dave Barach --- build-data/platforms/vpp.mk | 8 ++++---- vnet/vnet/devices/dpdk/vhost_user.c | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'build-data/platforms/vpp.mk') diff --git a/build-data/platforms/vpp.mk b/build-data/platforms/vpp.mk index 4c75d74d..555147df 100644 --- a/build-data/platforms/vpp.mk +++ b/build-data/platforms/vpp.mk @@ -28,11 +28,11 @@ vlib_configure_args_vpp = --with-pre-data=128 vpp_debug_TAG_CFLAGS = -g -O0 -DCLIB_DEBUG -DFORTIFY_SOURCE=2 -march=$(MARCH) \ - -fstack-protector-all -fPIC + -fstack-protector-all -fPIC -Werror vpp_debug_TAG_LDFLAGS = -g -O0 -DCLIB_DEBUG -DFORTIFY_SOURCE=2 -march=$(MARCH) \ - -fstack-protector-all -fPIC + -fstack-protector-all -fPIC -Werror vpp_TAG_CFLAGS = -g -O2 -DFORTIFY_SOURCE=2 -march=$(MARCH) \ - -fstack-protector -fPIC + -fstack-protector -fPIC -Werror vpp_TAG_LDFLAGS = -g -O2 -DFORTIFY_SOURCE=2 -march=$(MARCH) \ - -fstack-protector -fPIC + -fstack-protector -fPIC -Werror diff --git a/vnet/vnet/devices/dpdk/vhost_user.c b/vnet/vnet/devices/dpdk/vhost_user.c index d6ed35fa..91734e29 100644 --- a/vnet/vnet/devices/dpdk/vhost_user.c +++ b/vnet/vnet/devices/dpdk/vhost_user.c @@ -39,7 +39,7 @@ #define DBG_SOCK(args...) #endif -static const char *vhost_message_str[] = { +static const char *vhost_message_str[] __attribute__((unused)) = { [VHOST_USER_NONE] = "VHOST_USER_NONE", [VHOST_USER_GET_FEATURES] = "VHOST_USER_GET_FEATURES", [VHOST_USER_SET_FEATURES] = "VHOST_USER_SET_FEATURES", -- cgit 1.2.3-korg From e936bbe5945ca3c0f522f6c0abdfbdaa407bcb84 Mon Sep 17 00:00:00 2001 From: Damjan Marion Date: Thu, 25 Feb 2016 23:17:38 +0100 Subject: Add support for native vpp_lite (non-dpdk) platform Change-Id: Icaa71957f67b923bc9795baa78c7495055615672 Signed-off-by: Damjan Marion --- build-data/packages/vlib.mk | 13 +++++++++---- build-data/packages/vnet.mk | 8 +++++--- build-data/packages/vpp.mk | 9 ++++++--- build-data/platforms/virl.mk | 2 ++ build-data/platforms/vpp.mk | 2 ++ build-data/platforms/vpp_lite.mk | 36 ++++++++++++++++++++++++++++++++++++ vlib/vlib/threads.c | 3 ++- vnet/Makefile.am | 4 +++- vnet/vnet/ip/ip6_neighbor.c | 4 +++- vnet/vnet/ipsec/esp.h | 2 ++ vnet/vnet/ipsec/ikev2.c | 29 ----------------------------- vnet/vnet/ipsec/ikev2_payload.c | 2 ++ vnet/vnet/ipsec/ipsec.h | 7 ++++++- vnet/vnet/ipsec/ipsec_output.c | 21 +++++++++++++++++++++ vnet/vnet/lawful-intercept/node.c | 6 ------ vnet/vnet/policer/node_funcs.c | 3 +++ vnet/vnet/policer/policer.c | 1 + vnet/vnet/policer/xlate.c | 1 + vpp/api/api.c | 2 +- 19 files changed, 105 insertions(+), 50 deletions(-) create mode 100644 build-data/platforms/vpp_lite.mk (limited to 'build-data/platforms/vpp.mk') diff --git a/build-data/packages/vlib.mk b/build-data/packages/vlib.mk index 11bb1c7a..8b72b602 100644 --- a/build-data/packages/vlib.mk +++ b/build-data/packages/vlib.mk @@ -1,6 +1,11 @@ -vlib_configure_depend = vppinfra-install dpdk-install +vlib_configure_depend = vppinfra-install -vlib_configure_args += --with-dpdk +vlib_CPPFLAGS = $(call installed_includes_fn, vppinfra) +vlib_LDFLAGS = $(call installed_libs_fn, vppinfra) -vlib_CPPFLAGS = $(call installed_includes_fn, vppinfra dpdk) -vlib_LDFLAGS = $(call installed_libs_fn, vppinfra dpdk) +ifeq ($($(PLATFORM)_uses_dpdk),yes) +vlib_configure_depend += dpdk-install +vlib_configure_args += --with-dpdk +vlib_CPPFLAGS += $(call installed_includes_fn, dpdk) +vlib_LDFLAGS += $(call installed_libs_fn, dpdk) +endif diff --git a/build-data/packages/vnet.mk b/build-data/packages/vnet.mk index 4aa29613..ca3523cc 100644 --- a/build-data/packages/vnet.mk +++ b/build-data/packages/vnet.mk @@ -1,13 +1,11 @@ vnet_configure_depend = \ vppinfra-install \ - dpdk-install \ svm-install \ vlib-api-install \ vlib-install vnet_CPPFLAGS = $(call installed_includes_fn, \ vppinfra \ - dpdk \ openssl \ svm \ vlib \ @@ -15,7 +13,6 @@ vnet_CPPFLAGS = $(call installed_includes_fn, \ vnet_LDFLAGS = $(call installed_libs_fn, \ vppinfra \ - dpdk \ openssl \ svm \ vlib \ @@ -24,3 +21,8 @@ vnet_LDFLAGS = $(call installed_libs_fn, \ # Platform dependent configure flags vnet_configure_args += $(vnet_configure_args_$(PLATFORM)) +ifeq ($($(PLATFORM)_uses_dpdk),yes) +vnet_configure_depend += dpdk-install +vnet_CPPFLAGS += $(call installed_includes_fn, dpdk) +vnet_LDFLAGS += $(call installed_libs_fn, dpdk) +endif diff --git a/build-data/packages/vpp.mk b/build-data/packages/vpp.mk index 02aca4e6..54aa5484 100644 --- a/build-data/packages/vpp.mk +++ b/build-data/packages/vpp.mk @@ -1,6 +1,5 @@ vpp_configure_depend = \ vppinfra-install \ - dpdk-install \ svm-install \ vlib-api-install \ vlib-install \ @@ -15,7 +14,6 @@ vpp_configure_args += $(vpp_configure_args_$(PLATFORM)) vpp_CPPFLAGS = $(call installed_includes_fn, \ vppinfra \ - dpdk \ openssl \ svm \ vlib \ @@ -24,9 +22,14 @@ vpp_CPPFLAGS = $(call installed_includes_fn, \ vpp_LDFLAGS = $(call installed_libs_fn, \ vppinfra \ - dpdk \ openssl \ svm \ vlib \ vlib-api \ vnet) + +ifeq ($($(PLATFORM)_uses_dpdk),yes) +vpp_configure_depend += dpdk-install +vpp_CPPFLAGS += $(call installed_includes_fn, dpdk) +vpp_LDFLAGS += $(call installed_libs_fn, dpdk) +endif diff --git a/build-data/platforms/virl.mk b/build-data/platforms/virl.mk index 40f79418..29b47dad 100644 --- a/build-data/platforms/virl.mk +++ b/build-data/platforms/virl.mk @@ -15,6 +15,8 @@ virl_arch = native virl_native_tools = vppapigen +virl_uses_dpdk = yes + virl_root_packages = vpp vlib vlib-api vnet svm dpdk vpp-api-test \ vpp-japi diff --git a/build-data/platforms/vpp.mk b/build-data/platforms/vpp.mk index 555147df..6b1ba82f 100644 --- a/build-data/platforms/vpp.mk +++ b/build-data/platforms/vpp.mk @@ -15,6 +15,8 @@ vpp_arch = native vpp_native_tools = vppapigen +vpp_uses_dpdk = yes + vpp_root_packages = vpp vlib vlib-api vnet svm dpdk vpp-api-test \ vpp-japi gmod diff --git a/build-data/platforms/vpp_lite.mk b/build-data/platforms/vpp_lite.mk new file mode 100644 index 00000000..9376aa35 --- /dev/null +++ b/build-data/platforms/vpp_lite.mk @@ -0,0 +1,36 @@ +# Copyright (c) 2016 Cisco and/or its affiliates. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# vector packet processor +vpp_lite_arch = native +vpp_lite_native_tools = vppapigen + +vpp_lite_uses_dpdk = no + +vpp_lite_root_packages = vpp vlib vlib-api vnet svm vpp-api-test \ + vpp-japi gmod + +vlib_configure_args_vpp_lite = --with-pre-data=128 + +vnet_configure_args_vpp_lite = --without-vcgn +vpp_configure_args_vpp_lite = --without-vcgn + +vpp_lite_debug_TAG_CFLAGS = -g -O0 -DCLIB_DEBUG -DFORTIFY_SOURCE=2 -march=$(MARCH) \ + -fstack-protector-all -fPIC -Werror +vpp_lite_debug_TAG_LDFLAGS = -g -O0 -DCLIB_DEBUG -DFORTIFY_SOURCE=2 -march=$(MARCH) \ + -fstack-protector-all -fPIC -Werror + +vpp_lite_TAG_CFLAGS = -g -O2 -DFORTIFY_SOURCE=2 -march=$(MARCH) \ + -fstack-protector -fPIC -Werror +vpp_lite_TAG_LDFLAGS = -g -O2 -DFORTIFY_SOURCE=2 -march=$(MARCH) \ + -fstack-protector -fPIC -Werror diff --git a/vlib/vlib/threads.c b/vlib/vlib/threads.c index 72102561..1f3c141b 100644 --- a/vlib/vlib/threads.c +++ b/vlib/vlib/threads.c @@ -1142,6 +1142,7 @@ show_threads_fn (vlib_main_t * vm, w->registration ? w->registration->name : "", w->lwp); +#if DPDK==1 int lcore = w->dpdk_lcore_id; if (lcore > -1) { @@ -1165,7 +1166,7 @@ show_threads_fn (vlib_main_t * vm, line = format(line, "unknown"); } } - +#endif vlib_cli_output(vm, "%v", line); vec_free(line); } diff --git a/vnet/Makefile.am b/vnet/Makefile.am index 411dce3b..cf1fb1e0 100644 --- a/vnet/Makefile.am +++ b/vnet/Makefile.am @@ -299,7 +299,6 @@ libvnet_la_SOURCES += \ vnet/ipsec/ipsec.c \ vnet/ipsec/ipsec_cli.c \ vnet/ipsec/ipsec_format.c \ - vnet/ipsec/ipsec_output.c \ vnet/ipsec/ipsec_input.c \ vnet/ipsec/ipsec_if.c \ vnet/ipsec/ipsec_if_in.c \ @@ -313,6 +312,9 @@ libvnet_la_SOURCES += \ vnet/ipsec/ikev2_format.c endif +libvnet_la_SOURCES += \ + vnet/ipsec/ipsec_output.c + nobase_include_HEADERS += \ vnet/ipsec/ipsec.h \ vnet/ipsec/esp.h \ diff --git a/vnet/vnet/ip/ip6_neighbor.c b/vnet/vnet/ip/ip6_neighbor.c index 3eb9710d..70d77a5f 100644 --- a/vnet/vnet/ip/ip6_neighbor.c +++ b/vnet/vnet/ip/ip6_neighbor.c @@ -284,10 +284,10 @@ typedef struct { ip6_address_t addr; } ip6_neighbor_set_unset_rpc_args_t; +#if DPDK > 0 static void ip6_neighbor_set_unset_rpc_callback ( ip6_neighbor_set_unset_rpc_args_t * a); -#if DPDK > 0 static void set_unset_ip6_neighbor_rpc (vlib_main_t * vm, u32 sw_if_index, @@ -458,6 +458,7 @@ vnet_unset_ip6_ethernet_neighbor (vlib_main_t * vm, return rv; } +#if DPDK > 0 static void ip6_neighbor_set_unset_rpc_callback ( ip6_neighbor_set_unset_rpc_args_t * a) { @@ -469,6 +470,7 @@ static void ip6_neighbor_set_unset_rpc_callback vnet_unset_ip6_ethernet_neighbor (vm, a->sw_if_index, &a->addr, a->link_layer_address, 6); } +#endif static int ip6_neighbor_sort (void *a1, void *a2) diff --git a/vnet/vnet/ipsec/esp.h b/vnet/vnet/ipsec/esp.h index 3d46a013..b44c26e1 100644 --- a/vnet/vnet/ipsec/esp.h +++ b/vnet/vnet/ipsec/esp.h @@ -12,7 +12,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#if DPDK==1 #include +#endif #include #include diff --git a/vnet/vnet/ipsec/ikev2.c b/vnet/vnet/ipsec/ikev2.c index ab2277f5..70dd58bd 100644 --- a/vnet/vnet/ipsec/ikev2.c +++ b/vnet/vnet/ipsec/ikev2.c @@ -26,29 +26,6 @@ static int ikev2_delete_tunnel_interface(vnet_main_t * vnm, ikev2_sa_t *sa, ikev2_child_sa_t * child); -static void hexdump(u8 buffer[], int len) -{ -#define HEXDUMP_LINE_LEN 16 - int i; - char s[HEXDUMP_LINE_LEN+1]; - bzero(s, HEXDUMP_LINE_LEN+1); - - for(i=0; i < len; i++) { - if (!(i%HEXDUMP_LINE_LEN)) { - if (s[0]) - printf("[%s]",s); - printf("\n%05x: ", i); - bzero(s, HEXDUMP_LINE_LEN); - } - s[i%HEXDUMP_LINE_LEN]=isprint(buffer[i])?buffer[i]:'.'; - printf("%02x ", buffer[i]); - } - while(i++%HEXDUMP_LINE_LEN) - printf(" "); - - printf("[%s]\n", s); -} - #define ikev2_set_state(sa, v) do { \ (sa)->state = v; \ clib_warning("sa state changed to " #v); \ @@ -458,7 +435,6 @@ ikev2_calc_child_keys(ikev2_sa_t *sa, ikev2_child_sa_t * child) int len = ctr_encr->key_len * 2 + ctr_integ->key_len * 2; keymat = ikev2_calc_prfplus(tr_prf, sa->sk_d, s, len); - hexdump(keymat, vec_len(keymat)); int pos = 0; @@ -1884,7 +1860,6 @@ ikev2_node_fn (vlib_main_t * vm, ike0->exchange, format_ip4_address, ip40->src_address.as_u8, format_ip4_address, ip40->dst_address.as_u8); - hexdump((u8 *) ip40, b0->current_length); } dispatch0: @@ -1899,10 +1874,6 @@ dispatch0: b0->current_length = len + sizeof(ip4_header_t) + sizeof(udp_header_t); ip40->length = clib_host_to_net_u16(b0->current_length); ip40->checksum = ip4_header_checksum (ip40); -#if 0 - clib_warning("sending response:"); - hexdump(vlib_buffer_get_current (b0), b0->current_length); -#endif } /* delete sa */ if (sa0 && (sa0->state == IKEV2_STATE_DELETED || diff --git a/vnet/vnet/ipsec/ikev2_payload.c b/vnet/vnet/ipsec/ikev2_payload.c index f523fa81..a1ee5192 100644 --- a/vnet/vnet/ipsec/ikev2_payload.c +++ b/vnet/vnet/ipsec/ikev2_payload.c @@ -13,6 +13,8 @@ * limitations under the License. */ +#include + #include #include #include diff --git a/vnet/vnet/ipsec/ipsec.h b/vnet/vnet/ipsec/ipsec.h index 6ef36d02..b755976f 100644 --- a/vnet/vnet/ipsec/ipsec.h +++ b/vnet/vnet/ipsec/ipsec.h @@ -12,7 +12,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#if DPDK==1 #include +#endif #define foreach_ipsec_policy_action \ _(0, BYPASS, "bypass") \ @@ -237,9 +239,12 @@ int ipsec_set_interface_key(vnet_main_t * vnm, u32 hw_if_index, ipsec_if_set_key always_inline void ipsec_alloc_empty_buffers(vlib_main_t * vm, ipsec_main_t *im) { +#if DPDK==1 dpdk_main_t * dm = &dpdk_main; u32 free_list_index = dm->vlib_buffer_free_list_index; - +#else + u32 free_list_index = VLIB_BUFFER_DEFAULT_FREE_LIST_INDEX; +#endif uword l = vec_len (im->empty_buffers); uword n_alloc = 0; diff --git a/vnet/vnet/ipsec/ipsec_output.c b/vnet/vnet/ipsec/ipsec_output.c index ac5968b9..fd804fae 100644 --- a/vnet/vnet/ipsec/ipsec_output.c +++ b/vnet/vnet/ipsec/ipsec_output.c @@ -21,6 +21,7 @@ #include +#if IPSEC > 0 #define foreach_ipsec_output_next \ _(DROP, "error-drop") \ @@ -403,3 +404,23 @@ VLIB_REGISTER_NODE (ipsec_output_node) = { #undef _ }, }; + +#else /* IPSEC > 1 */ + +/* Dummy ipsec output node, in case when IPSec is disabled */ + +static uword +ipsec_output_node_fn (vlib_main_t * vm, + vlib_node_runtime_t * node, + vlib_frame_t * frame) +{ + clib_warning ("IPSec disabled"); + return 0; +} + +VLIB_REGISTER_NODE (ipsec_output_node) = { + .vector_size = sizeof (u32), + .function = ipsec_output_node_fn, + .name = "ipsec-output", +}; +#endif diff --git a/vnet/vnet/lawful-intercept/node.c b/vnet/vnet/lawful-intercept/node.c index 8a47aa32..26514cc5 100644 --- a/vnet/vnet/lawful-intercept/node.c +++ b/vnet/vnet/lawful-intercept/node.c @@ -290,12 +290,6 @@ VLIB_REGISTER_NODE (li_hit_node) = { .name = "li-hit", }; -VLIB_REGISTER_NODE (ipsec_output_node) = { - .vector_size = sizeof (u32), - .function = li_hit_node_fn, - .name = "ipsec-output", -}; - static clib_error_t * li_init (vlib_main_t * vm) { diff --git a/vnet/vnet/policer/node_funcs.c b/vnet/vnet/policer/node_funcs.c index b85418fe..8a76e869 100644 --- a/vnet/vnet/policer/node_funcs.c +++ b/vnet/vnet/policer/node_funcs.c @@ -12,6 +12,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +#include + #include #include #include diff --git a/vnet/vnet/policer/policer.c b/vnet/vnet/policer/policer.c index 310c5f59..a43dc751 100644 --- a/vnet/vnet/policer/policer.c +++ b/vnet/vnet/policer/policer.c @@ -12,6 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include #include u8 * format_policer_instance (u8 * s, va_list * va) diff --git a/vnet/vnet/policer/xlate.c b/vnet/vnet/policer/xlate.c index 6e8c324a..d1eab304 100644 --- a/vnet/vnet/policer/xlate.c +++ b/vnet/vnet/policer/xlate.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include diff --git a/vpp/api/api.c b/vpp/api/api.c index f51fa0a3..2c0b4b3c 100644 --- a/vpp/api/api.c +++ b/vpp/api/api.c @@ -75,10 +75,10 @@ #undef __included_bihash_template_h__ #include -#if DPDK > 0 #if IPSEC > 0 #include #endif /* IPSEC */ +#if DPDK > 0 #include #endif -- cgit 1.2.3-korg From 19010202285445372c281faca6a9757fd0ed466c Mon Sep 17 00:00:00 2001 From: Damjan Marion Date: Thu, 24 Mar 2016 17:17:47 +0100 Subject: Use rte_mempool private data for storing vlib_buffer_t Change-Id: If3fc88a35bc0b736376113a39667caea42802ea1 Signed-off-by: Damjan Marion --- build-data/platforms/virl.mk | 2 -- build-data/platforms/vpp.mk | 2 -- dpdk/Makefile | 2 +- vlib/vlib/buffer.h | 45 ++++++++++++++++++++------------- vlib/vlib/buffer_funcs.h | 37 +++++++++++++++++---------- vlib/vlib/dpdk_buffer.c | 51 +++++++++++++++++++++----------------- vnet/vnet/devices/af_packet/node.c | 8 +++--- vnet/vnet/devices/dpdk/device.c | 20 +++++++-------- vnet/vnet/devices/dpdk/dpdk.h | 1 - vnet/vnet/devices/dpdk/init.c | 4 +-- vnet/vnet/devices/dpdk/node.c | 32 ++++++++++++------------ vnet/vnet/devices/ssvm/ssvm_eth.h | 2 +- vnet/vnet/dpdk_replication.h | 6 ++--- vnet/vnet/ip/ip.h | 2 +- vnet/vnet/ip/ip6_forward.c | 2 +- vnet/vnet/pg/input.c | 6 ++--- vnet/vnet/unix/tapcli.c | 4 +-- vnet/vnet/unix/tuntap.c | 12 +++------ 18 files changed, 126 insertions(+), 112 deletions(-) (limited to 'build-data/platforms/vpp.mk') diff --git a/build-data/platforms/virl.mk b/build-data/platforms/virl.mk index 29b47dad..f47f3691 100644 --- a/build-data/platforms/virl.mk +++ b/build-data/platforms/virl.mk @@ -24,8 +24,6 @@ vpp_configure_args_virl = --with-dpdk vnet_configure_args_virl = --with-dpdk --with-virl # Set these parameters carefully. The vlib_buffer_t is 128 bytes, i.e. -# dpdk_headroom = uiotarball_headroom = vlib_pre_data + 128 -dpdk_configure_args_virl = --with-headroom=256 vlib_configure_args_virl = --with-pre-data=128 # Override default -march and CONFIG_RTE_MACHINE settings diff --git a/build-data/platforms/vpp.mk b/build-data/platforms/vpp.mk index 6b1ba82f..50c85dcc 100644 --- a/build-data/platforms/vpp.mk +++ b/build-data/platforms/vpp.mk @@ -24,8 +24,6 @@ vpp_configure_args_vpp = --with-dpdk vnet_configure_args_vpp = --with-dpdk # Set these parameters carefully. The vlib_buffer_t is 128 bytes, i.e. -# dpdk_headroom = uiotarball_headroom = vlib_pre_data + 128 -dpdk_configure_args_vpp = --with-headroom=256 vlib_configure_args_vpp = --with-pre-data=128 diff --git a/dpdk/Makefile b/dpdk/Makefile index a07e8615..dabbf6ad 100644 --- a/dpdk/Makefile +++ b/dpdk/Makefile @@ -16,7 +16,7 @@ SHELL := /bin/bash DPDK_BUILD_DIR ?= $(CURDIR)/_build DPDK_INSTALL_DIR ?= $(CURDIR)/_install -DPDK_PKTMBUF_HEADROOM ?= 256 +DPDK_PKTMBUF_HEADROOM ?= 128 DPDK_DOWNLOAD_DIR ?= $(HOME)/Downloads DPDK_MARCH ?= native DPDK_DEBUG ?= n diff --git a/vlib/vlib/buffer.h b/vlib/vlib/buffer.h index 6322481b..9c148ef2 100644 --- a/vlib/vlib/buffer.h +++ b/vlib/vlib/buffer.h @@ -45,7 +45,16 @@ #include #include #include /* for vlib_error_t */ + +#if DPDK > 0 +#include +#define VLIB_BUFFER_DATA_SIZE (2048) +#define VLIB_BUFFER_PRE_DATA_SIZE RTE_PKTMBUF_HEADROOM +#else #include /* for __PRE_DATA_SIZE */ +#define VLIB_BUFFER_DATA_SIZE (512) +#define VLIB_BUFFER_PRE_DATA_SIZE __PRE_DATA_SIZE +#endif #ifdef CLIB_HAVE_VEC128 typedef u8x16 vlib_copy_unit_t; @@ -62,6 +71,7 @@ typedef uword vlib_copy_unit_t; /* VLIB buffer representation. */ typedef struct { + CLIB_CACHE_LINE_ALIGN_MARK(cacheline0); /* Offset within data[] that we are currently processing. If negative current header points into predata area. */ i16 current_data; /**< signed offset in data[], pre_data[] @@ -124,23 +134,25 @@ typedef struct { u32 opaque[8]; /**< Opaque data used by sub-graphs for their own purposes. See .../vnet/vnet/buffer.h */ - /***** end of first cache line */ + CLIB_CACHE_LINE_ALIGN_MARK(cacheline1); u32 opaque2[16]; /**< More opaque data, in its own cache line */ /***** end of second cache line */ - u8 pre_data [__PRE_DATA_SIZE]; /**< Space for inserting data - before buffer start. - Packet rewrite string will be - rewritten backwards and may extend - back before buffer->data[0]. - Must come directly before packet data. - */ - -#define VLIB_BUFFER_PRE_DATA_SIZE (ARRAY_LEN (((vlib_buffer_t *)0)->pre_data)) + CLIB_CACHE_LINE_ALIGN_MARK(cacheline2); + u8 pre_data [VLIB_BUFFER_PRE_DATA_SIZE]; /**< Space for inserting data + before buffer start. + Packet rewrite string will be + rewritten backwards and may extend + back before buffer->data[0]. + Must come directly before packet data. + */ + u8 data[0]; /**< Packet data. Hardware DMA here */ } vlib_buffer_t; /* Must be a multiple of 64B. */ +#define VLIB_BUFFER_HDR_SIZE (sizeof(vlib_buffer_t) - VLIB_BUFFER_PRE_DATA_SIZE) + /** \brief Prefetch buffer metadata. The first 64 bytes of buffer contains most header information @@ -283,13 +295,7 @@ typedef struct { initializing static data for each packet generated. */ vlib_buffer_free_list_t * buffer_free_list_pool; #define VLIB_BUFFER_DEFAULT_FREE_LIST_INDEX (0) - -#if DPDK == 1 -/* must be same as dpdk buffer size */ -#define VLIB_BUFFER_DEFAULT_FREE_LIST_BYTES (2048) -#else -#define VLIB_BUFFER_DEFAULT_FREE_LIST_BYTES (512) -#endif +#define VLIB_BUFFER_DEFAULT_FREE_LIST_BYTES VLIB_BUFFER_DATA_SIZE /* Hash table mapping buffer size (rounded to next unit of sizeof (vlib_buffer_t)) to free list index. */ @@ -357,6 +363,11 @@ serialize_vlib_buffer_n_bytes (serialize_main_t * m) return sm->tx.n_total_data_bytes + s->current_buffer_index + vec_len (s->overflow_buffer); } +#if DPDK > 0 +#define rte_mbuf_from_vlib_buffer(x) (((struct rte_mbuf *)x) - 1) +#define vlib_buffer_from_rte_mbuf(x) ((vlib_buffer_t *)(x+1)) +#endif + /* */ diff --git a/vlib/vlib/buffer_funcs.h b/vlib/vlib/buffer_funcs.h index eea417a9..f7bdb12d 100644 --- a/vlib/vlib/buffer_funcs.h +++ b/vlib/vlib/buffer_funcs.h @@ -254,7 +254,7 @@ u8 * vlib_validate_buffers (vlib_main_t * vm, clib_error_t * vlib_buffer_pool_create(vlib_main_t * vm, unsigned num_mbufs, - unsigned mbuf_size, unsigned socket_id); + unsigned socket_id); /** \brief Allocate buffers into supplied array @@ -425,11 +425,9 @@ vlib_buffer_chain_init(vlib_buffer_t *first) first->flags &= ~VLIB_BUFFER_NEXT_PRESENT; first->flags |= VLIB_BUFFER_TOTAL_LENGTH_VALID; #if DPDK == 1 - (((struct rte_mbuf *) first) - 1)->nb_segs = 1; - (((struct rte_mbuf *) first) - 1)->next = 0; - (((struct rte_mbuf *) first) - 1)->pkt_len = 0; - (((struct rte_mbuf *) first) - 1)->data_len = 0; - (((struct rte_mbuf *) first) - 1)->data_off = RTE_PKTMBUF_HEADROOM + first->current_data; + struct rte_mbuf * mb = rte_mbuf_from_vlib_buffer(first); + rte_pktmbuf_reset(mb); + mb->data_off = VLIB_BUFFER_PRE_DATA_SIZE + first->current_data; #endif } @@ -446,11 +444,17 @@ vlib_buffer_chain_buffer(vlib_main_t *vm, next_buffer->current_length = 0; next_buffer->flags &= ~VLIB_BUFFER_NEXT_PRESENT; #if DPDK == 1 - (((struct rte_mbuf *) first) - 1)->nb_segs++; - (((struct rte_mbuf *) last) - 1)->next = (((struct rte_mbuf *) next_buffer) - 1); - (((struct rte_mbuf *) next_buffer) - 1)->data_len = 0; - (((struct rte_mbuf *) next_buffer) - 1)->data_off = RTE_PKTMBUF_HEADROOM + next_buffer->current_data; - (((struct rte_mbuf *) next_buffer) - 1)->next = 0; + struct rte_mbuf * mb; + mb = rte_mbuf_from_vlib_buffer(first); + mb->nb_segs++; + + mb = rte_mbuf_from_vlib_buffer(last); + mb->next = rte_mbuf_from_vlib_buffer(next_buffer); + + mb = rte_mbuf_from_vlib_buffer(next_buffer); + mb->data_len = 0; + mb->data_off = VLIB_BUFFER_PRE_DATA_SIZE + next_buffer->current_data; + mb->next = 0; #endif return next_buffer; } @@ -468,8 +472,10 @@ vlib_buffer_chain_increase_length(vlib_buffer_t *first, if (first != last) first->total_length_not_including_first_buffer += len; #if DPDK == 1 - (((struct rte_mbuf *) first) - 1)->pkt_len += len; - (((struct rte_mbuf *) last) - 1)->data_len += len; + struct rte_mbuf * mb_first = rte_mbuf_from_vlib_buffer(first); + struct rte_mbuf * mb_last = rte_mbuf_from_vlib_buffer(last); + mb_first->pkt_len += len; + mb_last->data_len += len; #endif } @@ -589,6 +595,11 @@ vlib_buffer_init_for_free_list (vlib_buffer_t * _dst, vlib_buffer_union_t * dst = (vlib_buffer_union_t *) _dst; vlib_buffer_union_t * src = (vlib_buffer_union_t *) &fl->buffer_init_template; + /* Make sure vlib_buffer_t is cacheline aligned and sized */ + ASSERT(STRUCT_OFFSET_OF(vlib_buffer_t, cacheline0) == 0); + ASSERT(STRUCT_OFFSET_OF(vlib_buffer_t, cacheline1) == CLIB_CACHE_LINE_BYTES); + ASSERT(STRUCT_OFFSET_OF(vlib_buffer_t, cacheline2) == CLIB_CACHE_LINE_BYTES * 2); + /* Make sure buffer template is sane. */ ASSERT (fl->index == fl->buffer_init_template.free_list_index); diff --git a/vlib/vlib/dpdk_buffer.c b/vlib/vlib/dpdk_buffer.c index 04a6447d..db1fde18 100644 --- a/vlib/vlib/dpdk_buffer.c +++ b/vlib/vlib/dpdk_buffer.c @@ -66,12 +66,10 @@ #include -phys_addr_t __attribute__ ((weak)) rte_mem_virt2phy(); -int __attribute__ ((weak)) rte_eal_has_hugepages(); -unsigned __attribute__ ((weak)) rte_socket_id(); -struct rte_mempool * __attribute__ ((weak)) rte_mempool_create(); -void __attribute__ ((weak)) rte_pktmbuf_init(); -void __attribute__ ((weak)) rte_pktmbuf_pool_init(); +#pragma weak rte_mem_virt2phy +#pragma weak rte_eal_has_hugepages +#pragma weak rte_socket_id +#pragma weak rte_pktmbuf_pool_create uword vlib_buffer_length_in_chain_slow_path (vlib_main_t * vm, vlib_buffer_t * b_first) { @@ -400,13 +398,13 @@ del_free_list (vlib_main_t * vm, vlib_buffer_free_list_t * f) for (i = 0; i < vec_len (f->unaligned_buffers); i++) { b = vlib_get_buffer (vm, f->unaligned_buffers[i]); - mb = ((struct rte_mbuf *)b)-1; + mb = rte_mbuf_from_vlib_buffer(b); ASSERT(rte_mbuf_refcnt_read(mb) == 1); rte_pktmbuf_free (mb); } for (i = 0; i < vec_len (f->aligned_buffers); i++) { b = vlib_get_buffer (vm, f->aligned_buffers[i]); - mb = ((struct rte_mbuf *)b)-1; + mb = rte_mbuf_from_vlib_buffer(b); ASSERT(rte_mbuf_refcnt_read(mb) == 1); rte_pktmbuf_free (mb); } @@ -487,7 +485,7 @@ fill_free_list (vlib_main_t * vm, mb->data_off = RTE_PKTMBUF_HEADROOM; mb->nb_segs = 1; - b = (vlib_buffer_t *)(mb+1); + b = vlib_buffer_from_rte_mbuf(mb); bi = vlib_get_buffer_index (vm, b); vec_add1_aligned (fl->aligned_buffers, bi, sizeof (vlib_copy_unit_t)); @@ -726,7 +724,7 @@ vlib_buffer_free_inline (vlib_main_t * vm, { if (PREDICT_TRUE (b->clone_count == 0)) { - mb = ((struct rte_mbuf *)b)-1; + mb = rte_mbuf_from_vlib_buffer(b); ASSERT(rte_mbuf_refcnt_read(mb) == 1); rte_pktmbuf_free (mb); } @@ -820,7 +818,7 @@ vlib_packet_template_get_packet (vlib_main_t * vm, /* Fix up mbuf header length fields */ struct rte_mbuf * mb; - mb = ((struct rte_mbuf *)b) - 1; + mb = rte_mbuf_from_vlib_buffer(b); mb->data_len = b->current_length; mb->pkt_len = b->current_length; @@ -916,22 +914,26 @@ vlib_buffer_chain_append_data_with_alloc(vlib_main_t *vm, void vlib_buffer_chain_validate (vlib_main_t * vm, vlib_buffer_t * b_first) { vlib_buffer_t *b = b_first, *prev = b_first; - struct rte_mbuf *mb_first = ((struct rte_mbuf *) b) - 1; + struct rte_mbuf *mb_prev, *mb, *mb_first; - mb_first->pkt_len = mb_first-> data_len = b_first->current_length; + mb_first = rte_mbuf_from_vlib_buffer(b_first); + + mb_first->pkt_len = mb_first->data_len = b_first->current_length; while (b->flags & VLIB_BUFFER_NEXT_PRESENT) { b = vlib_get_buffer(vm, b->next_buffer); + mb = rte_mbuf_from_vlib_buffer(b); + mb_prev = rte_mbuf_from_vlib_buffer(prev); mb_first->nb_segs++; mb_first->pkt_len += b->current_length; - (((struct rte_mbuf *) prev) - 1)->next = (((struct rte_mbuf *) b) - 1); - (((struct rte_mbuf *) b) - 1)->data_len = b->current_length; + mb_prev->next = mb; + mb->data_len = b->current_length; prev = b; } } clib_error_t * vlib_buffer_pool_create(vlib_main_t * vm, unsigned num_mbufs, - unsigned mbuf_size, unsigned socket_id) + unsigned socket_id) { vlib_buffer_main_t * bm = vm->buffer_main; vlib_physmem_main_t * vpm = &vm->physmem_main; @@ -939,7 +941,7 @@ vlib_buffer_pool_create(vlib_main_t * vm, unsigned num_mbufs, uword new_start, new_size; int i; - if (!rte_mempool_create) + if (!rte_pktmbuf_pool_create) return clib_error_return (0, "not linked with DPDK"); vec_validate_aligned(bm->pktmbuf_pools, socket_id, CLIB_CACHE_LINE_BYTES); @@ -949,12 +951,15 @@ vlib_buffer_pool_create(vlib_main_t * vm, unsigned num_mbufs, return 0; u8 * pool_name = format(0, "mbuf_pool_socket%u%c",socket_id, 0); - rmp = rte_mempool_create((char *) pool_name, - num_mbufs, mbuf_size, 512, - sizeof(struct rte_pktmbuf_pool_private), - rte_pktmbuf_pool_init, NULL, - rte_pktmbuf_init, NULL, - socket_id, 0); + + rmp = rte_pktmbuf_pool_create((char *) pool_name, /* pool name */ + num_mbufs, /* number of mbufs */ + 512, /* cache size */ + VLIB_BUFFER_HDR_SIZE, /* priv size */ + VLIB_BUFFER_PRE_DATA_SIZE + + VLIB_BUFFER_DATA_SIZE, /* dataroom size */ + socket_id); /* cpu socket */ + vec_free(pool_name); if (rmp) diff --git a/vnet/vnet/devices/af_packet/node.c b/vnet/vnet/devices/af_packet/node.c index 15a96f44..efe0e1c2 100644 --- a/vnet/vnet/devices/af_packet/node.c +++ b/vnet/vnet/devices/af_packet/node.c @@ -94,11 +94,6 @@ buffer_add_to_chain(vlib_main_t *vm, u32 bi, u32 first_bi, u32 prev_bi) vlib_buffer_t * b = vlib_get_buffer (vm, bi); vlib_buffer_t * first_b = vlib_get_buffer (vm, first_bi); vlib_buffer_t * prev_b = vlib_get_buffer (vm, prev_bi); -#if DPDK > 0 - struct rte_mbuf * mbuf = ((struct rte_mbuf *) b) - 1; - struct rte_mbuf * first_mbuf = ((struct rte_mbuf *) first_b) - 1; - struct rte_mbuf * prev_mbuf = ((struct rte_mbuf *) prev_b) - 1; -#endif /* update first buffer */ first_b->total_length_not_including_first_buffer += b->current_length; @@ -111,6 +106,9 @@ buffer_add_to_chain(vlib_main_t *vm, u32 bi, u32 first_bi, u32 prev_bi) b->next_buffer = 0; #if DPDK > 0 + struct rte_mbuf * mbuf = rte_mbuf_from_vlib_buffer(b); + struct rte_mbuf * first_mbuf = rte_mbuf_from_vlib_buffer(first_b); + struct rte_mbuf * prev_mbuf = rte_mbuf_from_vlib_buffer(prev_b); first_mbuf->nb_segs++; prev_mbuf->next = mbuf; mbuf->data_len = b->current_length; diff --git a/vnet/vnet/devices/dpdk/device.c b/vnet/vnet/devices/dpdk/device.c index 02703cc5..dcf95803 100644 --- a/vnet/vnet/devices/dpdk/device.c +++ b/vnet/vnet/devices/dpdk/device.c @@ -87,7 +87,7 @@ static struct rte_mbuf * dpdk_replicate_packet_mb (vlib_buffer_t * b) unsigned socket_id = rte_socket_id(); ASSERT (bm->pktmbuf_pools[socket_id]); - pkt_mb = ((struct rte_mbuf *)b)-1; + pkt_mb = rte_mbuf_from_vlib_buffer(b); nb_segs = pkt_mb->nb_segs; for (nb_segs_left = nb_segs; nb_segs_left; nb_segs_left--) { @@ -159,7 +159,7 @@ dpdk_tx_trace_buffer (dpdk_main_t * dm, dpdk_tx_dma_trace_t * t0; struct rte_mbuf * mb; - mb = ((struct rte_mbuf *)buffer)-1; + mb = rte_mbuf_from_vlib_buffer(buffer); t0 = vlib_add_trace (vm, node, buffer, sizeof (t0[0])); t0->queue_index = queue_id; @@ -541,7 +541,7 @@ dpdk_interface_tx (vlib_main_t * vm, { u32 bi0 = from[n_packets]; vlib_buffer_t *b0 = vlib_get_buffer (vm, bi0); - struct rte_mbuf *mb0 = ((struct rte_mbuf *)b0) - 1; + struct rte_mbuf *mb0 = rte_mbuf_from_vlib_buffer(b0); rte_pktmbuf_free (mb0); } return n_on_ring; @@ -584,9 +584,9 @@ dpdk_interface_tx (vlib_main_t * vm, pref0 = vlib_get_buffer (vm, pi0); pref1 = vlib_get_buffer (vm, pi1); - prefmb0 = ((struct rte_mbuf *)pref0) - 1; - prefmb1 = ((struct rte_mbuf *)pref1) - 1; - + prefmb0 = rte_mbuf_from_vlib_buffer(pref0); + prefmb1 = rte_mbuf_from_vlib_buffer(pref1); + CLIB_PREFETCH(prefmb0, CLIB_CACHE_LINE_BYTES, LOAD); CLIB_PREFETCH(pref0, CLIB_CACHE_LINE_BYTES, LOAD); CLIB_PREFETCH(prefmb1, CLIB_CACHE_LINE_BYTES, LOAD); @@ -599,8 +599,8 @@ dpdk_interface_tx (vlib_main_t * vm, b0 = vlib_get_buffer (vm, bi0); b1 = vlib_get_buffer (vm, bi1); - mb0 = ((struct rte_mbuf *)b0) - 1; - mb1 = ((struct rte_mbuf *)b1) - 1; + mb0 = rte_mbuf_from_vlib_buffer(b0); + mb1 = rte_mbuf_from_vlib_buffer(b1); any_clone = b0->clone_count | b1->clone_count; if (PREDICT_FALSE(any_clone != 0)) @@ -701,7 +701,7 @@ dpdk_interface_tx (vlib_main_t * vm, b0 = vlib_get_buffer (vm, bi0); - mb0 = ((struct rte_mbuf *)b0) - 1; + mb0 = rte_mbuf_from_vlib_buffer(b0); if (PREDICT_FALSE(b0->clone_count != 0)) { struct rte_mbuf * mb0_new = dpdk_replicate_packet_mb (b0); @@ -921,7 +921,7 @@ dpdk_interface_admin_up_down (vnet_main_t * vnm, u32 hw_if_index, u32 flags) vlib_buffer_main_t * bm = vm->buffer_main; memset(&conf, 0, sizeof(conf)); snprintf(conf.name, RTE_KNI_NAMESIZE, "vpp%u", xd->kni_port_id); - conf.mbuf_size = MBUF_SIZE; + conf.mbuf_size = VLIB_BUFFER_DATA_SIZE; memset(&ops, 0, sizeof(ops)); ops.port_id = xd->kni_port_id; ops.change_mtu = kni_change_mtu; diff --git a/vnet/vnet/devices/dpdk/dpdk.h b/vnet/vnet/devices/dpdk/dpdk.h index 656f39ea..14f7b3e8 100644 --- a/vnet/vnet/devices/dpdk/dpdk.h +++ b/vnet/vnet/devices/dpdk/dpdk.h @@ -62,7 +62,6 @@ #define always_inline static inline __attribute__ ((__always_inline__)) #endif -#define MBUF_SIZE (2048 + sizeof(struct rte_mbuf) + RTE_PKTMBUF_HEADROOM) #define NB_MBUF (32<<10) extern vnet_device_class_t dpdk_device_class; diff --git a/vnet/vnet/devices/dpdk/init.c b/vnet/vnet/devices/dpdk/init.c index 8fe95ae5..8bb253a3 100644 --- a/vnet/vnet/devices/dpdk/init.c +++ b/vnet/vnet/devices/dpdk/init.c @@ -1405,13 +1405,13 @@ dpdk_config (vlib_main_t * vm, unformat_input_t * input) rte_dump_physmem_layout(stdout); /* main thread 1st */ - error = vlib_buffer_pool_create(vm, dm->num_mbufs, MBUF_SIZE, rte_socket_id()); + error = vlib_buffer_pool_create(vm, dm->num_mbufs, rte_socket_id()); if (error) return error; for (i = 0; i < RTE_MAX_LCORE; i++) { - error = vlib_buffer_pool_create(vm, dm->num_mbufs, MBUF_SIZE, + error = vlib_buffer_pool_create(vm, dm->num_mbufs, rte_lcore_to_socket_id(i)); if (error) return error; diff --git a/vnet/vnet/devices/dpdk/node.c b/vnet/vnet/devices/dpdk/node.c index 72d564ba..4f5a84ae 100644 --- a/vnet/vnet/devices/dpdk/node.c +++ b/vnet/vnet/devices/dpdk/node.c @@ -366,7 +366,7 @@ void dpdk_rx_trace (dpdk_main_t * dm, n_left -= 1; b0 = vlib_get_buffer (vm, bi0); - mb = ((struct rte_mbuf *)b0) - 1; + mb = rte_mbuf_from_vlib_buffer(b0); dpdk_rx_next_and_error_from_mb_flags_x1 (xd, mb, b0, &next0, &error0); vlib_trace_buffer (vm, node, next0, b0, /* follow_chain */ 0); @@ -602,20 +602,20 @@ static inline u32 dpdk_device_input ( dpdk_main_t * dm, if (PREDICT_TRUE(n_buffers > 2)) { struct rte_mbuf *pfmb = xd->rx_vectors[queue_id][mb_index+2]; - vlib_buffer_t *bp = (vlib_buffer_t *)(pfmb+1); + vlib_buffer_t *bp = vlib_buffer_from_rte_mbuf(pfmb); CLIB_PREFETCH (pfmb, CLIB_CACHE_LINE_BYTES, STORE); CLIB_PREFETCH (bp, CLIB_CACHE_LINE_BYTES, STORE); } ASSERT(mb); - b0 = (vlib_buffer_t *)(mb+1); + b0 = vlib_buffer_from_rte_mbuf(mb); /* check whether EFD is looking for packets to discard */ if (PREDICT_FALSE(efd_discard_burst)) { vlib_thread_main_t * tm = vlib_get_thread_main(); - + if (PREDICT_TRUE(cntr_type = is_efd_discardable(tm, b0, mb))) { rte_pktmbuf_free(mb); @@ -633,7 +633,7 @@ static inline u32 dpdk_device_input ( dpdk_main_t * dm, if (PREDICT_FALSE(mb->nb_segs > 1)) { struct rte_mbuf *pfmb = mb->next; - vlib_buffer_t *bp = (vlib_buffer_t *)(pfmb+1); + vlib_buffer_t *bp = vlib_buffer_from_rte_mbuf(pfmb); CLIB_PREFETCH (pfmb, CLIB_CACHE_LINE_BYTES, LOAD); CLIB_PREFETCH (bp, CLIB_CACHE_LINE_BYTES, STORE); b_chain = b0; @@ -693,7 +693,7 @@ static inline u32 dpdk_device_input ( dpdk_main_t * dm, { ASSERT(mb_seg != 0); - b_seg = (vlib_buffer_t *)(mb_seg+1); + b_seg = vlib_buffer_from_rte_mbuf(mb_seg); vlib_buffer_init_for_free_list (b_seg, fl); b_seg->clone_count = 0; @@ -1280,13 +1280,13 @@ void dpdk_io_thread (vlib_worker_thread_t * w, if (PREDICT_TRUE(n_buffers > 1)) { struct rte_mbuf *pfmb = xd->rx_vectors[queue_id][mb_index+2]; - vlib_buffer_t *bp = (vlib_buffer_t *)(pfmb+1); + vlib_buffer_t *bp = vlib_buffer_from_rte_mbuf(pfmb); CLIB_PREFETCH (pfmb, CLIB_CACHE_LINE_BYTES, LOAD); CLIB_PREFETCH (bp, CLIB_CACHE_LINE_BYTES, STORE); CLIB_PREFETCH (bp->data, CLIB_CACHE_LINE_BYTES, LOAD); } - b0 = (vlib_buffer_t *)(mb+1); + b0 = vlib_buffer_from_rte_mbuf(mb); /* check whether EFD is looking for packets to discard */ if (PREDICT_FALSE(efd_discard_burst)) @@ -1310,7 +1310,7 @@ void dpdk_io_thread (vlib_worker_thread_t * w, if (PREDICT_FALSE(mb->nb_segs > 1)) { struct rte_mbuf *pfmb = mb->next; - vlib_buffer_t *bp = (vlib_buffer_t *)(pfmb+1); + vlib_buffer_t *bp = vlib_buffer_from_rte_mbuf(pfmb); CLIB_PREFETCH (pfmb, CLIB_CACHE_LINE_BYTES, LOAD); CLIB_PREFETCH (bp, CLIB_CACHE_LINE_BYTES, STORE); b_chain = b0; @@ -1361,7 +1361,7 @@ void dpdk_io_thread (vlib_worker_thread_t * w, { ASSERT(mb_seg != 0); - b_seg = (vlib_buffer_t *)(mb_seg+1); + b_seg = vlib_buffer_from_rte_mbuf(mb_seg); vlib_buffer_init_for_free_list (b_seg, fl); b_seg->clone_count = 0; @@ -1681,14 +1681,14 @@ dpdk_io_input (vlib_main_t * vm, if (PREDICT_TRUE(n_buffers > 1)) { struct rte_mbuf *pfmb = xd->rx_vectors[queue_id][mb_index+2]; - vlib_buffer_t *bp = (vlib_buffer_t *)(pfmb+1); + vlib_buffer_t *bp = vlib_buffer_from_rte_mbuf(pfmb); CLIB_PREFETCH (pfmb, CLIB_CACHE_LINE_BYTES, LOAD); CLIB_PREFETCH (bp, CLIB_CACHE_LINE_BYTES, STORE); CLIB_PREFETCH (bp->data, CLIB_CACHE_LINE_BYTES, LOAD); } - - b0 = (vlib_buffer_t *)(mb+1); - + + b0 = vlib_buffer_from_rte_mbuf(mb); + /* check whether EFD is looking for packets to discard */ if (PREDICT_FALSE(efd_discard_burst)) { @@ -1711,7 +1711,7 @@ dpdk_io_input (vlib_main_t * vm, if (PREDICT_FALSE(mb->nb_segs > 1)) { struct rte_mbuf *pfmb = mb->next; - vlib_buffer_t *bp = (vlib_buffer_t *)(pfmb+1); + vlib_buffer_t *bp = vlib_buffer_from_rte_mbuf(pfmb); CLIB_PREFETCH (pfmb, CLIB_CACHE_LINE_BYTES, LOAD); CLIB_PREFETCH (bp, CLIB_CACHE_LINE_BYTES, STORE); b_chain = b0; @@ -1762,7 +1762,7 @@ dpdk_io_input (vlib_main_t * vm, { ASSERT(mb_seg != 0); - b_seg = (vlib_buffer_t *)(mb_seg+1); + b_seg = vlib_buffer_from_rte_mbuf(mb_seg); vlib_buffer_init_for_free_list (b_seg, fl); b_seg->clone_count = 0; diff --git a/vnet/vnet/devices/ssvm/ssvm_eth.h b/vnet/vnet/devices/ssvm/ssvm_eth.h index 70d895b9..8f1f8896 100644 --- a/vnet/vnet/devices/ssvm/ssvm_eth.h +++ b/vnet/vnet/devices/ssvm/ssvm_eth.h @@ -35,7 +35,7 @@ extern vnet_device_class_t ssvm_eth_device_class; extern vlib_node_registration_t ssvm_eth_input_node; #define SSVM_BUFFER_SIZE \ - (VLIB_BUFFER_DEFAULT_FREE_LIST_BYTES + VLIB_BUFFER_PRE_DATA_SIZE) + (VLIB_BUFFER_DATA_SIZE + VLIB_BUFFER_PRE_DATA_SIZE) #define SSVM_PACKET_TYPE 1 typedef struct { diff --git a/vnet/vnet/dpdk_replication.h b/vnet/vnet/dpdk_replication.h index b25558f9..6259c449 100644 --- a/vnet/vnet/dpdk_replication.h +++ b/vnet/vnet/dpdk_replication.h @@ -49,7 +49,7 @@ vlib_dpdk_clone_buffer (vlib_main_t * vm, vlib_buffer_t * b) return 0; src_buf = b; - rv = dst_buf = (vlib_buffer_t *)(rte_mbufs[0] + 1); + rv = dst_buf = vlib_buffer_from_rte_mbuf(rte_mbufs[0]); vlib_buffer_init_for_free_list (dst_buf, fl); copy_src = b->data + src_buf->current_data; copy_dst = dst_buf->data + src_buf->current_data; @@ -75,7 +75,7 @@ vlib_dpdk_clone_buffer (vlib_main_t * vm, vlib_buffer_t * b) if (i < new_buffers_needed - 1) { src_buf = vlib_get_buffer (vm, src_buf->next_buffer); - dst_buf = (vlib_buffer_t *)(rte_mbufs[i+1] + 1); + dst_buf = vlib_buffer_from_rte_mbuf(rte_mbufs[i+1]); vlib_buffer_init_for_free_list (dst_buf, fl); copy_src = src_buf->data; copy_dst = dst_buf->data; @@ -87,7 +87,7 @@ vlib_dpdk_clone_buffer (vlib_main_t * vm, vlib_buffer_t * b) if (rte_mempool_get_bulk (rmp, (void **)rte_mbufs, 1) < 0) return 0; - rv = (vlib_buffer_t *)(rte_mbufs[0] + 1); + rv = vlib_buffer_from_rte_mbuf(rte_mbufs[0]); vlib_buffer_init_for_free_list (rv, fl); memcpy(rv->data + b->current_data, b->data + b->current_data, diff --git a/vnet/vnet/ip/ip.h b/vnet/vnet/ip/ip.h index 76a2552f..de46ad38 100644 --- a/vnet/vnet/ip/ip.h +++ b/vnet/vnet/ip/ip.h @@ -162,7 +162,7 @@ ip_incremental_checksum_buffer (vlib_main_t * vm, vlib_buffer_t * first_buffer, #if DPDK > 0 { u32 n_bytes_left = n_bytes_to_checksum; - struct rte_mbuf * mb = ((struct rte_mbuf *)first_buffer)-1; + struct rte_mbuf * mb = rte_mbuf_from_vlib_buffer(first_buffer); u8 nb_segs = mb->nb_segs; ASSERT(mb->data_len >= first_buffer_offset); void * h; diff --git a/vnet/vnet/ip/ip6_forward.c b/vnet/vnet/ip/ip6_forward.c index 1d0e21e5..a478bab5 100644 --- a/vnet/vnet/ip/ip6_forward.c +++ b/vnet/vnet/ip/ip6_forward.c @@ -1445,7 +1445,7 @@ u16 ip6_tcp_udp_icmp_compute_checksum (vlib_main_t * vm, vlib_buffer_t * p0, ip6 #if DPDK > 0 if (p0) { - struct rte_mbuf *mb = ((struct rte_mbuf *)p0)-1; + struct rte_mbuf *mb = rte_mbuf_from_vlib_buffer(p0); u8 nb_segs = mb->nb_segs; n_this_buffer = (p0->current_length > headers_size ? diff --git a/vnet/vnet/pg/input.c b/vnet/vnet/pg/input.c index 4ec61ca7..38402c2e 100644 --- a/vnet/vnet/pg/input.c +++ b/vnet/vnet/pg/input.c @@ -61,7 +61,7 @@ pg_set_mbuf_metadata (pg_main_t * pg, u32 * buffers, u32 n_alloc) for (i = 0; i < n_alloc; i++) { b = vlib_get_buffer (vm, buffers[i]); - mb = ((struct rte_mbuf *)b) - 1; + mb = rte_mbuf_from_vlib_buffer(b); delta = vlib_buffer_length_in_chain (vm, b) - (i16) mb->pkt_len; new_data_len = (u16)((i16) mb->data_len + delta); @@ -1473,9 +1473,9 @@ pg_stream_fill (pg_main_t * pg, pg_stream_t * s, u32 n_buffers) ({ vlib_buffer_t * b; struct rte_mbuf *mb; - + b = vlib_get_buffer(vm, bi0[0]); - mb = (struct rte_mbuf *)b - 1; + mb = rte_mbuf_from_vlib_buffer(b); ASSERT(rte_mbuf_refcnt_read(mb) == 1); })); } diff --git a/vnet/vnet/unix/tapcli.c b/vnet/vnet/unix/tapcli.c index 5b0ac937..7776b9ee 100644 --- a/vnet/vnet/unix/tapcli.c +++ b/vnet/vnet/unix/tapcli.c @@ -220,7 +220,7 @@ static uword tapcli_rx_iface(vlib_main_t * vm, tapcli_interface_t * ti) { tapcli_main_t * tm = &tapcli_main; - const uword buffer_size = VLIB_BUFFER_DEFAULT_FREE_LIST_BYTES; + const uword buffer_size = VLIB_BUFFER_DATA_SIZE; u32 n_trace = vlib_get_trace_count (vm, node); u8 set_trace = 0; @@ -434,7 +434,7 @@ static clib_error_t * tapcli_config (vlib_main_t * vm, unformat_input_t * input) { tapcli_main_t *tm = &tapcli_main; - const uword buffer_size = VLIB_BUFFER_DEFAULT_FREE_LIST_BYTES; + const uword buffer_size = VLIB_BUFFER_DATA_SIZE; while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) { diff --git a/vnet/vnet/unix/tuntap.c b/vnet/vnet/unix/tuntap.c index 77c60fd6..7ea0b703 100644 --- a/vnet/vnet/unix/tuntap.c +++ b/vnet/vnet/unix/tuntap.c @@ -200,12 +200,11 @@ tuntap_rx (vlib_main_t * vm, tuntap_main_t * tm = &tuntap_main; vlib_buffer_t * b; u32 bi; + const uword buffer_size = VLIB_BUFFER_DATA_SIZE; #if DPDK == 0 - const uword buffer_size = VLIB_BUFFER_DEFAULT_FREE_LIST_BYTES; u32 free_list_index = VLIB_BUFFER_DEFAULT_FREE_LIST_INDEX; #else dpdk_main_t * dm = &dpdk_main; - const uword buffer_size = MBUF_SIZE; u32 free_list_index = dm->vlib_buffer_free_list_index; #endif @@ -262,7 +261,7 @@ tuntap_rx (vlib_main_t * vm, #endif b = vlib_get_buffer (vm, tm->rx_buffers[i_rx]); #if DPDK == 1 - mb = (((struct rte_mbuf *)b)-1); + mb = rte_mbuf_from_vlib_buffer(b); #endif b->flags = 0; b->current_data = 0; @@ -445,12 +444,7 @@ tuntap_config (vlib_main_t * vm, unformat_input_t * input) u8 * name; int flags = IFF_TUN | IFF_NO_PI; int is_enabled = 0, is_ether = 0, have_normal_interface = 0; -#if DPDK == 0 - const uword buffer_size = VLIB_BUFFER_DEFAULT_FREE_LIST_BYTES; -#else - const uword buffer_size = MBUF_SIZE; -#endif - + const uword buffer_size = VLIB_BUFFER_DATA_SIZE; while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) { -- cgit 1.2.3-korg From 28e3db9dd617324a3196f369788d62cc72b5903b Mon Sep 17 00:00:00 2001 From: Damjan Marion Date: Fri, 1 Apr 2016 12:35:17 +0200 Subject: Add options to link with external DPDK tree By uncommenting following lines in the build-data/platforms/vpp.mk VPP links nicely with packaged DPDK 2.2 distributed with Ubuntu 16.04 LTS. vpp_uses_external_dpdk = yes vpp_dpdk_inc_dir = /usr/include/dpdk vpp_dpdk_lib_dir = /usr/lib vpp_dpdk_shared_lib = yes Change-Id: Id5b7d95bac6aa60341933b92e86d949a9abf1a5d Signed-off-by: Damjan Marion --- build-data/packages/sample-plugin.mk | 5 +++++ build-data/packages/vlib.mk | 7 ++++++- build-data/packages/vnet.mk | 5 +++++ build-data/packages/vpp-api-test.mk | 5 +++++ build-data/packages/vpp.mk | 11 ++++++++++- build-data/platforms/vpp.mk | 7 ++++++- 6 files changed, 37 insertions(+), 3 deletions(-) (limited to 'build-data/platforms/vpp.mk') diff --git a/build-data/packages/sample-plugin.mk b/build-data/packages/sample-plugin.mk index 58d46325..047a26f5 100644 --- a/build-data/packages/sample-plugin.mk +++ b/build-data/packages/sample-plugin.mk @@ -36,7 +36,12 @@ sample-plugin_image_include = echo $(arch_lib_dir)/vlib_plugins ifneq ($($(PLATFORM)_uses_dpdk),no) sample-plugin_configure_args = --with-dpdk +ifeq ($($(PLATFORM)_uses_external_dpdk),yes) +sample-plugin_CPPFLAGS += -I$($(PLATFORM)_dpdk_inc_dir) +sample-plugin_LDFLAGS += -L$($(PLATFORM)_dpdk_lib_dir) +else sample-plugin_configure_depend += dpdk-install sample-plugin_CPPFLAGS += $(call installed_includes_fn, dpdk) sample-plugin_LDFLAGS += $(call installed_libs_fn, dpdk) endif +endif diff --git a/build-data/packages/vlib.mk b/build-data/packages/vlib.mk index 9c361282..2172708d 100644 --- a/build-data/packages/vlib.mk +++ b/build-data/packages/vlib.mk @@ -4,8 +4,13 @@ vlib_CPPFLAGS = $(call installed_includes_fn, vppinfra) vlib_LDFLAGS = $(call installed_libs_fn, vppinfra) ifneq ($($(PLATFORM)_uses_dpdk),no) -vlib_configure_depend += dpdk-install vlib_configure_args += --with-dpdk +ifeq ($($(PLATFORM)_uses_external_dpdk),yes) +vlib_CPPFLAGS += -I$($(PLATFORM)_dpdk_inc_dir) +vlib_LDFLAGS += -L$($(PLATFORM)_dpdk_lib_dir) +else +vlib_configure_depend += dpdk-install vlib_CPPFLAGS += $(call installed_includes_fn, dpdk) vlib_LDFLAGS += $(call installed_libs_fn, dpdk) endif +endif diff --git a/build-data/packages/vnet.mk b/build-data/packages/vnet.mk index 0486b4e8..2ff9034a 100644 --- a/build-data/packages/vnet.mk +++ b/build-data/packages/vnet.mk @@ -22,7 +22,12 @@ vnet_LDFLAGS = $(call installed_libs_fn, \ vnet_configure_args += $(vnet_configure_args_$(PLATFORM)) ifneq ($($(PLATFORM)_uses_dpdk),no) +ifeq ($($(PLATFORM)_uses_external_dpdk),yes) +vnet_CPPFLAGS += -I$($(PLATFORM)_dpdk_inc_dir) +vnet_LDFLAGS += -L$($(PLATFORM)_dpdk_lib_dir) +else vnet_configure_depend += dpdk-install vnet_CPPFLAGS += $(call installed_includes_fn, dpdk) vnet_LDFLAGS += $(call installed_libs_fn, dpdk) endif +endif diff --git a/build-data/packages/vpp-api-test.mk b/build-data/packages/vpp-api-test.mk index e26c2e76..38edb5bc 100644 --- a/build-data/packages/vpp-api-test.mk +++ b/build-data/packages/vpp-api-test.mk @@ -24,7 +24,12 @@ vpp-api-test_LDFLAGS = $(call installed_libs_fn, \ ifneq ($($(PLATFORM)_uses_dpdk),no) vpp-api-test_configure_args = --with-dpdk +ifeq ($($(PLATFORM)_uses_external_dpdk),yes) +vpp-api-test_CPPFLAGS += -I$($(PLATFORM)_dpdk_inc_dir) +vpp-api-test_LDFLAGS += -L$($(PLATFORM)_dpdk_lib_dir) +else vpp-api-test_configure_depend += dpdk-install vpp-api-test_CPPFLAGS += $(call installed_includes_fn, dpdk) vpp-api-test_LDFLAGS += $(call installed_libs_fn, dpdk) endif +endif diff --git a/build-data/packages/vpp.mk b/build-data/packages/vpp.mk index 9ccf6901..f96235f4 100644 --- a/build-data/packages/vpp.mk +++ b/build-data/packages/vpp.mk @@ -6,7 +6,11 @@ vpp_configure_depend = \ vnet-install \ # -vpp_configure_args = +ifeq ($($(PLATFORM)_dpdk_shared_lib),yes) +vpp_configure_args = --enable-dpdk-shared +else +vpp_configure_args = +endif # Platform dependent configure flags vpp_configure_args += $(vpp_configure_args_$(PLATFORM)) @@ -29,7 +33,12 @@ vpp_LDFLAGS = $(call installed_libs_fn, \ vnet) ifneq ($($(PLATFORM)_uses_dpdk),no) +ifeq ($($(PLATFORM)_uses_external_dpdk),yes) +vpp_CPPFLAGS += -I$($(PLATFORM)_dpdk_inc_dir) +vpp_LDFLAGS += -L$($(PLATFORM)_dpdk_lib_dir) +else vpp_configure_depend += dpdk-install vpp_CPPFLAGS += $(call installed_includes_fn, dpdk) vpp_LDFLAGS += $(call installed_libs_fn, dpdk) endif +endif diff --git a/build-data/platforms/vpp.mk b/build-data/platforms/vpp.mk index 50c85dcc..9b4a78c8 100644 --- a/build-data/platforms/vpp.mk +++ b/build-data/platforms/vpp.mk @@ -17,7 +17,7 @@ vpp_native_tools = vppapigen vpp_uses_dpdk = yes -vpp_root_packages = vpp vlib vlib-api vnet svm dpdk vpp-api-test \ +vpp_root_packages = vpp vlib vlib-api vnet svm vpp-api-test \ vpp-japi gmod vpp_configure_args_vpp = --with-dpdk @@ -26,6 +26,11 @@ vnet_configure_args_vpp = --with-dpdk # Set these parameters carefully. The vlib_buffer_t is 128 bytes, i.e. vlib_configure_args_vpp = --with-pre-data=128 +# DPDK configuration parameters +# vpp_uses_external_dpdk = yes +# vpp_dpdk_inc_dir = /usr/include/dpdk +# vpp_dpdk_lib_dir = /usr/lib +# vpp_dpdk_shared_lib = yes vpp_debug_TAG_CFLAGS = -g -O0 -DCLIB_DEBUG -DFORTIFY_SOURCE=2 -march=$(MARCH) \ -fstack-protector-all -fPIC -Werror -- cgit 1.2.3-korg From c47e9796746f96f1f8f08fb95c98f5bf632705f4 Mon Sep 17 00:00:00 2001 From: Damjan Marion Date: Mon, 11 Apr 2016 13:34:36 +0200 Subject: Add configure option to enable building unit tests Same template should be used for other libs... Change-Id: Icc771cb6b243d215f30fb51c0dbc028e497a74c6 Signed-off-by: Damjan Marion --- build-data/packages/vppinfra.mk | 5 ++++- build-data/platforms/vpp.mk | 3 +++ vppinfra/Makefile.am | 6 +++++- vppinfra/configure.ac | 7 +++++++ 4 files changed, 19 insertions(+), 2 deletions(-) (limited to 'build-data/platforms/vpp.mk') diff --git a/build-data/packages/vppinfra.mk b/build-data/packages/vppinfra.mk index 92059877..6ca6eb24 100644 --- a/build-data/packages/vppinfra.mk +++ b/build-data/packages/vppinfra.mk @@ -1,2 +1,5 @@ -# nothing + +ifeq ($($(PLATFORM)_enable_tests),yes) +vppinfra_configure_args += --enable-tests +endif diff --git a/build-data/platforms/vpp.mk b/build-data/platforms/vpp.mk index 9b4a78c8..c3c18aeb 100644 --- a/build-data/platforms/vpp.mk +++ b/build-data/platforms/vpp.mk @@ -17,6 +17,9 @@ vpp_native_tools = vppapigen vpp_uses_dpdk = yes +# Uncoment to enable building unit tests +# vpp_enable_tests = yes + vpp_root_packages = vpp vlib vlib-api vnet svm vpp-api-test \ vpp-japi gmod diff --git a/vppinfra/Makefile.am b/vppinfra/Makefile.am index 3a400163..adcd32cc 100644 --- a/vppinfra/Makefile.am +++ b/vppinfra/Makefile.am @@ -20,7 +20,10 @@ endif lib_LIBRARIES = -TESTS = test_bihash_template \ +TESTS = + +if ENABLE_TESTS +TESTS += test_bihash_template \ test_elog \ test_elf \ test_fifo \ @@ -44,6 +47,7 @@ TESTS = test_bihash_template \ test_timing_wheel \ test_vec \ test_zvec +endif noinst_PROGRAMS = $(TESTS) check_PROGRAMS = $(TESTS) diff --git a/vppinfra/configure.ac b/vppinfra/configure.ac index d0b3a0c0..712186af 100644 --- a/vppinfra/configure.ac +++ b/vppinfra/configure.ac @@ -31,6 +31,13 @@ AC_ARG_WITH(ldflags, ###################################################################### +AC_ARG_ENABLE(tests, + AC_HELP_STRING([--enable-tests],[Enable unit tests]), + [enable_tests=1], + [enable_tests=0]) + +AM_CONDITIONAL(ENABLE_TESTS, test "$enable_tests" = "1") + AC_ARG_WITH(unix, AC_HELP_STRING([--with-unix],[Compile unix version of clib]), [], -- cgit 1.2.3-korg From ec177abc1aa2811c1c69f9b37b76efb66a427ad2 Mon Sep 17 00:00:00 2001 From: Dave Barach Date: Mon, 18 Apr 2016 17:10:18 -0400 Subject: Add TAG=vpp_gcov which compiles vpp to produce .gcda files Change-Id: Ib6a0940e08f9e0983f3ec70f9e8488c2185ca4da Signed-off-by: Dave Barach --- build-data/platforms/vpp.mk | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'build-data/platforms/vpp.mk') diff --git a/build-data/platforms/vpp.mk b/build-data/platforms/vpp.mk index c3c18aeb..04a697d3 100644 --- a/build-data/platforms/vpp.mk +++ b/build-data/platforms/vpp.mk @@ -44,3 +44,8 @@ vpp_TAG_CFLAGS = -g -O2 -DFORTIFY_SOURCE=2 -march=$(MARCH) \ -fstack-protector -fPIC -Werror vpp_TAG_LDFLAGS = -g -O2 -DFORTIFY_SOURCE=2 -march=$(MARCH) \ -fstack-protector -fPIC -Werror + +vpp_gcov_TAG_CFLAGS = -g -O0 -DCLIB_DEBUG -march=$(MARCH) \ + -fPIC -Werror -fprofile-arcs -ftest-coverage +vpp_gcov_TAG_LDFLAGS = -g -O0 -DCLIB_DEBUG -march=$(MARCH) \ + -fPIC -Werror -coverage -- cgit 1.2.3-korg From 6855f6cdfee8c479f1e0ae440ce87a91ff41a708 Mon Sep 17 00:00:00 2001 From: Ole Troan Date: Sat, 9 Apr 2016 03:16:30 +0200 Subject: Python-API: Inital commit of Python bindings for the VPP API. See: https://wiki.fd.io/view/VPP/Python_API Change-Id: If135fc32208c7031787e1935b399d930e0e1ea1f Signed-off-by: Ole Troan --- Makefile | 2 +- build-data/packages/vpp-api.mk | 23 + build-data/packages/vpp-japi.mk | 23 - build-data/platforms/virl.mk | 2 +- build-data/platforms/vpp.mk | 2 +- build-data/platforms/vpp_lite.mk | 2 +- vlib-api/vlibmemory/api.h | 7 + vlib-api/vlibmemory/memory_shared.c | 14 +- vnet/vnet/map/examples/test_map.py | 141 + vpp-api/Makefile.am | 2 + vpp-api/configure.ac | 15 + vpp-api/java/Makefile.am | 93 + vpp-api/java/configure.ac | 19 + .../japi/org/openvpp/vppjapi/vppApiCallbacks.java | 35 + .../openvpp/vppjapi/vppBridgeDomainDetails.java | 30 + .../vppjapi/vppBridgeDomainInterfaceDetails.java | 21 + vpp-api/java/japi/org/openvpp/vppjapi/vppConn.java | 237 + .../japi/org/openvpp/vppjapi/vppIPv4Address.java | 26 + .../japi/org/openvpp/vppjapi/vppIPv6Address.java | 27 + .../org/openvpp/vppjapi/vppInterfaceCounters.java | 77 + .../org/openvpp/vppjapi/vppInterfaceDetails.java | 71 + .../java/japi/org/openvpp/vppjapi/vppL2Fib.java | 35 + .../java/japi/org/openvpp/vppjapi/vppVersion.java | 31 + .../org/openvpp/vppjapi/vppVxlanTunnelDetails.java | 33 + vpp-api/java/japi/test/demo.java | 170 + vpp-api/java/japi/test/vppApi.java | 52 + vpp-api/java/japi/vppjni.c | 1900 ++++ vpp-api/java/japi/vppjni.h | 308 + vpp-api/java/japi/vppjni_bridge_domain.h | 510 + vpp-api/java/japi/vppjni_env.c | 111 + vpp-api/java/japi/vppjni_env.h | 118 + vpp-api/java/m4/ax_check_java_home.m4 | 80 + vpp-api/java/m4/ax_check_java_plugin.m4 | 101 + vpp-api/java/m4/ax_java_check_class.m4 | 85 + vpp-api/java/m4/ax_java_options.m4 | 48 + vpp-api/java/m4/ax_libgcj_jar.m4 | 83 + vpp-api/java/m4/ax_prog_jar.m4 | 49 + vpp-api/java/m4/ax_prog_java.m4 | 115 + vpp-api/java/m4/ax_prog_java_cc.m4 | 104 + vpp-api/java/m4/ax_prog_java_works.m4 | 134 + vpp-api/java/m4/ax_prog_javac.m4 | 79 + vpp-api/java/m4/ax_prog_javac_works.m4 | 72 + vpp-api/java/m4/ax_prog_javadoc.m4 | 50 + vpp-api/java/m4/ax_prog_javah.m4 | 64 + vpp-api/java/m4/ax_try_compile_java.m4 | 55 + vpp-api/java/m4/ax_try_run_java.m4 | 56 + vpp-api/python/Makefile.am | 49 + vpp-api/python/README.rst | 0 vpp-api/python/pneum/api-gen.py | 337 + vpp-api/python/pneum/pneum.c | 239 + vpp-api/python/pneum/pneum.h | 24 + vpp-api/python/pneum/test_pneum.c | 136 + vpp-api/python/setup.py | 21 + vpp-api/python/tests/test_papi.py | 125 + vpp-api/python/vpp_papi/__init__.py | 2 + vpp-api/python/vpp_papi/pneum_wrap.c | 120 + vpp-japi/Makefile.am | 93 - vpp-japi/configure.ac | 19 - .../japi/org/openvpp/vppjapi/vppApiCallbacks.java | 35 - .../openvpp/vppjapi/vppBridgeDomainDetails.java | 30 - .../vppjapi/vppBridgeDomainInterfaceDetails.java | 21 - vpp-japi/japi/org/openvpp/vppjapi/vppConn.java | 237 - .../japi/org/openvpp/vppjapi/vppIPv4Address.java | 26 - .../japi/org/openvpp/vppjapi/vppIPv6Address.java | 27 - .../org/openvpp/vppjapi/vppInterfaceCounters.java | 77 - .../org/openvpp/vppjapi/vppInterfaceDetails.java | 71 - vpp-japi/japi/org/openvpp/vppjapi/vppL2Fib.java | 35 - vpp-japi/japi/org/openvpp/vppjapi/vppVersion.java | 31 - .../org/openvpp/vppjapi/vppVxlanTunnelDetails.java | 33 - vpp-japi/japi/test/demo.java | 170 - vpp-japi/japi/test/vppApi.java | 52 - vpp-japi/japi/vppjni.c | 1900 ---- vpp-japi/japi/vppjni.h | 308 - vpp-japi/japi/vppjni_bridge_domain.h | 510 - vpp-japi/japi/vppjni_env.c | 111 - vpp-japi/japi/vppjni_env.h | 118 - vpp-japi/libtool | 10083 ------------------- vpp-japi/m4/ax_check_java_home.m4 | 80 - vpp-japi/m4/ax_check_java_plugin.m4 | 101 - vpp-japi/m4/ax_java_check_class.m4 | 85 - vpp-japi/m4/ax_java_options.m4 | 48 - vpp-japi/m4/ax_libgcj_jar.m4 | 83 - vpp-japi/m4/ax_prog_jar.m4 | 49 - vpp-japi/m4/ax_prog_java.m4 | 115 - vpp-japi/m4/ax_prog_java_cc.m4 | 104 - vpp-japi/m4/ax_prog_java_works.m4 | 134 - vpp-japi/m4/ax_prog_javac.m4 | 79 - vpp-japi/m4/ax_prog_javac_works.m4 | 72 - vpp-japi/m4/ax_prog_javadoc.m4 | 50 - vpp-japi/m4/ax_prog_javah.m4 | 64 - vpp-japi/m4/ax_try_compile_java.m4 | 55 - vpp-japi/m4/ax_try_run_java.m4 | 56 - vpp/api/api.c | 18 +- vppapigen/lex.c | 33 +- vppapigen/node.c | 59 +- vppapigen/node.h | 1 + 96 files changed, 6428 insertions(+), 15210 deletions(-) create mode 100644 build-data/packages/vpp-api.mk delete mode 100644 build-data/packages/vpp-japi.mk create mode 100755 vnet/vnet/map/examples/test_map.py create mode 100644 vpp-api/Makefile.am create mode 100644 vpp-api/configure.ac create mode 100644 vpp-api/java/Makefile.am create mode 100644 vpp-api/java/configure.ac create mode 100644 vpp-api/java/japi/org/openvpp/vppjapi/vppApiCallbacks.java create mode 100644 vpp-api/java/japi/org/openvpp/vppjapi/vppBridgeDomainDetails.java create mode 100644 vpp-api/java/japi/org/openvpp/vppjapi/vppBridgeDomainInterfaceDetails.java create mode 100644 vpp-api/java/japi/org/openvpp/vppjapi/vppConn.java create mode 100644 vpp-api/java/japi/org/openvpp/vppjapi/vppIPv4Address.java create mode 100644 vpp-api/java/japi/org/openvpp/vppjapi/vppIPv6Address.java create mode 100644 vpp-api/java/japi/org/openvpp/vppjapi/vppInterfaceCounters.java create mode 100644 vpp-api/java/japi/org/openvpp/vppjapi/vppInterfaceDetails.java create mode 100644 vpp-api/java/japi/org/openvpp/vppjapi/vppL2Fib.java create mode 100644 vpp-api/java/japi/org/openvpp/vppjapi/vppVersion.java create mode 100644 vpp-api/java/japi/org/openvpp/vppjapi/vppVxlanTunnelDetails.java create mode 100644 vpp-api/java/japi/test/demo.java create mode 100644 vpp-api/java/japi/test/vppApi.java create mode 100644 vpp-api/java/japi/vppjni.c create mode 100644 vpp-api/java/japi/vppjni.h create mode 100644 vpp-api/java/japi/vppjni_bridge_domain.h create mode 100644 vpp-api/java/japi/vppjni_env.c create mode 100644 vpp-api/java/japi/vppjni_env.h create mode 100644 vpp-api/java/m4/ax_check_java_home.m4 create mode 100644 vpp-api/java/m4/ax_check_java_plugin.m4 create mode 100644 vpp-api/java/m4/ax_java_check_class.m4 create mode 100644 vpp-api/java/m4/ax_java_options.m4 create mode 100644 vpp-api/java/m4/ax_libgcj_jar.m4 create mode 100644 vpp-api/java/m4/ax_prog_jar.m4 create mode 100644 vpp-api/java/m4/ax_prog_java.m4 create mode 100644 vpp-api/java/m4/ax_prog_java_cc.m4 create mode 100644 vpp-api/java/m4/ax_prog_java_works.m4 create mode 100644 vpp-api/java/m4/ax_prog_javac.m4 create mode 100644 vpp-api/java/m4/ax_prog_javac_works.m4 create mode 100644 vpp-api/java/m4/ax_prog_javadoc.m4 create mode 100644 vpp-api/java/m4/ax_prog_javah.m4 create mode 100644 vpp-api/java/m4/ax_try_compile_java.m4 create mode 100644 vpp-api/java/m4/ax_try_run_java.m4 create mode 100644 vpp-api/python/Makefile.am create mode 100644 vpp-api/python/README.rst create mode 100755 vpp-api/python/pneum/api-gen.py create mode 100644 vpp-api/python/pneum/pneum.c create mode 100644 vpp-api/python/pneum/pneum.h create mode 100644 vpp-api/python/pneum/test_pneum.c create mode 100644 vpp-api/python/setup.py create mode 100755 vpp-api/python/tests/test_papi.py create mode 100644 vpp-api/python/vpp_papi/__init__.py create mode 100644 vpp-api/python/vpp_papi/pneum_wrap.c delete mode 100644 vpp-japi/Makefile.am delete mode 100644 vpp-japi/configure.ac delete mode 100644 vpp-japi/japi/org/openvpp/vppjapi/vppApiCallbacks.java delete mode 100644 vpp-japi/japi/org/openvpp/vppjapi/vppBridgeDomainDetails.java delete mode 100644 vpp-japi/japi/org/openvpp/vppjapi/vppBridgeDomainInterfaceDetails.java delete mode 100644 vpp-japi/japi/org/openvpp/vppjapi/vppConn.java delete mode 100644 vpp-japi/japi/org/openvpp/vppjapi/vppIPv4Address.java delete mode 100644 vpp-japi/japi/org/openvpp/vppjapi/vppIPv6Address.java delete mode 100644 vpp-japi/japi/org/openvpp/vppjapi/vppInterfaceCounters.java delete mode 100644 vpp-japi/japi/org/openvpp/vppjapi/vppInterfaceDetails.java delete mode 100644 vpp-japi/japi/org/openvpp/vppjapi/vppL2Fib.java delete mode 100644 vpp-japi/japi/org/openvpp/vppjapi/vppVersion.java delete mode 100644 vpp-japi/japi/org/openvpp/vppjapi/vppVxlanTunnelDetails.java delete mode 100644 vpp-japi/japi/test/demo.java delete mode 100644 vpp-japi/japi/test/vppApi.java delete mode 100644 vpp-japi/japi/vppjni.c delete mode 100644 vpp-japi/japi/vppjni.h delete mode 100644 vpp-japi/japi/vppjni_bridge_domain.h delete mode 100644 vpp-japi/japi/vppjni_env.c delete mode 100644 vpp-japi/japi/vppjni_env.h delete mode 100755 vpp-japi/libtool delete mode 100644 vpp-japi/m4/ax_check_java_home.m4 delete mode 100644 vpp-japi/m4/ax_check_java_plugin.m4 delete mode 100644 vpp-japi/m4/ax_java_check_class.m4 delete mode 100644 vpp-japi/m4/ax_java_options.m4 delete mode 100644 vpp-japi/m4/ax_libgcj_jar.m4 delete mode 100644 vpp-japi/m4/ax_prog_jar.m4 delete mode 100644 vpp-japi/m4/ax_prog_java.m4 delete mode 100644 vpp-japi/m4/ax_prog_java_cc.m4 delete mode 100644 vpp-japi/m4/ax_prog_java_works.m4 delete mode 100644 vpp-japi/m4/ax_prog_javac.m4 delete mode 100644 vpp-japi/m4/ax_prog_javac_works.m4 delete mode 100644 vpp-japi/m4/ax_prog_javadoc.m4 delete mode 100644 vpp-japi/m4/ax_prog_javah.m4 delete mode 100644 vpp-japi/m4/ax_try_compile_java.m4 delete mode 100644 vpp-japi/m4/ax_try_run_java.m4 (limited to 'build-data/platforms/vpp.mk') diff --git a/Makefile b/Makefile index b53941b4..68652836 100644 --- a/Makefile +++ b/Makefile @@ -93,7 +93,7 @@ endif @echo 'export PATH=$(BR)/tools/ccache-bin:$$PATH' >> $(BR)/path_setup @echo 'export PATH=$(BR)/tools/bin:$$PATH' >> $(BR)/path_setup @echo 'export CCACHE_DIR=$(CCACHE_DIR)' >> $(BR)/path_setup - + ifeq ("$(wildcard /usr/bin/ccache )","") @echo "WARNING: Please install ccache AYEC and re-run this script" else diff --git a/build-data/packages/vpp-api.mk b/build-data/packages/vpp-api.mk new file mode 100644 index 00000000..f1841648 --- /dev/null +++ b/build-data/packages/vpp-api.mk @@ -0,0 +1,23 @@ +vpp-api_configure_depend = \ + vppinfra-install \ + svm-install \ + vlib-api-install \ + vlib-install \ + vnet-install \ + vpp-install + +vpp-api_CPPFLAGS = $(call installed_includes_fn, \ + vppinfra \ + svm \ + vlib \ + vlib-api \ + vnet \ + vpp) + +vpp-api_LDFLAGS = $(call installed_libs_fn, \ + vppinfra \ + svm \ + vlib \ + vlib-api) + +vpp-api_CPPFLAGS += -I/usr/lib/jvm/java-7-openjdk-amd64/include diff --git a/build-data/packages/vpp-japi.mk b/build-data/packages/vpp-japi.mk deleted file mode 100644 index 6f69baa0..00000000 --- a/build-data/packages/vpp-japi.mk +++ /dev/null @@ -1,23 +0,0 @@ -vpp-japi_configure_depend = \ - vppinfra-install \ - svm-install \ - vlib-api-install \ - vlib-install \ - vnet-install \ - vpp-install - -vpp-japi_CPPFLAGS = $(call installed_includes_fn, \ - vppinfra \ - svm \ - vlib \ - vlib-api \ - vnet \ - vpp) - -vpp-japi_LDFLAGS = $(call installed_libs_fn, \ - vppinfra \ - svm \ - vlib \ - vlib-api) - -vpp-japi_CPPFLAGS += -I/usr/lib/jvm/java-7-openjdk-amd64/include diff --git a/build-data/platforms/virl.mk b/build-data/platforms/virl.mk index f47f3691..3d5274a8 100644 --- a/build-data/platforms/virl.mk +++ b/build-data/platforms/virl.mk @@ -18,7 +18,7 @@ virl_native_tools = vppapigen virl_uses_dpdk = yes virl_root_packages = vpp vlib vlib-api vnet svm dpdk vpp-api-test \ - vpp-japi + vpp-api vpp_configure_args_virl = --with-dpdk vnet_configure_args_virl = --with-dpdk --with-virl diff --git a/build-data/platforms/vpp.mk b/build-data/platforms/vpp.mk index 04a697d3..c381be19 100644 --- a/build-data/platforms/vpp.mk +++ b/build-data/platforms/vpp.mk @@ -21,7 +21,7 @@ vpp_uses_dpdk = yes # vpp_enable_tests = yes vpp_root_packages = vpp vlib vlib-api vnet svm vpp-api-test \ - vpp-japi gmod + vpp-api gmod vpp_configure_args_vpp = --with-dpdk vnet_configure_args_vpp = --with-dpdk diff --git a/build-data/platforms/vpp_lite.mk b/build-data/platforms/vpp_lite.mk index 9376aa35..4183700e 100644 --- a/build-data/platforms/vpp_lite.mk +++ b/build-data/platforms/vpp_lite.mk @@ -18,7 +18,7 @@ vpp_lite_native_tools = vppapigen vpp_lite_uses_dpdk = no vpp_lite_root_packages = vpp vlib vlib-api vnet svm vpp-api-test \ - vpp-japi gmod + vpp-api gmod vlib_configure_args_vpp_lite = --with-pre-data=128 diff --git a/vlib-api/vlibmemory/api.h b/vlib-api/vlibmemory/api.h index 117bf433..516d321f 100644 --- a/vlib-api/vlibmemory/api.h +++ b/vlib-api/vlibmemory/api.h @@ -86,6 +86,13 @@ typedef struct vl_shmem_hdr_ { } vl_shmem_hdr_t; +/* Note that the size of the structure is 16 bytes, with 4 bytes of padding after data[0]. */ +typedef struct msgbuf_ { + unix_shared_memory_queue_t *q; + u32 data_len; + u8 data[0]; +} msgbuf_t; + #define VL_SHM_VERSION 2 #define VL_API_EPOCH_MASK 0xFF diff --git a/vlib-api/vlibmemory/memory_shared.c b/vlib-api/vlibmemory/memory_shared.c index ecd5cff7..a3219431 100644 --- a/vlib-api/vlibmemory/memory_shared.c +++ b/vlib-api/vlibmemory/memory_shared.c @@ -21,6 +21,7 @@ #include #include +#include #include #include #include @@ -38,11 +39,6 @@ #include #undef vl_typedefs -typedef struct msgbuf_ { - unix_shared_memory_queue_t *q; - u8 data[0]; -} msgbuf_t; - static inline void *vl_msg_api_alloc_internal(int nbytes, int pool) { int i; @@ -119,12 +115,13 @@ static inline void *vl_msg_api_alloc_internal(int nbytes, int pool) pthread_mutex_lock (&am->vlib_rp->mutex); oldheap = svm_push_data_heap (am->vlib_rp); - rv = clib_mem_alloc(nbytes + sizeof(msgbuf_t)); + rv = clib_mem_alloc(nbytes); rv->q = 0; svm_pop_heap (oldheap); pthread_mutex_unlock (&am->vlib_rp->mutex); out: + rv->data_len = htonl(nbytes - sizeof(msgbuf_t)); return(rv->data); } @@ -152,7 +149,8 @@ void vl_msg_api_free(void *a) void *oldheap; api_main_t *am = &api_main; - rv = (msgbuf_t *)(((u8 *)a) - sizeof(*rv)); + rv = (msgbuf_t *)(((u8 *)a) - offsetof(msgbuf_t, data)); + /* * Here's the beauty of the scheme. Only one proc/thread has * control of a given message buffer. To free a buffer, we just clear the @@ -176,7 +174,7 @@ static void vl_msg_api_free_nolock (void *a) void *oldheap; api_main_t *am = &api_main; - rv = (msgbuf_t *)(((u8 *)a) - sizeof(*rv)); + rv = (msgbuf_t *)(((u8 *)a) - offsetof(msgbuf_t, data)); /* * Here's the beauty of the scheme. Only one proc/thread has * control of a given message buffer. To free a buffer, we just clear the diff --git a/vnet/vnet/map/examples/test_map.py b/vnet/vnet/map/examples/test_map.py new file mode 100755 index 00000000..21388d49 --- /dev/null +++ b/vnet/vnet/map/examples/test_map.py @@ -0,0 +1,141 @@ +#!/usr/bin/env python + +import time,argparse,sys,cmd, unittest +from ipaddress import * + +parser = argparse.ArgumentParser(description='VPP MAP test') +parser.add_argument('-i', nargs='*', action="store", dest="inputdir") +args = parser.parse_args() + +for dir in args.inputdir: + sys.path.append(dir) +from vpp_papi import * + +# +# 1:1 Shared IPv4 address, shared BR (16) VPP CLI +# +def lw46_shared(ip4_pfx_str, ip6_pfx_str, ip6_src_str, ea_bits_len, psid_offset, psid_len, ip6_src_ecmp = False): + ip4_pfx = ip_network(ip4_pfx_str) + ip6_src = ip_address(ip6_src_str) + ip6_dst = ip_network(ip6_pfx_str) + ip6_nul = IPv6Address(u'0::0') + mod = ip4_pfx.num_addresses / 1024 + + for i in range(ip4_pfx.num_addresses): + a = time.clock() + t = map_add_domain(0, ip6_nul.packed, ip4_pfx[i].packed, ip6_src.packed, 0, 32, 128, ea_bits_len, psid_offset, psid_len, 0, 0) + #print "Return from map_add_domain", t + if t == None: + print "map_add_domain failed" + continue + if t.retval != 0: + print "map_add_domain failed", t + continue + for psid in range(0x1 << int(psid_len)): + r = map_add_del_rule(0, t.index, 1, (ip6_dst[(i * (0x1<H', msg[0:2]) + size = unpack('>H', msg[2:4]) + print "Received", id, "of size", size + i += 1 + #del msg + continue + + #time.sleep(0.001) + return + +# Create RX thread +rxthread = RXThread() +rxthread.setDaemon(True) + +print "Connect", connect_to_vpe("client124") +import timeit +rxthread.start() +print "After thread started" + +#pneum_kill_thread() +print "After thread killed" + +#t = show_version(0) +#print "Result from show version", t + +print timeit.timeit('t = show_version(0)', number=1000, setup="from __main__ import show_version") +time.sleep(10) +#print timeit.timeit('control_ping(0)', number=10, setup="from __main__ import control_ping") + + +disconnect_from_vpe() +sys.exit() + + +print t.program, t.version,t.builddate,t.builddirectory + +''' + +t = map_domain_dump(0) +if not t: + print('show map domain failed') + +for d in t: + print("IP6 prefix:",str(IPv6Address(d.ip6prefix))) + print( "IP4 prefix:",str(IPv4Address(d.ip4prefix))) +''' + +suite = unittest.TestLoader().loadTestsFromTestCase(TestMAP) +unittest.TextTestRunner(verbosity=2).run(suite) + +disconnect_from_vpe() + + diff --git a/vpp-api/Makefile.am b/vpp-api/Makefile.am new file mode 100644 index 00000000..5b326540 --- /dev/null +++ b/vpp-api/Makefile.am @@ -0,0 +1,2 @@ +AUTOMAKE_OPTIONS = foreign +SUBDIRS = java python diff --git a/vpp-api/configure.ac b/vpp-api/configure.ac new file mode 100644 index 00000000..31ee6656 --- /dev/null +++ b/vpp-api/configure.ac @@ -0,0 +1,15 @@ +AC_INIT(vpp-api, 1.0.0) +LT_INIT +AC_CONFIG_MACRO_DIR([m4]) +AC_CONFIG_SUBDIRS([java]) +AM_INIT_AUTOMAKE +AM_SILENT_RULES + +AM_PROG_AS +AC_PROG_CC +AM_PROG_CC_C_O + +AC_OUTPUT([python/Makefile]) +AC_CONFIG_FILES([Makefile]) +AC_OUTPUT + diff --git a/vpp-api/java/Makefile.am b/vpp-api/java/Makefile.am new file mode 100644 index 00000000..0e16b72b --- /dev/null +++ b/vpp-api/java/Makefile.am @@ -0,0 +1,93 @@ +# Copyright (c) 2015 Cisco and/or its affiliates. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +AUTOMAKE_OPTIONS = foreign subdir-objects +ACLOCAL_AMFLAGS = -I m4 +AM_CFLAGS = -Wall + +noinst_PROGRAMS = +BUILT_SOURCES = +bin_PROGRAMS = +CLEANFILES = +lib_LTLIBRARIES = + +nobase_include_HEADERS = \ + japi/org_openvpp_vppjapi_vppApi.h \ + japi/org_openvpp_vppjapi_vppConn.h + +lib_LTLIBRARIES += libvppjni.la + +libvppjni_la_SOURCES = japi/vppjni.c japi/vppapi.c japi/vppjni_env.h japi/vppjni_env.c +libvppjni_la_LIBADD = -lvlibmemoryclient -lvlibapi -lsvm -lvppinfra \ + -lpthread -lm -lrt +libvppjni_la_LDFLAGS = -module +libvppjni_la_CPPFLAGS = -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux + +jarfile = vppjapi-$(PACKAGE_VERSION).jar +packagedir = org/openvpp/vppjapi +JAVAROOT = . + +$(jarfile): libvppjni.la + cd .libs ; $(JAR) cf $(JARFLAGS) ../$@ libvppjni.so.0.0.0 ../$(packagedir)/*.class ; cd .. + +BUILT_SOURCES += japi/org_openvpp_vppjapi_vppConn.h japi/vppapi.c + +japi/org_openvpp_vppjapi_vppConn.h: \ + japi/org/openvpp/vppjapi/vppVersion.java \ + japi/org/openvpp/vppjapi/vppInterfaceDetails.java \ + japi/org/openvpp/vppjapi/vppInterfaceCounters.java \ + japi/org/openvpp/vppjapi/vppBridgeDomainDetails.java \ + japi/org/openvpp/vppjapi/vppBridgeDomainInterfaceDetails.java \ + japi/org/openvpp/vppjapi/vppL2Fib.java \ + japi/org/openvpp/vppjapi/vppIPv4Address.java \ + japi/org/openvpp/vppjapi/vppIPv6Address.java \ + japi/org/openvpp/vppjapi/vppVxlanTunnelDetails.java \ + japi/org/openvpp/vppjapi/vppConn.java \ + japi/org/openvpp/vppjapi/vppApiCallbacks.java \ + ../../vpp/api/vpe.api.h + $(JAVAC) -classpath . -d . @srcdir@/japi/org/openvpp/vppjapi/vppVersion.java ; \ + $(JAVAH) -classpath . -d japi org.openvpp.vppjapi.vppVersion ; \ + $(JAVAC) -classpath . -d . @srcdir@/japi/org/openvpp/vppjapi/vppInterfaceDetails.java ; \ + $(JAVAH) -classpath . -d japi org.openvpp.vppjapi.vppInterfaceDetails ; \ + $(JAVAC) -classpath . -d . @srcdir@/japi/org/openvpp/vppjapi/vppInterfaceCounters.java ; \ + $(JAVAH) -classpath . -d japi org.openvpp.vppjapi.vppInterfaceCounters ; \ + $(JAVAC) -classpath . -d . @srcdir@/japi/org/openvpp/vppjapi/vppBridgeDomainInterfaceDetails.java ; \ + $(JAVAH) -classpath . -d japi org.openvpp.vppjapi.vppBridgeDomainInterfaceDetails ; \ + $(JAVAC) -classpath . -d . @srcdir@/japi/org/openvpp/vppjapi/vppBridgeDomainDetails.java ; \ + $(JAVAH) -classpath . -d japi org.openvpp.vppjapi.vppBridgeDomainDetails ; \ + $(JAVAC) -classpath . -d . @srcdir@/japi/org/openvpp/vppjapi/vppL2Fib.java ; \ + $(JAVAH) -classpath . -d japi org.openvpp.vppjapi.vppL2Fib ; \ + $(JAVAC) -classpath . -d . @srcdir@/japi/org/openvpp/vppjapi/vppIPv4Address.java ; \ + $(JAVAH) -classpath . -d japi org.openvpp.vppjapi.vppIPv4Address ; \ + $(JAVAC) -classpath . -d . @srcdir@/japi/org/openvpp/vppjapi/vppIPv6Address.java ; \ + $(JAVAH) -classpath . -d japi org.openvpp.vppjapi.vppIPv6Address ; \ + $(JAVAC) -classpath . -d . @srcdir@/japi/org/openvpp/vppjapi/vppVxlanTunnelDetails.java ; \ + $(JAVAH) -classpath . -d japi org.openvpp.vppjapi.vppVxlanTunnelDetails ; \ + $(JAVAC) -classpath . -d . @srcdir@/japi/org/openvpp/vppjapi/vppConn.java ; \ + $(JAVAH) -classpath . -d japi org.openvpp.vppjapi.vppConn ; + +japi/vppapi.c: japi/org_openvpp_vppjapi_vppConn.h + pushd .. ; dir=`pwd` ; popd ; \ + instdir=`echo $${dir} | sed -e 's:build-root/build:build-root/install:'` ; \ + vppapigen --input $${instdir}/../vpp/api/vpe.api --jni japi/vppapi.c --app vpe ; \ + vppapigen --input $${instdir}/../vpp/api/vpe.api --java japi/vppApi.java --app vpe ; \ + $(JAVAC) -classpath . -d . japi/vppApi.java ; \ + $(JAVAH) -classpath . -d japi org.openvpp.vppjapi.vppApi ; \ + $(JAVAC) -classpath . -d . @srcdir@/japi/org/openvpp/vppjapi/vppApiCallbacks.java ; \ + $(JAVAH) -classpath . -d japi org.openvpp.vppjapi.vppApiCallbacks ; + +demo = japi/test/demo.class +$(demo): $(jarfile) + $(JAVAC) -cp $(jarfile) -d $(JAVAROOT) @srcdir@/japi/test/demo.java + +all-local: $(jarfile) $(demo) diff --git a/vpp-api/java/configure.ac b/vpp-api/java/configure.ac new file mode 100644 index 00000000..1607061d --- /dev/null +++ b/vpp-api/java/configure.ac @@ -0,0 +1,19 @@ +AC_INIT(vpp-japi, 1.0.0) +LT_INIT +AC_CONFIG_MACRO_DIR([m4]) +AM_INIT_AUTOMAKE +AM_SILENT_RULES + +AM_PROG_AS +AC_PROG_CC +AM_PROG_CC_C_O + +AX_PROG_JAVAC +AX_PROG_JAVAH +AX_PROG_JAR +AX_PROG_JAVADOC +AX_PROG_JAVA +AX_CHECK_JAVA_HOME + +AC_OUTPUT([Makefile]) + diff --git a/vpp-api/java/japi/org/openvpp/vppjapi/vppApiCallbacks.java b/vpp-api/java/japi/org/openvpp/vppjapi/vppApiCallbacks.java new file mode 100644 index 00000000..df5b9533 --- /dev/null +++ b/vpp-api/java/japi/org/openvpp/vppjapi/vppApiCallbacks.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2015 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.openvpp.vppjapi; + +import java.io.IOException; +import org.openvpp.vppjapi.vppApi; + +public abstract class vppApiCallbacks extends vppApi { + public vppApiCallbacks(String clientName) throws IOException { + super(clientName); + } +/* Disabled! + * + * public abstract void interfaceDetails( + int ifIndex, String interfaceName, int supIfIndex, byte[] physAddr, + byte adminUp, byte linkUp, byte linkDuplex, byte linkSpeed, + int subId, byte subDot1ad, byte subNumberOfTags, int subOuterVlanId, int subInnerVlanId, + byte subExactMatch, byte subDefault, byte subOuterVlanIdAny, byte subInnerVlanIdAny, + int vtrOp, int vtrPushDot1q, int vtrTag1, int vtrTag2); + */ + +} diff --git a/vpp-api/java/japi/org/openvpp/vppjapi/vppBridgeDomainDetails.java b/vpp-api/java/japi/org/openvpp/vppjapi/vppBridgeDomainDetails.java new file mode 100644 index 00000000..db859a07 --- /dev/null +++ b/vpp-api/java/japi/org/openvpp/vppjapi/vppBridgeDomainDetails.java @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2015 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.openvpp.vppjapi; + +import org.openvpp.vppjapi.vppBridgeDomainInterfaceDetails; + +public final class vppBridgeDomainDetails { + public String name; + public int bdId; + public boolean flood; + public boolean uuFlood; + public boolean forward; + public boolean learn; + public boolean arpTerm; + public String bviInterfaceName; + public vppBridgeDomainInterfaceDetails[] interfaces; +} diff --git a/vpp-api/java/japi/org/openvpp/vppjapi/vppBridgeDomainInterfaceDetails.java b/vpp-api/java/japi/org/openvpp/vppjapi/vppBridgeDomainInterfaceDetails.java new file mode 100644 index 00000000..ab99ee45 --- /dev/null +++ b/vpp-api/java/japi/org/openvpp/vppjapi/vppBridgeDomainInterfaceDetails.java @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2015 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.openvpp.vppjapi; + +public final class vppBridgeDomainInterfaceDetails { + public String interfaceName; + public byte splitHorizonGroup; +} diff --git a/vpp-api/java/japi/org/openvpp/vppjapi/vppConn.java b/vpp-api/java/japi/org/openvpp/vppjapi/vppConn.java new file mode 100644 index 00000000..3e8c12a9 --- /dev/null +++ b/vpp-api/java/japi/org/openvpp/vppjapi/vppConn.java @@ -0,0 +1,237 @@ +/* + * Copyright (c) 2015 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.openvpp.vppjapi; + +import java.io.IOException; +import java.io.InputStream; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.StandardCopyOption; +import java.nio.file.attribute.PosixFilePermission; +import java.nio.file.attribute.PosixFilePermissions; +import java.util.Set; + +import org.openvpp.vppjapi.vppVersion; +import org.openvpp.vppjapi.vppInterfaceDetails; +import org.openvpp.vppjapi.vppInterfaceCounters; +import org.openvpp.vppjapi.vppBridgeDomainDetails; +import org.openvpp.vppjapi.vppIPv4Address; +import org.openvpp.vppjapi.vppIPv6Address; +import org.openvpp.vppjapi.vppVxlanTunnelDetails; + +public class vppConn implements AutoCloseable { + private static final String LIBNAME = "libvppjni.so.0.0.0"; + + static { + try { + loadLibrary(); + } catch (Exception e) { + System.out.printf("Can't find vpp jni library: %s\n", LIBNAME); + throw new ExceptionInInitializerError(e); + } + } + + private static void loadStream(final InputStream is) throws IOException { + final Set perms = PosixFilePermissions.fromString("rwxr-x---"); + final Path p = Files.createTempFile(LIBNAME, null, PosixFilePermissions.asFileAttribute(perms)); + try { + Files.copy(is, p, StandardCopyOption.REPLACE_EXISTING); + + try { + Runtime.getRuntime().load(p.toString()); + } catch (UnsatisfiedLinkError e) { + throw new IOException(String.format("Failed to load library %s", p), e); + } + } finally { + try { + Files.deleteIfExists(p); + } catch (IOException e) { + } + } + } + + private static void loadLibrary() throws IOException { + try (final InputStream is = vppConn.class.getResourceAsStream('/' + LIBNAME)) { + if (is == null) { + throw new IOException(String.format("Failed to open library resource %s", + LIBNAME)); + } + loadStream(is); + } + } + + private static vppConn currentConnection = null; + private final String clientName; + private volatile boolean disconnected = false; + + // Hidden on purpose to prevent external instantiation + vppConn(final String clientName) throws IOException { + this.clientName = clientName; + + synchronized (vppConn.class) { + if (currentConnection != null) { + throw new IOException("Already connected as " + currentConnection.clientName); + } + + final int ret = clientConnect(clientName); + if (ret != 0) { + throw new IOException("Connection returned error " + ret); + } + + currentConnection = this; + } + } + + @Override + public synchronized final void close() { + if (!disconnected) { + disconnected = true; + + synchronized (vppConn.class) { + clientDisconnect(); + currentConnection = null; + } + } + } + + /** + * Check if this instance is connected. + * + * @throws IllegalStateException if this instance was disconnected. + */ + protected final void checkConnected() { + if (disconnected) { + throw new IllegalStateException("Disconnected client " + clientName); + } + } + + public final int getRetval(int context, int release) { + checkConnected(); + return getRetval0(context, release); + } + + public final String getInterfaceList (String nameFilter) { + checkConnected(); + return getInterfaceList0(nameFilter); + } + + public final int swIfIndexFromName (String interfaceName) { + checkConnected(); + return swIfIndexFromName0(interfaceName); + } + + public final String interfaceNameFromSwIfIndex (int swIfIndex) { + checkConnected(); + return interfaceNameFromSwIfIndex0(swIfIndex); + } + + public final void clearInterfaceTable () { + checkConnected(); + clearInterfaceTable0(); + } + + public final vppInterfaceDetails[] swInterfaceDump (byte nameFilterValid, byte [] nameFilter) { + checkConnected(); + return swInterfaceDump0(nameFilterValid, nameFilter); + } + + public final int bridgeDomainIdFromName(String bridgeDomain) { + checkConnected(); + return bridgeDomainIdFromName0(bridgeDomain); + } + + public final int findOrAddBridgeDomainId(String bridgeDomain) { + checkConnected(); + return findOrAddBridgeDomainId0(bridgeDomain); + } + + public final vppVersion getVppVersion() { + checkConnected(); + return getVppVersion0(); + } + + public final vppInterfaceCounters getInterfaceCounters(int swIfIndex) { + checkConnected(); + return getInterfaceCounters0(swIfIndex); + } + + public final int[] bridgeDomainDump(int bdId) { + checkConnected(); + return bridgeDomainDump0(bdId); + } + + public final vppBridgeDomainDetails getBridgeDomainDetails(int bdId) { + checkConnected(); + return getBridgeDomainDetails0(bdId); + } + + public final vppL2Fib[] l2FibTableDump(int bdId) { + checkConnected(); + return l2FibTableDump0(bdId); + } + + public final int bridgeDomainIdFromInterfaceName(String interfaceName) { + checkConnected(); + return bridgeDomainIdFromInterfaceName0(interfaceName); + } + + public final vppIPv4Address[] ipv4AddressDump(String interfaceName) { + checkConnected(); + return ipv4AddressDump0(interfaceName); + } + + public final vppIPv6Address[] ipv6AddressDump(String interfaceName) { + checkConnected(); + return ipv6AddressDump0(interfaceName); + } + + public final vppVxlanTunnelDetails[] vxlanTunnelDump(int swIfIndex) { + checkConnected(); + return vxlanTunnelDump0(swIfIndex); + } + + public final int setInterfaceDescription(String ifName, String ifDesc) { + checkConnected(); + return setInterfaceDescription0(ifName, ifDesc); + } + + public final String getInterfaceDescription(String ifName) { + checkConnected(); + return getInterfaceDescription0(ifName); + } + + private static native int clientConnect(String clientName); + private static native void clientDisconnect(); + private static native int getRetval0(int context, int release); + private static native String getInterfaceList0(String nameFilter); + private static native int swIfIndexFromName0(String interfaceName); + private static native String interfaceNameFromSwIfIndex0(int swIfIndex); + private static native void clearInterfaceTable0(); + private static native vppInterfaceDetails[] swInterfaceDump0(byte nameFilterValid, byte [] nameFilter); + private static native int bridgeDomainIdFromName0(String bridgeDomain); + private static native int findOrAddBridgeDomainId0(String bridgeDomain); + private static native vppVersion getVppVersion0(); + private static native vppInterfaceCounters getInterfaceCounters0(int swIfIndex); + private static native int[] bridgeDomainDump0(int bdId); + private static native vppBridgeDomainDetails getBridgeDomainDetails0(int bdId); + private static native vppL2Fib[] l2FibTableDump0(int bdId); + private static native int bridgeDomainIdFromInterfaceName0(String interfaceName); + private static native vppIPv4Address[] ipv4AddressDump0(String interfaceName); + private static native vppIPv6Address[] ipv6AddressDump0(String interfaceName); + private static native vppVxlanTunnelDetails[] vxlanTunnelDump0(int swIfIndex); + private static native int setInterfaceDescription0(String ifName, String ifDesc); + private static native String getInterfaceDescription0(String ifName); +} diff --git a/vpp-api/java/japi/org/openvpp/vppjapi/vppIPv4Address.java b/vpp-api/java/japi/org/openvpp/vppjapi/vppIPv4Address.java new file mode 100644 index 00000000..046ceab5 --- /dev/null +++ b/vpp-api/java/japi/org/openvpp/vppjapi/vppIPv4Address.java @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2015 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.openvpp.vppjapi; + +public final class vppIPv4Address { + public final int ip; + public final byte prefixLength; + + public vppIPv4Address(int ip, byte prefixLength) { + this.ip = ip; + this.prefixLength = prefixLength; + } +} diff --git a/vpp-api/java/japi/org/openvpp/vppjapi/vppIPv6Address.java b/vpp-api/java/japi/org/openvpp/vppjapi/vppIPv6Address.java new file mode 100644 index 00000000..6690a5db --- /dev/null +++ b/vpp-api/java/japi/org/openvpp/vppjapi/vppIPv6Address.java @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2015 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.openvpp.vppjapi; + +public class vppIPv6Address { + // FIXME: this is dangerous + public final byte[] ip; + public final byte prefixLength; + + public vppIPv6Address(byte[] ip, byte prefixLength) { + this.ip = ip; + this.prefixLength = prefixLength; + } +} diff --git a/vpp-api/java/japi/org/openvpp/vppjapi/vppInterfaceCounters.java b/vpp-api/java/japi/org/openvpp/vppjapi/vppInterfaceCounters.java new file mode 100644 index 00000000..b2687fb8 --- /dev/null +++ b/vpp-api/java/japi/org/openvpp/vppjapi/vppInterfaceCounters.java @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2015 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.openvpp.vppjapi; + +public final class vppInterfaceCounters { + + public final long rxOctets; + public final long rxIp4; + public final long rxIp6; + public final long rxUnicast; + public final long rxMulticast; + public final long rxBroadcast; + public final long rxDiscard; + public final long rxFifoFull; + public final long rxError; + public final long rxUnknownProto; + public final long rxMiss; + + public final long txOctets; + public final long txIp4; + public final long txIp6; + public final long txUnicast; + public final long txMulticast; + public final long txBroadcast; + public final long txDiscard; + public final long txFifoFull; + public final long txError; + public final long txUnknownProto; + public final long txMiss; + + public vppInterfaceCounters( + long rxOctets, long rxIp4, long rxIp6, long rxUni, long rxMulti, + long rxBcast, long rxDiscard, long rxFifoFull, long rxError, + long rxUnknownProto, long rxMiss, + long txOctets, long txIp4, long txIp6, long txUni, long txMulti, + long txBcast, long txDiscard, long txFifoFull, long txError, + long txUnknownProto, long txMiss) + { + this.rxOctets = rxOctets; + this.rxIp4 = rxIp4; + this.rxIp6 = rxIp6; + this.rxUnicast = rxUni; + this.rxMulticast = rxMulti; + this.rxBroadcast = rxBcast; + this.rxDiscard = rxDiscard; + this.rxFifoFull = rxFifoFull; + this.rxError = rxError; + this.rxUnknownProto = rxUnknownProto; + this.rxMiss = rxMiss; + + this.txOctets = txOctets; + this.txIp4 = txIp4; + this.txIp6 = txIp6; + this.txUnicast = txUni; + this.txMulticast = txMulti; + this.txBroadcast = txBcast; + this.txDiscard = txDiscard; + this.txFifoFull = txFifoFull; + this.txError = txError; + this.txUnknownProto = txUnknownProto; + this.txMiss = txMiss; + } +} + diff --git a/vpp-api/java/japi/org/openvpp/vppjapi/vppInterfaceDetails.java b/vpp-api/java/japi/org/openvpp/vppjapi/vppInterfaceDetails.java new file mode 100644 index 00000000..742dd25a --- /dev/null +++ b/vpp-api/java/japi/org/openvpp/vppjapi/vppInterfaceDetails.java @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2015 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.openvpp.vppjapi; + +public final class vppInterfaceDetails { + public final int ifIndex; + public final String interfaceName; + public final int supIfIndex; + // FIXME: this is dangerous + public final byte[] physAddr; + public final byte adminUp; + public final byte linkUp; + public final byte linkDuplex; + public final byte linkSpeed; + public final int subId; + public final byte subDot1ad; + public final byte subNumberOfTags; + public final int subOuterVlanId; + public final int subInnerVlanId; + public final byte subExactMatch; + public final byte subDefault; + public final byte subOuterVlanIdAny; + public final byte subInnerVlanIdAny; + public final int vtrOp; + public final int vtrPushDot1q; + public final int vtrTag1; + public final int vtrTag2; + public final int linkMtu; + + public vppInterfaceDetails(int ifIndex, String interfaceName, int supIfIndex, byte[] physAddr, byte adminUp, + byte linkUp, byte linkDuplex, byte linkSpeed, int subId, byte subDot1ad, byte subNumberOfTags, + int subOuterVlanId, int subInnerVlanId, byte subExactMatch, byte subDefault, byte subOuterVlanIdAny, + byte subInnerVlanIdAny, int vtrOp, int vtrPushDot1q, int vtrTag1, int vtrTag2, int linkMtu) + { + this.ifIndex = ifIndex; + this.interfaceName = interfaceName; + this.supIfIndex = supIfIndex; + this.physAddr = physAddr; + this.adminUp = adminUp; + this.linkUp = linkUp; + this.linkDuplex = linkDuplex; + this.linkSpeed = linkSpeed; + this.subId = subId; + this.subDot1ad = subDot1ad; + this.subNumberOfTags = subNumberOfTags; + this.subOuterVlanId = subOuterVlanId; + this.subInnerVlanId = subInnerVlanId; + this.subExactMatch = subExactMatch; + this.subDefault = subDefault; + this.subOuterVlanIdAny = subOuterVlanIdAny; + this.subInnerVlanIdAny = subInnerVlanIdAny; + this.vtrOp = vtrOp; + this.vtrPushDot1q = vtrPushDot1q; + this.vtrTag1 = vtrTag1; + this.vtrTag2 = vtrTag2; + this.linkMtu = linkMtu; + } +} diff --git a/vpp-api/java/japi/org/openvpp/vppjapi/vppL2Fib.java b/vpp-api/java/japi/org/openvpp/vppjapi/vppL2Fib.java new file mode 100644 index 00000000..b38d801e --- /dev/null +++ b/vpp-api/java/japi/org/openvpp/vppjapi/vppL2Fib.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2015 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.openvpp.vppjapi; + +public final class vppL2Fib { + // FIXME: this is dangerous + public final byte[] physAddress; + public final boolean staticConfig; + public final String outgoingInterface; + public final boolean filter; + public final boolean bridgedVirtualInterface; + + public vppL2Fib(byte[] physAddress, boolean staticConfig, + String outgoingInterface, boolean filter, + boolean bridgedVirtualInterface) { + this.physAddress = physAddress; + this.staticConfig = staticConfig; + this.outgoingInterface = outgoingInterface; + this.filter = filter; + this.bridgedVirtualInterface = bridgedVirtualInterface; + } +} diff --git a/vpp-api/java/japi/org/openvpp/vppjapi/vppVersion.java b/vpp-api/java/japi/org/openvpp/vppjapi/vppVersion.java new file mode 100644 index 00000000..6408dee2 --- /dev/null +++ b/vpp-api/java/japi/org/openvpp/vppjapi/vppVersion.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2015 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.openvpp.vppjapi; + +public final class vppVersion { + public final String programName; + public final String buildDirectory; + public final String gitBranch; + public final String buildDate; + + public vppVersion(String progName, String buildDir, String gitBranch, String buildDate) { + this.programName = progName; + this.buildDirectory = buildDir; + this.gitBranch = gitBranch; + this.buildDate = buildDate; + } +} + diff --git a/vpp-api/java/japi/org/openvpp/vppjapi/vppVxlanTunnelDetails.java b/vpp-api/java/japi/org/openvpp/vppjapi/vppVxlanTunnelDetails.java new file mode 100644 index 00000000..dd81e98c --- /dev/null +++ b/vpp-api/java/japi/org/openvpp/vppjapi/vppVxlanTunnelDetails.java @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2015 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.openvpp.vppjapi; + +public final class vppVxlanTunnelDetails { + public final int srcAddress; + public final int dstAddress; + public final int encapVrfId; + public final int vni; + public final int decapNextIndex; + + public vppVxlanTunnelDetails(int srcAddress, int dstAddress, + int encapVrfId, int vni, int decapNextIndex) { + this.srcAddress = srcAddress; + this.dstAddress = dstAddress; + this.encapVrfId = encapVrfId; + this.vni = vni; + this.decapNextIndex = decapNextIndex; + } +} diff --git a/vpp-api/java/japi/test/demo.java b/vpp-api/java/japi/test/demo.java new file mode 100644 index 00000000..ea1db84b --- /dev/null +++ b/vpp-api/java/japi/test/demo.java @@ -0,0 +1,170 @@ +/* + * Copyright (c) 2015 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import org.openvpp.vppjapi.*; + +public class demo { + public static void main (String[] args) throws Exception { + vppApi api = new vppApi ("JavaTest"); + System.out.printf ("Connected OK..."); + + String intlist; + int [] contexts; + int i, limit; + int trips; + int rv, errors, saved_error; + long before, after; + + if (false) + { + intlist = api.getInterfaceList (""); + System.out.printf ("Unfiltered interface list:\n%s", intlist); + + trips = 0; + + contexts = new int[6]; + + for (i = 0; i < 6; i++) + { + contexts[i] = api.swInterfaceSetFlags + (5 + i /* sw_if_index */, + (byte)1 /* admin_up */, + (byte)1 /* link_up (ignored) */, + (byte)0 /* deleted */); + } + + /* Thread.sleep (1); */ + errors = 0; + saved_error = 0; + + for (i = 0; i < 6; i ++) + { + while (true) + { + rv = api.getRetval (contexts[i], 1 /* release */); + if (rv != -77) + break; + Thread.sleep (1); + trips++; + } + if (rv < 0) + { + saved_error = rv; + errors++; + } + } + + if (errors == 0) + System.out.printf ("intfcs up...\n"); + else + System.out.printf + ("%d errors, last error %d...\n", errors, saved_error); + } + + limit = 250000; + saved_error = 0; + errors = 0; + contexts = new int [limit]; + byte [] address = new byte [4]; + byte [] zeros = new byte [4]; + + address[0] = (byte)192; + address[1] = (byte)168; + address[2] = (byte)2; + address[3] = (byte)1; + + for (i = 0; i < 4; i++) + zeros[i] = 0; + + System.out.printf ("start %d route ops ...", limit); + + before = System.currentTimeMillis(); + + for (i = 0; i < limit; i++) { + contexts[i] = api.ipAddDelRoute + (0 /* int nextHopSwIfIndex */, + 0 /* int vrfId */, + 0 /* int lookupInVrf */, + 0 /* int resolveAttempts */, + 0 /* int classifyTableIndex */, + (byte)0 /* byte createVrfIfNeeded */, + (byte)0 /* byte resolveIfNeeded */, + (byte)1 /* byte isAdd */, + (byte)1 /* byte isDrop */, + (byte)0 /* byte isIpv6 */, + (byte)0 /* byte isLocal */, + (byte)0 /* byte isClassify */, + (byte)0 /* byte isMultipath */, + (byte)0 /* byte notLast */, + (byte)0 /* byte nextHopWeight */, + (byte)32 /* byte dstAddressLength */, + address, + zeros); + + address[3] += 1; + if (address[3] == 0) + { + address[2] += 1; + if (address[2] == 0) + { + address[1] += 1; + { + if (address[1] == 0) + { + address[0] += 1; + } + } + } + } + } + + trips = 0; + + for (i = 0; i < limit; i++) + { + while (true) + { + rv = api.getRetval (contexts[i], 1 /* release */); + if (rv != -77) + break; + Thread.sleep (1); + trips++; + } + if (rv < 0) + { + saved_error = rv; + errors++; + } + } + + after = System.currentTimeMillis(); + + + if (errors == 0) + System.out.printf ("done %d route ops (all OK)...\n", limit); + else + System.out.printf + ("%d errors, last error %d...\n", errors, saved_error); + + System.out.printf ("result in %d trips\n", trips); + + System.out.printf ("%d routes in %d milliseconds, %d routes/msec\n", + limit, after - before, + limit / (after - before)); + + api.close(); + System.out.printf ("Done...\n"); + } +} diff --git a/vpp-api/java/japi/test/vppApi.java b/vpp-api/java/japi/test/vppApi.java new file mode 100644 index 00000000..87af3292 --- /dev/null +++ b/vpp-api/java/japi/test/vppApi.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2015 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import java.net.InetAddress; +import org.openvpp.vppjapi.*; + +public class vppApi { + + native int controlPing(); + native void test (byte[] array, byte[] array2); + + public static void main (String[] args) throws Exception { + vppConn api = new vppConn (); + String ipv6 = "db01::feed"; + String ipv4 = "192.168.1.1"; + InetAddress addr6 = InetAddress.getByName(ipv6); + InetAddress addr4 = InetAddress.getByName(ipv4); + byte[] ip4bytes = addr4.getAddress(); + byte[] ip6bytes = addr6.getAddress(); + int rv; + + api.test(ip4bytes,ip6bytes); + + rv = api.clientConnect ("JavaTest"); + if (rv == 0) + System.out.printf ("Connected OK..."); + else + { + System.out.printf ("clientConnect returned %d\n", rv); + System.exit (1); + } + rv = api.controlPing(); + System.out.printf ("data plane pid is %d\n", rv); + + Thread.sleep (5000); + + api.clientDisconnect(); + System.out.printf ("Done...\n"); + } +} diff --git a/vpp-api/java/japi/vppjni.c b/vpp-api/java/japi/vppjni.c new file mode 100644 index 00000000..9c9437d2 --- /dev/null +++ b/vpp-api/java/japi/vppjni.c @@ -0,0 +1,1900 @@ +/* + * Copyright (c) 2015 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#define _GNU_SOURCE /* for strcasestr(3) */ +#include + +#define vl_api_version(n,v) static u32 vpe_api_version = (v); +#include +#undef vl_api_version + +#include +#include +#include +#include +#include +#include + +#include +#define vl_typedefs /* define message structures */ +#include +#undef vl_typedefs + +#define vl_endianfun +#include +#undef vl_endianfun + +/* instantiate all the print functions we know about */ +#define vl_print(handle, ...) +#define vl_printfun +#include +#undef vl_printfun + +#define VPPJNI_DEBUG 0 + +#if VPPJNI_DEBUG == 1 + #define DEBUG_LOG(...) clib_warning(__VA_ARGS__) +#else + #define DEBUG_LOG(...) +#endif + +static int connect_to_vpe(char *name); + +/* + * The Java runtime isn't compile w/ -fstack-protector, + * so we have to supply missing external references for the + * regular vpp libraries. Weak reference in case folks get religion + * at a later date... + */ +void __stack_chk_guard (void) __attribute__((weak)); +void __stack_chk_guard (void) { } + +BIND_JAPI_CLASS(vppBridgeDomainDetails, "()V"); +BIND_JAPI_BOOL_FIELD(vppBridgeDomainDetails, arpTerm); +BIND_JAPI_BOOL_FIELD(vppBridgeDomainDetails, flood); +BIND_JAPI_BOOL_FIELD(vppBridgeDomainDetails, forward); +BIND_JAPI_BOOL_FIELD(vppBridgeDomainDetails, learn); +BIND_JAPI_BOOL_FIELD(vppBridgeDomainDetails, uuFlood); +BIND_JAPI_INT_FIELD(vppBridgeDomainDetails, bdId); +BIND_JAPI_STRING_FIELD(vppBridgeDomainDetails, name); +BIND_JAPI_STRING_FIELD(vppBridgeDomainDetails, bviInterfaceName); +BIND_JAPI_OBJ_FIELD(vppBridgeDomainDetails, interfaces, "[Lorg/openvpp/vppjapi/vppBridgeDomainInterfaceDetails;"); + +BIND_JAPI_CLASS(vppBridgeDomainInterfaceDetails, "()V"); +BIND_JAPI_BYTE_FIELD(vppBridgeDomainInterfaceDetails, splitHorizonGroup); +BIND_JAPI_STRING_FIELD(vppBridgeDomainInterfaceDetails, interfaceName); + +BIND_JAPI_CLASS(vppInterfaceCounters, "(JJJJJJJJJJJJJJJJJJJJJJ)V"); +BIND_JAPI_CLASS(vppInterfaceDetails, "(ILjava/lang/String;I[BBBBBIBBIIBBBBIIIII)V"); +BIND_JAPI_CLASS(vppIPv4Address, "(IB)V"); +BIND_JAPI_CLASS(vppIPv6Address, "([BB)V"); +BIND_JAPI_CLASS(vppL2Fib, "([BZLjava/lang/String;ZZ)V"); +BIND_JAPI_CLASS(vppVersion, "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V"); +BIND_JAPI_CLASS(vppVxlanTunnelDetails, "(IIIII)V"); + +void vl_client_add_api_signatures (vl_api_memclnt_create_t *mp) +{ + /* + * Send the main API signature in slot 0. This bit of code must + * match the checks in ../vpe/api/api.c: vl_msg_api_version_check(). + */ + mp->api_versions[0] = clib_host_to_net_u32 (vpe_api_version); +} + +/* Note: non-static, called once to set up the initial intfc table */ +static int sw_interface_dump (vppjni_main_t * jm) +{ + vl_api_sw_interface_dump_t *mp; + f64 timeout; + hash_pair_t * p; + name_sort_t * nses = 0, * ns; + sw_interface_subif_t * sub = NULL; + + /* Toss the old name table */ + hash_foreach_pair (p, jm->sw_if_index_by_interface_name, + ({ + vec_add2 (nses, ns, 1); + ns->name = (u8 *)(p->key); + ns->value = (u32) p->value[0]; + })); + + hash_free (jm->sw_if_index_by_interface_name); + + vec_foreach (ns, nses) + vec_free (ns->name); + + vec_free (nses); + + vec_foreach (sub, jm->sw_if_subif_table) { + vec_free (sub->interface_name); + } + vec_free (jm->sw_if_subif_table); + + /* recreate the interface name hash table */ + jm->sw_if_index_by_interface_name + = hash_create_string (0, sizeof(uword)); + + /* Get list of ethernets */ + M(SW_INTERFACE_DUMP, sw_interface_dump); + mp->name_filter_valid = 1; + strncpy ((char *) mp->name_filter, "Ether", sizeof(mp->name_filter-1)); + S; + + /* and local / loopback interfaces */ + M(SW_INTERFACE_DUMP, sw_interface_dump); + mp->name_filter_valid = 1; + strncpy ((char *) mp->name_filter, "lo", sizeof(mp->name_filter-1)); + S; + + /* and vxlan tunnel interfaces */ + M(SW_INTERFACE_DUMP, sw_interface_dump); + mp->name_filter_valid = 1; + strncpy ((char *) mp->name_filter, "vxlan", sizeof(mp->name_filter-1)); + S; + + /* and tap tunnel interfaces */ + M(SW_INTERFACE_DUMP, sw_interface_dump); + mp->name_filter_valid = 1; + strncpy ((char *) mp->name_filter, "tap", sizeof(mp->name_filter-1)); + S; + + /* and host (af_packet) interfaces */ + M(SW_INTERFACE_DUMP, sw_interface_dump); + mp->name_filter_valid = 1; + strncpy ((char *) mp->name_filter, "host", sizeof(mp->name_filter-1)); + S; + + /* and l2tpv3 tunnel interfaces */ + M(SW_INTERFACE_DUMP, sw_interface_dump); + mp->name_filter_valid = 1; + strncpy ((char *) mp->name_filter, "l2tpv3_tunnel", + sizeof(mp->name_filter-1)); + S; + + /* Use a control ping for synchronization */ + { + vl_api_control_ping_t * mp; + M(CONTROL_PING, control_ping); + S; + } + W; +} + +JNIEXPORT jobject JNICALL Java_org_openvpp_vppjapi_vppConn_getVppVersion0 + (JNIEnv *env, jobject obj) +{ + vppjni_main_t * jm = &vppjni_main; + + vppjni_lock (jm, 11); + jstring progName = (*env)->NewStringUTF(env, (char *)jm->program_name); + jstring buildDir = (*env)->NewStringUTF(env, (char *)jm->build_directory); + jstring version = (*env)->NewStringUTF(env, (char *)jm->version); + jstring buildDate = (*env)->NewStringUTF(env, (char *)jm->build_date); + vppjni_unlock (jm); + + return vppVersionObject(env, progName, buildDir, version, buildDate); +} + +static int jm_show_version (vppjni_main_t *jm) +{ + int rv; + vl_api_show_version_t *mp; + f64 timeout; + + vppjni_lock (jm, 10); + M(SHOW_VERSION, show_version); + + S; + vppjni_unlock (jm); + WNR; + return rv; +} + +static int jm_stats_enable_disable (vppjni_main_t *jm, u8 enable) +{ + vl_api_want_stats_t * mp; + f64 timeout; + int rv; + + vppjni_lock (jm, 13); + + M(WANT_STATS, want_stats); + + mp->enable_disable = enable; + + S; + vppjni_unlock (jm); + WNR; + + // already subscribed / already disabled (it's ok) + if (rv == -2 || rv == -3) + rv = 0; + return rv; +} + +JNIEXPORT jint JNICALL Java_org_openvpp_vppjapi_vppConn_setInterfaceDescription0 + (JNIEnv *env, jobject obj, jstring ifName, jstring ifDesc) +{ + int rv = 0; + vppjni_main_t * jm = &vppjni_main; + uword * p; + u32 sw_if_index = ~0; + sw_if_config_t *cfg; + + const char *if_name_str = (*env)->GetStringUTFChars (env, ifName, 0); + const char *if_desc_str = (*env)->GetStringUTFChars (env, ifDesc, 0); + + vppjni_lock (jm, 23); + + p = hash_get_mem (jm->sw_if_index_by_interface_name, if_name_str); + if (p == 0) { + rv = -1; + goto out; + } + sw_if_index = (jint) p[0]; + + u8 *if_desc = 0; + vec_validate_init_c_string (if_desc, if_desc_str, strlen(if_desc_str)); + (*env)->ReleaseStringUTFChars (env, ifDesc, if_desc_str); + + p = hash_get (jm->sw_if_config_by_sw_if_index, sw_if_index); + if (p != 0) { + cfg = (sw_if_config_t *) (p[0]); + if (cfg->desc) + vec_free(cfg->desc); + } else { + cfg = (sw_if_config_t *) clib_mem_alloc(sizeof(sw_if_config_t)); + hash_set (jm->sw_if_config_by_sw_if_index, sw_if_index, cfg); + } + + cfg->desc = if_desc; + +out: + (*env)->ReleaseStringUTFChars (env, ifName, if_name_str); + vppjni_unlock (jm); + return rv; +} + +JNIEXPORT jstring JNICALL Java_org_openvpp_vppjapi_vppConn_getInterfaceDescription0 +(JNIEnv * env, jobject obj, jstring ifName) +{ + vppjni_main_t * jm = &vppjni_main; + u32 sw_if_index = ~0; + uword * p; + jstring ifDesc = NULL; + const char *if_name_str = (*env)->GetStringUTFChars (env, ifName, 0); + if (!if_name_str) + return NULL; + + vppjni_lock (jm, 24); + p = hash_get_mem (jm->sw_if_index_by_interface_name, if_name_str); + if (p == 0) + goto out; + + sw_if_index = (jint) p[0]; + + p = hash_get (jm->sw_if_config_by_sw_if_index, sw_if_index); + if (p == 0) + goto out; + + sw_if_config_t *cfg = (sw_if_config_t *) (p[0]); + u8 * s = format (0, "%s%c", cfg->desc, 0); + ifDesc = (*env)->NewStringUTF(env, (char *)s); + +out: + vppjni_unlock (jm); + + return ifDesc; +} + +JNIEXPORT jint JNICALL Java_org_openvpp_vppjapi_vppConn_clientConnect + (JNIEnv *env, jobject obj, jstring clientName) +{ + int rv; + const char *client_name; + void vl_msg_reply_handler_hookup(void); + vppjni_main_t * jm = &vppjni_main; + api_main_t * am = &api_main; + u8 * heap; + mheap_t * h; + f64 timeout; + + /* + * Bail out now if we're not running as root + */ + if (geteuid() != 0) + return -1; + + if (jm->is_connected) + return -2; + + client_name = (*env)->GetStringUTFChars(env, clientName, 0); + if (!client_name) + return -3; + + if (jm->heap == 0) + clib_mem_init (0, 128<<20); + + heap = clib_mem_get_per_cpu_heap(); + h = mheap_header (heap); + + clib_time_init (&jm->clib_time); + + rv = connect_to_vpe ((char *) client_name); + + if (rv < 0) + clib_warning ("connection failed, rv %d", rv); + + (*env)->ReleaseStringUTFChars (env, clientName, client_name); + + if (rv == 0) { + vl_msg_reply_handler_hookup (); + jm->is_connected = 1; + /* make the main heap thread-safe */ + h->flags |= MHEAP_FLAG_THREAD_SAFE; + + jm->reply_hash = hash_create (0, sizeof (uword)); + //jm->callback_hash = hash_create (0, sizeof (uword)); + //jm->ping_hash = hash_create (0, sizeof (uword)); + jm->api_main = am; + vjbd_main_init(&jm->vjbd_main); + jm->sw_if_index_by_interface_name = + hash_create_string (0, sizeof (uword)); + jm->sw_if_config_by_sw_if_index = + hash_create (0, sizeof (uword)); + + { + // call control ping first to attach rx thread to java thread + vl_api_control_ping_t * mp; + M(CONTROL_PING, control_ping); + S; + WNR; + + if (rv != 0) { + clib_warning ("first control ping failed: %d", rv); + } + } + rv = jm_show_version(jm); + if (rv != 0) + clib_warning ("unable to retrieve vpp version (rv: %d)", rv); + rv = sw_interface_dump(jm); + if (rv != 0) + clib_warning ("unable to retrieve interface list (rv: %d)", rv); + rv = jm_stats_enable_disable(jm, 1); + if (rv != 0) + clib_warning ("unable to subscribe to stats (rv: %d)", rv); + } + DEBUG_LOG ("clientConnect result: %d", rv); + + return rv; +} + +JNIEXPORT void JNICALL Java_org_openvpp_vppjapi_vppConn_clientDisconnect + (JNIEnv *env, jobject obj) +{ + u8 *save_heap; + vppjni_main_t * jm = &vppjni_main; + vl_client_disconnect_from_vlib(); + + save_heap = jm->heap; + memset (jm, 0, sizeof (*jm)); + jm->heap = save_heap; +} + +void vl_api_generic_reply_handler (vl_api_generic_reply_t *mp) +{ + api_main_t * am = &api_main; + u16 msg_id = clib_net_to_host_u16 (mp->_vl_msg_id); + trace_cfg_t *cfgp; + i32 retval = clib_net_to_host_u32 (mp->retval); + int total_bytes = sizeof(mp); + vppjni_main_t * jm = &vppjni_main; + u8 * saved_reply = 0; + u32 context = clib_host_to_net_u32 (mp->context); + + cfgp = am->api_trace_cfg + msg_id; + + if (!cfgp) + clib_warning ("msg id %d: no trace configuration\n", msg_id); + else + total_bytes = cfgp->size; + + jm->context_id_received = context; + + DEBUG_LOG ("Received generic reply for msg id %d", msg_id); + + /* A generic reply, successful, we're done */ + if (retval >= 0 && total_bytes == sizeof(*mp)) + return; + + /* Save the reply */ + vec_validate (saved_reply, total_bytes - 1); + memcpy (saved_reply, mp, total_bytes); + + vppjni_lock (jm, 2); + hash_set (jm->reply_hash, context, saved_reply); + jm->saved_reply_count ++; + vppjni_unlock (jm); +} + +JNIEXPORT jint JNICALL Java_org_openvpp_vppjapi_vppConn_getRetval0 +(JNIEnv * env, jobject obj, jint context, jint release) +{ + vppjni_main_t * jm = &vppjni_main; + vl_api_generic_reply_t * mp; + uword * p; + int rv = 0; + + /* Dunno yet? */ + if (context > jm->context_id_received) + return (VNET_API_ERROR_RESPONSE_NOT_READY); + + vppjni_lock (jm, 1); + p = hash_get (jm->reply_hash, context); + + /* + * Two cases: a generic "yes" reply - won't be in the hash table + * or "no", or "more data" which will be in the table. + */ + if (p == 0) + goto out; + + mp = (vl_api_generic_reply_t *) (p[0]); + rv = clib_net_to_host_u32 (mp->retval); + + if (release) { + u8 * free_me = (u8 *) mp; + vec_free (free_me); + hash_unset (jm->reply_hash, context); + jm->saved_reply_count --; + } + +out: + vppjni_unlock (jm); + return (rv); +} + +static int +name_sort_cmp (void * a1, void * a2) +{ + name_sort_t * n1 = a1; + name_sort_t * n2 = a2; + + return strcmp ((char *)n1->name, (char *)n2->name); +} + +JNIEXPORT jstring JNICALL Java_org_openvpp_vppjapi_vppConn_getInterfaceList0 + (JNIEnv * env, jobject obj, jstring name_filter) +{ + vppjni_main_t * jm = &vppjni_main; + jstring rv; + hash_pair_t * p; + name_sort_t * nses = 0, * ns; + const char *this_name; + u8 * s = 0; + const char * nf = (*env)->GetStringUTFChars (env, name_filter, NULL); + if (!nf) + return NULL; + + vppjni_lock (jm, 4); + + hash_foreach_pair (p, jm->sw_if_index_by_interface_name, + ({ + this_name = (const char *)(p->key); + if (strlen (nf) == 0 || strcasestr (this_name, nf)) { + vec_add2 (nses, ns, 1); + ns->name = (u8 *)(p->key); + ns->value = (u32) p->value[0]; + } + })); + + vec_sort_with_function (nses, name_sort_cmp); + + vec_foreach (ns, nses) + s = format (s, "%s: %d, ", ns->name, ns->value); + + _vec_len (s) = vec_len (s) - 2; + vec_terminate_c_string (s); + vppjni_unlock (jm); + + vec_free (nses); + + (*env)->ReleaseStringUTFChars (env, name_filter, nf); + + rv = (*env)->NewStringUTF (env, (char *) s); + vec_free (s); + + return rv; +} + +JNIEXPORT jint JNICALL Java_org_openvpp_vppjapi_vppConn_swIfIndexFromName0 + (JNIEnv * env, jobject obj, jstring interfaceName) +{ + vppjni_main_t * jm = &vppjni_main; + jint rv = -1; + const char * if_name = (*env)->GetStringUTFChars (env, interfaceName, NULL); + if (if_name) { + uword * p; + + vppjni_lock (jm, 5); + + p = hash_get_mem (jm->sw_if_index_by_interface_name, if_name); + + if (p != 0) + rv = (jint) p[0]; + + vppjni_unlock (jm); + + (*env)->ReleaseStringUTFChars (env, interfaceName, if_name); + } + + return rv; +} + +JNIEXPORT jobject JNICALL Java_org_openvpp_vppjapi_vppConn_getInterfaceCounters0 +(JNIEnv * env, jobject obj, jint swIfIndex) +{ + vppjni_main_t * jm = &vppjni_main; + sw_interface_stats_t *s; + u32 sw_if_index = swIfIndex; + jobject result = NULL; + + vppjni_lock (jm, 16); + + if (sw_if_index >= vec_len(jm->sw_if_stats_by_sw_if_index)) { + goto out; + } + s = &jm->sw_if_stats_by_sw_if_index[sw_if_index]; + if (!s->valid) { + goto out; + } + + result = vppInterfaceCountersObject(env, + s->rx.octets, s->rx.pkts.ip4, s->rx.pkts.ip6, s->rx.pkts.unicast, + s->rx.pkts.multicast, s->rx.pkts.broadcast, s->rx.pkts.discard, + s->rx.pkts.fifo_full, s->rx.pkts.error, s->rx.pkts.unknown_proto, + s->rx.pkts.miss, + s->tx.octets, s->tx.pkts.ip4, s->tx.pkts.ip6, s->tx.pkts.unicast, + s->tx.pkts.multicast, s->tx.pkts.broadcast, s->tx.pkts.discard, + s->tx.pkts.fifo_full, s->tx.pkts.error, s->tx.pkts.unknown_proto, + s->tx.pkts.miss); + +out: + vppjni_unlock (jm); + return result; +} + +JNIEXPORT jstring JNICALL Java_org_openvpp_vppjapi_vppConn_interfaceNameFromSwIfIndex0 +(JNIEnv * env, jobject obj, jint swIfIndex) +{ + vppjni_main_t * jm = &vppjni_main; + sw_interface_details_t *sw_if_details; + u32 sw_if_index; + jstring ifname = NULL; + + vppjni_lock (jm, 8); + + sw_if_index = swIfIndex; + + if (sw_if_index >= vec_len(jm->sw_if_table)) { + goto out; + } + sw_if_details = &jm->sw_if_table[sw_if_index]; + if (!sw_if_details->valid) { + goto out; + } + + u8 * s = format (0, "%s%c", sw_if_details->interface_name, 0); + ifname = (*env)->NewStringUTF(env, (char *)s); + +out: + vppjni_unlock (jm); + + return ifname; +} + +JNIEXPORT void JNICALL Java_org_openvpp_vppjapi_vppConn_clearInterfaceTable0 +(JNIEnv * env, jobject obj) +{ + vppjni_main_t * jm = &vppjni_main; + + vppjni_lock (jm, 21); + + vec_reset_length(jm->sw_if_table); + + vppjni_unlock (jm); +} + +static jobjectArray sw_if_dump_get_interfaces (); + +JNIEXPORT jobjectArray JNICALL Java_org_openvpp_vppjapi_vppConn_swInterfaceDump0 +(JNIEnv * env, jobject obj, jbyte name_filter_valid, jbyteArray name_filter) +{ + vppjni_main_t *jm = &vppjni_main; + f64 timeout; + vl_api_sw_interface_dump_t * mp; + u32 my_context_id; + int rv; + rv = vppjni_sanity_check (jm); + if (rv) { + clib_warning("swInterfaceDump sanity_check rv = %d", rv); + return NULL; + } + + vppjni_lock (jm, 7); + my_context_id = vppjni_get_context_id (jm); + jsize cnt = (*env)->GetArrayLength (env, name_filter); + + M(SW_INTERFACE_DUMP, sw_interface_dump); + mp->context = clib_host_to_net_u32 (my_context_id); + mp->name_filter_valid = name_filter_valid; + + if (cnt > sizeof(mp->name_filter)) + cnt = sizeof(mp->name_filter); + + (*env)->GetByteArrayRegion(env, name_filter, 0, cnt, (jbyte *)mp->name_filter); + + DEBUG_LOG ("interface filter (%d, %s, len: %d)", mp->name_filter_valid, (char *)mp->name_filter, cnt); + + jm->collect_indices = 1; + + S; + { + // now send control ping so we know when it ends + vl_api_control_ping_t * mp; + M(CONTROL_PING, control_ping); + mp->context = clib_host_to_net_u32 (my_context_id); + + S; + } + vppjni_unlock (jm); + WNR; + + vppjni_lock (jm, 7); + jobjectArray result = sw_if_dump_get_interfaces(env); + vppjni_unlock (jm); + return result; +} + +static jobjectArray sw_if_dump_get_interfaces (JNIEnv * env) +{ + vppjni_main_t * jm = &vppjni_main; + sw_interface_details_t *sw_if_details; + u32 i; + + int len = vec_len(jm->sw_if_dump_if_indices); + + jobjectArray ifArray = vppInterfaceDetailsArray(env, len); + + for (i = 0; i < len; i++) { + u32 sw_if_index = jm->sw_if_dump_if_indices[i]; + ASSERT(sw_if_index < vec_len(jm->sw_if_table)); + sw_if_details = &jm->sw_if_table[sw_if_index]; + ASSERT(sw_if_details->valid); + + u8 * s = format (0, "%s%c", sw_if_details->interface_name, 0); + + jstring ifname = (*env)->NewStringUTF(env, (char *)s); + jint ifIndex = sw_if_details->sw_if_index; + jint supIfIndex = sw_if_details->sup_sw_if_index; + jbyteArray physAddr = (*env)->NewByteArray(env, + sw_if_details->l2_address_length); + (*env)->SetByteArrayRegion(env, physAddr, 0, + sw_if_details->l2_address_length, + (signed char*)sw_if_details->l2_address); + jint subId = sw_if_details->sub_id; + jint subOuterVlanId = sw_if_details->sub_outer_vlan_id; + jint subInnerVlanId = sw_if_details->sub_inner_vlan_id; + jint vtrOp = sw_if_details->vtr_op; + jint vtrPushDot1q = sw_if_details->vtr_push_dot1q; + jint vtrTag1 = sw_if_details->vtr_tag1; + jint vtrTag2 = sw_if_details->vtr_tag2; + jint linkMtu = sw_if_details->link_mtu; + + jbyte adminUpDown = sw_if_details->admin_up_down; + jbyte linkUpDown = sw_if_details->link_up_down; + jbyte linkDuplex = sw_if_details->link_duplex; + jbyte linkSpeed = sw_if_details->link_speed; + jbyte subDot1ad = sw_if_details->sub_dot1ad; + jbyte subNumberOfTags = sw_if_details->sub_number_of_tags; + jbyte subExactMatch = sw_if_details->sub_exact_match; + jbyte subDefault = sw_if_details->sub_default; + jbyte subOuterVlanIdAny = sw_if_details->sub_outer_vlan_id_any; + jbyte subInnerVlanIdAny = sw_if_details->sub_inner_vlan_id_any; + + jobject ifObj = vppInterfaceDetailsObject(env, + ifIndex, ifname, + supIfIndex, physAddr, adminUpDown, linkUpDown, + linkDuplex, linkSpeed, subId, subDot1ad, + subNumberOfTags, subOuterVlanId, subInnerVlanId, + subExactMatch, subDefault, subOuterVlanIdAny, + subInnerVlanIdAny, vtrOp, vtrPushDot1q, vtrTag1, vtrTag2, linkMtu); + (*env)->SetObjectArrayElement(env, ifArray, i, ifObj); + } + + jm->collect_indices = 0; + vec_reset_length(jm->sw_if_dump_if_indices); + return ifArray; +} + +JNIEXPORT jint JNICALL Java_org_openvpp_vppjapi_vppConn_findOrAddBridgeDomainId0 + (JNIEnv * env, jobject obj, jstring bridgeDomain) +{ + vppjni_main_t * jm = &vppjni_main; + jint rv = -1; + const char * bdName = (*env)->GetStringUTFChars (env, bridgeDomain, NULL); + if (bdName) { + static u8 * bd_name = 0; + + vec_validate_init_c_string (bd_name, bdName, strlen(bdName)); + (*env)->ReleaseStringUTFChars (env, bridgeDomain, bdName); + + vppjni_lock (jm, 6); + rv = (jint)vjbd_find_or_add_bd (&jm->vjbd_main, bd_name); + vppjni_unlock (jm); + + _vec_len(bd_name) = 0; + } + return rv; +} + +JNIEXPORT jint JNICALL Java_org_openvpp_vppjapi_vppConn_bridgeDomainIdFromName0 + (JNIEnv * env, jobject obj, jstring bridgeDomain) +{ + vppjni_main_t * jm = &vppjni_main; + jint rv = -1; + const char * bdName = (*env)->GetStringUTFChars (env, bridgeDomain, NULL); + if (bdName) { + static u8 * bd_name = 0; + + vec_validate_init_c_string (bd_name, bdName, strlen(bdName)); + (*env)->ReleaseStringUTFChars (env, bridgeDomain, bdName); + + vppjni_lock (jm, 20); + rv = (jint)vjbd_id_from_name(&jm->vjbd_main, (u8 *)bd_name); + vppjni_unlock (jm); + + _vec_len(bd_name) = 0; + } + + return rv; +} + +JNIEXPORT jint JNICALL Java_org_openvpp_vppjapi_vppConn_bridgeDomainIdFromInterfaceName0 + (JNIEnv * env, jobject obj, jstring interfaceName) +{ + vppjni_main_t * jm = &vppjni_main; + vjbd_main_t * bdm = &jm->vjbd_main; + u32 sw_if_index; + jint rv = -1; + const char * if_name; + uword * p; + + if_name = (*env)->GetStringUTFChars (env, interfaceName, NULL); + + vppjni_lock (jm, 14); + + p = hash_get_mem (jm->sw_if_index_by_interface_name, if_name); + + if (p != 0) { + sw_if_index = (jint) p[0]; + p = hash_get (bdm->bd_id_by_sw_if_index, sw_if_index); + if (p != 0) { + rv = (jint) p[0]; + } + } + + vppjni_unlock (jm); + + (*env)->ReleaseStringUTFChars (env, interfaceName, if_name); + + return rv; +} + +/* + * Special-case: build the interface table, maintain + * the next loopback sw_if_index vbl. + */ +static void vl_api_sw_interface_details_t_handler +(vl_api_sw_interface_details_t * mp) +{ + vppjni_main_t * jm = &vppjni_main; + static sw_interface_details_t empty_sw_if_details = {0,}; + sw_interface_details_t *sw_if_details; + u32 sw_if_index; + + vppjni_lock (jm, 1); + + sw_if_index = ntohl (mp->sw_if_index); + + u8 * s = format (0, "%s%c", mp->interface_name, 0); + + if (jm->collect_indices) { + u32 pos = vec_len(jm->sw_if_dump_if_indices); + vec_validate(jm->sw_if_dump_if_indices, pos); + jm->sw_if_dump_if_indices[pos] = sw_if_index; + } + + vec_validate_init_empty(jm->sw_if_table, sw_if_index, empty_sw_if_details); + sw_if_details = &jm->sw_if_table[sw_if_index]; + sw_if_details->valid = 1; + + snprintf((char *)sw_if_details->interface_name, + sizeof(sw_if_details->interface_name), "%s", (char *)s); + sw_if_details->sw_if_index = sw_if_index; + sw_if_details->sup_sw_if_index = ntohl(mp->sup_sw_if_index); + sw_if_details->l2_address_length = ntohl (mp->l2_address_length); + ASSERT(sw_if_details->l2_address_length <= sizeof(sw_if_details->l2_address)); + memcpy(sw_if_details->l2_address, mp->l2_address, + sw_if_details->l2_address_length); + sw_if_details->sub_id = ntohl (mp->sub_id); + sw_if_details->sub_outer_vlan_id = ntohl (mp->sub_outer_vlan_id); + sw_if_details->sub_inner_vlan_id = ntohl (mp->sub_inner_vlan_id); + sw_if_details->vtr_op = ntohl (mp->vtr_op); + sw_if_details->vtr_push_dot1q = ntohl (mp->vtr_push_dot1q); + sw_if_details->vtr_tag1 = ntohl (mp->vtr_tag1); + sw_if_details->vtr_tag2 = ntohl (mp->vtr_tag2); + + sw_if_details->admin_up_down = mp->admin_up_down; + sw_if_details->link_up_down = mp->link_up_down; + sw_if_details->link_duplex = mp->link_duplex; + sw_if_details->link_speed = mp->link_speed; + sw_if_details->sub_dot1ad = mp->sub_dot1ad; + sw_if_details->sub_number_of_tags = mp->sub_number_of_tags; + sw_if_details->sub_exact_match = mp->sub_exact_match; + sw_if_details->sub_default = mp->sub_default; + sw_if_details->sub_outer_vlan_id_any = mp->sub_outer_vlan_id_any; + sw_if_details->sub_inner_vlan_id_any = mp->sub_inner_vlan_id_any; + + hash_set_mem (jm->sw_if_index_by_interface_name, s, sw_if_index); + DEBUG_LOG ("Got interface %s", (char *)s); + + /* In sub interface case, fill the sub interface table entry */ + if (mp->sw_if_index != mp->sup_sw_if_index) { + sw_interface_subif_t * sub = NULL; + + vec_add2(jm->sw_if_subif_table, sub, 1); + + vec_validate(sub->interface_name, strlen((char *)s) + 1); + strncpy((char *)sub->interface_name, (char *)s, + vec_len(sub->interface_name)); + sub->sw_if_index = ntohl(mp->sw_if_index); + sub->sub_id = ntohl(mp->sub_id); + + sub->sub_dot1ad = mp->sub_dot1ad; + sub->sub_number_of_tags = mp->sub_number_of_tags; + sub->sub_outer_vlan_id = ntohs(mp->sub_outer_vlan_id); + sub->sub_inner_vlan_id = ntohs(mp->sub_inner_vlan_id); + sub->sub_exact_match = mp->sub_exact_match; + sub->sub_default = mp->sub_default; + sub->sub_outer_vlan_id_any = mp->sub_outer_vlan_id_any; + sub->sub_inner_vlan_id_any = mp->sub_inner_vlan_id_any; + + /* vlan tag rewrite */ + sub->vtr_op = ntohl(mp->vtr_op); + sub->vtr_push_dot1q = ntohl(mp->vtr_push_dot1q); + sub->vtr_tag1 = ntohl(mp->vtr_tag1); + sub->vtr_tag2 = ntohl(mp->vtr_tag2); + } + vppjni_unlock (jm); +} + +static void vl_api_sw_interface_set_flags_t_handler +(vl_api_sw_interface_set_flags_t * mp) +{ + /* $$$ nothing for the moment */ +} + +static jintArray create_array_of_bd_ids(JNIEnv * env, jint bd_id) +{ + vppjni_main_t *jm = &vppjni_main; + vjbd_main_t * bdm = &jm->vjbd_main; + u32 *buf = NULL; + u32 i; + + if (bd_id != ~0) { + vec_add1(buf, bd_id); + } else { + for (i = 0; i < vec_len(bdm->bd_oper); i++) { + u32 bd_id = bdm->bd_oper[i].bd_id; + vec_add1(buf, bd_id); + } + } + + jintArray bdidArray = (*env)->NewIntArray(env, vec_len(buf)); + if (!bdidArray) { + goto out; + } + + (*env)->SetIntArrayRegion(env, bdidArray, 0, vec_len(buf), (int*)buf); + +out: + vec_free(buf); + return bdidArray; +} + +static void bridge_domain_oper_free(void) +{ + vppjni_main_t *jm = &vppjni_main; + vjbd_main_t *bdm = &jm->vjbd_main; + u32 i; + + for (i = 0; i < vec_len(bdm->bd_oper); i++) { + vec_free(bdm->bd_oper->l2fib_oper); + } + vec_reset_length(bdm->bd_oper); + hash_free(bdm->bd_id_by_sw_if_index); + hash_free(bdm->oper_bd_index_by_bd_id); +} + +JNIEXPORT jintArray JNICALL Java_org_openvpp_vppjapi_vppConn_bridgeDomainDump0 +(JNIEnv * env, jobject obj, jint bd_id) +{ + vppjni_main_t *jm = &vppjni_main; + vl_api_bridge_domain_dump_t * mp; + u32 my_context_id; + f64 timeout; + int rv; + rv = vppjni_sanity_check (jm); + if (rv) return NULL; + + vppjni_lock (jm, 15); + + if (~0 == bd_id) { + bridge_domain_oper_free(); + } + + my_context_id = vppjni_get_context_id (jm); + M(BRIDGE_DOMAIN_DUMP, bridge_domain_dump); + mp->context = clib_host_to_net_u32 (my_context_id); + mp->bd_id = clib_host_to_net_u32(bd_id); + S; + + /* Use a control ping for synchronization */ + { + vl_api_control_ping_t * mp; + M(CONTROL_PING, control_ping); + S; + } + + WNR; + if (0 != rv) { + return NULL; + } + + jintArray ret = create_array_of_bd_ids(env, bd_id); + + vppjni_unlock (jm); + + return ret; +} + +static void +vl_api_bridge_domain_details_t_handler (vl_api_bridge_domain_details_t * mp) +{ + vppjni_main_t *jm = &vppjni_main; + vjbd_main_t * bdm = &jm->vjbd_main; + vjbd_oper_t * bd_oper; + u32 bd_id, bd_index; + + bd_id = ntohl (mp->bd_id); + + bd_index = vec_len(bdm->bd_oper); + vec_validate (bdm->bd_oper, bd_index); + bd_oper = vec_elt_at_index(bdm->bd_oper, bd_index); + + hash_set(bdm->oper_bd_index_by_bd_id, bd_id, bd_index); + + bd_oper->bd_id = bd_id; + bd_oper->flood = mp->flood != 0; + bd_oper->forward = mp->forward != 0; + bd_oper->learn = mp->learn != 0; + bd_oper->uu_flood = mp->uu_flood != 0; + bd_oper->arp_term = mp->arp_term != 0; + bd_oper->bvi_sw_if_index = ntohl (mp->bvi_sw_if_index); + bd_oper->n_sw_ifs = ntohl (mp->n_sw_ifs); + + bd_oper->bd_sw_if_oper = 0; +} + +static void +vl_api_bridge_domain_sw_if_details_t_handler +(vl_api_bridge_domain_sw_if_details_t * mp) +{ + vppjni_main_t *jm = &vppjni_main; + vjbd_main_t * bdm = &jm->vjbd_main; + bd_sw_if_oper_t * bd_sw_if_oper; + u32 bd_id, sw_if_index; + + bd_id = ntohl (mp->bd_id); + sw_if_index = ntohl (mp->sw_if_index); + + uword *p; + p = hash_get (bdm->oper_bd_index_by_bd_id, bd_id); + if (p == 0) { + clib_warning("Invalid bd_id %d in bridge_domain_sw_if_details_t_handler", bd_id); + return; + } + u32 oper_bd_index = (jint) p[0]; + vjbd_oper_t *bd_oper = vec_elt_at_index(bdm->bd_oper, oper_bd_index); + + u32 len = vec_len(bd_oper->bd_sw_if_oper); + vec_validate(bd_oper->bd_sw_if_oper, len); + bd_sw_if_oper = &bd_oper->bd_sw_if_oper[len]; + bd_sw_if_oper->bd_id = bd_id; + bd_sw_if_oper->sw_if_index = sw_if_index; + bd_sw_if_oper->shg = mp->shg; + + hash_set(bdm->bd_id_by_sw_if_index, sw_if_index, bd_id); +} + +static const char* interface_name_from_sw_if_index(u32 sw_if_index) +{ + vppjni_main_t *jm = &vppjni_main; + + if (sw_if_index >= vec_len(jm->sw_if_table)) { + return NULL; + } + if (!jm->sw_if_table[sw_if_index].valid) { + return NULL; + } + return (const char*)jm->sw_if_table[sw_if_index].interface_name; +} + +JNIEXPORT jobject JNICALL Java_org_openvpp_vppjapi_vppConn_getBridgeDomainDetails0 +(JNIEnv * env, jobject obj, jint bdId) +{ + vppjni_main_t *jm = &vppjni_main; + vjbd_main_t * bdm = &jm->vjbd_main; + u32 oper_bd_index; + u32 bd_id = bdId; + jobject rv = NULL; + uword *p; + + vppjni_lock (jm, 16); + + p = hash_get (bdm->oper_bd_index_by_bd_id, bd_id); + if (p == 0) { + rv = NULL; + goto out; + } + oper_bd_index = (jint) p[0]; + + vjbd_oper_t *bd_oper = vec_elt_at_index(bdm->bd_oper, oper_bd_index); + + + /* setting BridgeDomainDetails */ + + jobject bddObj = vppBridgeDomainDetailsObject(env); + + u8 *vec_bd_name = vjbd_oper_name_from_id(bdm, bd_id); + if (NULL == vec_bd_name) { + rv = NULL; + goto out; + } + char *str_bd_name = (char*)format (0, "%s%c", vec_bd_name, 0); + vec_free(vec_bd_name); + jstring bdName = (*env)->NewStringUTF(env, str_bd_name); + vec_free(str_bd_name); + if (NULL == bdName) { + rv = NULL; + goto out; + } + + set_vppBridgeDomainDetails_name(env, bddObj, bdName); + set_vppBridgeDomainDetails_bdId(env, bddObj, bdId); + set_vppBridgeDomainDetails_flood(env, bddObj, (jboolean)bd_oper->flood); + set_vppBridgeDomainDetails_uuFlood(env, bddObj, (jboolean)bd_oper->uu_flood); + set_vppBridgeDomainDetails_forward(env, bddObj, (jboolean)bd_oper->forward); + set_vppBridgeDomainDetails_learn(env, bddObj, (jboolean)bd_oper->learn); + set_vppBridgeDomainDetails_arpTerm(env, bddObj, (jboolean)bd_oper->arp_term); + + jstring bviInterfaceName = NULL; + if (~0 != bd_oper->bvi_sw_if_index) { + const char *str_if_name = interface_name_from_sw_if_index(bd_oper->bvi_sw_if_index); + if (NULL == str_if_name) { + clib_warning("Could not get interface name for sw_if_index %d", bd_oper->bvi_sw_if_index); + rv = NULL; + goto out; + } + bviInterfaceName = (*env)->NewStringUTF(env, str_if_name); + if (NULL == bviInterfaceName) { + rv = NULL; + goto out; + } + } + + set_vppBridgeDomainDetails_bviInterfaceName(env, bddObj, bviInterfaceName); + + /* setting BridgeDomainInterfaceDetails */ + + u32 len = vec_len(bd_oper->bd_sw_if_oper); + ASSERT(len == bd_oper->n_sw_ifs); + + jobjectArray bdidArray = vppBridgeDomainInterfaceDetailsArray(env, len); + + u32 i; + for (i = 0; i < len; i++) { + bd_sw_if_oper_t *sw_if_oper = &bd_oper->bd_sw_if_oper[i]; + + jobject bdidObj = vppBridgeDomainInterfaceDetailsObject(env); + (*env)->SetObjectArrayElement(env, bdidArray, i, bdidObj); + + u32 sw_if_index = sw_if_oper->sw_if_index; + const char *str_if_name = interface_name_from_sw_if_index(sw_if_index); + if (NULL == str_if_name) { + rv = NULL; + goto out; + } + jstring interfaceName = (*env)->NewStringUTF(env, str_if_name); + if (NULL == interfaceName) { + rv = NULL; + goto out; + } + + set_vppBridgeDomainInterfaceDetails_interfaceName(env, bdidObj, interfaceName); + set_vppBridgeDomainInterfaceDetails_splitHorizonGroup(env, bdidObj, (jbyte)sw_if_oper->shg); + } + + set_vppBridgeDomainDetails_interfaces(env, bddObj, bdidArray); + + rv = bddObj; + +out: + + vppjni_unlock (jm); + + return rv; +} + +static jobject l2_fib_create_object(JNIEnv *env, bd_l2fib_oper_t *l2_fib) +{ + u32 sw_if_index = l2_fib->sw_if_index; + const char *str_if_name = interface_name_from_sw_if_index(sw_if_index); + if (NULL == str_if_name) { + return NULL; + } + jstring interfaceName = (*env)->NewStringUTF(env, str_if_name); + if (NULL == interfaceName) { + return NULL; + } + + jbyteArray physAddr = (*env)->NewByteArray(env, 6); + (*env)->SetByteArrayRegion(env, physAddr, 0, 6, + (signed char*)l2_fib->mac_addr.fields.mac); + jboolean staticConfig = !l2_fib->learned; + jstring outgoingInterface = interfaceName; + jboolean filter = l2_fib->filter; + jboolean bridgedVirtualInterface = l2_fib->bvi; + + return vppL2FibObject(env, physAddr, staticConfig, outgoingInterface, filter, bridgedVirtualInterface); +} + +JNIEXPORT jobjectArray JNICALL Java_org_openvpp_vppjapi_vppConn_l2FibTableDump0 +(JNIEnv * env, jobject obj, jint bd_id) +{ + vppjni_main_t *jm = &vppjni_main; + vjbd_main_t * bdm = &jm->vjbd_main; + vl_api_l2_fib_table_dump_t *mp; + jobjectArray l2FibArray = NULL; + vjbd_oper_t *bd_oper; + u32 oper_bd_index; + uword *p; + f64 timeout; + int rv; + u32 i; + + vppjni_lock (jm, 17); + + //vjbd_l2fib_oper_reset (bdm); + + p = hash_get (bdm->oper_bd_index_by_bd_id, bd_id); + if (p == 0) { + goto done; + } + oper_bd_index = p[0]; + bd_oper = vec_elt_at_index(bdm->bd_oper, oper_bd_index); + vec_reset_length (bd_oper->l2fib_oper); + + /* Get list of l2 fib table entries */ + M(L2_FIB_TABLE_DUMP, l2_fib_table_dump); + mp->bd_id = ntohl(bd_id); + S; + + /* Use a control ping for synchronization */ + { + vl_api_control_ping_t * mp; + M(CONTROL_PING, control_ping); + S; + } + + WNR; + if (0 != rv) { + goto done; + } + + u32 count = vec_len(bd_oper->l2fib_oper); + bd_l2fib_oper_t *l2fib_oper = bd_oper->l2fib_oper; + + l2FibArray = vppL2FibArray(env, count); + for (i = 0; i < count; i++) { + bd_l2fib_oper_t *l2_fib = &l2fib_oper[i]; + jobject l2FibObj = l2_fib_create_object(env, l2_fib); + (*env)->SetObjectArrayElement(env, l2FibArray, i, l2FibObj); + } + +done: + vppjni_unlock (jm); + + return l2FibArray; +} + +static void +vl_api_l2_fib_table_entry_t_handler (vl_api_l2_fib_table_entry_t * mp) +{ + //static u8 * mac_addr; + vppjni_main_t *jm = &vppjni_main; + vjbd_main_t * bdm = &jm->vjbd_main; + vjbd_oper_t * bd_oper; + u32 bd_id, oper_bd_index; + //uword mhash_val_l2fi; + bd_l2fib_oper_t * l2fib_oper; + l2fib_u64_mac_t * l2fe_u64_mac = (l2fib_u64_mac_t *)&mp->mac; + + bd_id = ntohl (mp->bd_id); + + uword *p = hash_get (bdm->oper_bd_index_by_bd_id, bd_id); + if (p == 0) { + return; + } + oper_bd_index = (jint) p[0]; + bd_oper = vec_elt_at_index(bdm->bd_oper, oper_bd_index); + +#if 0 + vec_validate (mac_addr, MAC_ADDRESS_SIZE); + memcpy (mac_addr, l2fe_u64_mac->fields.mac, MAC_ADDRESS_SIZE); + mhash_val_l2fi = vec_len (bd_oper->l2fib_oper); + if (mhash_elts (&bd_oper->l2fib_index_by_mac) == 0) + mhash_init (&bd_oper->l2fib_index_by_mac, sizeof (u32), MAC_ADDRESS_SIZE); + mhash_set_mem (&bd_oper->l2fib_index_by_mac, mac_addr, &mhash_val_l2fi, 0); +#endif + + vec_add2 (bd_oper->l2fib_oper, l2fib_oper, 1); + + l2fib_oper->bd_id = bd_id; + l2fib_oper->mac_addr.raw = l2fib_mac_to_u64 (l2fe_u64_mac->fields.mac); + l2fib_oper->sw_if_index = ntohl (mp->sw_if_index); + l2fib_oper->learned = !mp->static_mac; + l2fib_oper->filter = mp->filter_mac; + l2fib_oper->bvi = mp->bvi_mac; +} + +static int ipAddressDump +(JNIEnv * env, jobject obj, jstring interfaceName, jboolean isIPv6) +{ + vppjni_main_t *jm = &vppjni_main; + vl_api_ip_address_dump_t * mp; + const char *if_name; + u32 my_context_id; + u32 sw_if_index; + f64 timeout; + uword *p; + int rv = 0; + + if (NULL == interfaceName) { + return -1; + } + + if_name = (*env)->GetStringUTFChars (env, interfaceName, NULL); + if (!if_name) { + return -1; + } + + p = hash_get_mem (jm->sw_if_index_by_interface_name, if_name); + (*env)->ReleaseStringUTFChars (env, interfaceName, if_name); + if (p == 0) { + return -1; + } + sw_if_index = (u32) p[0]; + + rv = vppjni_sanity_check (jm); + if (0 != rv) { + return rv; + } + + my_context_id = vppjni_get_context_id (jm); + M(IP_ADDRESS_DUMP, ip_address_dump); + mp->context = clib_host_to_net_u32 (my_context_id); + mp->sw_if_index = clib_host_to_net_u32(sw_if_index); + mp->is_ipv6 = isIPv6; + jm->is_ipv6 = isIPv6; + S; + + /* Use a control ping for synchronization */ + { + vl_api_control_ping_t * mp; + M(CONTROL_PING, control_ping); + S; + } + + WNR; + + return rv; +} + +JNIEXPORT jobjectArray JNICALL Java_org_openvpp_vppjapi_vppConn_ipv4AddressDump0 +(JNIEnv * env, jobject obj, jstring interfaceName) +{ + vppjni_main_t *jm = &vppjni_main; + jobject returnArray = NULL; + int i; + + vppjni_lock (jm, 18); + + vec_reset_length(jm->ipv4_addresses); + + if (0 != ipAddressDump(env, obj, interfaceName, 0)) { + goto done; + } + + u32 count = vec_len(jm->ipv4_addresses); + ipv4_address_t *ipv4_address = jm->ipv4_addresses; + + jobjectArray ipv4AddressArray = vppIPv4AddressArray(env, count); + + for (i = 0; i < count; i++) { + ipv4_address_t *address = &ipv4_address[i]; + + jint ip = address->ip; + jbyte prefixLength = address->prefix_length; + + jobject ipv4AddressObj = vppIPv4AddressObject(env, ip, prefixLength); + + (*env)->SetObjectArrayElement(env, ipv4AddressArray, i, ipv4AddressObj); + } + + returnArray = ipv4AddressArray; + +done: + vppjni_unlock (jm); + return returnArray; +} + +JNIEXPORT jobjectArray JNICALL Java_org_openvpp_vppjapi_vppConn_ipv6AddressDump0 +(JNIEnv * env, jobject obj, jstring interfaceName) +{ + vppjni_main_t *jm = &vppjni_main; + jobject returnArray = NULL; + int i; + + vppjni_lock (jm, 19); + + vec_reset_length(jm->ipv6_addresses); + + if (0 != ipAddressDump(env, obj, interfaceName, 1)) { + goto done; + } + + u32 count = vec_len(jm->ipv6_addresses); + ipv6_address_t *ipv6_address = jm->ipv6_addresses; + + jobjectArray ipv6AddressArray = vppIPv6AddressArray(env, count); + + for (i = 0; i < count; i++) { + ipv6_address_t *address = &ipv6_address[i]; + + jbyteArray ip = (*env)->NewByteArray(env, 16); + (*env)->SetByteArrayRegion(env, ip, 0, 16, + (signed char*)address->ip); + + jbyte prefixLength = address->prefix_length; + + jobject ipv6AddressObj = vppIPv6AddressObject(env, ip, prefixLength); + + (*env)->SetObjectArrayElement(env, ipv6AddressArray, i, ipv6AddressObj); + } + + returnArray = ipv6AddressArray; + +done: + vppjni_unlock (jm); + return returnArray; +} + +static void vl_api_ip_address_details_t_handler (vl_api_ip_address_details_t * mp) +{ + vppjni_main_t * jm = &vppjni_main; + + if (!jm->is_ipv6) { + ipv4_address_t *address = 0; + vec_add2(jm->ipv4_addresses, address, 1); + memcpy(&address->ip, mp->ip, 4); + address->prefix_length = mp->prefix_length; + } else { + ipv6_address_t *address = 0; + vec_add2(jm->ipv6_addresses, address, 1); + memcpy(address->ip, mp->ip, 16); + address->prefix_length = mp->prefix_length; + } +} + +#define VXLAN_TUNNEL_INTERFACE_NAME_PREFIX "vxlan_tunnel" + +JNIEXPORT jobjectArray JNICALL Java_org_openvpp_vppjapi_vppConn_vxlanTunnelDump0 +(JNIEnv * env, jobject obj, jint swIfIndex) +{ + vppjni_main_t *jm = &vppjni_main; + vl_api_vxlan_tunnel_dump_t * mp; + jobjectArray returnArray = NULL; + u32 my_context_id; + f64 timeout; + int rv = 0; + int i; + + vppjni_lock (jm, 22); + + vec_reset_length(jm->vxlan_tunnel_details); + + my_context_id = vppjni_get_context_id (jm); + M(VXLAN_TUNNEL_DUMP, vxlan_tunnel_dump); + mp->context = clib_host_to_net_u32 (my_context_id); + mp->sw_if_index = clib_host_to_net_u32 (swIfIndex); + S; + + /* Use a control ping for synchronization */ + { + vl_api_control_ping_t * mp; + M(CONTROL_PING, control_ping); + S; + } + + WNR; + if (0 != rv) { + goto done; + } + + u32 count = vec_len(jm->vxlan_tunnel_details); + + jobjectArray vxlanTunnelDetailsArray = vppVxlanTunnelDetailsArray(env, count); + + for (i = 0; i < count; i++) { + vxlan_tunnel_details_t *details = &jm->vxlan_tunnel_details[i]; + + jint src_address = details->src_address; + jint dst_address = details->dst_address; + jint encap_vrf_id = details->encap_vrf_id; + jint vni = details->vni; + jint decap_next_index = details->decap_next_index; + + jobject vxlanTunnelDetailsObj = vppVxlanTunnelDetailsObject(env, + src_address, dst_address, encap_vrf_id, vni, decap_next_index); + + (*env)->SetObjectArrayElement(env, vxlanTunnelDetailsArray, i, + vxlanTunnelDetailsObj); + } + + returnArray = vxlanTunnelDetailsArray; + +done: + vppjni_unlock (jm); + return returnArray; +} + +static void vl_api_vxlan_tunnel_details_t_handler +(vl_api_vxlan_tunnel_details_t * mp) +{ + vppjni_main_t * jm = &vppjni_main; + vxlan_tunnel_details_t *tunnel_details; + + vec_add2(jm->vxlan_tunnel_details, tunnel_details, 1); + tunnel_details->src_address = ntohl(mp->src_address); + tunnel_details->dst_address = ntohl(mp->dst_address); + tunnel_details->encap_vrf_id = ntohl(mp->encap_vrf_id); + tunnel_details->vni = ntohl(mp->vni); + tunnel_details->decap_next_index = ntohl(mp->decap_next_index); +} + +/* cleanup handler for RX thread */ +static void cleanup_rx_thread(void *arg) +{ + vppjni_main_t * jm = &vppjni_main; + + vppjni_lock (jm, 99); + + int getEnvStat = (*jm->jvm)->GetEnv(jm->jvm, (void **)&(jm->jenv), JNI_VERSION_1_6); + if (getEnvStat == JNI_EVERSION) { + clib_warning ("Unsupported JNI version\n"); + jm->retval = -999; + goto out; + } else if (getEnvStat != JNI_EDETACHED) { + (*jm->jvm)->DetachCurrentThread(jm->jvm); + } +out: + vppjni_unlock (jm); +} + +static void +vl_api_show_version_reply_t_handler (vl_api_show_version_reply_t * mp) +{ + vppjni_main_t * jm = &vppjni_main; + i32 retval = ntohl(mp->retval); + + if (retval >= 0) { + DEBUG_LOG ("show version request succeeded(%d)"); + strncpy((char*)jm->program_name, (const char*)mp->program, + sizeof(jm->program_name)-1); + jm->program_name[sizeof(jm->program_name)-1] = 0; + + strncpy((char*)jm->build_directory, (const char*)mp->build_directory, + sizeof(jm->build_directory)-1); + jm->build_directory[sizeof(jm->build_directory)-1] = 0; + + strncpy((char*)jm->version, (const char*)mp->version, + sizeof(jm->version)-1); + jm->version[sizeof(jm->version)-1] = 0; + + strncpy((char*)jm->build_date, (const char*)mp->build_date, + sizeof(jm->build_date)-1); + jm->build_date[sizeof(jm->build_date)-1] = 0; + } else { + clib_error ("show version request failed(%d)", retval); + } + jm->retval = retval; + jm->result_ready = 1; +} + +static void vl_api_want_stats_reply_t_handler (vl_api_want_stats_reply_t * mp) +{ + vppjni_main_t * jm = &vppjni_main; + jm->retval = mp->retval; // FIXME: vpp api does not do ntohl on this retval + jm->result_ready = 1; +} + +// control ping needs to be very first thing called +// to attach rx thread to java thread +static void vl_api_control_ping_reply_t_handler +(vl_api_control_ping_reply_t * mp) +{ + vppjni_main_t * jm = &vppjni_main; + i32 retval = ntohl(mp->retval); + jm->retval = retval; + + // attach to java thread if not attached + int getEnvStat = (*jm->jvm)->GetEnv(jm->jvm, (void **)&(jm->jenv), JNI_VERSION_1_6); + if (getEnvStat == JNI_EDETACHED) { + if ((*jm->jvm)->AttachCurrentThread(jm->jvm, (void **)&(jm->jenv), NULL) != 0) { + clib_warning("Failed to attach thread\n"); + jm->retval = -999; + goto out; + } + + // workaround as we can't use pthread_cleanup_push + pthread_key_create(&jm->cleanup_rx_thread_key, cleanup_rx_thread); + // destructor is only called if the value of key is non null + pthread_setspecific(jm->cleanup_rx_thread_key, (void *)1); + } else if (getEnvStat == JNI_EVERSION) { + clib_warning ("Unsupported JNI version\n"); + jm->retval = -999; + goto out; + } + // jm->jenv is now stable global reference that can be reused (only within RX thread) + +#if 0 + // ! callback system removed for now + // + // get issuer msg-id + p = hash_get (jm->ping_hash, context); + if (p != 0) { // ping marks end of some dump call + JNIEnv *env = jm->jenv; + u16 msg_id = (u16)p[0]; + + // we will no longer need this + hash_unset (jm->ping_hash, context); + + // get original caller obj + p = hash_get (jm->callback_hash, context); + + if (p == 0) // don't have callback stored + goto out; + + jobject obj = (jobject)p[0]; // object that called original call + + switch (msg_id) { + case VL_API_SW_INTERFACE_DUMP: + if (0 != sw_if_dump_call_all_callbacks(obj)) { + goto out2; + } + break; + default: + clib_warning("Unhandled control ping issuer msg-id: %d", msg_id); + goto out2; + break; + } +out2: + // free the saved obj + hash_unset (jm->callback_hash, context); + // delete global reference + (*env)->DeleteGlobalRef(env, obj); + } +#endif + +out: + jm->result_ready = 1; +} + +#define VPPJNI_DEBUG_COUNTERS 0 + +static void vl_api_vnet_interface_counters_t_handler +(vl_api_vnet_interface_counters_t *mp) +{ + vppjni_main_t *jm = &vppjni_main; + CLIB_UNUSED(char *counter_name); + u32 count, sw_if_index; + int i; + static sw_interface_stats_t empty_stats = {0, }; + + vppjni_lock (jm, 12); + count = ntohl (mp->count); + sw_if_index = ntohl (mp->first_sw_if_index); + if (mp->is_combined == 0) { + u64 * vp, v; + vp = (u64 *) mp->data; + + for (i = 0; i < count; i++) { + sw_interface_details_t *sw_if = NULL; + + v = clib_mem_unaligned (vp, u64); + v = clib_net_to_host_u64 (v); + vp++; + + if (sw_if_index < vec_len(jm->sw_if_table)) + sw_if = vec_elt_at_index(jm->sw_if_table, sw_if_index); + + if (sw_if /* && (sw_if->admin_up_down == 1)*/ && sw_if->interface_name[0] != 0) { + vec_validate_init_empty(jm->sw_if_stats_by_sw_if_index, sw_if_index, empty_stats); + sw_interface_stats_t * s = vec_elt_at_index(jm->sw_if_stats_by_sw_if_index, sw_if_index); + + s->sw_if_index = sw_if_index; + s->valid = 1; + + switch (mp->vnet_counter_type) { + case VNET_INTERFACE_COUNTER_DROP: + counter_name = "drop"; + s->rx.pkts.discard = v; + break; + case VNET_INTERFACE_COUNTER_PUNT: + counter_name = "punt"; + s->rx.pkts.unknown_proto = v; + break; + case VNET_INTERFACE_COUNTER_IP4: + counter_name = "ip4"; + s->rx.pkts.ip4 = v; + break; + case VNET_INTERFACE_COUNTER_IP6: + counter_name = "ip6"; + s->rx.pkts.ip6 = v; + break; + case VNET_INTERFACE_COUNTER_RX_NO_BUF: + counter_name = "rx-no-buf"; + s->rx.pkts.fifo_full = v; + break; + case VNET_INTERFACE_COUNTER_RX_MISS: + counter_name = "rx-miss"; + s->rx.pkts.miss = v; + break; + case VNET_INTERFACE_COUNTER_RX_ERROR: + counter_name = "rx-error"; + s->rx.pkts.error = v; + break; + case VNET_INTERFACE_COUNTER_TX_ERROR: + counter_name = "tx-error (fifo-full)"; + s->tx.pkts.fifo_full = v; + break; + default: + counter_name = "bogus"; + break; + } + +#if VPPJNI_DEBUG_COUNTERS == 1 + clib_warning ("%s (%d): %s (%lld)\n", sw_if->interface_name, s->sw_if_index, + counter_name, v); +#endif + } + sw_if_index++; + } + } else { + vlib_counter_t *vp; + u64 packets, bytes; + vp = (vlib_counter_t *) mp->data; + + for (i = 0; i < count; i++) { + sw_interface_details_t *sw_if = NULL; + + packets = clib_mem_unaligned (&vp->packets, u64); + packets = clib_net_to_host_u64 (packets); + bytes = clib_mem_unaligned (&vp->bytes, u64); + bytes = clib_net_to_host_u64 (bytes); + vp++; + + if (sw_if_index < vec_len(jm->sw_if_table)) + sw_if = vec_elt_at_index(jm->sw_if_table, sw_if_index); + + if (sw_if /* && (sw_if->admin_up_down == 1) */ && sw_if->interface_name[0] != 0) { + vec_validate_init_empty(jm->sw_if_stats_by_sw_if_index, sw_if_index, empty_stats); + sw_interface_stats_t * s = vec_elt_at_index(jm->sw_if_stats_by_sw_if_index, sw_if_index); + + s->valid = 1; + s->sw_if_index = sw_if_index; + + switch (mp->vnet_counter_type) { + case VNET_INTERFACE_COUNTER_RX: + s->rx.pkts.unicast = packets; + s->rx.octets = bytes; + counter_name = "rx"; + break; + + case VNET_INTERFACE_COUNTER_TX: + s->tx.pkts.unicast = packets; + s->tx.octets = bytes; + counter_name = "tx"; + break; + + default: + counter_name = "bogus"; + break; + } + +#if VPPJNI_DEBUG_COUNTERS == 1 + clib_warning ("%s (%d): %s.packets %lld\n", + sw_if->interface_name, + sw_if_index, counter_name, packets); + clib_warning ("%s (%d): %s.bytes %lld\n", + sw_if->interface_name, + sw_if_index, counter_name, bytes); +#endif + } + sw_if_index++; + } + } + vppjni_unlock (jm); +} + +jint JNI_OnLoad(JavaVM *vm, void *reserved) { + vppjni_main_t * jm = &vppjni_main; + JNIEnv* env; + if ((*vm)->GetEnv(vm, (void**) &env, JNI_VERSION_1_6) != JNI_OK) { + return JNI_ERR; + } + + if (vppjni_init(env) != 0) { + return JNI_ERR; + } + + jm->jvm = vm; + return JNI_VERSION_1_6; +} + +void JNI_OnUnload(JavaVM *vm, void *reserved) { + vppjni_main_t * jm = &vppjni_main; + JNIEnv* env; + if ((*vm)->GetEnv(vm, (void**) &env, JNI_VERSION_1_6) != JNI_OK) { + return; + } + + vppjni_uninit(env); + + jm->jenv = NULL; + jm->jvm = NULL; +} + +#define foreach_vpe_api_msg \ +_(CONTROL_PING_REPLY, control_ping_reply) \ +_(SW_INTERFACE_DETAILS, sw_interface_details) \ +_(SHOW_VERSION_REPLY, show_version_reply) \ +_(WANT_STATS_REPLY, want_stats_reply) \ +_(VNET_INTERFACE_COUNTERS, vnet_interface_counters) \ +_(SW_INTERFACE_SET_FLAGS, sw_interface_set_flags) \ +_(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \ +_(BRIDGE_DOMAIN_SW_IF_DETAILS, bridge_domain_sw_if_details) \ +_(L2_FIB_TABLE_ENTRY, l2_fib_table_entry) \ +_(IP_ADDRESS_DETAILS, ip_address_details) \ +_(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) + +static int connect_to_vpe(char *name) +{ + vppjni_main_t * jm = &vppjni_main; + api_main_t * am = &api_main; + + if (vl_client_connect_to_vlib("/vpe-api", name, 32) < 0) + return -1; + + jm->my_client_index = am->my_client_index; + jm->vl_input_queue = am->shmem_hdr->vl_input_queue; + +#define _(N,n) \ + vl_msg_api_set_handlers(VL_API_##N, #n, \ + vl_api_##n##_t_handler, \ + vl_noop_handler, \ + vl_api_##n##_t_endian, \ + vl_api_##n##_t_print, \ + sizeof(vl_api_##n##_t), 1); + foreach_vpe_api_msg; +#undef _ + + return 0; +} + +/* Format an IP6 address. */ +u8 * format_ip6_address (u8 * s, va_list * args) +{ + ip6_address_t * a = va_arg (*args, ip6_address_t *); + u32 max_zero_run = 0, this_zero_run = 0; + int max_zero_run_index = -1, this_zero_run_index=0; + int in_zero_run = 0, i; + int last_double_colon = 0; + + /* Ugh, this is a pain. Scan forward looking for runs of 0's */ + for (i = 0; i < ARRAY_LEN (a->as_u16); i++) { + if (a->as_u16[i] == 0) { + if (in_zero_run) { + this_zero_run++; + } else { + in_zero_run = 1; + this_zero_run =1; + this_zero_run_index = i; + } + } else { + if (in_zero_run) { + /* offer to compress the biggest run of > 1 zero */ + if (this_zero_run > max_zero_run && this_zero_run > 1) { + max_zero_run_index = this_zero_run_index; + max_zero_run = this_zero_run; + } + } + in_zero_run = 0; + this_zero_run = 0; + } + } + + if (in_zero_run) { + if (this_zero_run > max_zero_run && this_zero_run > 1) { + max_zero_run_index = this_zero_run_index; + max_zero_run = this_zero_run; + } + } + + for (i = 0; i < ARRAY_LEN (a->as_u16); i++) { + if (i == max_zero_run_index) { + s = format (s, "::"); + i += max_zero_run - 1; + last_double_colon = 1; + } else { + s = format (s, "%s%x", + (last_double_colon || i == 0) ? "" : ":", + clib_net_to_host_u16 (a->as_u16[i])); + last_double_colon = 0; + } + } + + return s; +} + +/* Format an IP4 address. */ +u8 * format_ip4_address (u8 * s, va_list * args) +{ + u8 * a = va_arg (*args, u8 *); + return format (s, "%d.%d.%d.%d", a[0], a[1], a[2], a[3]); +} + + diff --git a/vpp-api/java/japi/vppjni.h b/vpp-api/java/japi/vppjni.h new file mode 100644 index 00000000..bd0683ae --- /dev/null +++ b/vpp-api/java/japi/vppjni.h @@ -0,0 +1,308 @@ +/* + * Copyright (c) 2015 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef __included_vppjni_h__ +#define __included_vppjni_h__ + +#include +#include +#include +#include +#include +#include +#include + +typedef struct { + u8 * name; + u32 value; +} name_sort_t; + +typedef struct { + u8 valid; // used in a vector of sw_interface_details_t + + u8 interface_name[64]; + u32 sw_if_index; + u32 sup_sw_if_index; + u32 l2_address_length; + u8 l2_address[8]; + u8 admin_up_down; + u8 link_up_down; + u8 link_duplex; + u8 link_speed; + u16 link_mtu; + u32 sub_id; + u8 sub_dot1ad; + u8 sub_number_of_tags; + u16 sub_outer_vlan_id; + u16 sub_inner_vlan_id; + u8 sub_exact_match; + u8 sub_default; + u8 sub_outer_vlan_id_any; + u8 sub_inner_vlan_id_any; + u32 vtr_op; + u32 vtr_push_dot1q; + u32 vtr_tag1; + u32 vtr_tag2; +} sw_interface_details_t; + +typedef struct { + u8 * interface_name; + u32 sw_if_index; + /* + * Subinterface ID. A number 0-N to uniquely identify + * this subinterface under the super interface + */ + u32 sub_id; + + /* 0 = dot1q, 1=dot1ad */ + u8 sub_dot1ad; + + /* Number of tags 0-2 */ + u8 sub_number_of_tags; + u16 sub_outer_vlan_id; + u16 sub_inner_vlan_id; + u8 sub_exact_match; + u8 sub_default; + u8 sub_outer_vlan_id_any; + u8 sub_inner_vlan_id_any; + + /* vlan tag rewrite */ + u32 vtr_op; + u32 vtr_push_dot1q; + u32 vtr_tag1; + u32 vtr_tag2; +} sw_interface_subif_t; + +typedef struct { + u8 *desc; +} sw_if_config_t; + +typedef struct { + u32 ip; + u8 prefix_length; +} ipv4_address_t; + +typedef struct { + u8 ip[16]; + u8 prefix_length; +} ipv6_address_t; + +typedef struct { + u64 ip4; + u64 ip6; + u64 unicast; + u64 multicast; + u64 broadcast; + u64 discard; + u64 fifo_full; + u64 error; + u64 unknown_proto; + u64 miss; +} packet_counters_t; + +typedef struct { + u64 octets; + packet_counters_t pkts; +} if_counters_t; + +typedef struct { + u8 valid; + u32 sw_if_index; + if_counters_t rx; + if_counters_t tx; +} sw_interface_stats_t; + +typedef struct { + u32 src_address; + u32 dst_address; + u32 encap_vrf_id; + u32 vni; + u32 decap_next_index; +} vxlan_tunnel_details_t; + + +typedef struct { + /* Context IDs */ + volatile u32 context_id_sent; + volatile u32 context_id_received; + + /* Spinlock */ + volatile u32 lock; + u32 tag; + + /* To recycle pseudo-synchronous message code from vpp_api_test... */ + volatile u32 result_ready; + volatile i32 retval; + volatile u8 *shmem_result; + + /* thread cleanup */ + pthread_key_t cleanup_rx_thread_key; + /* attachment of rx thread to java thread */ + JNIEnv *jenv; + JavaVM *jvm; + uword *callback_hash; // map context_id => jobject + uword *ping_hash; // map ping context_id => msg type called + + /* Timestamp */ + clib_time_t clib_time; + + /* connected indication */ + u8 is_connected; + + /* context -> non-trivial reply hash */ + uword * reply_hash; + u32 saved_reply_count; + + /* interface name map */ + uword * sw_if_index_by_interface_name; + + /* interface counters */ + sw_interface_stats_t * sw_if_stats_by_sw_if_index; + + /* interface table */ + sw_interface_details_t * sw_if_table; + + uword * sw_if_config_by_sw_if_index; + + /* interface indices of responses to one sw_if_dump request */ + u8 collect_indices; + u32 * sw_if_dump_if_indices; + + /* program name, build_dir, version */ + u8 program_name[32]; + u8 build_directory[256]; + u8 version[32]; + u8 build_date[32]; + + /* subinterface table */ + sw_interface_subif_t * sw_if_subif_table; + + /* used in ip_address_dump request and response handling */ + ipv4_address_t *ipv4_addresses; + ipv6_address_t *ipv6_addresses; + u8 is_ipv6; + + /* used in vxlan_tunnel_dump request and response handling */ + vxlan_tunnel_details_t *vxlan_tunnel_details; + + /* main heap */ + u8 * heap; + + /* convenience */ + unix_shared_memory_queue_t * vl_input_queue; + api_main_t * api_main; + u32 my_client_index; + + vjbd_main_t vjbd_main; +} vppjni_main_t; + +vppjni_main_t vppjni_main __attribute__((aligned (64))); + + +static inline u32 vppjni_get_context_id (vppjni_main_t * jm) +{ + u32 my_context_id; + my_context_id = __sync_add_and_fetch (&jm->context_id_sent, 1); + return my_context_id; +} + +static inline void vppjni_lock (vppjni_main_t * jm, u32 tag) +{ + while (__sync_lock_test_and_set (&jm->lock, 1)) + ; + jm->tag = tag; +} + +static inline void vppjni_unlock (vppjni_main_t * jm) +{ + jm->tag = 0; + CLIB_MEMORY_BARRIER(); + jm->lock = 0; +} + +static inline f64 vppjni_time_now (vppjni_main_t *jm) +{ + return clib_time_now (&jm->clib_time); +} + +static inline int vppjni_sanity_check (vppjni_main_t * jm) +{ + if (!jm->is_connected) + return VNET_API_ERROR_NOT_CONNECTED; + return 0; +} + +#define __PACKED(x) x __attribute__((packed)) + +typedef __PACKED(struct _vl_api_generic_reply { + u16 _vl_msg_id; + u32 context; + i32 retval; + u8 data[0]; +}) vl_api_generic_reply_t; + +void vl_api_generic_reply_handler (vl_api_generic_reply_t *mp); + +/* M: construct, but don't yet send a message */ + +#define M(T,t) \ +do { \ + jm->result_ready = 0; \ + mp = vl_msg_api_alloc(sizeof(*mp)); \ + memset (mp, 0, sizeof (*mp)); \ + mp->_vl_msg_id = ntohs (VL_API_##T); \ + mp->client_index = jm->my_client_index; \ + } while(0); + +#define M2(T,t,n) \ +do { \ + jm->result_ready = 0; \ + mp = vl_msg_api_alloc(sizeof(*mp)+(n)); \ + memset (mp, 0, sizeof (*mp)); \ + mp->_vl_msg_id = ntohs (VL_API_##T); \ + mp->client_index = jm->my_client_index; \ + } while(0); + + +/* S: send a message */ +#define S (vl_msg_api_send_shmem (jm->vl_input_queue, (u8 *)&mp)) + +/* W: wait for results, with timeout */ +#define W \ + do { \ + timeout = vppjni_time_now (jm) + 1.0; \ + \ + while (vppjni_time_now (jm) < timeout) { \ + if (jm->result_ready == 1) { \ + return (jm->retval); \ + } \ + } \ + return -99; \ +} while(0); + +/* WNR: wait for results, with timeout (without returning) */ +#define WNR \ + do { \ + timeout = vppjni_time_now (jm) + 1.0; \ + \ + rv = -99; \ + while (vppjni_time_now (jm) < timeout) { \ + if (jm->result_ready == 1) { \ + rv = (jm->retval); \ + break; \ + } \ + } \ +} while(0); + +#endif /* __included_vppjni_h__ */ diff --git a/vpp-api/java/japi/vppjni_bridge_domain.h b/vpp-api/java/japi/vppjni_bridge_domain.h new file mode 100644 index 00000000..b614a5be --- /dev/null +++ b/vpp-api/java/japi/vppjni_bridge_domain.h @@ -0,0 +1,510 @@ +/*--------------------------------------------------------------------------- + * Copyright (c) 2009-2014 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *--------------------------------------------------------------------------- + */ + +#ifndef __included_vppjni_bridge_domain_h__ +#define __included_vppjni_bridge_domain_h__ + +#include +#include +#include + +/* + * The L2fib key is the mac address and bridge domain ID + */ +#define MAC_ADDRESS_SIZE 6 + +typedef struct { + union { + struct { + u16 unused1; + u8 mac[MAC_ADDRESS_SIZE]; + } fields; + u64 raw; + }; +} l2fib_u64_mac_t; + +/* + * The l2fib entry results + */ +typedef struct { + u32 bd_id; + l2fib_u64_mac_t mac_addr; + u32 sw_if_index; + u8 learned:1; + u8 bvi:1; + u8 filter:1; // drop packets to/from this mac + u8 unused1:5; +} bd_l2fib_oper_t; + +typedef struct { + u32 bd_id; + u8 * bd_name; +} bd_local_cfg_t; + +typedef struct { + u32 bd_id; + u32 sw_if_index; + u32 shg; +} bd_sw_if_oper_t; + +typedef struct { + u32 bd_id; + u8 flood:1; + u8 forward:1; + u8 learn:1; + u8 uu_flood:1; + u8 arp_term:1; + u8 unused1:3; + u32 bvi_sw_if_index; + u32 n_sw_ifs; + bd_sw_if_oper_t * bd_sw_if_oper; + f64 last_sync_time; + mhash_t l2fib_index_by_mac; + bd_l2fib_oper_t * l2fib_oper; // vector indexed by l2fib_index +} vjbd_oper_t; + +#define BD_OPER_REFRESH_INTERVAL 2.0 +#define BD_OPER_L2FIB_REFRESH_INTERVAL 5.0 + +typedef struct { + u32 next_bd_id; + uword * bd_index_bitmap; + uword * bd_index_by_id; + mhash_t bd_id_by_name; + bd_local_cfg_t * local_cfg; // vector indexed by bd_index + vjbd_oper_t * bd_oper; // vector indexed by oper_bd_index + f64 bd_oper_last_sync_all_time; + bd_sw_if_oper_t * sw_if_oper; // vector indexed by sw_if_index + f64 l2fib_oper_last_sync_time; + uword * bd_id_by_sw_if_index; + uword * oper_bd_index_by_bd_id; +} vjbd_main_t; + +extern vjbd_main_t vjbd_main; + +always_inline +u64 l2fib_mac_to_u64 (u8 * mac_address) { + u64 temp; + + // The mac address in memory is A:B:C:D:E:F + // The bd id in register is H:L +#if CLIB_ARCH_IS_LITTLE_ENDIAN + // Create the in-register key as F:E:D:C:B:A:H:L + // In memory the key is L:H:A:B:C:D:E:F + temp = *((u64 *)(mac_address - 2)); + temp = (temp & ~0xffff); +#else + // Create the in-register key as H:L:A:B:C:D:E:F + // In memory the key is H:L:A:B:C:D:E:F + temp = *((u64 *)(mac_address)) >> 16; +#endif + + return temp; +} + +static_always_inline void vjbd_main_init (vjbd_main_t *bdm) +{ + bdm->bd_index_by_id = hash_create (0, sizeof(uword)); + mhash_init_vec_string (&bdm->bd_id_by_name, sizeof (u32)); + bdm->bd_id_by_sw_if_index = hash_create (0, sizeof (u32)); + bdm->oper_bd_index_by_bd_id = hash_create (0, sizeof (u32)); +} + +static_always_inline u32 vjbd_id_is_valid (vjbd_main_t * bdm, u32 bd_id) +{ + return ((bd_id != 0) && (bd_id != ~0) && (bd_id <= bdm->next_bd_id)); +} + +static_always_inline u32 vjbd_index_is_free (vjbd_main_t * bdm, u16 bd_index) +{ + u32 bd_id = vec_elt_at_index(bdm->local_cfg, bd_index)->bd_id; + + return (!clib_bitmap_get (bdm->bd_index_bitmap, (bd_index)) && + (bd_index < vec_len (bdm->local_cfg)) && + ((bd_id == 0) || (bd_id == ~0))); +} + +static_always_inline u32 vjbd_index_is_valid (vjbd_main_t * bdm, u16 bd_index) +{ + return (clib_bitmap_get (bdm->bd_index_bitmap, bd_index) && + (bd_index < vec_len (bdm->local_cfg))); +} + +static_always_inline u32 vjbd_id_from_name (vjbd_main_t * bdm, + const u8 * bd_name) +{ + u32 bd_id; + uword * p; + + ASSERT (vec_c_string_is_terminated (bd_name)); + + if (bdm->next_bd_id == 0) + return ~0; + + p = mhash_get (&bdm->bd_id_by_name, (void *)bd_name); + if (p) + { + bd_id = p[0]; + ASSERT (vjbd_id_is_valid (bdm, bd_id)); + } + else + bd_id = ~0; + + return bd_id; +} + +static_always_inline u32 vjbd_index_from_id (vjbd_main_t * bdm, u32 bd_id) +{ + uword * p; + u16 bd_index; + + ASSERT (vjbd_id_is_valid (bdm, bd_id)); + + p = hash_get (bdm->bd_index_by_id, bd_id); + + ASSERT (p); // there is always an index associated with a valid bd_id + bd_index = p[0]; + + ASSERT (vjbd_index_is_valid (bdm, bd_index)); + + return bd_index; +} + +static_always_inline u32 vjbd_id_from_index (vjbd_main_t * bdm, u16 bd_index) +{ + u32 bd_id; + + ASSERT (vjbd_index_is_valid (bdm, bd_index)); + + bd_id = vec_elt_at_index(bdm->local_cfg, bd_index)->bd_id; + + ASSERT (vjbd_id_is_valid (bdm, bd_id)); + + return bd_id; +} + +static_always_inline u8 * vjbd_name_from_id (vjbd_main_t * bdm, u32 bd_id) +{ + u16 bd_index = vjbd_index_from_id (bdm, bd_id); + + return vec_elt_at_index(bdm->local_cfg, bd_index)->bd_name; +} + +static_always_inline u8 * vjbd_oper_name_from_id (vjbd_main_t * bdm, u32 bd_id) +{ + if (vjbd_id_is_valid (bdm, bd_id)) { + return format(0, "%s", vjbd_name_from_id(bdm, bd_id)); + } else { + return format(0, "BridgeDomainOper%d", bd_id); + } +} + +static_always_inline vjbd_oper_t * vjbd_oper_from_id (vjbd_main_t * bdm, + u32 bd_id) +{ + u16 bd_index = vjbd_index_from_id (bdm, bd_id); + return vec_elt_at_index (bdm->bd_oper, bd_index); +} + +static_always_inline void vjbd_oper_maybe_sync_from_vpp (vjbd_main_t * bdm, + u32 bd_id) +{ +#ifdef VPPJNI_OPER + vppjni_vpe_api_msg_main_t *ovam = ovam_get_main (); + + if (bd_id == ~0) + { + if ((ovam_time_now (ovam) - bdm->bd_oper_last_sync_all_time) > + BD_OPER_REFRESH_INTERVAL) + { + ovam_bridge_domain_dump (bd_id); + bdm->bd_oper_last_sync_all_time = ovam_time_now (ovam); + } + } + + else + { + vjbd_oper_t * bd_oper = vjbd_oper_from_id (bdm, bd_id); + + if ((ovam_time_now (ovam) - bd_oper->last_sync_time) > + BD_OPER_REFRESH_INTERVAL) + { + ovam_bridge_domain_dump (bd_id); + + bd_oper->last_sync_time = ovam_time_now (ovam); + } + } +#endif +} + +static_always_inline u32 vjbd_id_from_sw_if_index (vjbd_main_t * bdm, + u32 sw_if_index) +{ + bd_sw_if_oper_t * bd_sw_if_oper; + u32 bd_id = ~0; + + vjbd_oper_maybe_sync_from_vpp (bdm, ~0); + if (sw_if_index < vec_len (bdm->sw_if_oper)) + { + bd_sw_if_oper = vec_elt_at_index (bdm->sw_if_oper, sw_if_index); + bd_id = bd_sw_if_oper->bd_id; + } + + return bd_id; +} + +static_always_inline u8 * vjbd_name_from_sw_if_index (vjbd_main_t * bdm, + u32 sw_if_index) +{ + u32 bd_id, bd_index; + u8 * bd_name = 0; + + /* DAW-FIXME: + ASSERT (ovam_sw_if_index_valid (ovam_get_main(), sw_if_index)); + */ + vjbd_oper_maybe_sync_from_vpp (bdm, ~0); + bd_id = vjbd_id_from_sw_if_index (bdm, sw_if_index); + if (vjbd_id_is_valid (bdm, bd_id)) + { + bd_index = vjbd_index_from_id (bdm, bd_id); + bd_name = vec_elt_at_index (bdm->local_cfg, bd_index)->bd_name; + } + + return bd_name; +} + +static_always_inline u32 +vjbd_oper_l2fib_index_from_mac (vjbd_oper_t * bd_oper, u8 * mac) +{ + u32 l2fib_index; + uword * p; + + p = mhash_get (&bd_oper->l2fib_index_by_mac, mac); + if (p) + { + l2fib_index = p[0]; + ASSERT (l2fib_index < vec_len (bd_oper->l2fib_oper)); + } + else + l2fib_index = ~0; + + return l2fib_index; +} + +static_always_inline u32 vjbd_local_cfg_next_id (vjbd_main_t * bdm, + u32 bd_id) +{ + u32 i, end = vec_len (bdm->local_cfg); + u32 next_bd_id = 0; + + if ((bd_id == 0) || vjbd_id_is_valid (bdm, bd_id)) + for (i = 0; i < end; i++) + { + u32 curr_bd_id = bdm->local_cfg[i].bd_id; + if ((curr_bd_id != ~0) && (curr_bd_id > bd_id) && + ((next_bd_id == 0) || (curr_bd_id < next_bd_id))) + next_bd_id = curr_bd_id; + } + + return next_bd_id; +} + +static_always_inline u32 vjbd_sw_if_oper_next_index (vjbd_main_t * bdm, + u32 start, u32 bd_id) +{ + u32 i, end = vec_len (bdm->sw_if_oper); + + if (vjbd_id_is_valid (bdm, bd_id)) + for (i = start; i < end; i++) + if (bdm->sw_if_oper[i].bd_id == bd_id) + return i; + + return ~0; +} + +static_always_inline void +vjbd_oper_l2fib_maybe_sync_from_vpp (vjbd_main_t * bdm) +{ +#ifdef VPPJNI_OPER + vppjni_vpe_api_msg_main_t *ovam = ovam_get_main (); + if ((ovam_time_now (ovam) - bdm->l2fib_oper_last_sync_time) > + BD_OPER_L2FIB_REFRESH_INTERVAL) + { + ovam_l2fib_table_dump (); + bdm->l2fib_oper_last_sync_time = ovam_time_now (ovam); + } +#endif +} + +static_always_inline void vjbd_l2fib_oper_reset (vjbd_main_t * bdm) +{ + vjbd_oper_t * bd_oper; + + vec_foreach (bd_oper, bdm->bd_oper) + { + mhash_init (&bd_oper->l2fib_index_by_mac, sizeof (u32), MAC_ADDRESS_SIZE); + vec_reset_length (bd_oper->l2fib_oper); + } +} + +static_always_inline void vjbd_oper_reset (vjbd_main_t * bdm, u32 bd_id) +{ + u16 bd_index; + u32 si, len; + vjbd_oper_t * bd_oper; + u32 end; + + if (!bdm->bd_oper) + { + ASSERT (vec_len (bdm->sw_if_oper) == 0); + return; + } + + if (bd_id == ~0) + { + bdm->bd_oper_last_sync_all_time = 0.0; + bd_index = 0; + end = vec_len (bdm->bd_oper); + } + else + { + bd_index = vjbd_index_from_id (bdm, bd_id); + end = bd_index + 1; + } + + for (; bd_index < end; bd_index++) + { + bd_oper = vec_elt_at_index (bdm->bd_oper, bd_index); + bd_oper->last_sync_time = 0.0; + + len = vec_len (bdm->sw_if_oper); + for (si = vjbd_sw_if_oper_next_index (bdm, 0, bd_id); + (si != ~0) && (si < len); + si = vjbd_sw_if_oper_next_index (bdm, si + 1, bd_id)) + { + bd_sw_if_oper_t * bd_sw_if_oper; + + bd_sw_if_oper = vec_elt_at_index (bdm->sw_if_oper, si); + bd_sw_if_oper->bd_id = ~0; + } + } +} + +static_always_inline void +vjbd_sw_if_add_del (u32 sw_if_index ,u32 bd_id, u8 bvi, u8 shg, u8 is_add) +{ + vjbd_main_t * bdm = &vjbd_main; + u16 bd_index = vjbd_index_from_id (bdm, bd_id); + vjbd_oper_t * bd_oper = vec_elt_at_index (bdm->bd_oper, bd_index); + bd_sw_if_oper_t * bd_sw_if_oper; + + ASSERT (vjbd_id_is_valid (bdm, bd_id)); + /* DAW-FIXME + ASSERT (ovam_sw_if_index_valid (ovam_get_main (), sw_if_index)); + */ + + vec_validate (bdm->sw_if_oper, sw_if_index); + bd_sw_if_oper = vec_elt_at_index (bdm->sw_if_oper, sw_if_index); + if (is_add) + { + bd_sw_if_oper->bd_id = bd_id; + bd_sw_if_oper->shg = shg; + bd_oper->bvi_sw_if_index = bvi ? sw_if_index : ~0; + } + else + { + bd_sw_if_oper->bd_id = 0; + bd_sw_if_oper->shg = 0; + if (bd_oper->bvi_sw_if_index == sw_if_index) + bd_oper->bvi_sw_if_index = ~0; + } +} + +static_always_inline u32 vjbd_id_sw_if_count (vjbd_main_t * bdm, u32 bd_id) +{ + u32 count = 0, i, end = vec_len (bdm->sw_if_oper); + + if (vjbd_id_is_valid (bdm, bd_id)) + for (count = i = 0; i < end; i++) + if (bdm->sw_if_oper[i].bd_id == bd_id) + count++; + + return count; +} + +static_always_inline u32 vjbd_find_or_add_bd (vjbd_main_t * bdm, u8 * bd_name) +{ + u16 bd_index; + u32 bd_id; + bd_local_cfg_t * bd_local_cfg; + uword mhash_val_bd_id; + + bd_id = vjbd_id_from_name (bdm, bd_name); + if (bd_id != ~0) + return bd_id; + + mhash_val_bd_id = bd_id = ++bdm->next_bd_id; + mhash_set_mem (&bdm->bd_id_by_name, (void *)bd_name, &mhash_val_bd_id, 0); + + bd_index = clib_bitmap_first_clear (bdm->bd_index_bitmap); + vec_validate (bdm->local_cfg, bd_index); + vec_validate (bdm->bd_oper, bd_index); + + ASSERT (vjbd_index_is_free (bdm, bd_index)); + + bd_local_cfg = vec_elt_at_index (bdm->local_cfg, bd_index); + bd_local_cfg->bd_id = bd_id; + vec_validate_init_c_string (bd_local_cfg->bd_name, bd_name, + vec_len (bd_name) - 1); + hash_set (bdm->bd_index_by_id, bd_id, bd_index); + bdm->bd_index_bitmap = clib_bitmap_set (bdm->bd_index_bitmap, + bd_index, 1); + return bd_id; +} + +static_always_inline void vjbd_delete_bd (vjbd_main_t * bdm, u32 bd_id) +{ + u16 bd_index; + bd_local_cfg_t * bd_local_cfg; + + ASSERT (vjbd_id_is_valid (bdm, bd_id)); + + // bd must not have any members before deleting + ASSERT (!vjbd_id_sw_if_count (bdm, bd_id)); + + bd_index = vjbd_index_from_id (bdm, bd_id); + bd_local_cfg = vec_elt_at_index (bdm->local_cfg, bd_index); + vjbd_oper_reset (bdm, bd_id); + + mhash_unset (&bdm->bd_id_by_name, vjbd_name_from_id (bdm, bd_id), 0); + bdm->bd_index_bitmap = clib_bitmap_set (bdm->bd_index_bitmap, + bd_index, 0); + hash_unset (bdm->bd_index_by_id, bd_id); + bd_local_cfg->bd_id = ~0; + vec_validate_init_c_string (bd_local_cfg->bd_name, "", 0); + + if (clib_bitmap_is_zero (bdm->bd_index_bitmap)) + { + vec_reset_length (bdm->local_cfg); + vec_reset_length (bdm->bd_oper); + } + + /* Force a resync of all bd_oper data. */ + bdm->bd_oper_last_sync_all_time = 0.0; + vjbd_oper_maybe_sync_from_vpp (bdm, ~0); +} + +#endif /* __included_vppjni_vpp_bridge_domain_h__ */ diff --git a/vpp-api/java/japi/vppjni_env.c b/vpp-api/java/japi/vppjni_env.c new file mode 100644 index 00000000..1c4ea6eb --- /dev/null +++ b/vpp-api/java/japi/vppjni_env.c @@ -0,0 +1,111 @@ +/* + * Copyright (c) 2016 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include + +#include "vppjni_env.h" + +// Head of the class registration list. +static vppjni_class_t *class_head; +// Head of the class registration list. +static vppjni_field_t *field_head; + +void vppjni_register_class(vppjni_class_t *ptr) +{ + vppjni_class_t **where = &class_head; + while (*where != NULL) { + where = &((*where)->next); + } + *where = ptr; +} + +void vppjni_register_field(vppjni_field_t *ptr) { + vppjni_field_t **where = &field_head; + while (*where != NULL) { + where = &((*where)->next); + } + *where = ptr; +} + +jobject vppjni_new_object(JNIEnv *env, const vppjni_class_t *ptr, va_list ap) { + jobject obj = (*env)->NewObjectV(env, ptr->jclass, ptr->jinit, ap); + if ((*env)->ExceptionCheck(env)) { + (*env)->ExceptionDescribe(env); + return NULL; + } + + return obj; +} + +int vppjni_init(JNIEnv *env) +{ + vppjni_class_t *cwlk; + vppjni_field_t *fwlk; + + for (cwlk = class_head; cwlk != NULL; cwlk = cwlk->next) { + jclass cls; + jmethodID method; + + cls = (*env)->FindClass(env, cwlk->fqcn); + if ((*env)->ExceptionCheck(env)) { + (*env)->ExceptionDescribe(env); + vppjni_uninit(env); + return JNI_ERR; + } + + method = (*env)->GetMethodID(env, cls, "", cwlk->init_sig); + if ((*env)->ExceptionCheck(env)) { + (*env)->ExceptionDescribe(env); + vppjni_uninit(env); + return JNI_ERR; + } + + cwlk->jclass = (*env)->NewGlobalRef(env, cls); + if (cwlk->jclass == NULL) { + vppjni_uninit(env); + return JNI_ERR; + } + cwlk->jinit = method; + } + + for (fwlk = field_head; fwlk != NULL; fwlk = fwlk->next) { + fwlk->jfield = (*env)->GetFieldID(env, fwlk->clsref->jclass, fwlk->name, fwlk->type); + if ((*env)->ExceptionCheck(env)) { + (*env)->ExceptionDescribe(env); + vppjni_uninit(env); + return JNI_ERR; + } + } + + return 0; +} + +void vppjni_uninit(JNIEnv *env) { + vppjni_class_t *cwlk; + vppjni_field_t *fwlk; + + for (fwlk = field_head; fwlk != NULL; fwlk = fwlk->next) { + fwlk->jfield = NULL; + } + + for (cwlk = class_head; cwlk != NULL; cwlk = cwlk->next) { + if (cwlk->jclass != NULL ) { + (*env)->DeleteGlobalRef(env, cwlk->jclass); + } + + cwlk->jclass = NULL; + cwlk->jinit = NULL; + } +} + diff --git a/vpp-api/java/japi/vppjni_env.h b/vpp-api/java/japi/vppjni_env.h new file mode 100644 index 00000000..44029c2c --- /dev/null +++ b/vpp-api/java/japi/vppjni_env.h @@ -0,0 +1,118 @@ +/* + * Copyright (c) 2016 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Utilities for accessing Java classes/method/fields in an efficient + * manner. + */ + +/* + * A potentially-uninitialized reference to a Java class + */ +typedef struct vppjni_class { + // Fully-Qualified Class Name + const char *fqcn; + // Constructor signature + const char *init_sig; + // Global reference to class handle + jclass jclass; + // Constructor method handle + jmethodID jinit; + // Next item in linked list + struct vppjni_class *next; +} vppjni_class_t; + +typedef struct jenv_field { + // Field name + const char *name; + // Field type + const char *type; + // Defining class reference + const vppjni_class_t *clsref; + // Field handle + jfieldID jfield; + // Next item in linked list + struct jenv_field *next; +} vppjni_field_t; + +#define VPPJNI_CLASS_SYMBOL(name) vppjni_class_##name +#define VPPJNI_CLASS_INIT(name) vppjni_class_##name##_init +#define BIND_JAPI_CLASS(name, sig) \ + static vppjni_class_t VPPJNI_CLASS_SYMBOL(name); \ + static void VPPJNI_CLASS_INIT(name)(void) __attribute__((__constructor__)); \ + static void VPPJNI_CLASS_INIT(name)() \ + { \ + VPPJNI_CLASS_SYMBOL(name).fqcn = "org/openvpp/vppjapi/" #name; \ + VPPJNI_CLASS_SYMBOL(name).init_sig = sig; \ + vppjni_register_class(&VPPJNI_CLASS_SYMBOL(name)); \ + } \ + static __attribute__((unused)) jobject name##Array(JNIEnv *env, jsize length) \ + { \ + return (*env)->NewObjectArray(env, length, VPPJNI_CLASS_SYMBOL(name).jclass, NULL); \ + } \ + static jobject name##Object(JNIEnv *env, ...) \ + { \ + va_list ap; \ + va_start(ap, env); \ + jobject obj = vppjni_new_object(env, &VPPJNI_CLASS_SYMBOL(name), ap); \ + va_end(ap); \ + return obj; \ + } + +#define VPPJNI_FIELD_SYMBOL(cls, name) vppjni_field_##cls##_##name +#define VPPJNI_FIELD_INIT(cls, name) vppjni_field_##cls##_##name##_init +#define BIND_JAPI_FIELD(cls, field, sig) \ + static vppjni_field_t VPPJNI_FIELD_SYMBOL(cls, field); \ + static void VPPJNI_FIELD_INIT(cls, field)(void) __attribute__((__constructor__)); \ + static void VPPJNI_FIELD_INIT(cls, field)() \ + { \ + VPPJNI_FIELD_SYMBOL(cls, field).name = #field; \ + VPPJNI_FIELD_SYMBOL(cls, field).type = sig; \ + VPPJNI_FIELD_SYMBOL(cls, field).clsref = &VPPJNI_CLASS_SYMBOL(cls); \ + vppjni_register_field(&VPPJNI_FIELD_SYMBOL(cls, field)); \ + } +#define BIND_JAPI_BOOL_FIELD(cls, field) \ + BIND_JAPI_FIELD(cls, field, "Z"); \ + static void set_##cls##_##field(JNIEnv *env, jobject obj, jboolean value) \ + { \ + (*env)->SetBooleanField(env, obj, VPPJNI_FIELD_SYMBOL(cls, field).jfield, value); \ + } +#define BIND_JAPI_BYTE_FIELD(cls, field) \ + BIND_JAPI_FIELD(cls, field, "B"); \ + static void set_##cls##_##field(JNIEnv *env, jobject obj, jbyte value) \ + { \ + (*env)->SetByteField(env, obj, VPPJNI_FIELD_SYMBOL(cls, field).jfield, value); \ + } +#define BIND_JAPI_INT_FIELD(cls, field) \ + BIND_JAPI_FIELD(cls, field, "I"); \ + static void set_##cls##_##field(JNIEnv *env, jobject obj, jint value) \ + { \ + (*env)->SetIntField(env, obj, VPPJNI_FIELD_SYMBOL(cls, field).jfield, value); \ + } +#define BIND_JAPI_OBJ_FIELD(cls, field, sig) \ + BIND_JAPI_FIELD(cls, field, sig); \ + static void set_##cls##_##field(JNIEnv *env, jobject obj, jobject value) \ + { \ + (*env)->SetObjectField(env, obj, VPPJNI_FIELD_SYMBOL(cls, field).jfield, value); \ + } +#define BIND_JAPI_STRING_FIELD(cls, field) \ + BIND_JAPI_OBJ_FIELD(cls, field, "Ljava/lang/String;") + +jobject vppjni_new_object(JNIEnv *env, const vppjni_class_t *ptr, va_list ap) __attribute__ ((visibility ("hidden"))); +void vppjni_register_class(vppjni_class_t *ptr) __attribute__ ((visibility ("hidden"))); +void vppjni_register_field(vppjni_field_t *ptr) __attribute__ ((visibility ("hidden"))); +int vppjni_init(JNIEnv *env) __attribute__ ((visibility ("hidden"))); +void vppjni_uninit(JNIEnv *env) __attribute__ ((visibility ("hidden"))); + diff --git a/vpp-api/java/m4/ax_check_java_home.m4 b/vpp-api/java/m4/ax_check_java_home.m4 new file mode 100644 index 00000000..cfe8f589 --- /dev/null +++ b/vpp-api/java/m4/ax_check_java_home.m4 @@ -0,0 +1,80 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_check_java_home.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_CHECK_JAVA_HOME +# +# DESCRIPTION +# +# Check for Sun Java (JDK / JRE) installation, where the 'java' VM is in. +# If found, set environment variable JAVA_HOME = Java installation home, +# else left JAVA_HOME untouch, which in most case means JAVA_HOME is +# empty. +# +# LICENSE +# +# Copyright (c) 2008 Gleen Salmon +# +# 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 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 . +# +# As a special exception, the respective Autoconf Macro's copyright owner +# gives unlimited permission to copy, distribute and modify the configure +# scripts that are the output of Autoconf when processing the Macro. You +# need not follow the terms of the GNU General Public License when using +# or distributing such scripts, even though portions of the text of the +# Macro appear in them. The GNU General Public License (GPL) does govern +# all other use of the material that constitutes the Autoconf Macro. +# +# This special exception to the GPL applies to versions of the Autoconf +# Macro released by the Autoconf Archive. When you make and distribute a +# modified version of the Autoconf Macro, you may extend this special +# exception to the GPL to apply to your modified version as well. + +#serial 6 + +AU_ALIAS([AC_CHECK_JAVA_HOME], [AX_CHECK_JAVA_HOME]) + +AC_DEFUN([AX_CHECK_JAVA_HOME], +[AC_MSG_CHECKING([for JAVA_HOME]) +# We used a fake loop so that we can use "break" to exit when the result +# is found. +while true +do + # If the user defined JAVA_HOME, don't touch it. + test "${JAVA_HOME+set}" = set && break + + # On Mac OS X 10.5 and following, run /usr/libexec/java_home to get + # the value of JAVA_HOME to use. + # (http://developer.apple.com/library/mac/#qa/qa2001/qa1170.html). + JAVA_HOME=`/usr/libexec/java_home 2>/dev/null` + test x"$JAVA_HOME" != x && break + + # See if we can find the java executable, and compute from there. + TRY_JAVA_HOME=`ls -dr /usr/java/* 2> /dev/null | head -n 1` + if test x$TRY_JAVA_HOME != x; then + PATH=$PATH:$TRY_JAVA_HOME/bin + fi + AC_PATH_PROG([JAVA_PATH_NAME], [java]) + if test "x$JAVA_PATH_NAME" != x; then + JAVA_HOME=`echo $JAVA_PATH_NAME | sed "s/\(.*\)[[/]]bin[[/]]java.*/\1/"` + break + fi + + AC_MSG_NOTICE([Could not compute JAVA_HOME]) + break +done +AC_MSG_RESULT([$JAVA_HOME]) +]) diff --git a/vpp-api/java/m4/ax_check_java_plugin.m4 b/vpp-api/java/m4/ax_check_java_plugin.m4 new file mode 100644 index 00000000..920753e5 --- /dev/null +++ b/vpp-api/java/m4/ax_check_java_plugin.m4 @@ -0,0 +1,101 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_check_java_plugin.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_CHECK_JAVA_PLUGIN() +# +# DESCRIPTION +# +# This macro sets to empty on failure and to a compatible +# version of plugin.jar otherwise. Directories searched are /usr/java/* +# and /usr/local/java/*, which are assumed to be j{dk,re} installations. +# Apply the shell variable as you see fit. If sun changes things so +# /lib/plugin.jar is not the magic file it will stop working. +# +# This macro assumes that unzip, zipinfo or pkzipc is available (and can +# list the contents of the jar archive). The first two are assumed to work +# similarly enough to the infozip versisonms. The pkzipc version is +# assumed to work if I undertstand the documentation on pkware's site but +# YMMV. I do not have access to pwkware's version to test it. +# +# LICENSE +# +# Copyright (c) 2008 Duncan Simpson +# +# 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 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 . +# +# As a special exception, the respective Autoconf Macro's copyright owner +# gives unlimited permission to copy, distribute and modify the configure +# scripts that are the output of Autoconf when processing the Macro. You +# need not follow the terms of the GNU General Public License when using +# or distributing such scripts, even though portions of the text of the +# Macro appear in them. The GNU General Public License (GPL) does govern +# all other use of the material that constitutes the Autoconf Macro. +# +# This special exception to the GPL applies to versions of the Autoconf +# Macro released by the Autoconf Archive. When you make and distribute a +# modified version of the Autoconf Macro, you may extend this special +# exception to the GPL to apply to your modified version as well. + +#serial 7 + +AU_ALIAS([DPS_CHECK_PLUGIN], [AX_CHECK_JAVA_PLUGIN]) +AC_DEFUN([AX_CHECK_JAVA_PLUGIN], +[AC_REQUIRE([AC_PROG_AWK]) +AC_REQUIRE([AC_PROG_FGREP]) +AC_CHECK_PROG(ZIPINFO,[zipinfo unzip pkzipc]) +AC_MSG_CHECKING([for the java plugin]) +case "x$ZIPINFO" in +[*/zipinfo)] + zipinf="zipinfo -1" ;; +[*/unzip)] + zipinf="unzip -l";; +[*/pkzipc)] + ziping="unzipc -view";; +[x*)] + AC_MSG_RESULT([skiped, none of zipinfo, unzip and pkzipc found]) + AC_SUBST($1,[]) + zipinf="";; +esac +if test "x$zipinf" != "x"; then +jplugin="" +for jhome in `ls -dr /usr/java/* /usr/local/java/* 2> /dev/null`; do +for jfile in lib/plugin.jar jre/lib/plugin.jar; do +if test "x$jplugin" = "x" && test -f "$jhome/$jfile"; then +eval "$zipinf $jhome/$jfile | $AWK '{ print \$NF; }' | $FGREP netscape/javascript/JSObject" >/dev/null 2>/dev/null +if test $? -eq 0; then +dnl Some version of gcj (and javac) refuse to work with some files +dnl that pass this test. To stop this problem make sure that the compiler +dnl still works with this jar file in the classpath +cat << \EOF > Test.java +/* [#]line __oline__ "configure" */ +public class Test { +} +EOF +if eval "$JAVAC -classpath $jhome/$jfile Test.java 2>/dev/null >/dev/null" && test -f Test.class; then +jplugin="$jhome/$jfile" +fi +rm -f Test.java Test.class +fi; fi; done; done +if test "x$jplugin" != "x"; then +AC_SUBST($1,$jplugin) +AC_MSG_RESULT($jplugin) +else +AC_MSG_RESULT([java plugin not found]) +AC_SUBST($1,[]) +fi +fi +]) diff --git a/vpp-api/java/m4/ax_java_check_class.m4 b/vpp-api/java/m4/ax_java_check_class.m4 new file mode 100644 index 00000000..917638ae --- /dev/null +++ b/vpp-api/java/m4/ax_java_check_class.m4 @@ -0,0 +1,85 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_java_check_class.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_JAVA_CHECK_CLASS(,,) +# +# DESCRIPTION +# +# Test if a Java class is available. Based on AX_PROG_JAVAC_WORKS. This +# version uses a cache variable which is both compiler, options and +# classpath dependent (so if you switch from javac to gcj it correctly +# notices and redoes the test). +# +# The macro tries to compile a minimal program importing . Some +# newer compilers moan about the failure to use this but fail or produce a +# class file anyway. All moaing is sunk to /dev/null since I only wanted +# to know if the class could be imported. This is a recommended followup +# to AX_CHECK_JAVA_PLUGIN with classpath appropriately adjusted. +# +# LICENSE +# +# Copyright (c) 2008 Duncan Simpson +# +# 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 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 . +# +# As a special exception, the respective Autoconf Macro's copyright owner +# gives unlimited permission to copy, distribute and modify the configure +# scripts that are the output of Autoconf when processing the Macro. You +# need not follow the terms of the GNU General Public License when using +# or distributing such scripts, even though portions of the text of the +# Macro appear in them. The GNU General Public License (GPL) does govern +# all other use of the material that constitutes the Autoconf Macro. +# +# This special exception to the GPL applies to versions of the Autoconf +# Macro released by the Autoconf Archive. When you make and distribute a +# modified version of the Autoconf Macro, you may extend this special +# exception to the GPL to apply to your modified version as well. + +#serial 9 + +AU_ALIAS([DPS_JAVA_CHECK_CLASS], [AX_JAVA_CHECK_CLASS]) +AC_DEFUN([AX_JAVA_CHECK_CLASS],[ +m4_define([cache_val],[m4_translit(ax_cv_have_java_class_$1, " ." ,"__")]) +if test "x$CLASSPATH" != "x"; then +xtra=" with classpath ${CLASSPATH}" +xopts=`echo ${CLASSPATH} | ${SED} 's/^ *://'` +xopts="-classpath $xopts" +else xtra=""; xopts=""; fi +cache_var="cache_val"AS_TR_SH([_Jc_${JAVAC}_Cp_${CLASSPATH}]) +AC_CACHE_CHECK([if the $1 class is available$xtra], [$cache_var], [ +JAVA_TEST=Test.java +CLASS_TEST=Test.class +cat << \EOF > $JAVA_TEST +/* [#]xline __oline__ "configure" */ +import $1; +public class Test { +} +EOF +if AC_TRY_COMMAND($JAVAC $JAVACFLAGS $xopts $JAVA_TEST) >/dev/null 2>&1; then + eval "${cache_var}=yes" +else + eval "${cache_var}=no" + echo "configure: failed program was:" >&AS_MESSAGE_LOG_FD + cat $JAVA_TEST >&AS_MESSAGE_LOG_FD +fi +rm -f $JAVA_TEST $CLASS_TEST +]) +if eval 'test "x$'${cache_var}'" = "xyes"'; then +$2 +true; else +$3 +false; fi]) diff --git a/vpp-api/java/m4/ax_java_options.m4 b/vpp-api/java/m4/ax_java_options.m4 new file mode 100644 index 00000000..36c10d92 --- /dev/null +++ b/vpp-api/java/m4/ax_java_options.m4 @@ -0,0 +1,48 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_java_options.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_JAVA_OPTIONS +# +# DESCRIPTION +# +# AX_JAVA_OPTIONS adds configure command line options used for Java m4 +# macros. This Macro is optional. +# +# Note: This is part of the set of autoconf M4 macros for Java programs. +# It is VERY IMPORTANT that you download the whole set, some macros depend +# on other. Unfortunately, the autoconf archive does not support the +# concept of set of macros, so I had to break it for submission. The +# general documentation, as well as the sample configure.in, is included +# in the AX_PROG_JAVA macro. +# +# LICENSE +# +# Copyright (c) 2008 Devin Weaver +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. + +#serial 6 + +AU_ALIAS([AC_JAVA_OPTIONS], [AX_JAVA_OPTIONS]) +AC_DEFUN([AX_JAVA_OPTIONS],[ +AC_ARG_WITH(java-prefix, + [ --with-java-prefix=PFX prefix where Java runtime is installed (optional)]) +AC_ARG_WITH(javac-flags, + [ --with-javac-flags=FLAGS flags to pass to the Java compiler (optional)]) +AC_ARG_WITH(java-flags, + [ --with-java-flags=FLAGS flags to pass to the Java VM (optional)]) +JAVAPREFIX=$with_java_prefix +JAVACFLAGS=$with_javac_flags +JAVAFLAGS=$with_java_flags +AC_SUBST(JAVAPREFIX)dnl +AC_SUBST(JAVACFLAGS)dnl +AC_SUBST(JAVAFLAGS)dnl +AC_SUBST(JAVA)dnl +AC_SUBST(JAVAC)dnl +]) diff --git a/vpp-api/java/m4/ax_libgcj_jar.m4 b/vpp-api/java/m4/ax_libgcj_jar.m4 new file mode 100644 index 00000000..5e942857 --- /dev/null +++ b/vpp-api/java/m4/ax_libgcj_jar.m4 @@ -0,0 +1,83 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_libgcj_jar.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_LIBGCJ_JAR +# +# DESCRIPTION +# +# Locate libgcj.jar so you can place it before everything else when using +# gcj. +# +# LICENSE +# +# Copyright (c) 2008 Duncan Simpson +# +# 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 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 . +# +# As a special exception, the respective Autoconf Macro's copyright owner +# gives unlimited permission to copy, distribute and modify the configure +# scripts that are the output of Autoconf when processing the Macro. You +# need not follow the terms of the GNU General Public License when using +# or distributing such scripts, even though portions of the text of the +# Macro appear in them. The GNU General Public License (GPL) does govern +# all other use of the material that constitutes the Autoconf Macro. +# +# This special exception to the GPL applies to versions of the Autoconf +# Macro released by the Autoconf Archive. When you make and distribute a +# modified version of the Autoconf Macro, you may extend this special +# exception to the GPL to apply to your modified version as well. + +#serial 9 + +AU_ALIAS([DPS_LIBGCJ_JAR], [AX_LIBGCJ_JAR]) +AC_DEFUN([AX_LIBGCJ_JAR], +[ +AC_REQUIRE([AC_EXEEXT]) +AC_REQUIRE([AX_PROG_JAVAC]) +AC_REQUIRE([AC_PROG_FGREP]) +AC_PROG_SED +if test "x$SED" = "x"; then +AC_MSG_WARN([sed not avaiable, so libgcj.jar test skipped]) +else +AC_MSG_CHECKING([if $JAVAC is gcj]); +jc=`eval "[echo x$JAVAC | $SED 's/^x.*\\/\\([^/]*\\)\$/x\\1/;s/^ *\\([^ ]*\\) .*$/\\1/;s/"$EXEEXT"$//']"` +if test "x$jc" != "xxgcj"; then +AC_MSG_RESULT(no) +else +AC_MSG_RESULT(yes) +AC_MSG_CHECKING([libgcj.jar location]) +save_cp="$CLASSPATH"; +unset CLASSPATH; +AC_MSG_CHECKING([gcj default classpath]) +cat << \EOF > Test.java +/* [#]line __oline__ "configure" */ +public class Test { +} +EOF +lgcj=`eval "[$JAVAC -v -C Test.java 2>&1 | $FGREP \\(system\\) | $SED 's/^ *\\([^ ]*\\) .*$/\\1/;s/\\.jar\\//.jar/']"`; +if test -f Test.class && test "x$lgcj" != "x"; then +AC_MSG_RESULT($lgcj) +$1="$lgcj:" +else +AC_MSG_RESULT(failed) +$1="" +fi +if test "x$save_cp" != "x"; then CLASSPATH="$save_cp"; fi +rm -f Test.java Test.class +fi +fi +]) diff --git a/vpp-api/java/m4/ax_prog_jar.m4 b/vpp-api/java/m4/ax_prog_jar.m4 new file mode 100644 index 00000000..3c60fcaf --- /dev/null +++ b/vpp-api/java/m4/ax_prog_jar.m4 @@ -0,0 +1,49 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_prog_jar.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_PROG_JAR +# +# DESCRIPTION +# +# AX_PROG_JAR tests for an existing jar program. It uses the environment +# variable JAR then tests in sequence various common jar programs. +# +# If you want to force a specific compiler: +# +# - at the configure.in level, set JAR=yourcompiler before calling +# AX_PROG_JAR +# +# - at the configure level, setenv JAR +# +# You can use the JAR variable in your Makefile.in, with @JAR@. +# +# Note: This macro depends on the autoconf M4 macros for Java programs. It +# is VERY IMPORTANT that you download that whole set, some macros depend +# on other. Unfortunately, the autoconf archive does not support the +# concept of set of macros, so I had to break it for submission. +# +# The general documentation of those macros, as well as the sample +# configure.in, is included in the AX_PROG_JAVA macro. +# +# LICENSE +# +# Copyright (c) 2008 Egon Willighagen +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. + +#serial 7 + +AU_ALIAS([AC_PROG_JAR], [AX_PROG_JAR]) +AC_DEFUN([AX_PROG_JAR],[ +AS_IF([test "x$JAVAPREFIX" = x], + [test "x$JAR" = x && AC_CHECK_PROGS([JAR], [jar])], + [test "x$JAR" = x && AC_CHECK_PROGS([JAR], [jar], [], [$JAVAPREFIX/bin])]) +test "x$JAR" = x && AC_MSG_ERROR([no acceptable jar program found in \$PATH]) +AC_PROVIDE([$0])dnl +]) diff --git a/vpp-api/java/m4/ax_prog_java.m4 b/vpp-api/java/m4/ax_prog_java.m4 new file mode 100644 index 00000000..03961db5 --- /dev/null +++ b/vpp-api/java/m4/ax_prog_java.m4 @@ -0,0 +1,115 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_prog_java.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_PROG_JAVA +# +# DESCRIPTION +# +# Here is a summary of the main macros: +# +# AX_PROG_JAVAC: finds a Java compiler. +# +# AX_PROG_JAVA: finds a Java virtual machine. +# +# AX_CHECK_CLASS: finds if we have the given class (beware of CLASSPATH!). +# +# AX_CHECK_RQRD_CLASS: finds if we have the given class and stops +# otherwise. +# +# AX_TRY_COMPILE_JAVA: attempt to compile user given source. +# +# AX_TRY_RUN_JAVA: attempt to compile and run user given source. +# +# AX_JAVA_OPTIONS: adds Java configure options. +# +# AX_PROG_JAVA tests an existing Java virtual machine. It uses the +# environment variable JAVA then tests in sequence various common Java +# virtual machines. For political reasons, it starts with the free ones. +# You *must* call [AX_PROG_JAVAC] before. +# +# If you want to force a specific VM: +# +# - at the configure.in level, set JAVA=yourvm before calling AX_PROG_JAVA +# +# (but after AC_INIT) +# +# - at the configure level, setenv JAVA +# +# You can use the JAVA variable in your Makefile.in, with @JAVA@. +# +# *Warning*: its success or failure can depend on a proper setting of the +# CLASSPATH env. variable. +# +# TODO: allow to exclude virtual machines (rationale: most Java programs +# cannot run with some VM like kaffe). +# +# Note: This is part of the set of autoconf M4 macros for Java programs. +# It is VERY IMPORTANT that you download the whole set, some macros depend +# on other. Unfortunately, the autoconf archive does not support the +# concept of set of macros, so I had to break it for submission. +# +# A Web page, with a link to the latest CVS snapshot is at +# . +# +# This is a sample configure.in Process this file with autoconf to produce +# a configure script. +# +# AC_INIT(UnTag.java) +# +# dnl Checks for programs. +# AC_CHECK_CLASSPATH +# AX_PROG_JAVAC +# AX_PROG_JAVA +# +# dnl Checks for classes +# AX_CHECK_RQRD_CLASS(org.xml.sax.Parser) +# AX_CHECK_RQRD_CLASS(com.jclark.xml.sax.Driver) +# +# AC_OUTPUT(Makefile) +# +# LICENSE +# +# Copyright (c) 2008 Stephane Bortzmeyer +# +# 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 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 . +# +# As a special exception, the respective Autoconf Macro's copyright owner +# gives unlimited permission to copy, distribute and modify the configure +# scripts that are the output of Autoconf when processing the Macro. You +# need not follow the terms of the GNU General Public License when using +# or distributing such scripts, even though portions of the text of the +# Macro appear in them. The GNU General Public License (GPL) does govern +# all other use of the material that constitutes the Autoconf Macro. +# +# This special exception to the GPL applies to versions of the Autoconf +# Macro released by the Autoconf Archive. When you make and distribute a +# modified version of the Autoconf Macro, you may extend this special +# exception to the GPL to apply to your modified version as well. + +#serial 9 + +AU_ALIAS([AC_PROG_JAVA], [AX_PROG_JAVA]) +AC_DEFUN([AX_PROG_JAVA],[ +m4_define([m4_ax_prog_java_list], [kaffe java])dnl +AS_IF([test "x$JAVAPREFIX" = x], + [test x$JAVA = x && AC_CHECK_PROGS([JAVA], [m4_ax_prog_java_list])], + [test x$JAVA = x && AC_CHECK_PROGS([JAVA], [m4_ax_prog_java_list], [], [$JAVAPREFIX/bin])]) +test x$JAVA = x && AC_MSG_ERROR([no acceptable Java virtual machine found in \$PATH]) +m4_undefine([m4_ax_prog_java_list])dnl +AX_PROG_JAVA_WORKS +AC_PROVIDE([$0])dnl +]) diff --git a/vpp-api/java/m4/ax_prog_java_cc.m4 b/vpp-api/java/m4/ax_prog_java_cc.m4 new file mode 100644 index 00000000..3df064ff --- /dev/null +++ b/vpp-api/java/m4/ax_prog_java_cc.m4 @@ -0,0 +1,104 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_prog_java_cc.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_PROG_JAVA_CC +# +# DESCRIPTION +# +# Finds the appropriate java compiler on your path. By preference the java +# compiler is gcj, then jikes then javac. +# +# The macro can take one argument specifying a space separated list of +# java compiler names. +# +# For example: +# +# AX_PROG_JAVA_CC(javac, gcj) +# +# The macro also sets the compiler options variable: JAVA_CC_OPTS to +# something sensible: +# +# - for GCJ it sets it to: @GCJ_OPTS@ +# (if GCJ_OPTS is not yet defined then it is set to "-C") +# +# - no other compiler has applicable options yet +# +# Here's an example configure.in: +# +# AC_INIT(Makefile.in) +# AX_PROG_JAVA_CC() +# AC_OUTPUT(Makefile) +# dnl End. +# +# And here's the start of the Makefile.in: +# +# PROJECT_ROOT := @srcdir@ +# # Tool definitions. +# JAVAC := @JAVA_CC@ +# JAVAC_OPTS := @JAVA_CC_OPTS@ +# JAR_TOOL := @jar_tool@ +# +# LICENSE +# +# Copyright (c) 2008 Nic Ferrier +# +# 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 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 . +# +# As a special exception, the respective Autoconf Macro's copyright owner +# gives unlimited permission to copy, distribute and modify the configure +# scripts that are the output of Autoconf when processing the Macro. You +# need not follow the terms of the GNU General Public License when using +# or distributing such scripts, even though portions of the text of the +# Macro appear in them. The GNU General Public License (GPL) does govern +# all other use of the material that constitutes the Autoconf Macro. +# +# This special exception to the GPL applies to versions of the Autoconf +# Macro released by the Autoconf Archive. When you make and distribute a +# modified version of the Autoconf Macro, you may extend this special +# exception to the GPL to apply to your modified version as well. + +#serial 4 + +# AX_PROG_JAVA_CC([COMPILER ...]) +# -------------------------- +# COMPILER ... is a space separated list of java compilers to search for. +# This just gives the user an opportunity to specify an alternative +# search list for the java compiler. +AU_ALIAS([AC_PROG_JAVA_CC], [AX_PROG_JAVA_CC]) +AC_DEFUN([AX_PROG_JAVA_CC], +[AC_ARG_VAR([JAVA_CC], [java compiler command])dnl +AC_ARG_VAR([JAVA_CC_FLAGS], [java compiler flags])dnl +m4_ifval([$1], + [AC_CHECK_TOOLS(JAVA_CC, [$1])], +[AC_CHECK_TOOL(JAVA_CC, gcj) +if test -z "$JAVA_CC"; then + AC_CHECK_TOOL(JAVA_CC, javac) +fi +if test -z "$JAVA_CC"; then + AC_CHECK_TOOL(JAVA_CC, jikes) +fi +]) + +if test "$JAVA_CC" = "gcj"; then + if test "$GCJ_OPTS" = ""; then + AC_SUBST(GCJ_OPTS,-C) + fi + AC_SUBST(JAVA_CC_OPTS, @GCJ_OPTS@, + [Define the compilation options for GCJ]) +fi +test -z "$JAVA_CC" && AC_MSG_ERROR([no acceptable java compiler found in \$PATH]) +])# AX_PROG_JAVA_CC diff --git a/vpp-api/java/m4/ax_prog_java_works.m4 b/vpp-api/java/m4/ax_prog_java_works.m4 new file mode 100644 index 00000000..54e132af --- /dev/null +++ b/vpp-api/java/m4/ax_prog_java_works.m4 @@ -0,0 +1,134 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_prog_java_works.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_PROG_JAVA_WORKS +# +# DESCRIPTION +# +# Internal use ONLY. +# +# Note: This is part of the set of autoconf M4 macros for Java programs. +# It is VERY IMPORTANT that you download the whole set, some macros depend +# on other. Unfortunately, the autoconf archive does not support the +# concept of set of macros, so I had to break it for submission. The +# general documentation, as well as the sample configure.in, is included +# in the AX_PROG_JAVA macro. +# +# LICENSE +# +# Copyright (c) 2008 Stephane Bortzmeyer +# +# 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 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 . +# +# As a special exception, the respective Autoconf Macro's copyright owner +# gives unlimited permission to copy, distribute and modify the configure +# scripts that are the output of Autoconf when processing the Macro. You +# need not follow the terms of the GNU General Public License when using +# or distributing such scripts, even though portions of the text of the +# Macro appear in them. The GNU General Public License (GPL) does govern +# all other use of the material that constitutes the Autoconf Macro. +# +# This special exception to the GPL applies to versions of the Autoconf +# Macro released by the Autoconf Archive. When you make and distribute a +# modified version of the Autoconf Macro, you may extend this special +# exception to the GPL to apply to your modified version as well. + +#serial 9 + +AU_ALIAS([AC_PROG_JAVA_WORKS], [AX_PROG_JAVA_WORKS]) +AC_DEFUN([AX_PROG_JAVA_WORKS], [ +AC_PATH_PROG(UUDECODE, uudecode, [no]) +if test x$UUDECODE != xno; then +AC_CACHE_CHECK([if uudecode can decode base 64 file], ac_cv_prog_uudecode_base64, [ +dnl /** +dnl * Test.java: used to test if java compiler works. +dnl */ +dnl public class Test +dnl { +dnl +dnl public static void +dnl main( String[] argv ) +dnl { +dnl System.exit (0); +dnl } +dnl +dnl } +cat << \EOF > Test.uue +begin-base64 644 Test.class +yv66vgADAC0AFQcAAgEABFRlc3QHAAQBABBqYXZhL2xhbmcvT2JqZWN0AQAE +bWFpbgEAFihbTGphdmEvbGFuZy9TdHJpbmc7KVYBAARDb2RlAQAPTGluZU51 +bWJlclRhYmxlDAAKAAsBAARleGl0AQAEKEkpVgoADQAJBwAOAQAQamF2YS9s +YW5nL1N5c3RlbQEABjxpbml0PgEAAygpVgwADwAQCgADABEBAApTb3VyY2VG +aWxlAQAJVGVzdC5qYXZhACEAAQADAAAAAAACAAkABQAGAAEABwAAACEAAQAB +AAAABQO4AAyxAAAAAQAIAAAACgACAAAACgAEAAsAAQAPABAAAQAHAAAAIQAB +AAEAAAAFKrcAErEAAAABAAgAAAAKAAIAAAAEAAQABAABABMAAAACABQ= +==== +EOF +if $UUDECODE Test.uue; then + ac_cv_prog_uudecode_base64=yes +else + echo "configure: __oline__: uudecode had trouble decoding base 64 file 'Test.uue'" >&AS_MESSAGE_LOG_FD + echo "configure: failed file was:" >&AS_MESSAGE_LOG_FD + cat Test.uue >&AS_MESSAGE_LOG_FD + ac_cv_prog_uudecode_base64=no +fi +rm -f Test.uue]) +fi +if test x$ac_cv_prog_uudecode_base64 != xyes; then + rm -f Test.class + AC_MSG_WARN([I have to compile Test.class from scratch]) + if test x$ac_cv_prog_javac_works = xno; then + AC_MSG_ERROR([Cannot compile java source. $JAVAC does not work properly]) + fi + if test x$ac_cv_prog_javac_works = x; then + AX_PROG_JAVAC + fi +fi +AC_CACHE_CHECK(if $JAVA works, ac_cv_prog_java_works, [ +JAVA_TEST=Test.java +CLASS_TEST=Test.class +TEST=Test +changequote(, )dnl +cat << \EOF > $JAVA_TEST +/* [#]line __oline__ "configure" */ +public class Test { +public static void main (String args[]) { + System.exit (0); +} } +EOF +changequote([, ])dnl +if test x$ac_cv_prog_uudecode_base64 != xyes; then + if AC_TRY_COMMAND($JAVAC $JAVACFLAGS $JAVA_TEST) && test -s $CLASS_TEST; then + : + else + echo "configure: failed program was:" >&AS_MESSAGE_LOG_FD + cat $JAVA_TEST >&AS_MESSAGE_LOG_FD + AC_MSG_ERROR(The Java compiler $JAVAC failed (see config.log, check the CLASSPATH?)) + fi +fi +if AC_TRY_COMMAND($JAVA -classpath . $JAVAFLAGS $TEST) >/dev/null 2>&1; then + ac_cv_prog_java_works=yes +else + echo "configure: failed program was:" >&AS_MESSAGE_LOG_FD + cat $JAVA_TEST >&AS_MESSAGE_LOG_FD + AC_MSG_ERROR(The Java VM $JAVA failed (see config.log, check the CLASSPATH?)) +fi +rm -fr $JAVA_TEST $CLASS_TEST Test.uue +]) +AC_PROVIDE([$0])dnl +] +) diff --git a/vpp-api/java/m4/ax_prog_javac.m4 b/vpp-api/java/m4/ax_prog_javac.m4 new file mode 100644 index 00000000..d061243c --- /dev/null +++ b/vpp-api/java/m4/ax_prog_javac.m4 @@ -0,0 +1,79 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_prog_javac.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_PROG_JAVAC +# +# DESCRIPTION +# +# AX_PROG_JAVAC tests an existing Java compiler. It uses the environment +# variable JAVAC then tests in sequence various common Java compilers. For +# political reasons, it starts with the free ones. +# +# If you want to force a specific compiler: +# +# - at the configure.in level, set JAVAC=yourcompiler before calling +# AX_PROG_JAVAC +# +# - at the configure level, setenv JAVAC +# +# You can use the JAVAC variable in your Makefile.in, with @JAVAC@. +# +# *Warning*: its success or failure can depend on a proper setting of the +# CLASSPATH env. variable. +# +# TODO: allow to exclude compilers (rationale: most Java programs cannot +# compile with some compilers like guavac). +# +# Note: This is part of the set of autoconf M4 macros for Java programs. +# It is VERY IMPORTANT that you download the whole set, some macros depend +# on other. Unfortunately, the autoconf archive does not support the +# concept of set of macros, so I had to break it for submission. The +# general documentation, as well as the sample configure.in, is included +# in the AX_PROG_JAVA macro. +# +# LICENSE +# +# Copyright (c) 2008 Stephane Bortzmeyer +# +# 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 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 . +# +# As a special exception, the respective Autoconf Macro's copyright owner +# gives unlimited permission to copy, distribute and modify the configure +# scripts that are the output of Autoconf when processing the Macro. You +# need not follow the terms of the GNU General Public License when using +# or distributing such scripts, even though portions of the text of the +# Macro appear in them. The GNU General Public License (GPL) does govern +# all other use of the material that constitutes the Autoconf Macro. +# +# This special exception to the GPL applies to versions of the Autoconf +# Macro released by the Autoconf Archive. When you make and distribute a +# modified version of the Autoconf Macro, you may extend this special +# exception to the GPL to apply to your modified version as well. + +#serial 7 + +AU_ALIAS([AC_PROG_JAVAC], [AX_PROG_JAVAC]) +AC_DEFUN([AX_PROG_JAVAC],[ +m4_define([m4_ax_prog_javac_list],["gcj -C" guavac jikes javac])dnl +AS_IF([test "x$JAVAPREFIX" = x], + [test "x$JAVAC" = x && AC_CHECK_PROGS([JAVAC], [m4_ax_prog_javac_list])], + [test "x$JAVAC" = x && AC_CHECK_PROGS([JAVAC], [m4_ax_prog_javac_list], [], [$JAVAPREFIX/bin])]) +m4_undefine([m4_ax_prog_javac_list])dnl +test "x$JAVAC" = x && AC_MSG_ERROR([no acceptable Java compiler found in \$PATH]) +AX_PROG_JAVAC_WORKS +AC_PROVIDE([$0])dnl +]) diff --git a/vpp-api/java/m4/ax_prog_javac_works.m4 b/vpp-api/java/m4/ax_prog_javac_works.m4 new file mode 100644 index 00000000..7dfa1e37 --- /dev/null +++ b/vpp-api/java/m4/ax_prog_javac_works.m4 @@ -0,0 +1,72 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_prog_javac_works.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_PROG_JAVAC_WORKS +# +# DESCRIPTION +# +# Internal use ONLY. +# +# Note: This is part of the set of autoconf M4 macros for Java programs. +# It is VERY IMPORTANT that you download the whole set, some macros depend +# on other. Unfortunately, the autoconf archive does not support the +# concept of set of macros, so I had to break it for submission. The +# general documentation, as well as the sample configure.in, is included +# in the AX_PROG_JAVA macro. +# +# LICENSE +# +# Copyright (c) 2008 Stephane Bortzmeyer +# +# 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 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 . +# +# As a special exception, the respective Autoconf Macro's copyright owner +# gives unlimited permission to copy, distribute and modify the configure +# scripts that are the output of Autoconf when processing the Macro. You +# need not follow the terms of the GNU General Public License when using +# or distributing such scripts, even though portions of the text of the +# Macro appear in them. The GNU General Public License (GPL) does govern +# all other use of the material that constitutes the Autoconf Macro. +# +# This special exception to the GPL applies to versions of the Autoconf +# Macro released by the Autoconf Archive. When you make and distribute a +# modified version of the Autoconf Macro, you may extend this special +# exception to the GPL to apply to your modified version as well. + +#serial 6 + +AU_ALIAS([AC_PROG_JAVAC_WORKS], [AX_PROG_JAVAC_WORKS]) +AC_DEFUN([AX_PROG_JAVAC_WORKS],[ +AC_CACHE_CHECK([if $JAVAC works], ac_cv_prog_javac_works, [ +JAVA_TEST=Test.java +CLASS_TEST=Test.class +cat << \EOF > $JAVA_TEST +/* [#]line __oline__ "configure" */ +public class Test { +} +EOF +if AC_TRY_COMMAND($JAVAC $JAVACFLAGS $JAVA_TEST) >/dev/null 2>&1; then + ac_cv_prog_javac_works=yes +else + AC_MSG_ERROR([The Java compiler $JAVAC failed (see config.log, check the CLASSPATH?)]) + echo "configure: failed program was:" >&AS_MESSAGE_LOG_FD + cat $JAVA_TEST >&AS_MESSAGE_LOG_FD +fi +rm -f $JAVA_TEST $CLASS_TEST +]) +AC_PROVIDE([$0])dnl +]) diff --git a/vpp-api/java/m4/ax_prog_javadoc.m4 b/vpp-api/java/m4/ax_prog_javadoc.m4 new file mode 100644 index 00000000..bcb6045a --- /dev/null +++ b/vpp-api/java/m4/ax_prog_javadoc.m4 @@ -0,0 +1,50 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_prog_javadoc.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_PROG_JAVADOC +# +# DESCRIPTION +# +# AX_PROG_JAVADOC tests for an existing javadoc generator. It uses the +# environment variable JAVADOC then tests in sequence various common +# javadoc generator. +# +# If you want to force a specific compiler: +# +# - at the configure.in level, set JAVADOC=yourgenerator before calling +# AX_PROG_JAVADOC +# +# - at the configure level, setenv JAVADOC +# +# You can use the JAVADOC variable in your Makefile.in, with @JAVADOC@. +# +# Note: This macro depends on the autoconf M4 macros for Java programs. It +# is VERY IMPORTANT that you download that whole set, some macros depend +# on other. Unfortunately, the autoconf archive does not support the +# concept of set of macros, so I had to break it for submission. +# +# The general documentation of those macros, as well as the sample +# configure.in, is included in the AX_PROG_JAVA macro. +# +# LICENSE +# +# Copyright (c) 2008 Egon Willighagen +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. + +#serial 8 + +AU_ALIAS([AC_PROG_JAVADOC], [AX_PROG_JAVADOC]) +AC_DEFUN([AX_PROG_JAVADOC],[ +AS_IF([test "x$JAVAPREFIX" = x], + [test "x$JAVADOC" = x && AC_CHECK_PROGS([JAVADOC], [javadoc])], + [test "x$JAVADOC" = x && AC_CHECK_PROGS([JAVADOC], [javadoc], [], [$JAVAPREFIX/bin])]) +test "x$JAVADOC" = x && AC_MSG_ERROR([no acceptable javadoc generator found in \$PATH]) +AC_PROVIDE([$0])dnl +]) diff --git a/vpp-api/java/m4/ax_prog_javah.m4 b/vpp-api/java/m4/ax_prog_javah.m4 new file mode 100644 index 00000000..cefc616d --- /dev/null +++ b/vpp-api/java/m4/ax_prog_javah.m4 @@ -0,0 +1,64 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_prog_javah.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_PROG_JAVAH +# +# DESCRIPTION +# +# AX_PROG_JAVAH tests the availability of the javah header generator and +# looks for the jni.h header file. If available, JAVAH is set to the full +# path of javah and CPPFLAGS is updated accordingly. +# +# LICENSE +# +# Copyright (c) 2008 Luc Maisonobe +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. + +#serial 8 + +AU_ALIAS([AC_PROG_JAVAH], [AX_PROG_JAVAH]) +AC_DEFUN([AX_PROG_JAVAH],[ +AC_REQUIRE([AC_CANONICAL_BUILD])dnl +AC_REQUIRE([AC_PROG_CPP])dnl +AC_PATH_PROG(JAVAH,javah) +AS_IF([test -n "$ac_cv_path_JAVAH"], + [ + AC_TRY_CPP([#include ],,[ + ac_save_CPPFLAGS="$CPPFLAGS" + _ACJAVAH_FOLLOW_SYMLINKS("$ac_cv_path_JAVAH") + ax_prog_javah_bin_dir=`AS_DIRNAME([$_ACJAVAH_FOLLOWED])` + ac_dir="`AS_DIRNAME([$ax_prog_javah_bin_dir])`/include" + AS_CASE([$build_os], + [cygwin*], + [ac_machdep=win32], + [ac_machdep=`AS_ECHO($build_os) | sed 's,[[-0-9]].*,,'`]) + CPPFLAGS="$ac_save_CPPFLAGS -I$ac_dir -I$ac_dir/$ac_machdep" + AC_TRY_CPP([#include ], + ac_save_CPPFLAGS="$CPPFLAGS", + AC_MSG_WARN([unable to include ])) + CPPFLAGS="$ac_save_CPPFLAGS"]) + ]) +]) + +AC_DEFUN([_ACJAVAH_FOLLOW_SYMLINKS],[ +# find the include directory relative to the javac executable +_cur="$1" +while ls -ld "$_cur" 2>/dev/null | grep " -> " >/dev/null; do + AC_MSG_CHECKING([symlink for $_cur]) + _slink=`ls -ld "$_cur" | sed 's/.* -> //'` + case "$_slink" in + /*) _cur="$_slink";; + # 'X' avoids triggering unwanted echo options. + *) _cur=`echo "X$_cur" | sed -e 's/^X//' -e 's:[[^/]]*$::'`"$_slink";; + esac + AC_MSG_RESULT([$_cur]) +done +_ACJAVAH_FOLLOWED="$_cur" +]) diff --git a/vpp-api/java/m4/ax_try_compile_java.m4 b/vpp-api/java/m4/ax_try_compile_java.m4 new file mode 100644 index 00000000..a8ed6b2a --- /dev/null +++ b/vpp-api/java/m4/ax_try_compile_java.m4 @@ -0,0 +1,55 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_try_compile_java.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_TRY_COMPILE_JAVA +# +# DESCRIPTION +# +# AX_TRY_COMPILE_JAVA attempt to compile user given source. +# +# *Warning*: its success or failure can depend on a proper setting of the +# CLASSPATH env. variable. +# +# Note: This is part of the set of autoconf M4 macros for Java programs. +# It is VERY IMPORTANT that you download the whole set, some macros depend +# on other. Unfortunately, the autoconf archive does not support the +# concept of set of macros, so I had to break it for submission. The +# general documentation, as well as the sample configure.in, is included +# in the AX_PROG_JAVA macro. +# +# LICENSE +# +# Copyright (c) 2008 Devin Weaver +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. + +#serial 8 + +AU_ALIAS([AC_TRY_COMPILE_JAVA], [AX_TRY_COMPILE_JAVA]) +AC_DEFUN([AX_TRY_COMPILE_JAVA],[ +AC_REQUIRE([AX_PROG_JAVAC])dnl +cat << \EOF > Test.java +/* [#]line __oline__ "configure" */ +ifelse([$1], , , [import $1;]) +public class Test { +[$2] +} +EOF +if AC_TRY_COMMAND($JAVAC $JAVACFLAGS Test.java) && test -s Test.class +then +dnl Don't remove the temporary files here, so they can be examined. + ifelse([$3], , :, [$3]) +else + echo "configure: failed program was:" >&AS_MESSAGE_LOG_FD + cat Test.java >&AS_MESSAGE_LOG_FD +ifelse([$4], , , [ rm -fr Test.java Test.class + $4 +])dnl +fi +rm -fr Test.java Test.class]) diff --git a/vpp-api/java/m4/ax_try_run_java.m4 b/vpp-api/java/m4/ax_try_run_java.m4 new file mode 100644 index 00000000..c680f03f --- /dev/null +++ b/vpp-api/java/m4/ax_try_run_java.m4 @@ -0,0 +1,56 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_try_run_java.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_TRY_RUN_JAVA +# +# DESCRIPTION +# +# AX_TRY_RUN_JAVA attempt to compile and run user given source. +# +# *Warning*: its success or failure can depend on a proper setting of the +# CLASSPATH env. variable. +# +# Note: This is part of the set of autoconf M4 macros for Java programs. +# It is VERY IMPORTANT that you download the whole set, some macros depend +# on other. Unfortunately, the autoconf archive does not support the +# concept of set of macros, so I had to break it for submission. The +# general documentation, as well as the sample configure.in, is included +# in the AX_PROG_JAVA macro. +# +# LICENSE +# +# Copyright (c) 2008 Devin Weaver +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. + +#serial 2 + +AU_ALIAS([AC_TRY_RUN_JAVA], [AX_TRY_RUN_JAVA]) +AC_DEFUN([AX_TRY_RUN_JAVA],[ +AC_REQUIRE([AX_PROG_JAVAC])dnl +AC_REQUIRE([AX_PROG_JAVA])dnl +cat << \EOF > Test.java +/* [#]line __oline__ "configure" */ +ifelse([$1], , , [include $1;]) +public class Test { +[$2] +} +EOF +if AC_TRY_COMMAND($JAVAC $JAVACFLAGS Test.java) && test -s Test.class && ($JAVA $JAVAFLAGS Test; exit) 2>/dev/null +then +dnl Don't remove the temporary files here, so they can be examined. + ifelse([$3], , :, [$3]) +else + echo "configure: failed program was:" >&AS_MESSAGE_LOG_FD + cat Test.java >&AS_MESSAGE_LOG_FD +ifelse([$4], , , [ rm -fr Test.java Test.class + $4 +])dnl +fi +rm -fr Test.java Test.class]) diff --git a/vpp-api/python/Makefile.am b/vpp-api/python/Makefile.am new file mode 100644 index 00000000..b96ff3d9 --- /dev/null +++ b/vpp-api/python/Makefile.am @@ -0,0 +1,49 @@ +# Copyright (c) 2016 Cisco and/or its affiliates. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +AUTOMAKE_OPTIONS = foreign subdir-objects +ACLOCAL_AMFLAGS = -I m4 +AM_CFLAGS = -Wall + +BUILT_SOURCES = +bin_PROGRAMS = +CLEANFILES = +lib_LTLIBRARIES = +noinst_PROGRAMS = test_pneum +nobase_include_HEADERS = pneum/pneum.h + +# +# Python binding +# +lib_LTLIBRARIES += libpneum.la +libpneum_la_SOURCES = pneum/pneum.c +libpneum_la_LIBADD = -lvlibmemoryclient -lvlibapi -lsvm -lvppinfra -lpthread -lm -lrt +libpneum_la_LDFLAGS = -module +libpneum_la_CPPFLAGS = + +BUILT_SOURCES += vpp_papi.py + +vpp_papi.py: $(prefix)/../vpp/api/vpe.api pneum/api-gen.py + @echo " PYTHON API"; \ + $(CC) $(CPPFLAGS) -E -P -C -x c $< \ + | vppapigen --input - --python defs_$@; \ + echo "#include " \ + | $(CC) $(CPPFLAGS) -E -P -x c - | grep VL_API \ + | @srcdir@/pneum/api-gen.py -i defs_$@ > @srcdir@/vpp_papi/$@ + +# +# Test client +# +noinst_PROGRAMS += test_pneum +test_pneum_SOURCES = pneum/pneum.c pneum/test_pneum.c +test_pneum_LDADD = -lvlibmemoryclient -lvlibapi -lsvm -lvppinfra -lpthread -lm -lrt diff --git a/vpp-api/python/README.rst b/vpp-api/python/README.rst new file mode 100644 index 00000000..e69de29b diff --git a/vpp-api/python/pneum/api-gen.py b/vpp-api/python/pneum/api-gen.py new file mode 100755 index 00000000..bbc9c329 --- /dev/null +++ b/vpp-api/python/pneum/api-gen.py @@ -0,0 +1,337 @@ +#!/usr/bin/env python +# +# Copyright (c) 2016 Cisco and/or its affiliates. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +import argparse, sys, os, importlib, pprint + +parser = argparse.ArgumentParser(description='VPP Python API generator') +parser.add_argument('-i', action="store", dest="inputfile") +parser.add_argument('-c', '--cfile', action="store") +args = parser.parse_args() + +sys.path.append(".") + +inputfile = args.inputfile.replace('.py', '') +cfg = importlib.import_module(inputfile, package=None) + +# https://docs.python.org/3/library/struct.html +format_struct = {'u8': 'B', + 'u16' : 'H', + 'u32' : 'I', + 'i32' : 'i', + 'u64' : 'Q', + 'f64' : 'd', + 'vl_api_ip4_fib_counter_t' : 'IBQQ', + 'vl_api_ip6_fib_counter_t' : 'QQBQQ', + }; +type_size = {'u8': 1, + 'u16' : 2, + 'u32' : 4, + 'i32' : 4, + 'u64' : 8, + 'f64' : 8, + 'vl_api_ip4_fib_counter_t' : 21, + 'vl_api_ip6_fib_counter_t' : 33, +}; + +def get_args(t): + args = None + for i in t: + arg = i[1] + arg = arg.replace('_','') + if args == None: + args = arg + continue + args = args + ', ' + arg + return args + +def get_pack(t): + bytecount = 0 + pack = '>' + tup = u'' + j = -1 + for i in t: + j += 1 + if len(i) is 3: + size = type_size[i[0]] + bytecount += size * int(i[2]) + if i[2] == '0': + tup += 'msg[' + str(bytecount) + ':],' + continue + if size == 1: + n = i[2] * size + pack += str(n) + 's' + tup += 'tr[' + str(j) + '],' + continue + pack += format_struct[i[0]] * int(i[2]) + tup += 'tr[' + str(j) + ':' + str(j + int(i[2])) + '],' + j += int(i[2]) - 1 + else: + bytecount += type_size[i[0]] + pack += format_struct[i[0]] + tup += 'tr[' + str(j) + '],' + return pack, bytecount, tup + +def get_reply_func(f): + if f['name']+'_reply' in func_name: + return func_name[f['name']+'_reply'] + if f['name'].find('_dump') > 0: + r = f['name'].replace('_dump','_details') + if r in func_name: + return func_name[r] + return None + +def get_enums(): + # Read enums from stdin + enums_by_name = {} + enums_by_index = {} + i = 1 + for l in sys.stdin: + l = l.replace(',\n','') + print l, "=", i + + l = l.replace('VL_API_','').lower() + enums_by_name[l] = i + enums_by_index[i] = l + + i += 1 + return enums_by_name, enums_by_index + +def get_definitions(): + # Pass 1 + func_list = [] + func_name = {} + i = 1 + for a in cfg.vppapidef: + pack, packlen, tup = get_pack(a[1:]) + func_name[a[0]] = dict([('name', a[0]), ('args', get_args(a[4:])), ('full_args', get_args(a[1:])), ('pack', pack), ('packlen', packlen), ('tup', tup)]) + func_list.append(func_name[a[0]]) # Indexed by name + return func_list, func_name + +def generate_c_macros(func_list, enums_by_name): + file = open(args.cfile, 'w+') + print >>file, "#define foreach_api_msg \\" + for f in func_list: + if not f['name'] in enums_by_name: + continue + print >>file, "_(" + f['name'].upper() + ", " + f['name'] + ") \\" + print >>file, ''' +void pneum_set_handlers(void) { +#define _(N,n) \\ + api_func_table[VL_API_##N] = sizeof(vl_api_##n##_t); + foreach_api_msg; +#undef _ +} + ''' + +# +# XXX:Deal with empty arrays +# Print array with a hash of 'decode' and 'multipart' +# Simplify to do only decode for now. And deduce multipart from _dump? +# +def decode_function_print(name, args, pack, packlen, tup): + + print(u'def ' + name + u'_decode(msg):') + print(u" n = namedtuple('" + name + "', '" + args + "')" + + ''' + if not n: + return None + ''') + print(u" tr = unpack('" + pack + "', msg[:" + str(packlen) + "])") + print(u" r = n._make((" + tup + "))" + + ''' + if not r: + return None + return r + ''') + +def function_print(name, id, args, pack, multipart): + if not args: + args = "" + print "def", name + "(async = False):" + else: + print "def", name + "(" + args + ",async = False):" + print " global waiting_for_reply" + print " context = get_context(" + id + ")" + + print ''' + results[context] = {} + results[context]['e'] = threading.Event() + results[context]['e'].clear() + results[context]['r'] = [] + waiting_for_reply = True + ''' + if multipart == True: + print " results[context]['m'] = True" + + print " vpp_api.write(pack('" + pack + "', " + id + ", 0, context, " + args + "))" + + if multipart == True: + print " vpp_api.write(pack('>HII', VL_API_CONTROL_PING, 0, context))" + + print ''' + if not async: + results[context]['e'].wait(5) + return results[context]['r'] + return context + ''' + +# +# Should dynamically create size +# +def api_table_print (name, msg_id): + f = name + '_decode' + print('api_func_table[' + msg_id + '] = ' + f) + +# +# Generate the main Python file +# + +print '''#!/usr/bin/env python3 + +import sys, time, threading, signal, os, logging +from struct import * +from collections import namedtuple + +# +# Import C API shared object +# +import vpp_api + +context = 0 +results = {} +waiting_for_reply = False + +# +# XXX: Make this return a unique number +# +def get_context(id): + global context + context += 1 + return context + +def msg_handler(msg): + global result, context, event_callback, waiting_for_reply + if not msg: + logging.warning('vpp_api.read failed') + return + + id = unpack('>H', msg[0:2]) + logging.debug('Received message', id[0]) + if id[0] == VL_API_RX_THREAD_EXIT: + logging.info("We got told to leave") + return; + + # + # Decode message and returns a tuple. + # + logging.debug('api_func', api_func_table[id[0]]) + r = api_func_table[id[0]](msg) + if not r: + logging.warning('Message decode failed', id[0]) + return + + if 'context' in r._asdict(): + if r.context > 0: + context = r.context + + # + # XXX: Call provided callback for event + # Are we guaranteed to not get an event during processing of other messages? + # How to differentiate what's a callback message and what not? Context = 0? + # + logging.debug('R:', context, r, waiting_for_reply) + if waiting_for_reply == False: + event_callback(r) + return + + # + # Collect results until control ping + # + if id[0] == VL_API_CONTROL_PING_REPLY: + results[context]['e'].set() + waiting_for_reply = False + return + if not context in results: + logging.warning('Not expecting results for this context', context) + return + if 'm' in results[context]: + results[context]['r'].append(r) + return + + results[context]['r'] = r + results[context]['e'].set() + waiting_for_reply = False + +def connect(name): + signal.alarm(3) # 3 second + rv = vpp_api.connect(name, msg_handler) + signal.alarm(0) + logging.info("Connect:", rv) + return rv + +def disconnect(): + rv = vpp_api.disconnect() + logging.info("Disconnected") + return rv + +def register_event_callback(callback): + global event_callback + event_callback = callback +''' + +enums_by_name, enums_by_index = get_enums() +func_list, func_name = get_definitions() + +# +# Not needed with the new msg_size field. +# generate_c_macros(func_list, enums_by_name) +# + +pp = pprint.PrettyPrinter(indent=4) +#print 'enums_by_index =', pp.pprint(enums_by_index) +#print 'func_name =', pp.pprint(func_name) + +# Pass 2 + +# +# 1) The VPE API lacks a clear definition of what messages are reply messages +# 2) Length is missing, and has to be pre-known or in case of variable sized ones calculated per message type +# +for f in func_list: + #if f['name'].find('_reply') > 0 or f['name'].find('_details') > 0: + decode_function_print(f['name'], f['full_args'], f['pack'], f['packlen'], f['tup']) + + #r = get_reply_func(f) + #if not r: + # # + # # XXX: Functions here are not taken care of. E.g. events + # # + # print('Missing function', f) + # continue + + if f['name'].find('_dump') > 0: + f['multipart'] = True + else: + f['multipart'] = False + msg_id_in = 'VL_API_' + f['name'].upper() + function_print(f['name'], msg_id_in, f['args'], f['pack'], f['multipart']) + + +print "api_func_table = [0] * 10000" +for f in func_list: + # if f['name'].find('_reply') > 0 or f['name'].find('_details') > 0: + msg_id_in = 'VL_API_' + f['name'].upper() + api_table_print(f['name'], msg_id_in) diff --git a/vpp-api/python/pneum/pneum.c b/vpp-api/python/pneum/pneum.c new file mode 100644 index 00000000..971c79bf --- /dev/null +++ b/vpp-api/python/pneum/pneum.c @@ -0,0 +1,239 @@ +/* + * Copyright (c) 2016 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include + +#include "pneum.h" + +#define vl_typedefs /* define message structures */ +#include +#undef vl_typedefs + +#define vl_endianfun /* define message structures */ +#include +#undef vl_endianfun + +typedef struct { + u8 rx_thread_jmpbuf_valid; + u8 connected_to_vlib; + jmp_buf rx_thread_jmpbuf; + pthread_t rx_thread_handle; +} pneum_main_t; + +pneum_main_t pneum_main; + +extern int wrap_pneum_callback(char *data, int len); + +/* + * Satisfy external references when -lvlib is not available. + */ +void vlib_cli_output (struct vlib_main_t * vm, char * fmt, ...) +{ + clib_warning ("vlib_cli_output callled..."); +} + +#define vl_api_version(n,v) static u32 vpe_api_version = v; +#include +#undef vl_api_version +void +vl_client_add_api_signatures (vl_api_memclnt_create_t *mp) +{ + /* + * Send the main API signature in slot 0. This bit of code must + * match the checks in ../vpe/api/api.c: vl_msg_api_version_check(). + */ + mp->api_versions[0] = clib_host_to_net_u32 (vpe_api_version); +} + +static void +pneum_api_handler (void *msg) +{ + u16 id = ntohs(*((u16 *)msg)); + + if (id == VL_API_RX_THREAD_EXIT) { + pneum_main_t *pm = &pneum_main; + vl_msg_api_free(msg); + longjmp(pm->rx_thread_jmpbuf, 1); + } + msgbuf_t *msgbuf = (msgbuf_t *)(((u8 *)msg) - offsetof(msgbuf_t, data)); + int l = ntohl(msgbuf->data_len); + if (l == 0) + clib_warning("Message ID %d has wrong length: %d\n", id, l); + + /* Call Python callback */ + (void)wrap_pneum_callback(msg, l); + vl_msg_api_free(msg); +} + +static void * +pneum_rx_thread_fn (void *arg) +{ + unix_shared_memory_queue_t *q; + pneum_main_t *pm = &pneum_main; + api_main_t *am = &api_main; + uword msg; + + q = am->vl_input_queue; + + /* So we can make the rx thread terminate cleanly */ + if (setjmp(pm->rx_thread_jmpbuf) == 0) { + pm->rx_thread_jmpbuf_valid = 1; + while (1) + while (!unix_shared_memory_queue_sub(q, (u8 *)&msg, 0)) + pneum_api_handler((void *)msg); + } + pthread_exit(0); +} + +int +pneum_connect (char *name) +{ + int rv = 0; + pneum_main_t *pm = &pneum_main; + + /* + * Bail out now if we're not running as root + */ + if (geteuid() != 0) + return (-1); + + if ((rv = vl_client_api_map("/vpe-api"))) { + clib_warning ("vl_client_api map rv %d", rv); + return rv; + } + + if (vl_client_connect(name, 0, 32) < 0) { + vl_client_api_unmap(); + return (-1); + } + + /* Start the rx queue thread */ + rv = pthread_create(&pm->rx_thread_handle, NULL, pneum_rx_thread_fn, 0); + if (rv) { + clib_warning("pthread_create returned %d", rv); + vl_client_api_unmap(); + return (-1); + } + + pm->connected_to_vlib = 1; + + return (0); +} + +int +pneum_disconnect (void) +{ + api_main_t *am = &api_main; + pneum_main_t *pm = &pneum_main; + + fformat (stdout,"disconnecting from vpe \n"); + + if (pm->rx_thread_jmpbuf_valid) { + vl_api_rx_thread_exit_t *ep; + uword junk; + ep = vl_msg_api_alloc (sizeof (*ep)); + ep->_vl_msg_id = ntohs(VL_API_RX_THREAD_EXIT); + vl_msg_api_send_shmem(am->vl_input_queue, (u8 *)&ep); + pthread_join(pm->rx_thread_handle, (void **) &junk); + } + if (pm->connected_to_vlib) { + vl_client_disconnect(); + vl_client_api_unmap(); + } + memset (pm, 0, sizeof (*pm)); + + return (0); +} + +int +pneum_read (char **p, int *l) +{ + unix_shared_memory_queue_t *q; + api_main_t *am = &api_main; + uword msg; + + *l = 0; + + if (am->our_pid == 0) return (-1); + + q = am->vl_input_queue; + int rv = unix_shared_memory_queue_sub(q, (u8 *)&msg, 0); + if (rv == 0) { + u16 msg_id = ntohs(*((u16 *)msg)); + msgbuf_t *msgbuf = (msgbuf_t *)(((u8 *)msg) - offsetof(msgbuf_t, data)); + *l = ntohl(msgbuf->data_len); + if (*l == 0) { + printf("Unregistered API message: %d\n", msg_id); + return (-1); + } + *p = (char *)msg; + } else { + printf("Read failed with %d\n", rv); + } + return (rv); +} + +/* + * XXX: Makes the assumption that client_index is the first member + */ +typedef VL_API_PACKED(struct _vl_api_header { + u16 _vl_msg_id; + u32 client_index; +}) vl_api_header_t; + +static unsigned int +pneum_client_index (void) +{ + return (api_main.my_client_index); +} + +int +pneum_write (char *p, int l) +{ + int rv = -1; + api_main_t *am = &api_main; + vl_api_header_t *mp = vl_msg_api_alloc(l); + unix_shared_memory_queue_t *q; + + if (!mp) return (-1); + memcpy(mp, p, l); + mp->client_index = pneum_client_index(); + q = am->shmem_hdr->vl_input_queue; + rv = unix_shared_memory_queue_add(q, (u8 *)&mp, 0); + if (rv != 0) { + printf("vpe_api_write fails: %d\n", rv); + /* Clear message */ + vl_msg_api_free(mp); + } + return (rv); +} diff --git a/vpp-api/python/pneum/pneum.h b/vpp-api/python/pneum/pneum.h new file mode 100644 index 00000000..b99cbd4e --- /dev/null +++ b/vpp-api/python/pneum/pneum.h @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2016 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef __included_pneum_h__ +#define __included_pneum_h__ + +unsigned int vpe_client_index(void); +int pneum_connect(char *name); +int pneum_disconnect(void); +int pneum_read(char **data, int *l); +int pneum_write(char *data, int len); + +#endif diff --git a/vpp-api/python/pneum/test_pneum.c b/vpp-api/python/pneum/test_pneum.c new file mode 100644 index 00000000..18627b3f --- /dev/null +++ b/vpp-api/python/pneum/test_pneum.c @@ -0,0 +1,136 @@ +/* + *------------------------------------------------------------------ + * test_pneum.c + * + * Copyright (c) 2016 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------ + */ +#include +#include +#include +#include +#include +#include +#include +#include + +#include /* time_t, time (for timestamp in second) */ +#include /* ftime, timeb (for timestamp in millisecond) */ +#include /* gettimeofday, timeval (for timestamp in microsecond) */ + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include "pneum.h" + +#define vl_typedefs /* define message structures */ +#include +#undef vl_typedefs + +volatile int sigterm_received = 0; +volatile u32 result_ready; +volatile u16 result_msg_id; + +/* M_NOALLOC: construct, but don't yet send a message */ + +#define M_NOALLOC(T,t) \ + do { \ + result_ready = 0; \ + memset (mp, 0, sizeof (*mp)); \ + mp->_vl_msg_id = ntohs (VL_API_##T); \ + mp->client_index = am->my_client_index; \ + } while(0); + + + +int +wrap_pneum_callback (char *data, int len) +{ + //printf("Callback %d\n", len); + result_ready = 1; + result_msg_id = ntohs(*((u16 *)data)); + return (0); +} + +int main (int argc, char ** argv) +{ + api_main_t * am = &api_main; + vl_api_show_version_t message; + vl_api_show_version_t *mp; + int async = 1; + int rv = pneum_connect("pneum_client"); + + if (rv != 0) { + printf("Connect failed: %d\n", rv); + exit(rv); + } + + struct timeb timer_msec; + long long int timestamp_msec_start; /* timestamp in millisecond. */ + if (!ftime(&timer_msec)) { + timestamp_msec_start = ((long long int) timer_msec.time) * 1000ll + + (long long int) timer_msec.millitm; + } + else { + timestamp_msec_start = -1; + } + + + /* + * Test vpe_api_write and vpe_api_read to send and recv message for an + * API + */ + int i; + long int no_msgs = 10000; + mp = &message; + + for (i = 0; i < no_msgs; i++) { + /* Construct the API message */ + M_NOALLOC(SHOW_VERSION, show_version); + pneum_write((char *)mp, sizeof(*mp)); + if (!async) + while (result_ready == 0); + } + if (async) { + vl_api_control_ping_t control; + vl_api_control_ping_t *mp; + mp = &control; + M_NOALLOC(CONTROL_PING, control_ping); + pneum_write((char *)mp, sizeof(*mp)); + + while (result_msg_id != VL_API_CONTROL_PING_REPLY); + } + + long long int timestamp_msec_end; /* timestamp in millisecond. */ + if (!ftime(&timer_msec)) { + timestamp_msec_end = ((long long int) timer_msec.time) * 1000ll + + (long long int) timer_msec.millitm; + } + else { + timestamp_msec_end = -1; + } + + printf("Took %lld msec, %lld msgs/msec \n", (timestamp_msec_end - timestamp_msec_start), + no_msgs/(timestamp_msec_end - timestamp_msec_start)); + fformat(stdout, "Exiting...\n"); + pneum_disconnect(); + exit (0); +} diff --git a/vpp-api/python/setup.py b/vpp-api/python/setup.py new file mode 100644 index 00000000..d890ba70 --- /dev/null +++ b/vpp-api/python/setup.py @@ -0,0 +1,21 @@ +from distutils.core import setup, Extension + +module1 = Extension('vpp_api', + define_macros = [('MAJOR_VERSION', '1'), + ('MINOR_VERSION', '0')], + include_dirs = ['pneum'], + libraries = ['pneum'], + library_dirs = ['../../build-root/install-vpp_debug-native/vpp-api/lib64'], + sources = ['vpp_papi/pneum_wrap.c']) + +setup (name = 'vpp_papi', + version = '1.0', + description = 'VPP Python binding', + author = 'Ole Troan', + author_email = 'ot@cisco.com', + #url = 'https://docs.python.org/extending/building', + packages=['vpp_papi'], + long_description = ''' +VPP Python language binding. +''', + ext_modules = [module1]) diff --git a/vpp-api/python/tests/test_papi.py b/vpp-api/python/tests/test_papi.py new file mode 100755 index 00000000..ec51f093 --- /dev/null +++ b/vpp-api/python/tests/test_papi.py @@ -0,0 +1,125 @@ +#!/usr/bin/env python3 + +import vpp_papi +import unittest, sys, time, threading, struct, logging +from ipaddress import * + +papi_event = threading.Event() +def papi_event_handler(result): + if result.vlmsgid == vpp_papi.VL_API_SW_INTERFACE_SET_FLAGS: + papi_event.set() + return + if result.vlmsgid == vpp_papi.VL_API_VNET_INTERFACE_COUNTERS: + format = '>' + str(int(len(result.data) / 8)) + 'Q' + counters = struct.unpack(format, result.data) + print('Counters:', counters) + return + + print('Unknown message id:', result.vlmsgid) + +class TestPAPI(unittest.TestCase): + + def setUp(self): + r = vpp_papi.connect("test_papi") + self.assertEqual(r, 0) + + def tearDown(self): + r = vpp_papi.disconnect() + self.assertEqual(r, 0) + + def test_show_version(self): + t = vpp_papi.show_version() + program = t.program.decode().rstrip('\x00') + self.assertEqual('vpe', program) + + # + # Add a few MAP domains, then dump them later + # + def test_map(self): + t = vpp_papi.map_summary_stats() + print(t) + ip6 = IPv6Address(u'2001:db8::1').packed + ip4 = IPv4Address(u'10.0.0.0').packed + ip6_src = IPv6Address(u'2001:db9::1').packed + t = vpp_papi.map_add_domain(ip6, ip4, ip6_src, 32, 24, 128, 0, 0, 6, 0, 0) + print(t) + self.assertEqual(t.retval, 0) + + ip4 = IPv4Address(u'10.0.1.0').packed + t = vpp_papi.map_add_domain(ip6, ip4, ip6_src, 32, 24, 128, 0, 0, 6, 0, 0) + print(t) + self.assertEqual(t.retval, 0) + + t = vpp_papi.map_summary_stats() + print(t) + self.assertEqual(t.totalbindings, 2) + + t = vpp_papi.map_domain_dump() + print (t) + self.assertEqual(len(t), 2) + + def test_sw_interface_dump(self): + # + # Dump interfaces + # + t = vpp_papi.sw_interface_dump(0, b'ignored') + for interface in t: + if interface.vlmsgid == vpp_papi.VL_API_SW_INTERFACE_DETAILS: + print(interface.interfacename.decode()) + + def test_want_interface_events(self): + pid = 123 + vpp_papi.register_event_callback(papi_event_handler) + papi_event.clear() + t = vpp_papi.want_interface_events(True, pid) + print (t) + print('Setting interface up') + t = vpp_papi.sw_interface_set_flags(0, 1, 1, 0) + print (t) + self.assertEqual(papi_event.wait(5), True) + t = vpp_papi.sw_interface_set_flags(0, 0, 0, 0) + print (t) + self.assertEqual(papi_event.wait(5), True) + + @unittest.skip("not quite ready yet") + def test_want_stats(self): + pid = 123 + vpp_papi.register_event_callback(papi_event_handler) + papi_event.clear() + t = vpp_papi.want_stats(True, pid) + + print (t) + + # + # Wait for some stats + # + self.assertEqual(papi_event.wait(30), True) + t = vpp_papi.want_stats(False, pid) + print (t) + + def test_tap(self): + pid = 123 + vpp_papi.register_event_callback(papi_event_handler) + papi_event.clear() + t = vpp_papi.want_stats(True, pid) + + print (t) + + t = vpp_papi.tap_connect(1, b'tap', b'foo', 1, 0) + print (t) + self.assertEqual(t.retval, 0) + swifindex = t.swifindex + + t = vpp_papi.sw_interface_set_flags(swifindex, 1, 1, 0) + print (t) + self.assertEqual(t.retval, 0) + + ip6 = IPv6Address(u'2001:db8::1').packed + t = vpp_papi.sw_interface_add_del_address(swifindex, 1, 1, 0, 16, ip6) + print (t) + time.sleep(40) + + +if __name__ == '__main__': + #logging.basicConfig(level=logging.DEBUG) + unittest.main() diff --git a/vpp-api/python/vpp_papi/__init__.py b/vpp-api/python/vpp_papi/__init__.py new file mode 100644 index 00000000..8be644d7 --- /dev/null +++ b/vpp-api/python/vpp_papi/__init__.py @@ -0,0 +1,2 @@ +__import__('pkg_resources').declare_namespace(__name__) +from .vpp_papi import * diff --git a/vpp-api/python/vpp_papi/pneum_wrap.c b/vpp-api/python/vpp_papi/pneum_wrap.c new file mode 100644 index 00000000..09d972d4 --- /dev/null +++ b/vpp-api/python/vpp_papi/pneum_wrap.c @@ -0,0 +1,120 @@ +#include +#include "pneum.h" + +static PyObject *pneum_callback = NULL; + +int +wrap_pneum_callback (char *data, int len) +{ + PyGILState_STATE gstate; + PyObject *result;//, *arglist; + + gstate = PyGILState_Ensure(); + + /* Time to call the callback */ + result = PyObject_CallFunction(pneum_callback, "y#", data, len); + if (result) + Py_DECREF(result); + else + PyErr_Print(); + + PyGILState_Release(gstate); + return (0); +} + +static PyObject * +wrap_connect (PyObject *self, PyObject *args) +{ + char *name; + int rv; + PyObject *temp; + + if (!PyArg_ParseTuple(args, "sO:set_callback", &name, &temp)) + return (NULL); + + if (!PyCallable_Check(temp)) { + PyErr_SetString(PyExc_TypeError, "parameter must be callable"); + return NULL; + } + + Py_XINCREF(temp); /* Add a reference to new callback */ + Py_XDECREF(pneum_callback); /* Dispose of previous callback */ + pneum_callback = temp; /* Remember new callback */ + + Py_BEGIN_ALLOW_THREADS + rv = pneum_connect(name); + Py_END_ALLOW_THREADS + return PyLong_FromLong(rv); +} + +static PyObject * +wrap_disconnect (PyObject *self, PyObject *args) +{ + int rv; + Py_BEGIN_ALLOW_THREADS + rv = pneum_disconnect(); + Py_END_ALLOW_THREADS + return PyLong_FromLong(rv); +} +static PyObject * +wrap_write (PyObject *self, PyObject *args) +{ + char *data; + int len, rv; + + if (!PyArg_ParseTuple(args, "s#", &data, &len)) + return NULL; + Py_BEGIN_ALLOW_THREADS + rv = pneum_write(data, len); + Py_END_ALLOW_THREADS + + return PyLong_FromLong(rv); +} + +void vl_msg_api_free(void *); + +static PyObject * +wrap_read (PyObject *self, PyObject *args) +{ + char *data; + int len, rv; + + Py_BEGIN_ALLOW_THREADS + rv = pneum_read(&data, &len); + Py_END_ALLOW_THREADS + + if (rv != 0) { Py_RETURN_NONE; } + + PyObject *ret = Py_BuildValue("y#", data, len); + if (!ret) { Py_RETURN_NONE; } + + vl_msg_api_free(data); + return ret; +} + +static PyMethodDef vpp_api_Methods[] = { + {"connect", wrap_connect, METH_VARARGS, "Connect to the VPP API."}, + {"disconnect", wrap_disconnect, METH_VARARGS, "Disconnect from the VPP API."}, + {"write", wrap_write, METH_VARARGS, "Write data to the VPP API."}, + {"read", wrap_read, METH_VARARGS, "Read data from the VPP API."}, + {NULL, NULL, 0, NULL} /* Sentinel */ +}; + +static struct PyModuleDef vpp_api_module = { + PyModuleDef_HEAD_INIT, + "vpp_api", /* name of module */ + NULL, /* module documentation, may be NULL */ + -1, /* size of per-interpreter state of the module, + or -1 if the module keeps state in global variables. */ + vpp_api_Methods +}; + +PyMODINIT_FUNC +PyInit_vpp_api (void) +{ + /* Ensure threading is initialised */ + if (!PyEval_ThreadsInitialized()) { + PyEval_InitThreads(); + } + return PyModule_Create(&vpp_api_module); +} diff --git a/vpp-japi/Makefile.am b/vpp-japi/Makefile.am deleted file mode 100644 index f1eb37da..00000000 --- a/vpp-japi/Makefile.am +++ /dev/null @@ -1,93 +0,0 @@ -# Copyright (c) 2015 Cisco and/or its affiliates. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at: -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -AUTOMAKE_OPTIONS = foreign subdir-objects -ACLOCAL_AMFLAGS = -I m4 -AM_CFLAGS = -Wall - -noinst_PROGRAMS = -BUILT_SOURCES = -bin_PROGRAMS = -CLEANFILES = -lib_LTLIBRARIES = - -nobase_include_HEADERS = \ - japi/org_openvpp_vppjapi_vppApi.h \ - japi/org_openvpp_vppjapi_vppConn.h - -lib_LTLIBRARIES += libvppjni.la - -libvppjni_la_SOURCES = japi/vppjni.c japi/vppapi.c japi/vppjni_env.h japi/vppjni_env.c -libvppjni_la_LIBADD = -lvlibmemoryclient -lvlibapi -lsvm -lvppinfra \ - -lpthread -lm -lrt -libvppjni_la_LDFLAGS = -module -libvppjni_la_CPPFLAGS = -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux - -jarfile = vppjapi-$(PACKAGE_VERSION).jar -packagedir = org/openvpp/vppjapi -JAVAROOT = . - -$(jarfile): libvppjni.la - cd .libs ; $(JAR) cf $(JARFLAGS) ../$@ libvppjni.so.0.0.0 ../$(packagedir)/*.class ; cd .. - -BUILT_SOURCES += japi/org_openvpp_vppjapi_vppConn.h japi/vppapi.c - -japi/org_openvpp_vppjapi_vppConn.h: \ - japi/org/openvpp/vppjapi/vppVersion.java \ - japi/org/openvpp/vppjapi/vppInterfaceDetails.java \ - japi/org/openvpp/vppjapi/vppInterfaceCounters.java \ - japi/org/openvpp/vppjapi/vppBridgeDomainDetails.java \ - japi/org/openvpp/vppjapi/vppBridgeDomainInterfaceDetails.java \ - japi/org/openvpp/vppjapi/vppL2Fib.java \ - japi/org/openvpp/vppjapi/vppIPv4Address.java \ - japi/org/openvpp/vppjapi/vppIPv6Address.java \ - japi/org/openvpp/vppjapi/vppVxlanTunnelDetails.java \ - japi/org/openvpp/vppjapi/vppConn.java \ - japi/org/openvpp/vppjapi/vppApiCallbacks.java \ - ../vpp/api/vpe.api.h - $(JAVAC) -classpath . -d . @srcdir@/japi/org/openvpp/vppjapi/vppVersion.java ; \ - $(JAVAH) -classpath . -d japi org.openvpp.vppjapi.vppVersion ; \ - $(JAVAC) -classpath . -d . @srcdir@/japi/org/openvpp/vppjapi/vppInterfaceDetails.java ; \ - $(JAVAH) -classpath . -d japi org.openvpp.vppjapi.vppInterfaceDetails ; \ - $(JAVAC) -classpath . -d . @srcdir@/japi/org/openvpp/vppjapi/vppInterfaceCounters.java ; \ - $(JAVAH) -classpath . -d japi org.openvpp.vppjapi.vppInterfaceCounters ; \ - $(JAVAC) -classpath . -d . @srcdir@/japi/org/openvpp/vppjapi/vppBridgeDomainInterfaceDetails.java ; \ - $(JAVAH) -classpath . -d japi org.openvpp.vppjapi.vppBridgeDomainInterfaceDetails ; \ - $(JAVAC) -classpath . -d . @srcdir@/japi/org/openvpp/vppjapi/vppBridgeDomainDetails.java ; \ - $(JAVAH) -classpath . -d japi org.openvpp.vppjapi.vppBridgeDomainDetails ; \ - $(JAVAC) -classpath . -d . @srcdir@/japi/org/openvpp/vppjapi/vppL2Fib.java ; \ - $(JAVAH) -classpath . -d japi org.openvpp.vppjapi.vppL2Fib ; \ - $(JAVAC) -classpath . -d . @srcdir@/japi/org/openvpp/vppjapi/vppIPv4Address.java ; \ - $(JAVAH) -classpath . -d japi org.openvpp.vppjapi.vppIPv4Address ; \ - $(JAVAC) -classpath . -d . @srcdir@/japi/org/openvpp/vppjapi/vppIPv6Address.java ; \ - $(JAVAH) -classpath . -d japi org.openvpp.vppjapi.vppIPv6Address ; \ - $(JAVAC) -classpath . -d . @srcdir@/japi/org/openvpp/vppjapi/vppVxlanTunnelDetails.java ; \ - $(JAVAH) -classpath . -d japi org.openvpp.vppjapi.vppVxlanTunnelDetails ; \ - $(JAVAC) -classpath . -d . @srcdir@/japi/org/openvpp/vppjapi/vppConn.java ; \ - $(JAVAH) -classpath . -d japi org.openvpp.vppjapi.vppConn ; - -japi/vppapi.c: japi/org_openvpp_vppjapi_vppConn.h - pushd .. ; dir=`pwd` ; popd ; \ - instdir=`echo $${dir} | sed -e 's:build-root/build:build-root/install:'` ; \ - vppapigen --input $${instdir}/vpp/api/vpe.api --jni japi/vppapi.c --app vpe ; \ - vppapigen --input $${instdir}/vpp/api/vpe.api --java japi/vppApi.java --app vpe ; \ - $(JAVAC) -classpath . -d . japi/vppApi.java ; \ - $(JAVAH) -classpath . -d japi org.openvpp.vppjapi.vppApi ; \ - $(JAVAC) -classpath . -d . @srcdir@/japi/org/openvpp/vppjapi/vppApiCallbacks.java ; \ - $(JAVAH) -classpath . -d japi org.openvpp.vppjapi.vppApiCallbacks ; - -demo = japi/test/demo.class -$(demo): $(jarfile) - $(JAVAC) -cp $(jarfile) -d $(JAVAROOT) @srcdir@/japi/test/demo.java - -all-local: $(jarfile) $(demo) diff --git a/vpp-japi/configure.ac b/vpp-japi/configure.ac deleted file mode 100644 index 1607061d..00000000 --- a/vpp-japi/configure.ac +++ /dev/null @@ -1,19 +0,0 @@ -AC_INIT(vpp-japi, 1.0.0) -LT_INIT -AC_CONFIG_MACRO_DIR([m4]) -AM_INIT_AUTOMAKE -AM_SILENT_RULES - -AM_PROG_AS -AC_PROG_CC -AM_PROG_CC_C_O - -AX_PROG_JAVAC -AX_PROG_JAVAH -AX_PROG_JAR -AX_PROG_JAVADOC -AX_PROG_JAVA -AX_CHECK_JAVA_HOME - -AC_OUTPUT([Makefile]) - diff --git a/vpp-japi/japi/org/openvpp/vppjapi/vppApiCallbacks.java b/vpp-japi/japi/org/openvpp/vppjapi/vppApiCallbacks.java deleted file mode 100644 index df5b9533..00000000 --- a/vpp-japi/japi/org/openvpp/vppjapi/vppApiCallbacks.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2015 Cisco and/or its affiliates. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.openvpp.vppjapi; - -import java.io.IOException; -import org.openvpp.vppjapi.vppApi; - -public abstract class vppApiCallbacks extends vppApi { - public vppApiCallbacks(String clientName) throws IOException { - super(clientName); - } -/* Disabled! - * - * public abstract void interfaceDetails( - int ifIndex, String interfaceName, int supIfIndex, byte[] physAddr, - byte adminUp, byte linkUp, byte linkDuplex, byte linkSpeed, - int subId, byte subDot1ad, byte subNumberOfTags, int subOuterVlanId, int subInnerVlanId, - byte subExactMatch, byte subDefault, byte subOuterVlanIdAny, byte subInnerVlanIdAny, - int vtrOp, int vtrPushDot1q, int vtrTag1, int vtrTag2); - */ - -} diff --git a/vpp-japi/japi/org/openvpp/vppjapi/vppBridgeDomainDetails.java b/vpp-japi/japi/org/openvpp/vppjapi/vppBridgeDomainDetails.java deleted file mode 100644 index db859a07..00000000 --- a/vpp-japi/japi/org/openvpp/vppjapi/vppBridgeDomainDetails.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2015 Cisco and/or its affiliates. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.openvpp.vppjapi; - -import org.openvpp.vppjapi.vppBridgeDomainInterfaceDetails; - -public final class vppBridgeDomainDetails { - public String name; - public int bdId; - public boolean flood; - public boolean uuFlood; - public boolean forward; - public boolean learn; - public boolean arpTerm; - public String bviInterfaceName; - public vppBridgeDomainInterfaceDetails[] interfaces; -} diff --git a/vpp-japi/japi/org/openvpp/vppjapi/vppBridgeDomainInterfaceDetails.java b/vpp-japi/japi/org/openvpp/vppjapi/vppBridgeDomainInterfaceDetails.java deleted file mode 100644 index ab99ee45..00000000 --- a/vpp-japi/japi/org/openvpp/vppjapi/vppBridgeDomainInterfaceDetails.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 2015 Cisco and/or its affiliates. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.openvpp.vppjapi; - -public final class vppBridgeDomainInterfaceDetails { - public String interfaceName; - public byte splitHorizonGroup; -} diff --git a/vpp-japi/japi/org/openvpp/vppjapi/vppConn.java b/vpp-japi/japi/org/openvpp/vppjapi/vppConn.java deleted file mode 100644 index 3e8c12a9..00000000 --- a/vpp-japi/japi/org/openvpp/vppjapi/vppConn.java +++ /dev/null @@ -1,237 +0,0 @@ -/* - * Copyright (c) 2015 Cisco and/or its affiliates. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.openvpp.vppjapi; - -import java.io.IOException; -import java.io.InputStream; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.StandardCopyOption; -import java.nio.file.attribute.PosixFilePermission; -import java.nio.file.attribute.PosixFilePermissions; -import java.util.Set; - -import org.openvpp.vppjapi.vppVersion; -import org.openvpp.vppjapi.vppInterfaceDetails; -import org.openvpp.vppjapi.vppInterfaceCounters; -import org.openvpp.vppjapi.vppBridgeDomainDetails; -import org.openvpp.vppjapi.vppIPv4Address; -import org.openvpp.vppjapi.vppIPv6Address; -import org.openvpp.vppjapi.vppVxlanTunnelDetails; - -public class vppConn implements AutoCloseable { - private static final String LIBNAME = "libvppjni.so.0.0.0"; - - static { - try { - loadLibrary(); - } catch (Exception e) { - System.out.printf("Can't find vpp jni library: %s\n", LIBNAME); - throw new ExceptionInInitializerError(e); - } - } - - private static void loadStream(final InputStream is) throws IOException { - final Set perms = PosixFilePermissions.fromString("rwxr-x---"); - final Path p = Files.createTempFile(LIBNAME, null, PosixFilePermissions.asFileAttribute(perms)); - try { - Files.copy(is, p, StandardCopyOption.REPLACE_EXISTING); - - try { - Runtime.getRuntime().load(p.toString()); - } catch (UnsatisfiedLinkError e) { - throw new IOException(String.format("Failed to load library %s", p), e); - } - } finally { - try { - Files.deleteIfExists(p); - } catch (IOException e) { - } - } - } - - private static void loadLibrary() throws IOException { - try (final InputStream is = vppConn.class.getResourceAsStream('/' + LIBNAME)) { - if (is == null) { - throw new IOException(String.format("Failed to open library resource %s", - LIBNAME)); - } - loadStream(is); - } - } - - private static vppConn currentConnection = null; - private final String clientName; - private volatile boolean disconnected = false; - - // Hidden on purpose to prevent external instantiation - vppConn(final String clientName) throws IOException { - this.clientName = clientName; - - synchronized (vppConn.class) { - if (currentConnection != null) { - throw new IOException("Already connected as " + currentConnection.clientName); - } - - final int ret = clientConnect(clientName); - if (ret != 0) { - throw new IOException("Connection returned error " + ret); - } - - currentConnection = this; - } - } - - @Override - public synchronized final void close() { - if (!disconnected) { - disconnected = true; - - synchronized (vppConn.class) { - clientDisconnect(); - currentConnection = null; - } - } - } - - /** - * Check if this instance is connected. - * - * @throws IllegalStateException if this instance was disconnected. - */ - protected final void checkConnected() { - if (disconnected) { - throw new IllegalStateException("Disconnected client " + clientName); - } - } - - public final int getRetval(int context, int release) { - checkConnected(); - return getRetval0(context, release); - } - - public final String getInterfaceList (String nameFilter) { - checkConnected(); - return getInterfaceList0(nameFilter); - } - - public final int swIfIndexFromName (String interfaceName) { - checkConnected(); - return swIfIndexFromName0(interfaceName); - } - - public final String interfaceNameFromSwIfIndex (int swIfIndex) { - checkConnected(); - return interfaceNameFromSwIfIndex0(swIfIndex); - } - - public final void clearInterfaceTable () { - checkConnected(); - clearInterfaceTable0(); - } - - public final vppInterfaceDetails[] swInterfaceDump (byte nameFilterValid, byte [] nameFilter) { - checkConnected(); - return swInterfaceDump0(nameFilterValid, nameFilter); - } - - public final int bridgeDomainIdFromName(String bridgeDomain) { - checkConnected(); - return bridgeDomainIdFromName0(bridgeDomain); - } - - public final int findOrAddBridgeDomainId(String bridgeDomain) { - checkConnected(); - return findOrAddBridgeDomainId0(bridgeDomain); - } - - public final vppVersion getVppVersion() { - checkConnected(); - return getVppVersion0(); - } - - public final vppInterfaceCounters getInterfaceCounters(int swIfIndex) { - checkConnected(); - return getInterfaceCounters0(swIfIndex); - } - - public final int[] bridgeDomainDump(int bdId) { - checkConnected(); - return bridgeDomainDump0(bdId); - } - - public final vppBridgeDomainDetails getBridgeDomainDetails(int bdId) { - checkConnected(); - return getBridgeDomainDetails0(bdId); - } - - public final vppL2Fib[] l2FibTableDump(int bdId) { - checkConnected(); - return l2FibTableDump0(bdId); - } - - public final int bridgeDomainIdFromInterfaceName(String interfaceName) { - checkConnected(); - return bridgeDomainIdFromInterfaceName0(interfaceName); - } - - public final vppIPv4Address[] ipv4AddressDump(String interfaceName) { - checkConnected(); - return ipv4AddressDump0(interfaceName); - } - - public final vppIPv6Address[] ipv6AddressDump(String interfaceName) { - checkConnected(); - return ipv6AddressDump0(interfaceName); - } - - public final vppVxlanTunnelDetails[] vxlanTunnelDump(int swIfIndex) { - checkConnected(); - return vxlanTunnelDump0(swIfIndex); - } - - public final int setInterfaceDescription(String ifName, String ifDesc) { - checkConnected(); - return setInterfaceDescription0(ifName, ifDesc); - } - - public final String getInterfaceDescription(String ifName) { - checkConnected(); - return getInterfaceDescription0(ifName); - } - - private static native int clientConnect(String clientName); - private static native void clientDisconnect(); - private static native int getRetval0(int context, int release); - private static native String getInterfaceList0(String nameFilter); - private static native int swIfIndexFromName0(String interfaceName); - private static native String interfaceNameFromSwIfIndex0(int swIfIndex); - private static native void clearInterfaceTable0(); - private static native vppInterfaceDetails[] swInterfaceDump0(byte nameFilterValid, byte [] nameFilter); - private static native int bridgeDomainIdFromName0(String bridgeDomain); - private static native int findOrAddBridgeDomainId0(String bridgeDomain); - private static native vppVersion getVppVersion0(); - private static native vppInterfaceCounters getInterfaceCounters0(int swIfIndex); - private static native int[] bridgeDomainDump0(int bdId); - private static native vppBridgeDomainDetails getBridgeDomainDetails0(int bdId); - private static native vppL2Fib[] l2FibTableDump0(int bdId); - private static native int bridgeDomainIdFromInterfaceName0(String interfaceName); - private static native vppIPv4Address[] ipv4AddressDump0(String interfaceName); - private static native vppIPv6Address[] ipv6AddressDump0(String interfaceName); - private static native vppVxlanTunnelDetails[] vxlanTunnelDump0(int swIfIndex); - private static native int setInterfaceDescription0(String ifName, String ifDesc); - private static native String getInterfaceDescription0(String ifName); -} diff --git a/vpp-japi/japi/org/openvpp/vppjapi/vppIPv4Address.java b/vpp-japi/japi/org/openvpp/vppjapi/vppIPv4Address.java deleted file mode 100644 index 046ceab5..00000000 --- a/vpp-japi/japi/org/openvpp/vppjapi/vppIPv4Address.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (c) 2015 Cisco and/or its affiliates. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.openvpp.vppjapi; - -public final class vppIPv4Address { - public final int ip; - public final byte prefixLength; - - public vppIPv4Address(int ip, byte prefixLength) { - this.ip = ip; - this.prefixLength = prefixLength; - } -} diff --git a/vpp-japi/japi/org/openvpp/vppjapi/vppIPv6Address.java b/vpp-japi/japi/org/openvpp/vppjapi/vppIPv6Address.java deleted file mode 100644 index 6690a5db..00000000 --- a/vpp-japi/japi/org/openvpp/vppjapi/vppIPv6Address.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2015 Cisco and/or its affiliates. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.openvpp.vppjapi; - -public class vppIPv6Address { - // FIXME: this is dangerous - public final byte[] ip; - public final byte prefixLength; - - public vppIPv6Address(byte[] ip, byte prefixLength) { - this.ip = ip; - this.prefixLength = prefixLength; - } -} diff --git a/vpp-japi/japi/org/openvpp/vppjapi/vppInterfaceCounters.java b/vpp-japi/japi/org/openvpp/vppjapi/vppInterfaceCounters.java deleted file mode 100644 index b2687fb8..00000000 --- a/vpp-japi/japi/org/openvpp/vppjapi/vppInterfaceCounters.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2015 Cisco and/or its affiliates. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.openvpp.vppjapi; - -public final class vppInterfaceCounters { - - public final long rxOctets; - public final long rxIp4; - public final long rxIp6; - public final long rxUnicast; - public final long rxMulticast; - public final long rxBroadcast; - public final long rxDiscard; - public final long rxFifoFull; - public final long rxError; - public final long rxUnknownProto; - public final long rxMiss; - - public final long txOctets; - public final long txIp4; - public final long txIp6; - public final long txUnicast; - public final long txMulticast; - public final long txBroadcast; - public final long txDiscard; - public final long txFifoFull; - public final long txError; - public final long txUnknownProto; - public final long txMiss; - - public vppInterfaceCounters( - long rxOctets, long rxIp4, long rxIp6, long rxUni, long rxMulti, - long rxBcast, long rxDiscard, long rxFifoFull, long rxError, - long rxUnknownProto, long rxMiss, - long txOctets, long txIp4, long txIp6, long txUni, long txMulti, - long txBcast, long txDiscard, long txFifoFull, long txError, - long txUnknownProto, long txMiss) - { - this.rxOctets = rxOctets; - this.rxIp4 = rxIp4; - this.rxIp6 = rxIp6; - this.rxUnicast = rxUni; - this.rxMulticast = rxMulti; - this.rxBroadcast = rxBcast; - this.rxDiscard = rxDiscard; - this.rxFifoFull = rxFifoFull; - this.rxError = rxError; - this.rxUnknownProto = rxUnknownProto; - this.rxMiss = rxMiss; - - this.txOctets = txOctets; - this.txIp4 = txIp4; - this.txIp6 = txIp6; - this.txUnicast = txUni; - this.txMulticast = txMulti; - this.txBroadcast = txBcast; - this.txDiscard = txDiscard; - this.txFifoFull = txFifoFull; - this.txError = txError; - this.txUnknownProto = txUnknownProto; - this.txMiss = txMiss; - } -} - diff --git a/vpp-japi/japi/org/openvpp/vppjapi/vppInterfaceDetails.java b/vpp-japi/japi/org/openvpp/vppjapi/vppInterfaceDetails.java deleted file mode 100644 index 742dd25a..00000000 --- a/vpp-japi/japi/org/openvpp/vppjapi/vppInterfaceDetails.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (c) 2015 Cisco and/or its affiliates. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.openvpp.vppjapi; - -public final class vppInterfaceDetails { - public final int ifIndex; - public final String interfaceName; - public final int supIfIndex; - // FIXME: this is dangerous - public final byte[] physAddr; - public final byte adminUp; - public final byte linkUp; - public final byte linkDuplex; - public final byte linkSpeed; - public final int subId; - public final byte subDot1ad; - public final byte subNumberOfTags; - public final int subOuterVlanId; - public final int subInnerVlanId; - public final byte subExactMatch; - public final byte subDefault; - public final byte subOuterVlanIdAny; - public final byte subInnerVlanIdAny; - public final int vtrOp; - public final int vtrPushDot1q; - public final int vtrTag1; - public final int vtrTag2; - public final int linkMtu; - - public vppInterfaceDetails(int ifIndex, String interfaceName, int supIfIndex, byte[] physAddr, byte adminUp, - byte linkUp, byte linkDuplex, byte linkSpeed, int subId, byte subDot1ad, byte subNumberOfTags, - int subOuterVlanId, int subInnerVlanId, byte subExactMatch, byte subDefault, byte subOuterVlanIdAny, - byte subInnerVlanIdAny, int vtrOp, int vtrPushDot1q, int vtrTag1, int vtrTag2, int linkMtu) - { - this.ifIndex = ifIndex; - this.interfaceName = interfaceName; - this.supIfIndex = supIfIndex; - this.physAddr = physAddr; - this.adminUp = adminUp; - this.linkUp = linkUp; - this.linkDuplex = linkDuplex; - this.linkSpeed = linkSpeed; - this.subId = subId; - this.subDot1ad = subDot1ad; - this.subNumberOfTags = subNumberOfTags; - this.subOuterVlanId = subOuterVlanId; - this.subInnerVlanId = subInnerVlanId; - this.subExactMatch = subExactMatch; - this.subDefault = subDefault; - this.subOuterVlanIdAny = subOuterVlanIdAny; - this.subInnerVlanIdAny = subInnerVlanIdAny; - this.vtrOp = vtrOp; - this.vtrPushDot1q = vtrPushDot1q; - this.vtrTag1 = vtrTag1; - this.vtrTag2 = vtrTag2; - this.linkMtu = linkMtu; - } -} diff --git a/vpp-japi/japi/org/openvpp/vppjapi/vppL2Fib.java b/vpp-japi/japi/org/openvpp/vppjapi/vppL2Fib.java deleted file mode 100644 index b38d801e..00000000 --- a/vpp-japi/japi/org/openvpp/vppjapi/vppL2Fib.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2015 Cisco and/or its affiliates. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.openvpp.vppjapi; - -public final class vppL2Fib { - // FIXME: this is dangerous - public final byte[] physAddress; - public final boolean staticConfig; - public final String outgoingInterface; - public final boolean filter; - public final boolean bridgedVirtualInterface; - - public vppL2Fib(byte[] physAddress, boolean staticConfig, - String outgoingInterface, boolean filter, - boolean bridgedVirtualInterface) { - this.physAddress = physAddress; - this.staticConfig = staticConfig; - this.outgoingInterface = outgoingInterface; - this.filter = filter; - this.bridgedVirtualInterface = bridgedVirtualInterface; - } -} diff --git a/vpp-japi/japi/org/openvpp/vppjapi/vppVersion.java b/vpp-japi/japi/org/openvpp/vppjapi/vppVersion.java deleted file mode 100644 index 6408dee2..00000000 --- a/vpp-japi/japi/org/openvpp/vppjapi/vppVersion.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2015 Cisco and/or its affiliates. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.openvpp.vppjapi; - -public final class vppVersion { - public final String programName; - public final String buildDirectory; - public final String gitBranch; - public final String buildDate; - - public vppVersion(String progName, String buildDir, String gitBranch, String buildDate) { - this.programName = progName; - this.buildDirectory = buildDir; - this.gitBranch = gitBranch; - this.buildDate = buildDate; - } -} - diff --git a/vpp-japi/japi/org/openvpp/vppjapi/vppVxlanTunnelDetails.java b/vpp-japi/japi/org/openvpp/vppjapi/vppVxlanTunnelDetails.java deleted file mode 100644 index dd81e98c..00000000 --- a/vpp-japi/japi/org/openvpp/vppjapi/vppVxlanTunnelDetails.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2015 Cisco and/or its affiliates. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.openvpp.vppjapi; - -public final class vppVxlanTunnelDetails { - public final int srcAddress; - public final int dstAddress; - public final int encapVrfId; - public final int vni; - public final int decapNextIndex; - - public vppVxlanTunnelDetails(int srcAddress, int dstAddress, - int encapVrfId, int vni, int decapNextIndex) { - this.srcAddress = srcAddress; - this.dstAddress = dstAddress; - this.encapVrfId = encapVrfId; - this.vni = vni; - this.decapNextIndex = decapNextIndex; - } -} diff --git a/vpp-japi/japi/test/demo.java b/vpp-japi/japi/test/demo.java deleted file mode 100644 index ea1db84b..00000000 --- a/vpp-japi/japi/test/demo.java +++ /dev/null @@ -1,170 +0,0 @@ -/* - * Copyright (c) 2015 Cisco and/or its affiliates. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import org.openvpp.vppjapi.*; - -public class demo { - public static void main (String[] args) throws Exception { - vppApi api = new vppApi ("JavaTest"); - System.out.printf ("Connected OK..."); - - String intlist; - int [] contexts; - int i, limit; - int trips; - int rv, errors, saved_error; - long before, after; - - if (false) - { - intlist = api.getInterfaceList (""); - System.out.printf ("Unfiltered interface list:\n%s", intlist); - - trips = 0; - - contexts = new int[6]; - - for (i = 0; i < 6; i++) - { - contexts[i] = api.swInterfaceSetFlags - (5 + i /* sw_if_index */, - (byte)1 /* admin_up */, - (byte)1 /* link_up (ignored) */, - (byte)0 /* deleted */); - } - - /* Thread.sleep (1); */ - errors = 0; - saved_error = 0; - - for (i = 0; i < 6; i ++) - { - while (true) - { - rv = api.getRetval (contexts[i], 1 /* release */); - if (rv != -77) - break; - Thread.sleep (1); - trips++; - } - if (rv < 0) - { - saved_error = rv; - errors++; - } - } - - if (errors == 0) - System.out.printf ("intfcs up...\n"); - else - System.out.printf - ("%d errors, last error %d...\n", errors, saved_error); - } - - limit = 250000; - saved_error = 0; - errors = 0; - contexts = new int [limit]; - byte [] address = new byte [4]; - byte [] zeros = new byte [4]; - - address[0] = (byte)192; - address[1] = (byte)168; - address[2] = (byte)2; - address[3] = (byte)1; - - for (i = 0; i < 4; i++) - zeros[i] = 0; - - System.out.printf ("start %d route ops ...", limit); - - before = System.currentTimeMillis(); - - for (i = 0; i < limit; i++) { - contexts[i] = api.ipAddDelRoute - (0 /* int nextHopSwIfIndex */, - 0 /* int vrfId */, - 0 /* int lookupInVrf */, - 0 /* int resolveAttempts */, - 0 /* int classifyTableIndex */, - (byte)0 /* byte createVrfIfNeeded */, - (byte)0 /* byte resolveIfNeeded */, - (byte)1 /* byte isAdd */, - (byte)1 /* byte isDrop */, - (byte)0 /* byte isIpv6 */, - (byte)0 /* byte isLocal */, - (byte)0 /* byte isClassify */, - (byte)0 /* byte isMultipath */, - (byte)0 /* byte notLast */, - (byte)0 /* byte nextHopWeight */, - (byte)32 /* byte dstAddressLength */, - address, - zeros); - - address[3] += 1; - if (address[3] == 0) - { - address[2] += 1; - if (address[2] == 0) - { - address[1] += 1; - { - if (address[1] == 0) - { - address[0] += 1; - } - } - } - } - } - - trips = 0; - - for (i = 0; i < limit; i++) - { - while (true) - { - rv = api.getRetval (contexts[i], 1 /* release */); - if (rv != -77) - break; - Thread.sleep (1); - trips++; - } - if (rv < 0) - { - saved_error = rv; - errors++; - } - } - - after = System.currentTimeMillis(); - - - if (errors == 0) - System.out.printf ("done %d route ops (all OK)...\n", limit); - else - System.out.printf - ("%d errors, last error %d...\n", errors, saved_error); - - System.out.printf ("result in %d trips\n", trips); - - System.out.printf ("%d routes in %d milliseconds, %d routes/msec\n", - limit, after - before, - limit / (after - before)); - - api.close(); - System.out.printf ("Done...\n"); - } -} diff --git a/vpp-japi/japi/test/vppApi.java b/vpp-japi/japi/test/vppApi.java deleted file mode 100644 index 87af3292..00000000 --- a/vpp-japi/japi/test/vppApi.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2015 Cisco and/or its affiliates. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import java.net.InetAddress; -import org.openvpp.vppjapi.*; - -public class vppApi { - - native int controlPing(); - native void test (byte[] array, byte[] array2); - - public static void main (String[] args) throws Exception { - vppConn api = new vppConn (); - String ipv6 = "db01::feed"; - String ipv4 = "192.168.1.1"; - InetAddress addr6 = InetAddress.getByName(ipv6); - InetAddress addr4 = InetAddress.getByName(ipv4); - byte[] ip4bytes = addr4.getAddress(); - byte[] ip6bytes = addr6.getAddress(); - int rv; - - api.test(ip4bytes,ip6bytes); - - rv = api.clientConnect ("JavaTest"); - if (rv == 0) - System.out.printf ("Connected OK..."); - else - { - System.out.printf ("clientConnect returned %d\n", rv); - System.exit (1); - } - rv = api.controlPing(); - System.out.printf ("data plane pid is %d\n", rv); - - Thread.sleep (5000); - - api.clientDisconnect(); - System.out.printf ("Done...\n"); - } -} diff --git a/vpp-japi/japi/vppjni.c b/vpp-japi/japi/vppjni.c deleted file mode 100644 index 9c9437d2..00000000 --- a/vpp-japi/japi/vppjni.c +++ /dev/null @@ -1,1900 +0,0 @@ -/* - * Copyright (c) 2015 Cisco and/or its affiliates. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#define _GNU_SOURCE /* for strcasestr(3) */ -#include - -#define vl_api_version(n,v) static u32 vpe_api_version = (v); -#include -#undef vl_api_version - -#include -#include -#include -#include -#include -#include - -#include -#define vl_typedefs /* define message structures */ -#include -#undef vl_typedefs - -#define vl_endianfun -#include -#undef vl_endianfun - -/* instantiate all the print functions we know about */ -#define vl_print(handle, ...) -#define vl_printfun -#include -#undef vl_printfun - -#define VPPJNI_DEBUG 0 - -#if VPPJNI_DEBUG == 1 - #define DEBUG_LOG(...) clib_warning(__VA_ARGS__) -#else - #define DEBUG_LOG(...) -#endif - -static int connect_to_vpe(char *name); - -/* - * The Java runtime isn't compile w/ -fstack-protector, - * so we have to supply missing external references for the - * regular vpp libraries. Weak reference in case folks get religion - * at a later date... - */ -void __stack_chk_guard (void) __attribute__((weak)); -void __stack_chk_guard (void) { } - -BIND_JAPI_CLASS(vppBridgeDomainDetails, "()V"); -BIND_JAPI_BOOL_FIELD(vppBridgeDomainDetails, arpTerm); -BIND_JAPI_BOOL_FIELD(vppBridgeDomainDetails, flood); -BIND_JAPI_BOOL_FIELD(vppBridgeDomainDetails, forward); -BIND_JAPI_BOOL_FIELD(vppBridgeDomainDetails, learn); -BIND_JAPI_BOOL_FIELD(vppBridgeDomainDetails, uuFlood); -BIND_JAPI_INT_FIELD(vppBridgeDomainDetails, bdId); -BIND_JAPI_STRING_FIELD(vppBridgeDomainDetails, name); -BIND_JAPI_STRING_FIELD(vppBridgeDomainDetails, bviInterfaceName); -BIND_JAPI_OBJ_FIELD(vppBridgeDomainDetails, interfaces, "[Lorg/openvpp/vppjapi/vppBridgeDomainInterfaceDetails;"); - -BIND_JAPI_CLASS(vppBridgeDomainInterfaceDetails, "()V"); -BIND_JAPI_BYTE_FIELD(vppBridgeDomainInterfaceDetails, splitHorizonGroup); -BIND_JAPI_STRING_FIELD(vppBridgeDomainInterfaceDetails, interfaceName); - -BIND_JAPI_CLASS(vppInterfaceCounters, "(JJJJJJJJJJJJJJJJJJJJJJ)V"); -BIND_JAPI_CLASS(vppInterfaceDetails, "(ILjava/lang/String;I[BBBBBIBBIIBBBBIIIII)V"); -BIND_JAPI_CLASS(vppIPv4Address, "(IB)V"); -BIND_JAPI_CLASS(vppIPv6Address, "([BB)V"); -BIND_JAPI_CLASS(vppL2Fib, "([BZLjava/lang/String;ZZ)V"); -BIND_JAPI_CLASS(vppVersion, "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V"); -BIND_JAPI_CLASS(vppVxlanTunnelDetails, "(IIIII)V"); - -void vl_client_add_api_signatures (vl_api_memclnt_create_t *mp) -{ - /* - * Send the main API signature in slot 0. This bit of code must - * match the checks in ../vpe/api/api.c: vl_msg_api_version_check(). - */ - mp->api_versions[0] = clib_host_to_net_u32 (vpe_api_version); -} - -/* Note: non-static, called once to set up the initial intfc table */ -static int sw_interface_dump (vppjni_main_t * jm) -{ - vl_api_sw_interface_dump_t *mp; - f64 timeout; - hash_pair_t * p; - name_sort_t * nses = 0, * ns; - sw_interface_subif_t * sub = NULL; - - /* Toss the old name table */ - hash_foreach_pair (p, jm->sw_if_index_by_interface_name, - ({ - vec_add2 (nses, ns, 1); - ns->name = (u8 *)(p->key); - ns->value = (u32) p->value[0]; - })); - - hash_free (jm->sw_if_index_by_interface_name); - - vec_foreach (ns, nses) - vec_free (ns->name); - - vec_free (nses); - - vec_foreach (sub, jm->sw_if_subif_table) { - vec_free (sub->interface_name); - } - vec_free (jm->sw_if_subif_table); - - /* recreate the interface name hash table */ - jm->sw_if_index_by_interface_name - = hash_create_string (0, sizeof(uword)); - - /* Get list of ethernets */ - M(SW_INTERFACE_DUMP, sw_interface_dump); - mp->name_filter_valid = 1; - strncpy ((char *) mp->name_filter, "Ether", sizeof(mp->name_filter-1)); - S; - - /* and local / loopback interfaces */ - M(SW_INTERFACE_DUMP, sw_interface_dump); - mp->name_filter_valid = 1; - strncpy ((char *) mp->name_filter, "lo", sizeof(mp->name_filter-1)); - S; - - /* and vxlan tunnel interfaces */ - M(SW_INTERFACE_DUMP, sw_interface_dump); - mp->name_filter_valid = 1; - strncpy ((char *) mp->name_filter, "vxlan", sizeof(mp->name_filter-1)); - S; - - /* and tap tunnel interfaces */ - M(SW_INTERFACE_DUMP, sw_interface_dump); - mp->name_filter_valid = 1; - strncpy ((char *) mp->name_filter, "tap", sizeof(mp->name_filter-1)); - S; - - /* and host (af_packet) interfaces */ - M(SW_INTERFACE_DUMP, sw_interface_dump); - mp->name_filter_valid = 1; - strncpy ((char *) mp->name_filter, "host", sizeof(mp->name_filter-1)); - S; - - /* and l2tpv3 tunnel interfaces */ - M(SW_INTERFACE_DUMP, sw_interface_dump); - mp->name_filter_valid = 1; - strncpy ((char *) mp->name_filter, "l2tpv3_tunnel", - sizeof(mp->name_filter-1)); - S; - - /* Use a control ping for synchronization */ - { - vl_api_control_ping_t * mp; - M(CONTROL_PING, control_ping); - S; - } - W; -} - -JNIEXPORT jobject JNICALL Java_org_openvpp_vppjapi_vppConn_getVppVersion0 - (JNIEnv *env, jobject obj) -{ - vppjni_main_t * jm = &vppjni_main; - - vppjni_lock (jm, 11); - jstring progName = (*env)->NewStringUTF(env, (char *)jm->program_name); - jstring buildDir = (*env)->NewStringUTF(env, (char *)jm->build_directory); - jstring version = (*env)->NewStringUTF(env, (char *)jm->version); - jstring buildDate = (*env)->NewStringUTF(env, (char *)jm->build_date); - vppjni_unlock (jm); - - return vppVersionObject(env, progName, buildDir, version, buildDate); -} - -static int jm_show_version (vppjni_main_t *jm) -{ - int rv; - vl_api_show_version_t *mp; - f64 timeout; - - vppjni_lock (jm, 10); - M(SHOW_VERSION, show_version); - - S; - vppjni_unlock (jm); - WNR; - return rv; -} - -static int jm_stats_enable_disable (vppjni_main_t *jm, u8 enable) -{ - vl_api_want_stats_t * mp; - f64 timeout; - int rv; - - vppjni_lock (jm, 13); - - M(WANT_STATS, want_stats); - - mp->enable_disable = enable; - - S; - vppjni_unlock (jm); - WNR; - - // already subscribed / already disabled (it's ok) - if (rv == -2 || rv == -3) - rv = 0; - return rv; -} - -JNIEXPORT jint JNICALL Java_org_openvpp_vppjapi_vppConn_setInterfaceDescription0 - (JNIEnv *env, jobject obj, jstring ifName, jstring ifDesc) -{ - int rv = 0; - vppjni_main_t * jm = &vppjni_main; - uword * p; - u32 sw_if_index = ~0; - sw_if_config_t *cfg; - - const char *if_name_str = (*env)->GetStringUTFChars (env, ifName, 0); - const char *if_desc_str = (*env)->GetStringUTFChars (env, ifDesc, 0); - - vppjni_lock (jm, 23); - - p = hash_get_mem (jm->sw_if_index_by_interface_name, if_name_str); - if (p == 0) { - rv = -1; - goto out; - } - sw_if_index = (jint) p[0]; - - u8 *if_desc = 0; - vec_validate_init_c_string (if_desc, if_desc_str, strlen(if_desc_str)); - (*env)->ReleaseStringUTFChars (env, ifDesc, if_desc_str); - - p = hash_get (jm->sw_if_config_by_sw_if_index, sw_if_index); - if (p != 0) { - cfg = (sw_if_config_t *) (p[0]); - if (cfg->desc) - vec_free(cfg->desc); - } else { - cfg = (sw_if_config_t *) clib_mem_alloc(sizeof(sw_if_config_t)); - hash_set (jm->sw_if_config_by_sw_if_index, sw_if_index, cfg); - } - - cfg->desc = if_desc; - -out: - (*env)->ReleaseStringUTFChars (env, ifName, if_name_str); - vppjni_unlock (jm); - return rv; -} - -JNIEXPORT jstring JNICALL Java_org_openvpp_vppjapi_vppConn_getInterfaceDescription0 -(JNIEnv * env, jobject obj, jstring ifName) -{ - vppjni_main_t * jm = &vppjni_main; - u32 sw_if_index = ~0; - uword * p; - jstring ifDesc = NULL; - const char *if_name_str = (*env)->GetStringUTFChars (env, ifName, 0); - if (!if_name_str) - return NULL; - - vppjni_lock (jm, 24); - p = hash_get_mem (jm->sw_if_index_by_interface_name, if_name_str); - if (p == 0) - goto out; - - sw_if_index = (jint) p[0]; - - p = hash_get (jm->sw_if_config_by_sw_if_index, sw_if_index); - if (p == 0) - goto out; - - sw_if_config_t *cfg = (sw_if_config_t *) (p[0]); - u8 * s = format (0, "%s%c", cfg->desc, 0); - ifDesc = (*env)->NewStringUTF(env, (char *)s); - -out: - vppjni_unlock (jm); - - return ifDesc; -} - -JNIEXPORT jint JNICALL Java_org_openvpp_vppjapi_vppConn_clientConnect - (JNIEnv *env, jobject obj, jstring clientName) -{ - int rv; - const char *client_name; - void vl_msg_reply_handler_hookup(void); - vppjni_main_t * jm = &vppjni_main; - api_main_t * am = &api_main; - u8 * heap; - mheap_t * h; - f64 timeout; - - /* - * Bail out now if we're not running as root - */ - if (geteuid() != 0) - return -1; - - if (jm->is_connected) - return -2; - - client_name = (*env)->GetStringUTFChars(env, clientName, 0); - if (!client_name) - return -3; - - if (jm->heap == 0) - clib_mem_init (0, 128<<20); - - heap = clib_mem_get_per_cpu_heap(); - h = mheap_header (heap); - - clib_time_init (&jm->clib_time); - - rv = connect_to_vpe ((char *) client_name); - - if (rv < 0) - clib_warning ("connection failed, rv %d", rv); - - (*env)->ReleaseStringUTFChars (env, clientName, client_name); - - if (rv == 0) { - vl_msg_reply_handler_hookup (); - jm->is_connected = 1; - /* make the main heap thread-safe */ - h->flags |= MHEAP_FLAG_THREAD_SAFE; - - jm->reply_hash = hash_create (0, sizeof (uword)); - //jm->callback_hash = hash_create (0, sizeof (uword)); - //jm->ping_hash = hash_create (0, sizeof (uword)); - jm->api_main = am; - vjbd_main_init(&jm->vjbd_main); - jm->sw_if_index_by_interface_name = - hash_create_string (0, sizeof (uword)); - jm->sw_if_config_by_sw_if_index = - hash_create (0, sizeof (uword)); - - { - // call control ping first to attach rx thread to java thread - vl_api_control_ping_t * mp; - M(CONTROL_PING, control_ping); - S; - WNR; - - if (rv != 0) { - clib_warning ("first control ping failed: %d", rv); - } - } - rv = jm_show_version(jm); - if (rv != 0) - clib_warning ("unable to retrieve vpp version (rv: %d)", rv); - rv = sw_interface_dump(jm); - if (rv != 0) - clib_warning ("unable to retrieve interface list (rv: %d)", rv); - rv = jm_stats_enable_disable(jm, 1); - if (rv != 0) - clib_warning ("unable to subscribe to stats (rv: %d)", rv); - } - DEBUG_LOG ("clientConnect result: %d", rv); - - return rv; -} - -JNIEXPORT void JNICALL Java_org_openvpp_vppjapi_vppConn_clientDisconnect - (JNIEnv *env, jobject obj) -{ - u8 *save_heap; - vppjni_main_t * jm = &vppjni_main; - vl_client_disconnect_from_vlib(); - - save_heap = jm->heap; - memset (jm, 0, sizeof (*jm)); - jm->heap = save_heap; -} - -void vl_api_generic_reply_handler (vl_api_generic_reply_t *mp) -{ - api_main_t * am = &api_main; - u16 msg_id = clib_net_to_host_u16 (mp->_vl_msg_id); - trace_cfg_t *cfgp; - i32 retval = clib_net_to_host_u32 (mp->retval); - int total_bytes = sizeof(mp); - vppjni_main_t * jm = &vppjni_main; - u8 * saved_reply = 0; - u32 context = clib_host_to_net_u32 (mp->context); - - cfgp = am->api_trace_cfg + msg_id; - - if (!cfgp) - clib_warning ("msg id %d: no trace configuration\n", msg_id); - else - total_bytes = cfgp->size; - - jm->context_id_received = context; - - DEBUG_LOG ("Received generic reply for msg id %d", msg_id); - - /* A generic reply, successful, we're done */ - if (retval >= 0 && total_bytes == sizeof(*mp)) - return; - - /* Save the reply */ - vec_validate (saved_reply, total_bytes - 1); - memcpy (saved_reply, mp, total_bytes); - - vppjni_lock (jm, 2); - hash_set (jm->reply_hash, context, saved_reply); - jm->saved_reply_count ++; - vppjni_unlock (jm); -} - -JNIEXPORT jint JNICALL Java_org_openvpp_vppjapi_vppConn_getRetval0 -(JNIEnv * env, jobject obj, jint context, jint release) -{ - vppjni_main_t * jm = &vppjni_main; - vl_api_generic_reply_t * mp; - uword * p; - int rv = 0; - - /* Dunno yet? */ - if (context > jm->context_id_received) - return (VNET_API_ERROR_RESPONSE_NOT_READY); - - vppjni_lock (jm, 1); - p = hash_get (jm->reply_hash, context); - - /* - * Two cases: a generic "yes" reply - won't be in the hash table - * or "no", or "more data" which will be in the table. - */ - if (p == 0) - goto out; - - mp = (vl_api_generic_reply_t *) (p[0]); - rv = clib_net_to_host_u32 (mp->retval); - - if (release) { - u8 * free_me = (u8 *) mp; - vec_free (free_me); - hash_unset (jm->reply_hash, context); - jm->saved_reply_count --; - } - -out: - vppjni_unlock (jm); - return (rv); -} - -static int -name_sort_cmp (void * a1, void * a2) -{ - name_sort_t * n1 = a1; - name_sort_t * n2 = a2; - - return strcmp ((char *)n1->name, (char *)n2->name); -} - -JNIEXPORT jstring JNICALL Java_org_openvpp_vppjapi_vppConn_getInterfaceList0 - (JNIEnv * env, jobject obj, jstring name_filter) -{ - vppjni_main_t * jm = &vppjni_main; - jstring rv; - hash_pair_t * p; - name_sort_t * nses = 0, * ns; - const char *this_name; - u8 * s = 0; - const char * nf = (*env)->GetStringUTFChars (env, name_filter, NULL); - if (!nf) - return NULL; - - vppjni_lock (jm, 4); - - hash_foreach_pair (p, jm->sw_if_index_by_interface_name, - ({ - this_name = (const char *)(p->key); - if (strlen (nf) == 0 || strcasestr (this_name, nf)) { - vec_add2 (nses, ns, 1); - ns->name = (u8 *)(p->key); - ns->value = (u32) p->value[0]; - } - })); - - vec_sort_with_function (nses, name_sort_cmp); - - vec_foreach (ns, nses) - s = format (s, "%s: %d, ", ns->name, ns->value); - - _vec_len (s) = vec_len (s) - 2; - vec_terminate_c_string (s); - vppjni_unlock (jm); - - vec_free (nses); - - (*env)->ReleaseStringUTFChars (env, name_filter, nf); - - rv = (*env)->NewStringUTF (env, (char *) s); - vec_free (s); - - return rv; -} - -JNIEXPORT jint JNICALL Java_org_openvpp_vppjapi_vppConn_swIfIndexFromName0 - (JNIEnv * env, jobject obj, jstring interfaceName) -{ - vppjni_main_t * jm = &vppjni_main; - jint rv = -1; - const char * if_name = (*env)->GetStringUTFChars (env, interfaceName, NULL); - if (if_name) { - uword * p; - - vppjni_lock (jm, 5); - - p = hash_get_mem (jm->sw_if_index_by_interface_name, if_name); - - if (p != 0) - rv = (jint) p[0]; - - vppjni_unlock (jm); - - (*env)->ReleaseStringUTFChars (env, interfaceName, if_name); - } - - return rv; -} - -JNIEXPORT jobject JNICALL Java_org_openvpp_vppjapi_vppConn_getInterfaceCounters0 -(JNIEnv * env, jobject obj, jint swIfIndex) -{ - vppjni_main_t * jm = &vppjni_main; - sw_interface_stats_t *s; - u32 sw_if_index = swIfIndex; - jobject result = NULL; - - vppjni_lock (jm, 16); - - if (sw_if_index >= vec_len(jm->sw_if_stats_by_sw_if_index)) { - goto out; - } - s = &jm->sw_if_stats_by_sw_if_index[sw_if_index]; - if (!s->valid) { - goto out; - } - - result = vppInterfaceCountersObject(env, - s->rx.octets, s->rx.pkts.ip4, s->rx.pkts.ip6, s->rx.pkts.unicast, - s->rx.pkts.multicast, s->rx.pkts.broadcast, s->rx.pkts.discard, - s->rx.pkts.fifo_full, s->rx.pkts.error, s->rx.pkts.unknown_proto, - s->rx.pkts.miss, - s->tx.octets, s->tx.pkts.ip4, s->tx.pkts.ip6, s->tx.pkts.unicast, - s->tx.pkts.multicast, s->tx.pkts.broadcast, s->tx.pkts.discard, - s->tx.pkts.fifo_full, s->tx.pkts.error, s->tx.pkts.unknown_proto, - s->tx.pkts.miss); - -out: - vppjni_unlock (jm); - return result; -} - -JNIEXPORT jstring JNICALL Java_org_openvpp_vppjapi_vppConn_interfaceNameFromSwIfIndex0 -(JNIEnv * env, jobject obj, jint swIfIndex) -{ - vppjni_main_t * jm = &vppjni_main; - sw_interface_details_t *sw_if_details; - u32 sw_if_index; - jstring ifname = NULL; - - vppjni_lock (jm, 8); - - sw_if_index = swIfIndex; - - if (sw_if_index >= vec_len(jm->sw_if_table)) { - goto out; - } - sw_if_details = &jm->sw_if_table[sw_if_index]; - if (!sw_if_details->valid) { - goto out; - } - - u8 * s = format (0, "%s%c", sw_if_details->interface_name, 0); - ifname = (*env)->NewStringUTF(env, (char *)s); - -out: - vppjni_unlock (jm); - - return ifname; -} - -JNIEXPORT void JNICALL Java_org_openvpp_vppjapi_vppConn_clearInterfaceTable0 -(JNIEnv * env, jobject obj) -{ - vppjni_main_t * jm = &vppjni_main; - - vppjni_lock (jm, 21); - - vec_reset_length(jm->sw_if_table); - - vppjni_unlock (jm); -} - -static jobjectArray sw_if_dump_get_interfaces (); - -JNIEXPORT jobjectArray JNICALL Java_org_openvpp_vppjapi_vppConn_swInterfaceDump0 -(JNIEnv * env, jobject obj, jbyte name_filter_valid, jbyteArray name_filter) -{ - vppjni_main_t *jm = &vppjni_main; - f64 timeout; - vl_api_sw_interface_dump_t * mp; - u32 my_context_id; - int rv; - rv = vppjni_sanity_check (jm); - if (rv) { - clib_warning("swInterfaceDump sanity_check rv = %d", rv); - return NULL; - } - - vppjni_lock (jm, 7); - my_context_id = vppjni_get_context_id (jm); - jsize cnt = (*env)->GetArrayLength (env, name_filter); - - M(SW_INTERFACE_DUMP, sw_interface_dump); - mp->context = clib_host_to_net_u32 (my_context_id); - mp->name_filter_valid = name_filter_valid; - - if (cnt > sizeof(mp->name_filter)) - cnt = sizeof(mp->name_filter); - - (*env)->GetByteArrayRegion(env, name_filter, 0, cnt, (jbyte *)mp->name_filter); - - DEBUG_LOG ("interface filter (%d, %s, len: %d)", mp->name_filter_valid, (char *)mp->name_filter, cnt); - - jm->collect_indices = 1; - - S; - { - // now send control ping so we know when it ends - vl_api_control_ping_t * mp; - M(CONTROL_PING, control_ping); - mp->context = clib_host_to_net_u32 (my_context_id); - - S; - } - vppjni_unlock (jm); - WNR; - - vppjni_lock (jm, 7); - jobjectArray result = sw_if_dump_get_interfaces(env); - vppjni_unlock (jm); - return result; -} - -static jobjectArray sw_if_dump_get_interfaces (JNIEnv * env) -{ - vppjni_main_t * jm = &vppjni_main; - sw_interface_details_t *sw_if_details; - u32 i; - - int len = vec_len(jm->sw_if_dump_if_indices); - - jobjectArray ifArray = vppInterfaceDetailsArray(env, len); - - for (i = 0; i < len; i++) { - u32 sw_if_index = jm->sw_if_dump_if_indices[i]; - ASSERT(sw_if_index < vec_len(jm->sw_if_table)); - sw_if_details = &jm->sw_if_table[sw_if_index]; - ASSERT(sw_if_details->valid); - - u8 * s = format (0, "%s%c", sw_if_details->interface_name, 0); - - jstring ifname = (*env)->NewStringUTF(env, (char *)s); - jint ifIndex = sw_if_details->sw_if_index; - jint supIfIndex = sw_if_details->sup_sw_if_index; - jbyteArray physAddr = (*env)->NewByteArray(env, - sw_if_details->l2_address_length); - (*env)->SetByteArrayRegion(env, physAddr, 0, - sw_if_details->l2_address_length, - (signed char*)sw_if_details->l2_address); - jint subId = sw_if_details->sub_id; - jint subOuterVlanId = sw_if_details->sub_outer_vlan_id; - jint subInnerVlanId = sw_if_details->sub_inner_vlan_id; - jint vtrOp = sw_if_details->vtr_op; - jint vtrPushDot1q = sw_if_details->vtr_push_dot1q; - jint vtrTag1 = sw_if_details->vtr_tag1; - jint vtrTag2 = sw_if_details->vtr_tag2; - jint linkMtu = sw_if_details->link_mtu; - - jbyte adminUpDown = sw_if_details->admin_up_down; - jbyte linkUpDown = sw_if_details->link_up_down; - jbyte linkDuplex = sw_if_details->link_duplex; - jbyte linkSpeed = sw_if_details->link_speed; - jbyte subDot1ad = sw_if_details->sub_dot1ad; - jbyte subNumberOfTags = sw_if_details->sub_number_of_tags; - jbyte subExactMatch = sw_if_details->sub_exact_match; - jbyte subDefault = sw_if_details->sub_default; - jbyte subOuterVlanIdAny = sw_if_details->sub_outer_vlan_id_any; - jbyte subInnerVlanIdAny = sw_if_details->sub_inner_vlan_id_any; - - jobject ifObj = vppInterfaceDetailsObject(env, - ifIndex, ifname, - supIfIndex, physAddr, adminUpDown, linkUpDown, - linkDuplex, linkSpeed, subId, subDot1ad, - subNumberOfTags, subOuterVlanId, subInnerVlanId, - subExactMatch, subDefault, subOuterVlanIdAny, - subInnerVlanIdAny, vtrOp, vtrPushDot1q, vtrTag1, vtrTag2, linkMtu); - (*env)->SetObjectArrayElement(env, ifArray, i, ifObj); - } - - jm->collect_indices = 0; - vec_reset_length(jm->sw_if_dump_if_indices); - return ifArray; -} - -JNIEXPORT jint JNICALL Java_org_openvpp_vppjapi_vppConn_findOrAddBridgeDomainId0 - (JNIEnv * env, jobject obj, jstring bridgeDomain) -{ - vppjni_main_t * jm = &vppjni_main; - jint rv = -1; - const char * bdName = (*env)->GetStringUTFChars (env, bridgeDomain, NULL); - if (bdName) { - static u8 * bd_name = 0; - - vec_validate_init_c_string (bd_name, bdName, strlen(bdName)); - (*env)->ReleaseStringUTFChars (env, bridgeDomain, bdName); - - vppjni_lock (jm, 6); - rv = (jint)vjbd_find_or_add_bd (&jm->vjbd_main, bd_name); - vppjni_unlock (jm); - - _vec_len(bd_name) = 0; - } - return rv; -} - -JNIEXPORT jint JNICALL Java_org_openvpp_vppjapi_vppConn_bridgeDomainIdFromName0 - (JNIEnv * env, jobject obj, jstring bridgeDomain) -{ - vppjni_main_t * jm = &vppjni_main; - jint rv = -1; - const char * bdName = (*env)->GetStringUTFChars (env, bridgeDomain, NULL); - if (bdName) { - static u8 * bd_name = 0; - - vec_validate_init_c_string (bd_name, bdName, strlen(bdName)); - (*env)->ReleaseStringUTFChars (env, bridgeDomain, bdName); - - vppjni_lock (jm, 20); - rv = (jint)vjbd_id_from_name(&jm->vjbd_main, (u8 *)bd_name); - vppjni_unlock (jm); - - _vec_len(bd_name) = 0; - } - - return rv; -} - -JNIEXPORT jint JNICALL Java_org_openvpp_vppjapi_vppConn_bridgeDomainIdFromInterfaceName0 - (JNIEnv * env, jobject obj, jstring interfaceName) -{ - vppjni_main_t * jm = &vppjni_main; - vjbd_main_t * bdm = &jm->vjbd_main; - u32 sw_if_index; - jint rv = -1; - const char * if_name; - uword * p; - - if_name = (*env)->GetStringUTFChars (env, interfaceName, NULL); - - vppjni_lock (jm, 14); - - p = hash_get_mem (jm->sw_if_index_by_interface_name, if_name); - - if (p != 0) { - sw_if_index = (jint) p[0]; - p = hash_get (bdm->bd_id_by_sw_if_index, sw_if_index); - if (p != 0) { - rv = (jint) p[0]; - } - } - - vppjni_unlock (jm); - - (*env)->ReleaseStringUTFChars (env, interfaceName, if_name); - - return rv; -} - -/* - * Special-case: build the interface table, maintain - * the next loopback sw_if_index vbl. - */ -static void vl_api_sw_interface_details_t_handler -(vl_api_sw_interface_details_t * mp) -{ - vppjni_main_t * jm = &vppjni_main; - static sw_interface_details_t empty_sw_if_details = {0,}; - sw_interface_details_t *sw_if_details; - u32 sw_if_index; - - vppjni_lock (jm, 1); - - sw_if_index = ntohl (mp->sw_if_index); - - u8 * s = format (0, "%s%c", mp->interface_name, 0); - - if (jm->collect_indices) { - u32 pos = vec_len(jm->sw_if_dump_if_indices); - vec_validate(jm->sw_if_dump_if_indices, pos); - jm->sw_if_dump_if_indices[pos] = sw_if_index; - } - - vec_validate_init_empty(jm->sw_if_table, sw_if_index, empty_sw_if_details); - sw_if_details = &jm->sw_if_table[sw_if_index]; - sw_if_details->valid = 1; - - snprintf((char *)sw_if_details->interface_name, - sizeof(sw_if_details->interface_name), "%s", (char *)s); - sw_if_details->sw_if_index = sw_if_index; - sw_if_details->sup_sw_if_index = ntohl(mp->sup_sw_if_index); - sw_if_details->l2_address_length = ntohl (mp->l2_address_length); - ASSERT(sw_if_details->l2_address_length <= sizeof(sw_if_details->l2_address)); - memcpy(sw_if_details->l2_address, mp->l2_address, - sw_if_details->l2_address_length); - sw_if_details->sub_id = ntohl (mp->sub_id); - sw_if_details->sub_outer_vlan_id = ntohl (mp->sub_outer_vlan_id); - sw_if_details->sub_inner_vlan_id = ntohl (mp->sub_inner_vlan_id); - sw_if_details->vtr_op = ntohl (mp->vtr_op); - sw_if_details->vtr_push_dot1q = ntohl (mp->vtr_push_dot1q); - sw_if_details->vtr_tag1 = ntohl (mp->vtr_tag1); - sw_if_details->vtr_tag2 = ntohl (mp->vtr_tag2); - - sw_if_details->admin_up_down = mp->admin_up_down; - sw_if_details->link_up_down = mp->link_up_down; - sw_if_details->link_duplex = mp->link_duplex; - sw_if_details->link_speed = mp->link_speed; - sw_if_details->sub_dot1ad = mp->sub_dot1ad; - sw_if_details->sub_number_of_tags = mp->sub_number_of_tags; - sw_if_details->sub_exact_match = mp->sub_exact_match; - sw_if_details->sub_default = mp->sub_default; - sw_if_details->sub_outer_vlan_id_any = mp->sub_outer_vlan_id_any; - sw_if_details->sub_inner_vlan_id_any = mp->sub_inner_vlan_id_any; - - hash_set_mem (jm->sw_if_index_by_interface_name, s, sw_if_index); - DEBUG_LOG ("Got interface %s", (char *)s); - - /* In sub interface case, fill the sub interface table entry */ - if (mp->sw_if_index != mp->sup_sw_if_index) { - sw_interface_subif_t * sub = NULL; - - vec_add2(jm->sw_if_subif_table, sub, 1); - - vec_validate(sub->interface_name, strlen((char *)s) + 1); - strncpy((char *)sub->interface_name, (char *)s, - vec_len(sub->interface_name)); - sub->sw_if_index = ntohl(mp->sw_if_index); - sub->sub_id = ntohl(mp->sub_id); - - sub->sub_dot1ad = mp->sub_dot1ad; - sub->sub_number_of_tags = mp->sub_number_of_tags; - sub->sub_outer_vlan_id = ntohs(mp->sub_outer_vlan_id); - sub->sub_inner_vlan_id = ntohs(mp->sub_inner_vlan_id); - sub->sub_exact_match = mp->sub_exact_match; - sub->sub_default = mp->sub_default; - sub->sub_outer_vlan_id_any = mp->sub_outer_vlan_id_any; - sub->sub_inner_vlan_id_any = mp->sub_inner_vlan_id_any; - - /* vlan tag rewrite */ - sub->vtr_op = ntohl(mp->vtr_op); - sub->vtr_push_dot1q = ntohl(mp->vtr_push_dot1q); - sub->vtr_tag1 = ntohl(mp->vtr_tag1); - sub->vtr_tag2 = ntohl(mp->vtr_tag2); - } - vppjni_unlock (jm); -} - -static void vl_api_sw_interface_set_flags_t_handler -(vl_api_sw_interface_set_flags_t * mp) -{ - /* $$$ nothing for the moment */ -} - -static jintArray create_array_of_bd_ids(JNIEnv * env, jint bd_id) -{ - vppjni_main_t *jm = &vppjni_main; - vjbd_main_t * bdm = &jm->vjbd_main; - u32 *buf = NULL; - u32 i; - - if (bd_id != ~0) { - vec_add1(buf, bd_id); - } else { - for (i = 0; i < vec_len(bdm->bd_oper); i++) { - u32 bd_id = bdm->bd_oper[i].bd_id; - vec_add1(buf, bd_id); - } - } - - jintArray bdidArray = (*env)->NewIntArray(env, vec_len(buf)); - if (!bdidArray) { - goto out; - } - - (*env)->SetIntArrayRegion(env, bdidArray, 0, vec_len(buf), (int*)buf); - -out: - vec_free(buf); - return bdidArray; -} - -static void bridge_domain_oper_free(void) -{ - vppjni_main_t *jm = &vppjni_main; - vjbd_main_t *bdm = &jm->vjbd_main; - u32 i; - - for (i = 0; i < vec_len(bdm->bd_oper); i++) { - vec_free(bdm->bd_oper->l2fib_oper); - } - vec_reset_length(bdm->bd_oper); - hash_free(bdm->bd_id_by_sw_if_index); - hash_free(bdm->oper_bd_index_by_bd_id); -} - -JNIEXPORT jintArray JNICALL Java_org_openvpp_vppjapi_vppConn_bridgeDomainDump0 -(JNIEnv * env, jobject obj, jint bd_id) -{ - vppjni_main_t *jm = &vppjni_main; - vl_api_bridge_domain_dump_t * mp; - u32 my_context_id; - f64 timeout; - int rv; - rv = vppjni_sanity_check (jm); - if (rv) return NULL; - - vppjni_lock (jm, 15); - - if (~0 == bd_id) { - bridge_domain_oper_free(); - } - - my_context_id = vppjni_get_context_id (jm); - M(BRIDGE_DOMAIN_DUMP, bridge_domain_dump); - mp->context = clib_host_to_net_u32 (my_context_id); - mp->bd_id = clib_host_to_net_u32(bd_id); - S; - - /* Use a control ping for synchronization */ - { - vl_api_control_ping_t * mp; - M(CONTROL_PING, control_ping); - S; - } - - WNR; - if (0 != rv) { - return NULL; - } - - jintArray ret = create_array_of_bd_ids(env, bd_id); - - vppjni_unlock (jm); - - return ret; -} - -static void -vl_api_bridge_domain_details_t_handler (vl_api_bridge_domain_details_t * mp) -{ - vppjni_main_t *jm = &vppjni_main; - vjbd_main_t * bdm = &jm->vjbd_main; - vjbd_oper_t * bd_oper; - u32 bd_id, bd_index; - - bd_id = ntohl (mp->bd_id); - - bd_index = vec_len(bdm->bd_oper); - vec_validate (bdm->bd_oper, bd_index); - bd_oper = vec_elt_at_index(bdm->bd_oper, bd_index); - - hash_set(bdm->oper_bd_index_by_bd_id, bd_id, bd_index); - - bd_oper->bd_id = bd_id; - bd_oper->flood = mp->flood != 0; - bd_oper->forward = mp->forward != 0; - bd_oper->learn = mp->learn != 0; - bd_oper->uu_flood = mp->uu_flood != 0; - bd_oper->arp_term = mp->arp_term != 0; - bd_oper->bvi_sw_if_index = ntohl (mp->bvi_sw_if_index); - bd_oper->n_sw_ifs = ntohl (mp->n_sw_ifs); - - bd_oper->bd_sw_if_oper = 0; -} - -static void -vl_api_bridge_domain_sw_if_details_t_handler -(vl_api_bridge_domain_sw_if_details_t * mp) -{ - vppjni_main_t *jm = &vppjni_main; - vjbd_main_t * bdm = &jm->vjbd_main; - bd_sw_if_oper_t * bd_sw_if_oper; - u32 bd_id, sw_if_index; - - bd_id = ntohl (mp->bd_id); - sw_if_index = ntohl (mp->sw_if_index); - - uword *p; - p = hash_get (bdm->oper_bd_index_by_bd_id, bd_id); - if (p == 0) { - clib_warning("Invalid bd_id %d in bridge_domain_sw_if_details_t_handler", bd_id); - return; - } - u32 oper_bd_index = (jint) p[0]; - vjbd_oper_t *bd_oper = vec_elt_at_index(bdm->bd_oper, oper_bd_index); - - u32 len = vec_len(bd_oper->bd_sw_if_oper); - vec_validate(bd_oper->bd_sw_if_oper, len); - bd_sw_if_oper = &bd_oper->bd_sw_if_oper[len]; - bd_sw_if_oper->bd_id = bd_id; - bd_sw_if_oper->sw_if_index = sw_if_index; - bd_sw_if_oper->shg = mp->shg; - - hash_set(bdm->bd_id_by_sw_if_index, sw_if_index, bd_id); -} - -static const char* interface_name_from_sw_if_index(u32 sw_if_index) -{ - vppjni_main_t *jm = &vppjni_main; - - if (sw_if_index >= vec_len(jm->sw_if_table)) { - return NULL; - } - if (!jm->sw_if_table[sw_if_index].valid) { - return NULL; - } - return (const char*)jm->sw_if_table[sw_if_index].interface_name; -} - -JNIEXPORT jobject JNICALL Java_org_openvpp_vppjapi_vppConn_getBridgeDomainDetails0 -(JNIEnv * env, jobject obj, jint bdId) -{ - vppjni_main_t *jm = &vppjni_main; - vjbd_main_t * bdm = &jm->vjbd_main; - u32 oper_bd_index; - u32 bd_id = bdId; - jobject rv = NULL; - uword *p; - - vppjni_lock (jm, 16); - - p = hash_get (bdm->oper_bd_index_by_bd_id, bd_id); - if (p == 0) { - rv = NULL; - goto out; - } - oper_bd_index = (jint) p[0]; - - vjbd_oper_t *bd_oper = vec_elt_at_index(bdm->bd_oper, oper_bd_index); - - - /* setting BridgeDomainDetails */ - - jobject bddObj = vppBridgeDomainDetailsObject(env); - - u8 *vec_bd_name = vjbd_oper_name_from_id(bdm, bd_id); - if (NULL == vec_bd_name) { - rv = NULL; - goto out; - } - char *str_bd_name = (char*)format (0, "%s%c", vec_bd_name, 0); - vec_free(vec_bd_name); - jstring bdName = (*env)->NewStringUTF(env, str_bd_name); - vec_free(str_bd_name); - if (NULL == bdName) { - rv = NULL; - goto out; - } - - set_vppBridgeDomainDetails_name(env, bddObj, bdName); - set_vppBridgeDomainDetails_bdId(env, bddObj, bdId); - set_vppBridgeDomainDetails_flood(env, bddObj, (jboolean)bd_oper->flood); - set_vppBridgeDomainDetails_uuFlood(env, bddObj, (jboolean)bd_oper->uu_flood); - set_vppBridgeDomainDetails_forward(env, bddObj, (jboolean)bd_oper->forward); - set_vppBridgeDomainDetails_learn(env, bddObj, (jboolean)bd_oper->learn); - set_vppBridgeDomainDetails_arpTerm(env, bddObj, (jboolean)bd_oper->arp_term); - - jstring bviInterfaceName = NULL; - if (~0 != bd_oper->bvi_sw_if_index) { - const char *str_if_name = interface_name_from_sw_if_index(bd_oper->bvi_sw_if_index); - if (NULL == str_if_name) { - clib_warning("Could not get interface name for sw_if_index %d", bd_oper->bvi_sw_if_index); - rv = NULL; - goto out; - } - bviInterfaceName = (*env)->NewStringUTF(env, str_if_name); - if (NULL == bviInterfaceName) { - rv = NULL; - goto out; - } - } - - set_vppBridgeDomainDetails_bviInterfaceName(env, bddObj, bviInterfaceName); - - /* setting BridgeDomainInterfaceDetails */ - - u32 len = vec_len(bd_oper->bd_sw_if_oper); - ASSERT(len == bd_oper->n_sw_ifs); - - jobjectArray bdidArray = vppBridgeDomainInterfaceDetailsArray(env, len); - - u32 i; - for (i = 0; i < len; i++) { - bd_sw_if_oper_t *sw_if_oper = &bd_oper->bd_sw_if_oper[i]; - - jobject bdidObj = vppBridgeDomainInterfaceDetailsObject(env); - (*env)->SetObjectArrayElement(env, bdidArray, i, bdidObj); - - u32 sw_if_index = sw_if_oper->sw_if_index; - const char *str_if_name = interface_name_from_sw_if_index(sw_if_index); - if (NULL == str_if_name) { - rv = NULL; - goto out; - } - jstring interfaceName = (*env)->NewStringUTF(env, str_if_name); - if (NULL == interfaceName) { - rv = NULL; - goto out; - } - - set_vppBridgeDomainInterfaceDetails_interfaceName(env, bdidObj, interfaceName); - set_vppBridgeDomainInterfaceDetails_splitHorizonGroup(env, bdidObj, (jbyte)sw_if_oper->shg); - } - - set_vppBridgeDomainDetails_interfaces(env, bddObj, bdidArray); - - rv = bddObj; - -out: - - vppjni_unlock (jm); - - return rv; -} - -static jobject l2_fib_create_object(JNIEnv *env, bd_l2fib_oper_t *l2_fib) -{ - u32 sw_if_index = l2_fib->sw_if_index; - const char *str_if_name = interface_name_from_sw_if_index(sw_if_index); - if (NULL == str_if_name) { - return NULL; - } - jstring interfaceName = (*env)->NewStringUTF(env, str_if_name); - if (NULL == interfaceName) { - return NULL; - } - - jbyteArray physAddr = (*env)->NewByteArray(env, 6); - (*env)->SetByteArrayRegion(env, physAddr, 0, 6, - (signed char*)l2_fib->mac_addr.fields.mac); - jboolean staticConfig = !l2_fib->learned; - jstring outgoingInterface = interfaceName; - jboolean filter = l2_fib->filter; - jboolean bridgedVirtualInterface = l2_fib->bvi; - - return vppL2FibObject(env, physAddr, staticConfig, outgoingInterface, filter, bridgedVirtualInterface); -} - -JNIEXPORT jobjectArray JNICALL Java_org_openvpp_vppjapi_vppConn_l2FibTableDump0 -(JNIEnv * env, jobject obj, jint bd_id) -{ - vppjni_main_t *jm = &vppjni_main; - vjbd_main_t * bdm = &jm->vjbd_main; - vl_api_l2_fib_table_dump_t *mp; - jobjectArray l2FibArray = NULL; - vjbd_oper_t *bd_oper; - u32 oper_bd_index; - uword *p; - f64 timeout; - int rv; - u32 i; - - vppjni_lock (jm, 17); - - //vjbd_l2fib_oper_reset (bdm); - - p = hash_get (bdm->oper_bd_index_by_bd_id, bd_id); - if (p == 0) { - goto done; - } - oper_bd_index = p[0]; - bd_oper = vec_elt_at_index(bdm->bd_oper, oper_bd_index); - vec_reset_length (bd_oper->l2fib_oper); - - /* Get list of l2 fib table entries */ - M(L2_FIB_TABLE_DUMP, l2_fib_table_dump); - mp->bd_id = ntohl(bd_id); - S; - - /* Use a control ping for synchronization */ - { - vl_api_control_ping_t * mp; - M(CONTROL_PING, control_ping); - S; - } - - WNR; - if (0 != rv) { - goto done; - } - - u32 count = vec_len(bd_oper->l2fib_oper); - bd_l2fib_oper_t *l2fib_oper = bd_oper->l2fib_oper; - - l2FibArray = vppL2FibArray(env, count); - for (i = 0; i < count; i++) { - bd_l2fib_oper_t *l2_fib = &l2fib_oper[i]; - jobject l2FibObj = l2_fib_create_object(env, l2_fib); - (*env)->SetObjectArrayElement(env, l2FibArray, i, l2FibObj); - } - -done: - vppjni_unlock (jm); - - return l2FibArray; -} - -static void -vl_api_l2_fib_table_entry_t_handler (vl_api_l2_fib_table_entry_t * mp) -{ - //static u8 * mac_addr; - vppjni_main_t *jm = &vppjni_main; - vjbd_main_t * bdm = &jm->vjbd_main; - vjbd_oper_t * bd_oper; - u32 bd_id, oper_bd_index; - //uword mhash_val_l2fi; - bd_l2fib_oper_t * l2fib_oper; - l2fib_u64_mac_t * l2fe_u64_mac = (l2fib_u64_mac_t *)&mp->mac; - - bd_id = ntohl (mp->bd_id); - - uword *p = hash_get (bdm->oper_bd_index_by_bd_id, bd_id); - if (p == 0) { - return; - } - oper_bd_index = (jint) p[0]; - bd_oper = vec_elt_at_index(bdm->bd_oper, oper_bd_index); - -#if 0 - vec_validate (mac_addr, MAC_ADDRESS_SIZE); - memcpy (mac_addr, l2fe_u64_mac->fields.mac, MAC_ADDRESS_SIZE); - mhash_val_l2fi = vec_len (bd_oper->l2fib_oper); - if (mhash_elts (&bd_oper->l2fib_index_by_mac) == 0) - mhash_init (&bd_oper->l2fib_index_by_mac, sizeof (u32), MAC_ADDRESS_SIZE); - mhash_set_mem (&bd_oper->l2fib_index_by_mac, mac_addr, &mhash_val_l2fi, 0); -#endif - - vec_add2 (bd_oper->l2fib_oper, l2fib_oper, 1); - - l2fib_oper->bd_id = bd_id; - l2fib_oper->mac_addr.raw = l2fib_mac_to_u64 (l2fe_u64_mac->fields.mac); - l2fib_oper->sw_if_index = ntohl (mp->sw_if_index); - l2fib_oper->learned = !mp->static_mac; - l2fib_oper->filter = mp->filter_mac; - l2fib_oper->bvi = mp->bvi_mac; -} - -static int ipAddressDump -(JNIEnv * env, jobject obj, jstring interfaceName, jboolean isIPv6) -{ - vppjni_main_t *jm = &vppjni_main; - vl_api_ip_address_dump_t * mp; - const char *if_name; - u32 my_context_id; - u32 sw_if_index; - f64 timeout; - uword *p; - int rv = 0; - - if (NULL == interfaceName) { - return -1; - } - - if_name = (*env)->GetStringUTFChars (env, interfaceName, NULL); - if (!if_name) { - return -1; - } - - p = hash_get_mem (jm->sw_if_index_by_interface_name, if_name); - (*env)->ReleaseStringUTFChars (env, interfaceName, if_name); - if (p == 0) { - return -1; - } - sw_if_index = (u32) p[0]; - - rv = vppjni_sanity_check (jm); - if (0 != rv) { - return rv; - } - - my_context_id = vppjni_get_context_id (jm); - M(IP_ADDRESS_DUMP, ip_address_dump); - mp->context = clib_host_to_net_u32 (my_context_id); - mp->sw_if_index = clib_host_to_net_u32(sw_if_index); - mp->is_ipv6 = isIPv6; - jm->is_ipv6 = isIPv6; - S; - - /* Use a control ping for synchronization */ - { - vl_api_control_ping_t * mp; - M(CONTROL_PING, control_ping); - S; - } - - WNR; - - return rv; -} - -JNIEXPORT jobjectArray JNICALL Java_org_openvpp_vppjapi_vppConn_ipv4AddressDump0 -(JNIEnv * env, jobject obj, jstring interfaceName) -{ - vppjni_main_t *jm = &vppjni_main; - jobject returnArray = NULL; - int i; - - vppjni_lock (jm, 18); - - vec_reset_length(jm->ipv4_addresses); - - if (0 != ipAddressDump(env, obj, interfaceName, 0)) { - goto done; - } - - u32 count = vec_len(jm->ipv4_addresses); - ipv4_address_t *ipv4_address = jm->ipv4_addresses; - - jobjectArray ipv4AddressArray = vppIPv4AddressArray(env, count); - - for (i = 0; i < count; i++) { - ipv4_address_t *address = &ipv4_address[i]; - - jint ip = address->ip; - jbyte prefixLength = address->prefix_length; - - jobject ipv4AddressObj = vppIPv4AddressObject(env, ip, prefixLength); - - (*env)->SetObjectArrayElement(env, ipv4AddressArray, i, ipv4AddressObj); - } - - returnArray = ipv4AddressArray; - -done: - vppjni_unlock (jm); - return returnArray; -} - -JNIEXPORT jobjectArray JNICALL Java_org_openvpp_vppjapi_vppConn_ipv6AddressDump0 -(JNIEnv * env, jobject obj, jstring interfaceName) -{ - vppjni_main_t *jm = &vppjni_main; - jobject returnArray = NULL; - int i; - - vppjni_lock (jm, 19); - - vec_reset_length(jm->ipv6_addresses); - - if (0 != ipAddressDump(env, obj, interfaceName, 1)) { - goto done; - } - - u32 count = vec_len(jm->ipv6_addresses); - ipv6_address_t *ipv6_address = jm->ipv6_addresses; - - jobjectArray ipv6AddressArray = vppIPv6AddressArray(env, count); - - for (i = 0; i < count; i++) { - ipv6_address_t *address = &ipv6_address[i]; - - jbyteArray ip = (*env)->NewByteArray(env, 16); - (*env)->SetByteArrayRegion(env, ip, 0, 16, - (signed char*)address->ip); - - jbyte prefixLength = address->prefix_length; - - jobject ipv6AddressObj = vppIPv6AddressObject(env, ip, prefixLength); - - (*env)->SetObjectArrayElement(env, ipv6AddressArray, i, ipv6AddressObj); - } - - returnArray = ipv6AddressArray; - -done: - vppjni_unlock (jm); - return returnArray; -} - -static void vl_api_ip_address_details_t_handler (vl_api_ip_address_details_t * mp) -{ - vppjni_main_t * jm = &vppjni_main; - - if (!jm->is_ipv6) { - ipv4_address_t *address = 0; - vec_add2(jm->ipv4_addresses, address, 1); - memcpy(&address->ip, mp->ip, 4); - address->prefix_length = mp->prefix_length; - } else { - ipv6_address_t *address = 0; - vec_add2(jm->ipv6_addresses, address, 1); - memcpy(address->ip, mp->ip, 16); - address->prefix_length = mp->prefix_length; - } -} - -#define VXLAN_TUNNEL_INTERFACE_NAME_PREFIX "vxlan_tunnel" - -JNIEXPORT jobjectArray JNICALL Java_org_openvpp_vppjapi_vppConn_vxlanTunnelDump0 -(JNIEnv * env, jobject obj, jint swIfIndex) -{ - vppjni_main_t *jm = &vppjni_main; - vl_api_vxlan_tunnel_dump_t * mp; - jobjectArray returnArray = NULL; - u32 my_context_id; - f64 timeout; - int rv = 0; - int i; - - vppjni_lock (jm, 22); - - vec_reset_length(jm->vxlan_tunnel_details); - - my_context_id = vppjni_get_context_id (jm); - M(VXLAN_TUNNEL_DUMP, vxlan_tunnel_dump); - mp->context = clib_host_to_net_u32 (my_context_id); - mp->sw_if_index = clib_host_to_net_u32 (swIfIndex); - S; - - /* Use a control ping for synchronization */ - { - vl_api_control_ping_t * mp; - M(CONTROL_PING, control_ping); - S; - } - - WNR; - if (0 != rv) { - goto done; - } - - u32 count = vec_len(jm->vxlan_tunnel_details); - - jobjectArray vxlanTunnelDetailsArray = vppVxlanTunnelDetailsArray(env, count); - - for (i = 0; i < count; i++) { - vxlan_tunnel_details_t *details = &jm->vxlan_tunnel_details[i]; - - jint src_address = details->src_address; - jint dst_address = details->dst_address; - jint encap_vrf_id = details->encap_vrf_id; - jint vni = details->vni; - jint decap_next_index = details->decap_next_index; - - jobject vxlanTunnelDetailsObj = vppVxlanTunnelDetailsObject(env, - src_address, dst_address, encap_vrf_id, vni, decap_next_index); - - (*env)->SetObjectArrayElement(env, vxlanTunnelDetailsArray, i, - vxlanTunnelDetailsObj); - } - - returnArray = vxlanTunnelDetailsArray; - -done: - vppjni_unlock (jm); - return returnArray; -} - -static void vl_api_vxlan_tunnel_details_t_handler -(vl_api_vxlan_tunnel_details_t * mp) -{ - vppjni_main_t * jm = &vppjni_main; - vxlan_tunnel_details_t *tunnel_details; - - vec_add2(jm->vxlan_tunnel_details, tunnel_details, 1); - tunnel_details->src_address = ntohl(mp->src_address); - tunnel_details->dst_address = ntohl(mp->dst_address); - tunnel_details->encap_vrf_id = ntohl(mp->encap_vrf_id); - tunnel_details->vni = ntohl(mp->vni); - tunnel_details->decap_next_index = ntohl(mp->decap_next_index); -} - -/* cleanup handler for RX thread */ -static void cleanup_rx_thread(void *arg) -{ - vppjni_main_t * jm = &vppjni_main; - - vppjni_lock (jm, 99); - - int getEnvStat = (*jm->jvm)->GetEnv(jm->jvm, (void **)&(jm->jenv), JNI_VERSION_1_6); - if (getEnvStat == JNI_EVERSION) { - clib_warning ("Unsupported JNI version\n"); - jm->retval = -999; - goto out; - } else if (getEnvStat != JNI_EDETACHED) { - (*jm->jvm)->DetachCurrentThread(jm->jvm); - } -out: - vppjni_unlock (jm); -} - -static void -vl_api_show_version_reply_t_handler (vl_api_show_version_reply_t * mp) -{ - vppjni_main_t * jm = &vppjni_main; - i32 retval = ntohl(mp->retval); - - if (retval >= 0) { - DEBUG_LOG ("show version request succeeded(%d)"); - strncpy((char*)jm->program_name, (const char*)mp->program, - sizeof(jm->program_name)-1); - jm->program_name[sizeof(jm->program_name)-1] = 0; - - strncpy((char*)jm->build_directory, (const char*)mp->build_directory, - sizeof(jm->build_directory)-1); - jm->build_directory[sizeof(jm->build_directory)-1] = 0; - - strncpy((char*)jm->version, (const char*)mp->version, - sizeof(jm->version)-1); - jm->version[sizeof(jm->version)-1] = 0; - - strncpy((char*)jm->build_date, (const char*)mp->build_date, - sizeof(jm->build_date)-1); - jm->build_date[sizeof(jm->build_date)-1] = 0; - } else { - clib_error ("show version request failed(%d)", retval); - } - jm->retval = retval; - jm->result_ready = 1; -} - -static void vl_api_want_stats_reply_t_handler (vl_api_want_stats_reply_t * mp) -{ - vppjni_main_t * jm = &vppjni_main; - jm->retval = mp->retval; // FIXME: vpp api does not do ntohl on this retval - jm->result_ready = 1; -} - -// control ping needs to be very first thing called -// to attach rx thread to java thread -static void vl_api_control_ping_reply_t_handler -(vl_api_control_ping_reply_t * mp) -{ - vppjni_main_t * jm = &vppjni_main; - i32 retval = ntohl(mp->retval); - jm->retval = retval; - - // attach to java thread if not attached - int getEnvStat = (*jm->jvm)->GetEnv(jm->jvm, (void **)&(jm->jenv), JNI_VERSION_1_6); - if (getEnvStat == JNI_EDETACHED) { - if ((*jm->jvm)->AttachCurrentThread(jm->jvm, (void **)&(jm->jenv), NULL) != 0) { - clib_warning("Failed to attach thread\n"); - jm->retval = -999; - goto out; - } - - // workaround as we can't use pthread_cleanup_push - pthread_key_create(&jm->cleanup_rx_thread_key, cleanup_rx_thread); - // destructor is only called if the value of key is non null - pthread_setspecific(jm->cleanup_rx_thread_key, (void *)1); - } else if (getEnvStat == JNI_EVERSION) { - clib_warning ("Unsupported JNI version\n"); - jm->retval = -999; - goto out; - } - // jm->jenv is now stable global reference that can be reused (only within RX thread) - -#if 0 - // ! callback system removed for now - // - // get issuer msg-id - p = hash_get (jm->ping_hash, context); - if (p != 0) { // ping marks end of some dump call - JNIEnv *env = jm->jenv; - u16 msg_id = (u16)p[0]; - - // we will no longer need this - hash_unset (jm->ping_hash, context); - - // get original caller obj - p = hash_get (jm->callback_hash, context); - - if (p == 0) // don't have callback stored - goto out; - - jobject obj = (jobject)p[0]; // object that called original call - - switch (msg_id) { - case VL_API_SW_INTERFACE_DUMP: - if (0 != sw_if_dump_call_all_callbacks(obj)) { - goto out2; - } - break; - default: - clib_warning("Unhandled control ping issuer msg-id: %d", msg_id); - goto out2; - break; - } -out2: - // free the saved obj - hash_unset (jm->callback_hash, context); - // delete global reference - (*env)->DeleteGlobalRef(env, obj); - } -#endif - -out: - jm->result_ready = 1; -} - -#define VPPJNI_DEBUG_COUNTERS 0 - -static void vl_api_vnet_interface_counters_t_handler -(vl_api_vnet_interface_counters_t *mp) -{ - vppjni_main_t *jm = &vppjni_main; - CLIB_UNUSED(char *counter_name); - u32 count, sw_if_index; - int i; - static sw_interface_stats_t empty_stats = {0, }; - - vppjni_lock (jm, 12); - count = ntohl (mp->count); - sw_if_index = ntohl (mp->first_sw_if_index); - if (mp->is_combined == 0) { - u64 * vp, v; - vp = (u64 *) mp->data; - - for (i = 0; i < count; i++) { - sw_interface_details_t *sw_if = NULL; - - v = clib_mem_unaligned (vp, u64); - v = clib_net_to_host_u64 (v); - vp++; - - if (sw_if_index < vec_len(jm->sw_if_table)) - sw_if = vec_elt_at_index(jm->sw_if_table, sw_if_index); - - if (sw_if /* && (sw_if->admin_up_down == 1)*/ && sw_if->interface_name[0] != 0) { - vec_validate_init_empty(jm->sw_if_stats_by_sw_if_index, sw_if_index, empty_stats); - sw_interface_stats_t * s = vec_elt_at_index(jm->sw_if_stats_by_sw_if_index, sw_if_index); - - s->sw_if_index = sw_if_index; - s->valid = 1; - - switch (mp->vnet_counter_type) { - case VNET_INTERFACE_COUNTER_DROP: - counter_name = "drop"; - s->rx.pkts.discard = v; - break; - case VNET_INTERFACE_COUNTER_PUNT: - counter_name = "punt"; - s->rx.pkts.unknown_proto = v; - break; - case VNET_INTERFACE_COUNTER_IP4: - counter_name = "ip4"; - s->rx.pkts.ip4 = v; - break; - case VNET_INTERFACE_COUNTER_IP6: - counter_name = "ip6"; - s->rx.pkts.ip6 = v; - break; - case VNET_INTERFACE_COUNTER_RX_NO_BUF: - counter_name = "rx-no-buf"; - s->rx.pkts.fifo_full = v; - break; - case VNET_INTERFACE_COUNTER_RX_MISS: - counter_name = "rx-miss"; - s->rx.pkts.miss = v; - break; - case VNET_INTERFACE_COUNTER_RX_ERROR: - counter_name = "rx-error"; - s->rx.pkts.error = v; - break; - case VNET_INTERFACE_COUNTER_TX_ERROR: - counter_name = "tx-error (fifo-full)"; - s->tx.pkts.fifo_full = v; - break; - default: - counter_name = "bogus"; - break; - } - -#if VPPJNI_DEBUG_COUNTERS == 1 - clib_warning ("%s (%d): %s (%lld)\n", sw_if->interface_name, s->sw_if_index, - counter_name, v); -#endif - } - sw_if_index++; - } - } else { - vlib_counter_t *vp; - u64 packets, bytes; - vp = (vlib_counter_t *) mp->data; - - for (i = 0; i < count; i++) { - sw_interface_details_t *sw_if = NULL; - - packets = clib_mem_unaligned (&vp->packets, u64); - packets = clib_net_to_host_u64 (packets); - bytes = clib_mem_unaligned (&vp->bytes, u64); - bytes = clib_net_to_host_u64 (bytes); - vp++; - - if (sw_if_index < vec_len(jm->sw_if_table)) - sw_if = vec_elt_at_index(jm->sw_if_table, sw_if_index); - - if (sw_if /* && (sw_if->admin_up_down == 1) */ && sw_if->interface_name[0] != 0) { - vec_validate_init_empty(jm->sw_if_stats_by_sw_if_index, sw_if_index, empty_stats); - sw_interface_stats_t * s = vec_elt_at_index(jm->sw_if_stats_by_sw_if_index, sw_if_index); - - s->valid = 1; - s->sw_if_index = sw_if_index; - - switch (mp->vnet_counter_type) { - case VNET_INTERFACE_COUNTER_RX: - s->rx.pkts.unicast = packets; - s->rx.octets = bytes; - counter_name = "rx"; - break; - - case VNET_INTERFACE_COUNTER_TX: - s->tx.pkts.unicast = packets; - s->tx.octets = bytes; - counter_name = "tx"; - break; - - default: - counter_name = "bogus"; - break; - } - -#if VPPJNI_DEBUG_COUNTERS == 1 - clib_warning ("%s (%d): %s.packets %lld\n", - sw_if->interface_name, - sw_if_index, counter_name, packets); - clib_warning ("%s (%d): %s.bytes %lld\n", - sw_if->interface_name, - sw_if_index, counter_name, bytes); -#endif - } - sw_if_index++; - } - } - vppjni_unlock (jm); -} - -jint JNI_OnLoad(JavaVM *vm, void *reserved) { - vppjni_main_t * jm = &vppjni_main; - JNIEnv* env; - if ((*vm)->GetEnv(vm, (void**) &env, JNI_VERSION_1_6) != JNI_OK) { - return JNI_ERR; - } - - if (vppjni_init(env) != 0) { - return JNI_ERR; - } - - jm->jvm = vm; - return JNI_VERSION_1_6; -} - -void JNI_OnUnload(JavaVM *vm, void *reserved) { - vppjni_main_t * jm = &vppjni_main; - JNIEnv* env; - if ((*vm)->GetEnv(vm, (void**) &env, JNI_VERSION_1_6) != JNI_OK) { - return; - } - - vppjni_uninit(env); - - jm->jenv = NULL; - jm->jvm = NULL; -} - -#define foreach_vpe_api_msg \ -_(CONTROL_PING_REPLY, control_ping_reply) \ -_(SW_INTERFACE_DETAILS, sw_interface_details) \ -_(SHOW_VERSION_REPLY, show_version_reply) \ -_(WANT_STATS_REPLY, want_stats_reply) \ -_(VNET_INTERFACE_COUNTERS, vnet_interface_counters) \ -_(SW_INTERFACE_SET_FLAGS, sw_interface_set_flags) \ -_(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \ -_(BRIDGE_DOMAIN_SW_IF_DETAILS, bridge_domain_sw_if_details) \ -_(L2_FIB_TABLE_ENTRY, l2_fib_table_entry) \ -_(IP_ADDRESS_DETAILS, ip_address_details) \ -_(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) - -static int connect_to_vpe(char *name) -{ - vppjni_main_t * jm = &vppjni_main; - api_main_t * am = &api_main; - - if (vl_client_connect_to_vlib("/vpe-api", name, 32) < 0) - return -1; - - jm->my_client_index = am->my_client_index; - jm->vl_input_queue = am->shmem_hdr->vl_input_queue; - -#define _(N,n) \ - vl_msg_api_set_handlers(VL_API_##N, #n, \ - vl_api_##n##_t_handler, \ - vl_noop_handler, \ - vl_api_##n##_t_endian, \ - vl_api_##n##_t_print, \ - sizeof(vl_api_##n##_t), 1); - foreach_vpe_api_msg; -#undef _ - - return 0; -} - -/* Format an IP6 address. */ -u8 * format_ip6_address (u8 * s, va_list * args) -{ - ip6_address_t * a = va_arg (*args, ip6_address_t *); - u32 max_zero_run = 0, this_zero_run = 0; - int max_zero_run_index = -1, this_zero_run_index=0; - int in_zero_run = 0, i; - int last_double_colon = 0; - - /* Ugh, this is a pain. Scan forward looking for runs of 0's */ - for (i = 0; i < ARRAY_LEN (a->as_u16); i++) { - if (a->as_u16[i] == 0) { - if (in_zero_run) { - this_zero_run++; - } else { - in_zero_run = 1; - this_zero_run =1; - this_zero_run_index = i; - } - } else { - if (in_zero_run) { - /* offer to compress the biggest run of > 1 zero */ - if (this_zero_run > max_zero_run && this_zero_run > 1) { - max_zero_run_index = this_zero_run_index; - max_zero_run = this_zero_run; - } - } - in_zero_run = 0; - this_zero_run = 0; - } - } - - if (in_zero_run) { - if (this_zero_run > max_zero_run && this_zero_run > 1) { - max_zero_run_index = this_zero_run_index; - max_zero_run = this_zero_run; - } - } - - for (i = 0; i < ARRAY_LEN (a->as_u16); i++) { - if (i == max_zero_run_index) { - s = format (s, "::"); - i += max_zero_run - 1; - last_double_colon = 1; - } else { - s = format (s, "%s%x", - (last_double_colon || i == 0) ? "" : ":", - clib_net_to_host_u16 (a->as_u16[i])); - last_double_colon = 0; - } - } - - return s; -} - -/* Format an IP4 address. */ -u8 * format_ip4_address (u8 * s, va_list * args) -{ - u8 * a = va_arg (*args, u8 *); - return format (s, "%d.%d.%d.%d", a[0], a[1], a[2], a[3]); -} - - diff --git a/vpp-japi/japi/vppjni.h b/vpp-japi/japi/vppjni.h deleted file mode 100644 index bd0683ae..00000000 --- a/vpp-japi/japi/vppjni.h +++ /dev/null @@ -1,308 +0,0 @@ -/* - * Copyright (c) 2015 Cisco and/or its affiliates. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#ifndef __included_vppjni_h__ -#define __included_vppjni_h__ - -#include -#include -#include -#include -#include -#include -#include - -typedef struct { - u8 * name; - u32 value; -} name_sort_t; - -typedef struct { - u8 valid; // used in a vector of sw_interface_details_t - - u8 interface_name[64]; - u32 sw_if_index; - u32 sup_sw_if_index; - u32 l2_address_length; - u8 l2_address[8]; - u8 admin_up_down; - u8 link_up_down; - u8 link_duplex; - u8 link_speed; - u16 link_mtu; - u32 sub_id; - u8 sub_dot1ad; - u8 sub_number_of_tags; - u16 sub_outer_vlan_id; - u16 sub_inner_vlan_id; - u8 sub_exact_match; - u8 sub_default; - u8 sub_outer_vlan_id_any; - u8 sub_inner_vlan_id_any; - u32 vtr_op; - u32 vtr_push_dot1q; - u32 vtr_tag1; - u32 vtr_tag2; -} sw_interface_details_t; - -typedef struct { - u8 * interface_name; - u32 sw_if_index; - /* - * Subinterface ID. A number 0-N to uniquely identify - * this subinterface under the super interface - */ - u32 sub_id; - - /* 0 = dot1q, 1=dot1ad */ - u8 sub_dot1ad; - - /* Number of tags 0-2 */ - u8 sub_number_of_tags; - u16 sub_outer_vlan_id; - u16 sub_inner_vlan_id; - u8 sub_exact_match; - u8 sub_default; - u8 sub_outer_vlan_id_any; - u8 sub_inner_vlan_id_any; - - /* vlan tag rewrite */ - u32 vtr_op; - u32 vtr_push_dot1q; - u32 vtr_tag1; - u32 vtr_tag2; -} sw_interface_subif_t; - -typedef struct { - u8 *desc; -} sw_if_config_t; - -typedef struct { - u32 ip; - u8 prefix_length; -} ipv4_address_t; - -typedef struct { - u8 ip[16]; - u8 prefix_length; -} ipv6_address_t; - -typedef struct { - u64 ip4; - u64 ip6; - u64 unicast; - u64 multicast; - u64 broadcast; - u64 discard; - u64 fifo_full; - u64 error; - u64 unknown_proto; - u64 miss; -} packet_counters_t; - -typedef struct { - u64 octets; - packet_counters_t pkts; -} if_counters_t; - -typedef struct { - u8 valid; - u32 sw_if_index; - if_counters_t rx; - if_counters_t tx; -} sw_interface_stats_t; - -typedef struct { - u32 src_address; - u32 dst_address; - u32 encap_vrf_id; - u32 vni; - u32 decap_next_index; -} vxlan_tunnel_details_t; - - -typedef struct { - /* Context IDs */ - volatile u32 context_id_sent; - volatile u32 context_id_received; - - /* Spinlock */ - volatile u32 lock; - u32 tag; - - /* To recycle pseudo-synchronous message code from vpp_api_test... */ - volatile u32 result_ready; - volatile i32 retval; - volatile u8 *shmem_result; - - /* thread cleanup */ - pthread_key_t cleanup_rx_thread_key; - /* attachment of rx thread to java thread */ - JNIEnv *jenv; - JavaVM *jvm; - uword *callback_hash; // map context_id => jobject - uword *ping_hash; // map ping context_id => msg type called - - /* Timestamp */ - clib_time_t clib_time; - - /* connected indication */ - u8 is_connected; - - /* context -> non-trivial reply hash */ - uword * reply_hash; - u32 saved_reply_count; - - /* interface name map */ - uword * sw_if_index_by_interface_name; - - /* interface counters */ - sw_interface_stats_t * sw_if_stats_by_sw_if_index; - - /* interface table */ - sw_interface_details_t * sw_if_table; - - uword * sw_if_config_by_sw_if_index; - - /* interface indices of responses to one sw_if_dump request */ - u8 collect_indices; - u32 * sw_if_dump_if_indices; - - /* program name, build_dir, version */ - u8 program_name[32]; - u8 build_directory[256]; - u8 version[32]; - u8 build_date[32]; - - /* subinterface table */ - sw_interface_subif_t * sw_if_subif_table; - - /* used in ip_address_dump request and response handling */ - ipv4_address_t *ipv4_addresses; - ipv6_address_t *ipv6_addresses; - u8 is_ipv6; - - /* used in vxlan_tunnel_dump request and response handling */ - vxlan_tunnel_details_t *vxlan_tunnel_details; - - /* main heap */ - u8 * heap; - - /* convenience */ - unix_shared_memory_queue_t * vl_input_queue; - api_main_t * api_main; - u32 my_client_index; - - vjbd_main_t vjbd_main; -} vppjni_main_t; - -vppjni_main_t vppjni_main __attribute__((aligned (64))); - - -static inline u32 vppjni_get_context_id (vppjni_main_t * jm) -{ - u32 my_context_id; - my_context_id = __sync_add_and_fetch (&jm->context_id_sent, 1); - return my_context_id; -} - -static inline void vppjni_lock (vppjni_main_t * jm, u32 tag) -{ - while (__sync_lock_test_and_set (&jm->lock, 1)) - ; - jm->tag = tag; -} - -static inline void vppjni_unlock (vppjni_main_t * jm) -{ - jm->tag = 0; - CLIB_MEMORY_BARRIER(); - jm->lock = 0; -} - -static inline f64 vppjni_time_now (vppjni_main_t *jm) -{ - return clib_time_now (&jm->clib_time); -} - -static inline int vppjni_sanity_check (vppjni_main_t * jm) -{ - if (!jm->is_connected) - return VNET_API_ERROR_NOT_CONNECTED; - return 0; -} - -#define __PACKED(x) x __attribute__((packed)) - -typedef __PACKED(struct _vl_api_generic_reply { - u16 _vl_msg_id; - u32 context; - i32 retval; - u8 data[0]; -}) vl_api_generic_reply_t; - -void vl_api_generic_reply_handler (vl_api_generic_reply_t *mp); - -/* M: construct, but don't yet send a message */ - -#define M(T,t) \ -do { \ - jm->result_ready = 0; \ - mp = vl_msg_api_alloc(sizeof(*mp)); \ - memset (mp, 0, sizeof (*mp)); \ - mp->_vl_msg_id = ntohs (VL_API_##T); \ - mp->client_index = jm->my_client_index; \ - } while(0); - -#define M2(T,t,n) \ -do { \ - jm->result_ready = 0; \ - mp = vl_msg_api_alloc(sizeof(*mp)+(n)); \ - memset (mp, 0, sizeof (*mp)); \ - mp->_vl_msg_id = ntohs (VL_API_##T); \ - mp->client_index = jm->my_client_index; \ - } while(0); - - -/* S: send a message */ -#define S (vl_msg_api_send_shmem (jm->vl_input_queue, (u8 *)&mp)) - -/* W: wait for results, with timeout */ -#define W \ - do { \ - timeout = vppjni_time_now (jm) + 1.0; \ - \ - while (vppjni_time_now (jm) < timeout) { \ - if (jm->result_ready == 1) { \ - return (jm->retval); \ - } \ - } \ - return -99; \ -} while(0); - -/* WNR: wait for results, with timeout (without returning) */ -#define WNR \ - do { \ - timeout = vppjni_time_now (jm) + 1.0; \ - \ - rv = -99; \ - while (vppjni_time_now (jm) < timeout) { \ - if (jm->result_ready == 1) { \ - rv = (jm->retval); \ - break; \ - } \ - } \ -} while(0); - -#endif /* __included_vppjni_h__ */ diff --git a/vpp-japi/japi/vppjni_bridge_domain.h b/vpp-japi/japi/vppjni_bridge_domain.h deleted file mode 100644 index b614a5be..00000000 --- a/vpp-japi/japi/vppjni_bridge_domain.h +++ /dev/null @@ -1,510 +0,0 @@ -/*--------------------------------------------------------------------------- - * Copyright (c) 2009-2014 Cisco and/or its affiliates. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *--------------------------------------------------------------------------- - */ - -#ifndef __included_vppjni_bridge_domain_h__ -#define __included_vppjni_bridge_domain_h__ - -#include -#include -#include - -/* - * The L2fib key is the mac address and bridge domain ID - */ -#define MAC_ADDRESS_SIZE 6 - -typedef struct { - union { - struct { - u16 unused1; - u8 mac[MAC_ADDRESS_SIZE]; - } fields; - u64 raw; - }; -} l2fib_u64_mac_t; - -/* - * The l2fib entry results - */ -typedef struct { - u32 bd_id; - l2fib_u64_mac_t mac_addr; - u32 sw_if_index; - u8 learned:1; - u8 bvi:1; - u8 filter:1; // drop packets to/from this mac - u8 unused1:5; -} bd_l2fib_oper_t; - -typedef struct { - u32 bd_id; - u8 * bd_name; -} bd_local_cfg_t; - -typedef struct { - u32 bd_id; - u32 sw_if_index; - u32 shg; -} bd_sw_if_oper_t; - -typedef struct { - u32 bd_id; - u8 flood:1; - u8 forward:1; - u8 learn:1; - u8 uu_flood:1; - u8 arp_term:1; - u8 unused1:3; - u32 bvi_sw_if_index; - u32 n_sw_ifs; - bd_sw_if_oper_t * bd_sw_if_oper; - f64 last_sync_time; - mhash_t l2fib_index_by_mac; - bd_l2fib_oper_t * l2fib_oper; // vector indexed by l2fib_index -} vjbd_oper_t; - -#define BD_OPER_REFRESH_INTERVAL 2.0 -#define BD_OPER_L2FIB_REFRESH_INTERVAL 5.0 - -typedef struct { - u32 next_bd_id; - uword * bd_index_bitmap; - uword * bd_index_by_id; - mhash_t bd_id_by_name; - bd_local_cfg_t * local_cfg; // vector indexed by bd_index - vjbd_oper_t * bd_oper; // vector indexed by oper_bd_index - f64 bd_oper_last_sync_all_time; - bd_sw_if_oper_t * sw_if_oper; // vector indexed by sw_if_index - f64 l2fib_oper_last_sync_time; - uword * bd_id_by_sw_if_index; - uword * oper_bd_index_by_bd_id; -} vjbd_main_t; - -extern vjbd_main_t vjbd_main; - -always_inline -u64 l2fib_mac_to_u64 (u8 * mac_address) { - u64 temp; - - // The mac address in memory is A:B:C:D:E:F - // The bd id in register is H:L -#if CLIB_ARCH_IS_LITTLE_ENDIAN - // Create the in-register key as F:E:D:C:B:A:H:L - // In memory the key is L:H:A:B:C:D:E:F - temp = *((u64 *)(mac_address - 2)); - temp = (temp & ~0xffff); -#else - // Create the in-register key as H:L:A:B:C:D:E:F - // In memory the key is H:L:A:B:C:D:E:F - temp = *((u64 *)(mac_address)) >> 16; -#endif - - return temp; -} - -static_always_inline void vjbd_main_init (vjbd_main_t *bdm) -{ - bdm->bd_index_by_id = hash_create (0, sizeof(uword)); - mhash_init_vec_string (&bdm->bd_id_by_name, sizeof (u32)); - bdm->bd_id_by_sw_if_index = hash_create (0, sizeof (u32)); - bdm->oper_bd_index_by_bd_id = hash_create (0, sizeof (u32)); -} - -static_always_inline u32 vjbd_id_is_valid (vjbd_main_t * bdm, u32 bd_id) -{ - return ((bd_id != 0) && (bd_id != ~0) && (bd_id <= bdm->next_bd_id)); -} - -static_always_inline u32 vjbd_index_is_free (vjbd_main_t * bdm, u16 bd_index) -{ - u32 bd_id = vec_elt_at_index(bdm->local_cfg, bd_index)->bd_id; - - return (!clib_bitmap_get (bdm->bd_index_bitmap, (bd_index)) && - (bd_index < vec_len (bdm->local_cfg)) && - ((bd_id == 0) || (bd_id == ~0))); -} - -static_always_inline u32 vjbd_index_is_valid (vjbd_main_t * bdm, u16 bd_index) -{ - return (clib_bitmap_get (bdm->bd_index_bitmap, bd_index) && - (bd_index < vec_len (bdm->local_cfg))); -} - -static_always_inline u32 vjbd_id_from_name (vjbd_main_t * bdm, - const u8 * bd_name) -{ - u32 bd_id; - uword * p; - - ASSERT (vec_c_string_is_terminated (bd_name)); - - if (bdm->next_bd_id == 0) - return ~0; - - p = mhash_get (&bdm->bd_id_by_name, (void *)bd_name); - if (p) - { - bd_id = p[0]; - ASSERT (vjbd_id_is_valid (bdm, bd_id)); - } - else - bd_id = ~0; - - return bd_id; -} - -static_always_inline u32 vjbd_index_from_id (vjbd_main_t * bdm, u32 bd_id) -{ - uword * p; - u16 bd_index; - - ASSERT (vjbd_id_is_valid (bdm, bd_id)); - - p = hash_get (bdm->bd_index_by_id, bd_id); - - ASSERT (p); // there is always an index associated with a valid bd_id - bd_index = p[0]; - - ASSERT (vjbd_index_is_valid (bdm, bd_index)); - - return bd_index; -} - -static_always_inline u32 vjbd_id_from_index (vjbd_main_t * bdm, u16 bd_index) -{ - u32 bd_id; - - ASSERT (vjbd_index_is_valid (bdm, bd_index)); - - bd_id = vec_elt_at_index(bdm->local_cfg, bd_index)->bd_id; - - ASSERT (vjbd_id_is_valid (bdm, bd_id)); - - return bd_id; -} - -static_always_inline u8 * vjbd_name_from_id (vjbd_main_t * bdm, u32 bd_id) -{ - u16 bd_index = vjbd_index_from_id (bdm, bd_id); - - return vec_elt_at_index(bdm->local_cfg, bd_index)->bd_name; -} - -static_always_inline u8 * vjbd_oper_name_from_id (vjbd_main_t * bdm, u32 bd_id) -{ - if (vjbd_id_is_valid (bdm, bd_id)) { - return format(0, "%s", vjbd_name_from_id(bdm, bd_id)); - } else { - return format(0, "BridgeDomainOper%d", bd_id); - } -} - -static_always_inline vjbd_oper_t * vjbd_oper_from_id (vjbd_main_t * bdm, - u32 bd_id) -{ - u16 bd_index = vjbd_index_from_id (bdm, bd_id); - return vec_elt_at_index (bdm->bd_oper, bd_index); -} - -static_always_inline void vjbd_oper_maybe_sync_from_vpp (vjbd_main_t * bdm, - u32 bd_id) -{ -#ifdef VPPJNI_OPER - vppjni_vpe_api_msg_main_t *ovam = ovam_get_main (); - - if (bd_id == ~0) - { - if ((ovam_time_now (ovam) - bdm->bd_oper_last_sync_all_time) > - BD_OPER_REFRESH_INTERVAL) - { - ovam_bridge_domain_dump (bd_id); - bdm->bd_oper_last_sync_all_time = ovam_time_now (ovam); - } - } - - else - { - vjbd_oper_t * bd_oper = vjbd_oper_from_id (bdm, bd_id); - - if ((ovam_time_now (ovam) - bd_oper->last_sync_time) > - BD_OPER_REFRESH_INTERVAL) - { - ovam_bridge_domain_dump (bd_id); - - bd_oper->last_sync_time = ovam_time_now (ovam); - } - } -#endif -} - -static_always_inline u32 vjbd_id_from_sw_if_index (vjbd_main_t * bdm, - u32 sw_if_index) -{ - bd_sw_if_oper_t * bd_sw_if_oper; - u32 bd_id = ~0; - - vjbd_oper_maybe_sync_from_vpp (bdm, ~0); - if (sw_if_index < vec_len (bdm->sw_if_oper)) - { - bd_sw_if_oper = vec_elt_at_index (bdm->sw_if_oper, sw_if_index); - bd_id = bd_sw_if_oper->bd_id; - } - - return bd_id; -} - -static_always_inline u8 * vjbd_name_from_sw_if_index (vjbd_main_t * bdm, - u32 sw_if_index) -{ - u32 bd_id, bd_index; - u8 * bd_name = 0; - - /* DAW-FIXME: - ASSERT (ovam_sw_if_index_valid (ovam_get_main(), sw_if_index)); - */ - vjbd_oper_maybe_sync_from_vpp (bdm, ~0); - bd_id = vjbd_id_from_sw_if_index (bdm, sw_if_index); - if (vjbd_id_is_valid (bdm, bd_id)) - { - bd_index = vjbd_index_from_id (bdm, bd_id); - bd_name = vec_elt_at_index (bdm->local_cfg, bd_index)->bd_name; - } - - return bd_name; -} - -static_always_inline u32 -vjbd_oper_l2fib_index_from_mac (vjbd_oper_t * bd_oper, u8 * mac) -{ - u32 l2fib_index; - uword * p; - - p = mhash_get (&bd_oper->l2fib_index_by_mac, mac); - if (p) - { - l2fib_index = p[0]; - ASSERT (l2fib_index < vec_len (bd_oper->l2fib_oper)); - } - else - l2fib_index = ~0; - - return l2fib_index; -} - -static_always_inline u32 vjbd_local_cfg_next_id (vjbd_main_t * bdm, - u32 bd_id) -{ - u32 i, end = vec_len (bdm->local_cfg); - u32 next_bd_id = 0; - - if ((bd_id == 0) || vjbd_id_is_valid (bdm, bd_id)) - for (i = 0; i < end; i++) - { - u32 curr_bd_id = bdm->local_cfg[i].bd_id; - if ((curr_bd_id != ~0) && (curr_bd_id > bd_id) && - ((next_bd_id == 0) || (curr_bd_id < next_bd_id))) - next_bd_id = curr_bd_id; - } - - return next_bd_id; -} - -static_always_inline u32 vjbd_sw_if_oper_next_index (vjbd_main_t * bdm, - u32 start, u32 bd_id) -{ - u32 i, end = vec_len (bdm->sw_if_oper); - - if (vjbd_id_is_valid (bdm, bd_id)) - for (i = start; i < end; i++) - if (bdm->sw_if_oper[i].bd_id == bd_id) - return i; - - return ~0; -} - -static_always_inline void -vjbd_oper_l2fib_maybe_sync_from_vpp (vjbd_main_t * bdm) -{ -#ifdef VPPJNI_OPER - vppjni_vpe_api_msg_main_t *ovam = ovam_get_main (); - if ((ovam_time_now (ovam) - bdm->l2fib_oper_last_sync_time) > - BD_OPER_L2FIB_REFRESH_INTERVAL) - { - ovam_l2fib_table_dump (); - bdm->l2fib_oper_last_sync_time = ovam_time_now (ovam); - } -#endif -} - -static_always_inline void vjbd_l2fib_oper_reset (vjbd_main_t * bdm) -{ - vjbd_oper_t * bd_oper; - - vec_foreach (bd_oper, bdm->bd_oper) - { - mhash_init (&bd_oper->l2fib_index_by_mac, sizeof (u32), MAC_ADDRESS_SIZE); - vec_reset_length (bd_oper->l2fib_oper); - } -} - -static_always_inline void vjbd_oper_reset (vjbd_main_t * bdm, u32 bd_id) -{ - u16 bd_index; - u32 si, len; - vjbd_oper_t * bd_oper; - u32 end; - - if (!bdm->bd_oper) - { - ASSERT (vec_len (bdm->sw_if_oper) == 0); - return; - } - - if (bd_id == ~0) - { - bdm->bd_oper_last_sync_all_time = 0.0; - bd_index = 0; - end = vec_len (bdm->bd_oper); - } - else - { - bd_index = vjbd_index_from_id (bdm, bd_id); - end = bd_index + 1; - } - - for (; bd_index < end; bd_index++) - { - bd_oper = vec_elt_at_index (bdm->bd_oper, bd_index); - bd_oper->last_sync_time = 0.0; - - len = vec_len (bdm->sw_if_oper); - for (si = vjbd_sw_if_oper_next_index (bdm, 0, bd_id); - (si != ~0) && (si < len); - si = vjbd_sw_if_oper_next_index (bdm, si + 1, bd_id)) - { - bd_sw_if_oper_t * bd_sw_if_oper; - - bd_sw_if_oper = vec_elt_at_index (bdm->sw_if_oper, si); - bd_sw_if_oper->bd_id = ~0; - } - } -} - -static_always_inline void -vjbd_sw_if_add_del (u32 sw_if_index ,u32 bd_id, u8 bvi, u8 shg, u8 is_add) -{ - vjbd_main_t * bdm = &vjbd_main; - u16 bd_index = vjbd_index_from_id (bdm, bd_id); - vjbd_oper_t * bd_oper = vec_elt_at_index (bdm->bd_oper, bd_index); - bd_sw_if_oper_t * bd_sw_if_oper; - - ASSERT (vjbd_id_is_valid (bdm, bd_id)); - /* DAW-FIXME - ASSERT (ovam_sw_if_index_valid (ovam_get_main (), sw_if_index)); - */ - - vec_validate (bdm->sw_if_oper, sw_if_index); - bd_sw_if_oper = vec_elt_at_index (bdm->sw_if_oper, sw_if_index); - if (is_add) - { - bd_sw_if_oper->bd_id = bd_id; - bd_sw_if_oper->shg = shg; - bd_oper->bvi_sw_if_index = bvi ? sw_if_index : ~0; - } - else - { - bd_sw_if_oper->bd_id = 0; - bd_sw_if_oper->shg = 0; - if (bd_oper->bvi_sw_if_index == sw_if_index) - bd_oper->bvi_sw_if_index = ~0; - } -} - -static_always_inline u32 vjbd_id_sw_if_count (vjbd_main_t * bdm, u32 bd_id) -{ - u32 count = 0, i, end = vec_len (bdm->sw_if_oper); - - if (vjbd_id_is_valid (bdm, bd_id)) - for (count = i = 0; i < end; i++) - if (bdm->sw_if_oper[i].bd_id == bd_id) - count++; - - return count; -} - -static_always_inline u32 vjbd_find_or_add_bd (vjbd_main_t * bdm, u8 * bd_name) -{ - u16 bd_index; - u32 bd_id; - bd_local_cfg_t * bd_local_cfg; - uword mhash_val_bd_id; - - bd_id = vjbd_id_from_name (bdm, bd_name); - if (bd_id != ~0) - return bd_id; - - mhash_val_bd_id = bd_id = ++bdm->next_bd_id; - mhash_set_mem (&bdm->bd_id_by_name, (void *)bd_name, &mhash_val_bd_id, 0); - - bd_index = clib_bitmap_first_clear (bdm->bd_index_bitmap); - vec_validate (bdm->local_cfg, bd_index); - vec_validate (bdm->bd_oper, bd_index); - - ASSERT (vjbd_index_is_free (bdm, bd_index)); - - bd_local_cfg = vec_elt_at_index (bdm->local_cfg, bd_index); - bd_local_cfg->bd_id = bd_id; - vec_validate_init_c_string (bd_local_cfg->bd_name, bd_name, - vec_len (bd_name) - 1); - hash_set (bdm->bd_index_by_id, bd_id, bd_index); - bdm->bd_index_bitmap = clib_bitmap_set (bdm->bd_index_bitmap, - bd_index, 1); - return bd_id; -} - -static_always_inline void vjbd_delete_bd (vjbd_main_t * bdm, u32 bd_id) -{ - u16 bd_index; - bd_local_cfg_t * bd_local_cfg; - - ASSERT (vjbd_id_is_valid (bdm, bd_id)); - - // bd must not have any members before deleting - ASSERT (!vjbd_id_sw_if_count (bdm, bd_id)); - - bd_index = vjbd_index_from_id (bdm, bd_id); - bd_local_cfg = vec_elt_at_index (bdm->local_cfg, bd_index); - vjbd_oper_reset (bdm, bd_id); - - mhash_unset (&bdm->bd_id_by_name, vjbd_name_from_id (bdm, bd_id), 0); - bdm->bd_index_bitmap = clib_bitmap_set (bdm->bd_index_bitmap, - bd_index, 0); - hash_unset (bdm->bd_index_by_id, bd_id); - bd_local_cfg->bd_id = ~0; - vec_validate_init_c_string (bd_local_cfg->bd_name, "", 0); - - if (clib_bitmap_is_zero (bdm->bd_index_bitmap)) - { - vec_reset_length (bdm->local_cfg); - vec_reset_length (bdm->bd_oper); - } - - /* Force a resync of all bd_oper data. */ - bdm->bd_oper_last_sync_all_time = 0.0; - vjbd_oper_maybe_sync_from_vpp (bdm, ~0); -} - -#endif /* __included_vppjni_vpp_bridge_domain_h__ */ diff --git a/vpp-japi/japi/vppjni_env.c b/vpp-japi/japi/vppjni_env.c deleted file mode 100644 index 1c4ea6eb..00000000 --- a/vpp-japi/japi/vppjni_env.c +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright (c) 2016 Cisco and/or its affiliates. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#include - -#include "vppjni_env.h" - -// Head of the class registration list. -static vppjni_class_t *class_head; -// Head of the class registration list. -static vppjni_field_t *field_head; - -void vppjni_register_class(vppjni_class_t *ptr) -{ - vppjni_class_t **where = &class_head; - while (*where != NULL) { - where = &((*where)->next); - } - *where = ptr; -} - -void vppjni_register_field(vppjni_field_t *ptr) { - vppjni_field_t **where = &field_head; - while (*where != NULL) { - where = &((*where)->next); - } - *where = ptr; -} - -jobject vppjni_new_object(JNIEnv *env, const vppjni_class_t *ptr, va_list ap) { - jobject obj = (*env)->NewObjectV(env, ptr->jclass, ptr->jinit, ap); - if ((*env)->ExceptionCheck(env)) { - (*env)->ExceptionDescribe(env); - return NULL; - } - - return obj; -} - -int vppjni_init(JNIEnv *env) -{ - vppjni_class_t *cwlk; - vppjni_field_t *fwlk; - - for (cwlk = class_head; cwlk != NULL; cwlk = cwlk->next) { - jclass cls; - jmethodID method; - - cls = (*env)->FindClass(env, cwlk->fqcn); - if ((*env)->ExceptionCheck(env)) { - (*env)->ExceptionDescribe(env); - vppjni_uninit(env); - return JNI_ERR; - } - - method = (*env)->GetMethodID(env, cls, "", cwlk->init_sig); - if ((*env)->ExceptionCheck(env)) { - (*env)->ExceptionDescribe(env); - vppjni_uninit(env); - return JNI_ERR; - } - - cwlk->jclass = (*env)->NewGlobalRef(env, cls); - if (cwlk->jclass == NULL) { - vppjni_uninit(env); - return JNI_ERR; - } - cwlk->jinit = method; - } - - for (fwlk = field_head; fwlk != NULL; fwlk = fwlk->next) { - fwlk->jfield = (*env)->GetFieldID(env, fwlk->clsref->jclass, fwlk->name, fwlk->type); - if ((*env)->ExceptionCheck(env)) { - (*env)->ExceptionDescribe(env); - vppjni_uninit(env); - return JNI_ERR; - } - } - - return 0; -} - -void vppjni_uninit(JNIEnv *env) { - vppjni_class_t *cwlk; - vppjni_field_t *fwlk; - - for (fwlk = field_head; fwlk != NULL; fwlk = fwlk->next) { - fwlk->jfield = NULL; - } - - for (cwlk = class_head; cwlk != NULL; cwlk = cwlk->next) { - if (cwlk->jclass != NULL ) { - (*env)->DeleteGlobalRef(env, cwlk->jclass); - } - - cwlk->jclass = NULL; - cwlk->jinit = NULL; - } -} - diff --git a/vpp-japi/japi/vppjni_env.h b/vpp-japi/japi/vppjni_env.h deleted file mode 100644 index 44029c2c..00000000 --- a/vpp-japi/japi/vppjni_env.h +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Copyright (c) 2016 Cisco and/or its affiliates. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * Utilities for accessing Java classes/method/fields in an efficient - * manner. - */ - -/* - * A potentially-uninitialized reference to a Java class - */ -typedef struct vppjni_class { - // Fully-Qualified Class Name - const char *fqcn; - // Constructor signature - const char *init_sig; - // Global reference to class handle - jclass jclass; - // Constructor method handle - jmethodID jinit; - // Next item in linked list - struct vppjni_class *next; -} vppjni_class_t; - -typedef struct jenv_field { - // Field name - const char *name; - // Field type - const char *type; - // Defining class reference - const vppjni_class_t *clsref; - // Field handle - jfieldID jfield; - // Next item in linked list - struct jenv_field *next; -} vppjni_field_t; - -#define VPPJNI_CLASS_SYMBOL(name) vppjni_class_##name -#define VPPJNI_CLASS_INIT(name) vppjni_class_##name##_init -#define BIND_JAPI_CLASS(name, sig) \ - static vppjni_class_t VPPJNI_CLASS_SYMBOL(name); \ - static void VPPJNI_CLASS_INIT(name)(void) __attribute__((__constructor__)); \ - static void VPPJNI_CLASS_INIT(name)() \ - { \ - VPPJNI_CLASS_SYMBOL(name).fqcn = "org/openvpp/vppjapi/" #name; \ - VPPJNI_CLASS_SYMBOL(name).init_sig = sig; \ - vppjni_register_class(&VPPJNI_CLASS_SYMBOL(name)); \ - } \ - static __attribute__((unused)) jobject name##Array(JNIEnv *env, jsize length) \ - { \ - return (*env)->NewObjectArray(env, length, VPPJNI_CLASS_SYMBOL(name).jclass, NULL); \ - } \ - static jobject name##Object(JNIEnv *env, ...) \ - { \ - va_list ap; \ - va_start(ap, env); \ - jobject obj = vppjni_new_object(env, &VPPJNI_CLASS_SYMBOL(name), ap); \ - va_end(ap); \ - return obj; \ - } - -#define VPPJNI_FIELD_SYMBOL(cls, name) vppjni_field_##cls##_##name -#define VPPJNI_FIELD_INIT(cls, name) vppjni_field_##cls##_##name##_init -#define BIND_JAPI_FIELD(cls, field, sig) \ - static vppjni_field_t VPPJNI_FIELD_SYMBOL(cls, field); \ - static void VPPJNI_FIELD_INIT(cls, field)(void) __attribute__((__constructor__)); \ - static void VPPJNI_FIELD_INIT(cls, field)() \ - { \ - VPPJNI_FIELD_SYMBOL(cls, field).name = #field; \ - VPPJNI_FIELD_SYMBOL(cls, field).type = sig; \ - VPPJNI_FIELD_SYMBOL(cls, field).clsref = &VPPJNI_CLASS_SYMBOL(cls); \ - vppjni_register_field(&VPPJNI_FIELD_SYMBOL(cls, field)); \ - } -#define BIND_JAPI_BOOL_FIELD(cls, field) \ - BIND_JAPI_FIELD(cls, field, "Z"); \ - static void set_##cls##_##field(JNIEnv *env, jobject obj, jboolean value) \ - { \ - (*env)->SetBooleanField(env, obj, VPPJNI_FIELD_SYMBOL(cls, field).jfield, value); \ - } -#define BIND_JAPI_BYTE_FIELD(cls, field) \ - BIND_JAPI_FIELD(cls, field, "B"); \ - static void set_##cls##_##field(JNIEnv *env, jobject obj, jbyte value) \ - { \ - (*env)->SetByteField(env, obj, VPPJNI_FIELD_SYMBOL(cls, field).jfield, value); \ - } -#define BIND_JAPI_INT_FIELD(cls, field) \ - BIND_JAPI_FIELD(cls, field, "I"); \ - static void set_##cls##_##field(JNIEnv *env, jobject obj, jint value) \ - { \ - (*env)->SetIntField(env, obj, VPPJNI_FIELD_SYMBOL(cls, field).jfield, value); \ - } -#define BIND_JAPI_OBJ_FIELD(cls, field, sig) \ - BIND_JAPI_FIELD(cls, field, sig); \ - static void set_##cls##_##field(JNIEnv *env, jobject obj, jobject value) \ - { \ - (*env)->SetObjectField(env, obj, VPPJNI_FIELD_SYMBOL(cls, field).jfield, value); \ - } -#define BIND_JAPI_STRING_FIELD(cls, field) \ - BIND_JAPI_OBJ_FIELD(cls, field, "Ljava/lang/String;") - -jobject vppjni_new_object(JNIEnv *env, const vppjni_class_t *ptr, va_list ap) __attribute__ ((visibility ("hidden"))); -void vppjni_register_class(vppjni_class_t *ptr) __attribute__ ((visibility ("hidden"))); -void vppjni_register_field(vppjni_field_t *ptr) __attribute__ ((visibility ("hidden"))); -int vppjni_init(JNIEnv *env) __attribute__ ((visibility ("hidden"))); -void vppjni_uninit(JNIEnv *env) __attribute__ ((visibility ("hidden"))); - diff --git a/vpp-japi/libtool b/vpp-japi/libtool deleted file mode 100755 index 5f65406b..00000000 --- a/vpp-japi/libtool +++ /dev/null @@ -1,10083 +0,0 @@ -#! /bin/sh - -# libtool - Provide generalized library-building support services. -# Generated automatically by config.status (vpp-japi) 0.1 -# Libtool was configured on host tf-ucs-3: -# 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, 2009, 2010, 2011 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="" - -# ### BEGIN LIBTOOL CONFIG - -# Which release of libtool.m4 was used? -macro_version=2.4.2 -macro_revision=1.3337 - -# Whether or not to build shared libraries. -build_libtool_libs=yes - -# Whether or not to build static libraries. -build_old_libs=yes - -# What type of objects to build. -pic_mode=default - -# Whether or not to optimize for fast installation. -fast_install=yes - -# Shell to use when invoking shell scripts. -SHELL="/bin/sh" - -# An echo program that protects backslashes. -ECHO="printf %s\\n" - -# The PATH separator for the build system. -PATH_SEPARATOR=":" - -# The host system. -host_alias= -host=x86_64-unknown-linux-gnu -host_os=linux-gnu - -# The build system. -build_alias= -build=x86_64-unknown-linux-gnu -build_os=linux-gnu - -# A sed program that does not truncate output. -SED="/bin/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="/bin/grep" - -# An ERE matcher. -EGREP="/bin/grep -E" - -# A literal string matcher. -FGREP="/bin/grep -F" - -# A BSD- or MS-compatible name lister. -NM="/usr/bin/nm -B" - -# Whether we need soft or hard links. -LN_S="ln -s" - -# What is the maximum length of a command? -max_cmd_len=1572864 - -# Object file suffix (normally "o"). -objext=o - -# Executable file suffix (normally ""). -exeext= - -# whether the shell understands "unset". -lt_unset=unset - -# turn spaces into newlines. -SP2NL="tr \\040 \\012" - -# turn newlines into spaces. -NL2SP="tr \\015\\012 \\040\\040" - -# convert $build file names to $host format. -to_host_file_cmd=func_convert_file_noop - -# convert $build files to toolchain format. -to_tool_file_cmd=func_convert_file_noop - -# An object symbol dumper. -OBJDUMP="objdump" - -# Method to check whether dependent libraries are shared objects. -deplibs_check_method="pass_all" - -# Command to use when deplibs_check_method = "file_magic". -file_magic_cmd="\$MAGIC_CMD" - -# How to find potential files when deplibs_check_method = "file_magic". -file_magic_glob="" - -# Find potential files using nocaseglob when deplibs_check_method = "file_magic". -want_nocaseglob="no" - -# DLL creation program. -DLLTOOL="false" - -# Command to associate shared and link libraries. -sharedlib_from_linklib_cmd="printf %s\\n" - -# The archiver. -AR="ar" - -# Flags to create an archive. -AR_FLAGS="cru" - -# How to feed a file listing to the archiver. -archiver_list_spec="@" - -# A symbol stripping program. -STRIP="strip" - -# Commands used to install an old-style archive. -RANLIB="ranlib" -old_postinstall_cmds="chmod 644 \$oldlib~\$RANLIB \$tool_oldlib" -old_postuninstall_cmds="" - -# Whether to use a lock for old archive extraction. -lock_old_archive_extraction=no - -# A C compiler. -LTCC="gcc" - -# LTCC compiler flags. -LTCFLAGS="-g -O2" - -# Take the output of nm and produce a listing of raw symbols and C names. -global_symbol_pipe="sed -n -e 's/^.*[ ]\\([ABCDGIRSTW][ABCDGIRSTW]*\\)[ ][ ]*\\([_A-Za-z][_A-Za-z0-9]*\\)\$/\\1 \\2 \\2/p' | sed '/ __gnu_lto/d'" - -# Transform the output of nm in a proper C declaration. -global_symbol_to_cdecl="sed -n -e 's/^T .* \\(.*\\)\$/extern int \\1();/p' -e 's/^[ABCDGIRSTW]* .* \\(.*\\)\$/extern char \\1;/p'" - -# Transform the output of nm in a C name address pair. -global_symbol_to_c_name_address="sed -n -e 's/^: \\([^ ]*\\)[ ]*\$/ {\\\"\\1\\\", (void *) 0},/p' -e 's/^[ABCDGIRSTW]* \\([^ ]*\\) \\([^ ]*\\)\$/ {\"\\2\", (void *) \\&\\2},/p'" - -# Transform the output of nm in a C name address pair when lib prefix is needed. -global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \\([^ ]*\\)[ ]*\$/ {\\\"\\1\\\", (void *) 0},/p' -e 's/^[ABCDGIRSTW]* \\([^ ]*\\) \\(lib[^ ]*\\)\$/ {\"\\2\", (void *) \\&\\2},/p' -e 's/^[ABCDGIRSTW]* \\([^ ]*\\) \\([^ ]*\\)\$/ {\"lib\\2\", (void *) \\&\\2},/p'" - -# Specify filename containing input files for $NM. -nm_file_list_spec="@" - -# The root where to search for dependent libraries,and in which our libraries should be installed. -lt_sysroot= - -# The name of the directory that contains temporary libtool files. -objdir=.libs - -# Used to examine libraries when file_magic_cmd begins with "file". -MAGIC_CMD=file - -# Must we lock files when doing compilation? -need_locks="no" - -# Manifest tool. -MANIFEST_TOOL=":" - -# Tool to manipulate archived DWARF debug symbol files on Mac OS X. -DSYMUTIL="" - -# Tool to change global to local symbols on Mac OS X. -NMEDIT="" - -# Tool to manipulate fat objects and archives on Mac OS X. -LIPO="" - -# ldd/readelf like tool for Mach-O binaries on Mac OS X. -OTOOL="" - -# ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4. -OTOOL64="" - -# Old archive suffix (normally "a"). -libext=a - -# Shared library suffix (normally ".so"). -shrext_cmds=".so" - -# The commands to extract the exported symbol list from a shared archive. -extract_expsyms_cmds="" - -# Variables whose values should be saved in libtool wrapper scripts and -# restored at link time. -variables_saved_for_relink="PATH LD_LIBRARY_PATH LD_RUN_PATH GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" - -# Do we need the "lib" prefix for modules? -need_lib_prefix=no - -# Do we need a version for libraries? -need_version=no - -# Library versioning type. -version_type=linux - -# Shared library runtime path variable. -runpath_var=LD_RUN_PATH - -# Shared library path variable. -shlibpath_var=LD_LIBRARY_PATH - -# Is shlibpath searched before the hard-coded library search path? -shlibpath_overrides_runpath=no - -# Format of library name prefix. -libname_spec="lib\$name" - -# 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="\${libname}\${release}\${shared_ext}\$versuffix \${libname}\${release}\${shared_ext}\$major \$libname\${shared_ext}" - -# The coded name of the library, if different from the real name. -soname_spec="\${libname}\${release}\${shared_ext}\$major" - -# Permission mode override for installation of shared libraries. -install_override_mode="" - -# Command to use after installation of a shared archive. -postinstall_cmds="" - -# Command to use after uninstallation of a shared archive. -postuninstall_cmds="" - -# Commands used to finish a libtool library installation in a directory. -finish_cmds="PATH=\\\"\\\$PATH:/sbin\\\" ldconfig -n \$libdir" - -# As "finish_cmds", except a single script fragment to be evaled but -# not shown. -finish_eval="" - -# Whether we should hardcode library paths into libraries. -hardcode_into_libs=yes - -# Compile-time system search path for libraries. -sys_lib_search_path_spec="/usr/lib/gcc/x86_64-linux-gnu/4.8 /usr/lib/x86_64-linux-gnu /usr/lib /lib/x86_64-linux-gnu /lib " - -# Run-time system search path for libraries. -sys_lib_dlsearch_path_spec="/lib /usr/lib /usr/lib/x86_64-linux-gnu/libfakeroot /usr/local/lib /lib/x86_64-linux-gnu /usr/lib/x86_64-linux-gnu /usr/lib/x86_64-linux-gnu/mesa-egl /usr/lib/nvidia-346 /usr/lib32/nvidia-346 /usr/lib/x86_64-linux-gnu/mir/clientplatform/mesa /lib32 /usr/lib32 " - -# Whether dlopen is supported. -dlopen_support=unknown - -# Whether dlopen of programs is supported. -dlopen_self=unknown - -# Whether dlopen of statically linked programs is supported. -dlopen_self_static=unknown - -# Commands to strip libraries. -old_striplib="strip --strip-debug" -striplib="strip --strip-unneeded" - - -# The linker used to build libraries. -LD="/usr/bin/ld -m elf_x86_64" - -# How to create reloadable object files. -reload_flag=" -r" -reload_cmds="\$LD\$reload_flag -o \$output\$reload_objs" - -# Commands used to build an old-style archive. -old_archive_cmds="\$AR \$AR_FLAGS \$oldlib\$oldobjs~\$RANLIB \$tool_oldlib" - -# A language specific compiler. -CC="gcc" - -# Is the compiler the GNU compiler? -with_gcc=yes - -# Compiler flag to turn off builtin functions. -no_builtin_flag=" -fno-builtin" - -# Additional compiler flags for building library objects. -pic_flag=" -fPIC -DPIC" - -# How to pass a linker flag through the compiler. -wl="-Wl," - -# Compiler flag to prevent dynamic linking. -link_static_flag="-static" - -# Does compiler simultaneously support -c and -o options? -compiler_c_o="yes" - -# Whether or not to add -lc for building shared libraries. -build_libtool_need_lc=no - -# Whether or not to disallow shared libs when runtime libs are static. -allow_libtool_libs_with_static_runtimes=no - -# Compiler flag to allow reflexive dlopens. -export_dynamic_flag_spec="\${wl}--export-dynamic" - -# Compiler flag to generate shared objects directly from archives. -whole_archive_flag_spec="\${wl}--whole-archive\$convenience \${wl}--no-whole-archive" - -# Whether the compiler copes with passing no objects directly. -compiler_needs_object="no" - -# Create an old-style archive from a shared archive. -old_archive_from_new_cmds="" - -# Create a temporary old-style archive to link instead of a shared archive. -old_archive_from_expsyms_cmds="" - -# Commands used to build a shared archive. -archive_cmds="\$CC -shared \$pic_flag \$libobjs \$deplibs \$compiler_flags \${wl}-soname \$wl\$soname -o \$lib" -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 -shared \$pic_flag \$libobjs \$deplibs \$compiler_flags \${wl}-soname \$wl\$soname \${wl}-version-script \${wl}\$output_objdir/\$libname.ver -o \$lib" - -# Commands used to build a loadable module if different from building -# a shared archive. -module_cmds="" -module_expsym_cmds="" - -# Whether we are building with GNU ld or not. -with_gnu_ld="yes" - -# Flag that allows shared libraries with undefined symbols to be built. -allow_undefined_flag="" - -# Flag that enforces no undefined symbols. -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="\${wl}-rpath \${wl}\$libdir" - -# Whether we need a single "-rpath" flag with a separated argument. -hardcode_libdir_separator="" - -# Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes -# DIR into the resulting binary. -hardcode_direct=no - -# 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=no - -# Set to "yes" if using the -LDIR flag during linking hardcodes DIR -# into the resulting binary. -hardcode_minus_L=no - -# Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR -# into the resulting binary. -hardcode_shlibpath_var=unsupported - -# 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=no - -# Set to yes if linker adds runtime paths of dependent libraries -# to runtime path list. -inherit_rpath=no - -# Whether libtool must link a program against all its dependency libraries. -link_all_deplibs=no - -# Set to "yes" if exported symbols are required. -always_export_symbols=no - -# The commands to list exported symbols. -export_symbols_cmds="\$NM \$libobjs \$convenience | \$global_symbol_pipe | \$SED 's/.* //' | sort | uniq > \$export_symbols" - -# Symbols that should not be listed in the preloaded symbols. -exclude_expsyms="_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*" - -# Symbols that must always be exported. -include_expsyms="" - -# Commands necessary for linking programs (against libraries) with templates. -prelink_cmds="" - -# Commands necessary for finishing linking programs. -postlink_cmds="" - -# Specify filename containing input files. -file_list_spec="" - -# How to hardcode a shared library path into an executable. -hardcode_action=immediate - -# ### END LIBTOOL CONFIG - - -# libtool (GNU libtool) 2.4.2 -# Written by Gordon Matzigkeit , 1996 - -# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, -# 2007, 2008, 2009, 2010, 2011 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 -# --no-quiet, --no-silent -# print informational messages (default) -# --no-warn don't display warning messages -# --tag=TAG use configuration variables from tag TAG -# -v, --verbose print more informational messages than default -# --no-verbose don't print the extra informational messages -# --version print version information -# -h, --help, --help-all print short, long, or detailed 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. When passed as first option, -# `--mode=MODE' may be abbreviated as `MODE' or a unique abbreviation of that. -# 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.4.2 Debian-2.4.2-1.7ubuntu1 -# automake: $automake_version -# autoconf: $autoconf_version -# -# Report bugs to . -# GNU libtool home page: . -# General help using GNU software: . - -PROGRAM=libtool -PACKAGE=libtool -VERSION="2.4.2 Debian-2.4.2-1.7ubuntu1" -TIMESTAMP="" -package_revision=1.3337 - -# 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 - -# A function that is used when there is no print builtin or printf. -func_fallback_echo () -{ - eval 'cat <<_LTECHO_EOF -$1 -_LTECHO_EOF' -} - -# NLS nuisances: We save the old values to restore during execute mode. -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 -LC_ALL=C -LANGUAGE=C -export LANGUAGE LC_ALL - -$lt_unset CDPATH - - -# 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" - - - -: ${CP="cp -f"} -test "${ECHO+set}" = set || ECHO=${as_echo-'printf %s\n'} -: ${MAKE="make"} -: ${MKDIR="mkdir"} -: ${MV="mv -f"} -: ${RM="rm -f"} -: ${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 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 -} # Extended-shell func_dirname implementation - - -# func_basename file -func_basename () -{ - func_basename_result="${1##*/}" -} # Extended-shell func_basename implementation - - -# 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##*/}" -} # Extended-shell func_dirname_and_basename implementation - - -# 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 () -{ - # 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}"} -} # Extended-shell func_stripname implementation - - -# These SED scripts presuppose an absolute path with a trailing slash. -pathcar='s,^/\([^/]*\).*$,\1,' -pathcdr='s,^/[^/]*,,' -removedotparts=':dotsl - s@/\./@/@g - t dotsl - s,/\.$,/,' -collapseslashes='s@/\{1,\}@/@g' -finalslash='s,/*$,/,' - -# func_normal_abspath PATH -# Remove doubled-up and trailing slashes, "." path components, -# and cancel out any ".." path components in PATH after making -# it an absolute path. -# value returned in "$func_normal_abspath_result" -func_normal_abspath () -{ - # Start from root dir and reassemble the path. - func_normal_abspath_result= - func_normal_abspath_tpath=$1 - func_normal_abspath_altnamespace= - case $func_normal_abspath_tpath in - "") - # Empty path, that just means $cwd. - func_stripname '' '/' "`pwd`" - func_normal_abspath_result=$func_stripname_result - return - ;; - # The next three entries are used to spot a run of precisely - # two leading slashes without using negated character classes; - # we take advantage of case's first-match behaviour. - ///*) - # Unusual form of absolute path, do nothing. - ;; - //*) - # Not necessarily an ordinary path; POSIX reserves leading '//' - # and for example Cygwin uses it to access remote file shares - # over CIFS/SMB, so we conserve a leading double slash if found. - func_normal_abspath_altnamespace=/ - ;; - /*) - # Absolute path, do nothing. - ;; - *) - # Relative path, prepend $cwd. - func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath - ;; - esac - # Cancel out all the simple stuff to save iterations. We also want - # the path to end with a slash for ease of parsing, so make sure - # there is one (and only one) here. - func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ - -e "$removedotparts" -e "$collapseslashes" -e "$finalslash"` - while :; do - # Processed it all yet? - if test "$func_normal_abspath_tpath" = / ; then - # If we ascended to the root using ".." the result may be empty now. - if test -z "$func_normal_abspath_result" ; then - func_normal_abspath_result=/ - fi - break - fi - func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \ - -e "$pathcar"` - func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ - -e "$pathcdr"` - # Figure out what to do with it - case $func_normal_abspath_tcomponent in - "") - # Trailing empty path component, ignore it. - ;; - ..) - # Parent dir; strip last assembled component from result. - func_dirname "$func_normal_abspath_result" - func_normal_abspath_result=$func_dirname_result - ;; - *) - # Actual path component, append it. - func_normal_abspath_result=$func_normal_abspath_result/$func_normal_abspath_tcomponent - ;; - esac - done - # Restore leading double-slash if one was found on entry. - func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result -} - -# func_relative_path SRCDIR DSTDIR -# generates a relative path from SRCDIR to DSTDIR, with a trailing -# slash if non-empty, suitable for immediately appending a filename -# without needing to append a separator. -# value returned in "$func_relative_path_result" -func_relative_path () -{ - func_relative_path_result= - func_normal_abspath "$1" - func_relative_path_tlibdir=$func_normal_abspath_result - func_normal_abspath "$2" - func_relative_path_tbindir=$func_normal_abspath_result - - # Ascend the tree starting from libdir - while :; do - # check if we have found a prefix of bindir - case $func_relative_path_tbindir in - $func_relative_path_tlibdir) - # found an exact match - func_relative_path_tcancelled= - break - ;; - $func_relative_path_tlibdir*) - # found a matching prefix - func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir" - func_relative_path_tcancelled=$func_stripname_result - if test -z "$func_relative_path_result"; then - func_relative_path_result=. - fi - break - ;; - *) - func_dirname $func_relative_path_tlibdir - func_relative_path_tlibdir=${func_dirname_result} - if test "x$func_relative_path_tlibdir" = x ; then - # Have to descend all the way to the root! - func_relative_path_result=../$func_relative_path_result - func_relative_path_tcancelled=$func_relative_path_tbindir - break - fi - func_relative_path_result=../$func_relative_path_result - ;; - esac - done - - # Now calculate path; take care to avoid doubling-up slashes. - func_stripname '' '/' "$func_relative_path_result" - func_relative_path_result=$func_stripname_result - func_stripname '/' '/' "$func_relative_path_tcancelled" - if test "x$func_stripname_result" != x ; then - func_relative_path_result=${func_relative_path_result}/${func_stripname_result} - fi - - # Normalisation. If bindir is libdir, return empty string, - # else relative path ending with a slash; either way, target - # file name can be directly appended. - if test ! -z "$func_relative_path_result"; then - func_stripname './' '' "$func_relative_path_result/" - func_relative_path_result=$func_stripname_result - fi -} - -# The name of this program: -func_dirname_and_basename "$progpath" -progname=$func_basename_result - -# 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=${PATH_SEPARATOR-:} - 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' - -# Sed substitution that turns a string into a regex matching for the -# string literally. -sed_make_literal_regex='s,[].[^$\\*\/],\\&,g' - -# Sed substitution that converts a w32 file name or path -# which contains forward slashes, into one that contains -# (escaped) backslashes. A very naive implementation. -lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|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: ${opt_mode+$opt_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_echo_all arg... -# Invoke $ECHO with all args, space-separated. -func_echo_all () -{ - $ECHO "$*" -} - -# func_error arg... -# Echo program name prefixed message to standard error. -func_error () -{ - $ECHO "$progname: ${opt_mode+$opt_mode: }"${1+"$@"} 1>&2 -} - -# func_warning arg... -# Echo program name prefixed warning message to standard error. -func_warning () -{ - $opt_warning && $ECHO "$progname: ${opt_mode+$opt_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 "$my_directory_path" | $SED -e "$dirname"` - done - my_dir_list=`$ECHO "$my_dir_list" | $SED '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 "$my_tmpdir" -} - - -# 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 "$1" | $SED "$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 "$1" | $SED \ - -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_tr_sh -# Turn $1 into a string suitable for a shell variable name. -# Result is stored in $func_tr_sh_result. All characters -# not in the set a-zA-Z0-9_ are replaced with '_'. Further, -# if $1 begins with a digit, a '_' is prepended as well. -func_tr_sh () -{ - case $1 in - [0-9]* | *[!a-zA-Z0-9_]*) - func_tr_sh_result=`$ECHO "$1" | $SED 's/^\([0-9]\)/_\1/; s/[^a-zA-Z0-9_]/_/g'` - ;; - * ) - func_tr_sh_result=$1 - ;; - esac -} - - -# func_version -# Echo version message to standard output and exit. -func_version () -{ - $opt_debug - - $SED -n '/(C)/!b go - :more - /\./!{ - N - s/\n# / / - b more - } - :go - /^# '$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 () -{ - $opt_debug - - $SED -n '/^# Usage:/,/^# *.*--help/ { - s/^# // - s/^# *$// - s/\$progname/'$progname'/ - p - }' < "$progpath" - echo - $ECHO "run \`$progname --help | more' for full usage" - exit $? -} - -# func_help [NOEXIT] -# Echo long help message to standard output and exit, -# unless 'noexit' is passed as argument. -func_help () -{ - $opt_debug - - $SED -n '/^# Usage:/,/# Report bugs to/ { - :print - 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-automake} --version) 2>/dev/null |$SED 1q`"'/ - s/\$autoconf_version/'"`(${AUTOCONF-autoconf} --version) 2>/dev/null |$SED 1q`"'/ - p - d - } - /^# .* home page:/b print - /^# General help using/b print - ' < "$progpath" - ret=$? - if test -z "$1"; then - exit $ret - fi -} - -# func_missing_arg argname -# Echo program name prefixed message to standard error and set global -# exit_cmd. -func_missing_arg () -{ - $opt_debug - - func_error "missing argument for $1." - exit_cmd=exit -} - - -# func_split_short_opt shortopt -# Set func_split_short_opt_name and func_split_short_opt_arg shell -# variables after splitting SHORTOPT after the 2nd character. -func_split_short_opt () -{ - func_split_short_opt_arg=${1#??} - func_split_short_opt_name=${1%"$func_split_short_opt_arg"} -} # Extended-shell func_split_short_opt implementation - - -# func_split_long_opt longopt -# Set func_split_long_opt_name and func_split_long_opt_arg shell -# variables after splitting LONGOPT at the `=' sign. -func_split_long_opt () -{ - func_split_long_opt_name=${1%%=*} - func_split_long_opt_arg=${1#*=} -} # Extended-shell func_split_long_opt implementation - -exit_cmd=: - - - - - -magic="%%%MAGIC variable%%%" -magic_exe="%%%MAGIC EXE variable%%%" - -# Global variables. -nonopt= -preserve_args= -lo2o="s/\\.lo\$/.${objext}/" -o2lo="s/\\.${objext}\$/.lo/" -extracted_archives= -extracted_serial=0 - -# If this variable is set in any of the actions, the command in it -# will be execed at the end. This prevents here-documents from being -# left over by shells. -exec_cmd= - -# func_append var value -# Append VALUE to the end of shell variable VAR. -func_append () -{ - eval "${1}+=\${2}" -} # Extended-shell func_append implementation - -# func_append_quoted var value -# Quote VALUE and append to the end of shell variable VAR, separated -# by a space. -func_append_quoted () -{ - func_quote_for_eval "${2}" - eval "${1}+=\\ \$func_quote_for_eval_result" -} # Extended-shell func_append_quoted implementation - - -# func_arith arithmetic-term... -func_arith () -{ - func_arith_result=$(( $* )) -} # Extended-shell func_arith implementation - - -# func_len string -# STRING may not start with a hyphen. -func_len () -{ - func_len_result=${#1} -} # Extended-shell func_len implementation - - -# func_lo2o object -func_lo2o () -{ - case ${1} in - *.lo) func_lo2o_result=${1%.lo}.${objext} ;; - *) func_lo2o_result=${1} ;; - esac -} # Extended-shell func_lo2o implementation - - -# func_xform libobj-or-source -func_xform () -{ - func_xform_result=${1%.*}.lo -} # Extended-shell func_xform implementation - - -# func_fatal_configuration arg... -# Echo program name prefixed message to standard error, followed by -# a configuration failure hint, and exit. -func_fatal_configuration () -{ - func_error ${1+"$@"} - func_error "See the $PACKAGE documentation for more information." - func_fatal_error "Fatal configuration error." -} - - -# func_config -# Display the configuration for all the tags in this script. -func_config () -{ - re_begincf='^# ### BEGIN LIBTOOL' - re_endcf='^# ### END LIBTOOL' - - # Default configuration. - $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath" - - # Now print the configurations for the tags. - for tagname in $taglist; do - $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath" - done - - exit $? -} - -# func_features -# Display the features supported by this script. -func_features () -{ - echo "host: $host" - if test "$build_libtool_libs" = yes; then - echo "enable shared libraries" - else - echo "disable shared libraries" - fi - if test "$build_old_libs" = yes; then - echo "enable static libraries" - else - echo "disable static libraries" - fi - - exit $? -} - -# func_enable_tag tagname -# Verify that TAGNAME is valid, and either flag an error and exit, or -# enable the TAGNAME tag. We also add TAGNAME to the global $taglist -# variable here. -func_enable_tag () -{ - # Global variable: - tagname="$1" - - re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" - re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" - sed_extractcf="/$re_begincf/,/$re_endcf/p" - - # Validate tagname. - case $tagname in - *[!-_A-Za-z0-9,/]*) - func_fatal_error "invalid tag name: $tagname" - ;; - esac - - # Don't test for the "default" C tag, as we know it's - # there but not specially marked. - case $tagname in - CC) ;; - *) - if $GREP "$re_begincf" "$progpath" >/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 -} - -# 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 -} - - -# 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 - - - -# Option defaults: -opt_debug=: -opt_dry_run=false -opt_config=false -opt_preserve_dup_deps=false -opt_features=false -opt_finish=false -opt_help=false -opt_help_all=false -opt_silent=: -opt_warning=: -opt_verbose=: -opt_silent=false -opt_verbose=false - - -# Parse options once, thoroughly. This comes as soon as possible in the -# script to make things like `--version' happen as quickly as we can. -{ - # this just eases exit handling - while test $# -gt 0; do - opt="$1" - shift - case $opt in - --debug|-x) opt_debug='set -x' - func_echo "enabling shell trace mode" - $opt_debug - ;; - --dry-run|--dryrun|-n) - opt_dry_run=: - ;; - --config) - opt_config=: -func_config - ;; - --dlopen|-dlopen) - optarg="$1" - opt_dlopen="${opt_dlopen+$opt_dlopen -}$optarg" - shift - ;; - --preserve-dup-deps) - opt_preserve_dup_deps=: - ;; - --features) - opt_features=: -func_features - ;; - --finish) - opt_finish=: -set dummy --mode finish ${1+"$@"}; shift - ;; - --help) - opt_help=: - ;; - --help-all) - opt_help_all=: -opt_help=': help-all' - ;; - --mode) - test $# = 0 && func_missing_arg $opt && break - optarg="$1" - opt_mode="$optarg" -case $optarg 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 - shift - ;; - --no-silent|--no-quiet) - opt_silent=false -preserve_args+=" $opt" - ;; - --no-warning|--no-warn) - opt_warning=false -preserve_args+=" $opt" - ;; - --no-verbose) - opt_verbose=false -preserve_args+=" $opt" - ;; - --silent|--quiet) - opt_silent=: -preserve_args+=" $opt" - opt_verbose=false - ;; - --verbose|-v) - opt_verbose=: -preserve_args+=" $opt" -opt_silent=false - ;; - --tag) - test $# = 0 && func_missing_arg $opt && break - optarg="$1" - opt_tag="$optarg" -preserve_args+=" $opt $optarg" -func_enable_tag "$optarg" - shift - ;; - - -\?|-h) func_usage ;; - --help) func_help ;; - --version) func_version ;; - - # Separate optargs to long options: - --*=*) - func_split_long_opt "$opt" - set dummy "$func_split_long_opt_name" "$func_split_long_opt_arg" ${1+"$@"} - shift - ;; - - # Separate non-argument short options: - -\?*|-h*|-n*|-v*) - func_split_short_opt "$opt" - set dummy "$func_split_short_opt_name" "-$func_split_short_opt_arg" ${1+"$@"} - shift - ;; - - --) break ;; - -*) func_fatal_help "unrecognized option \`$opt'" ;; - *) set dummy "$opt" ${1+"$@"}; shift; break ;; - esac - done - - # Validate options: - - # save first non-option argument - if test "$#" -gt 0; then - nonopt="$opt" - shift - fi - - # preserve --debug - test "$opt_debug" = : || preserve_args+=" --debug" - - 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_preserve_dup_deps - ;; - esac - - $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 - - # Darwin sucks - eval std_shrext=\"$shrext_cmds\" - - # Only execute mode is allowed to have -dlopen flags. - if test -n "$opt_dlopen" && test "$opt_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=$opt_mode' for more information." - } - - - # Bail if the options were screwed - $exit_cmd $EXIT_FAILURE -} - - - - -## ----------- ## -## Main. ## -## ----------- ## - -# 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_dirname_and_basename "$1" "" "." - func_stripname '' '.exe' "$func_basename_result" - func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper" -} - -# 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_resolve_sysroot PATH -# Replace a leading = in PATH with a sysroot. Store the result into -# func_resolve_sysroot_result -func_resolve_sysroot () -{ - func_resolve_sysroot_result=$1 - case $func_resolve_sysroot_result in - =*) - func_stripname '=' '' "$func_resolve_sysroot_result" - func_resolve_sysroot_result=$lt_sysroot$func_stripname_result - ;; - esac -} - -# func_replace_sysroot PATH -# If PATH begins with the sysroot, replace it with = and -# store the result into func_replace_sysroot_result. -func_replace_sysroot () -{ - case "$lt_sysroot:$1" in - ?*:"$lt_sysroot"*) - func_stripname "$lt_sysroot" '' "$1" - func_replace_sysroot_result="=$func_stripname_result" - ;; - *) - # Including no sysroot. - func_replace_sysroot_result=$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_append_quoted CC_quoted "$arg" - done - CC_expanded=`func_echo_all $CC` - CC_quoted_expanded=`func_echo_all $CC_quoted` - 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 "* | " $CC_expanded "* | "$CC_expanded "* | \ - " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;; - # 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_append_quoted CC_quoted "$arg" - done - CC_expanded=`func_echo_all $CC` - CC_quoted_expanded=`func_echo_all $CC_quoted` - case "$@ " in - " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ - " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) - # 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 </dev/null` - if test "$?" -eq 0 && test -n "${func_convert_core_file_wine_to_w32_tmp}"; then - func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" | - $SED -e "$lt_sed_naive_backslashify"` - else - func_convert_core_file_wine_to_w32_result= - fi - fi -} -# end: func_convert_core_file_wine_to_w32 - - -# func_convert_core_path_wine_to_w32 ARG -# Helper function used by path conversion functions when $build is *nix, and -# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly -# configured wine environment available, with the winepath program in $build's -# $PATH. Assumes ARG has no leading or trailing path separator characters. -# -# ARG is path to be converted from $build format to win32. -# Result is available in $func_convert_core_path_wine_to_w32_result. -# Unconvertible file (directory) names in ARG are skipped; if no directory names -# are convertible, then the result may be empty. -func_convert_core_path_wine_to_w32 () -{ - $opt_debug - # unfortunately, winepath doesn't convert paths, only file names - func_convert_core_path_wine_to_w32_result="" - if test -n "$1"; then - oldIFS=$IFS - IFS=: - for func_convert_core_path_wine_to_w32_f in $1; do - IFS=$oldIFS - func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f" - if test -n "$func_convert_core_file_wine_to_w32_result" ; then - if test -z "$func_convert_core_path_wine_to_w32_result"; then - func_convert_core_path_wine_to_w32_result="$func_convert_core_file_wine_to_w32_result" - else - func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result" - fi - fi - done - IFS=$oldIFS - fi -} -# end: func_convert_core_path_wine_to_w32 - - -# func_cygpath ARGS... -# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when -# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2) -# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or -# (2), returns the Cygwin file name or path in func_cygpath_result (input -# file name or path is assumed to be in w32 format, as previously converted -# from $build's *nix or MSYS format). In case (3), returns the w32 file name -# or path in func_cygpath_result (input file name or path is assumed to be in -# Cygwin format). Returns an empty string on error. -# -# ARGS are passed to cygpath, with the last one being the file name or path to -# be converted. -# -# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH -# environment variable; do not put it in $PATH. -func_cygpath () -{ - $opt_debug - if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then - func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null` - if test "$?" -ne 0; then - # on failure, ensure result is empty - func_cygpath_result= - fi - else - func_cygpath_result= - func_error "LT_CYGPATH is empty or specifies non-existent file: \`$LT_CYGPATH'" - fi -} -#end: func_cygpath - - -# func_convert_core_msys_to_w32 ARG -# Convert file name or path ARG from MSYS format to w32 format. Return -# result in func_convert_core_msys_to_w32_result. -func_convert_core_msys_to_w32 () -{ - $opt_debug - # awkward: cmd appends spaces to result - func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null | - $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"` -} -#end: func_convert_core_msys_to_w32 - - -# func_convert_file_check ARG1 ARG2 -# Verify that ARG1 (a file name in $build format) was converted to $host -# format in ARG2. Otherwise, emit an error message, but continue (resetting -# func_to_host_file_result to ARG1). -func_convert_file_check () -{ - $opt_debug - if test -z "$2" && test -n "$1" ; then - func_error "Could not determine host file name corresponding to" - func_error " \`$1'" - func_error "Continuing, but uninstalled executables may not work." - # Fallback: - func_to_host_file_result="$1" - fi -} -# end func_convert_file_check - - -# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH -# Verify that FROM_PATH (a path in $build format) was converted to $host -# format in TO_PATH. Otherwise, emit an error message, but continue, resetting -# func_to_host_file_result to a simplistic fallback value (see below). -func_convert_path_check () -{ - $opt_debug - if test -z "$4" && test -n "$3"; then - func_error "Could not determine the host path corresponding to" - func_error " \`$3'" - func_error "Continuing, but uninstalled executables may not work." - # Fallback. This is a deliberately simplistic "conversion" and - # should not be "improved". See libtool.info. - if test "x$1" != "x$2"; then - lt_replace_pathsep_chars="s|$1|$2|g" - func_to_host_path_result=`echo "$3" | - $SED -e "$lt_replace_pathsep_chars"` - else - func_to_host_path_result="$3" - fi - fi -} -# end func_convert_path_check - - -# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG -# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT -# and appending REPL if ORIG matches BACKPAT. -func_convert_path_front_back_pathsep () -{ - $opt_debug - case $4 in - $1 ) func_to_host_path_result="$3$func_to_host_path_result" - ;; - esac - case $4 in - $2 ) func_to_host_path_result+="$3" - ;; - esac -} -# end func_convert_path_front_back_pathsep - - -################################################## -# $build to $host FILE NAME CONVERSION FUNCTIONS # -################################################## -# invoked via `$to_host_file_cmd ARG' -# -# In each case, ARG is the path to be converted from $build to $host format. -# Result will be available in $func_to_host_file_result. - - -# func_to_host_file ARG -# Converts the file name ARG from $build format to $host format. Return result -# in func_to_host_file_result. -func_to_host_file () -{ - $opt_debug - $to_host_file_cmd "$1" -} -# end func_to_host_file - - -# func_to_tool_file ARG LAZY -# converts the file name ARG from $build format to toolchain format. Return -# result in func_to_tool_file_result. If the conversion in use is listed -# in (the comma separated) LAZY, no conversion takes place. -func_to_tool_file () -{ - $opt_debug - case ,$2, in - *,"$to_tool_file_cmd",*) - func_to_tool_file_result=$1 - ;; - *) - $to_tool_file_cmd "$1" - func_to_tool_file_result=$func_to_host_file_result - ;; - esac -} -# end func_to_tool_file - - -# func_convert_file_noop ARG -# Copy ARG to func_to_host_file_result. -func_convert_file_noop () -{ - func_to_host_file_result="$1" -} -# end func_convert_file_noop - - -# func_convert_file_msys_to_w32 ARG -# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic -# conversion to w32 is not available inside the cwrapper. Returns result in -# func_to_host_file_result. -func_convert_file_msys_to_w32 () -{ - $opt_debug - func_to_host_file_result="$1" - if test -n "$1"; then - func_convert_core_msys_to_w32 "$1" - func_to_host_file_result="$func_convert_core_msys_to_w32_result" - fi - func_convert_file_check "$1" "$func_to_host_file_result" -} -# end func_convert_file_msys_to_w32 - - -# func_convert_file_cygwin_to_w32 ARG -# Convert file name ARG from Cygwin to w32 format. Returns result in -# func_to_host_file_result. -func_convert_file_cygwin_to_w32 () -{ - $opt_debug - func_to_host_file_result="$1" - if test -n "$1"; then - # because $build is cygwin, we call "the" cygpath in $PATH; no need to use - # LT_CYGPATH in this case. - func_to_host_file_result=`cygpath -m "$1"` - fi - func_convert_file_check "$1" "$func_to_host_file_result" -} -# end func_convert_file_cygwin_to_w32 - - -# func_convert_file_nix_to_w32 ARG -# Convert file name ARG from *nix to w32 format. Requires a wine environment -# and a working winepath. Returns result in func_to_host_file_result. -func_convert_file_nix_to_w32 () -{ - $opt_debug - func_to_host_file_result="$1" - if test -n "$1"; then - func_convert_core_file_wine_to_w32 "$1" - func_to_host_file_result="$func_convert_core_file_wine_to_w32_result" - fi - func_convert_file_check "$1" "$func_to_host_file_result" -} -# end func_convert_file_nix_to_w32 - - -# func_convert_file_msys_to_cygwin ARG -# Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. -# Returns result in func_to_host_file_result. -func_convert_file_msys_to_cygwin () -{ - $opt_debug - func_to_host_file_result="$1" - if test -n "$1"; then - func_convert_core_msys_to_w32 "$1" - func_cygpath -u "$func_convert_core_msys_to_w32_result" - func_to_host_file_result="$func_cygpath_result" - fi - func_convert_file_check "$1" "$func_to_host_file_result" -} -# end func_convert_file_msys_to_cygwin - - -# func_convert_file_nix_to_cygwin ARG -# Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed -# in a wine environment, working winepath, and LT_CYGPATH set. Returns result -# in func_to_host_file_result. -func_convert_file_nix_to_cygwin () -{ - $opt_debug - func_to_host_file_result="$1" - if test -n "$1"; then - # convert from *nix to w32, then use cygpath to convert from w32 to cygwin. - func_convert_core_file_wine_to_w32 "$1" - func_cygpath -u "$func_convert_core_file_wine_to_w32_result" - func_to_host_file_result="$func_cygpath_result" - fi - func_convert_file_check "$1" "$func_to_host_file_result" -} -# end func_convert_file_nix_to_cygwin - - -############################################# -# $build to $host PATH CONVERSION FUNCTIONS # -############################################# -# invoked via `$to_host_path_cmd ARG' -# -# In each case, ARG is the path to be converted from $build to $host format. -# The result will be available in $func_to_host_path_result. -# -# 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. -# -# All path conversion functions are named using the following convention: -# file name conversion function : func_convert_file_X_to_Y () -# path conversion function : func_convert_path_X_to_Y () -# where, for any given $build/$host combination the 'X_to_Y' value is the -# same. If conversion functions are added for new $build/$host combinations, -# the two new functions must follow this pattern, or func_init_to_host_path_cmd -# will break. - - -# func_init_to_host_path_cmd -# Ensures that function "pointer" variable $to_host_path_cmd is set to the -# appropriate value, based on the value of $to_host_file_cmd. -to_host_path_cmd= -func_init_to_host_path_cmd () -{ - $opt_debug - if test -z "$to_host_path_cmd"; then - func_stripname 'func_convert_file_' '' "$to_host_file_cmd" - to_host_path_cmd="func_convert_path_${func_stripname_result}" - fi -} - - -# func_to_host_path ARG -# Converts the path ARG from $build format to $host format. Return result -# in func_to_host_path_result. -func_to_host_path () -{ - $opt_debug - func_init_to_host_path_cmd - $to_host_path_cmd "$1" -} -# end func_to_host_path - - -# func_convert_path_noop ARG -# Copy ARG to func_to_host_path_result. -func_convert_path_noop () -{ - func_to_host_path_result="$1" -} -# end func_convert_path_noop - - -# func_convert_path_msys_to_w32 ARG -# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic -# conversion to w32 is not available inside the cwrapper. Returns result in -# func_to_host_path_result. -func_convert_path_msys_to_w32 () -{ - $opt_debug - func_to_host_path_result="$1" - if test -n "$1"; then - # 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_stripname : : "$1" - func_to_host_path_tmp1=$func_stripname_result - func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" - func_to_host_path_result="$func_convert_core_msys_to_w32_result" - func_convert_path_check : ";" \ - "$func_to_host_path_tmp1" "$func_to_host_path_result" - func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" - fi -} -# end func_convert_path_msys_to_w32 - - -# func_convert_path_cygwin_to_w32 ARG -# Convert path ARG from Cygwin to w32 format. Returns result in -# func_to_host_file_result. -func_convert_path_cygwin_to_w32 () -{ - $opt_debug - func_to_host_path_result="$1" - if test -n "$1"; then - # See func_convert_path_msys_to_w32: - func_stripname : : "$1" - func_to_host_path_tmp1=$func_stripname_result - func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"` - func_convert_path_check : ";" \ - "$func_to_host_path_tmp1" "$func_to_host_path_result" - func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" - fi -} -# end func_convert_path_cygwin_to_w32 - - -# func_convert_path_nix_to_w32 ARG -# Convert path ARG from *nix to w32 format. Requires a wine environment and -# a working winepath. Returns result in func_to_host_file_result. -func_convert_path_nix_to_w32 () -{ - $opt_debug - func_to_host_path_result="$1" - if test -n "$1"; then - # See func_convert_path_msys_to_w32: - func_stripname : : "$1" - func_to_host_path_tmp1=$func_stripname_result - func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" - func_to_host_path_result="$func_convert_core_path_wine_to_w32_result" - func_convert_path_check : ";" \ - "$func_to_host_path_tmp1" "$func_to_host_path_result" - func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" - fi -} -# end func_convert_path_nix_to_w32 - - -# func_convert_path_msys_to_cygwin ARG -# Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. -# Returns result in func_to_host_file_result. -func_convert_path_msys_to_cygwin () -{ - $opt_debug - func_to_host_path_result="$1" - if test -n "$1"; then - # See func_convert_path_msys_to_w32: - func_stripname : : "$1" - func_to_host_path_tmp1=$func_stripname_result - func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" - func_cygpath -u -p "$func_convert_core_msys_to_w32_result" - func_to_host_path_result="$func_cygpath_result" - func_convert_path_check : : \ - "$func_to_host_path_tmp1" "$func_to_host_path_result" - func_convert_path_front_back_pathsep ":*" "*:" : "$1" - fi -} -# end func_convert_path_msys_to_cygwin - - -# func_convert_path_nix_to_cygwin ARG -# Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a -# a wine environment, working winepath, and LT_CYGPATH set. Returns result in -# func_to_host_file_result. -func_convert_path_nix_to_cygwin () -{ - $opt_debug - func_to_host_path_result="$1" - if test -n "$1"; then - # 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_stripname : : "$1" - func_to_host_path_tmp1=$func_stripname_result - func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" - func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result" - func_to_host_path_result="$func_cygpath_result" - func_convert_path_check : : \ - "$func_to_host_path_tmp1" "$func_to_host_path_result" - func_convert_path_front_back_pathsep ":*" "*:" : "$1" - fi -} -# end func_convert_path_nix_to_cygwin - - -# func_mode_compile arg... -func_mode_compile () -{ - $opt_debug - # Get the compilation command and the source file. - base_compile= - srcfile="$nonopt" # always keep a non-empty value in "srcfile" - suppress_opt=yes - suppress_output= - arg_mode=normal - libobj= - later= - pie_flag= - - for arg - do - case $arg_mode in - arg ) - # do not "continue". Instead, add this to base_compile - lastarg="$arg" - arg_mode=normal - ;; - - target ) - libobj="$arg" - arg_mode=normal - continue - ;; - - normal ) - # Accept any command-line options. - case $arg in - -o) - test -n "$libobj" && \ - func_fatal_error "you cannot specify \`-o' more than once" - arg_mode=target - continue - ;; - - -pie | -fpie | -fPIE) - pie_flag+=" $arg" - continue - ;; - - -shared | -static | -prefer-pic | -prefer-non-pic) - later+=" $arg" - continue - ;; - - -no-suppress) - suppress_opt=no - continue - ;; - - -Xcompiler) - arg_mode=arg # the next one goes into the "base_compile" arg list - continue # The current "srcfile" will either be retained or - ;; # replaced later. I would guess that would be a bug. - - -Wc,*) - func_stripname '-Wc,' '' "$arg" - args=$func_stripname_result - lastarg= - save_ifs="$IFS"; IFS=',' - for arg in $args; do - IFS="$save_ifs" - func_append_quoted lastarg "$arg" - done - IFS="$save_ifs" - func_stripname ' ' '' "$lastarg" - lastarg=$func_stripname_result - - # Add the arguments to base_compile. - base_compile+=" $lastarg" - continue - ;; - - *) - # Accept the current argument as the source file. - # The previous "srcfile" becomes the current argument. - # - lastarg="$srcfile" - srcfile="$arg" - ;; - esac # case $arg - ;; - esac # case $arg_mode - - # Aesthetically quote the previous argument. - func_append_quoted base_compile "$lastarg" - done # for arg - - case $arg_mode in - arg) - func_fatal_error "you must specify an argument for -Xcompile" - ;; - target) - func_fatal_error "you must specify a target with \`-o'" - ;; - *) - # Get the name of the library object. - test -z "$libobj" && { - func_basename "$srcfile" - libobj="$func_basename_result" - } - ;; - esac - - # Recognize several different file suffixes. - # If the user specifies -o file.o, it is replaced with file.lo - case $libobj in - *.[cCFSifmso] | \ - *.ada | *.adb | *.ads | *.asm | \ - *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \ - *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup) - func_xform "$libobj" - libobj=$func_xform_result - ;; - esac - - case $libobj in - *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;; - *) - func_fatal_error "cannot determine name of library object from \`$libobj'" - ;; - esac - - func_infer_tag $base_compile - - for arg in $later; do - case $arg in - -shared) - test "$build_libtool_libs" != yes && \ - func_fatal_configuration "can not build a shared library" - build_old_libs=no - continue - ;; - - -static) - build_libtool_libs=no - build_old_libs=yes - continue - ;; - - -prefer-pic) - pic_mode=yes - continue - ;; - - -prefer-non-pic) - pic_mode=no - continue - ;; - esac - done - - func_quote_for_eval "$libobj" - test "X$libobj" != "X$func_quote_for_eval_result" \ - && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ - && 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 "$srcfile" | $SED 's%^.*/%%; 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+=" $output_obj" - $ECHO "$srcfile" > "$lockfile" - fi - - $opt_dry_run || $RM $removelist - removelist+=" $lockfile" - trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 - - func_to_tool_file "$srcfile" func_convert_file_msys_to_w32 - srcfile=$func_to_tool_file_result - 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+=" -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+=" -o $obj" - fi - - # Suppress compiler output if we already did a PIC compilation. - 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 "$opt_mode" = compile && func_mode_compile ${1+"$@"} -} - -func_mode_help () -{ - # We need to display help for each of the modes. - case $opt_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 build PIC objects only - -prefer-non-pic try to build 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 - -Wc,FLAG pass FLAG directly to the compiler - -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-dir 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 - -bindir BINDIR specify path to binaries directory (for systems where - libraries must be found in the PATH setting at runtime) - -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 - -Wc,FLAG - -Xcompiler FLAG pass linker-specific FLAG directly to the compiler - -Wl,FLAG - -Xlinker FLAG pass linker-specific FLAG directly to the linker - -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) - -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 \`$opt_mode'" - ;; - esac - - echo - $ECHO "Try \`$progname --help' for more information about other modes." -} - -# Now that we've collected a possible --mode arg, show help if necessary -if $opt_help; then - if test "$opt_help" = :; then - func_mode_help - else - { - func_help noexit - for opt_mode in compile link execute install finish uninstall clean; do - func_mode_help - done - } | sed -n '1p; 2,$s/^Usage:/ or: /p' - { - func_help noexit - for opt_mode in compile link execute install finish uninstall clean; do - echo - func_mode_help - done - } | - sed '1d - /^When reporting/,/^Report/{ - H - d - } - $x - /information about other modes/d - /more detailed .*MODE/d - s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/' - fi - exit $? -fi - - -# 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 $opt_dlopen; do - test -f "$file" \ - || func_fatal_help "\`$file' is not a file" - - dir= - case $file in - *.la) - func_resolve_sysroot "$file" - file=$func_resolve_sysroot_result - - # 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+="/$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 - -* | *.la | *.lo ) ;; - *) - # 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_append_quoted args "$file" - 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 "$opt_mode" = execute && func_mode_execute ${1+"$@"} - - -# func_mode_finish arg... -func_mode_finish () -{ - $opt_debug - libs= - libdirs= - admincmds= - - for opt in "$nonopt" ${1+"$@"} - do - if test -d "$opt"; then - libdirs+=" $opt" - - elif test -f "$opt"; then - if func_lalib_unsafe_p "$opt"; then - libs+=" $opt" - else - func_warning "\`$opt' is not a valid libtool archive" - fi - - else - func_fatal_error "invalid argument \`$opt'" - fi - done - - if test -n "$libs"; then - if test -n "$lt_sysroot"; then - sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"` - sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;" - else - sysroot_cmd= - fi - - # Remove sysroot references - if $opt_dry_run; then - for lib in $libs; do - echo "removing references to $lt_sysroot and \`=' prefixes from $lib" - done - else - tmpdir=`func_mktempdir` - for lib in $libs; do - sed -e "${sysroot_cmd} s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \ - > $tmpdir/tmp-la - mv -f $tmpdir/tmp-la $lib - done - ${RM}r "$tmpdir" - fi - fi - - if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then - 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+=" - $cmds" - fi - done - fi - - # Exit here if they wanted silent mode. - $opt_silent && exit $EXIT_SUCCESS - - if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then - echo "----------------------------------------------------------------------" - 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 "----------------------------------------------------------------------" - fi - exit $EXIT_SUCCESS -} - -test "$opt_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. - case $nonopt in *shtool*) :;; *) false;; esac; 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+="$func_quote_for_eval_result" - install_shared_prog=$install_prog - case " $install_prog " in - *[\\\ /]cp\ *) install_cp=: ;; - *) install_cp=false ;; - esac - - # We need to accept at least all the BSD install flags. - dest= - files= - opts= - prev= - install_type= - isdir=no - stripme= - no_mode=: - for arg - do - arg2= - if test -n "$dest"; then - files+=" $dest" - dest=$arg - continue - fi - - case $arg in - -d) isdir=yes ;; - -f) - if $install_cp; then :; else - prev=$arg - fi - ;; - -g | -m | -o) - prev=$arg - ;; - -s) - stripme=" -s" - continue - ;; - -*) - ;; - *) - # If the previous option needed an argument, then skip it. - if test -n "$prev"; then - if test "x$prev" = x-m && test -n "$install_override_mode"; then - arg2=$install_override_mode - no_mode=false - fi - prev= - else - dest=$arg - continue - fi - ;; - esac - - # Aesthetically quote the argument. - func_quote_for_eval "$arg" - install_prog+=" $func_quote_for_eval_result" - if test -n "$arg2"; then - func_quote_for_eval "$arg2" - fi - install_shared_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 -n "$install_override_mode" && $no_mode; then - if $install_cp; then :; else - func_quote_for_eval "$install_override_mode" - install_shared_prog+=" -m $func_quote_for_eval_result" - fi - fi - - 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+=" $file" - ;; - - *.la) - func_resolve_sysroot "$file" - file=$func_resolve_sysroot_result - - # 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+=" $libdir" ;; - esac - else - # Note the libdir as a future libdir. - case "$future_libdirs " in - *" $libdir "*) ;; - *) future_libdirs+=" $libdir" ;; - esac - fi - - func_dirname "$file" "/" "" - dir="$func_dirname_result" - dir+="$objdir" - - if test -n "$relink_command"; then - # Determine the prefix the user has applied to our future dir. - inst_prefix_dir=`$ECHO "$destdir" | $SED -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 "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` - else - relink_command=`$ECHO "$relink_command" | $SED "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_shared_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+=" $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 "$lib" | $SED '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 "$relink_command" | $SED '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 "$file$stripped_ext" | $SED "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_to_tool_file "$oldlib" func_convert_file_msys_to_w32 - tool_oldlib=$func_to_tool_file_result - - func_show_eval "$install_prog \$file \$oldlib" 'exit $?' - - if test -n "$stripme" && test -n "$old_striplib"; then - func_show_eval "$old_striplib $tool_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 "$opt_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 - -#if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) -#pragma GCC diagnostic ignored \"-Wstrict-prototypes\" -#endif - -/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ -#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE) -/* DATA imports from DLLs on WIN32 con't be const, because runtime - relocations are performed -- see ld's documentation on pseudo-relocs. */ -# define LT_DLSYM_CONST -#elif defined(__osf__) -/* This system does not cope well with relocations in const data. */ -# define LT_DLSYM_CONST -#else -# define LT_DLSYM_CONST const -#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 "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP` - for progfile in $progfiles; do - func_to_tool_file "$progfile" func_convert_file_msys_to_w32 - func_verbose "extracting global C symbols from \`$func_to_tool_file_result'" - $opt_dry_run || eval "$NM $func_to_tool_file_result | $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" - case $host in - *cygwin* | *mingw* | *cegcc* ) - # if an import library, we need to obtain dlname - if func_win32_import_lib_p "$dlprefile"; then - func_tr_sh "$dlprefile" - eval "curr_lafile=\$libfile_$func_tr_sh_result" - dlprefile_dlbasename="" - if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then - # Use subshell, to avoid clobbering current variable values - dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"` - if test -n "$dlprefile_dlname" ; then - func_basename "$dlprefile_dlname" - dlprefile_dlbasename="$func_basename_result" - else - # no lafile. user explicitly requested -dlpreopen . - $sharedlib_from_linklib_cmd "$dlprefile" - dlprefile_dlbasename=$sharedlib_from_linklib_result - fi - fi - $opt_dry_run || { - if test -n "$dlprefile_dlbasename" ; then - eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"' - else - func_warning "Could not compute DLL name from $name" - eval '$ECHO ": $name " >> "$nlist"' - fi - func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 - eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe | - $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'" - } - else # not an import lib - $opt_dry_run || { - eval '$ECHO ": $name " >> "$nlist"' - func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 - eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" - } - fi - ;; - *) - $opt_dry_run || { - eval '$ECHO ": $name " >> "$nlist"' - func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 - eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" - } - ;; - esac - 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; -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+=" $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 "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` - finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` - else - compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` - finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` - fi - ;; - *) - compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` - finalize_command=`$ECHO "$finalize_command" | $SED "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 "$compile_command" | $SED "s% @SYMFILE@%%"` - finalize_command=`$ECHO "$finalize_command" | $SED "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. -# Despite the name, also deal with 64 bit binaries. -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 - # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. - if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | - $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then - func_to_tool_file "$1" func_convert_file_msys_to_w32 - win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" | - $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_cygming_dll_for_implib ARG -# -# Platform-specific function to extract the -# name of the DLL associated with the specified -# import library ARG. -# Invoked by eval'ing the libtool variable -# $sharedlib_from_linklib_cmd -# Result is available in the variable -# $sharedlib_from_linklib_result -func_cygming_dll_for_implib () -{ - $opt_debug - sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"` -} - -# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs -# -# The is the core of a fallback implementation of a -# platform-specific function to extract the name of the -# DLL associated with the specified import library LIBNAME. -# -# SECTION_NAME is either .idata$6 or .idata$7, depending -# on the platform and compiler that created the implib. -# -# Echos the name of the DLL associated with the -# specified import library. -func_cygming_dll_for_implib_fallback_core () -{ - $opt_debug - match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"` - $OBJDUMP -s --section "$1" "$2" 2>/dev/null | - $SED '/^Contents of section '"$match_literal"':/{ - # Place marker at beginning of archive member dllname section - s/.*/====MARK====/ - p - d - } - # These lines can sometimes be longer than 43 characters, but - # are always uninteresting - /:[ ]*file format pe[i]\{,1\}-/d - /^In archive [^:]*:/d - # Ensure marker is printed - /^====MARK====/p - # Remove all lines with less than 43 characters - /^.\{43\}/!d - # From remaining lines, remove first 43 characters - s/^.\{43\}//' | - $SED -n ' - # Join marker and all lines until next marker into a single line - /^====MARK====/ b para - H - $ b para - b - :para - x - s/\n//g - # Remove the marker - s/^====MARK====// - # Remove trailing dots and whitespace - s/[\. \t]*$// - # Print - /./p' | - # we now have a list, one entry per line, of the stringified - # contents of the appropriate section of all members of the - # archive which possess that section. Heuristic: eliminate - # all those which have a first or second character that is - # a '.' (that is, objdump's representation of an unprintable - # character.) This should work for all archives with less than - # 0x302f exports -- but will fail for DLLs whose name actually - # begins with a literal '.' or a single character followed by - # a '.'. - # - # Of those that remain, print the first one. - $SED -e '/^\./d;/^.\./d;q' -} - -# func_cygming_gnu_implib_p ARG -# This predicate returns with zero status (TRUE) if -# ARG is a GNU/binutils-style import library. Returns -# with nonzero status (FALSE) otherwise. -func_cygming_gnu_implib_p () -{ - $opt_debug - func_to_tool_file "$1" func_convert_file_msys_to_w32 - func_cygming_gnu_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $EGREP ' (_head_[A-Za-z0-9_]+_[ad]l*|[A-Za-z0-9_]+_[ad]l*_iname)$'` - test -n "$func_cygming_gnu_implib_tmp" -} - -# func_cygming_ms_implib_p ARG -# This predicate returns with zero status (TRUE) if -# ARG is an MS-style import library. Returns -# with nonzero status (FALSE) otherwise. -func_cygming_ms_implib_p () -{ - $opt_debug - func_to_tool_file "$1" func_convert_file_msys_to_w32 - func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'` - test -n "$func_cygming_ms_implib_tmp" -} - -# func_cygming_dll_for_implib_fallback ARG -# Platform-specific function to extract the -# name of the DLL associated with the specified -# import library ARG. -# -# This fallback implementation is for use when $DLLTOOL -# does not support the --identify-strict option. -# Invoked by eval'ing the libtool variable -# $sharedlib_from_linklib_cmd -# Result is available in the variable -# $sharedlib_from_linklib_result -func_cygming_dll_for_implib_fallback () -{ - $opt_debug - if func_cygming_gnu_implib_p "$1" ; then - # binutils import library - sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"` - elif func_cygming_ms_implib_p "$1" ; then - # ms-generated import library - sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"` - else - # unknown - sharedlib_from_linklib_result="" - fi -} - - -# 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" - if test "$lock_old_archive_extraction" = yes; then - lockfile=$f_ex_an_ar_oldlib.lock - until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do - func_echo "Waiting for $lockfile to be removed" - sleep 2 - done - fi - func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \ - 'stat=$?; rm -f "$lockfile"; exit $stat' - if test "$lock_old_archive_extraction" = yes; then - $opt_dry_run || rm -f "$lockfile" - fi - 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 | sort | $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 | sort | $NL2SP` - done - - func_extract_archives_result="$my_oldobjs" -} - - -# 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=${1-no} - - $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. -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 - file=\"\$0\"" - - qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"` - $ECHO "\ - -# A function that is used when there is no print builtin or printf. -func_fallback_echo () -{ - eval 'cat <<_LTECHO_EOF -\$1 -_LTECHO_EOF' -} - ECHO=\"$qECHO\" - fi - -# Very basic option parsing. These options are (a) specific to -# the libtool wrapper, (b) are identical between the wrapper -# /script/ and the wrapper /executable/ which is used only on -# windows platforms, and (c) all begin with the string "--lt-" -# (application programs are unlikely to have options which match -# this pattern). -# -# There are only two supported options: --lt-debug and -# --lt-dump-script. There is, deliberately, no --lt-help. -# -# The first argument to this parsing function should be the -# script's $0 value, followed by "$@". -lt_option_debug= -func_parse_lt_options () -{ - lt_script_arg0=\$0 - shift - for lt_opt - do - case \"\$lt_opt\" in - --lt-debug) lt_option_debug=1 ;; - --lt-dump-script) - lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\` - test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=. - lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\` - cat \"\$lt_dump_D/\$lt_dump_F\" - exit 0 - ;; - --lt-*) - \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2 - exit 1 - ;; - esac - done - - # Print the debug banner immediately: - if test -n \"\$lt_option_debug\"; then - echo \"${outputname}:${output}:\${LINENO}: libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\" 1>&2 - fi -} - -# Used when --lt-debug. Prints its arguments to stdout -# (redirection is the responsibility of the caller) -func_lt_dump_args () -{ - lt_dump_args_N=1; - for lt_arg - do - \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[\$lt_dump_args_N]: \$lt_arg\" - lt_dump_args_N=\`expr \$lt_dump_args_N + 1\` - done -} - -# Core function for launching the target application -func_exec_program_core () -{ -" - case $host in - # Backslashes separate directories on plain windows - *-*-mingw | *-*-os2* | *-cegcc*) - $ECHO "\ - if test -n \"\$lt_option_debug\"; then - \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir\\\\\$program\" 1>&2 - func_lt_dump_args \${1+\"\$@\"} 1>&2 - fi - exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} -" - ;; - - *) - $ECHO "\ - if test -n \"\$lt_option_debug\"; then - \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir/\$program\" 1>&2 - func_lt_dump_args \${1+\"\$@\"} 1>&2 - fi - exec \"\$progdir/\$program\" \${1+\"\$@\"} -" - ;; - esac - $ECHO "\ - \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 - exit 1 -} - -# A function to encapsulate launching the target application -# Strips options in the --lt-* namespace from \$@ and -# launches target application with the remaining arguments. -func_exec_program () -{ - case \" \$* \" in - *\\ --lt-*) - for lt_wr_arg - do - case \$lt_wr_arg in - --lt-*) ;; - *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; - esac - shift - done ;; - esac - func_exec_program_core \${1+\"\$@\"} -} - - # Parse options - func_parse_lt_options \"\$0\" \${1+\"\$@\"} - - # Find the directory that this script lives in. - thisdir=\`\$ECHO \"\$file\" | $SED '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 \"\$file\" | $SED '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 \"\$file\" | $SED 's%^.*/%%'\` - file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` - done - - # Usually 'no', except on cygwin/mingw when embedded into - # the cwrapper. - WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_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 \"\$thisdir\" | $SED '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" - - # fixup the dll searchpath if we need to. - # - # Fix the DLL searchpath if we need to. Do this before prepending - # to shlibpath, because on Windows, both are PATH and uninstalled - # libraries must come first. - if test -n "$dllsearchpath"; then - $ECHO "\ - # Add the dll search path components to the executable PATH - PATH=$dllsearchpath:\$PATH -" - fi - - # 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 \"\$$shlibpath_var\" | $SED 's/::*\$//'\` - - export $shlibpath_var -" - fi - - $ECHO "\ - if test \"\$libtool_execute_magic\" != \"$magic\"; then - # Run the actual program with our arguments. - func_exec_program \${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\ -" -} - - -# 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 -#else -# include -# include -# ifdef __CYGWIN__ -# include -# endif -#endif -#include -#include -#include -#include -#include -#include -#include -#include - -/* declarations of non-ANSI functions */ -#if defined(__MINGW32__) -# ifdef __STRICT_ANSI__ -int _putenv (const char *); -# endif -#elif defined(__CYGWIN__) -# ifdef __STRICT_ANSI__ -char *realpath (const char *, char *); -int putenv (char *); -int setenv (const char *, const char *, int); -# endif -/* #elif defined (other platforms) ... */ -#endif - -/* portability defines, excluding path handling macros */ -#if defined(_MSC_VER) -# define setmode _setmode -# define stat _stat -# define chmod _chmod -# define getcwd _getcwd -# define putenv _putenv -# define S_IXUSR _S_IEXEC -# ifndef _INTPTR_T_DEFINED -# define _INTPTR_T_DEFINED -# define intptr_t int -# endif -#elif defined(__MINGW32__) -# define setmode _setmode -# define stat _stat -# define chmod _chmod -# define getcwd _getcwd -# define putenv _putenv -#elif defined(__CYGWIN__) -# define HAVE_SETENV -# define FOPEN_WB "wb" -/* #elif defined (other platforms) ... */ -#endif - -#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 - -/* path handling portability macros */ -#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 */ - -#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) - -#if defined(LT_DEBUGWRAPPER) -static int lt_debug = 1; -#else -static int lt_debug = 0; -#endif - -const char *program_name = "libtool-wrapper"; /* in case xstrdup fails */ - -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_debugprintf (const char *file, int line, const char *fmt, ...); -void lt_fatal (const char *file, int line, const char *message, ...); -static const char *nonnull (const char *s); -static const char *nonempty (const char *s); -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_update_exe_path (const char *name, const char *value); -void lt_update_lib_path (const char *name, const char *value); -char **prepare_spawn (char **argv); -void lt_dump_script (FILE *f); -EOF - - cat <= 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; - - lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n", - nonempty (path)); - 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; - - lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n", - nonempty (wrapper)); - - 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 (__FILE__, __LINE__, "getcwd failed: %s", - nonnull (strerror (errno))); - 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 (__FILE__, __LINE__, "getcwd failed: %s", - nonnull (strerror (errno))); - 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) - { - lt_debugprintf (__FILE__, __LINE__, - "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 - { - lt_fatal (__FILE__, __LINE__, - "error accessing file \"%s\": %s", - tmp_pathspec, nonnull (strerror (errno))); - } - } - XFREE (tmp_pathspec); - - if (!has_symlinks) - { - return xstrdup (pathspec); - } - - tmp_pathspec = realpath (pathspec, buf); - if (tmp_pathspec == 0) - { - lt_fatal (__FILE__, __LINE__, - "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; -} - -void -lt_debugprintf (const char *file, int line, const char *fmt, ...) -{ - va_list args; - if (lt_debug) - { - (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line); - va_start (args, fmt); - (void) vfprintf (stderr, fmt, args); - va_end (args); - } -} - -static void -lt_error_core (int exit_status, const char *file, - int line, const char *mode, - const char *message, va_list ap) -{ - fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode); - vfprintf (stderr, message, ap); - fprintf (stderr, ".\n"); - - if (exit_status >= 0) - exit (exit_status); -} - -void -lt_fatal (const char *file, int line, const char *message, ...) -{ - va_list ap; - va_start (ap, message); - lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap); - va_end (ap); -} - -static const char * -nonnull (const char *s) -{ - return s ? s : "(null)"; -} - -static const char * -nonempty (const char *s) -{ - return (s && !*s) ? "(empty)" : nonnull (s); -} - -void -lt_setenv (const char *name, const char *value) -{ - lt_debugprintf (__FILE__, __LINE__, - "(lt_setenv) setting '%s' to '%s'\n", - nonnull (name), nonnull (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; -} - -void -lt_update_exe_path (const char *name, const char *value) -{ - lt_debugprintf (__FILE__, __LINE__, - "(lt_update_exe_path) modifying '%s' by prepending '%s'\n", - nonnull (name), nonnull (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) -{ - lt_debugprintf (__FILE__, __LINE__, - "(lt_update_lib_path) modifying '%s' by prepending '%s'\n", - nonnull (name), nonnull (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 - case $host_os in - mingw*) - cat <<"EOF" - -/* Prepares an argument vector before calling spawn(). - Note that spawn() does not by itself call the command interpreter - (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") : - ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); - GetVersionEx(&v); - v.dwPlatformId == VER_PLATFORM_WIN32_NT; - }) ? "cmd.exe" : "command.com"). - Instead it simply concatenates the arguments, separated by ' ', and calls - CreateProcess(). We must quote the arguments since Win32 CreateProcess() - interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a - special way: - - Space and tab are interpreted as delimiters. They are not treated as - delimiters if they are surrounded by double quotes: "...". - - Unescaped double quotes are removed from the input. Their only effect is - that within double quotes, space and tab are treated like normal - characters. - - Backslashes not followed by double quotes are not special. - - But 2*n+1 backslashes followed by a double quote become - n backslashes followed by a double quote (n >= 0): - \" -> " - \\\" -> \" - \\\\\" -> \\" - */ -#define SHELL_SPECIAL_CHARS "\"\\ \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037" -#define SHELL_SPACE_CHARS " \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037" -char ** -prepare_spawn (char **argv) -{ - size_t argc; - char **new_argv; - size_t i; - - /* Count number of arguments. */ - for (argc = 0; argv[argc] != NULL; argc++) - ; - - /* Allocate new argument vector. */ - new_argv = XMALLOC (char *, argc + 1); - - /* Put quoted arguments into the new argument vector. */ - for (i = 0; i < argc; i++) - { - const char *string = argv[i]; - - if (string[0] == '\0') - new_argv[i] = xstrdup ("\"\""); - else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) - { - int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); - size_t length; - unsigned int backslashes; - const char *s; - char *quoted_string; - char *p; - - length = 0; - backslashes = 0; - if (quote_around) - length++; - for (s = string; *s != '\0'; s++) - { - char c = *s; - if (c == '"') - length += backslashes + 1; - length++; - if (c == '\\') - backslashes++; - else - backslashes = 0; - } - if (quote_around) - length += backslashes + 1; - - quoted_string = XMALLOC (char, length + 1); - - p = quoted_string; - backslashes = 0; - if (quote_around) - *p++ = '"'; - for (s = string; *s != '\0'; s++) - { - char c = *s; - if (c == '"') - { - unsigned int j; - for (j = backslashes + 1; j > 0; j--) - *p++ = '\\'; - } - *p++ = c; - if (c == '\\') - backslashes++; - else - backslashes = 0; - } - if (quote_around) - { - unsigned int j; - for (j = backslashes; j > 0; j--) - *p++ = '\\'; - *p++ = '"'; - } - *p = '\0'; - - new_argv[i] = quoted_string; - } - else - new_argv[i] = (char *) string; - } - new_argv[argc] = NULL; - - return new_argv; -} -EOF - ;; - esac - - cat <<"EOF" -void lt_dump_script (FILE* f) -{ -EOF - func_emit_wrapper yes | - $SED -n -e ' -s/^\(.\{79\}\)\(..*\)/\1\ -\2/ -h -s/\([\\"]\)/\\\1/g -s/$/\\n/ -s/\([^\n]*\).*/ fputs ("\1", f);/p -g -D' - cat <<"EOF" -} -EOF -} -# end: func_emit_cwrapperexe_src - -# func_win32_import_lib_p ARG -# True if ARG is an import lib, as indicated by $file_magic_cmd -func_win32_import_lib_p () -{ - $opt_debug - case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in - *import*) : ;; - *) false ;; - esac -} - -# 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 - bindir= - 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 - 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) - compile_command+=" @OUTPUT@" - finalize_command+=" @OUTPUT@" - ;; - esac - - case $prev in - bindir) - bindir="$arg" - prev= - continue - ;; - dlfiles|dlprefiles) - if test "$preload" = no; then - # Add the symbol object into the linking commands. - compile_command+=" @SYMFILE@" - 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+=" $arg" - else - 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+=" $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+=" $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+=" $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+=" $pic_object" - prev= - fi - - # A PIC object. - 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 - 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" - 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 - libobjs+=" $pic_object" - 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+=" $arg" ;; - esac - else - case "$xrpath " in - *" $arg "*) ;; - *) xrpath+=" $arg" ;; - esac - fi - prev= - continue - ;; - shrext) - shrext_cmds="$arg" - prev= - continue - ;; - weak) - weak_libs+=" $arg" - prev= - continue - ;; - xcclinker) - linker_flags+=" $qarg" - compiler_flags+=" $qarg" - prev= - compile_command+=" $qarg" - finalize_command+=" $qarg" - continue - ;; - xcompiler) - compiler_flags+=" $qarg" - prev= - compile_command+=" $qarg" - finalize_command+=" $qarg" - continue - ;; - xlinker) - linker_flags+=" $qarg" - compiler_flags+=" $wl$qarg" - prev= - compile_command+=" $wl$qarg" - 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. - compile_command+=" $link_static_flag" - 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 - ;; - - -bindir) - prev=bindir - 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*) - compile_command+=" $arg" - finalize_command+=" $arg" - ;; - esac - continue - ;; - - -L*) - func_stripname "-L" '' "$arg" - if test -z "$func_stripname_result"; 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 - func_resolve_sysroot "$func_stripname_result" - dir=$func_resolve_sysroot_result - # 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 "* | *" $arg "*) - # Will only happen for absolute or sysroot arguments - ;; - *) - # Preserve sysroot, but never include relative directories - case $dir in - [\\/]* | [A-Za-z]:[\\/]* | =*) deplibs+=" $arg" ;; - *) deplibs+=" -L$dir" ;; - esac - lib_search_path+=" $dir" - ;; - esac - case $host in - *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) - testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` - case :$dllsearchpath: in - *":$dir:"*) ;; - ::) dllsearchpath=$dir;; - *) dllsearchpath+=":$dir";; - esac - case :$dllsearchpath: in - *":$testbindir:"*) ;; - ::) dllsearchpath=$testbindir;; - *) 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* | *-*-haiku*) - # 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+=" 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+=" $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|--sysroot) - compiler_flags+=" $arg" - compile_command+=" $arg" - finalize_command+=" $arg" - prev=xcompiler - continue - ;; - - -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ - |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) - compiler_flags+=" $arg" - compile_command+=" $arg" - finalize_command+=" $arg" - case "$new_inherited_linker_flags " in - *" $arg "*) ;; - * ) 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_stripname '=' '' "$dir" - dir=$lt_sysroot$func_stripname_result - ;; - *) - func_fatal_error "only absolute run-paths are allowed" - ;; - esac - case "$xrpath " in - *" $dir "*) ;; - *) 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+=" $func_quote_for_eval_result" - 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+=" $wl$func_quote_for_eval_result" - compiler_flags+=" $wl$func_quote_for_eval_result" - 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" - ;; - - # Flags to be passed through unchanged, with rationale: - # -64, -mips[0-9] enable 64-bit mode for the SGI compiler - # -r[0-9][0-9]* specify processor for the SGI compiler - # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler - # +DA*, +DD* enable 64-bit mode for the HP compiler - # -q* compiler args for the IBM compiler - # -m*, -t[45]*, -txscale* architecture-specific flags for GCC - # -F/path path to uninstalled frameworks, gcc on darwin - # -p, -pg, --coverage, -fprofile-* profiling flags for GCC - # @file GCC response files - # -tp=* Portland pgcc target processor selection - # --sysroot=* for sysroot support - # -O*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization - -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ - -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ - -O*|-flto*|-fwhopr*|-fuse-linker-plugin) - func_quote_for_eval "$arg" - arg="$func_quote_for_eval_result" - compile_command+=" $arg" - finalize_command+=" $arg" - compiler_flags+=" $arg" - continue - ;; - - # Some other compiler flag. - -* | +*) - func_quote_for_eval "$arg" - arg="$func_quote_for_eval_result" - ;; - - *.$objext) - # A standard object. - 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+=" $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+=" $pic_object" - prev= - fi - - # A PIC object. - 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 - 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" - 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 - libobjs+=" $pic_object" - non_pic_objects+=" $non_pic_object" - else - func_fatal_error "\`$arg' is not a valid libtool object" - fi - fi - ;; - - *.$libext) - # An archive. - deplibs+=" $arg" - old_deplibs+=" $arg" - continue - ;; - - *.la) - # A libtool-controlled library. - - func_resolve_sysroot "$arg" - if test "$prev" = dlfiles; then - # This library was specified with -dlopen. - dlfiles+=" $func_resolve_sysroot_result" - prev= - elif test "$prev" = dlprefiles; then - # The library was specified with -dlpreopen. - dlprefiles+=" $func_resolve_sysroot_result" - prev= - else - deplibs+=" $func_resolve_sysroot_result" - 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 - compile_command+=" $arg" - 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\" - compile_command+=" $arg" - 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 \"\${$shlibpath_var}\" \| \$SED \'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" - func_to_tool_file "$output_objdir/" - tool_output_objdir=$func_to_tool_file_result - # 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_preserve_dup_deps ; then - case "$libs " in - *" $deplib "*) specialdeplibs+=" $deplib" ;; - esac - fi - 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+=" $pre_post_deps" ;; - esac - 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%" - test "X$link_all_deplibs" != Xno && libs="$libs $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= - func_resolve_sysroot "$lib" - case $lib in - *.la) func_source "$func_resolve_sysroot_result" ;; - esac - - # Collect preopened libtool deplibs, except any this library - # has declared as weak libs - for deplib in $dependency_libs; do - func_basename "$deplib" - deplib_base=$func_basename_result - case " $weak_libs " in - *" $deplib_base "*) ;; - *) 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|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) - if test "$linkmode,$pass" = "prog,link"; then - compile_deplibs="$deplib $compile_deplibs" - finalize_deplibs="$deplib $finalize_deplibs" - else - compiler_flags+=" $deplib" - if test "$linkmode" = lib ; then - case "$new_inherited_linker_flags " in - *" $deplib "*) ;; - * ) 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+=" $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" - func_resolve_sysroot "$func_stripname_result" - newlib_search_path+=" $func_resolve_sysroot_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" - func_resolve_sysroot "$func_stripname_result" - newlib_search_path+=" $func_resolve_sysroot_result" - ;; - *) - func_warning "\`-L' is ignored for archives/objects" - ;; - esac # linkmode - continue - ;; # -L - -R*) - if test "$pass" = link; then - func_stripname '-R' '' "$deplib" - func_resolve_sysroot "$func_stripname_result" - dir=$func_resolve_sysroot_result - # Make sure the xrpath contains only unique directories. - case "$xrpath " in - *" $dir "*) ;; - *) xrpath+=" $dir" ;; - esac - fi - deplibs="$deplib $deplibs" - continue - ;; - *.la) - func_resolve_sysroot "$deplib" - lib=$func_resolve_sysroot_result - ;; - *.$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 \"$deplib\"" 2>/dev/null | $SED 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+=" $deplib" - compile_deplibs="$deplib $compile_deplibs" - finalize_deplibs="$deplib $finalize_deplibs" - else - 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 "$inherited_linker_flags" | $SED '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+=" $tmp_inherited_linker_flag";; - esac - done - fi - dependency_libs=`$ECHO " $dependency_libs" | $SED '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+=" $dlopen" - test -n "$dlpreopen" && 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+=" $ladir/$objdir/$old_library" - old_convenience+=" $ladir/$objdir/$old_library" - tmp_libs= - for deplib in $dependency_libs; do - deplibs="$deplib $deplibs" - if $opt_preserve_dup_deps ; then - case "$tmp_libs " in - *" $deplib "*) specialdeplibs+=" $deplib" ;; - esac - fi - tmp_libs+=" $deplib" - done - elif test "$linkmode" != prog && test "$linkmode" != lib; then - func_fatal_error "\`$lib' is not a convenience library" - fi - continue - fi # $pass = conv - - - # Get the name of the library we link against. - linklib= - if test -n "$old_library" && - { test "$prefer_static_libs" = yes || - test "$prefer_static_libs,$installed" = "built,no"; }; then - linklib=$old_library - else - for l in $old_library $library_names; do - linklib="$l" - done - fi - 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+=" $lib $dependency_libs" - else - 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 "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then - func_warning "library \`$lib' was moved." - dir="$ladir" - absdir="$abs_ladir" - libdir="$abs_ladir" - else - dir="$lt_sysroot$libdir" - absdir="$lt_sysroot$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+=" $abs_ladir" - else - dir="$ladir/$objdir" - absdir="$abs_ladir/$objdir" - # Remove this search path later - 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 - case "$host" in - # special handling for platforms with PE-DLLs. - *cygwin* | *mingw* | *cegcc* ) - # Linker will automatically link against shared library if both - # static and shared are present. Therefore, ensure we extract - # symbols from the import library if a shared library is present - # (otherwise, the dlopen module name will be incorrect). We do - # this by putting the import library name into $newdlprefiles. - # We recover the dlopen module name by 'saving' the la file - # name in a special purpose variable, and (later) extracting the - # dlname from the la file. - if test -n "$dlname"; then - func_tr_sh "$dir/$linklib" - eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname" - newdlprefiles+=" $dir/$linklib" - else - 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+=" $dir/$old_library" - fi - ;; - * ) - # Prefer using a static library (so that no silly _DYNAMIC symbols - # are required to link). - if test -n "$old_library"; then - 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+=" $dir/$old_library" - # Otherwise, use the dlname, so that lt_dlopen finds it. - elif test -n "$dlname"; then - newdlprefiles+=" $dir/$dlname" - else - newdlprefiles+=" $dir/$linklib" - fi - ;; - esac - 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+=" $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" - func_resolve_sysroot "$func_stripname_result" - newlib_search_path+=" $func_resolve_sysroot_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_preserve_dup_deps ; then - case "$tmp_libs " in - *" $deplib "*) specialdeplibs+=" $deplib" ;; - esac - fi - 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+="$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+=" $absdir" ;; - esac - ;; - esac - case " $sys_lib_dlsearch_path " in - *" $libdir "*) ;; - *) - case "$finalize_rpath " in - *" $libdir "*) ;; - *) 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+=" $lib" - need_relink=no - ;; - *) - if test "$installed" = no; then - 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+=" $absdir" ;; - esac - ;; - esac - case " $sys_lib_dlsearch_path " in - *" $libdir "*) ;; - *) - case "$finalize_rpath " in - *" $libdir "*) ;; - *) 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 "$opt_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$absdir" - # Try looking first in the location we're being installed to. - if test -n "$inst_prefix_dir"; then - case $libdir in - [\\/]*) - 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+="$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+="$libdir:" ;; - esac - fi - fi - fi - - if test "$linkmode" = prog || test "$opt_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+="$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+=" -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+=" $temp_xrpath";; - esac;; - *) temp_deplibs+=" $libdir";; - esac - done - dependency_libs="$temp_deplibs" - fi - - 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" - case $deplib in - -L*) func_stripname '-L' '' "$deplib" - func_resolve_sysroot "$func_stripname_result";; - *) func_resolve_sysroot "$deplib" ;; - esac - if $opt_preserve_dup_deps ; then - case "$tmp_libs " in - *" $func_resolve_sysroot_result "*) - specialdeplibs+=" $func_resolve_sysroot_result" ;; - esac - fi - tmp_libs+=" $func_resolve_sysroot_result" - done - - if test "$link_all_deplibs" != no; then - # Add the search paths of all dependency libraries - for deplib in $dependency_libs; do - path= - case $deplib in - -L*) path="$deplib" ;; - *.la) - func_resolve_sysroot "$deplib" - deplib=$func_resolve_sysroot_result - 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+=" ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}" - 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 " $new_inherited_linker_flags" | $SED '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+=" $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+=" $deplib" ;; - esac - ;; - *) 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+=" $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+="$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+=" $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 - # correct linux to gnu/linux during the next big refactor - 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|qnx|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 - ;; - *) - func_fatal_configuration "$modename: unknown library version type \`$version_type'" - ;; - 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) # correct to gnu/linux during the next big refactor - 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+=":${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+=" $symfileobj" - test "X$libobjs" = "X " && libobjs= - - if test "$opt_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+=" $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+=" $output_objdir/$libname.$libext" - - # Transform .lo files to .o files. - oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; $lo2o" | $NL2SP` - fi - - # Eliminate all temporary directories. - #for path in $notinst_path; do - # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"` - # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"` - # dependency_libs=`$ECHO "$dependency_libs " | $SED "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 - func_replace_sysroot "$libdir" - temp_xrpath+=" -R$func_replace_sysroot_result" - case "$finalize_rpath " in - *" $libdir "*) ;; - *) 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+=" $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+=" $lib" ;; - esac - done - - if test "$build_libtool_libs" = yes; then - if test -n "$rpath"; then - case $host in - *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) - # these systems don't actually have a c library (as such)! - ;; - *-*-rhapsody* | *-*-darwin1.[012]) - # Rhapsody C library is in the System framework - 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+=" -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` - $nocaseglob - else - potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` - fi - 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 "$potlib" | $SED 's,[^/]*$,,'`"$potliblink";; - esac - done - if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | - $SED -e 10q | - $EGREP "$file_magic_regex" > /dev/null; then - 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+=" $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+=" $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 \"$potent_lib\"" 2>/dev/null | $SED 10q | \ - $EGREP "$match_pattern_regex" > /dev/null; then - 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+=" $a_deplib" - ;; - esac - done # Gone through all deplibs. - ;; - none | unknown | *) - newdeplibs="" - tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; 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 " $tmp_deplibs" | $SED "s,$i,,"` - done - fi - case $tmp_deplibs in - *[!\ \ ]*) - 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 - ;; - esac - ;; - 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 " $newdeplibs" | $SED '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 " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` - new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` - deplibs=`$ECHO " $deplibs" | $SED '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+=" -L$path/$objdir" ;; - esac - ;; - esac - done - for deplib in $deplibs; do - case $deplib in - -L*) - case " $new_libs " in - *" $deplib "*) ;; - *) new_libs+=" $deplib" ;; - esac - ;; - *) 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 - # Remove ${wl} instances when linking with ld. - # FIXME: should test the right _cmds variable. - case $archive_cmds in - *\$LD\ *) wl= ;; - esac - if test "$hardcode_into_libs" = yes; then - # Hardcode the library paths - hardcode_libdirs= - dep_rpath= - rpath="$finalize_rpath" - test "$opt_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 - func_replace_sysroot "$libdir" - libdir=$func_replace_sysroot_result - 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_libdir_separator$libdir" - ;; - esac - fi - else - eval flag=\"$hardcode_libdir_flag_spec\" - dep_rpath+=" $flag" - fi - elif test -n "$runpath_var"; then - case "$perm_rpath " in - *" $libdir "*) ;; - *) 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 "dep_rpath=\"$hardcode_libdir_flag_spec\"" - 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+="$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 "$opt_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+=" $link" - done - - # Use standard objects if they are pic - test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$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+=" $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 cmd1 in $cmds; do - IFS="$save_ifs" - # Take the normal branch if the nm_file_list_spec branch - # doesn't work or if tool conversion is not needed. - case $nm_file_list_spec~$to_tool_file_cmd in - *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*) - try_normal_branch=yes - eval cmd=\"$cmd1\" - func_len " $cmd" - len=$func_len_result - ;; - *) - try_normal_branch=no - ;; - esac - if test "$try_normal_branch" = yes \ - && { test "$len" -lt "$max_cmd_len" \ - || test "$max_cmd_len" -le -1; } - then - func_show_eval "$cmd" 'exit $?' - skipped_export=false - elif test -n "$nm_file_list_spec"; then - func_basename "$output" - output_la=$func_basename_result - save_libobjs=$libobjs - save_output=$output - output=${output_objdir}/${output_la}.nm - func_to_tool_file "$output" - libobjs=$nm_file_list_spec$func_to_tool_file_result - delfiles+=" $output" - func_verbose "creating $NM input file list: $output" - for obj in $save_libobjs; do - func_to_tool_file "$obj" - $ECHO "$func_to_tool_file_result" - done > "$output" - eval cmd=\"$cmd1\" - func_show_eval "$cmd" 'exit $?' - output=$save_output - libobjs=$save_libobjs - 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 "$include_expsyms" | $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+=" $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+=" $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+=" $gentop" - - func_extract_archives $gentop $convenience - 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+=" $flag" - fi - - # Make a backup of the uninstalled library when relinking - if test "$opt_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 - func_basename "$output" - output_la=$func_basename_result - - # 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 - func_to_tool_file "$obj" - $ECHO "$func_to_tool_file_result" >> $output - done - echo ')' >> $output - delfiles+=" $output" - func_to_tool_file "$output" - output=$func_to_tool_file_result - 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 - func_to_tool_file "$obj" - $ECHO "$func_to_tool_file_result" >> $output - done - delfiles+=" $output" - func_to_tool_file "$output" - output=$firstobj\"$file_list_spec$func_to_tool_file_result\" - 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 - 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. - reload_objs=$objlist - eval concat_cmds=\"$reload_cmds\" - else - # All subsequent reloadable object files will link in - # the last one created. - reload_objs="$objlist $last_robj" - eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$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~ - reload_objs="$objlist $last_robj" - eval concat_cmds=\"\${concat_cmds}$reload_cmds\" - if test -n "$last_robj"; then - eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\" - fi - 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 "$opt_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 "$include_expsyms" | $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+=" $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+=" $gentop" - - func_extract_archives $gentop $dlprefiles - 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 "$opt_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 "$opt_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 "$tmp_whole_archive_flags" | $SED 's|,| |g'` - else - gentop="$output_objdir/${obj}x" - generated+=" $gentop" - - func_extract_archives $gentop $convenience - reload_conv_objs="$reload_objs $func_extract_archives_result" - fi - fi - - # If we're not building shared, we need to use non_pic_objs - test "$build_libtool_libs" != yes && libobjs="$non_pic_objects" - - # Create the old-style object. - reload_objs="$objs$old_deplibs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; /\.lib$/d; $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 " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'` - finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED '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+=" ${wl}-bind_at_load" - finalize_command+=" ${wl}-bind_at_load" - ;; - esac - fi - # Time to change all our "foo.ltframework" stuff back to "-framework foo" - compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` - finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED '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+=" -L$path/$objdir" ;; - esac - ;; - esac - done - for deplib in $compile_deplibs; do - case $deplib in - -L*) - case " $new_libs " in - *" $deplib "*) ;; - *) new_libs+=" $deplib" ;; - esac - ;; - *) new_libs+=" $deplib" ;; - esac - done - compile_deplibs="$new_libs" - - - compile_command+=" $compile_deplibs" - 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+=" $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_libdir_separator$libdir" - ;; - esac - fi - else - eval flag=\"$hardcode_libdir_flag_spec\" - rpath+=" $flag" - fi - elif test -n "$runpath_var"; then - case "$perm_rpath " in - *" $libdir "*) ;; - *) 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+=":$libdir";; - esac - case :$dllsearchpath: in - *":$testbindir:"*) ;; - ::) dllsearchpath=$testbindir;; - *) 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_libdir_separator$libdir" - ;; - esac - fi - else - eval flag=\"$hardcode_libdir_flag_spec\" - rpath+=" $flag" - fi - elif test -n "$runpath_var"; then - case "$finalize_perm_rpath " in - *" $libdir "*) ;; - *) 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 "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP` - finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$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 - *cegcc* | *mingw32ce*) - # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. - wrappers_required=no - ;; - *cygwin* | *mingw* ) - if test "$build_libtool_libs" != yes; then - wrappers_required=no - fi - ;; - *) - 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 "$compile_command" | $SED '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=$?' - - if test -n "$postlink_cmds"; then - func_to_tool_file "$output" - postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` - func_execute_cmds "$postlink_cmds" 'exit $?' - fi - - # 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+="$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+="$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 "$link_command" | $SED '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 $?' - - if test -n "$postlink_cmds"; then - func_to_tool_file "$output" - postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` - func_execute_cmds "$postlink_cmds" 'exit $?' - fi - - 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 "$compile_var$compile_command$compile_rpath" | $SED '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 "$link_command" | $SED '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 $?' - - if test -n "$postlink_cmds"; then - func_to_tool_file "$output_objdir/$outputname" - postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` - func_execute_cmds "$postlink_cmds" 'exit $?' - fi - - # 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 "$relink_command" | $SED "$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+=" $symfileobj" - fi - fi - addlibs="$old_convenience" - fi - - if test -n "$addlibs"; then - gentop="$output_objdir/${outputname}x" - generated+=" $gentop" - - func_extract_archives $gentop $addlibs - 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+=" $gentop" - - func_extract_archives $gentop $dlprefiles - 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+=" $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+=" $gentop/$newobj" - ;; - *) oldobjs+=" $obj" ;; - esac - done - fi - func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 - tool_oldlib=$func_to_tool_file_result - 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 - elif test -n "$archiver_list_spec"; then - func_verbose "using command file archive linking..." - for obj in $oldobjs - do - func_to_tool_file "$obj" - $ECHO "$func_to_tool_file_result" - done > $output_objdir/$libname.libcmd - func_to_tool_file "$output_objdir/$libname.libcmd" - oldobjs=" $archiver_list_spec$func_to_tool_file_result" - 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 - 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 "$relink_command" | $SED "$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" - func_resolve_sysroot "$deplib" - eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result` - test -z "$libdir" && \ - func_fatal_error "\`$deplib' is not a valid libtool archive" - newdependency_libs+=" ${lt_sysroot:+=}$libdir/$name" - ;; - -L*) - func_stripname -L '' "$deplib" - func_replace_sysroot "$func_stripname_result" - newdependency_libs+=" -L$func_replace_sysroot_result" - ;; - -R*) - func_stripname -R '' "$deplib" - func_replace_sysroot "$func_stripname_result" - newdependency_libs+=" -R$func_replace_sysroot_result" - ;; - *) 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+=" ${lt_sysroot:+=}$libdir/$name" - ;; - *) 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+=" ${lt_sysroot:+=}$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+=" $abs" - done - dlfiles="$newdlfiles" - newdlprefiles= - for lib in $dlprefiles; do - case $lib in - [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; - *) abs=`pwd`"/$lib" ;; - esac - newdlprefiles+=" $abs" - done - dlprefiles="$newdlprefiles" - fi - $RM $output - # place dlname in correct position for cygwin - # In fact, it would be nice if we could use this code for all target - # systems that can't hard-code library paths into their executables - # and that have no shared library path variable independent of PATH, - # but it turns out we can't easily determine that from inspecting - # libtool variables, so we have to hard-code the OSs to which it - # applies here; at the moment, that means platforms that use the PE - # object format with DLL files. See the long comment at the top of - # tests/bindir.at for full details. - tdlname=$dlname - case $host,$output,$installed,$module,$dlname in - *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) - # If a -bindir argument was supplied, place the dll there. - if test "x$bindir" != x ; - then - func_relative_path "$install_libdir" "$bindir" - tdlname=$func_relative_path_result$dlname - else - # Otherwise fall back on heuristic. - tdlname=../bin/$dlname - fi - ;; - 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 "$opt_mode" = link || test "$opt_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+=" $arg"; rmforce=yes ;; - -*) RM+=" $arg" ;; - *) files+=" $arg" ;; - esac - done - - test -z "$RM" && \ - func_fatal_help "you must specify an RM program" - - rmdirs= - - for file in $files; do - func_dirname "$file" "" "." - dir="$func_dirname_result" - if test "X$dir" = X.; then - odir="$objdir" - else - odir="$dir/$objdir" - fi - func_basename "$file" - name="$func_basename_result" - test "$opt_mode" = uninstall && odir="$dir" - - # Remember odir for removal later, being careful to avoid duplicates - if test "$opt_mode" = clean; then - case " $rmdirs " in - *" $odir "*) ;; - *) rmdirs+=" $odir" ;; - 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+=" $odir/$n" - done - test -n "$old_library" && rmfiles+=" $odir/$old_library" - - case "$opt_mode" in - clean) - case " $library_names " in - *" $dlname "*) ;; - *) test -n "$dlname" && rmfiles+=" $odir/$dlname" ;; - esac - test -n "$libdir" && rmfiles+=" $odir/$name $odir/${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+=" $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+=" $dir/$non_pic_object" - fi - fi - ;; - - *) - if test "$opt_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+=" $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+=" $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+=" $odir/$name $odir/${name}S.${objext}" - if test "$fast_install" = yes && test -n "$relink_command"; then - rmfiles+=" $odir/lt-$name" - fi - if test "X$noexename" != "X$name" ; then - rmfiles+=" $odir/lt-${noexename}.c" - fi - fi - fi - ;; - esac - func_show_eval "$RM $rmfiles" 'exit_status=1' - done - - # 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 "$opt_mode" = uninstall || test "$opt_mode" = clean; } && - func_mode_uninstall ${1+"$@"} - -test -z "$opt_mode" && { - help="$generic_help" - func_fatal_help "you must specify a MODE" -} - -test -z "$exec_cmd" && \ - func_fatal_help "invalid operation mode \`$opt_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/vpp-japi/m4/ax_check_java_home.m4 b/vpp-japi/m4/ax_check_java_home.m4 deleted file mode 100644 index cfe8f589..00000000 --- a/vpp-japi/m4/ax_check_java_home.m4 +++ /dev/null @@ -1,80 +0,0 @@ -# =========================================================================== -# http://www.gnu.org/software/autoconf-archive/ax_check_java_home.html -# =========================================================================== -# -# SYNOPSIS -# -# AX_CHECK_JAVA_HOME -# -# DESCRIPTION -# -# Check for Sun Java (JDK / JRE) installation, where the 'java' VM is in. -# If found, set environment variable JAVA_HOME = Java installation home, -# else left JAVA_HOME untouch, which in most case means JAVA_HOME is -# empty. -# -# LICENSE -# -# Copyright (c) 2008 Gleen Salmon -# -# 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 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 . -# -# As a special exception, the respective Autoconf Macro's copyright owner -# gives unlimited permission to copy, distribute and modify the configure -# scripts that are the output of Autoconf when processing the Macro. You -# need not follow the terms of the GNU General Public License when using -# or distributing such scripts, even though portions of the text of the -# Macro appear in them. The GNU General Public License (GPL) does govern -# all other use of the material that constitutes the Autoconf Macro. -# -# This special exception to the GPL applies to versions of the Autoconf -# Macro released by the Autoconf Archive. When you make and distribute a -# modified version of the Autoconf Macro, you may extend this special -# exception to the GPL to apply to your modified version as well. - -#serial 6 - -AU_ALIAS([AC_CHECK_JAVA_HOME], [AX_CHECK_JAVA_HOME]) - -AC_DEFUN([AX_CHECK_JAVA_HOME], -[AC_MSG_CHECKING([for JAVA_HOME]) -# We used a fake loop so that we can use "break" to exit when the result -# is found. -while true -do - # If the user defined JAVA_HOME, don't touch it. - test "${JAVA_HOME+set}" = set && break - - # On Mac OS X 10.5 and following, run /usr/libexec/java_home to get - # the value of JAVA_HOME to use. - # (http://developer.apple.com/library/mac/#qa/qa2001/qa1170.html). - JAVA_HOME=`/usr/libexec/java_home 2>/dev/null` - test x"$JAVA_HOME" != x && break - - # See if we can find the java executable, and compute from there. - TRY_JAVA_HOME=`ls -dr /usr/java/* 2> /dev/null | head -n 1` - if test x$TRY_JAVA_HOME != x; then - PATH=$PATH:$TRY_JAVA_HOME/bin - fi - AC_PATH_PROG([JAVA_PATH_NAME], [java]) - if test "x$JAVA_PATH_NAME" != x; then - JAVA_HOME=`echo $JAVA_PATH_NAME | sed "s/\(.*\)[[/]]bin[[/]]java.*/\1/"` - break - fi - - AC_MSG_NOTICE([Could not compute JAVA_HOME]) - break -done -AC_MSG_RESULT([$JAVA_HOME]) -]) diff --git a/vpp-japi/m4/ax_check_java_plugin.m4 b/vpp-japi/m4/ax_check_java_plugin.m4 deleted file mode 100644 index 920753e5..00000000 --- a/vpp-japi/m4/ax_check_java_plugin.m4 +++ /dev/null @@ -1,101 +0,0 @@ -# =========================================================================== -# http://www.gnu.org/software/autoconf-archive/ax_check_java_plugin.html -# =========================================================================== -# -# SYNOPSIS -# -# AX_CHECK_JAVA_PLUGIN() -# -# DESCRIPTION -# -# This macro sets to empty on failure and to a compatible -# version of plugin.jar otherwise. Directories searched are /usr/java/* -# and /usr/local/java/*, which are assumed to be j{dk,re} installations. -# Apply the shell variable as you see fit. If sun changes things so -# /lib/plugin.jar is not the magic file it will stop working. -# -# This macro assumes that unzip, zipinfo or pkzipc is available (and can -# list the contents of the jar archive). The first two are assumed to work -# similarly enough to the infozip versisonms. The pkzipc version is -# assumed to work if I undertstand the documentation on pkware's site but -# YMMV. I do not have access to pwkware's version to test it. -# -# LICENSE -# -# Copyright (c) 2008 Duncan Simpson -# -# 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 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 . -# -# As a special exception, the respective Autoconf Macro's copyright owner -# gives unlimited permission to copy, distribute and modify the configure -# scripts that are the output of Autoconf when processing the Macro. You -# need not follow the terms of the GNU General Public License when using -# or distributing such scripts, even though portions of the text of the -# Macro appear in them. The GNU General Public License (GPL) does govern -# all other use of the material that constitutes the Autoconf Macro. -# -# This special exception to the GPL applies to versions of the Autoconf -# Macro released by the Autoconf Archive. When you make and distribute a -# modified version of the Autoconf Macro, you may extend this special -# exception to the GPL to apply to your modified version as well. - -#serial 7 - -AU_ALIAS([DPS_CHECK_PLUGIN], [AX_CHECK_JAVA_PLUGIN]) -AC_DEFUN([AX_CHECK_JAVA_PLUGIN], -[AC_REQUIRE([AC_PROG_AWK]) -AC_REQUIRE([AC_PROG_FGREP]) -AC_CHECK_PROG(ZIPINFO,[zipinfo unzip pkzipc]) -AC_MSG_CHECKING([for the java plugin]) -case "x$ZIPINFO" in -[*/zipinfo)] - zipinf="zipinfo -1" ;; -[*/unzip)] - zipinf="unzip -l";; -[*/pkzipc)] - ziping="unzipc -view";; -[x*)] - AC_MSG_RESULT([skiped, none of zipinfo, unzip and pkzipc found]) - AC_SUBST($1,[]) - zipinf="";; -esac -if test "x$zipinf" != "x"; then -jplugin="" -for jhome in `ls -dr /usr/java/* /usr/local/java/* 2> /dev/null`; do -for jfile in lib/plugin.jar jre/lib/plugin.jar; do -if test "x$jplugin" = "x" && test -f "$jhome/$jfile"; then -eval "$zipinf $jhome/$jfile | $AWK '{ print \$NF; }' | $FGREP netscape/javascript/JSObject" >/dev/null 2>/dev/null -if test $? -eq 0; then -dnl Some version of gcj (and javac) refuse to work with some files -dnl that pass this test. To stop this problem make sure that the compiler -dnl still works with this jar file in the classpath -cat << \EOF > Test.java -/* [#]line __oline__ "configure" */ -public class Test { -} -EOF -if eval "$JAVAC -classpath $jhome/$jfile Test.java 2>/dev/null >/dev/null" && test -f Test.class; then -jplugin="$jhome/$jfile" -fi -rm -f Test.java Test.class -fi; fi; done; done -if test "x$jplugin" != "x"; then -AC_SUBST($1,$jplugin) -AC_MSG_RESULT($jplugin) -else -AC_MSG_RESULT([java plugin not found]) -AC_SUBST($1,[]) -fi -fi -]) diff --git a/vpp-japi/m4/ax_java_check_class.m4 b/vpp-japi/m4/ax_java_check_class.m4 deleted file mode 100644 index 917638ae..00000000 --- a/vpp-japi/m4/ax_java_check_class.m4 +++ /dev/null @@ -1,85 +0,0 @@ -# =========================================================================== -# http://www.gnu.org/software/autoconf-archive/ax_java_check_class.html -# =========================================================================== -# -# SYNOPSIS -# -# AX_JAVA_CHECK_CLASS(,,) -# -# DESCRIPTION -# -# Test if a Java class is available. Based on AX_PROG_JAVAC_WORKS. This -# version uses a cache variable which is both compiler, options and -# classpath dependent (so if you switch from javac to gcj it correctly -# notices and redoes the test). -# -# The macro tries to compile a minimal program importing . Some -# newer compilers moan about the failure to use this but fail or produce a -# class file anyway. All moaing is sunk to /dev/null since I only wanted -# to know if the class could be imported. This is a recommended followup -# to AX_CHECK_JAVA_PLUGIN with classpath appropriately adjusted. -# -# LICENSE -# -# Copyright (c) 2008 Duncan Simpson -# -# 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 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 . -# -# As a special exception, the respective Autoconf Macro's copyright owner -# gives unlimited permission to copy, distribute and modify the configure -# scripts that are the output of Autoconf when processing the Macro. You -# need not follow the terms of the GNU General Public License when using -# or distributing such scripts, even though portions of the text of the -# Macro appear in them. The GNU General Public License (GPL) does govern -# all other use of the material that constitutes the Autoconf Macro. -# -# This special exception to the GPL applies to versions of the Autoconf -# Macro released by the Autoconf Archive. When you make and distribute a -# modified version of the Autoconf Macro, you may extend this special -# exception to the GPL to apply to your modified version as well. - -#serial 9 - -AU_ALIAS([DPS_JAVA_CHECK_CLASS], [AX_JAVA_CHECK_CLASS]) -AC_DEFUN([AX_JAVA_CHECK_CLASS],[ -m4_define([cache_val],[m4_translit(ax_cv_have_java_class_$1, " ." ,"__")]) -if test "x$CLASSPATH" != "x"; then -xtra=" with classpath ${CLASSPATH}" -xopts=`echo ${CLASSPATH} | ${SED} 's/^ *://'` -xopts="-classpath $xopts" -else xtra=""; xopts=""; fi -cache_var="cache_val"AS_TR_SH([_Jc_${JAVAC}_Cp_${CLASSPATH}]) -AC_CACHE_CHECK([if the $1 class is available$xtra], [$cache_var], [ -JAVA_TEST=Test.java -CLASS_TEST=Test.class -cat << \EOF > $JAVA_TEST -/* [#]xline __oline__ "configure" */ -import $1; -public class Test { -} -EOF -if AC_TRY_COMMAND($JAVAC $JAVACFLAGS $xopts $JAVA_TEST) >/dev/null 2>&1; then - eval "${cache_var}=yes" -else - eval "${cache_var}=no" - echo "configure: failed program was:" >&AS_MESSAGE_LOG_FD - cat $JAVA_TEST >&AS_MESSAGE_LOG_FD -fi -rm -f $JAVA_TEST $CLASS_TEST -]) -if eval 'test "x$'${cache_var}'" = "xyes"'; then -$2 -true; else -$3 -false; fi]) diff --git a/vpp-japi/m4/ax_java_options.m4 b/vpp-japi/m4/ax_java_options.m4 deleted file mode 100644 index 36c10d92..00000000 --- a/vpp-japi/m4/ax_java_options.m4 +++ /dev/null @@ -1,48 +0,0 @@ -# =========================================================================== -# http://www.gnu.org/software/autoconf-archive/ax_java_options.html -# =========================================================================== -# -# SYNOPSIS -# -# AX_JAVA_OPTIONS -# -# DESCRIPTION -# -# AX_JAVA_OPTIONS adds configure command line options used for Java m4 -# macros. This Macro is optional. -# -# Note: This is part of the set of autoconf M4 macros for Java programs. -# It is VERY IMPORTANT that you download the whole set, some macros depend -# on other. Unfortunately, the autoconf archive does not support the -# concept of set of macros, so I had to break it for submission. The -# general documentation, as well as the sample configure.in, is included -# in the AX_PROG_JAVA macro. -# -# LICENSE -# -# Copyright (c) 2008 Devin Weaver -# -# Copying and distribution of this file, with or without modification, are -# permitted in any medium without royalty provided the copyright notice -# and this notice are preserved. This file is offered as-is, without any -# warranty. - -#serial 6 - -AU_ALIAS([AC_JAVA_OPTIONS], [AX_JAVA_OPTIONS]) -AC_DEFUN([AX_JAVA_OPTIONS],[ -AC_ARG_WITH(java-prefix, - [ --with-java-prefix=PFX prefix where Java runtime is installed (optional)]) -AC_ARG_WITH(javac-flags, - [ --with-javac-flags=FLAGS flags to pass to the Java compiler (optional)]) -AC_ARG_WITH(java-flags, - [ --with-java-flags=FLAGS flags to pass to the Java VM (optional)]) -JAVAPREFIX=$with_java_prefix -JAVACFLAGS=$with_javac_flags -JAVAFLAGS=$with_java_flags -AC_SUBST(JAVAPREFIX)dnl -AC_SUBST(JAVACFLAGS)dnl -AC_SUBST(JAVAFLAGS)dnl -AC_SUBST(JAVA)dnl -AC_SUBST(JAVAC)dnl -]) diff --git a/vpp-japi/m4/ax_libgcj_jar.m4 b/vpp-japi/m4/ax_libgcj_jar.m4 deleted file mode 100644 index 5e942857..00000000 --- a/vpp-japi/m4/ax_libgcj_jar.m4 +++ /dev/null @@ -1,83 +0,0 @@ -# =========================================================================== -# http://www.gnu.org/software/autoconf-archive/ax_libgcj_jar.html -# =========================================================================== -# -# SYNOPSIS -# -# AX_LIBGCJ_JAR -# -# DESCRIPTION -# -# Locate libgcj.jar so you can place it before everything else when using -# gcj. -# -# LICENSE -# -# Copyright (c) 2008 Duncan Simpson -# -# 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 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 . -# -# As a special exception, the respective Autoconf Macro's copyright owner -# gives unlimited permission to copy, distribute and modify the configure -# scripts that are the output of Autoconf when processing the Macro. You -# need not follow the terms of the GNU General Public License when using -# or distributing such scripts, even though portions of the text of the -# Macro appear in them. The GNU General Public License (GPL) does govern -# all other use of the material that constitutes the Autoconf Macro. -# -# This special exception to the GPL applies to versions of the Autoconf -# Macro released by the Autoconf Archive. When you make and distribute a -# modified version of the Autoconf Macro, you may extend this special -# exception to the GPL to apply to your modified version as well. - -#serial 9 - -AU_ALIAS([DPS_LIBGCJ_JAR], [AX_LIBGCJ_JAR]) -AC_DEFUN([AX_LIBGCJ_JAR], -[ -AC_REQUIRE([AC_EXEEXT]) -AC_REQUIRE([AX_PROG_JAVAC]) -AC_REQUIRE([AC_PROG_FGREP]) -AC_PROG_SED -if test "x$SED" = "x"; then -AC_MSG_WARN([sed not avaiable, so libgcj.jar test skipped]) -else -AC_MSG_CHECKING([if $JAVAC is gcj]); -jc=`eval "[echo x$JAVAC | $SED 's/^x.*\\/\\([^/]*\\)\$/x\\1/;s/^ *\\([^ ]*\\) .*$/\\1/;s/"$EXEEXT"$//']"` -if test "x$jc" != "xxgcj"; then -AC_MSG_RESULT(no) -else -AC_MSG_RESULT(yes) -AC_MSG_CHECKING([libgcj.jar location]) -save_cp="$CLASSPATH"; -unset CLASSPATH; -AC_MSG_CHECKING([gcj default classpath]) -cat << \EOF > Test.java -/* [#]line __oline__ "configure" */ -public class Test { -} -EOF -lgcj=`eval "[$JAVAC -v -C Test.java 2>&1 | $FGREP \\(system\\) | $SED 's/^ *\\([^ ]*\\) .*$/\\1/;s/\\.jar\\//.jar/']"`; -if test -f Test.class && test "x$lgcj" != "x"; then -AC_MSG_RESULT($lgcj) -$1="$lgcj:" -else -AC_MSG_RESULT(failed) -$1="" -fi -if test "x$save_cp" != "x"; then CLASSPATH="$save_cp"; fi -rm -f Test.java Test.class -fi -fi -]) diff --git a/vpp-japi/m4/ax_prog_jar.m4 b/vpp-japi/m4/ax_prog_jar.m4 deleted file mode 100644 index 3c60fcaf..00000000 --- a/vpp-japi/m4/ax_prog_jar.m4 +++ /dev/null @@ -1,49 +0,0 @@ -# =========================================================================== -# http://www.gnu.org/software/autoconf-archive/ax_prog_jar.html -# =========================================================================== -# -# SYNOPSIS -# -# AX_PROG_JAR -# -# DESCRIPTION -# -# AX_PROG_JAR tests for an existing jar program. It uses the environment -# variable JAR then tests in sequence various common jar programs. -# -# If you want to force a specific compiler: -# -# - at the configure.in level, set JAR=yourcompiler before calling -# AX_PROG_JAR -# -# - at the configure level, setenv JAR -# -# You can use the JAR variable in your Makefile.in, with @JAR@. -# -# Note: This macro depends on the autoconf M4 macros for Java programs. It -# is VERY IMPORTANT that you download that whole set, some macros depend -# on other. Unfortunately, the autoconf archive does not support the -# concept of set of macros, so I had to break it for submission. -# -# The general documentation of those macros, as well as the sample -# configure.in, is included in the AX_PROG_JAVA macro. -# -# LICENSE -# -# Copyright (c) 2008 Egon Willighagen -# -# Copying and distribution of this file, with or without modification, are -# permitted in any medium without royalty provided the copyright notice -# and this notice are preserved. This file is offered as-is, without any -# warranty. - -#serial 7 - -AU_ALIAS([AC_PROG_JAR], [AX_PROG_JAR]) -AC_DEFUN([AX_PROG_JAR],[ -AS_IF([test "x$JAVAPREFIX" = x], - [test "x$JAR" = x && AC_CHECK_PROGS([JAR], [jar])], - [test "x$JAR" = x && AC_CHECK_PROGS([JAR], [jar], [], [$JAVAPREFIX/bin])]) -test "x$JAR" = x && AC_MSG_ERROR([no acceptable jar program found in \$PATH]) -AC_PROVIDE([$0])dnl -]) diff --git a/vpp-japi/m4/ax_prog_java.m4 b/vpp-japi/m4/ax_prog_java.m4 deleted file mode 100644 index 03961db5..00000000 --- a/vpp-japi/m4/ax_prog_java.m4 +++ /dev/null @@ -1,115 +0,0 @@ -# =========================================================================== -# http://www.gnu.org/software/autoconf-archive/ax_prog_java.html -# =========================================================================== -# -# SYNOPSIS -# -# AX_PROG_JAVA -# -# DESCRIPTION -# -# Here is a summary of the main macros: -# -# AX_PROG_JAVAC: finds a Java compiler. -# -# AX_PROG_JAVA: finds a Java virtual machine. -# -# AX_CHECK_CLASS: finds if we have the given class (beware of CLASSPATH!). -# -# AX_CHECK_RQRD_CLASS: finds if we have the given class and stops -# otherwise. -# -# AX_TRY_COMPILE_JAVA: attempt to compile user given source. -# -# AX_TRY_RUN_JAVA: attempt to compile and run user given source. -# -# AX_JAVA_OPTIONS: adds Java configure options. -# -# AX_PROG_JAVA tests an existing Java virtual machine. It uses the -# environment variable JAVA then tests in sequence various common Java -# virtual machines. For political reasons, it starts with the free ones. -# You *must* call [AX_PROG_JAVAC] before. -# -# If you want to force a specific VM: -# -# - at the configure.in level, set JAVA=yourvm before calling AX_PROG_JAVA -# -# (but after AC_INIT) -# -# - at the configure level, setenv JAVA -# -# You can use the JAVA variable in your Makefile.in, with @JAVA@. -# -# *Warning*: its success or failure can depend on a proper setting of the -# CLASSPATH env. variable. -# -# TODO: allow to exclude virtual machines (rationale: most Java programs -# cannot run with some VM like kaffe). -# -# Note: This is part of the set of autoconf M4 macros for Java programs. -# It is VERY IMPORTANT that you download the whole set, some macros depend -# on other. Unfortunately, the autoconf archive does not support the -# concept of set of macros, so I had to break it for submission. -# -# A Web page, with a link to the latest CVS snapshot is at -# . -# -# This is a sample configure.in Process this file with autoconf to produce -# a configure script. -# -# AC_INIT(UnTag.java) -# -# dnl Checks for programs. -# AC_CHECK_CLASSPATH -# AX_PROG_JAVAC -# AX_PROG_JAVA -# -# dnl Checks for classes -# AX_CHECK_RQRD_CLASS(org.xml.sax.Parser) -# AX_CHECK_RQRD_CLASS(com.jclark.xml.sax.Driver) -# -# AC_OUTPUT(Makefile) -# -# LICENSE -# -# Copyright (c) 2008 Stephane Bortzmeyer -# -# 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 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 . -# -# As a special exception, the respective Autoconf Macro's copyright owner -# gives unlimited permission to copy, distribute and modify the configure -# scripts that are the output of Autoconf when processing the Macro. You -# need not follow the terms of the GNU General Public License when using -# or distributing such scripts, even though portions of the text of the -# Macro appear in them. The GNU General Public License (GPL) does govern -# all other use of the material that constitutes the Autoconf Macro. -# -# This special exception to the GPL applies to versions of the Autoconf -# Macro released by the Autoconf Archive. When you make and distribute a -# modified version of the Autoconf Macro, you may extend this special -# exception to the GPL to apply to your modified version as well. - -#serial 9 - -AU_ALIAS([AC_PROG_JAVA], [AX_PROG_JAVA]) -AC_DEFUN([AX_PROG_JAVA],[ -m4_define([m4_ax_prog_java_list], [kaffe java])dnl -AS_IF([test "x$JAVAPREFIX" = x], - [test x$JAVA = x && AC_CHECK_PROGS([JAVA], [m4_ax_prog_java_list])], - [test x$JAVA = x && AC_CHECK_PROGS([JAVA], [m4_ax_prog_java_list], [], [$JAVAPREFIX/bin])]) -test x$JAVA = x && AC_MSG_ERROR([no acceptable Java virtual machine found in \$PATH]) -m4_undefine([m4_ax_prog_java_list])dnl -AX_PROG_JAVA_WORKS -AC_PROVIDE([$0])dnl -]) diff --git a/vpp-japi/m4/ax_prog_java_cc.m4 b/vpp-japi/m4/ax_prog_java_cc.m4 deleted file mode 100644 index 3df064ff..00000000 --- a/vpp-japi/m4/ax_prog_java_cc.m4 +++ /dev/null @@ -1,104 +0,0 @@ -# =========================================================================== -# http://www.gnu.org/software/autoconf-archive/ax_prog_java_cc.html -# =========================================================================== -# -# SYNOPSIS -# -# AX_PROG_JAVA_CC -# -# DESCRIPTION -# -# Finds the appropriate java compiler on your path. By preference the java -# compiler is gcj, then jikes then javac. -# -# The macro can take one argument specifying a space separated list of -# java compiler names. -# -# For example: -# -# AX_PROG_JAVA_CC(javac, gcj) -# -# The macro also sets the compiler options variable: JAVA_CC_OPTS to -# something sensible: -# -# - for GCJ it sets it to: @GCJ_OPTS@ -# (if GCJ_OPTS is not yet defined then it is set to "-C") -# -# - no other compiler has applicable options yet -# -# Here's an example configure.in: -# -# AC_INIT(Makefile.in) -# AX_PROG_JAVA_CC() -# AC_OUTPUT(Makefile) -# dnl End. -# -# And here's the start of the Makefile.in: -# -# PROJECT_ROOT := @srcdir@ -# # Tool definitions. -# JAVAC := @JAVA_CC@ -# JAVAC_OPTS := @JAVA_CC_OPTS@ -# JAR_TOOL := @jar_tool@ -# -# LICENSE -# -# Copyright (c) 2008 Nic Ferrier -# -# 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 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 . -# -# As a special exception, the respective Autoconf Macro's copyright owner -# gives unlimited permission to copy, distribute and modify the configure -# scripts that are the output of Autoconf when processing the Macro. You -# need not follow the terms of the GNU General Public License when using -# or distributing such scripts, even though portions of the text of the -# Macro appear in them. The GNU General Public License (GPL) does govern -# all other use of the material that constitutes the Autoconf Macro. -# -# This special exception to the GPL applies to versions of the Autoconf -# Macro released by the Autoconf Archive. When you make and distribute a -# modified version of the Autoconf Macro, you may extend this special -# exception to the GPL to apply to your modified version as well. - -#serial 4 - -# AX_PROG_JAVA_CC([COMPILER ...]) -# -------------------------- -# COMPILER ... is a space separated list of java compilers to search for. -# This just gives the user an opportunity to specify an alternative -# search list for the java compiler. -AU_ALIAS([AC_PROG_JAVA_CC], [AX_PROG_JAVA_CC]) -AC_DEFUN([AX_PROG_JAVA_CC], -[AC_ARG_VAR([JAVA_CC], [java compiler command])dnl -AC_ARG_VAR([JAVA_CC_FLAGS], [java compiler flags])dnl -m4_ifval([$1], - [AC_CHECK_TOOLS(JAVA_CC, [$1])], -[AC_CHECK_TOOL(JAVA_CC, gcj) -if test -z "$JAVA_CC"; then - AC_CHECK_TOOL(JAVA_CC, javac) -fi -if test -z "$JAVA_CC"; then - AC_CHECK_TOOL(JAVA_CC, jikes) -fi -]) - -if test "$JAVA_CC" = "gcj"; then - if test "$GCJ_OPTS" = ""; then - AC_SUBST(GCJ_OPTS,-C) - fi - AC_SUBST(JAVA_CC_OPTS, @GCJ_OPTS@, - [Define the compilation options for GCJ]) -fi -test -z "$JAVA_CC" && AC_MSG_ERROR([no acceptable java compiler found in \$PATH]) -])# AX_PROG_JAVA_CC diff --git a/vpp-japi/m4/ax_prog_java_works.m4 b/vpp-japi/m4/ax_prog_java_works.m4 deleted file mode 100644 index 54e132af..00000000 --- a/vpp-japi/m4/ax_prog_java_works.m4 +++ /dev/null @@ -1,134 +0,0 @@ -# =========================================================================== -# http://www.gnu.org/software/autoconf-archive/ax_prog_java_works.html -# =========================================================================== -# -# SYNOPSIS -# -# AX_PROG_JAVA_WORKS -# -# DESCRIPTION -# -# Internal use ONLY. -# -# Note: This is part of the set of autoconf M4 macros for Java programs. -# It is VERY IMPORTANT that you download the whole set, some macros depend -# on other. Unfortunately, the autoconf archive does not support the -# concept of set of macros, so I had to break it for submission. The -# general documentation, as well as the sample configure.in, is included -# in the AX_PROG_JAVA macro. -# -# LICENSE -# -# Copyright (c) 2008 Stephane Bortzmeyer -# -# 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 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 . -# -# As a special exception, the respective Autoconf Macro's copyright owner -# gives unlimited permission to copy, distribute and modify the configure -# scripts that are the output of Autoconf when processing the Macro. You -# need not follow the terms of the GNU General Public License when using -# or distributing such scripts, even though portions of the text of the -# Macro appear in them. The GNU General Public License (GPL) does govern -# all other use of the material that constitutes the Autoconf Macro. -# -# This special exception to the GPL applies to versions of the Autoconf -# Macro released by the Autoconf Archive. When you make and distribute a -# modified version of the Autoconf Macro, you may extend this special -# exception to the GPL to apply to your modified version as well. - -#serial 9 - -AU_ALIAS([AC_PROG_JAVA_WORKS], [AX_PROG_JAVA_WORKS]) -AC_DEFUN([AX_PROG_JAVA_WORKS], [ -AC_PATH_PROG(UUDECODE, uudecode, [no]) -if test x$UUDECODE != xno; then -AC_CACHE_CHECK([if uudecode can decode base 64 file], ac_cv_prog_uudecode_base64, [ -dnl /** -dnl * Test.java: used to test if java compiler works. -dnl */ -dnl public class Test -dnl { -dnl -dnl public static void -dnl main( String[] argv ) -dnl { -dnl System.exit (0); -dnl } -dnl -dnl } -cat << \EOF > Test.uue -begin-base64 644 Test.class -yv66vgADAC0AFQcAAgEABFRlc3QHAAQBABBqYXZhL2xhbmcvT2JqZWN0AQAE -bWFpbgEAFihbTGphdmEvbGFuZy9TdHJpbmc7KVYBAARDb2RlAQAPTGluZU51 -bWJlclRhYmxlDAAKAAsBAARleGl0AQAEKEkpVgoADQAJBwAOAQAQamF2YS9s -YW5nL1N5c3RlbQEABjxpbml0PgEAAygpVgwADwAQCgADABEBAApTb3VyY2VG -aWxlAQAJVGVzdC5qYXZhACEAAQADAAAAAAACAAkABQAGAAEABwAAACEAAQAB -AAAABQO4AAyxAAAAAQAIAAAACgACAAAACgAEAAsAAQAPABAAAQAHAAAAIQAB -AAEAAAAFKrcAErEAAAABAAgAAAAKAAIAAAAEAAQABAABABMAAAACABQ= -==== -EOF -if $UUDECODE Test.uue; then - ac_cv_prog_uudecode_base64=yes -else - echo "configure: __oline__: uudecode had trouble decoding base 64 file 'Test.uue'" >&AS_MESSAGE_LOG_FD - echo "configure: failed file was:" >&AS_MESSAGE_LOG_FD - cat Test.uue >&AS_MESSAGE_LOG_FD - ac_cv_prog_uudecode_base64=no -fi -rm -f Test.uue]) -fi -if test x$ac_cv_prog_uudecode_base64 != xyes; then - rm -f Test.class - AC_MSG_WARN([I have to compile Test.class from scratch]) - if test x$ac_cv_prog_javac_works = xno; then - AC_MSG_ERROR([Cannot compile java source. $JAVAC does not work properly]) - fi - if test x$ac_cv_prog_javac_works = x; then - AX_PROG_JAVAC - fi -fi -AC_CACHE_CHECK(if $JAVA works, ac_cv_prog_java_works, [ -JAVA_TEST=Test.java -CLASS_TEST=Test.class -TEST=Test -changequote(, )dnl -cat << \EOF > $JAVA_TEST -/* [#]line __oline__ "configure" */ -public class Test { -public static void main (String args[]) { - System.exit (0); -} } -EOF -changequote([, ])dnl -if test x$ac_cv_prog_uudecode_base64 != xyes; then - if AC_TRY_COMMAND($JAVAC $JAVACFLAGS $JAVA_TEST) && test -s $CLASS_TEST; then - : - else - echo "configure: failed program was:" >&AS_MESSAGE_LOG_FD - cat $JAVA_TEST >&AS_MESSAGE_LOG_FD - AC_MSG_ERROR(The Java compiler $JAVAC failed (see config.log, check the CLASSPATH?)) - fi -fi -if AC_TRY_COMMAND($JAVA -classpath . $JAVAFLAGS $TEST) >/dev/null 2>&1; then - ac_cv_prog_java_works=yes -else - echo "configure: failed program was:" >&AS_MESSAGE_LOG_FD - cat $JAVA_TEST >&AS_MESSAGE_LOG_FD - AC_MSG_ERROR(The Java VM $JAVA failed (see config.log, check the CLASSPATH?)) -fi -rm -fr $JAVA_TEST $CLASS_TEST Test.uue -]) -AC_PROVIDE([$0])dnl -] -) diff --git a/vpp-japi/m4/ax_prog_javac.m4 b/vpp-japi/m4/ax_prog_javac.m4 deleted file mode 100644 index d061243c..00000000 --- a/vpp-japi/m4/ax_prog_javac.m4 +++ /dev/null @@ -1,79 +0,0 @@ -# =========================================================================== -# http://www.gnu.org/software/autoconf-archive/ax_prog_javac.html -# =========================================================================== -# -# SYNOPSIS -# -# AX_PROG_JAVAC -# -# DESCRIPTION -# -# AX_PROG_JAVAC tests an existing Java compiler. It uses the environment -# variable JAVAC then tests in sequence various common Java compilers. For -# political reasons, it starts with the free ones. -# -# If you want to force a specific compiler: -# -# - at the configure.in level, set JAVAC=yourcompiler before calling -# AX_PROG_JAVAC -# -# - at the configure level, setenv JAVAC -# -# You can use the JAVAC variable in your Makefile.in, with @JAVAC@. -# -# *Warning*: its success or failure can depend on a proper setting of the -# CLASSPATH env. variable. -# -# TODO: allow to exclude compilers (rationale: most Java programs cannot -# compile with some compilers like guavac). -# -# Note: This is part of the set of autoconf M4 macros for Java programs. -# It is VERY IMPORTANT that you download the whole set, some macros depend -# on other. Unfortunately, the autoconf archive does not support the -# concept of set of macros, so I had to break it for submission. The -# general documentation, as well as the sample configure.in, is included -# in the AX_PROG_JAVA macro. -# -# LICENSE -# -# Copyright (c) 2008 Stephane Bortzmeyer -# -# 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 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 . -# -# As a special exception, the respective Autoconf Macro's copyright owner -# gives unlimited permission to copy, distribute and modify the configure -# scripts that are the output of Autoconf when processing the Macro. You -# need not follow the terms of the GNU General Public License when using -# or distributing such scripts, even though portions of the text of the -# Macro appear in them. The GNU General Public License (GPL) does govern -# all other use of the material that constitutes the Autoconf Macro. -# -# This special exception to the GPL applies to versions of the Autoconf -# Macro released by the Autoconf Archive. When you make and distribute a -# modified version of the Autoconf Macro, you may extend this special -# exception to the GPL to apply to your modified version as well. - -#serial 7 - -AU_ALIAS([AC_PROG_JAVAC], [AX_PROG_JAVAC]) -AC_DEFUN([AX_PROG_JAVAC],[ -m4_define([m4_ax_prog_javac_list],["gcj -C" guavac jikes javac])dnl -AS_IF([test "x$JAVAPREFIX" = x], - [test "x$JAVAC" = x && AC_CHECK_PROGS([JAVAC], [m4_ax_prog_javac_list])], - [test "x$JAVAC" = x && AC_CHECK_PROGS([JAVAC], [m4_ax_prog_javac_list], [], [$JAVAPREFIX/bin])]) -m4_undefine([m4_ax_prog_javac_list])dnl -test "x$JAVAC" = x && AC_MSG_ERROR([no acceptable Java compiler found in \$PATH]) -AX_PROG_JAVAC_WORKS -AC_PROVIDE([$0])dnl -]) diff --git a/vpp-japi/m4/ax_prog_javac_works.m4 b/vpp-japi/m4/ax_prog_javac_works.m4 deleted file mode 100644 index 7dfa1e37..00000000 --- a/vpp-japi/m4/ax_prog_javac_works.m4 +++ /dev/null @@ -1,72 +0,0 @@ -# =========================================================================== -# http://www.gnu.org/software/autoconf-archive/ax_prog_javac_works.html -# =========================================================================== -# -# SYNOPSIS -# -# AX_PROG_JAVAC_WORKS -# -# DESCRIPTION -# -# Internal use ONLY. -# -# Note: This is part of the set of autoconf M4 macros for Java programs. -# It is VERY IMPORTANT that you download the whole set, some macros depend -# on other. Unfortunately, the autoconf archive does not support the -# concept of set of macros, so I had to break it for submission. The -# general documentation, as well as the sample configure.in, is included -# in the AX_PROG_JAVA macro. -# -# LICENSE -# -# Copyright (c) 2008 Stephane Bortzmeyer -# -# 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 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 . -# -# As a special exception, the respective Autoconf Macro's copyright owner -# gives unlimited permission to copy, distribute and modify the configure -# scripts that are the output of Autoconf when processing the Macro. You -# need not follow the terms of the GNU General Public License when using -# or distributing such scripts, even though portions of the text of the -# Macro appear in them. The GNU General Public License (GPL) does govern -# all other use of the material that constitutes the Autoconf Macro. -# -# This special exception to the GPL applies to versions of the Autoconf -# Macro released by the Autoconf Archive. When you make and distribute a -# modified version of the Autoconf Macro, you may extend this special -# exception to the GPL to apply to your modified version as well. - -#serial 6 - -AU_ALIAS([AC_PROG_JAVAC_WORKS], [AX_PROG_JAVAC_WORKS]) -AC_DEFUN([AX_PROG_JAVAC_WORKS],[ -AC_CACHE_CHECK([if $JAVAC works], ac_cv_prog_javac_works, [ -JAVA_TEST=Test.java -CLASS_TEST=Test.class -cat << \EOF > $JAVA_TEST -/* [#]line __oline__ "configure" */ -public class Test { -} -EOF -if AC_TRY_COMMAND($JAVAC $JAVACFLAGS $JAVA_TEST) >/dev/null 2>&1; then - ac_cv_prog_javac_works=yes -else - AC_MSG_ERROR([The Java compiler $JAVAC failed (see config.log, check the CLASSPATH?)]) - echo "configure: failed program was:" >&AS_MESSAGE_LOG_FD - cat $JAVA_TEST >&AS_MESSAGE_LOG_FD -fi -rm -f $JAVA_TEST $CLASS_TEST -]) -AC_PROVIDE([$0])dnl -]) diff --git a/vpp-japi/m4/ax_prog_javadoc.m4 b/vpp-japi/m4/ax_prog_javadoc.m4 deleted file mode 100644 index bcb6045a..00000000 --- a/vpp-japi/m4/ax_prog_javadoc.m4 +++ /dev/null @@ -1,50 +0,0 @@ -# =========================================================================== -# http://www.gnu.org/software/autoconf-archive/ax_prog_javadoc.html -# =========================================================================== -# -# SYNOPSIS -# -# AX_PROG_JAVADOC -# -# DESCRIPTION -# -# AX_PROG_JAVADOC tests for an existing javadoc generator. It uses the -# environment variable JAVADOC then tests in sequence various common -# javadoc generator. -# -# If you want to force a specific compiler: -# -# - at the configure.in level, set JAVADOC=yourgenerator before calling -# AX_PROG_JAVADOC -# -# - at the configure level, setenv JAVADOC -# -# You can use the JAVADOC variable in your Makefile.in, with @JAVADOC@. -# -# Note: This macro depends on the autoconf M4 macros for Java programs. It -# is VERY IMPORTANT that you download that whole set, some macros depend -# on other. Unfortunately, the autoconf archive does not support the -# concept of set of macros, so I had to break it for submission. -# -# The general documentation of those macros, as well as the sample -# configure.in, is included in the AX_PROG_JAVA macro. -# -# LICENSE -# -# Copyright (c) 2008 Egon Willighagen -# -# Copying and distribution of this file, with or without modification, are -# permitted in any medium without royalty provided the copyright notice -# and this notice are preserved. This file is offered as-is, without any -# warranty. - -#serial 8 - -AU_ALIAS([AC_PROG_JAVADOC], [AX_PROG_JAVADOC]) -AC_DEFUN([AX_PROG_JAVADOC],[ -AS_IF([test "x$JAVAPREFIX" = x], - [test "x$JAVADOC" = x && AC_CHECK_PROGS([JAVADOC], [javadoc])], - [test "x$JAVADOC" = x && AC_CHECK_PROGS([JAVADOC], [javadoc], [], [$JAVAPREFIX/bin])]) -test "x$JAVADOC" = x && AC_MSG_ERROR([no acceptable javadoc generator found in \$PATH]) -AC_PROVIDE([$0])dnl -]) diff --git a/vpp-japi/m4/ax_prog_javah.m4 b/vpp-japi/m4/ax_prog_javah.m4 deleted file mode 100644 index cefc616d..00000000 --- a/vpp-japi/m4/ax_prog_javah.m4 +++ /dev/null @@ -1,64 +0,0 @@ -# =========================================================================== -# http://www.gnu.org/software/autoconf-archive/ax_prog_javah.html -# =========================================================================== -# -# SYNOPSIS -# -# AX_PROG_JAVAH -# -# DESCRIPTION -# -# AX_PROG_JAVAH tests the availability of the javah header generator and -# looks for the jni.h header file. If available, JAVAH is set to the full -# path of javah and CPPFLAGS is updated accordingly. -# -# LICENSE -# -# Copyright (c) 2008 Luc Maisonobe -# -# Copying and distribution of this file, with or without modification, are -# permitted in any medium without royalty provided the copyright notice -# and this notice are preserved. This file is offered as-is, without any -# warranty. - -#serial 8 - -AU_ALIAS([AC_PROG_JAVAH], [AX_PROG_JAVAH]) -AC_DEFUN([AX_PROG_JAVAH],[ -AC_REQUIRE([AC_CANONICAL_BUILD])dnl -AC_REQUIRE([AC_PROG_CPP])dnl -AC_PATH_PROG(JAVAH,javah) -AS_IF([test -n "$ac_cv_path_JAVAH"], - [ - AC_TRY_CPP([#include ],,[ - ac_save_CPPFLAGS="$CPPFLAGS" - _ACJAVAH_FOLLOW_SYMLINKS("$ac_cv_path_JAVAH") - ax_prog_javah_bin_dir=`AS_DIRNAME([$_ACJAVAH_FOLLOWED])` - ac_dir="`AS_DIRNAME([$ax_prog_javah_bin_dir])`/include" - AS_CASE([$build_os], - [cygwin*], - [ac_machdep=win32], - [ac_machdep=`AS_ECHO($build_os) | sed 's,[[-0-9]].*,,'`]) - CPPFLAGS="$ac_save_CPPFLAGS -I$ac_dir -I$ac_dir/$ac_machdep" - AC_TRY_CPP([#include ], - ac_save_CPPFLAGS="$CPPFLAGS", - AC_MSG_WARN([unable to include ])) - CPPFLAGS="$ac_save_CPPFLAGS"]) - ]) -]) - -AC_DEFUN([_ACJAVAH_FOLLOW_SYMLINKS],[ -# find the include directory relative to the javac executable -_cur="$1" -while ls -ld "$_cur" 2>/dev/null | grep " -> " >/dev/null; do - AC_MSG_CHECKING([symlink for $_cur]) - _slink=`ls -ld "$_cur" | sed 's/.* -> //'` - case "$_slink" in - /*) _cur="$_slink";; - # 'X' avoids triggering unwanted echo options. - *) _cur=`echo "X$_cur" | sed -e 's/^X//' -e 's:[[^/]]*$::'`"$_slink";; - esac - AC_MSG_RESULT([$_cur]) -done -_ACJAVAH_FOLLOWED="$_cur" -]) diff --git a/vpp-japi/m4/ax_try_compile_java.m4 b/vpp-japi/m4/ax_try_compile_java.m4 deleted file mode 100644 index a8ed6b2a..00000000 --- a/vpp-japi/m4/ax_try_compile_java.m4 +++ /dev/null @@ -1,55 +0,0 @@ -# =========================================================================== -# http://www.gnu.org/software/autoconf-archive/ax_try_compile_java.html -# =========================================================================== -# -# SYNOPSIS -# -# AX_TRY_COMPILE_JAVA -# -# DESCRIPTION -# -# AX_TRY_COMPILE_JAVA attempt to compile user given source. -# -# *Warning*: its success or failure can depend on a proper setting of the -# CLASSPATH env. variable. -# -# Note: This is part of the set of autoconf M4 macros for Java programs. -# It is VERY IMPORTANT that you download the whole set, some macros depend -# on other. Unfortunately, the autoconf archive does not support the -# concept of set of macros, so I had to break it for submission. The -# general documentation, as well as the sample configure.in, is included -# in the AX_PROG_JAVA macro. -# -# LICENSE -# -# Copyright (c) 2008 Devin Weaver -# -# Copying and distribution of this file, with or without modification, are -# permitted in any medium without royalty provided the copyright notice -# and this notice are preserved. This file is offered as-is, without any -# warranty. - -#serial 8 - -AU_ALIAS([AC_TRY_COMPILE_JAVA], [AX_TRY_COMPILE_JAVA]) -AC_DEFUN([AX_TRY_COMPILE_JAVA],[ -AC_REQUIRE([AX_PROG_JAVAC])dnl -cat << \EOF > Test.java -/* [#]line __oline__ "configure" */ -ifelse([$1], , , [import $1;]) -public class Test { -[$2] -} -EOF -if AC_TRY_COMMAND($JAVAC $JAVACFLAGS Test.java) && test -s Test.class -then -dnl Don't remove the temporary files here, so they can be examined. - ifelse([$3], , :, [$3]) -else - echo "configure: failed program was:" >&AS_MESSAGE_LOG_FD - cat Test.java >&AS_MESSAGE_LOG_FD -ifelse([$4], , , [ rm -fr Test.java Test.class - $4 -])dnl -fi -rm -fr Test.java Test.class]) diff --git a/vpp-japi/m4/ax_try_run_java.m4 b/vpp-japi/m4/ax_try_run_java.m4 deleted file mode 100644 index c680f03f..00000000 --- a/vpp-japi/m4/ax_try_run_java.m4 +++ /dev/null @@ -1,56 +0,0 @@ -# =========================================================================== -# http://www.gnu.org/software/autoconf-archive/ax_try_run_java.html -# =========================================================================== -# -# SYNOPSIS -# -# AX_TRY_RUN_JAVA -# -# DESCRIPTION -# -# AX_TRY_RUN_JAVA attempt to compile and run user given source. -# -# *Warning*: its success or failure can depend on a proper setting of the -# CLASSPATH env. variable. -# -# Note: This is part of the set of autoconf M4 macros for Java programs. -# It is VERY IMPORTANT that you download the whole set, some macros depend -# on other. Unfortunately, the autoconf archive does not support the -# concept of set of macros, so I had to break it for submission. The -# general documentation, as well as the sample configure.in, is included -# in the AX_PROG_JAVA macro. -# -# LICENSE -# -# Copyright (c) 2008 Devin Weaver -# -# Copying and distribution of this file, with or without modification, are -# permitted in any medium without royalty provided the copyright notice -# and this notice are preserved. This file is offered as-is, without any -# warranty. - -#serial 2 - -AU_ALIAS([AC_TRY_RUN_JAVA], [AX_TRY_RUN_JAVA]) -AC_DEFUN([AX_TRY_RUN_JAVA],[ -AC_REQUIRE([AX_PROG_JAVAC])dnl -AC_REQUIRE([AX_PROG_JAVA])dnl -cat << \EOF > Test.java -/* [#]line __oline__ "configure" */ -ifelse([$1], , , [include $1;]) -public class Test { -[$2] -} -EOF -if AC_TRY_COMMAND($JAVAC $JAVACFLAGS Test.java) && test -s Test.class && ($JAVA $JAVAFLAGS Test; exit) 2>/dev/null -then -dnl Don't remove the temporary files here, so they can be examined. - ifelse([$3], , :, [$3]) -else - echo "configure: failed program was:" >&AS_MESSAGE_LOG_FD - cat Test.java >&AS_MESSAGE_LOG_FD -ifelse([$4], , , [ rm -fr Test.java Test.class - $4 -])dnl -fi -rm -fr Test.java Test.class]) diff --git a/vpp/api/api.c b/vpp/api/api.c index b47214f0..cf2b8f44 100644 --- a/vpp/api/api.c +++ b/vpp/api/api.c @@ -5365,8 +5365,8 @@ vl_api_map_domain_dump_t_handler } pool_foreach(d, mm->domains, ({ + /* Make sure every field is initiated (or don't skip the memset()) */ rmp = vl_msg_api_alloc (sizeof (*rmp)); - memset (rmp, 0, sizeof (*rmp)); rmp->_vl_msg_id = ntohs(VL_API_MAP_DOMAIN_DETAILS); rmp->domain_index = htonl(d - mm->domains); rmp->ea_bits_len = d->ea_bits_len; @@ -5462,15 +5462,15 @@ vl_api_map_summary_stats_t_handler ( map_domain_counter_unlock (mm); - /* Note: in HOST byte order! */ - rmp->total_pkts[MAP_DOMAIN_COUNTER_RX] = total_pkts[MAP_DOMAIN_COUNTER_RX]; - rmp->total_bytes[MAP_DOMAIN_COUNTER_RX] = total_bytes[MAP_DOMAIN_COUNTER_RX]; - rmp->total_pkts[MAP_DOMAIN_COUNTER_TX] = total_pkts[MAP_DOMAIN_COUNTER_TX]; - rmp->total_bytes[MAP_DOMAIN_COUNTER_TX] = total_bytes[MAP_DOMAIN_COUNTER_TX]; - rmp->total_bindings = pool_elts(mm->domains); + /* Note: in network byte order! */ + rmp->total_pkts[MAP_DOMAIN_COUNTER_RX] = clib_host_to_net_u64(total_pkts[MAP_DOMAIN_COUNTER_RX]); + rmp->total_bytes[MAP_DOMAIN_COUNTER_RX] = clib_host_to_net_u64(total_bytes[MAP_DOMAIN_COUNTER_RX]); + rmp->total_pkts[MAP_DOMAIN_COUNTER_TX] = clib_host_to_net_u64(total_pkts[MAP_DOMAIN_COUNTER_TX]); + rmp->total_bytes[MAP_DOMAIN_COUNTER_TX] = clib_host_to_net_u64(total_bytes[MAP_DOMAIN_COUNTER_TX]); + rmp->total_bindings = clib_host_to_net_u64(pool_elts(mm->domains)); rmp->total_ip4_fragments = 0; // Not yet implemented. Should be a simple counter. - rmp->total_security_check[MAP_DOMAIN_COUNTER_TX] = map_error_counter_get(ip4_map_node.index, MAP_ERROR_ENCAP_SEC_CHECK); - rmp->total_security_check[MAP_DOMAIN_COUNTER_RX] = map_error_counter_get(ip4_map_node.index, MAP_ERROR_DECAP_SEC_CHECK); + rmp->total_security_check[MAP_DOMAIN_COUNTER_TX] = clib_host_to_net_u64(map_error_counter_get(ip4_map_node.index, MAP_ERROR_ENCAP_SEC_CHECK)); + rmp->total_security_check[MAP_DOMAIN_COUNTER_RX] = clib_host_to_net_u64(map_error_counter_get(ip4_map_node.index, MAP_ERROR_DECAP_SEC_CHECK)); vl_msg_api_send_shmem(q, (u8 *)&rmp); } diff --git a/vppapigen/lex.c b/vppapigen/lex.c index b41eb5ec..f1d49a87 100644 --- a/vppapigen/lex.c +++ b/vppapigen/lex.c @@ -28,7 +28,7 @@ #include "node.h" #include "gram.h" -FILE *ifp, *ofp, *javafp, *jnifp; +FILE *ifp, *ofp, *javafp, *jnifp, *pythonfp; char *java_class = "vppApi"; char *vlib_app_name = "vpp"; int dump_tree; @@ -260,6 +260,7 @@ int main (int argc, char **argv) char *ofile=0; char *jofile=0; char *jnifile=0; + char *pythonfile=0; char *show_name=0; while (curarg < argc) { @@ -364,6 +365,23 @@ int main (int argc, char **argv) } continue; } + if (!strncmp (argv [curarg], "--python", 8)) { + curarg++; + if (curarg < argc) { + pythonfp = fopen (argv[curarg], "w"); + if (pythonfp == NULL) { + fprintf (stderr, "Couldn't open python output file %s\n", + argv[curarg]); + exit (1); + } + pythonfile = argv[curarg]; + curarg++; + } else { + fprintf(stderr, "Missing filename after --python\n"); + exit(1); + } + continue; + } if (!strncmp (argv [curarg], "--app", 4)) { curarg++; if (curarg < argc) { @@ -399,6 +417,9 @@ int main (int argc, char **argv) if (jnifp == NULL) { jnifile = 0; } + if (pythonfp == NULL) { + pythonfile = 0; + } if (ifp == NULL) { fprintf(stderr, "No input file specified...\n"); exit(1); @@ -424,6 +445,10 @@ int main (int argc, char **argv) printf ("Java native bindings written to %s\n", jnifile); fclose (jnifp); } + if (pythonfile) { + printf ("Python bindings written to %s\n", pythonfile); + fclose (pythonfp); + } } else { fclose (ifp); @@ -441,6 +466,10 @@ int main (int argc, char **argv) printf ("Removing %s\n", jnifile); unlink (jnifile); } + if (pythonfile) { + printf ("Removing %s\n", pythonfile); + unlink (pythonfile); + } exit (1); } exit (0); @@ -452,7 +481,7 @@ int main (int argc, char **argv) static void usage (char *progname) { fprintf (stderr, - "usage: %s --input [--output ]\n%s", + "usage: %s --input [--output ] [--python ]\n%s", progname, " [--yydebug] [--dump-tree]\n"); exit (1); diff --git a/vppapigen/node.c b/vppapigen/node.c index 3a32abec..ffe5d77e 100644 --- a/vppapigen/node.c +++ b/vppapigen/node.c @@ -34,6 +34,7 @@ FILE *ofp; FILE *javafp; FILE *jnifp; +FILE *pythonfp; char *java_class; time_t starttime; char *vlib_app_name; @@ -161,6 +162,12 @@ void primtype_recursive_generate(node_t *this, enum passid which, FILE *ofp, current_java_methodfun = vftp->java_method_function; break; + case PYTHON_PASS: + fputs("('", pythonfp); + fputs((char *)type_name, pythonfp); + fputs("', ", pythonfp); + break; + default: fprintf(stderr, "primtype_recursive_generate: unimp pass %d\n", which); break; @@ -876,6 +883,20 @@ void node_define_generate (node_t *this, enum passid which, FILE *fp) fprintf (fp, "}\n\n"); break; + case PYTHON_PASS: + fprintf(fp, "('%s',\n", CDATA0); + child = this->deeper; + indent += 4; + while (child) { + node_vft_t *vftp = the_vft[child->type]; + indent_me(fp); + vftp->generate(child, which, fp); + child = child->peer; + } + indent -= 4; + fprintf(fp, "),\n\n"); + break; + default: fprintf(stderr, "node_define_generate: unimp pass %d\n", which); break; @@ -1032,6 +1053,9 @@ void node_scalar_generate (node_t *this, enum passid which, FILE *fp) } } break; + case PYTHON_PASS: + fprintf(fp, "'%s'),\n", CDATA0); + break; default: fprintf(stderr, "node_scalar_generate: unimp pass %d\n", which); @@ -1136,6 +1160,9 @@ void node_vector_generate (node_t *this, enum passid which, FILE *fp) indent_me(fp); fprintf(fp, "}\n"); break; + case PYTHON_PASS: + fprintf(fp, "'%s', '%d'),\n", CDATA0, IDATA1); + break; default: fprintf(stderr, "node_vector_generate: unimp pass %d\n", which); @@ -1216,6 +1243,14 @@ void node_complex_generate (node_t *this, enum passid which, FILE *fp) fprintf(fp, "%s_endian(&a->%s%s);\n", CDATA0, union_prefix, member_name); break; + case PYTHON_PASS: + fprintf(fp, "('%s',", CDATA0); + deeper = this->deeper; + if (deeper) { + vftp = the_vft[deeper->type]; + vftp->generate(deeper, which, fp); + } + break; default: fprintf(stderr, "node_complex_generate unimp pass %d...\n", which); @@ -1767,14 +1802,14 @@ void add_msg_ids(YYSTYPE a1) while (np) { if (np->type == NODE_DEFINE) { if (!(np->flags & NODE_FLAG_TYPEONLY)) { - /* add the parse tree for "u16 _vl_msg_id" */ + /* add the parse tree for "u16 _vl_msg_id" */ new_u16 = make_node(NODE_U16); new_u16->peer = np->deeper; np->deeper = new_u16; new_vbl = make_node(NODE_SCALAR); new_vbl->data[0] = sxerox("_vl_msg_id"); new_u16->deeper = new_vbl; - } + } } np = np->peer; } @@ -1988,6 +2023,23 @@ void generate_jni_bottom_boilerplate(FILE *fp) fputs (hookup_boilerplate, fp); } +void generate_python (YYSTYPE a1, FILE *fp) +{ + node_t *np = (node_t *)a1; + node_vft_t *vftp; + fprintf (fp, "vppapidef = [\n"); + /* Walk the top-level node-list */ + while (np) { + if (np->type == NODE_DEFINE && !(np->flags & NODE_FLAG_TYPEONLY)) { + /* Yeah, this is pedantic */ + vftp = the_vft[np->type]; + vftp->generate(np, PYTHON_PASS, fp); + } + np = np->peer; + } + fprintf (fp, "\n]\n"); +} + void generate(YYSTYPE a1) { if (dump_tree) { @@ -2020,4 +2072,7 @@ void generate(YYSTYPE a1) generate_jni_code(a1, jnifp); generate_jni_bottom_boilerplate(jnifp); } + if (pythonfp) { + generate_python(a1, pythonfp); + } } diff --git a/vppapigen/node.h b/vppapigen/node.h index 670b5aff..1f5a153c 100644 --- a/vppapigen/node.h +++ b/vppapigen/node.h @@ -63,6 +63,7 @@ enum passid { PRINTFUN_PASS, JAVA_METHOD_PASS, JAVA_JNI_PASS, + PYTHON_PASS, }; extern void *make_node (enum node_subclass type); -- cgit 1.2.3-korg From 1c80e831b728ab378949714d5059a0b5b1822a0a Mon Sep 17 00:00:00 2001 From: Damjan Marion Date: Wed, 11 May 2016 23:07:18 +0200 Subject: Add support for multiple microarchitectures in single binary * compiler -march= parameter is changed from native to corei7 so code is always genereted with instructions which are available on the Nehalem microarchitecture (up to SSE4.2) * compiler -mtune= parameter is added so code is optimized for corei7-avx which equals to Sandy Bridge microarchitecture * set of macros is added which allows run-time detection of available cpu instructions (e.g. clib_cpu_supports_avx()) * set of macros is added which allows us to clone graph node funcitons where cloned function is optmized for different microarchitecture Those macros are using following attributes: __attribute__((flatten)) __attribute__((target("arch=core-avx2))) I.e. If applied to foo_node_fn() macro will generate cloned functions foo_node_fn_avx2() and foo_node_fn_avx512() (future) It will also generate function void * foo_node_fn_multiarch_select() which detects available instruction set and returns pointer to the best matching function clone. Change-Id: I2dce0ac92a5ede95fcb56f47f3d1f3c4c040bac0 Signed-off-by: Damjan Marion --- build-data/packages/dpdk.mk | 6 +++ build-data/platforms/vpp.mk | 7 +++- build-data/platforms/vpp_lite.mk | 6 ++- build-root/Makefile | 5 +++ dpdk/Makefile | 3 +- vlib/vlib/node.h | 27 ++++++++++++ vnet/vnet/classify/ip_classify.c | 4 ++ vnet/vnet/cop/ip4_whitelist.c | 2 + vnet/vnet/cop/ip6_whitelist.c | 2 + vnet/vnet/cop/node1.c | 2 + vnet/vnet/devices/af_packet/device.c | 3 ++ vnet/vnet/devices/af_packet/node.c | 4 +- vnet/vnet/devices/dpdk/cli.c | 8 ++++ vnet/vnet/devices/dpdk/device.c | 3 ++ vnet/vnet/devices/dpdk/dpdk.h | 5 ++- vnet/vnet/devices/dpdk/init.c | 8 ++-- vnet/vnet/devices/dpdk/node.c | 50 +++++++++++++++++++--- vnet/vnet/devices/netmap/device.c | 3 ++ vnet/vnet/devices/netmap/node.c | 3 +- vnet/vnet/devices/ssvm/node.c | 2 + vnet/vnet/devices/ssvm/ssvm_eth.c | 3 ++ vnet/vnet/devices/virtio/vhost-user.c | 5 +++ vnet/vnet/ethernet/node.c | 6 +++ vnet/vnet/gre/gre.c | 3 ++ vnet/vnet/gre/node.c | 2 + vnet/vnet/interface.h | 26 ++++++++++++ vnet/vnet/interface_output.c | 6 +++ vnet/vnet/ip/ip4_forward.c | 18 ++++++++ vnet/vnet/ip/ip4_hop_by_hop.c | 2 + vnet/vnet/ip/ip4_input.c | 4 ++ vnet/vnet/ip/ip4_source_check.c | 6 +++ vnet/vnet/ip/ip6_forward.c | 16 +++++++ vnet/vnet/ip/ip6_hop_by_hop.c | 5 +++ vnet/vnet/ip/ip6_input.c | 2 + vnet/vnet/ip/ip_input_acl.c | 4 ++ vnet/vnet/ip/udp_local.c | 4 ++ vnet/vnet/ipsec/esp_decrypt.c | 2 + vnet/vnet/ipsec/esp_encrypt.c | 2 + vnet/vnet/ipsec/ipsec_if_in.c | 5 ++- vnet/vnet/ipsec/ipsec_if_out.c | 2 + vnet/vnet/ipsec/ipsec_input.c | 7 ++++ vnet/vnet/ipsec/ipsec_output.c | 2 + vnet/vnet/l2/l2_classify.c | 2 + vnet/vnet/l2/l2_efp_filter.c | 2 + vnet/vnet/l2/l2_flood.c | 2 + vnet/vnet/l2/l2_fwd.c | 2 + vnet/vnet/l2/l2_input.c | 2 + vnet/vnet/l2/l2_input_acl.c | 2 + vnet/vnet/l2/l2_input_vtr.c | 2 + vnet/vnet/l2/l2_learn.c | 1 + vnet/vnet/l2/l2_output.c | 2 + vnet/vnet/l2/l2_output_acl.c | 2 + vnet/vnet/l2/l2_patch.c | 2 + vnet/vnet/l2/l2_rw.c | 2 + vnet/vnet/l2/l2_xcrw.c | 2 + vnet/vnet/l2tp/decap.c | 2 + vnet/vnet/l2tp/encap.c | 2 + vnet/vnet/lawful-intercept/node.c | 2 + vnet/vnet/mpls-gre/interface.c | 7 ++++ vnet/vnet/mpls-gre/node.c | 4 ++ vnet/vnet/mpls-gre/policy_encap.c | 2 + vnet/vnet/policer/node_funcs.c | 3 ++ vnet/vnet/sr/sr.c | 6 +++ vnet/vnet/sr/sr_replicate.c | 2 + vnet/vnet/vxlan/decap.c | 5 +++ vnet/vnet/vxlan/encap.c | 3 ++ vpp/app/l2t_ip6.c | 2 + vpp/app/l2t_l2.c | 2 + vpp/app/version.c | 1 + vpp/vnet/main.c | 19 +++++---- vppinfra/vppinfra/cpu.c | 23 ++++++++--- vppinfra/vppinfra/cpu.h | 78 ++++++++++++++++++++++++++++++++++- 72 files changed, 439 insertions(+), 34 deletions(-) (limited to 'build-data/platforms/vpp.mk') diff --git a/build-data/packages/dpdk.mk b/build-data/packages/dpdk.mk index 2bfc4b49..0a4c1610 100644 --- a/build-data/packages/dpdk.mk +++ b/build-data/packages/dpdk.mk @@ -4,6 +4,11 @@ ifeq ($(DPDK_MARCH),) DPDK_MARCH="native" endif +DPDK_TUNE = $(strip $($(PLATFORM)_mtune)) +ifeq ($(DPDK_TUNE),) + DPDK_MARCH="generic" +endif + ifneq (,$(findstring debug,$(TAG))) DPDK_DEBUG=y else @@ -14,6 +19,7 @@ DPDK_MAKE_ARGS = -C $(call find_source_fn,$(PACKAGE_SOURCE)) \ DPDK_BUILD_DIR=$(PACKAGE_BUILD_DIR) \ DPDK_INSTALL_DIR=$(PACKAGE_INSTALL_DIR) \ DPDK_MARCH=$(DPDK_MARCH) \ + DPDK_TUNE=$(DPDK_TUNE) \ DPDK_DEBUG=$(DPDK_DEBUG) diff --git a/build-data/platforms/vpp.mk b/build-data/platforms/vpp.mk index c381be19..ec0d874d 100644 --- a/build-data/platforms/vpp.mk +++ b/build-data/platforms/vpp.mk @@ -13,6 +13,9 @@ # vector packet processor vpp_arch = native +vpp_march = corei7 # Nehalem Instruction set +vpp_mtune = corei7-avx # Optimize for Sandy Bridge +vpp_dpdk_arch = corei7 vpp_native_tools = vppapigen vpp_uses_dpdk = yes @@ -40,9 +43,9 @@ vpp_debug_TAG_CFLAGS = -g -O0 -DCLIB_DEBUG -DFORTIFY_SOURCE=2 -march=$(MARCH) \ vpp_debug_TAG_LDFLAGS = -g -O0 -DCLIB_DEBUG -DFORTIFY_SOURCE=2 -march=$(MARCH) \ -fstack-protector-all -fPIC -Werror -vpp_TAG_CFLAGS = -g -O2 -DFORTIFY_SOURCE=2 -march=$(MARCH) \ +vpp_TAG_CFLAGS = -g -O2 -DFORTIFY_SOURCE=2 -march=$(MARCH) -mtune=$(MTUNE) \ -fstack-protector -fPIC -Werror -vpp_TAG_LDFLAGS = -g -O2 -DFORTIFY_SOURCE=2 -march=$(MARCH) \ +vpp_TAG_LDFLAGS = -g -O2 -DFORTIFY_SOURCE=2 -march=$(MARCH) -mtune=$(MTUNE) \ -fstack-protector -fPIC -Werror vpp_gcov_TAG_CFLAGS = -g -O0 -DCLIB_DEBUG -march=$(MARCH) \ diff --git a/build-data/platforms/vpp_lite.mk b/build-data/platforms/vpp_lite.mk index 4183700e..d35d2347 100644 --- a/build-data/platforms/vpp_lite.mk +++ b/build-data/platforms/vpp_lite.mk @@ -13,6 +13,8 @@ # vector packet processor vpp_lite_arch = native +vpp_lite_march = corei7 # Nehalem Instruction set +vpp_lite_mtune = corei7-avx # Optimize for Sandy Bridge vpp_lite_native_tools = vppapigen vpp_lite_uses_dpdk = no @@ -30,7 +32,7 @@ vpp_lite_debug_TAG_CFLAGS = -g -O0 -DCLIB_DEBUG -DFORTIFY_SOURCE=2 -march=$(MARC vpp_lite_debug_TAG_LDFLAGS = -g -O0 -DCLIB_DEBUG -DFORTIFY_SOURCE=2 -march=$(MARCH) \ -fstack-protector-all -fPIC -Werror -vpp_lite_TAG_CFLAGS = -g -O2 -DFORTIFY_SOURCE=2 -march=$(MARCH) \ +vpp_lite_TAG_CFLAGS = -g -O2 -DFORTIFY_SOURCE=2 -march=$(MARCH) -mtune=$(MTUNE) \ -fstack-protector -fPIC -Werror -vpp_lite_TAG_LDFLAGS = -g -O2 -DFORTIFY_SOURCE=2 -march=$(MARCH) \ +vpp_lite_TAG_LDFLAGS = -g -O2 -DFORTIFY_SOURCE=2 -march=$(MARCH) -mtune=$(MTUNE) \ -fstack-protector -fPIC -Werror diff --git a/build-root/Makefile b/build-root/Makefile index a60cbf0a..97fb43d4 100644 --- a/build-root/Makefile +++ b/build-root/Makefile @@ -220,6 +220,11 @@ else endif export MARCH +MTUNE = $(strip $($(PLATFORM)_mtune)) +ifeq ($(MTUNE),) + MTUNE = generic +endif + ###################################################################### # Generic build stuff ###################################################################### diff --git a/dpdk/Makefile b/dpdk/Makefile index 165058d9..b7e1e097 100644 --- a/dpdk/Makefile +++ b/dpdk/Makefile @@ -19,6 +19,7 @@ DPDK_INSTALL_DIR ?= $(CURDIR)/_install DPDK_PKTMBUF_HEADROOM ?= 128 DPDK_DOWNLOAD_DIR ?= $(HOME)/Downloads DPDK_MARCH ?= native +DPDK_TUNE ?= generic DPDK_DEBUG ?= n B := $(DPDK_BUILD_DIR) @@ -51,7 +52,7 @@ DPDK_CPU_LDFLAGS := DPDK_EXTRA_LDFLAGS := -g ifeq ($(DPDK_DEBUG),n) -DPDK_EXTRA_CFLAGS := -g +DPDK_EXTRA_CFLAGS := -g -mtune=$(DPDK_TUNE) else DPDK_EXTRA_CFLAGS := -g -O0 endif diff --git a/vlib/vlib/node.h b/vlib/vlib/node.h index 2caede6e..9b33a0a3 100644 --- a/vlib/vlib/node.h +++ b/vlib/vlib/node.h @@ -40,6 +40,7 @@ #ifndef included_vlib_node_h #define included_vlib_node_h +#include #include #include #include /* for vlib_trace_filter_t */ @@ -149,6 +150,32 @@ static void __vlib_add_node_registration_##x (void) \ } \ __VA_ARGS__ vlib_node_registration_t x +#if CLIB_DEBUG > 0 +#define VLIB_NODE_FUNCTION_CLONE_TEMPLATE(arch, fn) +#define VLIB_NODE_FUNCTION_MULTIARCH_CLONE(fn) +#define VLIB_NODE_FUNCTION_MULTIARCH(node, fn) +#else +#define VLIB_NODE_FUNCTION_CLONE_TEMPLATE(arch, fn, tgt) \ + uword \ + __attribute__ ((flatten)) \ + __attribute__ ((target (tgt))) \ + CLIB_CPU_OPTIMIZED \ + fn ## _ ## arch ( struct vlib_main_t * vm, \ + struct vlib_node_runtime_t * node, \ + struct vlib_frame_t * frame) \ + { return fn (vm, node, frame); } + +#define VLIB_NODE_FUNCTION_MULTIARCH_CLONE(fn) \ + foreach_march_variant(VLIB_NODE_FUNCTION_CLONE_TEMPLATE, fn) + +#define VLIB_NODE_FUNCTION_MULTIARCH(node, fn) \ + VLIB_NODE_FUNCTION_MULTIARCH_CLONE(fn) \ + CLIB_MULTIARCH_SELECT_FN(fn, static inline) \ + static void __attribute__((__constructor__)) \ + __vlib_node_function_multiarch_select_##node (void) \ + { node.function = fn ## _multiarch_select(); } +#endif + always_inline vlib_node_registration_t * vlib_node_next_registered (vlib_node_registration_t * c) { diff --git a/vnet/vnet/classify/ip_classify.c b/vnet/vnet/classify/ip_classify.c index 8152f6ce..75e80ad6 100644 --- a/vnet/vnet/classify/ip_classify.c +++ b/vnet/vnet/classify/ip_classify.c @@ -329,6 +329,8 @@ VLIB_REGISTER_NODE (ip4_classify_node) = { .next_nodes = IP4_LOOKUP_NEXT_NODES, }; +VLIB_NODE_FUNCTION_MULTIARCH (ip4_classify_node, ip4_classify) + static uword ip6_classify (vlib_main_t * vm, vlib_node_runtime_t * node, @@ -350,6 +352,8 @@ VLIB_REGISTER_NODE (ip6_classify_node) = { .next_nodes = IP6_LOOKUP_NEXT_NODES, }; +VLIB_NODE_FUNCTION_MULTIARCH (ip6_classify_node, ip6_classify) + static clib_error_t * ip_classify_init (vlib_main_t * vm) { diff --git a/vnet/vnet/cop/ip4_whitelist.c b/vnet/vnet/cop/ip4_whitelist.c index 6178e891..5578558c 100644 --- a/vnet/vnet/cop/ip4_whitelist.c +++ b/vnet/vnet/cop/ip4_whitelist.c @@ -348,6 +348,8 @@ VLIB_REGISTER_NODE (ip4_cop_whitelist_node) = { }, }; +VLIB_NODE_FUNCTION_MULTIARCH (ip4_cop_whitelist_node, ip4_cop_whitelist_node_fn) + static clib_error_t * ip4_whitelist_init (vlib_main_t * vm) { diff --git a/vnet/vnet/cop/ip6_whitelist.c b/vnet/vnet/cop/ip6_whitelist.c index dc6a1ee5..4a8f33fb 100644 --- a/vnet/vnet/cop/ip6_whitelist.c +++ b/vnet/vnet/cop/ip6_whitelist.c @@ -286,6 +286,8 @@ VLIB_REGISTER_NODE (ip6_cop_whitelist_node) = { }, }; +VLIB_NODE_FUNCTION_MULTIARCH (ip6_cop_whitelist_node, ip6_cop_whitelist_node_fn) + static clib_error_t * ip6_whitelist_init (vlib_main_t * vm) { diff --git a/vnet/vnet/cop/node1.c b/vnet/vnet/cop/node1.c index 3ee7006a..b448b531 100644 --- a/vnet/vnet/cop/node1.c +++ b/vnet/vnet/cop/node1.c @@ -282,6 +282,8 @@ VLIB_REGISTER_NODE (cop_input_node) = { }, }; +VLIB_NODE_FUNCTION_MULTIARCH (cop_input_node, cop_input_node_fn) + #define foreach_cop_stub \ _(default-cop-whitelist, default_cop_whitelist) diff --git a/vnet/vnet/devices/af_packet/device.c b/vnet/vnet/devices/af_packet/device.c index f0e91487..0671d9e2 100644 --- a/vnet/vnet/devices/af_packet/device.c +++ b/vnet/vnet/devices/af_packet/device.c @@ -204,3 +204,6 @@ VNET_DEVICE_CLASS (af_packet_device_class) = { .subif_add_del_function = af_packet_subif_add_del_function, .no_flatten_output_chains = 1, }; + +VLIB_DEVICE_TX_FUNCTION_MULTIARCH (af_packet_device_class, + af_packet_interface_tx) diff --git a/vnet/vnet/devices/af_packet/node.c b/vnet/vnet/devices/af_packet/node.c index b622a221..0c608ea4 100644 --- a/vnet/vnet/devices/af_packet/node.c +++ b/vnet/vnet/devices/af_packet/node.c @@ -267,7 +267,6 @@ af_packet_input_fn (vlib_main_t * vm, vlib_node_runtime_t * node, return n_rx_packets; } - VLIB_REGISTER_NODE (af_packet_input_node) = { .function = af_packet_input_fn, .name = "af-packet-input", @@ -283,3 +282,6 @@ VLIB_REGISTER_NODE (af_packet_input_node) = { [AF_PACKET_INPUT_NEXT_ETHERNET_INPUT] = "ethernet-input", }, }; + +VLIB_NODE_FUNCTION_MULTIARCH (af_packet_input_node, af_packet_input_fn) + diff --git a/vnet/vnet/devices/dpdk/cli.c b/vnet/vnet/devices/dpdk/cli.c index 9ec19867..9063cad8 100644 --- a/vnet/vnet/devices/dpdk/cli.c +++ b/vnet/vnet/devices/dpdk/cli.c @@ -759,6 +759,7 @@ set_efd (vlib_main_t *vm, unformat_input_t *input, dpdk_main_t * dm = &dpdk_main; vlib_thread_main_t * tm = vlib_get_thread_main(); clib_error_t * error = NULL; + vlib_node_runtime_t * rt = vlib_node_get_runtime (vm, dpdk_input_node.index); if (unformat(input, "enable")) { if (unformat(input, "dpdk")) { @@ -844,6 +845,13 @@ set_efd (vlib_main_t *vm, unformat_input_t *input, format_unformat_error, input); } + if (dm->efd.enabled) + rt->function = dpdk_input_efd_multiarch_select(); + else if (dm->use_rss) + rt->function = dpdk_input_rss_multiarch_select(); + else + rt->function = dpdk_input_multiarch_select(); + return error; } diff --git a/vnet/vnet/devices/dpdk/device.c b/vnet/vnet/devices/dpdk/device.c index ab85dfb4..a38c8d19 100644 --- a/vnet/vnet/devices/dpdk/device.c +++ b/vnet/vnet/devices/dpdk/device.c @@ -1184,6 +1184,9 @@ VNET_DEVICE_CLASS (dpdk_device_class) = { .name_renumber = dpdk_device_renumber, }; +VLIB_DEVICE_TX_FUNCTION_MULTIARCH (dpdk_device_class, + dpdk_interface_tx) + void dpdk_set_flowcontrol_callback (vlib_main_t *vm, dpdk_flowcontrol_callback_t callback) { diff --git a/vnet/vnet/devices/dpdk/dpdk.h b/vnet/vnet/devices/dpdk/dpdk.h index 019d83f7..525cd8d1 100644 --- a/vnet/vnet/devices/dpdk/dpdk.h +++ b/vnet/vnet/devices/dpdk/dpdk.h @@ -584,8 +584,9 @@ dpdk_pmd_t dpdk_get_pmd_type (vnet_hw_interface_t *hi); i8 dpdk_get_cpu_socket (vnet_hw_interface_t *hi); -uword -dpdk_input_rss (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * f); +void * dpdk_input_multiarch_select(); +void * dpdk_input_rss_multiarch_select(); +void * dpdk_input_efd_multiarch_select(); clib_error_t* dpdk_get_hw_interface_stats (u32 hw_if_index, struct rte_eth_stats* dest); diff --git a/vnet/vnet/devices/dpdk/init.c b/vnet/vnet/devices/dpdk/init.c index 63fa4c07..8ee59ff8 100644 --- a/vnet/vnet/devices/dpdk/init.c +++ b/vnet/vnet/devices/dpdk/init.c @@ -804,6 +804,7 @@ dpdk_config (vlib_main_t * vm, unformat_input_t * input) clib_error_t * error = 0; dpdk_main_t * dm = &dpdk_main; vlib_thread_main_t * tm = vlib_get_thread_main(); + vlib_node_runtime_t * rt = vlib_node_get_runtime (vm, dpdk_input_node.index); u8 * s, * tmp = 0; u8 * pci_dev_id = 0; u8 * rte_cmd = 0, * ethname = 0; @@ -1251,10 +1252,9 @@ dpdk_config (vlib_main_t * vm, unformat_input_t * input) } if (dm->use_rss) - { - vlib_node_runtime_t * rt = vlib_node_get_runtime (vm, dpdk_input_node.index); - rt->function = dpdk_input_rss; - } + rt->function = dpdk_input_rss_multiarch_select(); + else + rt->function = dpdk_input_multiarch_select(); done: return error; } diff --git a/vnet/vnet/devices/dpdk/node.c b/vnet/vnet/devices/dpdk/node.c index a7590a5c..ca94511b 100644 --- a/vnet/vnet/devices/dpdk/node.c +++ b/vnet/vnet/devices/dpdk/node.c @@ -251,6 +251,8 @@ VLIB_REGISTER_NODE (handoff_dispatch_node) = { }, }; +VLIB_NODE_FUNCTION_MULTIARCH (handoff_dispatch_node, handoff_dispatch_node_fn) + clib_error_t *handoff_dispatch_init (vlib_main_t *vm) { handoff_dispatch_main_t * mp = &handoff_dispatch_main; @@ -488,7 +490,8 @@ static inline u32 dpdk_device_input ( dpdk_main_t * dm, dpdk_device_t * xd, vlib_node_runtime_t * node, u32 cpu_index, - u16 queue_id) + u16 queue_id, + int use_efd) { u32 n_buffers; u32 next_index = DPDK_RX_NEXT_ETHERNET_INPUT; @@ -510,7 +513,7 @@ static inline u32 dpdk_device_input ( dpdk_main_t * dm, if (n_buffers == 0) { /* check if EFD (dpdk) is enabled */ - if (PREDICT_FALSE(dm->efd.enabled)) + if (PREDICT_FALSE(use_efd && dm->efd.enabled)) { /* reset a few stats */ xd->efd_agent.last_poll_time = 0; @@ -546,7 +549,7 @@ static inline u32 dpdk_device_input ( dpdk_main_t * dm, /* Check for congestion if EFD (Early-Fast-Discard) is enabled * in any mode (e.g. dpdk, monitor, or drop_all) */ - if (PREDICT_FALSE(dm->efd.enabled)) + if (PREDICT_FALSE(use_efd && dm->efd.enabled)) { /* update EFD counters */ dpdk_efd_update_counters(xd, n_buffers, dm->efd.enabled); @@ -793,7 +796,7 @@ dpdk_input (vlib_main_t * vm, { xd = vec_elt_at_index(dm->devices, dq->device); ASSERT(dq->queue_id == 0); - n_rx_packets += dpdk_device_input (dm, xd, node, cpu_index, 0); + n_rx_packets += dpdk_device_input (dm, xd, node, cpu_index, 0, 0); } VIRL_SPEED_LIMIT() @@ -818,7 +821,7 @@ dpdk_input_rss (vlib_main_t * vm, vec_foreach (dq, dm->devices_by_cpu[cpu_index]) { xd = vec_elt_at_index(dm->devices, dq->device); - n_rx_packets += dpdk_device_input (dm, xd, node, cpu_index, dq->queue_id); + n_rx_packets += dpdk_device_input (dm, xd, node, cpu_index, dq->queue_id, 0); } VIRL_SPEED_LIMIT() @@ -826,6 +829,32 @@ dpdk_input_rss (vlib_main_t * vm, return n_rx_packets; } +uword +dpdk_input_efd (vlib_main_t * vm, + vlib_node_runtime_t * node, + vlib_frame_t * f) +{ + dpdk_main_t * dm = &dpdk_main; + dpdk_device_t * xd; + uword n_rx_packets = 0; + dpdk_device_and_queue_t * dq; + u32 cpu_index = os_get_cpu_number(); + + /* + * Poll all devices on this cpu for input/interrupts. + */ + vec_foreach (dq, dm->devices_by_cpu[cpu_index]) + { + xd = vec_elt_at_index(dm->devices, dq->device); + n_rx_packets += dpdk_device_input (dm, xd, node, cpu_index, dq->queue_id, 1); + } + + VIRL_SPEED_LIMIT() + + return n_rx_packets; +} + + VLIB_REGISTER_NODE (dpdk_input_node) = { .function = dpdk_input, .type = VLIB_NODE_TYPE_INPUT, @@ -850,6 +879,17 @@ VLIB_REGISTER_NODE (dpdk_input_node) = { }, }; + +/* handle dpdk_input_rss alternative function */ +VLIB_NODE_FUNCTION_MULTIARCH_CLONE(dpdk_input) +VLIB_NODE_FUNCTION_MULTIARCH_CLONE(dpdk_input_rss) +VLIB_NODE_FUNCTION_MULTIARCH_CLONE(dpdk_input_efd) + +/* this macro defines dpdk_input_rss_multiarch_select() */ +CLIB_MULTIARCH_SELECT_FN(dpdk_input); +CLIB_MULTIARCH_SELECT_FN(dpdk_input_rss); +CLIB_MULTIARCH_SELECT_FN(dpdk_input_efd); + /* * Override the next nodes for the dpdk input nodes. * Must be invoked prior to VLIB_INIT_FUNCTION calls. diff --git a/vnet/vnet/devices/netmap/device.c b/vnet/vnet/devices/netmap/device.c index f04e0672..a966ffef 100644 --- a/vnet/vnet/devices/netmap/device.c +++ b/vnet/vnet/devices/netmap/device.c @@ -232,3 +232,6 @@ VNET_DEVICE_CLASS (netmap_device_class) = { .subif_add_del_function = netmap_subif_add_del_function, .no_flatten_output_chains = 1, }; + +VLIB_DEVICE_TX_FUNCTION_MULTIARCH(netmap_device_class, + netmap_interface_tx) diff --git a/vnet/vnet/devices/netmap/node.c b/vnet/vnet/devices/netmap/node.c index 3986c7e4..f4c39e62 100644 --- a/vnet/vnet/devices/netmap/node.c +++ b/vnet/vnet/devices/netmap/node.c @@ -270,7 +270,6 @@ netmap_input_fn (vlib_main_t * vm, vlib_node_runtime_t * node, return n_rx_packets; } - VLIB_REGISTER_NODE (netmap_input_node) = { .function = netmap_input_fn, .name = "netmap-input", @@ -287,3 +286,5 @@ VLIB_REGISTER_NODE (netmap_input_node) = { }, }; +VLIB_NODE_FUNCTION_MULTIARCH (netmap_input_node, netmap_input_fn) + diff --git a/vnet/vnet/devices/ssvm/node.c b/vnet/vnet/devices/ssvm/node.c index 84625696..57b5fd22 100644 --- a/vnet/vnet/devices/ssvm/node.c +++ b/vnet/vnet/devices/ssvm/node.c @@ -334,3 +334,5 @@ VLIB_REGISTER_NODE (ssvm_eth_input_node) = { }, }; +VLIB_NODE_FUNCTION_MULTIARCH (ssvm_eth_input_node, ssvm_eth_input_node_fn) + diff --git a/vnet/vnet/devices/ssvm/ssvm_eth.c b/vnet/vnet/devices/ssvm/ssvm_eth.c index 49f2d5f8..7c65e212 100644 --- a/vnet/vnet/devices/ssvm/ssvm_eth.c +++ b/vnet/vnet/devices/ssvm/ssvm_eth.c @@ -474,3 +474,6 @@ VNET_DEVICE_CLASS (ssvm_eth_device_class) = { .rx_redirect_to_node = ssvm_eth_set_interface_next_node, .no_flatten_output_chains = 1, }; + +VLIB_DEVICE_TX_FUNCTION_MULTIARCH (ssvm_eth_device_class, + ssvm_eth_interface_tx) diff --git a/vnet/vnet/devices/virtio/vhost-user.c b/vnet/vnet/devices/virtio/vhost-user.c index 5902c42b..ef4993f9 100644 --- a/vnet/vnet/devices/virtio/vhost-user.c +++ b/vnet/vnet/devices/virtio/vhost-user.c @@ -1144,6 +1144,8 @@ VLIB_REGISTER_NODE (vhost_user_input_node) = { }, }; +VLIB_NODE_FUNCTION_MULTIARCH (vhost_user_input_node, vhost_user_input) + static uword vhost_user_intfc_tx (vlib_main_t * vm, vlib_node_runtime_t * node, @@ -1373,6 +1375,9 @@ VNET_DEVICE_CLASS (vhost_user_dev_class,static) = { .no_flatten_output_chains = 1, }; +VLIB_DEVICE_TX_FUNCTION_MULTIARCH (vhost_user_dev_class, + vhost_user_intfc_tx) + static uword vhost_user_process (vlib_main_t * vm, vlib_node_runtime_t * rt, diff --git a/vnet/vnet/ethernet/node.c b/vnet/vnet/ethernet/node.c index e8902fd7..226a66e9 100644 --- a/vnet/vnet/ethernet/node.c +++ b/vnet/vnet/ethernet/node.c @@ -945,6 +945,8 @@ VLIB_REGISTER_NODE (ethernet_input_node) = { .unformat_buffer = unformat_ethernet_header, }; +VLIB_NODE_FUNCTION_MULTIARCH (ethernet_input_node, ethernet_input) + VLIB_REGISTER_NODE (ethernet_input_type_node,static) = { .function = ethernet_input_type, .name = "ethernet-input-type", @@ -959,6 +961,8 @@ VLIB_REGISTER_NODE (ethernet_input_type_node,static) = { }, }; +VLIB_NODE_FUNCTION_MULTIARCH (ethernet_input_type_node, ethernet_input_type) + VLIB_REGISTER_NODE (ethernet_input_not_l2_node,static) = { .function = ethernet_input_not_l2, .name = "ethernet-input-not-l2", @@ -973,6 +977,8 @@ VLIB_REGISTER_NODE (ethernet_input_not_l2_node,static) = { }, }; +VLIB_NODE_FUNCTION_MULTIARCH (ethernet_input_not_l2_node, ethernet_input_not_l2) + void ethernet_set_rx_redirect (vnet_main_t * vnm, vnet_hw_interface_t * hi, u32 enable) diff --git a/vnet/vnet/gre/gre.c b/vnet/vnet/gre/gre.c index 075bd6fd..6d375159 100644 --- a/vnet/vnet/gre/gre.c +++ b/vnet/vnet/gre/gre.c @@ -454,6 +454,9 @@ VNET_DEVICE_CLASS (gre_device_class) = { #endif }; +VLIB_DEVICE_TX_FUNCTION_MULTIARCH (gre_device_class, + gre_interface_tx) + VNET_HW_INTERFACE_CLASS (gre_hw_interface_class) = { .name = "GRE", diff --git a/vnet/vnet/gre/node.c b/vnet/vnet/gre/node.c index a91f7e9e..e33b2b05 100644 --- a/vnet/vnet/gre/node.c +++ b/vnet/vnet/gre/node.c @@ -434,6 +434,8 @@ VLIB_REGISTER_NODE (gre_input_node) = { .unformat_buffer = unformat_gre_header, }; +VLIB_NODE_FUNCTION_MULTIARCH (gre_input_node, gre_input) + void gre_register_input_protocol (vlib_main_t * vm, gre_protocol_t protocol, diff --git a/vnet/vnet/interface.h b/vnet/vnet/interface.h index 2829a0cc..30dcf276 100644 --- a/vnet/vnet/interface.h +++ b/vnet/vnet/interface.h @@ -163,6 +163,32 @@ static void __vnet_add_device_class_registration_##x (void) \ } \ __VA_ARGS__ vnet_device_class_t x +#define VLIB_DEVICE_TX_FUNCTION_CLONE_TEMPLATE(arch, fn, tgt) \ + uword \ + __attribute__ ((flatten)) \ + __attribute__ ((target (tgt))) \ + CLIB_CPU_OPTIMIZED \ + fn ## _ ## arch ( vlib_main_t * vm, \ + vlib_node_runtime_t * node, \ + vlib_frame_t * frame) \ + { return fn (vm, node, frame); } + +#define VLIB_DEVICE_TX_FUNCTION_MULTIARCH_CLONE(fn) \ + foreach_march_variant(VLIB_DEVICE_TX_FUNCTION_CLONE_TEMPLATE, fn) + +#if CLIB_DEBUG > 0 +#define VLIB_MULTIARCH_CLONE_AND_SELECT_FN(fn,...) +#define VLIB_DEVICE_TX_FUNCTION_MULTIARCH(dev, fn) +#else +#define VLIB_DEVICE_TX_FUNCTION_MULTIARCH(dev, fn) \ + VLIB_DEVICE_TX_FUNCTION_MULTIARCH_CLONE(fn) \ + CLIB_MULTIARCH_SELECT_FN(fn, static inline) \ + static void __attribute__((__constructor__)) \ + __vlib_device_tx_function_multiarch_select_##dev (void) \ + { dev.tx_function = fn ## _multiarch_select(); } +#endif + + /* Layer-2 (e.g. Ethernet) interface class. */ typedef struct _vnet_hw_interface_class { /* Index into main vector. */ diff --git a/vnet/vnet/interface_output.c b/vnet/vnet/interface_output.c index 04c1b7f5..9f9fb707 100644 --- a/vnet/vnet/interface_output.c +++ b/vnet/vnet/interface_output.c @@ -1140,6 +1140,8 @@ VLIB_REGISTER_NODE (drop_buffers,static) = { .validate_frame = validate_error_frame, }; +VLIB_NODE_FUNCTION_MULTIARCH (drop_buffers, process_drop) + VLIB_REGISTER_NODE (punt_buffers,static) = { .function = process_punt, .flags = (VLIB_NODE_FLAG_FRAME_NO_FREE_AFTER_DISPATCH @@ -1150,12 +1152,16 @@ VLIB_REGISTER_NODE (punt_buffers,static) = { .validate_frame = validate_error_frame, }; +VLIB_NODE_FUNCTION_MULTIARCH (punt_buffers, process_punt) + VLIB_REGISTER_NODE (vnet_per_buffer_interface_output_node,static) = { .function = vnet_per_buffer_interface_output, .name = "interface-output", .vector_size = sizeof (u32), }; +VLIB_NODE_FUNCTION_MULTIARCH (vnet_per_buffer_interface_output_node, vnet_per_buffer_interface_output) + clib_error_t * vnet_per_buffer_interface_output_hw_interface_add_del (vnet_main_t * vnm, u32 hw_if_index, diff --git a/vnet/vnet/ip/ip4_forward.c b/vnet/vnet/ip/ip4_forward.c index a84b83bc..ae2f9eea 100644 --- a/vnet/vnet/ip/ip4_forward.c +++ b/vnet/vnet/ip/ip4_forward.c @@ -1354,6 +1354,8 @@ VLIB_REGISTER_NODE (ip4_lookup_node) = { .next_nodes = IP4_LOOKUP_NEXT_NODES, }; +VLIB_NODE_FUNCTION_MULTIARCH (ip4_lookup_node, ip4_lookup) + static uword ip4_indirect (vlib_main_t * vm, vlib_node_runtime_t * node, @@ -1373,6 +1375,8 @@ VLIB_REGISTER_NODE (ip4_indirect_node) = { .next_nodes = IP4_LOOKUP_NEXT_NODES, }; +VLIB_NODE_FUNCTION_MULTIARCH (ip4_indirect_node, ip4_indirect) + /* Global IP4 main. */ ip4_main_t ip4_main; @@ -1612,6 +1616,8 @@ VLIB_REGISTER_NODE (ip4_drop_node,static) = { }, }; +VLIB_NODE_FUNCTION_MULTIARCH (ip4_drop_node, ip4_drop) + VLIB_REGISTER_NODE (ip4_punt_node,static) = { .function = ip4_punt, .name = "ip4-punt", @@ -1625,6 +1631,8 @@ VLIB_REGISTER_NODE (ip4_punt_node,static) = { }, }; +VLIB_NODE_FUNCTION_MULTIARCH (ip4_punt_node, ip4_punt) + VLIB_REGISTER_NODE (ip4_miss_node,static) = { .function = ip4_miss, .name = "ip4-miss", @@ -1638,6 +1646,8 @@ VLIB_REGISTER_NODE (ip4_miss_node,static) = { }, }; +VLIB_NODE_FUNCTION_MULTIARCH (ip4_miss_node, ip4_miss) + /* Compute TCP/UDP/ICMP4 checksum in software. */ u16 ip4_tcp_udp_compute_checksum (vlib_main_t * vm, vlib_buffer_t * p0, @@ -2076,6 +2086,8 @@ VLIB_REGISTER_NODE (ip4_local_node,static) = { }, }; +VLIB_NODE_FUNCTION_MULTIARCH (ip4_local_node, ip4_local) + void ip4_register_protocol (u32 protocol, u32 node_index) { vlib_main_t * vm = vlib_get_main(); @@ -2743,6 +2755,8 @@ VLIB_REGISTER_NODE (ip4_rewrite_node) = { }, }; +VLIB_NODE_FUNCTION_MULTIARCH (ip4_rewrite_node, ip4_rewrite_transit) + VLIB_REGISTER_NODE (ip4_rewrite_local_node,static) = { .function = ip4_rewrite_local, .name = "ip4-rewrite-local", @@ -2759,6 +2773,8 @@ VLIB_REGISTER_NODE (ip4_rewrite_local_node,static) = { }, }; +VLIB_NODE_FUNCTION_MULTIARCH (ip4_rewrite_local_node, ip4_rewrite_local) + static clib_error_t * add_del_interface_table (vlib_main_t * vm, unformat_input_t * input, @@ -3032,6 +3048,8 @@ VLIB_REGISTER_NODE (ip4_lookup_multicast_node,static) = { .next_nodes = IP4_LOOKUP_NEXT_NODES, }; +VLIB_NODE_FUNCTION_MULTIARCH (ip4_lookup_multicast_node, ip4_lookup_multicast) + VLIB_REGISTER_NODE (ip4_multicast_node,static) = { .function = ip4_drop, .name = "ip4-multicast", diff --git a/vnet/vnet/ip/ip4_hop_by_hop.c b/vnet/vnet/ip/ip4_hop_by_hop.c index ae46040a..177feb74 100644 --- a/vnet/vnet/ip/ip4_hop_by_hop.c +++ b/vnet/vnet/ip/ip4_hop_by_hop.c @@ -233,6 +233,8 @@ VLIB_REGISTER_NODE (ip4_hop_by_hop_node) = { .next_nodes = IP4_LOOKUP_NEXT_NODES, }; +VLIB_NODE_FUNCTION_MULTIARCH (ip4_hop_by_hop_node, ip4_hop_by_hop_node_fn) + VLIB_REGISTER_NODE (ip4_add_hop_by_hop_node) = { .function = ip4_hop_by_hop_node_fn, .name = "ip4-add-hop-by-hop", diff --git a/vnet/vnet/ip/ip4_input.c b/vnet/vnet/ip/ip4_input.c index f31df0f6..60634250 100644 --- a/vnet/vnet/ip/ip4_input.c +++ b/vnet/vnet/ip/ip4_input.c @@ -371,6 +371,8 @@ VLIB_REGISTER_NODE (ip4_input_node) = { .format_trace = format_ip4_input_trace, }; +VLIB_NODE_FUNCTION_MULTIARCH (ip4_input_node, ip4_input) + VLIB_REGISTER_NODE (ip4_input_no_checksum_node,static) = { .function = ip4_input_no_checksum, .name = "ip4-input-no-checksum", @@ -389,6 +391,8 @@ VLIB_REGISTER_NODE (ip4_input_no_checksum_node,static) = { .format_trace = format_ip4_input_trace, }; +VLIB_NODE_FUNCTION_MULTIARCH (ip4_input_no_checksum_node, ip4_input_no_checksum) + static clib_error_t * ip4_init (vlib_main_t * vm) { clib_error_t * error; diff --git a/vnet/vnet/ip/ip4_source_check.c b/vnet/vnet/ip/ip4_source_check.c index 47e22f23..11e6678e 100644 --- a/vnet/vnet/ip/ip4_source_check.c +++ b/vnet/vnet/ip/ip4_source_check.c @@ -297,6 +297,9 @@ VLIB_REGISTER_NODE (ip4_check_source_reachable_via_any) = { .format_trace = format_ip4_source_check_trace, }; +VLIB_NODE_FUNCTION_MULTIARCH (ip4_check_source_reachable_via_any, + ip4_source_check_reachable_via_any) + VLIB_REGISTER_NODE (ip4_check_source_reachable_via_rx) = { .function = ip4_source_check_reachable_via_rx, .name = "ip4-source-check-via-rx", @@ -311,6 +314,9 @@ VLIB_REGISTER_NODE (ip4_check_source_reachable_via_rx) = { .format_trace = format_ip4_source_check_trace, }; +VLIB_NODE_FUNCTION_MULTIARCH (ip4_check_source_reachable_via_rx, + ip4_source_check_reachable_via_rx) + static clib_error_t * set_ip_source_check (vlib_main_t * vm, unformat_input_t * input, diff --git a/vnet/vnet/ip/ip6_forward.c b/vnet/vnet/ip/ip6_forward.c index a136da3e..7093c571 100644 --- a/vnet/vnet/ip/ip6_forward.c +++ b/vnet/vnet/ip/ip6_forward.c @@ -1260,6 +1260,8 @@ VLIB_REGISTER_NODE (ip6_lookup_node) = { .next_nodes = IP6_LOOKUP_NEXT_NODES, }; +VLIB_NODE_FUNCTION_MULTIARCH (ip6_lookup_node, ip6_lookup) + static uword ip6_indirect (vlib_main_t * vm, vlib_node_runtime_t * node, @@ -1278,6 +1280,8 @@ VLIB_REGISTER_NODE (ip6_indirect_node) = { .next_nodes = IP6_LOOKUP_NEXT_NODES, }; +VLIB_NODE_FUNCTION_MULTIARCH (ip6_indirect_node, ip6_indirect) + typedef struct { /* Adjacency taken. */ u32 adj_index; @@ -1454,6 +1458,8 @@ VLIB_REGISTER_NODE (ip6_drop_node,static) = { }, }; +VLIB_NODE_FUNCTION_MULTIARCH (ip6_drop_node, ip6_drop) + VLIB_REGISTER_NODE (ip6_punt_node,static) = { .function = ip6_punt, .name = "ip6-punt", @@ -1467,6 +1473,8 @@ VLIB_REGISTER_NODE (ip6_punt_node,static) = { }, }; +VLIB_NODE_FUNCTION_MULTIARCH (ip6_punt_node, ip6_punt) + VLIB_REGISTER_NODE (ip6_miss_node,static) = { .function = ip6_miss, .name = "ip6-miss", @@ -1480,6 +1488,8 @@ VLIB_REGISTER_NODE (ip6_miss_node,static) = { }, }; +VLIB_NODE_FUNCTION_MULTIARCH (ip6_miss_node, ip6_miss) + VLIB_REGISTER_NODE (ip6_multicast_node,static) = { .function = ip6_drop, .name = "ip6-multicast", @@ -1858,6 +1868,8 @@ VLIB_REGISTER_NODE (ip6_local_node,static) = { }, }; +VLIB_NODE_FUNCTION_MULTIARCH (ip6_local_node, ip6_local) + void ip6_register_protocol (u32 protocol, u32 node_index) { vlib_main_t * vm = vlib_get_main(); @@ -2424,6 +2436,8 @@ VLIB_REGISTER_NODE (ip6_rewrite_node) = { }, }; +VLIB_NODE_FUNCTION_MULTIARCH (ip6_rewrite_node, ip6_rewrite_transit) + VLIB_REGISTER_NODE (ip6_rewrite_local_node,static) = { .function = ip6_rewrite_local, .name = "ip6-rewrite-local", @@ -2439,6 +2453,8 @@ VLIB_REGISTER_NODE (ip6_rewrite_local_node,static) = { }, }; +VLIB_NODE_FUNCTION_MULTIARCH (ip6_rewrite_local_node, ip6_rewrite_local) + /* Global IP6 main. */ ip6_main_t ip6_main; diff --git a/vnet/vnet/ip/ip6_hop_by_hop.c b/vnet/vnet/ip/ip6_hop_by_hop.c index 16650dde..045dbc7f 100644 --- a/vnet/vnet/ip/ip6_hop_by_hop.c +++ b/vnet/vnet/ip/ip6_hop_by_hop.c @@ -628,6 +628,8 @@ VLIB_REGISTER_NODE (ip6_hop_by_hop_node) = { }, }; +VLIB_NODE_FUNCTION_MULTIARCH (ip6_hop_by_hop_node, ip6_hop_by_hop_node_fn) + /* The main h-b-h tracer will be invoked, no need to do much here */ typedef struct { u32 next_index; @@ -849,6 +851,7 @@ VLIB_REGISTER_NODE (ip6_add_hop_by_hop_node) = { }, }; +VLIB_NODE_FUNCTION_MULTIARCH (ip6_add_hop_by_hop_node, ip6_add_hop_by_hop_node_fn) /* The main h-b-h tracer was already invoked, no need to do much here */ typedef struct { @@ -1162,6 +1165,8 @@ VLIB_REGISTER_NODE (ip6_pop_hop_by_hop_node) = { }, }; +VLIB_NODE_FUNCTION_MULTIARCH (ip6_pop_hop_by_hop_node, + ip6_pop_hop_by_hop_node_fn) static clib_error_t * ip6_hop_by_hop_init (vlib_main_t * vm) diff --git a/vnet/vnet/ip/ip6_input.c b/vnet/vnet/ip/ip6_input.c index f96a1cfb..2042cbd7 100644 --- a/vnet/vnet/ip/ip6_input.c +++ b/vnet/vnet/ip/ip6_input.c @@ -305,6 +305,8 @@ VLIB_REGISTER_NODE (ip6_input_node) = { .format_trace = format_ip6_input_trace, }; +VLIB_NODE_FUNCTION_MULTIARCH (ip6_input_node, ip6_input) + static clib_error_t * ip6_init (vlib_main_t * vm) { ethernet_register_input_type (vm, ETHERNET_TYPE_IP6, diff --git a/vnet/vnet/ip/ip_input_acl.c b/vnet/vnet/ip/ip_input_acl.c index e905ed15..fcf8eeab 100644 --- a/vnet/vnet/ip/ip_input_acl.c +++ b/vnet/vnet/ip/ip_input_acl.c @@ -369,6 +369,8 @@ VLIB_REGISTER_NODE (ip4_inacl_node) = { }, }; +VLIB_NODE_FUNCTION_MULTIARCH (ip4_inacl_node, ip4_inacl) + static uword ip6_inacl (vlib_main_t * vm, vlib_node_runtime_t * node, @@ -392,6 +394,8 @@ VLIB_REGISTER_NODE (ip6_inacl_node) = { }, }; +VLIB_NODE_FUNCTION_MULTIARCH (ip6_inacl_node, ip6_inacl) + static clib_error_t * ip_inacl_init (vlib_main_t * vm) { diff --git a/vnet/vnet/ip/udp_local.c b/vnet/vnet/ip/udp_local.c index 253ad0f3..354dd4e8 100644 --- a/vnet/vnet/ip/udp_local.c +++ b/vnet/vnet/ip/udp_local.c @@ -327,6 +327,8 @@ VLIB_REGISTER_NODE (udp4_input_node) = { .unformat_buffer = unformat_udp_header, }; +VLIB_NODE_FUNCTION_MULTIARCH (udp4_input_node, udp4_input) + VLIB_REGISTER_NODE (udp6_input_node) = { .function = udp6_input, .name = "ip6-udp-lookup", @@ -350,6 +352,8 @@ VLIB_REGISTER_NODE (udp6_input_node) = { .unformat_buffer = unformat_udp_header, }; +VLIB_NODE_FUNCTION_MULTIARCH (udp6_input_node, udp6_input) + static void add_dst_port (udp_main_t * um, udp_dst_port_t dst_port, char * dst_port_name, u8 is_ip4) diff --git a/vnet/vnet/ipsec/esp_decrypt.c b/vnet/vnet/ipsec/esp_decrypt.c index 958a4d67..7af88b23 100644 --- a/vnet/vnet/ipsec/esp_decrypt.c +++ b/vnet/vnet/ipsec/esp_decrypt.c @@ -425,3 +425,5 @@ VLIB_REGISTER_NODE (esp_decrypt_node) = { }, }; +VLIB_NODE_FUNCTION_MULTIARCH (esp_decrypt_node, esp_decrypt_node_fn) + diff --git a/vnet/vnet/ipsec/esp_encrypt.c b/vnet/vnet/ipsec/esp_encrypt.c index 39bbf2e4..d1dbcf96 100644 --- a/vnet/vnet/ipsec/esp_encrypt.c +++ b/vnet/vnet/ipsec/esp_encrypt.c @@ -387,3 +387,5 @@ VLIB_REGISTER_NODE (esp_encrypt_node) = { }, }; +VLIB_NODE_FUNCTION_MULTIARCH (esp_encrypt_node, esp_encrypt_node_fn) + diff --git a/vnet/vnet/ipsec/ipsec_if_in.c b/vnet/vnet/ipsec/ipsec_if_in.c index 517f8bff..5a8a6858 100644 --- a/vnet/vnet/ipsec/ipsec_if_in.c +++ b/vnet/vnet/ipsec/ipsec_if_in.c @@ -148,4 +148,7 @@ VLIB_REGISTER_NODE (ipsec_if_input_node) = { [IPSEC_IF_INPUT_NEXT_ESP_DECRYPT] = "esp-decrypt", [IPSEC_IF_INPUT_NEXT_DROP] = "error-drop", }, -}; \ No newline at end of file +}; + +VLIB_NODE_FUNCTION_MULTIARCH (ipsec_if_input_node, ipsec_if_input_node_fn) + diff --git a/vnet/vnet/ipsec/ipsec_if_out.c b/vnet/vnet/ipsec/ipsec_if_out.c index 1e1dd528..9573c4f6 100644 --- a/vnet/vnet/ipsec/ipsec_if_out.c +++ b/vnet/vnet/ipsec/ipsec_if_out.c @@ -138,3 +138,5 @@ VLIB_REGISTER_NODE (ipsec_if_output_node) = { }, }; +VLIB_NODE_FUNCTION_MULTIARCH (ipsec_if_output_node, ipsec_if_output_node_fn) + diff --git a/vnet/vnet/ipsec/ipsec_input.c b/vnet/vnet/ipsec/ipsec_input.c index 3cd60ba1..09acd106 100644 --- a/vnet/vnet/ipsec/ipsec_input.c +++ b/vnet/vnet/ipsec/ipsec_input.c @@ -288,6 +288,9 @@ VLIB_REGISTER_NODE (ipsec_input_ip4_node,static) = { }, }; +VLIB_NODE_FUNCTION_MULTIARCH (ipsec_input_ip4_node, + ipsec_input_ip4_node_fn) + static vlib_node_registration_t ipsec_input_ip6_node; @@ -406,3 +409,7 @@ VLIB_REGISTER_NODE (ipsec_input_ip6_node,static) = { #undef _ }, }; + +VLIB_NODE_FUNCTION_MULTIARCH (ipsec_input_ip6_node, + ipsec_input_ip6_node_fn) + diff --git a/vnet/vnet/ipsec/ipsec_output.c b/vnet/vnet/ipsec/ipsec_output.c index 509b1e2f..93554681 100644 --- a/vnet/vnet/ipsec/ipsec_output.c +++ b/vnet/vnet/ipsec/ipsec_output.c @@ -405,6 +405,8 @@ VLIB_REGISTER_NODE (ipsec_output_node,static) = { }, }; +VLIB_NODE_FUNCTION_MULTIARCH (ipsec_output_node, ipsec_output_node_fn) + #else /* IPSEC > 1 */ /* Dummy ipsec output node, in case when IPSec is disabled */ diff --git a/vnet/vnet/l2/l2_classify.c b/vnet/vnet/l2/l2_classify.c index 449dea72..765bc686 100644 --- a/vnet/vnet/l2/l2_classify.c +++ b/vnet/vnet/l2/l2_classify.c @@ -399,6 +399,8 @@ VLIB_REGISTER_NODE (l2_classify_node) = { }, }; +VLIB_NODE_FUNCTION_MULTIARCH (l2_classify_node, l2_classify_node_fn) + clib_error_t *l2_classify_init (vlib_main_t *vm) { l2_classify_main_t * cm = &l2_classify_main; diff --git a/vnet/vnet/l2/l2_efp_filter.c b/vnet/vnet/l2/l2_efp_filter.c index b865c375..17b7eb3f 100644 --- a/vnet/vnet/l2/l2_efp_filter.c +++ b/vnet/vnet/l2/l2_efp_filter.c @@ -498,6 +498,8 @@ VLIB_REGISTER_NODE (l2_efp_filter_node,static) = { }, }; +VLIB_NODE_FUNCTION_MULTIARCH (l2_efp_filter_node, l2_efp_filter_node_fn) + clib_error_t *l2_efp_filter_init (vlib_main_t *vm) { l2_efp_filter_main_t * mp = &l2_efp_filter_main; diff --git a/vnet/vnet/l2/l2_flood.c b/vnet/vnet/l2/l2_flood.c index ca8c171c..9f71677c 100644 --- a/vnet/vnet/l2/l2_flood.c +++ b/vnet/vnet/l2/l2_flood.c @@ -442,6 +442,8 @@ VLIB_REGISTER_NODE (l2flood_node,static) = { }, }; +VLIB_NODE_FUNCTION_MULTIARCH (l2flood_node, l2flood_node_fn) + clib_error_t *l2flood_init (vlib_main_t *vm) { l2flood_main_t * mp = &l2flood_main; diff --git a/vnet/vnet/l2/l2_fwd.c b/vnet/vnet/l2/l2_fwd.c index 88a6b69c..5af83a75 100644 --- a/vnet/vnet/l2/l2_fwd.c +++ b/vnet/vnet/l2/l2_fwd.c @@ -367,6 +367,8 @@ VLIB_REGISTER_NODE (l2fwd_node,static) = { }, }; +VLIB_NODE_FUNCTION_MULTIARCH (l2fwd_node, l2fwd_node_fn) + clib_error_t *l2fwd_init (vlib_main_t *vm) { l2fwd_main_t * mp = &l2fwd_main; diff --git a/vnet/vnet/l2/l2_input.c b/vnet/vnet/l2/l2_input.c index 870aff68..dd3a8b75 100644 --- a/vnet/vnet/l2/l2_input.c +++ b/vnet/vnet/l2/l2_input.c @@ -433,6 +433,8 @@ VLIB_REGISTER_NODE (l2input_node) = { }, }; +VLIB_NODE_FUNCTION_MULTIARCH (l2input_node, l2input_node_fn) + clib_error_t *l2input_init (vlib_main_t *vm) { l2input_main_t * mp = &l2input_main; diff --git a/vnet/vnet/l2/l2_input_acl.c b/vnet/vnet/l2/l2_input_acl.c index 49df0f65..68c005f1 100644 --- a/vnet/vnet/l2/l2_input_acl.c +++ b/vnet/vnet/l2/l2_input_acl.c @@ -371,6 +371,8 @@ VLIB_REGISTER_NODE (l2_inacl_node,static) = { }, }; +VLIB_NODE_FUNCTION_MULTIARCH (l2_inacl_node, l2_inacl_node_fn) + clib_error_t *l2_inacl_init (vlib_main_t *vm) { l2_inacl_main_t * mp = &l2_inacl_main; diff --git a/vnet/vnet/l2/l2_input_vtr.c b/vnet/vnet/l2/l2_input_vtr.c index bbef33a9..d0f2181b 100644 --- a/vnet/vnet/l2/l2_input_vtr.c +++ b/vnet/vnet/l2/l2_input_vtr.c @@ -293,6 +293,8 @@ VLIB_REGISTER_NODE (l2_invtr_node,static) = { }, }; +VLIB_NODE_FUNCTION_MULTIARCH (l2_invtr_node, l2_invtr_node_fn) + clib_error_t *l2_invtr_init (vlib_main_t *vm) { l2_invtr_main_t * mp = &l2_invtr_main; diff --git a/vnet/vnet/l2/l2_learn.c b/vnet/vnet/l2/l2_learn.c index a891cb3c..0d94e43d 100644 --- a/vnet/vnet/l2/l2_learn.c +++ b/vnet/vnet/l2/l2_learn.c @@ -415,6 +415,7 @@ VLIB_REGISTER_NODE (l2learn_node,static) = { }, }; +VLIB_NODE_FUNCTION_MULTIARCH (l2learn_node, l2learn_node_fn) clib_error_t *l2learn_init (vlib_main_t *vm) { diff --git a/vnet/vnet/l2/l2_output.c b/vnet/vnet/l2/l2_output.c index a550d075..f5b22117 100644 --- a/vnet/vnet/l2/l2_output.c +++ b/vnet/vnet/l2/l2_output.c @@ -414,6 +414,8 @@ VLIB_REGISTER_NODE (l2output_node,static) = { }, }; +VLIB_NODE_FUNCTION_MULTIARCH (l2output_node, l2output_node_fn) + clib_error_t *l2output_init (vlib_main_t *vm) { l2output_main_t * mp = &l2output_main; diff --git a/vnet/vnet/l2/l2_output_acl.c b/vnet/vnet/l2/l2_output_acl.c index f75345f1..b222255f 100644 --- a/vnet/vnet/l2/l2_output_acl.c +++ b/vnet/vnet/l2/l2_output_acl.c @@ -274,6 +274,8 @@ VLIB_REGISTER_NODE (l2_outacl_node,static) = { }, }; +VLIB_NODE_FUNCTION_MULTIARCH (l2_outacl_node, l2_outacl_node_fn) + clib_error_t *l2_outacl_init (vlib_main_t *vm) { l2_outacl_main_t * mp = &l2_outacl_main; diff --git a/vnet/vnet/l2/l2_patch.c b/vnet/vnet/l2/l2_patch.c index 63be409d..0839142b 100644 --- a/vnet/vnet/l2/l2_patch.c +++ b/vnet/vnet/l2/l2_patch.c @@ -252,6 +252,8 @@ VLIB_REGISTER_NODE (l2_patch_node, static) = { }, }; +VLIB_NODE_FUNCTION_MULTIARCH (l2_patch_node, l2_patch_node_fn) + int vnet_l2_patch_add_del (u32 rx_sw_if_index, u32 tx_sw_if_index, int is_add) { l2_patch_main_t * l2pm = &l2_patch_main; diff --git a/vnet/vnet/l2/l2_rw.c b/vnet/vnet/l2/l2_rw.c index 93580c24..b66a7d34 100644 --- a/vnet/vnet/l2/l2_rw.c +++ b/vnet/vnet/l2/l2_rw.c @@ -604,3 +604,5 @@ VLIB_REGISTER_NODE (l2_rw_node) = { .next_nodes = { [L2_RW_NEXT_DROP] = "error-drop"}, }; +VLIB_NODE_FUNCTION_MULTIARCH (l2_rw_node, l2_rw_node_fn) + diff --git a/vnet/vnet/l2/l2_xcrw.c b/vnet/vnet/l2/l2_xcrw.c index f5fe3ca1..00542a19 100644 --- a/vnet/vnet/l2/l2_xcrw.c +++ b/vnet/vnet/l2/l2_xcrw.c @@ -255,6 +255,8 @@ VLIB_REGISTER_NODE (l2_xcrw_node, static) = { }, }; +VLIB_NODE_FUNCTION_MULTIARCH (l2_xcrw_node, l2_xcrw_node_fn) + clib_error_t *l2_xcrw_init (vlib_main_t *vm) { l2_xcrw_main_t * mp = &l2_xcrw_main; diff --git a/vnet/vnet/l2tp/decap.c b/vnet/vnet/l2tp/decap.c index 1a2bc489..5f0d05c0 100644 --- a/vnet/vnet/l2tp/decap.c +++ b/vnet/vnet/l2tp/decap.c @@ -247,6 +247,8 @@ VLIB_REGISTER_NODE (l2t_decap_node) = { }, }; +VLIB_NODE_FUNCTION_MULTIARCH (l2t_decap_node, l2t_decap_node_fn) + void l2tp_decap_init (void) { ip6_register_protocol (IP_PROTOCOL_L2TP, l2t_decap_node.index); diff --git a/vnet/vnet/l2tp/encap.c b/vnet/vnet/l2tp/encap.c index 8f26ab00..eca098cb 100644 --- a/vnet/vnet/l2tp/encap.c +++ b/vnet/vnet/l2tp/encap.c @@ -206,6 +206,8 @@ VLIB_REGISTER_NODE (l2t_encap_node) = { }, }; +VLIB_NODE_FUNCTION_MULTIARCH (l2t_encap_node, l2t_encap_node_fn) + void l2tp_encap_init (vlib_main_t * vm) { l2tp_encap_runtime_t * rt; diff --git a/vnet/vnet/lawful-intercept/node.c b/vnet/vnet/lawful-intercept/node.c index 26514cc5..8701c323 100644 --- a/vnet/vnet/lawful-intercept/node.c +++ b/vnet/vnet/lawful-intercept/node.c @@ -272,6 +272,8 @@ VLIB_REGISTER_NODE (li_hit_node) = { }, }; +VLIB_NODE_FUNCTION_MULTIARCH (li_hit_node, li_hit_node_fn) + #else #include diff --git a/vnet/vnet/mpls-gre/interface.c b/vnet/vnet/mpls-gre/interface.c index 408ca750..75cd022a 100644 --- a/vnet/vnet/mpls-gre/interface.c +++ b/vnet/vnet/mpls-gre/interface.c @@ -259,6 +259,9 @@ VNET_DEVICE_CLASS (mpls_gre_device_class) = { #endif }; +VLIB_DEVICE_TX_FUNCTION_MULTIARCH (mpls_gre_device_class, + mpls_gre_interface_tx) + VNET_HW_INTERFACE_CLASS (mpls_gre_hw_interface_class) = { .name = "MPLS-GRE", .format_header = format_mpls_gre_header_with_length, @@ -510,6 +513,8 @@ VNET_DEVICE_CLASS (mpls_eth_device_class) = { #endif }; +VLIB_DEVICE_TX_FUNCTION_MULTIARCH (mpls_eth_device_class, + mpls_eth_interface_tx) VNET_HW_INTERFACE_CLASS (mpls_eth_hw_interface_class) = { .name = "MPLS-ETH", @@ -676,6 +681,8 @@ VLIB_REGISTER_NODE (mpls_post_rewrite_node) = { }, }; +VLIB_NODE_FUNCTION_MULTIARCH (mpls_post_rewrite_node, mpls_post_rewrite) + static u8 * mpls_gre_rewrite (mpls_main_t *mm, mpls_gre_tunnel_t * t) { ip4_header_t * ip0; diff --git a/vnet/vnet/mpls-gre/node.c b/vnet/vnet/mpls-gre/node.c index 6bf5f814..474e2e2a 100644 --- a/vnet/vnet/mpls-gre/node.c +++ b/vnet/vnet/mpls-gre/node.c @@ -278,6 +278,8 @@ VLIB_REGISTER_NODE (mpls_input_node) = { .unformat_buffer = unformat_mpls_gre_header, }; +VLIB_NODE_FUNCTION_MULTIARCH (mpls_input_node, mpls_input) + static uword mpls_ethernet_input (vlib_main_t * vm, vlib_node_runtime_t * node, @@ -310,6 +312,8 @@ VLIB_REGISTER_NODE (mpls_ethernet_input_node) = { .unformat_buffer = unformat_mpls_gre_header, }; +VLIB_NODE_FUNCTION_MULTIARCH (mpls_ethernet_input_node, mpls_ethernet_input) + static void mpls_setup_nodes (vlib_main_t * vm) { diff --git a/vnet/vnet/mpls-gre/policy_encap.c b/vnet/vnet/mpls-gre/policy_encap.c index b4439193..e3f4beb6 100644 --- a/vnet/vnet/mpls-gre/policy_encap.c +++ b/vnet/vnet/mpls-gre/policy_encap.c @@ -153,6 +153,8 @@ VLIB_REGISTER_NODE (mpls_policy_encap_node) = { }, }; +VLIB_NODE_FUNCTION_MULTIARCH (mpls_policy_encap_node, mpls_policy_encap) + static clib_error_t * mpls_policy_encap_init (vlib_main_t * vm) { diff --git a/vnet/vnet/policer/node_funcs.c b/vnet/vnet/policer/node_funcs.c index 8a76e869..739ce455 100644 --- a/vnet/vnet/policer/node_funcs.c +++ b/vnet/vnet/policer/node_funcs.c @@ -324,6 +324,9 @@ VLIB_REGISTER_NODE (policer_by_sw_if_index_node, static) = { }, }; +VLIB_NODE_FUNCTION_MULTIARCH (policer_by_sw_if_index_node, + vnet_policer_by_sw_if_index); + int test_policer_add_del (u32 rx_sw_if_index, u8 *config_name, int is_add) diff --git a/vnet/vnet/sr/sr.c b/vnet/vnet/sr/sr.c index 46318a27..e0ef3181 100644 --- a/vnet/vnet/sr/sr.c +++ b/vnet/vnet/sr/sr.c @@ -653,6 +653,8 @@ VLIB_REGISTER_NODE (sr_rewrite_node) = { }, }; +VLIB_NODE_FUNCTION_MULTIARCH (sr_rewrite_node, sr_rewrite) + static int ip6_delete_route_no_next_hop (ip6_address_t *dst_address_arg, u32 dst_address_length, u32 rx_table_id) @@ -1911,6 +1913,8 @@ VLIB_REGISTER_NODE (sr_fix_dst_addr_node) = { }, }; +VLIB_NODE_FUNCTION_MULTIARCH (sr_fix_dst_addr_node, sr_fix_dst_addr) + static clib_error_t * sr_init (vlib_main_t * vm) { ip6_sr_main_t * sm = &sr_main; @@ -2560,6 +2564,8 @@ VLIB_REGISTER_NODE (sr_local_node, static) = { }, }; +VLIB_NODE_FUNCTION_MULTIARCH (sr_local_node, sr_local) + ip6_sr_main_t * sr_get_main (vlib_main_t * vm) { vlib_call_init_function (vm, sr_init); diff --git a/vnet/vnet/sr/sr_replicate.c b/vnet/vnet/sr/sr_replicate.c index 80d04ba6..ccc01465 100644 --- a/vnet/vnet/sr/sr_replicate.c +++ b/vnet/vnet/sr/sr_replicate.c @@ -350,6 +350,8 @@ VLIB_REGISTER_NODE (sr_replicate_node) = { }, }; +VLIB_NODE_FUNCTION_MULTIARCH (sr_replicate_node, sr_replicate_node_fn) + clib_error_t *sr_replicate_init (vlib_main_t *vm) { sr_replicate_main_t *msm = &sr_replicate_main; diff --git a/vnet/vnet/vxlan/decap.c b/vnet/vnet/vxlan/decap.c index bd61f4bb..00acd660 100644 --- a/vnet/vnet/vxlan/decap.c +++ b/vnet/vnet/vxlan/decap.c @@ -550,6 +550,8 @@ VLIB_REGISTER_NODE (vxlan4_input_node) = { // $$$$ .unformat_buffer = unformat_vxlan_header, }; +VLIB_NODE_FUNCTION_MULTIARCH (vxlan4_input_node, vxlan4_input) + VLIB_REGISTER_NODE (vxlan6_input_node) = { .function = vxlan6_input, .name = "vxlan6-input", @@ -570,3 +572,6 @@ VLIB_REGISTER_NODE (vxlan6_input_node) = { .format_trace = format_vxlan_rx_trace, // $$$$ .unformat_buffer = unformat_vxlan_header, }; + +VLIB_NODE_FUNCTION_MULTIARCH (vxlan6_input_node, vxlan6_input) + diff --git a/vnet/vnet/vxlan/encap.c b/vnet/vnet/vxlan/encap.c index ee5c7d5e..387a728a 100644 --- a/vnet/vnet/vxlan/encap.c +++ b/vnet/vnet/vxlan/encap.c @@ -586,3 +586,6 @@ VLIB_REGISTER_NODE (vxlan_encap_node) = { [VXLAN_ENCAP_NEXT_DROP] = "error-drop", }, }; + +VLIB_NODE_FUNCTION_MULTIARCH (vxlan_encap_node, vxlan_encap) + diff --git a/vpp/app/l2t_ip6.c b/vpp/app/l2t_ip6.c index ac24886a..8a1e23a9 100644 --- a/vpp/app/l2t_ip6.c +++ b/vpp/app/l2t_ip6.c @@ -274,6 +274,8 @@ static VLIB_REGISTER_NODE (sw6_ip6_node) = { }, }; +VLIB_NODE_FUNCTION_MULTIARCH (sw6_ip6_node, ip6_l2t_node_fn) + static clib_error_t * l2tp_config (vlib_main_t * vm, unformat_input_t * input) { diff --git a/vpp/app/l2t_l2.c b/vpp/app/l2t_l2.c index 5c8327d5..f6385a5a 100644 --- a/vpp/app/l2t_l2.c +++ b/vpp/app/l2t_l2.c @@ -250,3 +250,5 @@ VLIB_REGISTER_NODE (l2t_l2_node) = { }, }; +VLIB_NODE_FUNCTION_MULTIARCH (l2t_l2_node, l2t_l2_node_fn) + diff --git a/vpp/app/version.c b/vpp/app/version.c index 588aadf2..22bec400 100644 --- a/vpp/app/version.c +++ b/vpp/app/version.c @@ -59,6 +59,7 @@ show_vpe_version_command_fn (vlib_main_t * vm, _("Compiler", "%s", vpe_compiler); _("CPU model name", "%U", format_cpu_model_name); _("CPU microarchitecture", "%U", format_cpu_uarch); + _("CPU flags", "%U", format_cpu_flags); _("Current PID", "%d", getpid()); #if DPDK > 0 _("DPDK Version", "%s", rte_version()); diff --git a/vpp/vnet/main.c b/vpp/vnet/main.c index f707994b..25400839 100644 --- a/vpp/vnet/main.c +++ b/vpp/vnet/main.c @@ -12,6 +12,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +#include #include #include #include @@ -59,33 +61,32 @@ int main (int argc, char * argv[]) u32 size; void vlib_set_get_handoff_structure_cb (void *cb); -#if __x86_64__ && !defined(__clang__) - __builtin_cpu_init (); +#if __x86_64__ const char * msg = "ERROR: This binary requires CPU with %s extensions.\n"; #define _(a,b) \ - if (!__builtin_cpu_supports(a)) \ + if (!clib_cpu_supports_ ## a ()) \ { \ fprintf(stderr, msg, b); \ exit(1); \ } #if __AVX2__ - _("avx2", "AVX2") + _(avx2, "AVX2") #endif #if __AVX__ - _("avx", "AVX") + _(avx, "AVX") #endif #if __SSE4_2__ - _("sse4.2", "SSE4.2") + _(sse42, "SSE4.2") #endif #if __SSE4_1__ - _("sse4.1", "SSE4.1") + _(sse41, "SSE4.1") #endif #if __SSSE3__ - _("ssse3", "SSSE3") + _(ssse3, "SSSE3") #endif #if __SSE3__ - _("sse3", "SSE3") + _(sse3, "SSE3") #endif #undef _ #endif diff --git a/vppinfra/vppinfra/cpu.c b/vppinfra/vppinfra/cpu.c index f2dbaf1f..9008ee3d 100644 --- a/vppinfra/vppinfra/cpu.c +++ b/vppinfra/vppinfra/cpu.c @@ -16,10 +16,6 @@ #include #include -#if __x86_64__ -#include -#endif - #define foreach_x86_cpu_uarch \ _(0x06, 0x4f, "Broadwell", "Broadwell-EP/EX") \ _(0x06, 0x3d, "Broadwell", "Broadwell") \ @@ -108,4 +104,21 @@ format_cpu_model_name (u8 * s, va_list * args) #else /* ! __x86_64__ */ return format (s, "unknown"); #endif -} \ No newline at end of file +} + +u8 * +format_cpu_flags (u8 * s, va_list * args) +{ +#if __x86_64__ +#define _(flag, func, reg, bit) \ + if (clib_cpu_supports_ ## flag()) \ + s = format (s, #flag " "); + foreach_x86_64_flags + return s; +#undef _ +#else /* ! __x86_64__ */ + return format (s, "unknown"); +#endif +} + + diff --git a/vppinfra/vppinfra/cpu.h b/vppinfra/vppinfra/cpu.h index 79cdf74f..961af709 100644 --- a/vppinfra/vppinfra/cpu.h +++ b/vppinfra/vppinfra/cpu.h @@ -16,7 +16,83 @@ #ifndef included_clib_cpu_h #define included_clib_cpu_h +#include + +/* + * multiarchitecture support. Adding new entry will produce + * new graph node function variant optimized for specific cpu + * microarchitecture. + * Order is important for runtime selection, as 1st match wins... + */ + +#if __x86_64__ && CLIB_DEBUG == 0 +#define foreach_march_variant(macro, x) \ + macro(avx2, x, "arch=core-avx2") +#else +#define foreach_march_variant(macro, x) +#endif + + +#if __GNUC__ > 4 && !__clang__ +#define CLIB_CPU_OPTIMIZED __attribute__ ((optimize ("tree-vectorize"))) +#else +#define CLIB_CPU_OPTIMIZED +#endif + + +#define CLIB_MULTIARCH_ARCH_CHECK(arch, fn, tgt) \ + if (clib_cpu_supports_ ## arch()) \ + return & fn ## _ ##arch; + +#define CLIB_MULTIARCH_SELECT_FN(fn,...) \ + __VA_ARGS__ void * fn ## _multiarch_select(void) \ +{ \ + foreach_march_variant(CLIB_MULTIARCH_ARCH_CHECK, fn) \ + return & fn; \ +} + +#if __x86_64__ +#include "cpuid.h" + +#define foreach_x86_64_flags \ +_ (sse3, 1, ecx, 0) \ +_ (ssse3, 1, ecx, 9) \ +_ (sse41, 1, ecx, 19) \ +_ (sse42, 1, ecx, 20) \ +_ (avx, 1, ecx, 28) \ +_ (avx2, 7, ebx, 5) \ +_ (avx512f, 7, ebx, 16) \ +_ (aes, 1, ecx, 25) \ +_ (sha, 7, ebx, 29) + +static inline int +clib_get_cpuid(const u32 lev, u32 * eax, u32 *ebx, u32 * ecx, u32 * edx) +{ + if ((u32) __get_cpuid_max (0x80000000 & lev, 0) < lev) + return 0; + if (lev == 7) + __cpuid_count(lev, 0, *eax, *ebx, *ecx, *edx); + else + __cpuid(lev, *eax, *ebx, *ecx, *edx); + return 1; +} + + +#define _(flag, func, reg, bit) \ +static inline int \ +clib_cpu_supports_ ## flag() \ +{ \ + u32 __attribute__((unused)) eax, ebx = 0, ecx = 0, edx = 0; \ + clib_get_cpuid (func, &eax, &ebx, &ecx, &edx); \ + \ + return ((reg & (1 << bit)) != 0); \ +} + foreach_x86_64_flags +#undef _ +#endif + format_function_t format_cpu_uarch; format_function_t format_cpu_model_name; +format_function_t format_cpu_flags; -#endif \ No newline at end of file +#endif -- cgit 1.2.3-korg From 154d445f7f8f1553d9bb00d1be42bf1b06eda9f1 Mon Sep 17 00:00:00 2001 From: Damjan Marion Date: Tue, 28 Jun 2016 19:10:41 +0200 Subject: Fix native build on non x86_64 systems Change-Id: Iab9f6793112f19a5b54a555623d84099aa8bb03e Signed-off-by: Damjan Marion --- build-data/platforms/vpp.mk | 6 ++++++ build-data/platforms/vpp_lite.mk | 5 +++++ vnet/vnet/devices/nic/ixge.c | 2 ++ 3 files changed, 13 insertions(+) (limited to 'build-data/platforms/vpp.mk') diff --git a/build-data/platforms/vpp.mk b/build-data/platforms/vpp.mk index ec0d874d..9026ad32 100644 --- a/build-data/platforms/vpp.mk +++ b/build-data/platforms/vpp.mk @@ -13,9 +13,15 @@ # vector packet processor vpp_arch = native +ifeq ($(shell uname -m),x86_64) vpp_march = corei7 # Nehalem Instruction set vpp_mtune = corei7-avx # Optimize for Sandy Bridge vpp_dpdk_arch = corei7 +else +vpp_march = native +vpp_mtune = generic +vpp_dpdk_arch = native +endif vpp_native_tools = vppapigen vpp_uses_dpdk = yes diff --git a/build-data/platforms/vpp_lite.mk b/build-data/platforms/vpp_lite.mk index a28fec2f..9375a7a9 100644 --- a/build-data/platforms/vpp_lite.mk +++ b/build-data/platforms/vpp_lite.mk @@ -13,8 +13,13 @@ # vector packet processor vpp_lite_arch = native +ifeq ($(shell uname -m),x86_64) vpp_lite_march = corei7 # Nehalem Instruction set vpp_lite_mtune = corei7-avx # Optimize for Sandy Bridge +else +vpp_lite_march = native +vpp_lite_mtune = generic +endif vpp_lite_native_tools = vppapigen vpp_lite_uses_dpdk = no diff --git a/vnet/vnet/devices/nic/ixge.c b/vnet/vnet/devices/nic/ixge.c index cd08379e..b98e7d9c 100644 --- a/vnet/vnet/devices/nic/ixge.c +++ b/vnet/vnet/devices/nic/ixge.c @@ -20,6 +20,7 @@ * Please use supported DPDK driver instead. */ +#if __x86_64__ #include #ifndef CLIB_HAVE_VEC128 @@ -2815,3 +2816,4 @@ void ixge_set_next_node (ixge_rx_next_t next, char *name) break; } } +#endif -- cgit 1.2.3-korg From 20c02cb133cf7b8a0570b83acf927d5a0d601a36 Mon Sep 17 00:00:00 2001 From: Dave Barach Date: Sun, 26 Jun 2016 10:42:08 -0400 Subject: Simple ip4 NAT plugin Change-Id: Iffe77bf2a05ced41474540ff54a842101aad7c41 Signed-off-by: Dave Barach --- build-data/platforms/vpp.mk | 4 + plugins/Makefile.am | 4 + plugins/configure.ac | 43 +- plugins/snat-plugin/Makefile.am | 55 ++ plugins/snat-plugin/configure.ac | 27 + plugins/snat-plugin/snat/in2out.c | 953 ++++++++++++++++++++++++++++++ plugins/snat-plugin/snat/out2in.c | 601 +++++++++++++++++++ plugins/snat-plugin/snat/snat.api | 25 + plugins/snat-plugin/snat/snat.c | 716 ++++++++++++++++++++++ plugins/snat-plugin/snat/snat.h | 181 ++++++ plugins/snat-plugin/snat/snat_all_api_h.h | 19 + plugins/snat-plugin/snat/snat_msg_enum.h | 31 + plugins/snat-plugin/snat/snat_test.c | 265 +++++++++ vpp/Makefile.am | 10 +- 14 files changed, 2928 insertions(+), 6 deletions(-) create mode 100644 plugins/snat-plugin/Makefile.am create mode 100644 plugins/snat-plugin/configure.ac create mode 100644 plugins/snat-plugin/snat/in2out.c create mode 100644 plugins/snat-plugin/snat/out2in.c create mode 100644 plugins/snat-plugin/snat/snat.api create mode 100644 plugins/snat-plugin/snat/snat.c create mode 100644 plugins/snat-plugin/snat/snat.h create mode 100644 plugins/snat-plugin/snat/snat_all_api_h.h create mode 100644 plugins/snat-plugin/snat/snat_msg_enum.h create mode 100644 plugins/snat-plugin/snat/snat_test.c (limited to 'build-data/platforms/vpp.mk') diff --git a/build-data/platforms/vpp.mk b/build-data/platforms/vpp.mk index 9026ad32..45f74d33 100644 --- a/build-data/platforms/vpp.mk +++ b/build-data/platforms/vpp.mk @@ -38,6 +38,10 @@ vnet_configure_args_vpp = --with-dpdk # Set these parameters carefully. The vlib_buffer_t is 128 bytes, i.e. vlib_configure_args_vpp = --with-pre-data=128 +# Enable plugins here, and no place else, via multiple --enable-XXX-plugin +# stanzas. +plugins_configure_args_vpp = --with-dpdk --enable-sixrd-plugin + # DPDK configuration parameters # vpp_uses_external_dpdk = yes # vpp_dpdk_inc_dir = /usr/include/dpdk diff --git a/plugins/Makefile.am b/plugins/Makefile.am index 1fcc18ec..83dc70bf 100644 --- a/plugins/Makefile.am +++ b/plugins/Makefile.am @@ -29,3 +29,7 @@ endif if ENABLE_VCGN_PLUGIN SUBDIRS += vcgn-plugin endif + +if ENABLE_SNAT_PLUGIN +SUBDIRS += snat-plugin +endif diff --git a/plugins/configure.ac b/plugins/configure.ac index 40c0babd..8a5fdbc2 100644 --- a/plugins/configure.ac +++ b/plugins/configure.ac @@ -17,10 +17,30 @@ AC_ARG_WITH(plugin-toolkit, [with_plugin_toolkit=${prefix}/include], [with_plugin_toolkit=.]) +AC_ARG_WITH(dpdk, + AC_HELP_STRING([--with-dpdk],[Use the Intel dpdk]), + [with_dpdk=1], + [with_dpdk=0]) + AC_SUBST(TOOLKIT_INCLUDE,[${with_plugin_toolkit}]) AM_CONDITIONAL(WITH_PLUGIN_TOOLKIT, test "$with_plugin_toolkit" != ".") AM_CONDITIONAL(ENABLE_TESTS, test "$enable_tests" = "1") +AM_CONDITIONAL(WITH_DPDK, test "$with_dpdk" = "1") +AC_SUBST(DPDK,["-DDPDK=${with_dpdk}"]) + + +# +# Please DO NOT, UNDER ANY CIRCUMSTANCES enable or disable +# plugins by "clever" manipulation of the arguments to AC_ARG_ENABLE +# +# Instead, please configure the default set of plugins in +# .../build-data/platforms/.mk, by adding --enable-XXX-plugin +# stanzas to plugins_configure_args_ + +# The following per-plugin boilerplate is begging for an additional +# macro, but the first 10 tries at making one didn't work. Another day. + # # Sample plugin # @@ -40,8 +60,8 @@ AM_CONDITIONAL(ENABLE_SAMPLE_PLUGIN, test "$enable_sample_plugin" = "1") # AC_ARG_ENABLE(sixrd_plugin, AC_HELP_STRING([--enable-sixrd-plugin], [Build sixrd plugin]), - [], - [enable_sixrd_plugin=1]) + [enable_sixrd_plugin=1], + [enable_sixrd_plugin=0]) if test "x$enable_sixrd_plugin" = x1; then AC_CONFIG_SUBDIRS([sixrd-plugin]) @@ -54,8 +74,8 @@ AM_CONDITIONAL(ENABLE_SIXRD_PLUGIN, test "$enable_sixrd_plugin" = "1") # AC_ARG_ENABLE(ioam_plugin, AC_HELP_STRING([--enable-ioam-plugin], [Build ioam plugin]), - [], - [enable_ioam_plugin=1]) + [enable_ioam_plugin=1], + [enable_ioam_plugin=0]) if test "x$enable_ioam_plugin" = x1; then AC_CONFIG_SUBDIRS([ioam-plugin]) @@ -77,4 +97,19 @@ fi AM_CONDITIONAL(ENABLE_VCGN_PLUGIN, test "$enable_vcgn_plugin" = "1") +# +# SNAT plugin +# +AC_ARG_ENABLE(snat_plugin, + AC_HELP_STRING([--enable-snat-plugin], [Build snat plugin]), + [enable_snat_plugin=1], + [enable_snat_plugin=0]) + +if test "x$enable_snat_plugin" = x1; then + AC_CONFIG_SUBDIRS([snat-plugin]) +fi + +AM_CONDITIONAL(ENABLE_SNAT_PLUGIN, test "$enable_snat_plugin" = "1") + + AC_OUTPUT([Makefile]) diff --git a/plugins/snat-plugin/Makefile.am b/plugins/snat-plugin/Makefile.am new file mode 100644 index 00000000..11b0839a --- /dev/null +++ b/plugins/snat-plugin/Makefile.am @@ -0,0 +1,55 @@ + +# Copyright (c) +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +AUTOMAKE_OPTIONS = foreign subdir-objects + +AM_CFLAGS = -Wall -I@TOOLKIT_INCLUDE@ @DPDK@ + +lib_LTLIBRARIES = snat_plugin.la snat_test_plugin.la + +snat_plugin_la_SOURCES = snat/snat.c \ + snat/in2out.c \ + snat/out2in.c \ + snat/snat_plugin.api.h + +snat_plugin_la_LDFLAGS = -module + +BUILT_SOURCES = snat/snat.api.h + +SUFFIXES = .api.h .api + +%.api.h: %.api + mkdir -p `dirname $@` ; \ + $(CC) $(CPPFLAGS) -E -P -C -x c $^ \ + | vppapigen --input - --output $@ --show-name $@ + +nobase_include_HEADERS = \ + snat/snat_all_api_h.h \ + snat/snat_msg_enum.h \ + snat/snat.api.h + +snat_test_plugin_la_SOURCES = \ + snat/snat_test.c snat/snat_plugin.api.h +snat_test_plugin_la_LDFLAGS = -module + +if WITH_PLUGIN_TOOLKIT +install-data-hook: + mkdir /usr/lib/vpp_plugins || true + mkdir /usr/lib/vpp_api_test_plugins || true + cp -L $(prefix)/lib/snat_plugin.so /usr/lib/vpp_plugins + cp -L $(prefix)/lib/snat_test_plugin.so \ + /usr/lib/vpp_api_test_plugins + rm -f $(prefix)/lib/snat_plugin.* + rm -f $(prefix)/lib/snat_test_plugin.* +endif diff --git a/plugins/snat-plugin/configure.ac b/plugins/snat-plugin/configure.ac new file mode 100644 index 00000000..e43437d2 --- /dev/null +++ b/plugins/snat-plugin/configure.ac @@ -0,0 +1,27 @@ + +AC_INIT(snat_plugin, 1.0) +AM_INIT_AUTOMAKE + +AC_PROG_LIBTOOL +AM_PROG_AS +AC_PROG_CC +AM_PROG_CC_C_O + +AC_ARG_WITH(dpdk, + AC_HELP_STRING([--with-dpdk],[Use the Intel dpdk]), + [with_dpdk=1], + [with_dpdk=0]) + +AM_CONDITIONAL(WITH_DPDK, test "$with_dpdk" = "1") +AC_SUBST(DPDK,["-DDPDK=${with_dpdk}"]) + +AC_ARG_WITH(plugin-toolkit, + AC_HELP_STRING([--with-plugin-toolkit], + [build using the vpp toolkit]), + [with_plugin_toolkit=${prefix}/include], + [with_plugin_toolkit=.]) + +AC_SUBST(TOOLKIT_INCLUDE,[${with_plugin_toolkit}]) +AM_CONDITIONAL(WITH_PLUGIN_TOOLKIT, test "$with_plugin_toolkit" != ".") + +AC_OUTPUT([Makefile]) diff --git a/plugins/snat-plugin/snat/in2out.c b/plugins/snat-plugin/snat/in2out.c new file mode 100644 index 00000000..3f7df910 --- /dev/null +++ b/plugins/snat-plugin/snat/in2out.c @@ -0,0 +1,953 @@ +/* + * Copyright (c) 2016 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include + +#include +#include +#include + +#include +#include +#include + +vlib_node_registration_t snat_in2out_node, snat_in2out_slowpath_node; + +typedef struct { + u32 sw_if_index; + u32 next_index; + u32 session_index; + u32 is_slow_path; +} snat_in2out_trace_t; + +/* packet trace format function */ +static u8 * format_snat_in2out_trace (u8 * s, va_list * args) +{ + CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *); + CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *); + snat_in2out_trace_t * t = va_arg (*args, snat_in2out_trace_t *); + char * tag; + + tag = t->is_slow_path ? "SNAT_IN2OUT_SLOW_PATH" : "SNAT_IN2OUT_FAST_PATH"; + + s = format (s, "%s: sw_if_index %d, next index %d, session %d", tag, + t->sw_if_index, t->next_index, t->session_index); + + return s; +} + +vlib_node_registration_t snat_in2out_node; + +#define foreach_snat_in2out_error \ +_(UNSUPPORTED_PROTOCOL, "Unsupported protocol") \ +_(IN2OUT_PACKETS, "Good in2out packets processed") \ +_(OUT_OF_PORTS, "Out of ports") \ +_(BAD_OUTSIDE_FIB, "Outside VRF ID not found") \ +_(BAD_ICMP_TYPE, "icmp type not echo-request") + +typedef enum { +#define _(sym,str) SNAT_IN2OUT_ERROR_##sym, + foreach_snat_in2out_error +#undef _ + SNAT_IN2OUT_N_ERROR, +} snat_in2out_error_t; + +static char * snat_in2out_error_strings[] = { +#define _(sym,string) string, + foreach_snat_in2out_error +#undef _ +}; + +typedef enum { + SNAT_IN2OUT_NEXT_LOOKUP, + SNAT_IN2OUT_NEXT_DROP, + SNAT_IN2OUT_NEXT_SLOW_PATH, + SNAT_IN2OUT_N_NEXT, +} snat_in2out_next_t; + + +static u32 slow_path (snat_main_t *sm, vlib_buffer_t *b0, + ip4_header_t * ip0, + u32 rx_fib_index0, + snat_session_key_t * key0, + snat_session_t ** sessionp, + vlib_node_runtime_t * node, + u32 next0) +{ + snat_user_t *u; + snat_user_key_t user_key; + snat_session_t *s; + clib_bihash_kv_8_8_t kv0, value0; + u32 oldest_per_user_translation_list_index; + dlist_elt_t * oldest_per_user_translation_list_elt; + dlist_elt_t * per_user_translation_list_elt; + dlist_elt_t * per_user_list_head_elt; + u32 session_index; + snat_session_key_t key1; + u32 address_index; + u32 outside_fib_index; + uword * p; + + p = hash_get (sm->ip4_main->fib_index_by_table_id, sm->outside_vrf_id); + if (! p) + { + b0->error = node->errors[SNAT_IN2OUT_ERROR_BAD_OUTSIDE_FIB]; + return SNAT_IN2OUT_NEXT_DROP; + } + outside_fib_index = p[0]; + + user_key.addr = ip0->src_address; + user_key.fib_index = rx_fib_index0; + kv0.key = user_key.as_u64; + + /* Ever heard of the "user" = src ip4 address before? */ + if (clib_bihash_search_8_8 (&sm->user_hash, &kv0, &value0)) + { + /* no, make a new one */ + pool_get (sm->users, u); + memset (u, 0, sizeof (*u)); + u->addr = ip0->src_address; + + pool_get (sm->list_pool, per_user_list_head_elt); + + u->sessions_per_user_list_head_index = per_user_list_head_elt - + sm->list_pool; + + clib_dlist_init (sm->list_pool, u->sessions_per_user_list_head_index); + + kv0.value = u - sm->users; + + /* add user */ + clib_bihash_add_del_8_8 (&sm->user_hash, &kv0, 1 /* is_add */); + } + else + { + u = pool_elt_at_index (sm->users, value0.value); + } + + /* Over quota? Recycle the least recently used translation */ + if (u->nsessions >= sm->max_translations_per_user) + { + /* Remove the oldest translation */ + oldest_per_user_translation_list_index = + clib_dlist_remove_head + (sm->list_pool, u->sessions_per_user_list_head_index); + + ASSERT (oldest_per_user_translation_list_index != ~0); + + /* add it back to the end of the LRU list */ + clib_dlist_addtail (sm->list_pool, u->sessions_per_user_list_head_index, + oldest_per_user_translation_list_index); + + /* Get the list element */ + oldest_per_user_translation_list_elt = + pool_elt_at_index (sm->list_pool, + oldest_per_user_translation_list_index); + + /* Get the session index from the list element */ + session_index = oldest_per_user_translation_list_elt->value; + + /* Get the session */ + s = pool_elt_at_index (sm->sessions, session_index); + + /* Remove in2out, out2in keys */ + kv0.key = s->in2out.as_u64; + if (clib_bihash_add_del_8_8 (&sm->in2out, &kv0, 0 /* is_add */)) + clib_warning ("in2out key delete failed"); + kv0.key = s->out2in.as_u64; + if (clib_bihash_add_del_8_8 (&sm->out2in, &kv0, 0 /* is_add */)) + clib_warning ("out2in key delete failed"); + + snat_free_outside_address_and_port + (sm, &s->out2in, s->outside_address_index); + s->outside_address_index = ~0; + + if (snat_alloc_outside_address_and_port (sm, &key1, &address_index)) + { + ASSERT(0); + + b0->error = node->errors[SNAT_IN2OUT_ERROR_OUT_OF_PORTS]; + return SNAT_IN2OUT_NEXT_DROP; + } + s->outside_address_index = address_index; + } + else + { + if (snat_alloc_outside_address_and_port (sm, &key1, &address_index)) + { + ASSERT(0); + + b0->error = node->errors[SNAT_IN2OUT_ERROR_OUT_OF_PORTS]; + return SNAT_IN2OUT_NEXT_DROP; + } + + /* Create a new session */ + pool_get (sm->sessions, s); + memset (s, 0, sizeof (*s)); + + s->outside_address_index = address_index; + + /* Create list elts */ + pool_get (sm->list_pool, per_user_translation_list_elt); + clib_dlist_init (sm->list_pool, per_user_translation_list_elt - + sm->list_pool); + + per_user_translation_list_elt->value = s - sm->sessions; + s->per_user_index = per_user_translation_list_elt - sm->list_pool; + s->per_user_list_head_index = u->sessions_per_user_list_head_index; + + clib_dlist_addtail (sm->list_pool, s->per_user_list_head_index, + per_user_translation_list_elt - sm->list_pool); + u->nsessions++; + } + + s->in2out = *key0; + s->out2in = key1; + s->out2in.protocol = key0->protocol; + s->out2in.fib_index = outside_fib_index; + *sessionp = s; + + /* Add to translation hashes */ + kv0.key = s->in2out.as_u64; + kv0.value = s - sm->sessions; + if (clib_bihash_add_del_8_8 (&sm->in2out, &kv0, 1 /* is_add */)) + clib_warning ("in2out key add failed"); + + kv0.key = s->out2in.as_u64; + kv0.value = s - sm->sessions; + + if (clib_bihash_add_del_8_8 (&sm->out2in, &kv0, 1 /* is_add */)) + clib_warning ("out2in key add failed"); + + return next0; +} + +static inline u32 icmp_in2out_slow_path (snat_main_t *sm, + vlib_buffer_t * b0, + ip4_header_t * ip0, + icmp46_header_t * icmp0, + u32 sw_if_index0, + u32 rx_fib_index0, + vlib_node_runtime_t * node, + u32 next0, + f64 now) +{ + snat_session_key_t key0; + icmp_echo_header_t *echo0; + clib_bihash_kv_8_8_t kv0, value0; + snat_session_t * s0; + u32 new_addr0, old_addr0; + u16 old_id0, new_id0; + ip_csum_t sum0; + snat_runtime_t * rt = (snat_runtime_t *)node->runtime_data; + + if (PREDICT_FALSE(icmp0->type != ICMP4_echo_request)) + { + b0->error = node->errors[SNAT_IN2OUT_ERROR_BAD_ICMP_TYPE]; + return SNAT_IN2OUT_NEXT_DROP; + } + + echo0 = (icmp_echo_header_t *)(icmp0+1); + + key0.addr = ip0->src_address; + key0.port = echo0->identifier; + key0.protocol = SNAT_PROTOCOL_ICMP; + key0.fib_index = rx_fib_index0; + + kv0.key = key0.as_u64; + + if (clib_bihash_search_8_8 (&sm->in2out, &kv0, &value0)) + { + ip4_address_t * first_int_addr; + + if (PREDICT_FALSE(rt->cached_sw_if_index != sw_if_index0)) + { + first_int_addr = + ip4_interface_first_address (sm->ip4_main, sw_if_index0, + 0 /* just want the address */); + rt->cached_sw_if_index = sw_if_index0; + rt->cached_ip4_address = first_int_addr->as_u32; + } + + /* Don't NAT packet aimed at the intfc address */ + if (PREDICT_FALSE(ip0->dst_address.as_u32 == + rt->cached_ip4_address)) + return next0; + + next0 = slow_path (sm, b0, ip0, rx_fib_index0, &key0, + &s0, node, next0); + + if (PREDICT_FALSE (next0 == SNAT_IN2OUT_NEXT_DROP)) + return next0; + } + else + s0 = pool_elt_at_index (sm->sessions, value0.value); + + old_addr0 = ip0->src_address.as_u32; + ip0->src_address = s0->out2in.addr; + new_addr0 = ip0->src_address.as_u32; + vnet_buffer(b0)->sw_if_index[VLIB_TX] = s0->out2in.fib_index; + + sum0 = ip0->checksum; + sum0 = ip_csum_update (sum0, old_addr0, new_addr0, + ip4_header_t, + src_address /* changed member */); + ip0->checksum = ip_csum_fold (sum0); + + old_id0 = echo0->identifier; + new_id0 = s0->out2in.port; + echo0->identifier = new_id0; + + sum0 = icmp0->checksum; + sum0 = ip_csum_update (sum0, old_id0, new_id0, icmp_echo_header_t, + identifier); + icmp0->checksum = ip_csum_fold (sum0); + + /* Accounting, per-user LRU list maintenance */ + s0->last_heard = now; + s0->total_pkts++; + s0->total_bytes += vlib_buffer_length_in_chain (sm->vlib_main, b0); + clib_dlist_remove (sm->list_pool, s0->per_user_index); + clib_dlist_addtail (sm->list_pool, s0->per_user_list_head_index, + s0->per_user_index); + + return next0; +} + +static inline uword +snat_in2out_node_fn_inline (vlib_main_t * vm, + vlib_node_runtime_t * node, + vlib_frame_t * frame, int is_slow_path) +{ + u32 n_left_from, * from, * to_next; + snat_in2out_next_t next_index; + u32 pkts_processed = 0; + snat_main_t * sm = &snat_main; + snat_runtime_t * rt = (snat_runtime_t *)node->runtime_data; + f64 now = vlib_time_now (vm); + u32 stats_node_index; + + stats_node_index = is_slow_path ? snat_in2out_slowpath_node.index : + snat_in2out_node.index; + + from = vlib_frame_vector_args (frame); + n_left_from = frame->n_vectors; + next_index = node->cached_next_index; + + while (n_left_from > 0) + { + u32 n_left_to_next; + + vlib_get_next_frame (vm, node, next_index, + to_next, n_left_to_next); + + while (n_left_from >= 4 && n_left_to_next >= 2) + { + u32 bi0, bi1; + vlib_buffer_t * b0, * b1; + u32 next0, next1; + u32 sw_if_index0, sw_if_index1; + ip4_header_t * ip0, * ip1; + ip_csum_t sum0, sum1; + u32 new_addr0, old_addr0, new_addr1, old_addr1; + u16 old_port0, new_port0, old_port1, new_port1; + udp_header_t * udp0, * udp1; + tcp_header_t * tcp0, * tcp1; + icmp46_header_t * icmp0, * icmp1; + snat_session_key_t key0, key1; + u32 rx_fib_index0, rx_fib_index1; + u32 proto0, proto1; + snat_session_t * s0 = 0, * s1 = 0; + clib_bihash_kv_8_8_t kv0, value0, kv1, value1; + + /* Prefetch next iteration. */ + { + vlib_buffer_t * p2, * p3; + + p2 = vlib_get_buffer (vm, from[2]); + p3 = vlib_get_buffer (vm, from[3]); + + vlib_prefetch_buffer_header (p2, LOAD); + vlib_prefetch_buffer_header (p3, LOAD); + + CLIB_PREFETCH (p2->data, CLIB_CACHE_LINE_BYTES, STORE); + CLIB_PREFETCH (p3->data, CLIB_CACHE_LINE_BYTES, STORE); + } + + /* speculatively enqueue b0 and b1 to the current next frame */ + to_next[0] = bi0 = from[0]; + to_next[1] = bi1 = from[1]; + from += 2; + to_next += 2; + n_left_from -= 2; + n_left_to_next -= 2; + + b0 = vlib_get_buffer (vm, bi0); + b1 = vlib_get_buffer (vm, bi1); + + ip0 = vlib_buffer_get_current (b0); + udp0 = ip4_next_header (ip0); + tcp0 = (tcp_header_t *) udp0; + icmp0 = (icmp46_header_t *) udp0; + + sw_if_index0 = vnet_buffer(b0)->sw_if_index[VLIB_RX]; + rx_fib_index0 = vec_elt (sm->ip4_main->fib_index_by_sw_if_index, + sw_if_index0); + + next0 = next1 = SNAT_IN2OUT_NEXT_LOOKUP; + +#if 0 + /* Formally correct, but we send to slowpath, lookup or drop */ + vnet_get_config_data (&cm->config_main, + &b0->current_config_index, + &next0, + 0 /* sizeof config data */); +#endif + + proto0 = ~0; + proto0 = (ip0->protocol == IP_PROTOCOL_UDP) + ? SNAT_PROTOCOL_UDP : proto0; + proto0 = (ip0->protocol == IP_PROTOCOL_TCP) + ? SNAT_PROTOCOL_TCP : proto0; + proto0 = (ip0->protocol == IP_PROTOCOL_ICMP) + ? SNAT_PROTOCOL_ICMP : proto0; + + /* Next configured feature, probably ip4-lookup */ + if (is_slow_path) + { + if (PREDICT_FALSE (proto0 == ~0)) + goto trace00; + + if (PREDICT_FALSE (proto0 == SNAT_PROTOCOL_ICMP)) + { + next0 = icmp_in2out_slow_path + (sm, b0, ip0, icmp0, sw_if_index0, rx_fib_index0, + node, next0, now); + goto trace00; + } + } + else + { + if (PREDICT_FALSE (proto0 == ~0 || proto0 == SNAT_PROTOCOL_ICMP)) + { + next0 = SNAT_IN2OUT_NEXT_SLOW_PATH; + goto trace00; + } + } + + key0.addr = ip0->src_address; + key0.port = udp0->src_port; + key0.protocol = proto0; + key0.fib_index = rx_fib_index0; + + kv0.key = key0.as_u64; + + if (PREDICT_FALSE (clib_bihash_search_8_8 (&sm->in2out, &kv0, &value0) != 0)) + { + if (is_slow_path) + { + ip4_address_t * first_int_addr; + + if (PREDICT_FALSE(rt->cached_sw_if_index != sw_if_index0)) + { + first_int_addr = + ip4_interface_first_address (sm->ip4_main, sw_if_index0, + 0 /* just want the address */); + rt->cached_sw_if_index = sw_if_index0; + rt->cached_ip4_address = first_int_addr->as_u32; + } + + /* Don't NAT packet aimed at the intfc address */ + if (PREDICT_FALSE(ip0->dst_address.as_u32 == + rt->cached_ip4_address)) + goto trace00; + + next0 = slow_path (sm, b0, ip0, rx_fib_index0, &key0, + &s0, node, next0); + if (PREDICT_FALSE (next0 == SNAT_IN2OUT_NEXT_DROP)) + goto trace00; + } + else + { + next0 = SNAT_IN2OUT_NEXT_SLOW_PATH; + goto trace00; + } + } + else + s0 = pool_elt_at_index (sm->sessions, value0.value); + + old_addr0 = ip0->src_address.as_u32; + ip0->src_address = s0->out2in.addr; + new_addr0 = ip0->src_address.as_u32; + vnet_buffer(b0)->sw_if_index[VLIB_TX] = s0->out2in.fib_index; + + sum0 = ip0->checksum; + sum0 = ip_csum_update (sum0, old_addr0, new_addr0, + ip4_header_t, + src_address /* changed member */); + ip0->checksum = ip_csum_fold (sum0); + + if (PREDICT_TRUE(proto0 == SNAT_PROTOCOL_TCP)) + { + old_port0 = tcp0->ports.src; + tcp0->ports.src = s0->out2in.port; + new_port0 = tcp0->ports.src; + + sum0 = tcp0->checksum; + sum0 = ip_csum_update (sum0, old_addr0, new_addr0, + ip4_header_t, + dst_address /* changed member */); + sum0 = ip_csum_update (sum0, old_port0, new_port0, + ip4_header_t /* cheat */, + length /* changed member */); + tcp0->checksum = ip_csum_fold(sum0); + } + else + { + old_port0 = udp0->src_port; + udp0->src_port = s0->out2in.port; + udp0->checksum = 0; + } + + /* Accounting, per-user LRU list maintenance */ + s0->last_heard = now; + s0->total_pkts++; + s0->total_bytes += vlib_buffer_length_in_chain (vm, b0); + clib_dlist_remove (sm->list_pool, s0->per_user_index); + clib_dlist_addtail (sm->list_pool, s0->per_user_list_head_index, + s0->per_user_index); + trace00: + + if (PREDICT_FALSE((node->flags & VLIB_NODE_FLAG_TRACE) + && (b0->flags & VLIB_BUFFER_IS_TRACED))) + { + snat_in2out_trace_t *t = + vlib_add_trace (vm, node, b0, sizeof (*t)); + t->is_slow_path = is_slow_path; + t->sw_if_index = sw_if_index0; + t->next_index = next0; + t->session_index = ~0; + if (s0) + t->session_index = s0 - sm->sessions; + } + + pkts_processed += next0 != SNAT_IN2OUT_NEXT_DROP; + + ip1 = vlib_buffer_get_current (b1); + udp1 = ip4_next_header (ip1); + tcp1 = (tcp_header_t *) udp1; + icmp1 = (icmp46_header_t *) udp1; + + sw_if_index1 = vnet_buffer(b1)->sw_if_index[VLIB_RX]; + rx_fib_index1 = vec_elt (sm->ip4_main->fib_index_by_sw_if_index, + sw_if_index1); + +#if 0 + vnet_get_config_data (&cm->config_main, + &b1->current_config_index, + &next1, + 0 /* sizeof config data */); +#endif + + proto1 = ~0; + proto1 = (ip1->protocol == IP_PROTOCOL_UDP) + ? SNAT_PROTOCOL_UDP : proto1; + proto1 = (ip1->protocol == IP_PROTOCOL_TCP) + ? SNAT_PROTOCOL_TCP : proto1; + proto1 = (ip1->protocol == IP_PROTOCOL_ICMP) + ? SNAT_PROTOCOL_ICMP : proto1; + + /* Next configured feature, probably ip4-lookup */ + if (is_slow_path) + { + if (PREDICT_FALSE (proto1 == ~0)) + goto trace01; + + if (PREDICT_FALSE (proto1 == SNAT_PROTOCOL_ICMP)) + { + next1 = icmp_in2out_slow_path + (sm, b1, ip1, icmp1, sw_if_index1, rx_fib_index1, node, next1, + now); + goto trace01; + } + } + else + { + if (PREDICT_FALSE (proto1 == ~0 || proto1 == SNAT_PROTOCOL_ICMP)) + { + next1 = SNAT_IN2OUT_NEXT_SLOW_PATH; + goto trace01; + } + } + + key1.addr = ip1->src_address; + key1.port = udp1->src_port; + key1.protocol = proto1; + key1.fib_index = rx_fib_index1; + + kv1.key = key1.as_u64; + + if (PREDICT_FALSE(clib_bihash_search_8_8 (&sm->in2out, &kv1, &value1) != 0)) + { + if (is_slow_path) + { + ip4_address_t * first_int_addr; + + if (PREDICT_FALSE(rt->cached_sw_if_index != sw_if_index1)) + { + first_int_addr = + ip4_interface_first_address (sm->ip4_main, sw_if_index1, + 0 /* just want the address */); + rt->cached_sw_if_index = sw_if_index1; + rt->cached_ip4_address = first_int_addr->as_u32; + } + + /* Don't NAT packet aimed at the intfc address */ + if (PREDICT_FALSE(ip1->dst_address.as_u32 == + rt->cached_ip4_address)) + goto trace01; + + next1 = slow_path (sm, b1, ip1, rx_fib_index1, &key1, + &s1, node, next1); + if (PREDICT_FALSE (next1 == SNAT_IN2OUT_NEXT_DROP)) + goto trace01; + } + else + { + next1 = SNAT_IN2OUT_NEXT_SLOW_PATH; + goto trace01; + } + } + else + s1 = pool_elt_at_index (sm->sessions, value1.value); + + old_addr1 = ip1->src_address.as_u32; + ip1->src_address = s1->out2in.addr; + new_addr1 = ip1->src_address.as_u32; + vnet_buffer(b1)->sw_if_index[VLIB_TX] = s1->out2in.fib_index; + + sum1 = ip1->checksum; + sum1 = ip_csum_update (sum1, old_addr1, new_addr1, + ip4_header_t, + src_address /* changed member */); + ip1->checksum = ip_csum_fold (sum1); + + if (PREDICT_TRUE(proto1 == SNAT_PROTOCOL_TCP)) + { + old_port1 = tcp1->ports.src; + tcp1->ports.src = s1->out2in.port; + new_port1 = tcp1->ports.src; + + sum1 = tcp1->checksum; + sum1 = ip_csum_update (sum1, old_addr1, new_addr1, + ip4_header_t, + dst_address /* changed member */); + sum1 = ip_csum_update (sum1, old_port1, new_port1, + ip4_header_t /* cheat */, + length /* changed member */); + tcp1->checksum = ip_csum_fold(sum1); + } + else + { + old_port1 = udp1->src_port; + udp1->src_port = s1->out2in.port; + udp1->checksum = 0; + } + + /* Accounting, per-user LRU list maintenance */ + s1->last_heard = now; + s1->total_pkts++; + s1->total_bytes += vlib_buffer_length_in_chain (vm, b1); + clib_dlist_remove (sm->list_pool, s1->per_user_index); + clib_dlist_addtail (sm->list_pool, s1->per_user_list_head_index, + s1->per_user_index); + trace01: + + if (PREDICT_FALSE((node->flags & VLIB_NODE_FLAG_TRACE) + && (b1->flags & VLIB_BUFFER_IS_TRACED))) + { + snat_in2out_trace_t *t = + vlib_add_trace (vm, node, b1, sizeof (*t)); + t->sw_if_index = sw_if_index1; + t->next_index = next1; + t->session_index = ~0; + if (s1) + t->session_index = s1 - sm->sessions; + } + + pkts_processed += next1 != SNAT_IN2OUT_NEXT_DROP; + + /* verify speculative enqueues, maybe switch current next frame */ + vlib_validate_buffer_enqueue_x2 (vm, node, next_index, + to_next, n_left_to_next, + bi0, bi1, next0, next1); + } + + while (n_left_from > 0 && n_left_to_next > 0) + { + u32 bi0; + vlib_buffer_t * b0; + u32 next0; + u32 sw_if_index0; + ip4_header_t * ip0; + ip_csum_t sum0; + u32 new_addr0, old_addr0; + u16 old_port0, new_port0; + udp_header_t * udp0; + tcp_header_t * tcp0; + icmp46_header_t * icmp0; + snat_session_key_t key0; + u32 rx_fib_index0; + u32 proto0; + snat_session_t * s0 = 0; + clib_bihash_kv_8_8_t kv0, value0; + + /* speculatively enqueue b0 to the current next frame */ + bi0 = from[0]; + to_next[0] = bi0; + from += 1; + to_next += 1; + n_left_from -= 1; + n_left_to_next -= 1; + + b0 = vlib_get_buffer (vm, bi0); + next0 = SNAT_IN2OUT_NEXT_LOOKUP; + + ip0 = vlib_buffer_get_current (b0); + udp0 = ip4_next_header (ip0); + tcp0 = (tcp_header_t *) udp0; + icmp0 = (icmp46_header_t *) udp0; + + sw_if_index0 = vnet_buffer(b0)->sw_if_index[VLIB_RX]; + rx_fib_index0 = vec_elt (sm->ip4_main->fib_index_by_sw_if_index, + sw_if_index0); + + +#if 0 + vnet_get_config_data (&cm->config_main, + &b0->current_config_index, + &next0, + 0 /* sizeof config data */); +#endif + + proto0 = ~0; + proto0 = (ip0->protocol == IP_PROTOCOL_UDP) + ? SNAT_PROTOCOL_UDP : proto0; + proto0 = (ip0->protocol == IP_PROTOCOL_TCP) + ? SNAT_PROTOCOL_TCP : proto0; + proto0 = (ip0->protocol == IP_PROTOCOL_ICMP) + ? SNAT_PROTOCOL_ICMP : proto0; + + /* Next configured feature, probably ip4-lookup */ + if (is_slow_path) + { + if (PREDICT_FALSE (proto0 == ~0)) + goto trace0; + + if (PREDICT_FALSE (proto0 == SNAT_PROTOCOL_ICMP)) + { + next0 = icmp_in2out_slow_path + (sm, b0, ip0, icmp0, sw_if_index0, rx_fib_index0, node, next0, + now); + goto trace0; + } + } + else + { + if (PREDICT_FALSE (proto0 == ~0 || proto0 == SNAT_PROTOCOL_ICMP)) + { + next0 = SNAT_IN2OUT_NEXT_SLOW_PATH; + goto trace0; + } + } + + key0.addr = ip0->src_address; + key0.port = udp0->src_port; + key0.protocol = proto0; + key0.fib_index = rx_fib_index0; + + kv0.key = key0.as_u64; + + if (clib_bihash_search_8_8 (&sm->in2out, &kv0, &value0)) + { + if (is_slow_path) + { + ip4_address_t * first_int_addr; + + if (PREDICT_FALSE(rt->cached_sw_if_index != sw_if_index0)) + { + first_int_addr = + ip4_interface_first_address (sm->ip4_main, sw_if_index0, + 0 /* just want the address */); + rt->cached_sw_if_index = sw_if_index0; + rt->cached_ip4_address = first_int_addr->as_u32; + } + + /* Don't NAT packet aimed at the intfc address */ + if (PREDICT_FALSE(ip0->dst_address.as_u32 == + rt->cached_ip4_address)) + goto trace0; + + next0 = slow_path (sm, b0, ip0, rx_fib_index0, &key0, + &s0, node, next0); + if (PREDICT_FALSE (next0 == SNAT_IN2OUT_NEXT_DROP)) + goto trace0; + } + else + { + next0 = SNAT_IN2OUT_NEXT_SLOW_PATH; + goto trace0; + } + } + else + s0 = pool_elt_at_index (sm->sessions, value0.value); + + old_addr0 = ip0->src_address.as_u32; + ip0->src_address = s0->out2in.addr; + new_addr0 = ip0->src_address.as_u32; + vnet_buffer(b0)->sw_if_index[VLIB_TX] = s0->out2in.fib_index; + + sum0 = ip0->checksum; + sum0 = ip_csum_update (sum0, old_addr0, new_addr0, + ip4_header_t, + src_address /* changed member */); + ip0->checksum = ip_csum_fold (sum0); + + if (PREDICT_TRUE(proto0 == SNAT_PROTOCOL_TCP)) + { + old_port0 = tcp0->ports.src; + tcp0->ports.src = s0->out2in.port; + new_port0 = tcp0->ports.src; + + sum0 = tcp0->checksum; + sum0 = ip_csum_update (sum0, old_addr0, new_addr0, + ip4_header_t, + dst_address /* changed member */); + sum0 = ip_csum_update (sum0, old_port0, new_port0, + ip4_header_t /* cheat */, + length /* changed member */); + tcp0->checksum = ip_csum_fold(sum0); + } + else + { + old_port0 = udp0->src_port; + udp0->src_port = s0->out2in.port; + udp0->checksum = 0; + } + + /* Accounting, per-user LRU list maintenance */ + s0->last_heard = now; + s0->total_pkts++; + s0->total_bytes += vlib_buffer_length_in_chain (vm, b0); + clib_dlist_remove (sm->list_pool, s0->per_user_index); + clib_dlist_addtail (sm->list_pool, s0->per_user_list_head_index, + s0->per_user_index); + + trace0: + if (PREDICT_FALSE((node->flags & VLIB_NODE_FLAG_TRACE) + && (b0->flags & VLIB_BUFFER_IS_TRACED))) + { + snat_in2out_trace_t *t = + vlib_add_trace (vm, node, b0, sizeof (*t)); + t->is_slow_path = is_slow_path; + t->sw_if_index = sw_if_index0; + t->next_index = next0; + t->session_index = ~0; + if (s0) + t->session_index = s0 - sm->sessions; + } + + pkts_processed += next0 != SNAT_IN2OUT_NEXT_DROP; + + /* verify speculative enqueue, maybe switch current next frame */ + vlib_validate_buffer_enqueue_x1 (vm, node, next_index, + to_next, n_left_to_next, + bi0, next0); + } + + vlib_put_next_frame (vm, node, next_index, n_left_to_next); + } + + vlib_node_increment_counter (vm, stats_node_index, + SNAT_IN2OUT_ERROR_IN2OUT_PACKETS, + pkts_processed); + return frame->n_vectors; +} + +static uword +snat_in2out_fast_path_fn (vlib_main_t * vm, + vlib_node_runtime_t * node, + vlib_frame_t * frame) +{ + return snat_in2out_node_fn_inline (vm, node, frame, 0 /* is_slow_path */); +} + +VLIB_REGISTER_NODE (snat_in2out_node) = { + .function = snat_in2out_fast_path_fn, + .name = "snat-in2out", + .vector_size = sizeof (u32), + .format_trace = format_snat_in2out_trace, + .type = VLIB_NODE_TYPE_INTERNAL, + + .n_errors = ARRAY_LEN(snat_in2out_error_strings), + .error_strings = snat_in2out_error_strings, + + .runtime_data_bytes = sizeof (snat_runtime_t), + + .n_next_nodes = SNAT_IN2OUT_N_NEXT, + + /* edit / add dispositions here */ + .next_nodes = { + [SNAT_IN2OUT_NEXT_DROP] = "error-drop", + [SNAT_IN2OUT_NEXT_LOOKUP] = "ip4-lookup", + [SNAT_IN2OUT_NEXT_SLOW_PATH] = "snat-in2out-slowpath", + }, +}; + +VLIB_NODE_FUNCTION_MULTIARCH (snat_in2out_node, snat_in2out_fast_path_fn); + +static uword +snat_in2out_slow_path_fn (vlib_main_t * vm, + vlib_node_runtime_t * node, + vlib_frame_t * frame) +{ + return snat_in2out_node_fn_inline (vm, node, frame, 1 /* is_slow_path */); +} + +VLIB_REGISTER_NODE (snat_in2out_slowpath_node) = { + .function = snat_in2out_slow_path_fn, + .name = "snat-in2out-slowpath", + .vector_size = sizeof (u32), + .format_trace = format_snat_in2out_trace, + .type = VLIB_NODE_TYPE_INTERNAL, + + .n_errors = ARRAY_LEN(snat_in2out_error_strings), + .error_strings = snat_in2out_error_strings, + + .runtime_data_bytes = sizeof (snat_runtime_t), + + .n_next_nodes = SNAT_IN2OUT_N_NEXT, + + /* edit / add dispositions here */ + .next_nodes = { + [SNAT_IN2OUT_NEXT_DROP] = "error-drop", + [SNAT_IN2OUT_NEXT_LOOKUP] = "ip4-lookup", + [SNAT_IN2OUT_NEXT_SLOW_PATH] = "snat-in2out-slowpath", + }, +}; + +VLIB_NODE_FUNCTION_MULTIARCH (snat_in2out_slowpath_node, snat_in2out_slow_path_fn); diff --git a/plugins/snat-plugin/snat/out2in.c b/plugins/snat-plugin/snat/out2in.c new file mode 100644 index 00000000..0fa96c97 --- /dev/null +++ b/plugins/snat-plugin/snat/out2in.c @@ -0,0 +1,601 @@ +/* + * Copyright (c) 2016 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include + +#include +#include +#include + +#include +#include +#include + +vlib_node_registration_t snat_out2in_node; + +typedef struct { + u32 sw_if_index; + u32 next_index; + u32 session_index; +} snat_out2in_trace_t; + +/* packet trace format function */ +static u8 * format_snat_out2in_trace (u8 * s, va_list * args) +{ + CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *); + CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *); + snat_out2in_trace_t * t = va_arg (*args, snat_out2in_trace_t *); + + s = format (s, "SNAT_OUT2IN: sw_if_index %d, next index %d, session index %d", + t->sw_if_index, t->next_index, t->session_index); + return s; +} + +vlib_node_registration_t snat_out2in_node; + +#define foreach_snat_out2in_error \ +_(UNSUPPORTED_PROTOCOL, "Unsupported protocol") \ +_(OUT2IN_PACKETS, "Good out2in packets processed") \ +_(BAD_ICMP_TYPE, "icmp type not echo-reply") \ +_(NO_TRANSLATION, "No translation") + +typedef enum { +#define _(sym,str) SNAT_OUT2IN_ERROR_##sym, + foreach_snat_out2in_error +#undef _ + SNAT_OUT2IN_N_ERROR, +} snat_out2in_error_t; + +static char * snat_out2in_error_strings[] = { +#define _(sym,string) string, + foreach_snat_out2in_error +#undef _ +}; + +typedef enum { + SNAT_OUT2IN_NEXT_DROP, + SNAT_OUT2IN_N_NEXT, +} snat_out2in_next_t; + +static inline u32 icmp_out2in_slow_path (snat_main_t *sm, + vlib_buffer_t * b0, + ip4_header_t * ip0, + icmp46_header_t * icmp0, + u32 sw_if_index0, + u32 rx_fib_index0, + vlib_node_runtime_t * node, + u32 next0, f64 now) +{ + snat_session_key_t key0; + icmp_echo_header_t *echo0; + clib_bihash_kv_8_8_t kv0, value0; + snat_session_t * s0; + u32 new_addr0, old_addr0; + u16 old_id0, new_id0; + ip_csum_t sum0; + snat_runtime_t * rt = (snat_runtime_t *)node->runtime_data; + + echo0 = (icmp_echo_header_t *)(icmp0+1); + + key0.addr = ip0->dst_address; + key0.port = echo0->identifier; + key0.protocol = SNAT_PROTOCOL_ICMP; + key0.fib_index = rx_fib_index0; + + kv0.key = key0.as_u64; + + if (clib_bihash_search_8_8 (&sm->out2in, &kv0, &value0)) + { + ip4_address_t * first_int_addr; + + if (PREDICT_FALSE(rt->cached_sw_if_index != sw_if_index0)) + { + first_int_addr = + ip4_interface_first_address (sm->ip4_main, sw_if_index0, + 0 /* just want the address */); + rt->cached_sw_if_index = sw_if_index0; + rt->cached_ip4_address = first_int_addr->as_u32; + } + + /* Don't NAT packet aimed at the intfc address */ + if (PREDICT_FALSE(ip0->dst_address.as_u32 == + rt->cached_ip4_address)) + return next0; + + b0->error = node->errors[SNAT_OUT2IN_ERROR_NO_TRANSLATION]; + return SNAT_OUT2IN_NEXT_DROP; + } + else + s0 = pool_elt_at_index (sm->sessions, value0.value); + + old_addr0 = ip0->dst_address.as_u32; + ip0->dst_address = s0->in2out.addr; + new_addr0 = ip0->dst_address.as_u32; + vnet_buffer(b0)->sw_if_index[VLIB_TX] = s0->in2out.fib_index; + + sum0 = ip0->checksum; + sum0 = ip_csum_update (sum0, old_addr0, new_addr0, + ip4_header_t, + dst_address /* changed member */); + ip0->checksum = ip_csum_fold (sum0); + + old_id0 = echo0->identifier; + new_id0 = s0->in2out.port; + echo0->identifier = new_id0; + + sum0 = icmp0->checksum; + sum0 = ip_csum_update (sum0, old_id0, new_id0, icmp_echo_header_t, + identifier); + icmp0->checksum = ip_csum_fold (sum0); + + /* Accounting, per-user LRU list maintenance */ + s0->last_heard = now; + s0->total_pkts++; + s0->total_bytes += vlib_buffer_length_in_chain (sm->vlib_main, b0); + clib_dlist_remove (sm->list_pool, s0->per_user_index); + clib_dlist_addtail (sm->list_pool, s0->per_user_list_head_index, + s0->per_user_index); + + return next0; +} + +static uword +snat_out2in_node_fn (vlib_main_t * vm, + vlib_node_runtime_t * node, + vlib_frame_t * frame) +{ + u32 n_left_from, * from, * to_next; + snat_out2in_next_t next_index; + u32 pkts_processed = 0; + snat_main_t * sm = &snat_main; + ip_lookup_main_t * lm = sm->ip4_lookup_main; + ip_config_main_t * cm = &lm->rx_config_mains[VNET_UNICAST]; + f64 now = vlib_time_now (vm); + + from = vlib_frame_vector_args (frame); + n_left_from = frame->n_vectors; + next_index = node->cached_next_index; + + while (n_left_from > 0) + { + u32 n_left_to_next; + + vlib_get_next_frame (vm, node, next_index, + to_next, n_left_to_next); + + while (n_left_from >= 4 && n_left_to_next >= 2) + { + u32 bi0, bi1; + vlib_buffer_t * b0, * b1; + u32 next0 = SNAT_OUT2IN_NEXT_DROP; + u32 next1 = SNAT_OUT2IN_NEXT_DROP; + u32 sw_if_index0, sw_if_index1; + ip4_header_t * ip0, *ip1; + ip_csum_t sum0, sum1; + u32 new_addr0, old_addr0; + u16 new_port0, old_port0; + u32 new_addr1, old_addr1; + u16 new_port1, old_port1; + udp_header_t * udp0, * udp1; + tcp_header_t * tcp0, * tcp1; + icmp46_header_t * icmp0, * icmp1; + snat_session_key_t key0, key1; + u32 rx_fib_index0, rx_fib_index1; + u32 proto0, proto1; + snat_session_t * s0 = 0, * s1 = 0; + clib_bihash_kv_8_8_t kv0, kv1, value0, value1; + + /* Prefetch next iteration. */ + { + vlib_buffer_t * p2, * p3; + + p2 = vlib_get_buffer (vm, from[2]); + p3 = vlib_get_buffer (vm, from[3]); + + vlib_prefetch_buffer_header (p2, LOAD); + vlib_prefetch_buffer_header (p3, LOAD); + + CLIB_PREFETCH (p2->data, CLIB_CACHE_LINE_BYTES, STORE); + CLIB_PREFETCH (p3->data, CLIB_CACHE_LINE_BYTES, STORE); + } + + /* speculatively enqueue b0 and b1 to the current next frame */ + to_next[0] = bi0 = from[0]; + to_next[1] = bi1 = from[1]; + from += 2; + to_next += 2; + n_left_from -= 2; + n_left_to_next -= 2; + + b0 = vlib_get_buffer (vm, bi0); + b1 = vlib_get_buffer (vm, bi1); + + ip0 = vlib_buffer_get_current (b0); + udp0 = ip4_next_header (ip0); + tcp0 = (tcp_header_t *) udp0; + icmp0 = (icmp46_header_t *) udp0; + + sw_if_index0 = vnet_buffer(b0)->sw_if_index[VLIB_RX]; + rx_fib_index0 = vec_elt (sm->ip4_main->fib_index_by_sw_if_index, + sw_if_index0); + + vnet_get_config_data (&cm->config_main, + &b0->current_config_index, + &next0, + 0 /* sizeof config data */); + proto0 = ~0; + proto0 = (ip0->protocol == IP_PROTOCOL_UDP) + ? SNAT_PROTOCOL_UDP : proto0; + proto0 = (ip0->protocol == IP_PROTOCOL_TCP) + ? SNAT_PROTOCOL_TCP : proto0; + proto0 = (ip0->protocol == IP_PROTOCOL_ICMP) + ? SNAT_PROTOCOL_ICMP : proto0; + + if (PREDICT_FALSE (proto0 == ~0)) + goto trace0; + + if (PREDICT_FALSE (proto0 == SNAT_PROTOCOL_ICMP)) + { + next0 = icmp_out2in_slow_path + (sm, b0, ip0, icmp0, sw_if_index0, rx_fib_index0, node, + next0, now); + goto trace0; + } + + key0.addr = ip0->dst_address; + key0.port = udp0->dst_port; + key0.protocol = proto0; + key0.fib_index = rx_fib_index0; + + kv0.key = key0.as_u64; + + if (clib_bihash_search_8_8 (&sm->out2in, &kv0, &value0)) + goto trace0; + else + s0 = pool_elt_at_index (sm->sessions, value0.value); + + old_addr0 = ip0->dst_address.as_u32; + ip0->dst_address = s0->in2out.addr; + new_addr0 = ip0->dst_address.as_u32; + vnet_buffer(b0)->sw_if_index[VLIB_TX] = s0->out2in.fib_index; + + sum0 = ip0->checksum; + sum0 = ip_csum_update (sum0, old_addr0, new_addr0, + ip4_header_t, + dst_address /* changed member */); + ip0->checksum = ip_csum_fold (sum0); + + if (PREDICT_TRUE(proto0 == SNAT_PROTOCOL_TCP)) + { + old_port0 = tcp0->ports.dst; + tcp0->ports.dst = s0->in2out.port; + new_port0 = tcp0->ports.dst; + + sum0 = tcp0->checksum; + sum0 = ip_csum_update (sum0, old_addr0, new_addr0, + ip4_header_t, + dst_address /* changed member */); + + sum0 = ip_csum_update (sum0, old_port0, new_port0, + ip4_header_t /* cheat */, + length /* changed member */); + tcp0->checksum = ip_csum_fold(sum0); + } + else + { + old_port0 = udp0->dst_port; + udp0->dst_port = s0->in2out.port; + udp0->checksum = 0; + } + + /* Accounting, per-user LRU list maintenance */ + s0->last_heard = now; + s0->total_pkts++; + s0->total_bytes += vlib_buffer_length_in_chain (vm, b0); + clib_dlist_remove (sm->list_pool, s0->per_user_index); + clib_dlist_addtail (sm->list_pool, s0->per_user_list_head_index, + s0->per_user_index); + trace0: + + if (PREDICT_FALSE((node->flags & VLIB_NODE_FLAG_TRACE) + && (b0->flags & VLIB_BUFFER_IS_TRACED))) + { + snat_out2in_trace_t *t = + vlib_add_trace (vm, node, b0, sizeof (*t)); + t->sw_if_index = sw_if_index0; + t->next_index = next0; + t->session_index = ~0; + if (s0) + t->session_index = s0 - sm->sessions; + } + + pkts_processed += next0 != SNAT_OUT2IN_NEXT_DROP; + + + ip1 = vlib_buffer_get_current (b1); + udp1 = ip4_next_header (ip1); + tcp1 = (tcp_header_t *) udp1; + icmp1 = (icmp46_header_t *) udp1; + + sw_if_index1 = vnet_buffer(b1)->sw_if_index[VLIB_RX]; + rx_fib_index1 = vec_elt (sm->ip4_main->fib_index_by_sw_if_index, + sw_if_index1); + + vnet_get_config_data (&cm->config_main, + &b1->current_config_index, + &next1, + 0 /* sizeof config data */); + proto1 = ~0; + proto1 = (ip1->protocol == IP_PROTOCOL_UDP) + ? SNAT_PROTOCOL_UDP : proto1; + proto1 = (ip1->protocol == IP_PROTOCOL_TCP) + ? SNAT_PROTOCOL_TCP : proto1; + proto1 = (ip1->protocol == IP_PROTOCOL_ICMP) + ? SNAT_PROTOCOL_ICMP : proto1; + + if (PREDICT_FALSE (proto1 == ~0)) + goto trace1; + + if (PREDICT_FALSE (proto1 == SNAT_PROTOCOL_ICMP)) + { + next1 = icmp_out2in_slow_path + (sm, b1, ip1, icmp1, sw_if_index1, rx_fib_index1, node, + next1, now); + goto trace1; + } + + key1.addr = ip1->dst_address; + key1.port = udp1->dst_port; + key1.protocol = proto1; + key1.fib_index = rx_fib_index1; + + kv1.key = key1.as_u64; + + if (clib_bihash_search_8_8 (&sm->out2in, &kv1, &value1)) + goto trace1; + else + s1 = pool_elt_at_index (sm->sessions, value1.value); + + old_addr1 = ip1->dst_address.as_u32; + ip1->dst_address = s1->in2out.addr; + new_addr1 = ip1->dst_address.as_u32; + vnet_buffer(b1)->sw_if_index[VLIB_TX] = s1->out2in.fib_index; + + sum1 = ip1->checksum; + sum1 = ip_csum_update (sum1, old_addr1, new_addr1, + ip4_header_t, + dst_address /* changed member */); + ip1->checksum = ip_csum_fold (sum1); + + if (PREDICT_TRUE(proto1 == SNAT_PROTOCOL_TCP)) + { + old_port1 = tcp1->ports.dst; + tcp1->ports.dst = s1->in2out.port; + new_port1 = tcp1->ports.dst; + + sum1 = tcp1->checksum; + sum1 = ip_csum_update (sum1, old_addr1, new_addr1, + ip4_header_t, + dst_address /* changed member */); + + sum1 = ip_csum_update (sum1, old_port1, new_port1, + ip4_header_t /* cheat */, + length /* changed member */); + tcp1->checksum = ip_csum_fold(sum1); + } + else + { + old_port1 = udp1->dst_port; + udp1->dst_port = s1->in2out.port; + udp1->checksum = 0; + } + + /* Accounting, per-user LRU list maintenance */ + s1->last_heard = now; + s1->total_pkts++; + s1->total_bytes += vlib_buffer_length_in_chain (vm, b1); + clib_dlist_remove (sm->list_pool, s1->per_user_index); + clib_dlist_addtail (sm->list_pool, s1->per_user_list_head_index, + s1->per_user_index); + trace1: + + if (PREDICT_FALSE((node->flags & VLIB_NODE_FLAG_TRACE) + && (b1->flags & VLIB_BUFFER_IS_TRACED))) + { + snat_out2in_trace_t *t = + vlib_add_trace (vm, node, b1, sizeof (*t)); + t->sw_if_index = sw_if_index1; + t->next_index = next1; + t->session_index = ~0; + if (s1) + t->session_index = s1 - sm->sessions; + } + + pkts_processed += next0 != SNAT_OUT2IN_NEXT_DROP; + pkts_processed += next1 != SNAT_OUT2IN_NEXT_DROP; + + /* verify speculative enqueues, maybe switch current next frame */ + vlib_validate_buffer_enqueue_x2 (vm, node, next_index, + to_next, n_left_to_next, + bi0, bi1, next0, next1); + } + + while (n_left_from > 0 && n_left_to_next > 0) + { + u32 bi0; + vlib_buffer_t * b0; + u32 next0 = SNAT_OUT2IN_NEXT_DROP; + u32 sw_if_index0; + ip4_header_t * ip0; + ip_csum_t sum0; + u32 new_addr0, old_addr0; + u16 new_port0, old_port0; + udp_header_t * udp0; + tcp_header_t * tcp0; + icmp46_header_t * icmp0; + snat_session_key_t key0; + u32 rx_fib_index0; + u32 proto0; + snat_session_t * s0 = 0; + clib_bihash_kv_8_8_t kv0, value0; + + /* speculatively enqueue b0 to the current next frame */ + bi0 = from[0]; + to_next[0] = bi0; + from += 1; + to_next += 1; + n_left_from -= 1; + n_left_to_next -= 1; + + b0 = vlib_get_buffer (vm, bi0); + + ip0 = vlib_buffer_get_current (b0); + udp0 = ip4_next_header (ip0); + tcp0 = (tcp_header_t *) udp0; + icmp0 = (icmp46_header_t *) udp0; + + sw_if_index0 = vnet_buffer(b0)->sw_if_index[VLIB_RX]; + rx_fib_index0 = vec_elt (sm->ip4_main->fib_index_by_sw_if_index, + sw_if_index0); + + vnet_get_config_data (&cm->config_main, + &b0->current_config_index, + &next0, + 0 /* sizeof config data */); + proto0 = ~0; + proto0 = (ip0->protocol == IP_PROTOCOL_UDP) + ? SNAT_PROTOCOL_UDP : proto0; + proto0 = (ip0->protocol == IP_PROTOCOL_TCP) + ? SNAT_PROTOCOL_TCP : proto0; + proto0 = (ip0->protocol == IP_PROTOCOL_ICMP) + ? SNAT_PROTOCOL_ICMP : proto0; + + if (PREDICT_FALSE (proto0 == ~0)) + goto trace00; + + if (PREDICT_FALSE (proto0 == SNAT_PROTOCOL_ICMP)) + { + next0 = icmp_out2in_slow_path + (sm, b0, ip0, icmp0, sw_if_index0, rx_fib_index0, node, + next0, now); + goto trace00; + } + + key0.addr = ip0->dst_address; + key0.port = udp0->dst_port; + key0.protocol = proto0; + key0.fib_index = rx_fib_index0; + + kv0.key = key0.as_u64; + + if (clib_bihash_search_8_8 (&sm->out2in, &kv0, &value0)) + goto trace00; + else + s0 = pool_elt_at_index (sm->sessions, value0.value); + + old_addr0 = ip0->dst_address.as_u32; + ip0->dst_address = s0->in2out.addr; + new_addr0 = ip0->dst_address.as_u32; + vnet_buffer(b0)->sw_if_index[VLIB_TX] = s0->out2in.fib_index; + + sum0 = ip0->checksum; + sum0 = ip_csum_update (sum0, old_addr0, new_addr0, + ip4_header_t, + dst_address /* changed member */); + ip0->checksum = ip_csum_fold (sum0); + + if (PREDICT_TRUE(proto0 == SNAT_PROTOCOL_TCP)) + { + old_port0 = tcp0->ports.dst; + tcp0->ports.dst = s0->in2out.port; + new_port0 = tcp0->ports.dst; + + sum0 = tcp0->checksum; + sum0 = ip_csum_update (sum0, old_addr0, new_addr0, + ip4_header_t, + dst_address /* changed member */); + + sum0 = ip_csum_update (sum0, old_port0, new_port0, + ip4_header_t /* cheat */, + length /* changed member */); + tcp0->checksum = ip_csum_fold(sum0); + } + else + { + old_port0 = udp0->dst_port; + udp0->dst_port = s0->in2out.port; + udp0->checksum = 0; + } + + /* Accounting, per-user LRU list maintenance */ + s0->last_heard = now; + s0->total_pkts++; + s0->total_bytes += vlib_buffer_length_in_chain (vm, b0); + clib_dlist_remove (sm->list_pool, s0->per_user_index); + clib_dlist_addtail (sm->list_pool, s0->per_user_list_head_index, + s0->per_user_index); + trace00: + + if (PREDICT_FALSE((node->flags & VLIB_NODE_FLAG_TRACE) + && (b0->flags & VLIB_BUFFER_IS_TRACED))) + { + snat_out2in_trace_t *t = + vlib_add_trace (vm, node, b0, sizeof (*t)); + t->sw_if_index = sw_if_index0; + t->next_index = next0; + t->session_index = ~0; + if (s0) + t->session_index = s0 - sm->sessions; + } + + pkts_processed += next0 != SNAT_OUT2IN_NEXT_DROP; + + /* verify speculative enqueue, maybe switch current next frame */ + vlib_validate_buffer_enqueue_x1 (vm, node, next_index, + to_next, n_left_to_next, + bi0, next0); + } + + vlib_put_next_frame (vm, node, next_index, n_left_to_next); + } + + vlib_node_increment_counter (vm, snat_out2in_node.index, + SNAT_OUT2IN_ERROR_OUT2IN_PACKETS, + pkts_processed); + return frame->n_vectors; +} + +VLIB_REGISTER_NODE (snat_out2in_node) = { + .function = snat_out2in_node_fn, + .name = "snat-out2in", + .vector_size = sizeof (u32), + .format_trace = format_snat_out2in_trace, + .type = VLIB_NODE_TYPE_INTERNAL, + + .n_errors = ARRAY_LEN(snat_out2in_error_strings), + .error_strings = snat_out2in_error_strings, + + .runtime_data_bytes = sizeof (snat_runtime_t), + + .n_next_nodes = SNAT_OUT2IN_N_NEXT, + + /* edit / add dispositions here */ + .next_nodes = { + [SNAT_OUT2IN_NEXT_DROP] = "error-drop", + }, +}; +VLIB_NODE_FUNCTION_MULTIARCH (snat_out2in_node, snat_out2in_node_fn); diff --git a/plugins/snat-plugin/snat/snat.api b/plugins/snat-plugin/snat/snat.api new file mode 100644 index 00000000..0c5f4373 --- /dev/null +++ b/plugins/snat-plugin/snat/snat.api @@ -0,0 +1,25 @@ +define snat_add_address_range { + u32 client_index; + u32 context; + u8 is_ip4; + u8 first_ip_address[16]; + u8 last_ip_address[16]; +}; + +define snat_add_address_range_reply { + u32 context; + i32 retval; +}; + +define snat_interface_add_del_feature { + u32 client_index; + u32 context; + u8 is_add; + u8 is_inside; + u32 sw_if_index; +}; + +define snat_interface_add_del_feature_reply { + u32 context; + i32 retval; +}; diff --git a/plugins/snat-plugin/snat/snat.c b/plugins/snat-plugin/snat/snat.c new file mode 100644 index 00000000..3675602e --- /dev/null +++ b/plugins/snat-plugin/snat/snat.c @@ -0,0 +1,716 @@ +/* + * snat.c - simple nat plugin + * + * Copyright (c) 2016 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include + +#include +#include +#include + +snat_main_t snat_main; + +/* define message IDs */ +#include + +/* define message structures */ +#define vl_typedefs +#include +#undef vl_typedefs + +/* define generated endian-swappers */ +#define vl_endianfun +#include +#undef vl_endianfun + +#define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__) + +/* Get the API version number */ +#define vl_api_version(n,v) static u32 api_version=(v); +#include +#undef vl_api_version + +/* Macro to finish up custom dump fns */ +#define FINISH \ + vec_add1 (s, 0); \ + vl_print (handle, (char *)s); \ + vec_free (s); \ + return handle; + +/* + * A handy macro to set up a message reply. + * Assumes that the following variables are available: + * mp - pointer to request message + * rmp - pointer to reply message type + * rv - return value + */ + +#define REPLY_MACRO(t) \ +do { \ + unix_shared_memory_queue_t * q = \ + vl_api_client_index_to_input_queue (mp->client_index); \ + if (!q) \ + return; \ + \ + rmp = vl_msg_api_alloc (sizeof (*rmp)); \ + rmp->_vl_msg_id = ntohs((t)+sm->msg_id_base); \ + rmp->context = mp->context; \ + rmp->retval = ntohl(rv); \ + \ + vl_msg_api_send_shmem (q, (u8 *)&rmp); \ +} while(0); + + +/* Hook up input features */ +VNET_IP4_UNICAST_FEATURE_INIT (ip4_snat_in2out, static) = { + .node_name = "snat-in2out", + .runs_before = {"snat-out2in", 0}, + .feature_index = &snat_main.rx_feature_in2out, +}; +VNET_IP4_UNICAST_FEATURE_INIT (ip4_snat_out2in, static) = { + .node_name = "snat-out2in", + .runs_before = {"ip4-lookup", 0}, + .feature_index = &snat_main.rx_feature_out2in, +}; + +/* + * This routine exists to convince the vlib plugin framework that + * we haven't accidentally copied a random .dll into the plugin directory. + * + * Also collects global variable pointers passed from the vpp engine + */ + +clib_error_t * +vlib_plugin_register (vlib_main_t * vm, vnet_plugin_handoff_t * h, + int from_early_init) +{ + snat_main_t * sm = &snat_main; + clib_error_t * error = 0; + + sm->vlib_main = vm; + sm->vnet_main = h->vnet_main; + sm->ethernet_main = h->ethernet_main; + + return error; +} + +/*$$$$$ move to an installed header file */ +#if (1 || CLIB_DEBUG > 0) /* "trust, but verify" */ + +#define VALIDATE_SW_IF_INDEX(mp) \ + do { u32 __sw_if_index = ntohl(mp->sw_if_index); \ + vnet_main_t *__vnm = vnet_get_main(); \ + if (pool_is_free_index(__vnm->interface_main.sw_interfaces, \ + __sw_if_index)) { \ + rv = VNET_API_ERROR_INVALID_SW_IF_INDEX; \ + goto bad_sw_if_index; \ + } \ +} while(0); + +#define BAD_SW_IF_INDEX_LABEL \ +do { \ +bad_sw_if_index: \ + ; \ +} while (0); + +#define VALIDATE_RX_SW_IF_INDEX(mp) \ + do { u32 __rx_sw_if_index = ntohl(mp->rx_sw_if_index); \ + vnet_main_t *__vnm = vnet_get_main(); \ + if (pool_is_free_index(__vnm->interface_main.sw_interfaces, \ + __rx_sw_if_index)) { \ + rv = VNET_API_ERROR_INVALID_SW_IF_INDEX; \ + goto bad_rx_sw_if_index; \ + } \ +} while(0); + +#define BAD_RX_SW_IF_INDEX_LABEL \ +do { \ +bad_rx_sw_if_index: \ + ; \ +} while (0); + +#define VALIDATE_TX_SW_IF_INDEX(mp) \ + do { u32 __tx_sw_if_index = ntohl(mp->tx_sw_if_index); \ + vnet_main_t *__vnm = vnet_get_main(); \ + if (pool_is_free_index(__vnm->interface_main.sw_interfaces, \ + __tx_sw_if_index)) { \ + rv = VNET_API_ERROR_INVALID_SW_IF_INDEX; \ + goto bad_tx_sw_if_index; \ + } \ +} while(0); + +#define BAD_TX_SW_IF_INDEX_LABEL \ +do { \ +bad_tx_sw_if_index: \ + ; \ +} while (0); + +#else + +#define VALIDATE_SW_IF_INDEX(mp) +#define BAD_SW_IF_INDEX_LABEL +#define VALIDATE_RX_SW_IF_INDEX(mp) +#define BAD_RX_SW_IF_INDEX_LABEL +#define VALIDATE_TX_SW_IF_INDEX(mp) +#define BAD_TX_SW_IF_INDEX_LABEL + +#endif /* CLIB_DEBUG > 0 */ + +void snat_add_address (snat_main_t *sm, ip4_address_t *addr) +{ + snat_address_t * ap; + + vec_add2 (sm->addresses, ap, 1); + ap->addr = *addr; + +} + +static void increment_v4_address (ip4_address_t * a) +{ + u32 v; + + v = clib_net_to_host_u32(a->as_u32) + 1; + a->as_u32 = clib_host_to_net_u32(v); +} + +static void +vl_api_snat_add_address_range_t_handler +(vl_api_snat_add_address_range_t * mp) +{ + snat_main_t * sm = &snat_main; + vl_api_snat_add_address_range_reply_t * rmp; + ip4_address_t this_addr; + u32 start_host_order, end_host_order; + int i, count; + int rv = 0; + u32 * tmp; + + if (mp->is_ip4 != 1) + { + rv = VNET_API_ERROR_UNIMPLEMENTED; + goto send_reply; + } + + tmp = (u32 *) mp->first_ip_address; + start_host_order = clib_host_to_net_u32 (tmp[0]); + tmp = (u32 *) mp->last_ip_address; + end_host_order = clib_host_to_net_u32 (tmp[0]); + + count = (end_host_order - start_host_order) + 1; + + if (count > 1024) + clib_warning ("%U - %U, %d addresses...", + format_ip4_address, mp->first_ip_address, + format_ip4_address, mp->last_ip_address, + count); + + memcpy (&this_addr.as_u8, mp->first_ip_address, 4); + + for (i = 0; i < count; i++) + { + snat_add_address (sm, &this_addr); + increment_v4_address (&this_addr); + } + + send_reply: + REPLY_MACRO (VL_API_SNAT_ADD_ADDRESS_RANGE_REPLY); +} + +static void *vl_api_snat_add_address_range_t_print +(vl_api_snat_add_address_range_t *mp, void * handle) +{ + u8 * s; + + s = format (0, "SCRIPT: snat_add_address_range "); + s = format (s, "%U ", format_ip4_address, mp->first_ip_address); + if (memcmp (mp->first_ip_address, mp->last_ip_address, 4)) + { + s = format (s, " - %U ", format_ip4_address, mp->last_ip_address); + } + FINISH; +} + +static void +vl_api_snat_interface_add_del_feature_t_handler +(vl_api_snat_interface_add_del_feature_t * mp) +{ + snat_main_t * sm = &snat_main; + vl_api_snat_interface_add_del_feature_reply_t * rmp; + u8 is_del = mp->is_add == 0; + u32 sw_if_index = ntohl(mp->sw_if_index); + u32 ci; + ip4_main_t * im = &ip4_main; + ip_lookup_main_t * lm = &im->lookup_main; + ip_config_main_t * rx_cm = &lm->rx_config_mains[VNET_UNICAST]; + u32 feature_index; + int rv = 0; + + VALIDATE_SW_IF_INDEX(mp); + + feature_index = mp->is_inside ? sm->rx_feature_in2out + : sm->rx_feature_out2in; + + ci = rx_cm->config_index_by_sw_if_index[sw_if_index]; + ci = (is_del + ? vnet_config_del_feature + : vnet_config_add_feature) + (sm->vlib_main, &rx_cm->config_main, + ci, + feature_index, + 0 /* config struct */, + 0 /* sizeof config struct*/); + rx_cm->config_index_by_sw_if_index[sw_if_index] = ci; + + BAD_SW_IF_INDEX_LABEL; + + REPLY_MACRO(VL_API_SNAT_INTERFACE_ADD_DEL_FEATURE_REPLY); +} + +static void *vl_api_snat_interface_add_del_feature_t_print +(vl_api_snat_interface_add_del_feature_t * mp, void *handle) +{ + u8 * s; + + s = format (0, "SCRIPT: snat_interface_add_del_feature "); + s = format (s, "sw_if_index %d %s %s", + clib_host_to_net_u32(mp->sw_if_index), + mp->is_inside ? "in":"out", + mp->is_add ? "" : "del"); + + FINISH; +} + +/* List of message types that this plugin understands */ +#define foreach_snat_plugin_api_msg \ +_(SNAT_ADD_ADDRESS_RANGE, snat_add_address_range) \ +_(SNAT_INTERFACE_ADD_DEL_FEATURE, snat_interface_add_del_feature) + +/* Set up the API message handling tables */ +static clib_error_t * +snat_plugin_api_hookup (vlib_main_t *vm) +{ + snat_main_t * sm __attribute__ ((unused)) = &snat_main; +#define _(N,n) \ + vl_msg_api_set_handlers((VL_API_##N + sm->msg_id_base), \ + #n, \ + vl_api_##n##_t_handler, \ + vl_noop_handler, \ + vl_api_##n##_t_endian, \ + vl_api_##n##_t_print, \ + sizeof(vl_api_##n##_t), 1); + foreach_snat_plugin_api_msg; +#undef _ + + return 0; +} + +static void plugin_custom_dump_configure (snat_main_t * sm) +{ +#define _(n,f) sm->api_main->msg_print_handlers \ + [VL_API_##n + sm->msg_id_base] \ + = (void *) vl_api_##f##_t_print; + foreach_snat_plugin_api_msg; +#undef _ +} + +static clib_error_t * snat_init (vlib_main_t * vm) +{ + snat_main_t * sm = &snat_main; + clib_error_t * error = 0; + ip4_main_t * im = &ip4_main; + ip_lookup_main_t * lm = &im->lookup_main; + u8 * name; + + name = format (0, "snat_%08x%c", api_version, 0); + + /* Ask for a correctly-sized block of API message decode slots */ + sm->msg_id_base = vl_msg_api_get_msg_ids + ((char *) name, VL_MSG_FIRST_AVAILABLE); + + sm->vlib_main = vm; + sm->vnet_main = vnet_get_main(); + sm->ip4_main = im; + sm->ip4_lookup_main = lm; + sm->api_main = &api_main; + + error = snat_plugin_api_hookup (vm); + plugin_custom_dump_configure (sm); + vec_free(name); + + return error; +} + +VLIB_INIT_FUNCTION (snat_init); + +void snat_free_outside_address_and_port (snat_main_t * sm, + snat_session_key_t * k, + u32 address_index) +{ + snat_address_t *a; + u16 port_host_byte_order = clib_net_to_host_u16 (k->port); + + ASSERT (address_index < vec_len (sm->addresses)); + + a = sm->addresses + address_index; + + ASSERT (clib_bitmap_get (a->busy_port_bitmap, port_host_byte_order) == 1); + + a->busy_port_bitmap = clib_bitmap_set (a->busy_port_bitmap, + port_host_byte_order, 0); + a->busy_ports--; +} + +int snat_alloc_outside_address_and_port (snat_main_t * sm, + snat_session_key_t * k, + u32 * address_indexp) +{ + int i; + snat_address_t *a; + u32 portnum; + + for (i = 0; i < vec_len (sm->addresses); i++) + { + if (sm->addresses[i].busy_ports < (65535-1024)) + { + a = sm->addresses + i; + + while (1) + { + portnum = random_u32 (&sm->random_seed); + portnum &= 0xFFFF; + if (portnum < 1024) + continue; + if (clib_bitmap_get (a->busy_port_bitmap, portnum)) + continue; + a->busy_port_bitmap = clib_bitmap_set (a->busy_port_bitmap, + portnum, 1); + a->busy_ports++; + /* Caller sets protocol and fib index */ + k->addr = a->addr; + k->port = clib_host_to_net_u16(portnum); + *address_indexp = i; + return 0; + } + } + } + /* Totally out of translations to use... */ + return 1; +} + + +static clib_error_t * +add_address_command_fn (vlib_main_t * vm, + unformat_input_t * input, + vlib_cli_command_t * cmd) +{ + snat_main_t * sm = &snat_main; + ip4_address_t start_addr, end_addr, this_addr; + u32 start_host_order, end_host_order; + int i, count; + + if (unformat (input, "%U - %U", + unformat_ip4_address, &start_addr, + unformat_ip4_address, &end_addr)) + ; + else if (unformat (input, "%U", unformat_ip4_address, &start_addr)) + end_addr = start_addr; + + start_host_order = clib_host_to_net_u32 (start_addr.as_u32); + end_host_order = clib_host_to_net_u32 (end_addr.as_u32); + + if (end_host_order < start_host_order) + return clib_error_return (0, "end address less than start address"); + + count = (end_host_order - start_host_order) + 1; + + if (count > 1024) + clib_warning ("%U - %U, %d addresses...", + format_ip4_address, &start_addr, + format_ip4_address, &end_addr, + count); + + this_addr = start_addr; + + for (i = 0; i < count; i++) + { + snat_add_address (sm, &this_addr); + increment_v4_address (&this_addr); + } + + return 0; +} + +VLIB_CLI_COMMAND (add_address_command, static) = { + .path = "snat add address", + .short_help = "snat add addresses [- ]", + .function = add_address_command_fn, +}; + +static clib_error_t * +snat_feature_command_fn (vlib_main_t * vm, + unformat_input_t * input, + vlib_cli_command_t * cmd) +{ + vnet_main_t * vnm = vnet_get_main(); + snat_main_t * sm = &snat_main; + ip4_main_t * im = &ip4_main; + ip_lookup_main_t * lm = &im->lookup_main; + ip_config_main_t * rx_cm = &lm->rx_config_mains[VNET_UNICAST]; + clib_error_t * error = 0; + u32 sw_if_index, ci; + u32 feature_index; + u32 * inside_sw_if_indices = 0; + u32 * outside_sw_if_indices = 0; + int is_del = 0; + int i; + + sw_if_index = ~0; + + while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) + { + if (unformat (input, "in %U", unformat_vnet_sw_interface, + vnm, &sw_if_index)) + vec_add1 (inside_sw_if_indices, sw_if_index); + else if (unformat (input, "out %U", unformat_vnet_sw_interface, + vnm, &sw_if_index)) + vec_add1 (outside_sw_if_indices, sw_if_index); + else if (unformat (input, "del")) + is_del = 1; + else + break; + } + + if (vec_len (inside_sw_if_indices)) + { + feature_index = sm->rx_feature_in2out; + + for (i = 0; i < vec_len(inside_sw_if_indices); i++) + { + sw_if_index = inside_sw_if_indices[i]; + ci = rx_cm->config_index_by_sw_if_index[sw_if_index]; + ci = (is_del + ? vnet_config_del_feature + : vnet_config_add_feature) + (vm, &rx_cm->config_main, + ci, + feature_index, + 0 /* config struct */, + 0 /* sizeof config struct*/); + rx_cm->config_index_by_sw_if_index[sw_if_index] = ci; + } + } + + if (vec_len (outside_sw_if_indices)) + { + feature_index = sm->rx_feature_out2in; + + for (i = 0; i < vec_len(outside_sw_if_indices); i++) + { + sw_if_index = outside_sw_if_indices[i]; + ci = rx_cm->config_index_by_sw_if_index[sw_if_index]; + ci = (is_del + ? vnet_config_del_feature + : vnet_config_add_feature) + (vm, &rx_cm->config_main, + ci, + feature_index, + 0 /* config struct */, + 0 /* sizeof config struct*/); + rx_cm->config_index_by_sw_if_index[sw_if_index] = ci; + } + } + + vec_free (inside_sw_if_indices); + vec_free (outside_sw_if_indices); + + return error; +} + +VLIB_CLI_COMMAND (set_interface_snat_command, static) = { + .path = "set interface snat", + .function = snat_feature_command_fn, + .short_help = "set interface snat in out [del]", +}; + +static clib_error_t * +snat_config (vlib_main_t * vm, unformat_input_t * input) +{ + snat_main_t * sm = &snat_main; + u32 translation_buckets = 1024; + u32 translation_memory_size = 128<<20; + u32 user_buckets = 128; + u32 user_memory_size = 64<<20; + u32 max_translations_per_user = 100; + u32 outside_vrf_id = 0; + + while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) + { + if (unformat (input, "translation hash buckets %d", &translation_buckets)) + ; + else if (unformat (input, "translation hash memory %d", + &translation_memory_size)); + else if (unformat (input, "user hash buckets %d", &user_buckets)) + ; + else if (unformat (input, "user hash memory %d", + &user_memory_size)) + ; + else if (unformat (input, "max translations per user %d", + &max_translations_per_user)) + ; + else if (unformat (input, "outside VRF id %d", + &outside_vrf_id)) + ; + else + return clib_error_return (0, "unknown input `%U'", + format_unformat_error, input); + } + + /* for show commands, etc. */ + sm->translation_buckets = translation_buckets; + sm->translation_memory_size = translation_memory_size; + sm->user_buckets = user_buckets; + sm->user_memory_size = user_memory_size; + sm->max_translations_per_user = max_translations_per_user; + sm->outside_vrf_id = outside_vrf_id; + + clib_bihash_init_8_8 (&sm->in2out, "in2out", translation_buckets, + translation_memory_size); + + clib_bihash_init_8_8 (&sm->out2in, "out2in", translation_buckets, + translation_memory_size); + + clib_bihash_init_8_8 (&sm->user_hash, "users", user_buckets, + user_memory_size); + return 0; +} + +VLIB_CONFIG_FUNCTION (snat_config, "snat"); + +u8 * format_snat_key (u8 * s, va_list * args) +{ + snat_session_key_t * key = va_arg (*args, snat_session_key_t *); + char * protocol_string = "unknown"; + static char *protocol_strings[] = { + "UDP", + "TCP", + "ICMP", + }; + + if (key->protocol < ARRAY_LEN(protocol_strings)) + protocol_string = protocol_strings[key->protocol]; + + s = format (s, "%U proto %s port %d fib %d", + format_ip4_address, &key->addr, protocol_string, + key->port, key->fib_index); + return s; +} + +u8 * format_snat_session (u8 * s, va_list * args) +{ + snat_main_t * sm __attribute__((unused)) = va_arg (*args, snat_main_t *); + snat_session_t * sess = va_arg (*args, snat_session_t *); + + s = format (s, " i2o %U\n", format_snat_key, &sess->in2out); + s = format (s, " o2i %U\n", format_snat_key, &sess->out2in); + s = format (s, " last heard %.2f\n", sess->last_heard); + s = format (s, " total pkts %d, total bytes %lld\n", + sess->total_pkts, sess->total_bytes); + + return s; +} + +u8 * format_snat_user (u8 * s, va_list * args) +{ + snat_main_t * sm = va_arg (*args, snat_main_t *); + snat_user_t * u = va_arg (*args, snat_user_t *); + int verbose = va_arg (*args, int); + dlist_elt_t * head, * elt; + u32 elt_index, head_index; + u32 session_index; + snat_session_t * sess; + + s = format (s, "%U: %d translations\n", + format_ip4_address, &u->addr, u->nsessions); + + if (verbose == 0) + return s; + + head_index = u->sessions_per_user_list_head_index; + head = pool_elt_at_index (sm->list_pool, head_index); + + elt_index = head->next; + elt = pool_elt_at_index (sm->list_pool, elt_index); + session_index = elt->value; + + while (session_index != ~0) + { + sess = pool_elt_at_index (sm->sessions, session_index); + + s = format (s, " %U\n", format_snat_session, sm, sess); + + elt_index = elt->next; + elt = pool_elt_at_index (sm->list_pool, elt_index); + session_index = elt->value; + } + + return s; +} + +static clib_error_t * +show_snat_command_fn (vlib_main_t * vm, + unformat_input_t * input, + vlib_cli_command_t * cmd) +{ + int verbose = 0; + snat_main_t * sm = &snat_main; + snat_user_t * u; + + if (unformat (input, "detail")) + verbose = 1; + else if (unformat (input, "verbose")) + verbose = 2; + + vlib_cli_output (vm, "%d users, %d outside addresses, %d active sessions", + pool_elts (sm->users), + vec_len (sm->addresses), + pool_elts (sm->sessions)); + + if (verbose > 0) + { + vlib_cli_output (vm, "%U", format_bihash_8_8, &sm->in2out, + verbose - 1); + vlib_cli_output (vm, "%U", format_bihash_8_8, &sm->out2in, + verbose - 1); + vlib_cli_output (vm, "%d list pool elements", + pool_elts (sm->list_pool)); + + pool_foreach (u, sm->users, + ({ + vlib_cli_output (vm, "%U", format_snat_user, sm, u, verbose - 1); + })); + } + + return 0; +} + +VLIB_CLI_COMMAND (show_snat_command, static) = { + .path = "show snat", + .short_help = "show snat", + .function = show_snat_command_fn, +}; diff --git a/plugins/snat-plugin/snat/snat.h b/plugins/snat-plugin/snat/snat.h new file mode 100644 index 00000000..e3aa5627 --- /dev/null +++ b/plugins/snat-plugin/snat/snat.h @@ -0,0 +1,181 @@ + +/* + * snat.h - simple nat definitions + * + * Copyright (c) 2016 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef __included_snat_h__ +#define __included_snat_h__ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* Key */ +typedef struct { + union + { + struct + { + ip4_address_t addr; + u16 port; + u16 protocol:3, + fib_index:13; + }; + u64 as_u64; + }; +} snat_session_key_t; + +typedef struct { + union + { + struct + { + ip4_address_t addr; + u32 fib_index; + }; + u64 as_u64; + }; +} snat_user_key_t; + + +typedef enum { + SNAT_PROTOCOL_UDP = 0, + SNAT_PROTOCOL_TCP, + SNAT_PROTOCOL_ICMP, +} snat_protocol_t; + + +typedef CLIB_PACKED(struct { + snat_session_key_t out2in; /* 0-15 */ + + snat_session_key_t in2out; /* 16-31 */ + + u32 flags; /* 32-35 */ + + /* per-user translations */ + u32 per_user_index; /* 36-39 */ + + u32 per_user_list_head_index; /* 40-43 */ + + /* Last heard timer */ + f64 last_heard; /* 44-51 */ + + u64 total_bytes; /* 52-59 */ + + u32 total_pkts; /* 60-63 */ + + /* Outside address */ + u32 outside_address_index; /* 64-67 */ + +}) snat_session_t; + +#define SNAT_SESSION_STATIC (1<<0) + +typedef struct { + ip4_address_t addr; + u32 sessions_per_user_list_head_index; + u32 nsessions; +} snat_user_t; + +typedef struct { + ip4_address_t addr; + u32 busy_ports; + uword * busy_port_bitmap; +} snat_address_t; + +typedef struct { + /* Main lookup tables */ + clib_bihash_8_8_t out2in; + clib_bihash_8_8_t in2out; + + /* Find-a-user => src address lookup */ + clib_bihash_8_8_t user_hash; + + /* User pool */ + snat_user_t * users; + + /* Session pool */ + snat_session_t * sessions; + + /* Vector of outside addresses */ + snat_address_t * addresses; + + /* Pool of doubly-linked list elements */ + dlist_elt_t * list_pool; + + /* Randomize port allocation order */ + u32 random_seed; + + /* ip4 feature path indices */ + u32 rx_feature_in2out; + u32 rx_feature_out2in; + + /* Config parameters */ + u32 translation_buckets; + u32 translation_memory_size; + u32 user_buckets; + u32 user_memory_size; + u32 max_translations_per_user; + u32 outside_vrf_id; + u32 outside_fib_index; + + /* API message ID base */ + u16 msg_id_base; + + /* convenience */ + vlib_main_t * vlib_main; + vnet_main_t * vnet_main; + ip4_main_t * ip4_main; + ip_lookup_main_t * ip4_lookup_main; + ethernet_main_t * ethernet_main; + api_main_t * api_main; +} snat_main_t; + +extern snat_main_t snat_main; +extern vlib_node_registration_t snat_in2out_node; +extern vlib_node_registration_t snat_out2in_node; + +void snat_free_outside_address_and_port (snat_main_t * sm, + snat_session_key_t * k, + u32 address_index); + +int snat_alloc_outside_address_and_port (snat_main_t * sm, + snat_session_key_t * k, + u32 * address_indexp); +format_function_t format_snat_user; + +typedef struct { + u32 cached_sw_if_index; + u32 cached_ip4_address; +} snat_runtime_t; + +/* + * Why is this here? Because we don't need to touch this layer to + * simply reply to an icmp. We need to change id to a unique + * value to NAT an echo request/reply. + */ + +typedef struct { + u16 identifier; + u16 sequence; +} icmp_echo_header_t; + +#endif /* __included_snat_h__ */ diff --git a/plugins/snat-plugin/snat/snat_all_api_h.h b/plugins/snat-plugin/snat/snat_all_api_h.h new file mode 100644 index 00000000..49017700 --- /dev/null +++ b/plugins/snat-plugin/snat/snat_all_api_h.h @@ -0,0 +1,19 @@ + +/* + * snat_all_api_h.h - skeleton vpp engine plug-in api #include file + * + * Copyright (c) + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/* Include the generated file, see BUILT_SOURCES in Makefile.am */ +#include diff --git a/plugins/snat-plugin/snat/snat_msg_enum.h b/plugins/snat-plugin/snat/snat_msg_enum.h new file mode 100644 index 00000000..2c76fd51 --- /dev/null +++ b/plugins/snat-plugin/snat/snat_msg_enum.h @@ -0,0 +1,31 @@ + +/* + * snat_msg_enum.h - skeleton vpp engine plug-in message enumeration + * + * Copyright (c) + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef included_snat_msg_enum_h +#define included_snat_msg_enum_h + +#include + +#define vl_msg_id(n,h) n, +typedef enum { +#include + /* We'll want to know how many messages IDs we need... */ + VL_MSG_FIRST_AVAILABLE, +} vl_msg_id_t; +#undef vl_msg_id + +#endif /* included_snat_msg_enum_h */ diff --git a/plugins/snat-plugin/snat/snat_test.c b/plugins/snat-plugin/snat/snat_test.c new file mode 100644 index 00000000..cd2656cb --- /dev/null +++ b/plugins/snat-plugin/snat/snat_test.c @@ -0,0 +1,265 @@ + +/* + * snat.c - skeleton vpp-api-test plug-in + * + * Copyright (c) + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include +#include +#include +#include +#include +#include + +uword unformat_sw_if_index (unformat_input_t * input, va_list * args); + +/* Declare message IDs */ +#include + +/* define message structures */ +#define vl_typedefs +#include +#undef vl_typedefs + +/* declare message handlers for each api */ + +#define vl_endianfun /* define message structures */ +#include +#undef vl_endianfun + +/* instantiate all the print functions we know about */ +#define vl_print(handle, ...) +#define vl_printfun +#include +#undef vl_printfun + +/* Get the API version number. */ +#define vl_api_version(n,v) static u32 api_version=(v); +#include +#undef vl_api_version + +typedef struct { + /* API message ID base */ + u16 msg_id_base; + vat_main_t *vat_main; +} snat_test_main_t; + +snat_test_main_t snat_test_main; + +#define foreach_standard_reply_retval_handler \ +_(snat_add_address_range_reply) \ +_(snat_interface_add_del_feature_reply) + +#define _(n) \ + static void vl_api_##n##_t_handler \ + (vl_api_##n##_t * mp) \ + { \ + vat_main_t * vam = snat_test_main.vat_main; \ + i32 retval = ntohl(mp->retval); \ + if (vam->async_mode) { \ + vam->async_errors += (retval < 0); \ + } else { \ + vam->retval = retval; \ + vam->result_ready = 1; \ + } \ + } +foreach_standard_reply_retval_handler; +#undef _ + +/* + * Table of message reply handlers, must include boilerplate handlers + * we just generated + */ +#define foreach_vpe_api_reply_msg \ +_(SNAT_ADD_ADDRESS_RANGE_REPLY, snat_add_address_range_reply) \ + _(SNAT_INTERFACE_ADD_DEL_FEATURE_REPLY, \ + snat_interface_add_del_feature_reply) + +/* M: construct, but don't yet send a message */ +#define M(T,t) \ +do { \ + vam->result_ready = 0; \ + mp = vl_msg_api_alloc(sizeof(*mp)); \ + memset (mp, 0, sizeof (*mp)); \ + mp->_vl_msg_id = ntohs (VL_API_##T + sm->msg_id_base); \ + mp->client_index = vam->my_client_index; \ +} while(0); + +#define M2(T,t,n) \ +do { \ + vam->result_ready = 0; \ + mp = vl_msg_api_alloc(sizeof(*mp)+(n)); \ + memset (mp, 0, sizeof (*mp)); \ + mp->_vl_msg_id = ntohs (VL_API_##T + sm->msg_id_base); \ + mp->client_index = vam->my_client_index; \ +} while(0); + +/* S: send a message */ +#define S (vl_msg_api_send_shmem (vam->vl_input_queue, (u8 *)&mp)) + +/* W: wait for results, with timeout */ +#define W \ +do { \ + timeout = vat_time_now (vam) + 1.0; \ + \ + while (vat_time_now (vam) < timeout) { \ + if (vam->result_ready == 1) { \ + return (vam->retval); \ + } \ + } \ + return -99; \ +} while(0); + +static int api_snat_add_address_range (vat_main_t * vam) +{ + snat_test_main_t * sm = &snat_test_main; + unformat_input_t * i = vam->input; + f64 timeout; + ip4_address_t start_addr, end_addr; + u32 start_host_order, end_host_order; + vl_api_snat_add_address_range_t * mp; + int count; + + if (unformat (i, "%U - %U", + unformat_ip4_address, &start_addr, + unformat_ip4_address, &end_addr)) + ; + else if (unformat (i, "%U", unformat_ip4_address, &start_addr)) + end_addr = start_addr; + + start_host_order = clib_host_to_net_u32 (start_addr.as_u32); + end_host_order = clib_host_to_net_u32 (end_addr.as_u32); + + if (end_host_order < start_host_order) + { + errmsg ("end address less than start address\n"); + return -99; + } + + count = (end_host_order - start_host_order) + 1; + + if (count > 1024) + { + errmsg ("%U - %U, %d addresses...\n", + format_ip4_address, &start_addr, + format_ip4_address, &end_addr, + count); + } + + M(SNAT_ADD_ADDRESS_RANGE, snat_add_address_range); + + memcpy (mp->first_ip_address, &start_addr, 4); + memcpy (mp->last_ip_address, &end_addr, 4); + mp->is_ip4 = 1; + + S; W; + + /* NOTREACHED */ + return 0; +} + +static int api_snat_interface_add_del_feature (vat_main_t * vam) +{ + snat_test_main_t * sm = &snat_test_main; + unformat_input_t * i = vam->input; + f64 timeout; + vl_api_snat_interface_add_del_feature_t * mp; + u32 sw_if_index; + u8 sw_if_index_set = 0; + u8 is_inside = 1; + u8 is_add = 1; + + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index)) + sw_if_index_set = 1; + else if (unformat (i, "sw_if_index %d", &sw_if_index)) + sw_if_index_set = 1; + else if (unformat (i, "out")) + is_inside = 0; + else if (unformat (i, "in")) + is_inside = 1; + else if (unformat (i, "del")) + is_add = 0; + } + + if (sw_if_index_set == 0) + { + errmsg ("interface / sw_if_index required\n"); + return -99; + } + + M(SNAT_INTERFACE_ADD_DEL_FEATURE, snat_interface_add_del_feature); + mp->sw_if_index = ntohl(sw_if_index); + mp->is_add = is_add; + mp->is_inside = is_inside; + + S; W; + /* NOTREACHED */ + return 0; +} + +/* + * List of messages that the api test plugin sends, + * and that the data plane plugin processes + */ +#define foreach_vpe_api_msg \ +_(snat_add_address_range, " [- | sw_if_index [in] [out] [del]") + +void vat_api_hookup (vat_main_t *vam) +{ + snat_test_main_t * sm __attribute__((unused)) = &snat_test_main; + /* Hook up handlers for replies from the data plane plug-in */ +#define _(N,n) \ + vl_msg_api_set_handlers((VL_API_##N + sm->msg_id_base), \ + #n, \ + vl_api_##n##_t_handler, \ + vl_noop_handler, \ + vl_api_##n##_t_endian, \ + vl_api_##n##_t_print, \ + sizeof(vl_api_##n##_t), 1); + foreach_vpe_api_reply_msg; +#undef _ + + /* API messages we can send */ +#define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n); + foreach_vpe_api_msg; +#undef _ + + /* Help strings */ +#define _(n,h) hash_set_mem (vam->help_by_name, #n, h); + foreach_vpe_api_msg; +#undef _ +} + +clib_error_t * vat_plugin_register (vat_main_t *vam) +{ + snat_test_main_t * sm = &snat_test_main; + u8 * name; + + sm->vat_main = vam; + + /* Ask the vpp engine for the first assigned message-id */ + name = format (0, "snat_%08x%c", api_version, 0); + sm->msg_id_base = vl_client_get_first_plugin_msg_id ((char *) name); + + if (sm->msg_id_base != (u16) ~0) + vat_api_hookup (vam); + + vec_free(name); + + return 0; +} diff --git a/vpp/Makefile.am b/vpp/Makefile.am index 5577c075..74d6d41c 100644 --- a/vpp/Makefile.am +++ b/vpp/Makefile.am @@ -71,6 +71,12 @@ BUILT_SOURCES += vpp_plugin_configure .PHONY: vpp_plugin_configure +if WITH_DPDK +PLUGIN_DPDK_ARG="--with-dpdk" +else +PLUGIN_DPDK_ARG="" +endif + vpp_plugin_configure: @echo "PLUGIN CONFIGURE " $@ @echo "#!/bin/bash" > $@ @@ -78,10 +84,10 @@ vpp_plugin_configure: @echo "set +eu" >> $@ @echo " " >> $@ @echo "if [ -f ./configure ] ; then" >> $@ - @echo " CFLAGS='$(CFLAGS) $(AM_CFLAGS) -I/usr/include/vpp-dpdk' ./configure --with-plugin-toolkit" >> $@ + @echo " CFLAGS='$(CFLAGS) $(AM_CFLAGS) -I/usr/include/vpp-dpdk' ./configure --with-plugin-toolkit $(PLUGIN_DPDK_ARG)" >> $@ @echo "else" >> $@ @echo " if [ -f ../configure ] ; then" >> $@ - @echo " CFLAGS='$(CFLAGS) $(AM_CFLAGS) -I/usr/include/vpp-dpdk' ../configure --with-plugin-toolkit" >> $@ + @echo " CFLAGS='$(CFLAGS) $(AM_CFLAGS) -I/usr/include/vpp-dpdk' ../configure --with-plugin-toolkit $(PLUGIN_DPDK_ARG)" >> $@ @echo " else" >> $@ @echo " echo Couldnt find ./configure or ../configure " >> $@ @echo " exit 1" >> $@ -- cgit 1.2.3-korg From 905a7f5520a64aad545c8dd02796b56f88ed2d38 Mon Sep 17 00:00:00 2001 From: Damjan Marion Date: Thu, 7 Jul 2016 20:27:49 +0200 Subject: Multiple changes in the plugin build infra - configure.ac - some plugins are enabled by default - Plugin .so files are placed into corresponding subdirs - WITH_PLUGIN_TOOLKIT macro is retired - not needed anymore - plugins/build-data is removed - plugin makefiles are not building static libs anymore - plugin makefiles are not installing header files to /usr/include anymore Change-Id: I55681bd9ce34811f7eb1b2b24d9f0ca42df1cf04 Signed-off-by: Damjan Marion --- Makefile | 6 ++-- build-data/platforms/vpp.mk | 4 +-- build-root/bootstrap.sh | 2 +- plugins/build-data/packages/ioam-plugin.mk | 47 ---------------------------- plugins/build-data/packages/sample-plugin.mk | 47 ---------------------------- plugins/build-data/packages/sixrd-plugin.mk | 47 ---------------------------- plugins/build-data/packages/vcgn-plugin.mk | 47 ---------------------------- plugins/configure.ac | 36 ++++++++++++--------- plugins/ioam-plugin/Makefile.am | 23 +++++++------- plugins/ioam-plugin/configure.ac | 11 +------ plugins/sample-plugin/Makefile.am | 25 ++++++++------- plugins/sample-plugin/configure.ac | 11 +------ plugins/sixrd-plugin/Makefile.am | 19 ++++++----- plugins/sixrd-plugin/configure.ac | 11 +------ plugins/snat-plugin/Makefile.am | 32 +++++++++---------- plugins/snat-plugin/configure.ac | 12 +------ plugins/vcgn-plugin/Makefile.am | 14 ++++----- plugins/vcgn-plugin/configure.ac | 11 +------ 18 files changed, 84 insertions(+), 321 deletions(-) delete mode 100644 plugins/build-data/packages/ioam-plugin.mk delete mode 100644 plugins/build-data/packages/sample-plugin.mk delete mode 100644 plugins/build-data/packages/sixrd-plugin.mk delete mode 100644 plugins/build-data/packages/vcgn-plugin.mk (limited to 'build-data/platforms/vpp.mk') diff --git a/Makefile b/Makefile index 49a73861..a1c63078 100644 --- a/Makefile +++ b/Makefile @@ -110,7 +110,7 @@ ifeq ($(OS_ID),ubuntu) fi ; \ exit 0 endif - @echo "SOURCE_PATH = $(WS_ROOT) $(WS_ROOT)/plugins"> $(BR)/build-config.mk + @echo "SOURCE_PATH = $(WS_ROOT)" > $(BR)/build-config.mk @echo "#!/bin/bash\n" > $(BR)/path_setup @echo 'export PATH=$(BR)/tools/ccache-bin:$$PATH' >> $(BR)/path_setup @echo 'export PATH=$(BR)/tools/bin:$$PATH' >> $(BR)/path_setup @@ -178,12 +178,12 @@ define run @echo "WARNING: STARTUP_CONF not defined or file doesn't exist." @echo " Running with minimal startup config: $(MINIMAL_STARTUP_CONF)\n" @cd $(STARTUP_DIR) && \ - sudo $(2) $(1)/vpp/bin/vpp $(MINIMAL_STARTUP_CONF) plugin_path $(1)/plugins/lib64 + sudo $(2) $(1)/vpp/bin/vpp $(MINIMAL_STARTUP_CONF) plugin_path $(1)/plugins/lib64/vpp_plugins endef else define run @cd $(STARTUP_DIR) && \ - sudo $(2) $(1)/vpp/bin/vpp $(shell cat $(STARTUP_CONF) | sed -e 's/#.*//') plugin_path $(1)/plugins/lib64 + sudo $(2) $(1)/vpp/bin/vpp $(shell cat $(STARTUP_CONF) | sed -e 's/#.*//') plugin_path $(1)/plugins/lib64/vpp_plugins endef endif diff --git a/build-data/platforms/vpp.mk b/build-data/platforms/vpp.mk index 45f74d33..fb1867c7 100644 --- a/build-data/platforms/vpp.mk +++ b/build-data/platforms/vpp.mk @@ -38,9 +38,7 @@ vnet_configure_args_vpp = --with-dpdk # Set these parameters carefully. The vlib_buffer_t is 128 bytes, i.e. vlib_configure_args_vpp = --with-pre-data=128 -# Enable plugins here, and no place else, via multiple --enable-XXX-plugin -# stanzas. -plugins_configure_args_vpp = --with-dpdk --enable-sixrd-plugin +plugins_configure_args_vpp = --with-dpdk # DPDK configuration parameters # vpp_uses_external_dpdk = yes diff --git a/build-root/bootstrap.sh b/build-root/bootstrap.sh index 2419b6ae..f83734fd 100755 --- a/build-root/bootstrap.sh +++ b/build-root/bootstrap.sh @@ -12,7 +12,7 @@ ADD_TO_PATH="$build_root/tools/ccache-bin:$build_root/tools/bin" # Construct build-config.mk cd $build_root -echo SOURCE_PATH = $wsroot $wsroot/plugins/ > build-config.mk +echo SOURCE_PATH = $wsroot > build-config.mk echo echo Saving PATH settings in `pwd`/path_setup echo Source this file later, as needed diff --git a/plugins/build-data/packages/ioam-plugin.mk b/plugins/build-data/packages/ioam-plugin.mk deleted file mode 100644 index 1ebe8184..00000000 --- a/plugins/build-data/packages/ioam-plugin.mk +++ /dev/null @@ -1,47 +0,0 @@ -ioam-plugin_configure_depend = \ - vppinfra-install \ - svm-install \ - vlib-api-install \ - vlib-install \ - vnet-install \ - vpp-install \ - vpp-api-test-install - -ioam-plugin_CPPFLAGS = $(call installed_includes_fn, \ - vppinfra \ - openssl \ - svm \ - vlib \ - vlib-api \ - vnet \ - vpp \ - vpp-api-test) - -ioam-plugin_LDFLAGS = $(call installed_libs_fn, \ - vppinfra \ - openssl \ - svm \ - vlib \ - vlib-api \ - vnet \ - vpp \ - vpp-api-test) - -ioam-plugin_post_install = \ - mkdir -p $(PACKAGE_INSTALL_DIR)/$(arch_lib_dir)/vlib_plugins ; \ - cp $(PACKAGE_INSTALL_DIR)/$(arch_lib_dir)/*.so \ - $(PACKAGE_INSTALL_DIR)/$(arch_lib_dir)/vlib_plugins - -ioam-plugin_image_include = echo $(arch_lib_dir)/vlib_plugins - -ifneq ($($(PLATFORM)_uses_dpdk),no) -ioam-plugin_configure_args = --with-dpdk -ifeq ($($(PLATFORM)_uses_external_dpdk),yes) -ioam-plugin_CPPFLAGS += -I$($(PLATFORM)_dpdk_inc_dir) -ioam-plugin_LDFLAGS += -L$($(PLATFORM)_dpdk_lib_dir) -else -ioam-plugin_configure_depend += dpdk-install -ioam-plugin_CPPFLAGS += $(call installed_includes_fn, dpdk) -ioam-plugin_LDFLAGS += $(call installed_libs_fn, dpdk) -endif -endif diff --git a/plugins/build-data/packages/sample-plugin.mk b/plugins/build-data/packages/sample-plugin.mk deleted file mode 100644 index 047a26f5..00000000 --- a/plugins/build-data/packages/sample-plugin.mk +++ /dev/null @@ -1,47 +0,0 @@ -sample-plugin_configure_depend = \ - vppinfra-install \ - svm-install \ - vlib-api-install \ - vlib-install \ - vnet-install \ - vpp-install \ - vpp-api-test-install - -sample-plugin_CPPFLAGS = $(call installed_includes_fn, \ - vppinfra \ - openssl \ - svm \ - vlib \ - vlib-api \ - vnet \ - vpp \ - vpp-api-test) - -sample-plugin_LDFLAGS = $(call installed_libs_fn, \ - vppinfra \ - openssl \ - svm \ - vlib \ - vlib-api \ - vnet \ - vpp \ - vpp-api-test) - -sample-plugin_post_install = \ - mkdir -p $(PACKAGE_INSTALL_DIR)/$(arch_lib_dir)/vlib_plugins ; \ - cp $(PACKAGE_INSTALL_DIR)/$(arch_lib_dir)/*.so \ - $(PACKAGE_INSTALL_DIR)/$(arch_lib_dir)/vlib_plugins - -sample-plugin_image_include = echo $(arch_lib_dir)/vlib_plugins - -ifneq ($($(PLATFORM)_uses_dpdk),no) -sample-plugin_configure_args = --with-dpdk -ifeq ($($(PLATFORM)_uses_external_dpdk),yes) -sample-plugin_CPPFLAGS += -I$($(PLATFORM)_dpdk_inc_dir) -sample-plugin_LDFLAGS += -L$($(PLATFORM)_dpdk_lib_dir) -else -sample-plugin_configure_depend += dpdk-install -sample-plugin_CPPFLAGS += $(call installed_includes_fn, dpdk) -sample-plugin_LDFLAGS += $(call installed_libs_fn, dpdk) -endif -endif diff --git a/plugins/build-data/packages/sixrd-plugin.mk b/plugins/build-data/packages/sixrd-plugin.mk deleted file mode 100644 index 186d9b8f..00000000 --- a/plugins/build-data/packages/sixrd-plugin.mk +++ /dev/null @@ -1,47 +0,0 @@ -sixrd-plugin_configure_depend = \ - vppinfra-install \ - svm-install \ - vlib-api-install \ - vlib-install \ - vnet-install \ - vpp-install \ - vpp-api-test-install - -sixrd-plugin_CPPFLAGS = $(call installed_includes_fn, \ - vppinfra \ - openssl \ - svm \ - vlib \ - vlib-api \ - vnet \ - vpp \ - vpp-api-test) - -sixrd-plugin_LDFLAGS = $(call installed_libs_fn, \ - vppinfra \ - openssl \ - svm \ - vlib \ - vlib-api \ - vnet \ - vpp \ - vpp-api-test) - -sixrd-plugin_post_install = \ - mkdir -p $(PACKAGE_INSTALL_DIR)/$(arch_lib_dir)/vlib_plugins ; \ - cp $(PACKAGE_INSTALL_DIR)/$(arch_lib_dir)/*.so \ - $(PACKAGE_INSTALL_DIR)/$(arch_lib_dir)/vlib_plugins - -sixrd-plugin_image_include = echo $(arch_lib_dir)/vlib_plugins - -ifneq ($($(PLATFORM)_uses_dpdk),no) -sixrd-plugin_configure_args = --with-dpdk -ifeq ($($(PLATFORM)_uses_external_dpdk),yes) -sixrd-plugin_CPPFLAGS += -I$($(PLATFORM)_dpdk_inc_dir) -sixrd-plugin_LDFLAGS += -L$($(PLATFORM)_dpdk_lib_dir) -else -sixrd-plugin_configure_depend += dpdk-install -sixrd-plugin_CPPFLAGS += $(call installed_includes_fn, dpdk) -sixrd-plugin_LDFLAGS += $(call installed_libs_fn, dpdk) -endif -endif diff --git a/plugins/build-data/packages/vcgn-plugin.mk b/plugins/build-data/packages/vcgn-plugin.mk deleted file mode 100644 index cd865c15..00000000 --- a/plugins/build-data/packages/vcgn-plugin.mk +++ /dev/null @@ -1,47 +0,0 @@ -vcgn-plugin_configure_depend = \ - vppinfra-install \ - svm-install \ - vlib-api-install \ - vlib-install \ - vnet-install \ - vpp-install \ - vpp-api-test-install - -vcgn-plugin_CPPFLAGS = $(call installed_includes_fn, \ - vppinfra \ - openssl \ - svm \ - vlib \ - vlib-api \ - vnet \ - vpp \ - vpp-api-test) - -vcgn-plugin_LDFLAGS = $(call installed_libs_fn, \ - vppinfra \ - openssl \ - svm \ - vlib \ - vlib-api \ - vnet \ - vpp \ - vpp-api-test) - -vcgn-plugin_post_install = \ - mkdir -p $(PACKAGE_INSTALL_DIR)/$(arch_lib_dir)/vlib_plugins ; \ - cp $(PACKAGE_INSTALL_DIR)/$(arch_lib_dir)/*.so \ - $(PACKAGE_INSTALL_DIR)/$(arch_lib_dir)/vlib_plugins - -vcgn-plugin_image_include = echo $(arch_lib_dir)/vlib_plugins - -ifneq ($($(PLATFORM)_uses_dpdk),no) -vcgn-plugin_configure_args = --with-dpdk -ifeq ($($(PLATFORM)_uses_external_dpdk),yes) -vcgn-plugin_CPPFLAGS += -I$($(PLATFORM)_dpdk_inc_dir) -vcgn-plugin_LDFLAGS += -L$($(PLATFORM)_dpdk_lib_dir) -else -vcgn-plugin_configure_depend += dpdk-install -vcgn-plugin_CPPFLAGS += $(call installed_includes_fn, dpdk) -vcgn-plugin_LDFLAGS += $(call installed_libs_fn, dpdk) -endif -endif diff --git a/plugins/configure.ac b/plugins/configure.ac index 7aff9875..f10d1803 100644 --- a/plugins/configure.ac +++ b/plugins/configure.ac @@ -11,25 +11,29 @@ AC_ARG_ENABLE(tests, [enable_tests=1], [enable_tests=0]) -AC_ARG_WITH(plugin-toolkit, - AC_HELP_STRING([--with-plugin-toolkit], - [build using the vpp toolkit]), - [with_plugin_toolkit=${prefix}/include], - [with_plugin_toolkit=.]) - AC_ARG_WITH(dpdk, AC_HELP_STRING([--with-dpdk],[Use the Intel dpdk]), [with_dpdk=1], [with_dpdk=0]) -AC_SUBST(TOOLKIT_INCLUDE,[${with_plugin_toolkit}]) -AM_CONDITIONAL(WITH_PLUGIN_TOOLKIT, test "$with_plugin_toolkit" != ".") AM_CONDITIONAL(ENABLE_TESTS, test "$enable_tests" = "1") AM_CONDITIONAL(WITH_DPDK, test "$with_dpdk" = "1") AC_SUBST(DPDK,["-DDPDK=${with_dpdk}"]) -AC_DEFUN([PLUGIN], +AC_DEFUN([PLUGIN_ENABLED], +[ + AC_ARG_ENABLE($1_plugin, + AC_HELP_STRING([--disable-$1-plugin], [Do not build $1 plugin]), + [enable_the_plugin=0], + [enable_the_plugin=1]) +if test "x$enable_the_plugin" = x1; then + AC_CONFIG_SUBDIRS($1-plugin) +fi +AM_CONDITIONAL(ENABLE_$1_PLUGIN, test "$enable_the_plugin" = "1") +]) + +AC_DEFUN([PLUGIN_DISABLED], [ AC_ARG_ENABLE($1_plugin, AC_HELP_STRING([--enable-$1-plugin], [Build $1 plugin]), @@ -42,7 +46,7 @@ AM_CONDITIONAL(ENABLE_$1_PLUGIN, test "$enable_the_plugin" = "1") ]) # To add a new plugin subdirectory: -# +# # add PLUGIN(new) below, and # add the following to Makefile.am: # @@ -50,10 +54,12 @@ AM_CONDITIONAL(ENABLE_$1_PLUGIN, test "$enable_the_plugin" = "1") # SUBDIRS += new-plugin # endif -PLUGIN(sample) -PLUGIN(sixrd) -PLUGIN(ioam) -PLUGIN(vcgn) -PLUGIN(snat) +PLUGIN_ENABLED(sixrd) +PLUGIN_ENABLED(ioam) +PLUGIN_ENABLED(snat) + +# Disabled plugins, require --enable-XXX-plugin +PLUGIN_DISABLED(vcgn) +PLUGIN_DISABLED(sample) AC_OUTPUT([Makefile]) diff --git a/plugins/ioam-plugin/Makefile.am b/plugins/ioam-plugin/Makefile.am index e62525f1..47ff1167 100644 --- a/plugins/ioam-plugin/Makefile.am +++ b/plugins/ioam-plugin/Makefile.am @@ -13,7 +13,8 @@ AUTOMAKE_OPTIONS = foreign subdir-objects -AM_CFLAGS = -Wall -I@TOOLKIT_INCLUDE@ +AM_CFLAGS = -Wall +AM_LDFLAGS = -module -shared -avoid-version ######################################## # iOAM Proof of Transit @@ -26,8 +27,6 @@ ioam_pot_plugin_la_SOURCES = \ ioam/lib-pot/math64.h \ ioam/lib-pot/pot_api.c -ioam_pot_plugin_la_LDFLAGS = -module - BUILT_SOURCES = \ ioam/lib-pot/pot.api.h @@ -38,7 +37,7 @@ SUFFIXES = .api.h .api $(CC) $(CPPFLAGS) -E -P -C -x c $^ \ | vppapigen --input - --output $@ --show-name $@ -nobase_include_HEADERS = \ +noinst_HEADERS = \ ioam/lib-pot/pot_all_api_h.h \ ioam/lib-pot/pot_msg_enum.h \ ioam/lib-pot/pot.api.h \ @@ -49,14 +48,14 @@ ioam_pot_test_plugin_la_SOURCES = \ ioam/lib-pot/pot_test.c \ ioam/lib-pot/pot_plugin.api.h -ioam_pot_test_plugin_la_LDFLAGS = -module +vppapitestpluginsdir = ${libdir}/vpp_api_test_plugins +vpppluginsdir = ${libdir}/vpp_plugins + +vppapitestplugins_LTLIBRARIES = ioam_pot_test_plugin.la +vppplugins_LTLIBRARIES = ioam_pot_plugin.la -lib_LTLIBRARIES = ioam_pot_plugin.la ioam_pot_test_plugin.la -if WITH_PLUGIN_TOOLKIT +# Remove *.la files install-data-hook: - mkdir /usr/lib/vpp_plugins || true - mkdir /usr/lib/vpp_api_test_plugins || true - cp -L $(prefix)/lib/ioam_pot_plugin.so /usr/lib/vpp_plugins - cp -L $(prefix)/lib/ioam_pot_test_plugin.so /usr/lib/vpp_api_test_plugins -endif + @(cd $(vpppluginsdir) && $(RM) $(vppplugins_LTLIBRARIES)) + @(cd $(vppapitestpluginsdir) && $(RM) $(vppapitestplugins_LTLIBRARIES)) diff --git a/plugins/ioam-plugin/configure.ac b/plugins/ioam-plugin/configure.ac index 8c828575..27fda734 100644 --- a/plugins/ioam-plugin/configure.ac +++ b/plugins/ioam-plugin/configure.ac @@ -1,17 +1,8 @@ AC_INIT(ioam_plugin, 1.0) LT_INIT AM_INIT_AUTOMAKE +AC_PREFIX_DEFAULT([/usr]) -AM_PROG_AS AC_PROG_CC -AM_PROG_CC_C_O -AC_ARG_WITH(plugin-toolkit, - AC_HELP_STRING([--with-plugin-toolkit], - [build using the vpp toolkit]), - [with_plugin_toolkit=${prefix}/include], - [with_plugin_toolkit=.]) - -AC_SUBST(TOOLKIT_INCLUDE,[${with_plugin_toolkit}]) -AM_CONDITIONAL(WITH_PLUGIN_TOOLKIT, test "$with_plugin_toolkit" != ".") AC_OUTPUT([Makefile]) diff --git a/plugins/sample-plugin/Makefile.am b/plugins/sample-plugin/Makefile.am index 30b17194..0b213791 100644 --- a/plugins/sample-plugin/Makefile.am +++ b/plugins/sample-plugin/Makefile.am @@ -13,12 +13,17 @@ AUTOMAKE_OPTIONS = foreign subdir-objects -AM_CFLAGS = -Wall -I@TOOLKIT_INCLUDE@ +AM_CFLAGS = -Wall +AM_LDFLAGS = -module -shared -avoid-version + +vppapitestpluginsdir = ${libdir}/vpp_api_test_plugins +vpppluginsdir = ${libdir}/vpp_plugins + +vppapitestplugins_LTLIBRARIES = sample_test_plugin.la +vppplugins_LTLIBRARIES = sample_plugin.la -lib_LTLIBRARIES = sample_plugin.la sample_test_plugin.la sample_plugin_la_SOURCES = sample/sample.c sample/node.c \ - sample/sample_plugin.api.h -sample_plugin_la_LDFLAGS = -module + sample/sample_plugin.api.h BUILT_SOURCES = sample/sample.api.h @@ -29,18 +34,14 @@ SUFFIXES = .api.h .api $(CC) $(CPPFLAGS) -E -P -C -x c $^ \ | vppapigen --input - --output $@ --show-name $@ -nobase_include_HEADERS = \ +noinst_HEADERS = \ sample/sample_all_api_h.h \ sample/sample_msg_enum.h \ sample/sample.api.h sample_test_plugin_la_SOURCES = sample/sample_test.c sample/sample_plugin.api.h -sample_test_plugin_la_LDFLAGS = -module -if WITH_PLUGIN_TOOLKIT +# Remove *.la files install-data-hook: - mkdir /usr/lib/vpp_plugins || true - mkdir /usr/lib/vpp_api_test_plugins || true - cp -L $(prefix)/lib/sample_plugin.so /usr/lib/vpp_plugins - cp -L $(prefix)/lib/sample_test_plugin.so /usr/lib/vpp_api_test_plugins -endif + @(cd $(vpppluginsdir) && $(RM) $(vppplugins_LTLIBRARIES)) + @(cd $(vppapitestpluginsdir) && $(RM) $(vppapitestplugins_LTLIBRARIES)) diff --git a/plugins/sample-plugin/configure.ac b/plugins/sample-plugin/configure.ac index a8257305..43642732 100644 --- a/plugins/sample-plugin/configure.ac +++ b/plugins/sample-plugin/configure.ac @@ -2,17 +2,8 @@ AC_INIT(sample_plugin, 1.0) LT_INIT AM_INIT_AUTOMAKE AM_SILENT_RULES([yes]) +AC_PREFIX_DEFAULT([/usr]) -AM_PROG_AS AC_PROG_CC -AM_PROG_CC_C_O -AC_ARG_WITH(plugin-toolkit, - AC_HELP_STRING([--with-plugin-toolkit], - [build using the vpp toolkit]), - [with_plugin_toolkit=${prefix}/include], - [with_plugin_toolkit=.]) - -AC_SUBST(TOOLKIT_INCLUDE,[${with_plugin_toolkit}]) -AM_CONDITIONAL(WITH_PLUGIN_TOOLKIT, test "$with_plugin_toolkit" != ".") AC_OUTPUT([Makefile]) diff --git a/plugins/sixrd-plugin/Makefile.am b/plugins/sixrd-plugin/Makefile.am index c2fae798..71c8da48 100644 --- a/plugins/sixrd-plugin/Makefile.am +++ b/plugins/sixrd-plugin/Makefile.am @@ -13,25 +13,24 @@ AUTOMAKE_OPTIONS = foreign subdir-objects -AM_CFLAGS = -Wall -I@TOOLKIT_INCLUDE@ +AM_CFLAGS = -Wall +AM_LDFLAGS = -module -shared -avoid-version libsixrd_plugin_la_SOURCES = \ sixrd/sixrd.c \ sixrd/ip4_sixrd.c \ sixrd/ip6_sixrd.c -nobase_include_HEADERS = \ +noinst_HEADERS = \ sixrd/sixrd.h -libsixrd_plugin_la_LDFLAGS = -module - BUILT_SOURCES = -lib_LTLIBRARIES = libsixrd_plugin.la +vpppluginsdir = ${libdir}/vpp_plugins + +vppplugins_LTLIBRARIES = libsixrd_plugin.la + -if WITH_PLUGIN_TOOLKIT +# Remove *.la files install-data-hook: - mkdir /usr/lib/vpp_plugins || true - mkdir /usr/lib/vpp_api_test_plugins || true - cp -L $(prefix)/lib/libsixrd_plugin.so /usr/lib/vpp_plugins -endif + @(cd $(vpppluginsdir) && $(RM) $(vppplugins_LTLIBRARIES)) diff --git a/plugins/sixrd-plugin/configure.ac b/plugins/sixrd-plugin/configure.ac index 1652c87f..3aa4c425 100644 --- a/plugins/sixrd-plugin/configure.ac +++ b/plugins/sixrd-plugin/configure.ac @@ -2,17 +2,8 @@ AC_INIT(sixrd_plugin, 1.0) LT_INIT AM_INIT_AUTOMAKE AM_SILENT_RULES([yes]) +AC_PREFIX_DEFAULT([/usr]) -AM_PROG_AS AC_PROG_CC -AM_PROG_CC_C_O -AC_ARG_WITH(plugin-toolkit, - AC_HELP_STRING([--with-plugin-toolkit], - [build using the vpp toolkit]), - [with_plugin_toolkit=${prefix}/include], - [with_plugin_toolkit=.]) - -AC_SUBST(TOOLKIT_INCLUDE,[${with_plugin_toolkit}]) -AM_CONDITIONAL(WITH_PLUGIN_TOOLKIT, test "$with_plugin_toolkit" != ".") AC_OUTPUT([Makefile]) diff --git a/plugins/snat-plugin/Makefile.am b/plugins/snat-plugin/Makefile.am index 11b0839a..0fe694cf 100644 --- a/plugins/snat-plugin/Makefile.am +++ b/plugins/snat-plugin/Makefile.am @@ -3,9 +3,9 @@ # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at: -# +# # http://www.apache.org/licenses/LICENSE-2.0 -# +# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -14,16 +14,19 @@ AUTOMAKE_OPTIONS = foreign subdir-objects -AM_CFLAGS = -Wall -I@TOOLKIT_INCLUDE@ @DPDK@ +AM_CFLAGS = -Wall @DPDK@ +AM_LDFLAGS = -module -shared -avoid-version -lib_LTLIBRARIES = snat_plugin.la snat_test_plugin.la +vppapitestpluginsdir = ${libdir}/vpp_api_test_plugins +vpppluginsdir = ${libdir}/vpp_plugins + +vppapitestplugins_LTLIBRARIES = snat_test_plugin.la +vppplugins_LTLIBRARIES = snat_plugin.la snat_plugin_la_SOURCES = snat/snat.c \ snat/in2out.c \ snat/out2in.c \ - snat/snat_plugin.api.h - -snat_plugin_la_LDFLAGS = -module + snat/snat_plugin.api.h BUILT_SOURCES = snat/snat.api.h @@ -34,22 +37,15 @@ SUFFIXES = .api.h .api $(CC) $(CPPFLAGS) -E -P -C -x c $^ \ | vppapigen --input - --output $@ --show-name $@ -nobase_include_HEADERS = \ +noinst_HEADERS = \ snat/snat_all_api_h.h \ snat/snat_msg_enum.h \ snat/snat.api.h snat_test_plugin_la_SOURCES = \ snat/snat_test.c snat/snat_plugin.api.h -snat_test_plugin_la_LDFLAGS = -module -if WITH_PLUGIN_TOOLKIT +# Remove *.la files install-data-hook: - mkdir /usr/lib/vpp_plugins || true - mkdir /usr/lib/vpp_api_test_plugins || true - cp -L $(prefix)/lib/snat_plugin.so /usr/lib/vpp_plugins - cp -L $(prefix)/lib/snat_test_plugin.so \ - /usr/lib/vpp_api_test_plugins - rm -f $(prefix)/lib/snat_plugin.* - rm -f $(prefix)/lib/snat_test_plugin.* -endif + @(cd $(vpppluginsdir) && $(RM) $(vppplugins_LTLIBRARIES)) + @(cd $(vppapitestpluginsdir) && $(RM) $(vppapitestplugins_LTLIBRARIES)) diff --git a/plugins/snat-plugin/configure.ac b/plugins/snat-plugin/configure.ac index e10b18ac..9af139e4 100644 --- a/plugins/snat-plugin/configure.ac +++ b/plugins/snat-plugin/configure.ac @@ -1,11 +1,10 @@ AC_INIT(snat_plugin, 1.0) AM_INIT_AUTOMAKE AM_SILENT_RULES([yes]) +AC_PREFIX_DEFAULT([/usr]) AC_PROG_LIBTOOL -AM_PROG_AS AC_PROG_CC -AM_PROG_CC_C_O AC_ARG_WITH(dpdk, AC_HELP_STRING([--with-dpdk],[Use the Intel dpdk]), @@ -15,13 +14,4 @@ AC_ARG_WITH(dpdk, AM_CONDITIONAL(WITH_DPDK, test "$with_dpdk" = "1") AC_SUBST(DPDK,["-DDPDK=${with_dpdk}"]) -AC_ARG_WITH(plugin-toolkit, - AC_HELP_STRING([--with-plugin-toolkit], - [build using the vpp toolkit]), - [with_plugin_toolkit=${prefix}/include], - [with_plugin_toolkit=.]) - -AC_SUBST(TOOLKIT_INCLUDE,[${with_plugin_toolkit}]) -AM_CONDITIONAL(WITH_PLUGIN_TOOLKIT, test "$with_plugin_toolkit" != ".") - AC_OUTPUT([Makefile]) diff --git a/plugins/vcgn-plugin/Makefile.am b/plugins/vcgn-plugin/Makefile.am index f9705d05..927f35b6 100644 --- a/plugins/vcgn-plugin/Makefile.am +++ b/plugins/vcgn-plugin/Makefile.am @@ -13,7 +13,8 @@ AUTOMAKE_OPTIONS = foreign subdir-objects -AM_CFLAGS = -Wall -I@TOOLKIT_INCLUDE@ +AM_CFLAGS = -Wall +AM_LDFLAGS = -module -shared -avoid-version ######################################## # Virtual Carrier Grade NAT @@ -87,13 +88,10 @@ nobase_include_HEADERS = \ vcgn/tcp_header_definitions.h \ vcgn/vcgn_db.h -libvcgn_plugin_la_LDFLAGS = -module +vpppluginsdir = ${libdir}/vpp_plugins -lib_LTLIBRARIES = libvcgn_plugin.la +vppplugins_LTLIBRARIES = libvcgn_plugin.la -if WITH_PLUGIN_TOOLKIT +# Remove *.la files install-data-hook: - mkdir /usr/lib/vpp_plugins || true - mkdir /usr/lib/vpp_api_test_plugins || true - cp -L $(prefix)/lib/libvcgn_plugin.so /usr/lib/vpp_plugins -endif + @(cd $(vpppluginsdir) && $(RM) $(vppplugins_LTLIBRARIES)) diff --git a/plugins/vcgn-plugin/configure.ac b/plugins/vcgn-plugin/configure.ac index 5bc8bd9d..f9c365af 100644 --- a/plugins/vcgn-plugin/configure.ac +++ b/plugins/vcgn-plugin/configure.ac @@ -2,17 +2,8 @@ AC_INIT(vcgn_plugin, 1.0) LT_INIT AM_INIT_AUTOMAKE AM_SILENT_RULES([yes]) +AC_PREFIX_DEFAULT([/usr]) -AM_PROG_AS AC_PROG_CC -AM_PROG_CC_C_O -AC_ARG_WITH(plugin-toolkit, - AC_HELP_STRING([--with-plugin-toolkit], - [build using the vpp toolkit]), - [with_plugin_toolkit=${prefix}/include], - [with_plugin_toolkit=.]) - -AC_SUBST(TOOLKIT_INCLUDE,[${with_plugin_toolkit}]) -AM_CONDITIONAL(WITH_PLUGIN_TOOLKIT, test "$with_plugin_toolkit" != ".") AC_OUTPUT([Makefile]) -- cgit 1.2.3-korg From ad476c7861d0428766f9bee01f69cd00025a47c0 Mon Sep 17 00:00:00 2001 From: Damjan Marion Date: Wed, 13 Jul 2016 13:42:33 +0200 Subject: Add plugins debian packaging New debian package "vpp-plugins" is created with enabled plugins. Change-Id: I8920178e8874f12e075858001ec44257dfaf497d Signed-off-by: Damjan Marion --- build-data/platforms.mk | 5 +++++ build-data/platforms/vpp.mk | 2 +- build-root/deb/debian/control | 7 +++++++ build-root/scripts/find-plugins-contents | 11 +++++++++++ 4 files changed, 24 insertions(+), 1 deletion(-) create mode 100755 build-root/scripts/find-plugins-contents (limited to 'build-data/platforms/vpp.mk') diff --git a/build-data/platforms.mk b/build-data/platforms.mk index 625006b4..65809ea6 100644 --- a/build-data/platforms.mk +++ b/build-data/platforms.mk @@ -31,6 +31,7 @@ install-deb: $(patsubst %,%-find-source,$(ROOT_PACKAGES)) : need symbolic links in the lib pkg ; \ find $(INSTALL_PREFIX)$(ARCH)/*/lib* \( -type f -o -type l \) \ -print | egrep -e '*\.so\.*\.*\.*' \ + | grep -v plugins\/ \ | sed -e 's:.*:../& /usr/lib/x86_64-linux-gnu:' \ > deb/debian/vpp-lib.install ; \ \ @@ -38,6 +39,10 @@ install-deb: $(patsubst %,%-find-source,$(ROOT_PACKAGES)) ./scripts/find-dev-contents $(INSTALL_PREFIX)$(ARCH) \ deb/debian/vpp-dev.install ; \ \ + : plugins package ; \ + ./scripts/find-plugins-contents $(INSTALL_PREFIX)$(ARCH) \ + deb/debian/vpp-plugins.install ; \ + \ : dpdk headers ; \ ./scripts/find-dpdk-contents $(INSTALL_PREFIX)$(ARCH) \ deb/debian/vpp-dpdk-dev.install ; \ diff --git a/build-data/platforms/vpp.mk b/build-data/platforms/vpp.mk index fb1867c7..977c4c32 100644 --- a/build-data/platforms/vpp.mk +++ b/build-data/platforms/vpp.mk @@ -30,7 +30,7 @@ vpp_uses_dpdk = yes # vpp_enable_tests = yes vpp_root_packages = vpp vlib vlib-api vnet svm vpp-api-test \ - vpp-api gmod + vpp-api gmod plugins vpp_configure_args_vpp = --with-dpdk vnet_configure_args_vpp = --with-dpdk diff --git a/build-root/deb/debian/control b/build-root/deb/debian/control index 97464e42..d1e7680e 100644 --- a/build-root/deb/debian/control +++ b/build-root/deb/debian/control @@ -47,6 +47,13 @@ Description: Vector Packet Processing--runtime libraries vlib-api - binary API library vnet - network stack library +Package: vpp-plugins +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends} +Description: Vector Packet Processing--runtime plugins + This package contains VPP plugins + . + Package: vpp-dpdk-dkms Architecture: any Depends: ${shlibs:Depends}, ${misc:Depends} diff --git a/build-root/scripts/find-plugins-contents b/build-root/scripts/find-plugins-contents new file mode 100755 index 00000000..8d1a4d5a --- /dev/null +++ b/build-root/scripts/find-plugins-contents @@ -0,0 +1,11 @@ +#!/bin/bash + +rm -f $2 + +for i in ${1}/plugins/lib64/vpp_plugins/*.so; do + echo ../${i} /usr/lib/vpp_plugins >> ${2} +done + +for i in ${1}/plugins/lib64/vpp_api_test_plugins/*.so; do + echo ../${i} /usr/lib/vpp_api_test_plugins >> ${2} +done -- cgit 1.2.3-korg From e30872e6606b4ce6fe1d6ff44be69e590427e45f Mon Sep 17 00:00:00 2001 From: Damjan Marion Date: Sat, 12 Nov 2016 01:23:55 +0100 Subject: Add clang to 'make verify' Change-Id: I9ba84632da93ffb7713064db51f2888fc212713a Signed-off-by: Damjan Marion --- Makefile | 18 ++++++++++++++++++ build-data/platforms/vpp.mk | 5 +++++ 2 files changed, 23 insertions(+) (limited to 'build-data/platforms/vpp.mk') diff --git a/Makefile b/Makefile index 5d20bd23..41a45c88 100644 --- a/Makefile +++ b/Makefile @@ -329,6 +329,24 @@ doxygen: wipe-doxygen: $(call make-doxy) +define banner + @echo "========================================================================" + @echo " $(1)" + @echo "========================================================================" + @echo " " +endef + verify: $(BR)/.bootstrap.ok +ifeq ($(OS_ID),ubuntu) +ifeq ($(OS_VERSION_ID),16.04) + $(call banner,"Installing dependencies") + @sudo -E apt-get update + @sudo -E apt-get $(CONFIRM) $(FORCE) install clang + $(call banner,"Building for PLATFORM=vpp using clang") + @make -C build-root CC=clang PLATFORM=vpp TAG=vpp_clang wipe-all install-packages +endif +endif + $(call banner,"Building for PLATFORM=vpp using gcc") @make -C build-root PLATFORM=vpp TAG=vpp wipe-all install-packages + $(call banner,"Building for PLATFORM=vpp_lite using gcc") @make -C build-root PLATFORM=vpp_lite TAG=vpp_lite wipe-all install-packages diff --git a/build-data/platforms/vpp.mk b/build-data/platforms/vpp.mk index 977c4c32..4fe7cc8f 100644 --- a/build-data/platforms/vpp.mk +++ b/build-data/platforms/vpp.mk @@ -56,6 +56,11 @@ vpp_TAG_CFLAGS = -g -O2 -DFORTIFY_SOURCE=2 -march=$(MARCH) -mtune=$(MTUNE) \ vpp_TAG_LDFLAGS = -g -O2 -DFORTIFY_SOURCE=2 -march=$(MARCH) -mtune=$(MTUNE) \ -fstack-protector -fPIC -Werror +vpp_clang_TAG_CFLAGS = -g -O2 -DFORTIFY_SOURCE=2 -march=$(MARCH) -mtune=$(MTUNE) \ + -fstack-protector -fPIC -Werror +vpp_clang_TAG_LDFLAGS = -g -O2 -DFORTIFY_SOURCE=2 -march=$(MARCH) -mtune=$(MTUNE) \ + -fstack-protector -fPIC -Werror + vpp_gcov_TAG_CFLAGS = -g -O0 -DCLIB_DEBUG -march=$(MARCH) \ -fPIC -Werror -fprofile-arcs -ftest-coverage vpp_gcov_TAG_LDFLAGS = -g -O0 -DCLIB_DEBUG -march=$(MARCH) \ -- cgit 1.2.3-korg From a10f62b11e7a710fde628ae75fe5791e54caba0a Mon Sep 17 00:00:00 2001 From: Sergio Gonzalez Monroy Date: Fri, 25 Nov 2016 13:36:12 +0000 Subject: dpdk: add ipsec cryptodev support DPDK Cryptodev support and related IPsec ESP nodes using DPDK Cryptodev APIs. When DPDK Cryptodev support is enabled, the node graph is modified by adding and replacing some of the nodes. The following nodes are replaced: * esp-encrypt -> dpdk-esp-encrypt * esp-decrypt -> dpdk-esp-decrypt The following nodes are added: * dpdk-crypto-input : polling input node * dpdk-esp-encrypt-post : internal node * dpdk-esp-decrypt-post : internal node Change-Id: I6dca9a890abaf4fb2a4fffce3fd08ac013e4d701 Signed-off-by: Zhang, Roy Fan Signed-off-by: Sergio Gonzalez Monroy --- build-data/packages/dpdk.mk | 4 + build-data/packages/vnet.mk | 3 + build-data/packages/vpp.mk | 3 + build-data/platforms/vpp.mk | 1 + doxygen/user_doc.md | 1 + dpdk/Makefile | 4 + vnet/Makefile.am | 17 +- vnet/configure.ac | 8 + vnet/vnet/devices/dpdk/ipsec/cli.c | 141 ++++++ vnet/vnet/devices/dpdk/ipsec/crypto_node.c | 209 ++++++++ vnet/vnet/devices/dpdk/ipsec/dir.dox | 18 + .../devices/dpdk/ipsec/dpdk_crypto_ipsec_doc.md | 73 +++ vnet/vnet/devices/dpdk/ipsec/esp.h | 268 ++++++++++ vnet/vnet/devices/dpdk/ipsec/esp_decrypt.c | 549 ++++++++++++++++++++ vnet/vnet/devices/dpdk/ipsec/esp_encrypt.c | 554 +++++++++++++++++++++ vnet/vnet/devices/dpdk/ipsec/ipsec.c | 313 ++++++++++++ vnet/vnet/devices/dpdk/ipsec/ipsec.h | 216 ++++++++ vnet/vnet/ipsec-gre/interface.c | 9 +- vnet/vnet/ipsec/esp.h | 151 ++++++ vnet/vnet/ipsec/esp_decrypt.c | 121 ----- vnet/vnet/ipsec/esp_encrypt.c | 25 - vnet/vnet/ipsec/ipsec.c | 31 +- vnet/vnet/ipsec/ipsec.h | 5 + vnet/vnet/ipsec/ipsec_cli.c | 1 - vnet/vnet/ipsec/ipsec_if.c | 39 ++ vnet/vnet/ipsec/ipsec_if_in.c | 10 +- vnet/vnet/ipsec/ipsec_if_out.c | 7 +- vnet/vnet/ipsec/ipsec_input.c | 8 +- vnet/vnet/ipsec/ipsec_output.c | 8 +- vpp/Makefile.am | 5 +- vpp/configure.ac | 8 + 31 files changed, 2651 insertions(+), 159 deletions(-) create mode 100644 vnet/vnet/devices/dpdk/ipsec/cli.c create mode 100644 vnet/vnet/devices/dpdk/ipsec/crypto_node.c create mode 100644 vnet/vnet/devices/dpdk/ipsec/dir.dox create mode 100644 vnet/vnet/devices/dpdk/ipsec/dpdk_crypto_ipsec_doc.md create mode 100644 vnet/vnet/devices/dpdk/ipsec/esp.h create mode 100644 vnet/vnet/devices/dpdk/ipsec/esp_decrypt.c create mode 100644 vnet/vnet/devices/dpdk/ipsec/esp_encrypt.c create mode 100644 vnet/vnet/devices/dpdk/ipsec/ipsec.c create mode 100644 vnet/vnet/devices/dpdk/ipsec/ipsec.h (limited to 'build-data/platforms/vpp.mk') diff --git a/build-data/packages/dpdk.mk b/build-data/packages/dpdk.mk index f9163c87..a529e365 100644 --- a/build-data/packages/dpdk.mk +++ b/build-data/packages/dpdk.mk @@ -22,6 +22,10 @@ DPDK_MAKE_ARGS = -C $(call find_source_fn,$(PACKAGE_SOURCE)) \ DPDK_TUNE=$(DPDK_TUNE) \ DPDK_DEBUG=$(DPDK_DEBUG) +DPDK_CRYPTO_PMD=$(strip $($(PLATFORM)_uses_dpdk_cryptodev)) +ifneq ($(DPDK_CRYPTO_PMD),) +DPDK_MAKE_ARGS += DPDK_CRYPTO_PMD=y +endif DPDK_PLATFORM_TARGET=$(strip $($(PLATFORM)_dpdk_target)) ifneq ($(DPDK_PLATFORM_TARGET),) diff --git a/build-data/packages/vnet.mk b/build-data/packages/vnet.mk index cafb9393..399ca1b4 100644 --- a/build-data/packages/vnet.mk +++ b/build-data/packages/vnet.mk @@ -38,4 +38,7 @@ vnet_configure_depend += dpdk-install vnet_CPPFLAGS += $(call installed_includes_fn, dpdk) vnet_LDFLAGS += $(call installed_libs_fn, dpdk) endif +ifeq ($($(PLATFORM)_uses_dpdk_cryptodev),yes) +vnet_configure_args += --with-dpdk-crypto +endif endif diff --git a/build-data/packages/vpp.mk b/build-data/packages/vpp.mk index be10e17d..6831c6b8 100644 --- a/build-data/packages/vpp.mk +++ b/build-data/packages/vpp.mk @@ -45,4 +45,7 @@ vpp_configure_depend += dpdk-install vpp_CPPFLAGS += $(call installed_includes_fn, dpdk) vpp_LDFLAGS += $(call installed_libs_fn, dpdk) endif +ifeq ($($(PLATFORM)_uses_dpdk_cryptodev),yes) +vpp_configure_args += --with-dpdk-crypto +endif endif diff --git a/build-data/platforms/vpp.mk b/build-data/platforms/vpp.mk index 4fe7cc8f..15d4dc39 100644 --- a/build-data/platforms/vpp.mk +++ b/build-data/platforms/vpp.mk @@ -41,6 +41,7 @@ vlib_configure_args_vpp = --with-pre-data=128 plugins_configure_args_vpp = --with-dpdk # DPDK configuration parameters +# vpp_uses_dpdk_cryptodev = yes # vpp_uses_external_dpdk = yes # vpp_dpdk_inc_dir = /usr/include/dpdk # vpp_dpdk_lib_dir = /usr/lib diff --git a/doxygen/user_doc.md b/doxygen/user_doc.md index 59063764..2e87c877 100644 --- a/doxygen/user_doc.md +++ b/doxygen/user_doc.md @@ -6,6 +6,7 @@ Several modules provide operational, dataplane-user focused documentation. - [GUI guided user demo](https://wiki.fd.io/view/VPP_Sandbox/vpp-userdemo) - @subpage qos_doc - @subpage ipsec_gre_doc +- @subpage dpdk_crypto_ipsec_doc - @subpage map_doc - @subpage lldp_doc - @subpage ioam_plugin_doc diff --git a/dpdk/Makefile b/dpdk/Makefile index 2f5037df..46cc3db1 100644 --- a/dpdk/Makefile +++ b/dpdk/Makefile @@ -21,6 +21,7 @@ DPDK_DOWNLOAD_DIR ?= $(HOME)/Downloads DPDK_MARCH ?= native DPDK_TUNE ?= generic DPDK_DEBUG ?= n +DPDK_CRYPTO_PMD ?= n B := $(DPDK_BUILD_DIR) I := $(DPDK_INSTALL_DIR) @@ -118,6 +119,9 @@ $(B)/custom-config: $(B)/.patch.ok Makefile $(call set,RTE_LIBRTE_VMXNET3_DEBUG_INIT,$(DPDK_DEBUG)) $(call set,RTE_LIBRTE_PMD_BOND,y) $(call set,RTE_LIBRTE_IP_FRAG,y) + $(call set,RTE_LIBRTE_PMD_AESNI_MB,$(DPDK_CRYPTO_PMD)) + $(call set,RTE_LIBRTE_PMD_AESNI_GCM,$(DPDK_CRYPTO_PMD)) + $(call set,RTE_LIBRTE_PMD_QAT,$(DPDK_CRYPTO_PMD)) @# not needed $(call set,RTE_LIBRTE_TIMER,n) $(call set,RTE_LIBRTE_CFGFILE,n) diff --git a/vnet/Makefile.am b/vnet/Makefile.am index 86b73906..d806785f 100644 --- a/vnet/Makefile.am +++ b/vnet/Makefile.am @@ -13,7 +13,7 @@ AUTOMAKE_OPTIONS = foreign subdir-objects -AM_CFLAGS = -Wall -Werror @DPDK@ @IPSEC@ @IPV6SR@ +AM_CFLAGS = -Wall -Werror @DPDK@ @DPDK_CRYPTO@ @IPSEC@ @IPV6SR@ libvnet_la_SOURCES = libvnetplugin_la_SOURCES = @@ -345,7 +345,15 @@ libvnet_la_SOURCES += \ vnet/ipsec/ikev2_cli.c \ vnet/ipsec/ikev2_payload.c \ vnet/ipsec/ikev2_format.c -endif +if WITH_DPDK_CRYPTO +libvnet_la_SOURCES += \ + vnet/devices/dpdk/ipsec/esp_encrypt.c \ + vnet/devices/dpdk/ipsec/esp_decrypt.c \ + vnet/devices/dpdk/ipsec/crypto_node.c \ + vnet/devices/dpdk/ipsec/cli.c \ + vnet/devices/dpdk/ipsec/ipsec.c +endif +endif libvnet_la_SOURCES += \ vnet/ipsec/ipsec_output.c @@ -355,6 +363,11 @@ nobase_include_HEADERS += \ vnet/ipsec/esp.h \ vnet/ipsec/ikev2.h \ vnet/ipsec/ikev2_priv.h +if WITH_DPDK_CRYPTO +nobase_include_HEADERS += \ + vnet/devices/dpdk/ipsec/ipsec.h \ + vnet/devices/dpdk/ipsec/esp.h +endif ######################################## # Layer 3 protocol: osi diff --git a/vnet/configure.ac b/vnet/configure.ac index 80de43af..6a5281b0 100644 --- a/vnet/configure.ac +++ b/vnet/configure.ac @@ -12,6 +12,11 @@ AC_ARG_WITH(dpdk, [with_dpdk=1], [with_dpdk=0]) +AC_ARG_WITH(dpdk_crypto, + AC_HELP_STRING([--with-dpdk-crypto],[Use DPDK cryptodev]), + [with_dpdk_crypto=1], + [with_dpdk_crypto=0]) + AC_ARG_WITH(ipsec, AC_HELP_STRING([--without-ipsec],[Disable ipsec]), [with_ipsec=0], @@ -27,6 +32,9 @@ AC_ARG_ENABLE(tests, [enable_tests=1], [enable_tests=0]) +AM_CONDITIONAL(WITH_DPDK_CRYPTO, test "$with_dpdk_crypto" = "1") +AC_SUBST(DPDK_CRYPTO,[-DDPDK_CRYPTO=${with_dpdk_crypto}]) + AM_CONDITIONAL(WITH_DPDK, test "$with_dpdk" = "1") AC_SUBST(DPDK,[-DDPDK=${with_dpdk}]) diff --git a/vnet/vnet/devices/dpdk/ipsec/cli.c b/vnet/vnet/devices/dpdk/ipsec/cli.c new file mode 100644 index 00000000..3b634e03 --- /dev/null +++ b/vnet/vnet/devices/dpdk/ipsec/cli.c @@ -0,0 +1,141 @@ +/* + * Copyright (c) 2016 Intel and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include + +static void +dpdk_ipsec_show_mapping (vlib_main_t * vm, u16 detail_display) +{ + dpdk_crypto_main_t *dcm = &dpdk_crypto_main; + vlib_thread_main_t *tm = vlib_get_thread_main (); + u32 i, skip_master; + + if (detail_display) + vlib_cli_output (vm, "worker\t%10s\t%15s\tdir\tdev\tqp\n", + "cipher", "auth"); + else + vlib_cli_output (vm, "worker\tcrypto device id(type)\n"); + + skip_master = vlib_num_workers () > 0; + + for (i = 0; i < tm->n_vlib_mains; i++) + { + uword key, data; + u32 cpu_index = vlib_mains[i]->cpu_index; + crypto_worker_main_t *cwm = &dcm->workers_main[cpu_index]; + u8 *s = 0; + + if (skip_master) + { + skip_master = 0; + continue; + } + + if (!detail_display) + { + i32 last_cdev = -1; + crypto_qp_data_t *qpd; + + s = format (s, "%u\t", cpu_index); + + /* *INDENT-OFF* */ + vec_foreach (qpd, cwm->qp_data) + { + u32 dev_id = qpd->dev_id; + + if ((u16) last_cdev != dev_id) + { + struct rte_cryptodev_info cdev_info; + + rte_cryptodev_info_get (dev_id, &cdev_info); + + s = format(s, "%u(%s)\t", dev_id, cdev_info.feature_flags & + RTE_CRYPTODEV_FF_HW_ACCELERATED ? "HW" : "SW"); + } + last_cdev = dev_id; + } + /* *INDENT-ON* */ + vlib_cli_output (vm, "%s", s); + } + else + { + char cipher_str[15], auth_str[15]; + struct rte_cryptodev_capabilities cap; + crypto_worker_qp_key_t *p_key = (crypto_worker_qp_key_t *) & key; + /* *INDENT-OFF* */ + hash_foreach (key, data, cwm->algo_qp_map, + ({ + cap.op = RTE_CRYPTO_OP_TYPE_SYMMETRIC; + cap.sym.xform_type = RTE_CRYPTO_SYM_XFORM_CIPHER; + cap.sym.cipher.algo = p_key->cipher_algo; + check_algo_is_supported (&cap, cipher_str); + cap.op = RTE_CRYPTO_OP_TYPE_SYMMETRIC; + cap.sym.xform_type = RTE_CRYPTO_SYM_XFORM_AUTH; + cap.sym.auth.algo = p_key->auth_algo; + check_algo_is_supported (&cap, auth_str); + vlib_cli_output (vm, "%u\t%10s\t%15s\t%3s\t%u\t%u\n", + vlib_mains[i]->cpu_index, cipher_str, auth_str, + p_key->is_outbound ? "out" : "in", + cwm->qp_data[data].dev_id, + cwm->qp_data[data].qp_id); + })); + /* *INDENT-ON* */ + } + } +} + +static clib_error_t * +lcore_cryptodev_map_fn (vlib_main_t * vm, unformat_input_t * input, + vlib_cli_command_t * cmd) +{ + unformat_input_t _line_input, *line_input = &_line_input; + u16 detail = 0; + + if (!unformat_user (input, unformat_line_input, line_input)) + return 0; + + while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) + { + if (unformat (line_input, "verbose")) + detail = 1; + else + return clib_error_return (0, "parse error: '%U'", + format_unformat_error, line_input); + } + + unformat_free (line_input); + + dpdk_ipsec_show_mapping (vm, detail); + + return 0; +} + +/* *INDENT-OFF* */ +VLIB_CLI_COMMAND (lcore_cryptodev_map, static) = { + .path = "show crypto device mapping", + .short_help = + "show cryptodev device mapping ", + .function = lcore_cryptodev_map_fn, +}; +/* *INDENT-ON* */ + +/* + * fd.io coding-style-patch-verification: ON + * + * Local Variables: + * eval: (c-set-style "gnu") + * End: + */ diff --git a/vnet/vnet/devices/dpdk/ipsec/crypto_node.c b/vnet/vnet/devices/dpdk/ipsec/crypto_node.c new file mode 100644 index 00000000..37d5e5fa --- /dev/null +++ b/vnet/vnet/devices/dpdk/ipsec/crypto_node.c @@ -0,0 +1,209 @@ +/* + *------------------------------------------------------------------ + * crypto_node.c - DPDK Cryptodev input node + * + * Copyright (c) 2016 Intel and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------ + */ + +#include +#include +#include +#include + +#include + +#define foreach_dpdk_crypto_input_next \ + _(DROP, "error-drop") \ + _(ENCRYPT_POST, "dpdk-esp-encrypt-post") \ + _(DECRYPT_POST, "dpdk-esp-decrypt-post") + +typedef enum +{ +#define _(f,s) DPDK_CRYPTO_INPUT_NEXT_##f, + foreach_dpdk_crypto_input_next +#undef _ + DPDK_CRYPTO_INPUT_N_NEXT, +} dpdk_crypto_input_next_t; + +#define foreach_dpdk_crypto_input_error \ + _(DQ_COPS, "Crypto ops dequeued") \ + _(COP_FAILED, "Crypto op failed") + +typedef enum +{ +#define _(f,s) DPDK_CRYPTO_INPUT_ERROR_##f, + foreach_dpdk_crypto_input_error +#undef _ + DPDK_CRYPTO_INPUT_N_ERROR, +} dpdk_crypto_input_error_t; + +static char *dpdk_crypto_input_error_strings[] = { +#define _(n, s) s, + foreach_dpdk_crypto_input_error +#undef _ +}; + +vlib_node_registration_t dpdk_crypto_input_node; + +typedef struct +{ + u32 cdev; + u32 qp; + u32 status; + u32 sa_idx; + u32 next_index; +} dpdk_crypto_input_trace_t; + +static u8 * +format_dpdk_crypto_input_trace (u8 * s, va_list * args) +{ + CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *); + CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *); + dpdk_crypto_input_trace_t *t = va_arg (*args, dpdk_crypto_input_trace_t *); + + s = format (s, "dpdk_crypto: cryptodev-id %u queue-pair %u next-index %d", + t->cdev, t->qp, t->next_index); + + s = format (s, "status %u sa-idx %u\n", t->status, t->sa_idx); + + return s; +} + +static_always_inline u32 +dpdk_crypto_dequeue (vlib_main_t * vm, vlib_node_runtime_t * node, + crypto_qp_data_t * qpd) +{ + u32 n_deq, *to_next = 0, next_index, n_cops, def_next_index; + struct rte_crypto_op **cops = qpd->cops; + + if (qpd->inflights == 0) + return 0; + + if (qpd->is_outbound) + def_next_index = DPDK_CRYPTO_INPUT_NEXT_ENCRYPT_POST; + else + def_next_index = DPDK_CRYPTO_INPUT_NEXT_DECRYPT_POST; + + n_cops = rte_cryptodev_dequeue_burst (qpd->dev_id, qpd->qp_id, + cops, VLIB_FRAME_SIZE); + n_deq = n_cops; + next_index = def_next_index; + + qpd->inflights -= n_cops; + ASSERT (qpd->inflights >= 0); + + while (n_cops > 0) + { + u32 n_left_to_next; + + vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next); + + while (n_cops > 0 && n_left_to_next > 0) + { + u32 bi0, next0; + vlib_buffer_t *b0 = 0; + struct rte_crypto_op *cop; + struct rte_crypto_sym_op *sym_cop; + + cop = cops[0]; + cops += 1; + n_cops -= 1; + n_left_to_next -= 1; + + next0 = def_next_index; + + if (PREDICT_FALSE (cop->status != RTE_CRYPTO_OP_STATUS_SUCCESS)) + { + next0 = DPDK_CRYPTO_INPUT_NEXT_DROP; + vlib_node_increment_counter (vm, dpdk_crypto_input_node.index, + DPDK_CRYPTO_INPUT_ERROR_COP_FAILED, + 1); + } + cop->status = RTE_CRYPTO_OP_STATUS_NOT_PROCESSED; + + sym_cop = (struct rte_crypto_sym_op *) (cop + 1); + b0 = vlib_buffer_from_rte_mbuf (sym_cop->m_src); + bi0 = vlib_get_buffer_index (vm, b0); + + to_next[0] = bi0; + to_next += 1; + + if (PREDICT_FALSE (b0->flags & VLIB_BUFFER_IS_TRACED)) + { + dpdk_crypto_input_trace_t *tr; + tr = vlib_add_trace (vm, node, b0, sizeof (*tr)); + tr->cdev = qpd->dev_id; + tr->qp = qpd->qp_id; + tr->status = cop->status; + tr->next_index = next0; + tr->sa_idx = vnet_buffer (b0)->ipsec.sad_index; + } + + vlib_validate_buffer_enqueue_x1 (vm, node, next_index, to_next, + n_left_to_next, bi0, next0); + } + vlib_put_next_frame (vm, node, next_index, n_left_to_next); + } + + crypto_free_cop (qpd, qpd->cops, n_deq); + + vlib_node_increment_counter (vm, dpdk_crypto_input_node.index, + DPDK_CRYPTO_INPUT_ERROR_DQ_COPS, n_deq); + return n_deq; +} + +static uword +dpdk_crypto_input_fn (vlib_main_t * vm, vlib_node_runtime_t * node, + vlib_frame_t * frame) +{ + u32 cpu_index = os_get_cpu_number (); + dpdk_crypto_main_t *dcm = &dpdk_crypto_main; + crypto_worker_main_t *cwm = &dcm->workers_main[cpu_index]; + crypto_qp_data_t *qpd; + u32 n_deq = 0; + + /* *INDENT-OFF* */ + vec_foreach (qpd, cwm->qp_data) + n_deq += dpdk_crypto_dequeue(vm, node, qpd); + /* *INDENT-ON* */ + + return n_deq; +} + +VLIB_REGISTER_NODE (dpdk_crypto_input_node) = +{ + .function = dpdk_crypto_input_fn,.name = "dpdk-crypto-input",.format_trace = + format_dpdk_crypto_input_trace,.type = VLIB_NODE_TYPE_INPUT,.state = + VLIB_NODE_STATE_DISABLED,.n_errors = + DPDK_CRYPTO_INPUT_N_ERROR,.error_strings = + dpdk_crypto_input_error_strings,.n_next_nodes = + DPDK_CRYPTO_INPUT_N_NEXT,.next_nodes = + { +#define _(s,n) [DPDK_CRYPTO_INPUT_NEXT_##s] = n, + foreach_dpdk_crypto_input_next +#undef _ + } +,}; + +#if DPDK_CRYPTO==1 +VLIB_NODE_FUNCTION_MULTIARCH (dpdk_crypto_input_node, dpdk_crypto_input_fn) +#endif +/* + * fd.io coding-style-patch-verification: ON + * + * Local Variables: + * eval: (c-set-style "gnu") + * End: + */ diff --git a/vnet/vnet/devices/dpdk/ipsec/dir.dox b/vnet/vnet/devices/dpdk/ipsec/dir.dox new file mode 100644 index 00000000..ffebfc4d --- /dev/null +++ b/vnet/vnet/devices/dpdk/ipsec/dir.dox @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2016 Intel and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + @dir vnet/vnet/devices/dpdk/ipsec + @brief IPSec ESP encrypt/decrypt using DPDK Cryptodev API +*/ diff --git a/vnet/vnet/devices/dpdk/ipsec/dpdk_crypto_ipsec_doc.md b/vnet/vnet/devices/dpdk/ipsec/dpdk_crypto_ipsec_doc.md new file mode 100644 index 00000000..8089696f --- /dev/null +++ b/vnet/vnet/devices/dpdk/ipsec/dpdk_crypto_ipsec_doc.md @@ -0,0 +1,73 @@ +# VPP IPSec implementation using DPDK Cryptodev API {#dpdk_crypto_ipsec_doc} + +This document is meant to contain all related information about implementation and usability. + + +## VPP IPsec with DPDK Cryptodev + +DPDK Cryptodev is an asynchronous crypto API that supports both Hardware and Software implementations (for more details refer to [DPDK Cryptography Device Library documentation](http://dpdk.org/doc/guides/prog_guide/cryptodev_lib.html)). + +When DPDK Cryptodev support is enabled, the node graph is modified by adding and replacing some of the nodes. + +The following nodes are replaced: +* esp-encrypt -> dpdk-esp-encrypt +* esp-decrypt -> dpdk-esp-decrypt + +The following nodes are added: +* dpdk-crypto-input : polling input node, basically dequeuing from crypto devices. +* dpdk-esp-encrypt-post : internal node. +* dpdk-esp-decrypt-post : internal node. + + +### How to enable VPP IPSec with DPDK Cryptodev support + +To enable DPDK Cryptodev support (disabled by default), we need the following env option: + + vpp_uses_dpdk_cryptodev=yes + +A couple of ways to achive this: +* uncomment/add it in the platforms config (ie. build-data/platforms/vpp.mk) +* set the option when building vpp (ie. make vpp_uses_dpdk_cryptodev=yes build-release) + + +### Crypto Resources allocation + +VPP allocates crypto resources based on a best effort approach: +* first allocate Hardware crypto resources, then Software. +* if there are not enough crypto resources for all workers, all packets will be dropped if they reach ESP encrypt/decrypt nodes, displaying the warning: + + 0: dpdk_ipsec_init: not enough cryptodevs for ipsec + + +### Configuration example + +No especial IPsec configuration is required. + +Once DPDK Cryptodev is enabled, the user just needs to provide cryptodevs in the startup.conf. + +Example startup.conf: + +``` +dpdk { + socket-mem 1024,1024 + num-mbufs 131072 + dev 0000:81:00.0 + dev 0000:81:00.1 + dev 0000:85:01.0 + dev 0000:85:01.1 + vdev cryptodev_aesni_mb_pmd,socket_id=1 + vdev cryptodev_aesni_mb_pmd,socket_id=1 +} +``` + +In the above configuration: +* 0000:85:01.0 and 0000:85:01.1 are crypto BDFs and they require the same driver binding as DPDK Ethernet devices but they do not support any extra configuration options. +* Two AESNI-MB Software Cryptodev PMDs are created in NUMA node 1. + +For further details refer to [DPDK Crypto Device Driver documentation](http://dpdk.org/doc/guides/cryptodevs/index.html) + +### Operational data + +The following CLI command displays the Cryptodev/Worker mapping: + + show crypto device mapping [verbose] diff --git a/vnet/vnet/devices/dpdk/ipsec/esp.h b/vnet/vnet/devices/dpdk/ipsec/esp.h new file mode 100644 index 00000000..71282ac0 --- /dev/null +++ b/vnet/vnet/devices/dpdk/ipsec/esp.h @@ -0,0 +1,268 @@ +/* + * Copyright (c) 2016 Intel and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef __DPDK_ESP_H__ +#define __DPDK_ESP_H__ + +#include +#include +#include + +typedef struct +{ + enum rte_crypto_cipher_algorithm algo; + u8 key_len; + u8 iv_len; +} dpdk_esp_crypto_alg_t; + +typedef struct +{ + enum rte_crypto_auth_algorithm algo; + u8 trunc_size; +} dpdk_esp_integ_alg_t; + +typedef struct +{ + dpdk_esp_crypto_alg_t *esp_crypto_algs; + dpdk_esp_integ_alg_t *esp_integ_algs; +} dpdk_esp_main_t; + +dpdk_esp_main_t dpdk_esp_main; + +static_always_inline void +dpdk_esp_init () +{ + dpdk_esp_main_t *em = &dpdk_esp_main; + dpdk_esp_integ_alg_t *i; + dpdk_esp_crypto_alg_t *c; + + vec_validate (em->esp_crypto_algs, IPSEC_CRYPTO_N_ALG - 1); + + c = &em->esp_crypto_algs[IPSEC_CRYPTO_ALG_AES_CBC_128]; + c->algo = RTE_CRYPTO_CIPHER_AES_CBC; + c->key_len = 16; + c->iv_len = 16; + + c = &em->esp_crypto_algs[IPSEC_CRYPTO_ALG_AES_CBC_192]; + c->algo = RTE_CRYPTO_CIPHER_AES_CBC; + c->key_len = 24; + c->iv_len = 16; + + c = &em->esp_crypto_algs[IPSEC_CRYPTO_ALG_AES_CBC_256]; + c->algo = RTE_CRYPTO_CIPHER_AES_CBC; + c->key_len = 32; + c->iv_len = 16; + + vec_validate (em->esp_integ_algs, IPSEC_INTEG_N_ALG - 1); + + i = &em->esp_integ_algs[IPSEC_INTEG_ALG_SHA1_96]; + i->algo = RTE_CRYPTO_AUTH_SHA1_HMAC; + i->trunc_size = 12; + + i = &em->esp_integ_algs[IPSEC_INTEG_ALG_SHA_256_96]; + i->algo = RTE_CRYPTO_AUTH_SHA256_HMAC; + i->trunc_size = 12; + + i = &em->esp_integ_algs[IPSEC_INTEG_ALG_SHA_256_128]; + i->algo = RTE_CRYPTO_AUTH_SHA256_HMAC; + i->trunc_size = 16; + + i = &em->esp_integ_algs[IPSEC_INTEG_ALG_SHA_384_192]; + i->algo = RTE_CRYPTO_AUTH_SHA384_HMAC; + i->trunc_size = 24; + + i = &em->esp_integ_algs[IPSEC_INTEG_ALG_SHA_512_256]; + i->algo = RTE_CRYPTO_AUTH_SHA512_HMAC; + i->trunc_size = 32; +} + +static_always_inline int +add_del_sa_sess (u32 sa_index, u8 is_add) +{ + dpdk_crypto_main_t *dcm = &dpdk_crypto_main; + crypto_worker_main_t *cwm; + u8 skip_master = vlib_num_workers () > 0; + + /* *INDENT-OFF* */ + vec_foreach (cwm, dcm->workers_main) + { + crypto_sa_session_t *sa_sess; + u8 is_outbound; + + if (skip_master) + { + skip_master = 0; + continue; + } + + for (is_outbound = 0; is_outbound < 2; is_outbound++) + { + if (is_add) + { + pool_get (cwm->sa_sess_d[is_outbound], sa_sess); + } + else + { + u8 dev_id; + + sa_sess = pool_elt_at_index (cwm->sa_sess_d[is_outbound], sa_index); + dev_id = cwm->qp_data[sa_sess->qp_index].dev_id; + + if (!sa_sess->sess) + continue; + + if (rte_cryptodev_sym_session_free(dev_id, sa_sess->sess)) + { + clib_warning("failed to free session"); + return -1; + } + memset(sa_sess, 0, sizeof(sa_sess[0])); + } + } + } + /* *INDENT-OFF* */ + + return 0; +} + +static_always_inline int +translate_crypto_algo(ipsec_crypto_alg_t crypto_algo, + struct rte_crypto_sym_xform *cipher_xform) +{ + switch (crypto_algo) + { + case IPSEC_CRYPTO_ALG_NONE: + cipher_xform->cipher.algo = RTE_CRYPTO_CIPHER_NULL; + break; + case IPSEC_CRYPTO_ALG_AES_CBC_128: + case IPSEC_CRYPTO_ALG_AES_CBC_192: + case IPSEC_CRYPTO_ALG_AES_CBC_256: + cipher_xform->cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC; + break; + default: + return -1; + } + + cipher_xform->type = RTE_CRYPTO_SYM_XFORM_CIPHER; + + return 0; +} + +static_always_inline int +translate_integ_algo(ipsec_integ_alg_t integ_alg, + struct rte_crypto_sym_xform *auth_xform) +{ + switch (integ_alg) { + case IPSEC_INTEG_ALG_NONE: + auth_xform->auth.algo = RTE_CRYPTO_AUTH_NULL; + auth_xform->auth.digest_length = 0; + break; + case IPSEC_INTEG_ALG_SHA1_96: + auth_xform->auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC; + auth_xform->auth.digest_length = 12; + break; + case IPSEC_INTEG_ALG_SHA_256_96: + auth_xform->auth.algo = RTE_CRYPTO_AUTH_SHA256_HMAC; + auth_xform->auth.digest_length = 12; + break; + case IPSEC_INTEG_ALG_SHA_256_128: + auth_xform->auth.algo = RTE_CRYPTO_AUTH_SHA256_HMAC; + auth_xform->auth.digest_length = 16; + break; + case IPSEC_INTEG_ALG_SHA_384_192: + auth_xform->auth.algo = RTE_CRYPTO_AUTH_SHA384_HMAC; + auth_xform->auth.digest_length = 24; + break; + case IPSEC_INTEG_ALG_SHA_512_256: + auth_xform->auth.algo = RTE_CRYPTO_AUTH_SHA512_HMAC; + auth_xform->auth.digest_length = 32; + break; + default: + return -1; + } + + auth_xform->type = RTE_CRYPTO_SYM_XFORM_AUTH; + + return 0; +} + +static_always_inline int +create_sym_sess(ipsec_sa_t *sa, crypto_sa_session_t *sa_sess, u8 is_outbound) +{ + u32 cpu_index = os_get_cpu_number(); + dpdk_crypto_main_t * dcm = &dpdk_crypto_main; + crypto_worker_main_t *cwm = &dcm->workers_main[cpu_index]; + struct rte_crypto_sym_xform cipher_xform = {0}; + struct rte_crypto_sym_xform auth_xform = {0}; + struct rte_crypto_sym_xform *xfs; + uword key = 0, *data; + crypto_worker_qp_key_t *p_key = (crypto_worker_qp_key_t *)&key; + + cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER; + cipher_xform.cipher.key.data = sa->crypto_key; + cipher_xform.cipher.key.length = sa->crypto_key_len; + + auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH; + auth_xform.auth.key.data = sa->integ_key; + auth_xform.auth.key.length = sa->integ_key_len; + + if (translate_crypto_algo(sa->crypto_alg, &cipher_xform) < 0) + return -1; + p_key->cipher_algo = cipher_xform.cipher.algo; + + if (translate_integ_algo(sa->integ_alg, &auth_xform) < 0) + return -1; + p_key->auth_algo = auth_xform.auth.algo; + + if (is_outbound) + { + cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT; + auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE; + cipher_xform.next = &auth_xform; + xfs = &cipher_xform; + } + else + { + cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT; + auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY; + auth_xform.next = &cipher_xform; + xfs = &auth_xform; + } + + p_key->is_outbound = is_outbound; + + data = hash_get(cwm->algo_qp_map, key); + if (!data) + return -1; + + sa_sess->sess = + rte_cryptodev_sym_session_create(cwm->qp_data[*data].dev_id, xfs); + + if (!sa_sess->sess) + return -1; + + sa_sess->qp_index = (u8)*data; + + return 0; +} + +#endif /* __DPDK_ESP_H__ */ + +/* + * fd.io coding-style-patch-verification: ON + * + * Local Variables: + * eval: (c-set-style "gnu") + * End: + */ diff --git a/vnet/vnet/devices/dpdk/ipsec/esp_decrypt.c b/vnet/vnet/devices/dpdk/ipsec/esp_decrypt.c new file mode 100644 index 00000000..c898d05e --- /dev/null +++ b/vnet/vnet/devices/dpdk/ipsec/esp_decrypt.c @@ -0,0 +1,549 @@ +/* + * esp_decrypt.c : IPSec ESP Decrypt node using DPDK Cryptodev + * + * Copyright (c) 2016 Intel and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include + +#include +#include +#include + +#define foreach_esp_decrypt_next \ +_(DROP, "error-drop") \ +_(IP4_INPUT, "ip4-input") \ +_(IP6_INPUT, "ip6-input") + +#define _(v, s) ESP_DECRYPT_NEXT_##v, +typedef enum { + foreach_esp_decrypt_next +#undef _ + ESP_DECRYPT_N_NEXT, +} esp_decrypt_next_t; + +#define foreach_esp_decrypt_error \ + _(RX_PKTS, "ESP pkts received") \ + _(DECRYPTION_FAILED, "ESP decryption failed") \ + _(REPLAY, "SA replayed packet") \ + _(NOT_IP, "Not IP packet (dropped)") \ + _(ENQ_FAIL, "Enqueue failed (buffer full)") \ + _(NO_CRYPTODEV, "Cryptodev not configured") \ + _(BAD_LEN, "Invalid ciphertext length") \ + _(UNSUPPORTED, "Cipher/Auth not supported") + + +typedef enum { +#define _(sym,str) ESP_DECRYPT_ERROR_##sym, + foreach_esp_decrypt_error +#undef _ + ESP_DECRYPT_N_ERROR, +} esp_decrypt_error_t; + +static char * esp_decrypt_error_strings[] = { +#define _(sym,string) string, + foreach_esp_decrypt_error +#undef _ +}; + +vlib_node_registration_t dpdk_esp_decrypt_node; + +typedef struct { + ipsec_crypto_alg_t crypto_alg; + ipsec_integ_alg_t integ_alg; +} esp_decrypt_trace_t; + +/* packet trace format function */ +static u8 * format_esp_decrypt_trace (u8 * s, va_list * args) +{ + CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *); + CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *); + esp_decrypt_trace_t * t = va_arg (*args, esp_decrypt_trace_t *); + + s = format (s, "esp: crypto %U integrity %U", + format_ipsec_crypto_alg, t->crypto_alg, + format_ipsec_integ_alg, t->integ_alg); + return s; +} + +static uword +dpdk_esp_decrypt_node_fn (vlib_main_t * vm, + vlib_node_runtime_t * node, + vlib_frame_t * from_frame) +{ + u32 n_left_from, *from, *to_next, next_index; + ipsec_main_t *im = &ipsec_main; + u32 cpu_index = os_get_cpu_number(); + dpdk_crypto_main_t * dcm = &dpdk_crypto_main; + dpdk_esp_main_t * em = &dpdk_esp_main; + u32 i; + + from = vlib_frame_vector_args (from_frame); + n_left_from = from_frame->n_vectors; + + if (PREDICT_FALSE(!dcm->workers_main)) + { + vlib_node_increment_counter (vm, dpdk_esp_decrypt_node.index, + ESP_DECRYPT_ERROR_NO_CRYPTODEV, n_left_from); + vlib_buffer_free(vm, from, n_left_from); + return n_left_from; + } + + crypto_worker_main_t *cwm = vec_elt_at_index(dcm->workers_main, cpu_index); + u32 n_qps = vec_len(cwm->qp_data); + struct rte_crypto_op ** cops_to_enq[n_qps]; + u32 n_cop_qp[n_qps], * bi_to_enq[n_qps]; + + for (i = 0; i < n_qps; i++) + { + bi_to_enq[i] = cwm->qp_data[i].bi; + cops_to_enq[i] = cwm->qp_data[i].cops; + } + + memset(n_cop_qp, 0, n_qps * sizeof(u32)); + + crypto_alloc_cops(); + + next_index = ESP_DECRYPT_NEXT_DROP; + + while (n_left_from > 0) + { + u32 n_left_to_next; + + vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next); + + while (n_left_from > 0 && n_left_to_next > 0) + { + u32 bi0, sa_index0 = ~0, seq, icv_size; + vlib_buffer_t * b0; + esp_header_t * esp0; + ipsec_sa_t * sa0; + struct rte_mbuf * mb0 = 0; + const int BLOCK_SIZE = 16; + const int IV_SIZE = 16; + crypto_sa_session_t * sa_sess; + void * sess; + u16 qp_index; + struct rte_crypto_op * cop = 0; + + bi0 = from[0]; + from += 1; + n_left_from -= 1; + + b0 = vlib_get_buffer (vm, bi0); + esp0 = vlib_buffer_get_current (b0); + + sa_index0 = vnet_buffer(b0)->ipsec.sad_index; + sa0 = pool_elt_at_index (im->sad, sa_index0); + + seq = clib_host_to_net_u32(esp0->seq); + + /* anti-replay check */ + if (sa0->use_anti_replay) + { + int rv = 0; + + if (PREDICT_TRUE(sa0->use_esn)) + rv = esp_replay_check_esn(sa0, seq); + else + rv = esp_replay_check(sa0, seq); + + if (PREDICT_FALSE(rv)) + { + clib_warning ("anti-replay SPI %u seq %u", sa0->spi, seq); + vlib_node_increment_counter (vm, dpdk_esp_decrypt_node.index, + ESP_DECRYPT_ERROR_REPLAY, 1); + to_next[0] = bi0; + to_next += 1; + n_left_to_next -= 1; + goto trace; + } + } + + if (PREDICT_FALSE(sa0->integ_alg == IPSEC_INTEG_ALG_NONE) || + PREDICT_FALSE(sa0->crypto_alg == IPSEC_CRYPTO_ALG_NONE)) + { + clib_warning ("SPI %u : only cipher + auth supported", sa0->spi); + vlib_node_increment_counter (vm, dpdk_esp_decrypt_node.index, + ESP_DECRYPT_ERROR_UNSUPPORTED, 1); + to_next[0] = bi0; + to_next += 1; + n_left_to_next -= 1; + goto trace; + } + + sa_sess = pool_elt_at_index(cwm->sa_sess_d[0], sa_index0); + + if (PREDICT_FALSE(!sa_sess->sess)) + { + int ret = create_sym_sess(sa0, sa_sess, 0); + ASSERT(ret == 0); + } + + sess = sa_sess->sess; + qp_index = sa_sess->qp_index; + + ASSERT (vec_len (vec_elt (cwm->qp_data, qp_index).free_cops) > 0); + cop = vec_pop (vec_elt (cwm->qp_data, qp_index).free_cops); + ASSERT (cop->status == RTE_CRYPTO_OP_STATUS_NOT_PROCESSED); + + cops_to_enq[qp_index][0] = cop; + cops_to_enq[qp_index] += 1; + n_cop_qp[qp_index] += 1; + bi_to_enq[qp_index][0] = bi0; + bi_to_enq[qp_index] += 1; + + rte_crypto_op_attach_sym_session(cop, sess); + + icv_size = em->esp_integ_algs[sa0->integ_alg].trunc_size; + + /* Convert vlib buffer to mbuf */ + mb0 = rte_mbuf_from_vlib_buffer(b0); + mb0->data_len = b0->current_length; + mb0->pkt_len = b0->current_length; + mb0->data_off = RTE_PKTMBUF_HEADROOM + b0->current_data; + + /* Outer IP header has already been stripped */ + u16 payload_len = rte_pktmbuf_pkt_len(mb0) - sizeof (esp_header_t) - + IV_SIZE - icv_size; + + if ((payload_len & (BLOCK_SIZE - 1)) || (payload_len <= 0)) + { + clib_warning ("payload %u not multiple of %d\n", + payload_len, BLOCK_SIZE); + vlib_node_increment_counter (vm, dpdk_esp_decrypt_node.index, + ESP_DECRYPT_ERROR_BAD_LEN, 1); + vec_add (vec_elt (cwm->qp_data, qp_index).free_cops, &cop, 1); + bi_to_enq[qp_index] -= 1; + cops_to_enq[qp_index] -= 1; + n_cop_qp[qp_index] -= 1; + to_next[0] = bi0; + to_next += 1; + n_left_to_next -= 1; + goto trace; + } + + struct rte_crypto_sym_op *sym_cop = (struct rte_crypto_sym_op *)(cop + 1); + + sym_cop->m_src = mb0; + sym_cop->cipher.data.offset = sizeof (esp_header_t) + IV_SIZE; + sym_cop->cipher.data.length = payload_len; + + sym_cop->cipher.iv.data = + rte_pktmbuf_mtod_offset(mb0, void*, sizeof (esp_header_t)); + sym_cop->cipher.iv.phys_addr = + rte_pktmbuf_mtophys_offset(mb0, sizeof (esp_header_t)); + sym_cop->cipher.iv.length = IV_SIZE; + + if (sa0->use_esn) + { + dpdk_cop_priv_t* priv = (dpdk_cop_priv_t*) (sym_cop + 1); + u8* payload_end = + rte_pktmbuf_mtod_offset(mb0, u8*, sizeof(esp_header_t) + IV_SIZE + + payload_len); + + memcpy (priv->icv, payload_end, icv_size); + *((u32*) payload_end) = sa0->seq_hi; + sym_cop->auth.data.offset = 0; + sym_cop->auth.data.length = + sizeof(esp_header_t) + IV_SIZE + payload_len + sizeof(sa0->seq_hi); + sym_cop->auth.digest.data = priv->icv; + sym_cop->auth.digest.phys_addr = + cop->phys_addr + (uintptr_t) priv->icv - (uintptr_t) cop; + sym_cop->auth.digest.length = icv_size; + } + else + { + sym_cop->auth.data.offset = 0; + sym_cop->auth.data.length = sizeof(esp_header_t) + + IV_SIZE + payload_len; + + sym_cop->auth.digest.data = + rte_pktmbuf_mtod_offset(mb0, void*, + rte_pktmbuf_pkt_len(mb0) - icv_size); + sym_cop->auth.digest.phys_addr = + rte_pktmbuf_mtophys_offset(mb0, + rte_pktmbuf_pkt_len(mb0) - icv_size); + sym_cop->auth.digest.length = icv_size; + } + +trace: + if (PREDICT_FALSE(b0->flags & VLIB_BUFFER_IS_TRACED)) + { + esp_decrypt_trace_t *tr = vlib_add_trace (vm, node, b0, sizeof (*tr)); + tr->crypto_alg = sa0->crypto_alg; + tr->integ_alg = sa0->integ_alg; + } + } + vlib_put_next_frame (vm, node, next_index, n_left_to_next); + } + vlib_node_increment_counter (vm, dpdk_esp_decrypt_node.index, + ESP_DECRYPT_ERROR_RX_PKTS, + from_frame->n_vectors); + crypto_qp_data_t *qpd; + /* *INDENT-OFF* */ + vec_foreach_index (i, cwm->qp_data) + { + u32 enq; + + qpd = vec_elt_at_index(cwm->qp_data, i); + enq = rte_cryptodev_enqueue_burst(qpd->dev_id, qpd->qp_id, + qpd->cops, n_cop_qp[i]); + qpd->inflights += enq; + + if (PREDICT_FALSE(enq < n_cop_qp[i])) + { + crypto_free_cop (qpd, &qpd->cops[enq], n_cop_qp[i] - enq); + vlib_buffer_free (vm, &qpd->bi[enq], n_cop_qp[i] - enq); + + vlib_node_increment_counter (vm, dpdk_esp_decrypt_node.index, + ESP_DECRYPT_ERROR_ENQ_FAIL, + n_cop_qp[i] - enq); + } + } + /* *INDENT-ON* */ + + return from_frame->n_vectors; +} + +VLIB_REGISTER_NODE (dpdk_esp_decrypt_node) = { + .function = dpdk_esp_decrypt_node_fn, + .name = "dpdk-esp-decrypt", + .vector_size = sizeof (u32), + .format_trace = format_esp_decrypt_trace, + .type = VLIB_NODE_TYPE_INTERNAL, + + .n_errors = ARRAY_LEN(esp_decrypt_error_strings), + .error_strings = esp_decrypt_error_strings, + + .n_next_nodes = ESP_DECRYPT_N_NEXT, + .next_nodes = { +#define _(s,n) [ESP_DECRYPT_NEXT_##s] = n, + foreach_esp_decrypt_next +#undef _ + }, +}; + +VLIB_NODE_FUNCTION_MULTIARCH (dpdk_esp_decrypt_node, dpdk_esp_decrypt_node_fn) + +/* + * Decrypt Post Node + */ + +#define foreach_esp_decrypt_post_error \ + _(PKTS, "ESP post pkts") + +typedef enum { +#define _(sym,str) ESP_DECRYPT_POST_ERROR_##sym, + foreach_esp_decrypt_post_error +#undef _ + ESP_DECRYPT_POST_N_ERROR, +} esp_decrypt_post_error_t; + +static char * esp_decrypt_post_error_strings[] = { +#define _(sym,string) string, + foreach_esp_decrypt_post_error +#undef _ +}; + +vlib_node_registration_t dpdk_esp_decrypt_post_node; + +static u8 * format_esp_decrypt_post_trace (u8 * s, va_list * args) +{ + return s; +} + +static uword +dpdk_esp_decrypt_post_node_fn (vlib_main_t * vm, + vlib_node_runtime_t * node, + vlib_frame_t * from_frame) +{ + u32 n_left_from, *from, *to_next = 0, next_index; + ipsec_sa_t * sa0; + u32 sa_index0 = ~0; + ipsec_main_t *im = &ipsec_main; + dpdk_esp_main_t *em = &dpdk_esp_main; + + from = vlib_frame_vector_args (from_frame); + n_left_from = from_frame->n_vectors; + + next_index = node->cached_next_index; + + while (n_left_from > 0) + { + u32 n_left_to_next; + + vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next); + + while (n_left_from > 0 && n_left_to_next > 0) + { + esp_footer_t * f0; + const u32 IV_SIZE = 16; + u32 bi0, next0, icv_size; + vlib_buffer_t * b0 = 0; + ip4_header_t *ih4 = 0, *oh4 = 0; + ip6_header_t *ih6 = 0, *oh6 = 0; + u8 tunnel_mode = 1; + u8 transport_ip6 = 0; + + next0 = ESP_DECRYPT_NEXT_DROP; + + bi0 = from[0]; + from += 1; + n_left_from -= 1; + n_left_to_next -= 1; + + b0 = vlib_get_buffer (vm, bi0); + + sa_index0 = vnet_buffer(b0)->ipsec.sad_index; + sa0 = pool_elt_at_index (im->sad, sa_index0); + + to_next[0] = bi0; + to_next += 1; + + icv_size = em->esp_integ_algs[sa0->integ_alg].trunc_size; + + if (sa0->use_anti_replay) + { + esp_header_t * esp0 = vlib_buffer_get_current (b0); + u32 seq; + seq = clib_host_to_net_u32(esp0->seq); + if (PREDICT_TRUE(sa0->use_esn)) + esp_replay_advance_esn(sa0, seq); + else + esp_replay_advance(sa0, seq); + } + + ih4 = (ip4_header_t *) (b0->data + sizeof(ethernet_header_t)); + vlib_buffer_advance (b0, sizeof (esp_header_t) + IV_SIZE); + + b0->current_length -= (icv_size + 2); + b0->flags = VLIB_BUFFER_TOTAL_LENGTH_VALID; + f0 = (esp_footer_t *) ((u8 *) vlib_buffer_get_current (b0) + + b0->current_length); + b0->current_length -= f0->pad_length; + + /* transport mode */ + if (PREDICT_FALSE(!sa0->is_tunnel && !sa0->is_tunnel_ip6)) + { + tunnel_mode = 0; + + if (PREDICT_TRUE((ih4->ip_version_and_header_length & 0xF0) != 0x40)) + { + if (PREDICT_TRUE((ih4->ip_version_and_header_length & 0xF0) == 0x60)) + transport_ip6 = 1; + else + { + clib_warning("next header: 0x%x", f0->next_header); + vlib_node_increment_counter (vm, dpdk_esp_decrypt_node.index, + ESP_DECRYPT_ERROR_NOT_IP, 1); + goto trace; + } + } + } + + if (PREDICT_TRUE (tunnel_mode)) + { + if (PREDICT_TRUE(f0->next_header == IP_PROTOCOL_IP_IN_IP)) + next0 = ESP_DECRYPT_NEXT_IP4_INPUT; + else if (f0->next_header == IP_PROTOCOL_IPV6) + next0 = ESP_DECRYPT_NEXT_IP6_INPUT; + else + { + clib_warning("next header: 0x%x", f0->next_header); + vlib_node_increment_counter (vm, dpdk_esp_decrypt_node.index, + ESP_DECRYPT_ERROR_DECRYPTION_FAILED, + 1); + goto trace; + } + } + /* transport mode */ + else + { + if (PREDICT_FALSE(transport_ip6)) + { + next0 = ESP_DECRYPT_NEXT_IP6_INPUT; + ih6 = (ip6_header_t *) (b0->data + sizeof(ethernet_header_t)); + vlib_buffer_advance (b0, -sizeof(ip6_header_t)); + oh6 = vlib_buffer_get_current (b0); + memmove(oh6, ih6, sizeof(ip6_header_t)); + + oh6->protocol = f0->next_header; + oh6->payload_length = + clib_host_to_net_u16 (vlib_buffer_length_in_chain(vm, b0) - + sizeof (ip6_header_t)); + } + else + { + next0 = ESP_DECRYPT_NEXT_IP4_INPUT; + vlib_buffer_advance (b0, -sizeof(ip4_header_t)); + oh4 = vlib_buffer_get_current (b0); + + oh4->ip_version_and_header_length = 0x45; + oh4->tos = ih4->tos; + oh4->fragment_id = 0; + oh4->flags_and_fragment_offset = 0; + oh4->ttl = ih4->ttl; + oh4->protocol = f0->next_header; + oh4->src_address.as_u32 = ih4->src_address.as_u32; + oh4->dst_address.as_u32 = ih4->dst_address.as_u32; + oh4->length = + clib_host_to_net_u16 (vlib_buffer_length_in_chain (vm, b0)); + oh4->checksum = ip4_header_checksum (oh4); + } + } + + vnet_buffer (b0)->sw_if_index[VLIB_TX] = (u32)~0; + +trace: + if (PREDICT_FALSE(b0->flags & VLIB_BUFFER_IS_TRACED)) + { + esp_decrypt_trace_t *tr = vlib_add_trace (vm, node, b0, sizeof (*tr)); + tr->crypto_alg = sa0->crypto_alg; + tr->integ_alg = sa0->integ_alg; + } + + vlib_validate_buffer_enqueue_x1 (vm, node, next_index, + to_next, n_left_to_next, bi0, next0); + } + vlib_put_next_frame (vm, node, next_index, n_left_to_next); + } + vlib_node_increment_counter (vm, dpdk_esp_decrypt_post_node.index, + ESP_DECRYPT_POST_ERROR_PKTS, + from_frame->n_vectors); + + return from_frame->n_vectors; +} + +VLIB_REGISTER_NODE (dpdk_esp_decrypt_post_node) = { + .function = dpdk_esp_decrypt_post_node_fn, + .name = "dpdk-esp-decrypt-post", + .vector_size = sizeof (u32), + .format_trace = format_esp_decrypt_post_trace, + .type = VLIB_NODE_TYPE_INTERNAL, + + .n_errors = ARRAY_LEN(esp_decrypt_post_error_strings), + .error_strings = esp_decrypt_post_error_strings, + + .n_next_nodes = ESP_DECRYPT_N_NEXT, + .next_nodes = { +#define _(s,n) [ESP_DECRYPT_NEXT_##s] = n, + foreach_esp_decrypt_next +#undef _ + }, +}; + +VLIB_NODE_FUNCTION_MULTIARCH (dpdk_esp_decrypt_post_node, dpdk_esp_decrypt_post_node_fn) diff --git a/vnet/vnet/devices/dpdk/ipsec/esp_encrypt.c b/vnet/vnet/devices/dpdk/ipsec/esp_encrypt.c new file mode 100644 index 00000000..aef4b90d --- /dev/null +++ b/vnet/vnet/devices/dpdk/ipsec/esp_encrypt.c @@ -0,0 +1,554 @@ +/* + * esp_encrypt.c : IPSec ESP encrypt node using DPDK Cryptodev + * + * Copyright (c) 2016 Intel and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include + +#include +#include +#include + +#define foreach_esp_encrypt_next \ +_(DROP, "error-drop") \ +_(IP4_INPUT, "ip4-input") \ +_(IP6_INPUT, "ip6-input") \ +_(INTERFACE_OUTPUT, "interface-output") + +#define _(v, s) ESP_ENCRYPT_NEXT_##v, +typedef enum +{ + foreach_esp_encrypt_next +#undef _ + ESP_ENCRYPT_N_NEXT, +} esp_encrypt_next_t; + +#define foreach_esp_encrypt_error \ + _(RX_PKTS, "ESP pkts received") \ + _(SEQ_CYCLED, "sequence number cycled") \ + _(ENQ_FAIL, "Enqueue failed (buffer full)") \ + _(NO_CRYPTODEV, "Cryptodev not configured") \ + _(UNSUPPORTED, "Cipher/Auth not supported") + + +typedef enum +{ +#define _(sym,str) ESP_ENCRYPT_ERROR_##sym, + foreach_esp_encrypt_error +#undef _ + ESP_ENCRYPT_N_ERROR, +} esp_encrypt_error_t; + +static char *esp_encrypt_error_strings[] = { +#define _(sym,string) string, + foreach_esp_encrypt_error +#undef _ +}; + +vlib_node_registration_t dpdk_esp_encrypt_node; + +typedef struct +{ + u32 spi; + u32 seq; + ipsec_crypto_alg_t crypto_alg; + ipsec_integ_alg_t integ_alg; +} esp_encrypt_trace_t; + +/* packet trace format function */ +static u8 * +format_esp_encrypt_trace (u8 * s, va_list * args) +{ + CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *); + CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *); + esp_encrypt_trace_t *t = va_arg (*args, esp_encrypt_trace_t *); + + s = format (s, "esp: spi %u seq %u crypto %U integrity %U", + t->spi, t->seq, + format_ipsec_crypto_alg, t->crypto_alg, + format_ipsec_integ_alg, t->integ_alg); + return s; +} + +static uword +dpdk_esp_encrypt_node_fn (vlib_main_t * vm, + vlib_node_runtime_t * node, + vlib_frame_t * from_frame) +{ + u32 n_left_from, *from, *to_next, next_index; + ipsec_main_t *im = &ipsec_main; + u32 cpu_index = os_get_cpu_number (); + dpdk_crypto_main_t *dcm = &dpdk_crypto_main; + dpdk_esp_main_t *em = &dpdk_esp_main; + u32 i; + + from = vlib_frame_vector_args (from_frame); + n_left_from = from_frame->n_vectors; + + if (PREDICT_FALSE (!dcm->workers_main)) + { + /* Likely there are not enough cryptodevs, so drop frame */ + vlib_node_increment_counter (vm, dpdk_esp_encrypt_node.index, + ESP_ENCRYPT_ERROR_NO_CRYPTODEV, + n_left_from); + vlib_buffer_free (vm, from, n_left_from); + return n_left_from; + } + + crypto_worker_main_t *cwm = vec_elt_at_index (dcm->workers_main, cpu_index); + u32 n_qps = vec_len (cwm->qp_data); + struct rte_crypto_op **cops_to_enq[n_qps]; + u32 n_cop_qp[n_qps], *bi_to_enq[n_qps]; + + for (i = 0; i < n_qps; i++) + { + bi_to_enq[i] = cwm->qp_data[i].bi; + cops_to_enq[i] = cwm->qp_data[i].cops; + } + + memset (n_cop_qp, 0, n_qps * sizeof (u32)); + + crypto_alloc_cops (); + + next_index = ESP_ENCRYPT_NEXT_DROP; + + while (n_left_from > 0) + { + u32 n_left_to_next; + + vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next); + + while (n_left_from > 0 && n_left_to_next > 0) + { + u32 bi0, next0; + vlib_buffer_t *b0 = 0; + u32 sa_index0; + ipsec_sa_t *sa0; + ip4_and_esp_header_t *ih0, *oh0 = 0; + ip6_and_esp_header_t *ih6_0, *oh6_0 = 0; + struct rte_mbuf *mb0 = 0; + esp_footer_t *f0; + u8 is_ipv6; + u8 ip_hdr_size; + u8 next_hdr_type; + u8 transport_mode = 0; + const int BLOCK_SIZE = 16; + const int IV_SIZE = 16; + u16 orig_sz; + crypto_sa_session_t *sa_sess; + void *sess; + struct rte_crypto_op *cop = 0; + u16 qp_index; + + bi0 = from[0]; + from += 1; + n_left_from -= 1; + + b0 = vlib_get_buffer (vm, bi0); + sa_index0 = vnet_buffer (b0)->ipsec.sad_index; + sa0 = pool_elt_at_index (im->sad, sa_index0); + + if (PREDICT_FALSE (esp_seq_advance (sa0))) + { + clib_warning ("sequence number counter has cycled SPI %u", + sa0->spi); + vlib_node_increment_counter (vm, dpdk_esp_encrypt_node.index, + ESP_ENCRYPT_ERROR_SEQ_CYCLED, 1); + //TODO: rekey SA + to_next[0] = bi0; + to_next += 1; + n_left_to_next -= 1; + goto trace; + } + + sa_sess = pool_elt_at_index (cwm->sa_sess_d[1], sa_index0); + if (PREDICT_FALSE (!sa_sess->sess)) + { + int ret = create_sym_sess (sa0, sa_sess, 1); + ASSERT (ret == 0); + } + + qp_index = sa_sess->qp_index; + sess = sa_sess->sess; + + ASSERT (vec_len (vec_elt (cwm->qp_data, qp_index).free_cops) > 0); + cop = vec_pop (vec_elt (cwm->qp_data, qp_index).free_cops); + ASSERT (cop->status == RTE_CRYPTO_OP_STATUS_NOT_PROCESSED); + + cops_to_enq[qp_index][0] = cop; + cops_to_enq[qp_index] += 1; + n_cop_qp[qp_index] += 1; + bi_to_enq[qp_index][0] = bi0; + bi_to_enq[qp_index] += 1; + + ssize_t adv; + ih0 = vlib_buffer_get_current (b0); + orig_sz = b0->current_length; + is_ipv6 = (ih0->ip4.ip_version_and_header_length & 0xF0) == 0x60; + /* is ipv6 */ + if (PREDICT_TRUE (sa0->is_tunnel)) + { + if (PREDICT_TRUE (!is_ipv6)) + adv = -sizeof (ip4_and_esp_header_t); + else + adv = -sizeof (ip6_and_esp_header_t); + } + else + { + adv = -sizeof (esp_header_t); + if (PREDICT_TRUE (!is_ipv6)) + orig_sz -= sizeof (ip4_header_t); + else + orig_sz -= sizeof (ip6_header_t); + } + + /*transport mode save the eth header before it is overwritten */ + if (PREDICT_FALSE (!sa0->is_tunnel)) + { + ethernet_header_t *ieh0 = (ethernet_header_t *) + ((u8 *) vlib_buffer_get_current (b0) - + sizeof (ethernet_header_t)); + ethernet_header_t *oeh0 = + (ethernet_header_t *) ((u8 *) ieh0 + (adv - IV_SIZE)); + clib_memcpy (oeh0, ieh0, sizeof (ethernet_header_t)); + } + + vlib_buffer_advance (b0, adv - IV_SIZE); + + /* XXX IP6/ip4 and IP4/IP6 not supported, only IP4/IP4 and IP6/IP6 */ + + /* is ipv6 */ + if (PREDICT_FALSE (is_ipv6)) + { + ih6_0 = (ip6_and_esp_header_t *) ih0; + ip_hdr_size = sizeof (ip6_header_t); + oh6_0 = vlib_buffer_get_current (b0); + + if (PREDICT_TRUE (sa0->is_tunnel)) + { + next_hdr_type = IP_PROTOCOL_IPV6; + oh6_0->ip6.ip_version_traffic_class_and_flow_label = + ih6_0->ip6.ip_version_traffic_class_and_flow_label; + } + else + { + next_hdr_type = ih6_0->ip6.protocol; + memmove (oh6_0, ih6_0, sizeof (ip6_header_t)); + } + + oh6_0->ip6.protocol = IP_PROTOCOL_IPSEC_ESP; + oh6_0->ip6.hop_limit = 254; + oh6_0->esp.spi = clib_net_to_host_u32 (sa0->spi); + oh6_0->esp.seq = clib_net_to_host_u32 (sa0->seq); + } + else + { + ip_hdr_size = sizeof (ip4_header_t); + next_hdr_type = IP_PROTOCOL_IP_IN_IP; + oh0 = vlib_buffer_get_current (b0); + + oh0->ip4.ip_version_and_header_length = 0x45; + oh0->ip4.tos = ih0->ip4.tos; + oh0->ip4.fragment_id = 0; + oh0->ip4.flags_and_fragment_offset = 0; + oh0->ip4.ttl = 254; + oh0->ip4.protocol = IP_PROTOCOL_IPSEC_ESP; + oh0->esp.spi = clib_net_to_host_u32 (sa0->spi); + oh0->esp.seq = clib_net_to_host_u32 (sa0->seq); + } + + if (PREDICT_TRUE (sa0->is_tunnel && !sa0->is_tunnel_ip6)) + { + oh0->ip4.src_address.as_u32 = sa0->tunnel_src_addr.ip4.as_u32; + oh0->ip4.dst_address.as_u32 = sa0->tunnel_dst_addr.ip4.as_u32; + + /* in tunnel mode send it back to FIB */ + next0 = ESP_ENCRYPT_NEXT_IP4_INPUT; + vnet_buffer (b0)->sw_if_index[VLIB_TX] = (u32) ~ 0; + } + else if (sa0->is_tunnel && sa0->is_tunnel_ip6) + { + oh6_0->ip6.src_address.as_u64[0] = + sa0->tunnel_src_addr.ip6.as_u64[0]; + oh6_0->ip6.src_address.as_u64[1] = + sa0->tunnel_src_addr.ip6.as_u64[1]; + oh6_0->ip6.dst_address.as_u64[0] = + sa0->tunnel_dst_addr.ip6.as_u64[0]; + oh6_0->ip6.dst_address.as_u64[1] = + sa0->tunnel_dst_addr.ip6.as_u64[1]; + + /* in tunnel mode send it back to FIB */ + next0 = ESP_ENCRYPT_NEXT_IP6_INPUT; + vnet_buffer (b0)->sw_if_index[VLIB_TX] = (u32) ~ 0; + } + else + { + next0 = ESP_ENCRYPT_NEXT_INTERFACE_OUTPUT; + transport_mode = 1; + /*ipv6 already handled */ + if (PREDICT_TRUE (!is_ipv6)) + { + next_hdr_type = ih0->ip4.protocol; + oh0->ip4.src_address.as_u32 = ih0->ip4.src_address.as_u32; + oh0->ip4.dst_address.as_u32 = ih0->ip4.dst_address.as_u32; + } + } + + ASSERT (sa0->crypto_alg < IPSEC_CRYPTO_N_ALG); + ASSERT (sa0->crypto_alg != IPSEC_CRYPTO_ALG_NONE); + + int blocks = 1 + (orig_sz + 1) / BLOCK_SIZE; + + /* pad packet in input buffer */ + u8 pad_bytes = BLOCK_SIZE * blocks - 2 - orig_sz; + u8 i; + u8 *padding = vlib_buffer_get_current (b0) + b0->current_length; + + for (i = 0; i < pad_bytes; ++i) + padding[i] = i + 1; + + f0 = vlib_buffer_get_current (b0) + b0->current_length + pad_bytes; + f0->pad_length = pad_bytes; + f0->next_header = next_hdr_type; + b0->current_length += pad_bytes + 2 + + em->esp_integ_algs[sa0->integ_alg].trunc_size; + + vnet_buffer (b0)->sw_if_index[VLIB_RX] = + vnet_buffer (b0)->sw_if_index[VLIB_RX]; + b0->flags |= VLIB_BUFFER_TOTAL_LENGTH_VALID; + + struct rte_crypto_sym_op *sym_cop; + sym_cop = (struct rte_crypto_sym_op *) (cop + 1); + + dpdk_cop_priv_t *priv = (dpdk_cop_priv_t *) (sym_cop + 1); + + vnet_buffer (b0)->unused[0] = next0; + priv->iv[0] = sa0->seq; + priv->iv[1] = sa0->seq_hi; + + mb0 = rte_mbuf_from_vlib_buffer (b0); + mb0->data_len = b0->current_length; + mb0->pkt_len = b0->current_length; + mb0->data_off = RTE_PKTMBUF_HEADROOM + b0->current_data; + + rte_crypto_op_attach_sym_session (cop, sess); + + sym_cop->m_src = mb0; + sym_cop->cipher.data.offset = ip_hdr_size + sizeof (esp_header_t); + sym_cop->cipher.data.length = BLOCK_SIZE * blocks + IV_SIZE; + + sym_cop->cipher.iv.data = (u8 *) priv->iv; + sym_cop->cipher.iv.phys_addr = cop->phys_addr + + (uintptr_t) priv->iv - (uintptr_t) cop; + sym_cop->cipher.iv.length = IV_SIZE; + + ASSERT (sa0->integ_alg < IPSEC_INTEG_N_ALG); + ASSERT (sa0->integ_alg != IPSEC_INTEG_ALG_NONE); + + sym_cop->auth.data.offset = ip_hdr_size; + sym_cop->auth.data.length = b0->current_length - ip_hdr_size - + em->esp_integ_algs[sa0->integ_alg].trunc_size; + + sym_cop->auth.digest.data = vlib_buffer_get_current (b0) + + b0->current_length - + em->esp_integ_algs[sa0->integ_alg].trunc_size; + sym_cop->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset (mb0, + b0->current_length + - + em->esp_integ_algs + [sa0->integ_alg].trunc_size); + sym_cop->auth.digest.length = + em->esp_integ_algs[sa0->integ_alg].trunc_size; + + if (PREDICT_FALSE (sa0->use_esn)) + { + u8 *payload_end = + vlib_buffer_get_current (b0) + b0->current_length; + *((u32 *) payload_end) = sa0->seq_hi; + sym_cop->auth.data.length += sizeof (sa0->seq_hi); + } + + if (PREDICT_FALSE (is_ipv6)) + { + oh6_0->ip6.payload_length = + clib_host_to_net_u16 (vlib_buffer_length_in_chain (vm, b0) - + sizeof (ip6_header_t)); + } + else + { + oh0->ip4.length = + clib_host_to_net_u16 (vlib_buffer_length_in_chain (vm, b0)); + oh0->ip4.checksum = ip4_header_checksum (&oh0->ip4); + } + + if (transport_mode) + vlib_buffer_advance (b0, -sizeof (ethernet_header_t)); + + trace: + if (PREDICT_FALSE (b0->flags & VLIB_BUFFER_IS_TRACED)) + { + esp_encrypt_trace_t *tr = + vlib_add_trace (vm, node, b0, sizeof (*tr)); + tr->spi = sa0->spi; + tr->seq = sa0->seq - 1; + tr->crypto_alg = sa0->crypto_alg; + tr->integ_alg = sa0->integ_alg; + } + } + vlib_put_next_frame (vm, node, next_index, n_left_to_next); + } + vlib_node_increment_counter (vm, dpdk_esp_encrypt_node.index, + ESP_ENCRYPT_ERROR_RX_PKTS, + from_frame->n_vectors); + crypto_qp_data_t *qpd; + /* *INDENT-OFF* */ + vec_foreach_index (i, cwm->qp_data) + { + u32 enq; + + qpd = vec_elt_at_index(cwm->qp_data, i); + enq = rte_cryptodev_enqueue_burst(qpd->dev_id, qpd->qp_id, + qpd->cops, n_cop_qp[i]); + qpd->inflights += enq; + + if (PREDICT_FALSE(enq < n_cop_qp[i])) + { + crypto_free_cop (qpd, &qpd->cops[enq], n_cop_qp[i] - enq); + vlib_buffer_free (vm, &qpd->bi[enq], n_cop_qp[i] - enq); + + vlib_node_increment_counter (vm, dpdk_esp_encrypt_node.index, + ESP_ENCRYPT_ERROR_ENQ_FAIL, + n_cop_qp[i] - enq); + } + } + /* *INDENT-ON* */ + + return from_frame->n_vectors; +} + +VLIB_REGISTER_NODE (dpdk_esp_encrypt_node) = +{ + .function = dpdk_esp_encrypt_node_fn,.name = "dpdk-esp-encrypt",.flags = + VLIB_NODE_FLAG_IS_OUTPUT,.vector_size = sizeof (u32),.format_trace = + format_esp_encrypt_trace,.n_errors = + ARRAY_LEN (esp_encrypt_error_strings),.error_strings = + esp_encrypt_error_strings,.n_next_nodes = 1,.next_nodes = + { + [ESP_ENCRYPT_NEXT_DROP] = "error-drop",} +}; + +VLIB_NODE_FUNCTION_MULTIARCH (dpdk_esp_encrypt_node, dpdk_esp_encrypt_node_fn) +/* + * ESP Encrypt Post Node + */ +#define foreach_esp_encrypt_post_error \ + _(PKTS, "ESP post pkts") + typedef enum + { +#define _(sym,str) ESP_ENCRYPT_POST_ERROR_##sym, + foreach_esp_encrypt_post_error +#undef _ + ESP_ENCRYPT_POST_N_ERROR, + } esp_encrypt_post_error_t; + + static char *esp_encrypt_post_error_strings[] = { +#define _(sym,string) string, + foreach_esp_encrypt_post_error +#undef _ + }; + +vlib_node_registration_t dpdk_esp_encrypt_post_node; + +static u8 * +format_esp_encrypt_post_trace (u8 * s, va_list * args) +{ + return s; +} + +static uword +dpdk_esp_encrypt_post_node_fn (vlib_main_t * vm, + vlib_node_runtime_t * node, + vlib_frame_t * from_frame) +{ + u32 n_left_from, *from, *to_next = 0, next_index; + + from = vlib_frame_vector_args (from_frame); + n_left_from = from_frame->n_vectors; + + next_index = node->cached_next_index; + + while (n_left_from > 0) + { + u32 n_left_to_next; + + vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next); + + while (n_left_from > 0 && n_left_to_next > 0) + { + u32 bi0, next0; + vlib_buffer_t *b0 = 0; + + bi0 = from[0]; + from += 1; + n_left_from -= 1; + n_left_to_next -= 1; + + b0 = vlib_get_buffer (vm, bi0); + + to_next[0] = bi0; + to_next += 1; + + next0 = vnet_buffer (b0)->unused[0]; + + vlib_validate_buffer_enqueue_x1 (vm, node, next_index, + to_next, n_left_to_next, bi0, + next0); + } + vlib_put_next_frame (vm, node, next_index, n_left_to_next); + } + + vlib_node_increment_counter (vm, dpdk_esp_encrypt_post_node.index, + ESP_ENCRYPT_POST_ERROR_PKTS, + from_frame->n_vectors); + + return from_frame->n_vectors; +} + +VLIB_REGISTER_NODE (dpdk_esp_encrypt_post_node) = +{ + .function = dpdk_esp_encrypt_post_node_fn,.name = + "dpdk-esp-encrypt-post",.vector_size = sizeof (u32),.format_trace = + format_esp_encrypt_post_trace,.type = VLIB_NODE_TYPE_INTERNAL,.n_errors = + ARRAY_LEN (esp_encrypt_post_error_strings),.error_strings = + esp_encrypt_post_error_strings,.n_next_nodes = + ESP_ENCRYPT_N_NEXT,.next_nodes = + { +#define _(s,n) [ESP_ENCRYPT_NEXT_##s] = n, + foreach_esp_encrypt_next +#undef _ + } +}; + +VLIB_NODE_FUNCTION_MULTIARCH (dpdk_esp_encrypt_post_node, + dpdk_esp_encrypt_post_node_fn) +/* + * fd.io coding-style-patch-verification: ON + * + * Local Variables: + * eval: (c-set-style "gnu") + * End: + */ diff --git a/vnet/vnet/devices/dpdk/ipsec/ipsec.c b/vnet/vnet/devices/dpdk/ipsec/ipsec.c new file mode 100644 index 00000000..de253f02 --- /dev/null +++ b/vnet/vnet/devices/dpdk/ipsec/ipsec.c @@ -0,0 +1,313 @@ +/* + * Copyright (c) 2016 Intel and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include +#include +#include +#include +#include +#include +#include + +#define DPDK_CRYPTO_NB_OBJS 2048 +#define DPDK_CRYPTO_CACHE_SIZE 512 +#define DPDK_CRYPTO_PRIV_SIZE 128 +#define DPDK_CRYPTO_N_QUEUE_DESC 512 +#define DPDK_CRYPTO_NB_COPS (1024 * 4) + +/* + * return: + * -1: update failed + * 0: already exist + * 1: mapped + */ +static int +update_qp_data (crypto_worker_main_t * cwm, + u8 cdev_id, u16 qp_id, u8 is_outbound, u16 * idx) +{ + crypto_qp_data_t *qpd; + + /* *INDENT-OFF* */ + vec_foreach_index (*idx, cwm->qp_data) + { + qpd = vec_elt_at_index(cwm->qp_data, *idx); + + if (qpd->dev_id == cdev_id && qpd->qp_id == qp_id && + qpd->is_outbound == is_outbound) + return 0; + } + /* *INDENT-ON* */ + + vec_add2 (cwm->qp_data, qpd, 1); + + qpd->dev_id = cdev_id; + qpd->qp_id = qp_id; + qpd->is_outbound = is_outbound; + + return 1; +} + +/* + * return: + * -1: error + * 0: already exist + * 1: mapped + */ +static int +add_mapping (crypto_worker_main_t * cwm, + u8 cdev_id, u16 qp, u8 is_outbound, + const struct rte_cryptodev_capabilities *cipher_cap, + const struct rte_cryptodev_capabilities *auth_cap) +{ + int mapped; + u16 qp_index; + uword key = 0, data, *ret; + crypto_worker_qp_key_t *p_key = (crypto_worker_qp_key_t *) & key; + + p_key->cipher_algo = (u8) cipher_cap->sym.cipher.algo; + p_key->auth_algo = (u8) auth_cap->sym.auth.algo; + p_key->is_outbound = is_outbound; + + ret = hash_get (cwm->algo_qp_map, key); + if (ret) + return 0; + + mapped = update_qp_data (cwm, cdev_id, qp, is_outbound, &qp_index); + if (mapped < 0) + return -1; + + data = (uword) qp_index; + + ret = hash_set (cwm->algo_qp_map, key, data); + if (!ret) + rte_panic ("Failed to insert hash table\n"); + + return mapped; +} + +/* + * return: + * 0: already exist + * 1: mapped + */ +static int +add_cdev_mapping (crypto_worker_main_t * cwm, + struct rte_cryptodev_info *dev_info, u8 cdev_id, + u16 qp, u8 is_outbound) +{ + const struct rte_cryptodev_capabilities *i, *j; + u32 mapped = 0; + + for (i = dev_info->capabilities; i->op != RTE_CRYPTO_OP_TYPE_UNDEFINED; i++) + { + if (i->sym.xform_type != RTE_CRYPTO_SYM_XFORM_CIPHER) + continue; + + if (check_algo_is_supported (i, NULL) != 0) + continue; + + for (j = dev_info->capabilities; j->op != RTE_CRYPTO_OP_TYPE_UNDEFINED; + j++) + { + int status = 0; + + if (j->sym.xform_type != RTE_CRYPTO_SYM_XFORM_AUTH) + continue; + + if (check_algo_is_supported (j, NULL) != 0) + continue; + + status = add_mapping (cwm, cdev_id, qp, is_outbound, i, j); + if (status == 1) + mapped += 1; + if (status < 0) + return status; + } + } + + return mapped; +} + +static int +check_cryptodev_queues () +{ + u32 n_qs = 0; + u8 cdev_id; + u32 n_req_qs = 2; + + if (vlib_num_workers () > 0) + n_req_qs = vlib_num_workers () * 2; + + for (cdev_id = 0; cdev_id < rte_cryptodev_count (); cdev_id++) + { + struct rte_cryptodev_info cdev_info; + + rte_cryptodev_info_get (cdev_id, &cdev_info); + + if (! + (cdev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_OPERATION_CHAINING)) + continue; + + n_qs += cdev_info.max_nb_queue_pairs; + } + + if (n_qs >= n_req_qs) + return 0; + else + return -1; +} + +static clib_error_t * +dpdk_ipsec_init (vlib_main_t * vm) +{ + dpdk_crypto_main_t *dcm = &dpdk_crypto_main; + vlib_thread_main_t *tm = vlib_get_thread_main (); + struct rte_cryptodev_config dev_conf; + struct rte_cryptodev_qp_conf qp_conf; + struct rte_cryptodev_info cdev_info; + struct rte_mempool *rmp; + i32 dev_id, ret; + u32 i, skip_master; + + if (check_cryptodev_queues () < 0) + return clib_error_return (0, "not enough cryptodevs for ipsec"); + + vec_alloc (dcm->workers_main, tm->n_vlib_mains); + _vec_len (dcm->workers_main) = tm->n_vlib_mains; + + fprintf (stdout, "DPDK Cryptodevs info:\n"); + fprintf (stdout, "dev_id\tn_qp\tnb_obj\tcache_size\n"); + /* HW cryptodevs have higher dev_id, use HW first */ + for (dev_id = rte_cryptodev_count () - 1; dev_id >= 0; dev_id--) + { + u16 max_nb_qp, qp = 0; + skip_master = vlib_num_workers () > 0; + + rte_cryptodev_info_get (dev_id, &cdev_info); + + if (! + (cdev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_OPERATION_CHAINING)) + continue; + + max_nb_qp = cdev_info.max_nb_queue_pairs; + + for (i = 0; i < tm->n_vlib_mains; i++) + { + u8 is_outbound; + crypto_worker_main_t *cwm; + uword *map; + + if (skip_master) + { + skip_master = 0; + continue; + } + + cwm = vec_elt_at_index (dcm->workers_main, i); + map = cwm->algo_qp_map; + + if (!map) + { + map = hash_create (0, sizeof (crypto_worker_qp_key_t)); + if (!map) + return clib_error_return (0, "unable to create hash table " + "for worker %u", + vlib_mains[i]->cpu_index); + cwm->algo_qp_map = map; + } + + for (is_outbound = 0; is_outbound < 2 && qp < max_nb_qp; + is_outbound++) + { + int mapped = add_cdev_mapping (cwm, &cdev_info, + dev_id, qp, is_outbound); + if (mapped > 0) + qp++; + + if (mapped < 0) + return clib_error_return (0, + "too many queues for one worker"); + } + } + + if (qp == 0) + continue; + + dev_conf.socket_id = rte_cryptodev_socket_id (dev_id); + dev_conf.nb_queue_pairs = cdev_info.max_nb_queue_pairs; + dev_conf.session_mp.nb_objs = DPDK_CRYPTO_NB_OBJS; + dev_conf.session_mp.cache_size = DPDK_CRYPTO_CACHE_SIZE; + + ret = rte_cryptodev_configure (dev_id, &dev_conf); + if (ret < 0) + return clib_error_return (0, "cryptodev %u config error", dev_id); + + qp_conf.nb_descriptors = DPDK_CRYPTO_N_QUEUE_DESC; + for (qp = 0; qp < dev_conf.nb_queue_pairs; qp++) + { + ret = rte_cryptodev_queue_pair_setup (dev_id, qp, &qp_conf, + dev_conf.socket_id); + if (ret < 0) + return clib_error_return (0, "cryptodev %u qp %u setup error", + dev_id, qp); + } + fprintf (stdout, "%u\t%u\t%u\t%u\n", dev_id, dev_conf.nb_queue_pairs, + DPDK_CRYPTO_NB_OBJS, DPDK_CRYPTO_CACHE_SIZE); + } + + u32 socket_id = rte_socket_id (); + + vec_validate_aligned (dcm->cop_pools, socket_id, CLIB_CACHE_LINE_BYTES); + + /* pool already exists, nothing to do */ + if (dcm->cop_pools[socket_id]) + return 0; + + u8 *pool_name = format (0, "crypto_op_pool_socket%u%c", socket_id, 0); + + rmp = rte_crypto_op_pool_create ((char *) pool_name, + RTE_CRYPTO_OP_TYPE_SYMMETRIC, + DPDK_CRYPTO_NB_COPS * + (1 + vlib_num_workers ()), + DPDK_CRYPTO_CACHE_SIZE, + DPDK_CRYPTO_PRIV_SIZE, socket_id); + vec_free (pool_name); + + if (!rmp) + return clib_error_return (0, "failed to allocate mempool on socket %u", + socket_id); + dcm->cop_pools[socket_id] = rmp; + + dpdk_esp_init (); + + if (vec_len (vlib_mains) == 0) + vlib_node_set_state (&vlib_global_main, dpdk_crypto_input_node.index, + VLIB_NODE_STATE_POLLING); + else + for (i = 1; i < tm->n_vlib_mains; i++) + vlib_node_set_state (vlib_mains[i], dpdk_crypto_input_node.index, + VLIB_NODE_STATE_POLLING); + + return 0; +} + +VLIB_MAIN_LOOP_ENTER_FUNCTION (dpdk_ipsec_init); + +/* + * fd.io coding-style-patch-verification: ON + * + * Local Variables: + * eval: (c-set-style "gnu") + * End: + */ diff --git a/vnet/vnet/devices/dpdk/ipsec/ipsec.h b/vnet/vnet/devices/dpdk/ipsec/ipsec.h new file mode 100644 index 00000000..e103655c --- /dev/null +++ b/vnet/vnet/devices/dpdk/ipsec/ipsec.h @@ -0,0 +1,216 @@ +/* + * Copyright (c) 2016 Intel and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef __DPDK_IPSEC_H__ +#define __DPDK_IPSEC_H__ + +#include + +#undef always_inline +#include +#include + +#if CLIB_DEBUG > 0 +#define always_inline static inline +#else +#define always_inline static inline __attribute__ ((__always_inline__)) +#endif + + +#define MAX_QP_PER_LCORE 16 + +typedef struct +{ + u32 iv[4]; + u8 icv[64]; +} dpdk_cop_priv_t; + +typedef struct +{ + u8 cipher_algo; + u8 auth_algo; + u8 is_outbound; +} crypto_worker_qp_key_t; + +typedef struct +{ + u16 dev_id; + u16 qp_id; + u16 is_outbound; + i16 inflights; + u32 bi[VLIB_FRAME_SIZE]; + struct rte_crypto_op *cops[VLIB_FRAME_SIZE]; + struct rte_crypto_op **free_cops; +} crypto_qp_data_t; + +typedef struct +{ + u8 qp_index; + void *sess; +} crypto_sa_session_t; + +typedef struct +{ + crypto_sa_session_t *sa_sess_d[2]; + crypto_qp_data_t *qp_data; + uword *algo_qp_map; +} crypto_worker_main_t; + +typedef struct +{ + struct rte_mempool **cop_pools; + crypto_worker_main_t *workers_main; +} dpdk_crypto_main_t; + +dpdk_crypto_main_t dpdk_crypto_main; + +extern vlib_node_registration_t dpdk_crypto_input_node; + +#define CRYPTO_N_FREE_COPS (VLIB_FRAME_SIZE * 3) + +static_always_inline void +crypto_alloc_cops () +{ + dpdk_crypto_main_t *dcm = &dpdk_crypto_main; + u32 cpu_index = os_get_cpu_number (); + crypto_worker_main_t *cwm = &dcm->workers_main[cpu_index]; + unsigned socket_id = rte_socket_id (); + crypto_qp_data_t *qpd; + + /* *INDENT-OFF* */ + vec_foreach (qpd, cwm->qp_data) + { + u32 l = vec_len (qpd->free_cops); + + if (PREDICT_FALSE (l < VLIB_FRAME_SIZE)) + { + u32 n_alloc; + + if (PREDICT_FALSE (!qpd->free_cops)) + vec_alloc (qpd->free_cops, CRYPTO_N_FREE_COPS); + + n_alloc = rte_crypto_op_bulk_alloc (dcm->cop_pools[socket_id], + RTE_CRYPTO_OP_TYPE_SYMMETRIC, + &qpd->free_cops[l], + CRYPTO_N_FREE_COPS - l - 1); + + _vec_len (qpd->free_cops) = l + n_alloc; + } + } + /* *INDENT-ON* */ +} + +static_always_inline void +crypto_free_cop (crypto_qp_data_t * qpd, struct rte_crypto_op **cops, u32 n) +{ + u32 l = vec_len (qpd->free_cops); + + if (l + n >= CRYPTO_N_FREE_COPS) + { + l -= VLIB_FRAME_SIZE; + rte_mempool_put_bulk (cops[0]->mempool, + (void **) &qpd->free_cops[l], VLIB_FRAME_SIZE); + } + clib_memcpy (&qpd->free_cops[l], cops, sizeof (*cops) * n); + + _vec_len (qpd->free_cops) = l + n; +} + +static_always_inline int +check_algo_is_supported (const struct rte_cryptodev_capabilities *cap, + char *name) +{ + struct + { + uint8_t cipher_algo; + enum rte_crypto_sym_xform_type type; + union + { + enum rte_crypto_auth_algorithm auth; + enum rte_crypto_cipher_algorithm cipher; + }; + char *name; + } supported_algo[] = + { + { + .type = RTE_CRYPTO_SYM_XFORM_CIPHER,.cipher = + RTE_CRYPTO_CIPHER_NULL,.name = "NULL"}, + { + .type = RTE_CRYPTO_SYM_XFORM_CIPHER,.cipher = + RTE_CRYPTO_CIPHER_AES_CBC,.name = "AES_CBC"}, + { + .type = RTE_CRYPTO_SYM_XFORM_CIPHER,.cipher = + RTE_CRYPTO_CIPHER_AES_CTR,.name = "AES_CTR"}, + { + .type = RTE_CRYPTO_SYM_XFORM_CIPHER,.cipher = + RTE_CRYPTO_CIPHER_3DES_CBC,.name = "3DES-CBC"}, + { + .type = RTE_CRYPTO_SYM_XFORM_CIPHER,.auth = + RTE_CRYPTO_CIPHER_AES_GCM,.name = "AES-GCM"}, + { + .type = RTE_CRYPTO_SYM_XFORM_AUTH,.auth = + RTE_CRYPTO_AUTH_SHA1_HMAC,.name = "HMAC-SHA1"}, + { + .type = RTE_CRYPTO_SYM_XFORM_AUTH,.auth = + RTE_CRYPTO_AUTH_SHA256_HMAC,.name = "HMAC-SHA256"}, + { + .type = RTE_CRYPTO_SYM_XFORM_AUTH,.auth = + RTE_CRYPTO_AUTH_SHA384_HMAC,.name = "HMAC-SHA384"}, + { + .type = RTE_CRYPTO_SYM_XFORM_AUTH,.auth = + RTE_CRYPTO_AUTH_SHA512_HMAC,.name = "HMAC-SHA512"}, + { + .type = RTE_CRYPTO_SYM_XFORM_AUTH,.auth = + RTE_CRYPTO_AUTH_AES_XCBC_MAC,.name = "AES-XCBC-MAC"}, + { + .type = RTE_CRYPTO_SYM_XFORM_AUTH,.auth = + RTE_CRYPTO_AUTH_AES_GCM,.name = "AES-GCM"}, + { + /* tail */ + .type = RTE_CRYPTO_SYM_XFORM_NOT_SPECIFIED},}; + uint32_t i = 0; + + if (cap->op != RTE_CRYPTO_OP_TYPE_SYMMETRIC) + return -1; + + while (supported_algo[i].type != RTE_CRYPTO_SYM_XFORM_NOT_SPECIFIED) + { + if (cap->sym.xform_type == supported_algo[i].type) + { + if ((cap->sym.xform_type == RTE_CRYPTO_SYM_XFORM_CIPHER && + cap->sym.cipher.algo == supported_algo[i].cipher) || + (cap->sym.xform_type == RTE_CRYPTO_SYM_XFORM_AUTH && + cap->sym.auth.algo == supported_algo[i].auth)) + { + if (name) + strcpy (name, supported_algo[i].name); + return 0; + } + } + + i++; + } + + return -1; +} + +#endif /* __DPDK_IPSEC_H__ */ + +/* + * fd.io coding-style-patch-verification: ON + * + * Local Variables: + * eval: (c-set-style "gnu") + * End: + */ diff --git a/vnet/vnet/ipsec-gre/interface.c b/vnet/vnet/ipsec-gre/interface.c index fae79b97..56832ee1 100644 --- a/vnet/vnet/ipsec-gre/interface.c +++ b/vnet/vnet/ipsec-gre/interface.c @@ -27,7 +27,14 @@ #include #include #include + +#if DPDK_CRYPTO==1 +#include +#define ESP_NODE "dpdk-esp-encrypt" +#else #include +#define ESP_NODE "esp-encrypt" +#endif u8 * format_ipsec_gre_tunnel (u8 * s, va_list * args) @@ -186,7 +193,7 @@ vnet_ipsec_gre_add_del_tunnel (vnet_ipsec_gre_add_del_tunnel_args_t * a, hash_set (igm->tunnel_by_key, key, t - igm->tunnels); slot = vlib_node_add_named_next_with_slot - (vnm->vlib_main, hi->tx_node_index, "esp-encrypt", + (vnm->vlib_main, hi->tx_node_index, ESP_NODE, IPSEC_GRE_OUTPUT_NEXT_ESP_ENCRYPT); ASSERT (slot == IPSEC_GRE_OUTPUT_NEXT_ESP_ENCRYPT); diff --git a/vnet/vnet/ipsec/esp.h b/vnet/vnet/ipsec/esp.h index b9feacbb..50cac806 100644 --- a/vnet/vnet/ipsec/esp.h +++ b/vnet/vnet/ipsec/esp.h @@ -12,6 +12,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#ifndef __ESP_H__ +#define __ESP_H__ #include #include @@ -77,6 +79,154 @@ typedef struct esp_main_t esp_main; +#define ESP_WINDOW_SIZE (64) +#define ESP_SEQ_MAX (4294967295UL) + + +always_inline int +esp_replay_check (ipsec_sa_t * sa, u32 seq) +{ + u32 diff; + + if (PREDICT_TRUE (seq > sa->last_seq)) + return 0; + + diff = sa->last_seq - seq; + + if (ESP_WINDOW_SIZE > diff) + return (sa->replay_window & (1ULL << diff)) ? 1 : 0; + else + return 1; + + return 0; +} + +always_inline int +esp_replay_check_esn (ipsec_sa_t * sa, u32 seq) +{ + u32 tl = sa->last_seq; + u32 th = sa->last_seq_hi; + u32 diff = tl - seq; + + if (PREDICT_TRUE (tl >= (ESP_WINDOW_SIZE - 1))) + { + if (seq >= (tl - ESP_WINDOW_SIZE + 1)) + { + sa->seq_hi = th; + if (seq <= tl) + return (sa->replay_window & (1ULL << diff)) ? 1 : 0; + else + return 0; + } + else + { + sa->seq_hi = th + 1; + return 0; + } + } + else + { + if (seq >= (tl - ESP_WINDOW_SIZE + 1)) + { + sa->seq_hi = th - 1; + return (sa->replay_window & (1ULL << diff)) ? 1 : 0; + } + else + { + sa->seq_hi = th; + if (seq <= tl) + return (sa->replay_window & (1ULL << diff)) ? 1 : 0; + else + return 0; + } + } + + return 0; +} + +/* TODO seq increment should be atomic to be accessed by multiple workers */ +always_inline void +esp_replay_advance (ipsec_sa_t * sa, u32 seq) +{ + u32 pos; + + if (seq > sa->last_seq) + { + pos = seq - sa->last_seq; + if (pos < ESP_WINDOW_SIZE) + sa->replay_window = ((sa->replay_window) << pos) | 1; + else + sa->replay_window = 1; + sa->last_seq = seq; + } + else + { + pos = sa->last_seq - seq; + sa->replay_window |= (1ULL << pos); + } +} + +always_inline void +esp_replay_advance_esn (ipsec_sa_t * sa, u32 seq) +{ + int wrap = sa->seq_hi - sa->last_seq_hi; + u32 pos; + + if (wrap == 0 && seq > sa->last_seq) + { + pos = seq - sa->last_seq; + if (pos < ESP_WINDOW_SIZE) + sa->replay_window = ((sa->replay_window) << pos) | 1; + else + sa->replay_window = 1; + sa->last_seq = seq; + } + else if (wrap > 0) + { + pos = ~seq + sa->last_seq + 1; + if (pos < ESP_WINDOW_SIZE) + sa->replay_window = ((sa->replay_window) << pos) | 1; + else + sa->replay_window = 1; + sa->last_seq = seq; + sa->last_seq_hi = sa->seq_hi; + } + else if (wrap < 0) + { + pos = ~seq + sa->last_seq + 1; + sa->replay_window |= (1ULL << pos); + } + else + { + pos = sa->last_seq - seq; + sa->replay_window |= (1ULL << pos); + } +} + +always_inline int +esp_seq_advance (ipsec_sa_t * sa) +{ + if (PREDICT_TRUE (sa->use_esn)) + { + if (PREDICT_FALSE (sa->seq == ESP_SEQ_MAX)) + { + if (PREDICT_FALSE + (sa->use_anti_replay && sa->seq_hi == ESP_SEQ_MAX)) + return 1; + sa->seq_hi++; + } + sa->seq++; + } + else + { + if (PREDICT_FALSE (sa->use_anti_replay && sa->seq == ESP_SEQ_MAX)) + return 1; + sa->seq++; + } + + return 0; +} + always_inline void esp_init () { @@ -159,6 +309,7 @@ hmac_calc (ipsec_integ_alg_t alg, return em->esp_integ_algs[alg].trunc_size; } +#endif /* __ESP_H__ */ /* * fd.io coding-style-patch-verification: ON diff --git a/vnet/vnet/ipsec/esp_decrypt.c b/vnet/vnet/ipsec/esp_decrypt.c index 07a5edac..e69cd851 100644 --- a/vnet/vnet/ipsec/esp_decrypt.c +++ b/vnet/vnet/ipsec/esp_decrypt.c @@ -22,8 +22,6 @@ #include #include -#define ESP_WINDOW_SIZE 64 - #define foreach_esp_decrypt_next \ _(DROP, "error-drop") \ _(IP4_INPUT, "ip4-input") \ @@ -109,125 +107,6 @@ esp_decrypt_aes_cbc (ipsec_crypto_alg_t alg, EVP_DecryptFinal_ex (ctx, out + out_len, &out_len); } -always_inline int -esp_replay_check (ipsec_sa_t * sa, u32 seq) -{ - u32 diff; - - if (PREDICT_TRUE (seq > sa->last_seq)) - return 0; - - diff = sa->last_seq - seq; - - if (ESP_WINDOW_SIZE > diff) - return (sa->replay_window & (1ULL << diff)) ? 1 : 0; - else - return 1; - - return 0; -} - -always_inline int -esp_replay_check_esn (ipsec_sa_t * sa, u32 seq) -{ - u32 tl = sa->last_seq; - u32 th = sa->last_seq_hi; - u32 diff = tl - seq; - - if (PREDICT_TRUE (tl >= (ESP_WINDOW_SIZE - 1))) - { - if (seq >= (tl - ESP_WINDOW_SIZE + 1)) - { - sa->seq_hi = th; - if (seq <= tl) - return (sa->replay_window & (1ULL << diff)) ? 1 : 0; - else - return 0; - } - else - { - sa->seq_hi = th + 1; - return 0; - } - } - else - { - if (seq >= (tl - ESP_WINDOW_SIZE + 1)) - { - sa->seq_hi = th - 1; - return (sa->replay_window & (1ULL << diff)) ? 1 : 0; - } - else - { - sa->seq_hi = th; - if (seq <= tl) - return (sa->replay_window & (1ULL << diff)) ? 1 : 0; - else - return 0; - } - } - - return 0; -} - -always_inline void -esp_replay_advance (ipsec_sa_t * sa, u32 seq) -{ - u32 pos; - - if (seq > sa->last_seq) - { - pos = seq - sa->last_seq; - if (pos < ESP_WINDOW_SIZE) - sa->replay_window = ((sa->replay_window) << pos) | 1; - else - sa->replay_window = 1; - sa->last_seq = seq; - } - else - { - pos = sa->last_seq - seq; - sa->replay_window |= (1ULL << pos); - } -} - -always_inline void -esp_replay_advance_esn (ipsec_sa_t * sa, u32 seq) -{ - int wrap = sa->seq_hi - sa->last_seq_hi; - u32 pos; - - if (wrap == 0 && seq > sa->last_seq) - { - pos = seq - sa->last_seq; - if (pos < ESP_WINDOW_SIZE) - sa->replay_window = ((sa->replay_window) << pos) | 1; - else - sa->replay_window = 1; - sa->last_seq = seq; - } - else if (wrap > 0) - { - pos = ~seq + sa->last_seq + 1; - if (pos < ESP_WINDOW_SIZE) - sa->replay_window = ((sa->replay_window) << pos) | 1; - else - sa->replay_window = 1; - sa->last_seq = seq; - sa->last_seq_hi = sa->seq_hi; - } - else if (wrap < 0) - { - pos = ~seq + sa->last_seq + 1; - sa->replay_window |= (1ULL << pos); - } - else - { - pos = sa->last_seq - seq; - sa->replay_window |= (1ULL << pos); - } -} - static uword esp_decrypt_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * from_frame) diff --git a/vnet/vnet/ipsec/esp_encrypt.c b/vnet/vnet/ipsec/esp_encrypt.c index b7186e3d..b947611e 100644 --- a/vnet/vnet/ipsec/esp_encrypt.c +++ b/vnet/vnet/ipsec/esp_encrypt.c @@ -22,7 +22,6 @@ #include #include -#define ESP_SEQ_MAX (4294967295UL) #define foreach_esp_encrypt_next \ _(DROP, "error-drop") \ @@ -111,30 +110,6 @@ esp_encrypt_aes_cbc (ipsec_crypto_alg_t alg, EVP_EncryptFinal_ex (ctx, out + out_len, &out_len); } -always_inline int -esp_seq_advance (ipsec_sa_t * sa) -{ - if (PREDICT_TRUE (sa->use_esn)) - { - if (PREDICT_FALSE (sa->seq == ESP_SEQ_MAX)) - { - if (PREDICT_FALSE - (sa->use_anti_replay && sa->seq_hi == ESP_SEQ_MAX)) - return 1; - sa->seq_hi++; - } - sa->seq++; - } - else - { - if (PREDICT_FALSE (sa->use_anti_replay && sa->seq == ESP_SEQ_MAX)) - return 1; - sa->seq++; - } - - return 0; -} - static uword esp_encrypt_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * from_frame) diff --git a/vnet/vnet/ipsec/ipsec.c b/vnet/vnet/ipsec/ipsec.c index 223440ec..ee85c402 100644 --- a/vnet/vnet/ipsec/ipsec.c +++ b/vnet/vnet/ipsec/ipsec.c @@ -21,9 +21,25 @@ #include #include -#include #include +#if DPDK_CRYPTO==1 +#include +#define ESP_NODE "dpdk-esp-encrypt" +#else +#include +#define ESP_NODE "esp-encrypt" +#endif + +#if DPDK_CRYPTO==0 +/* dummy function */ +static int +add_del_sa_sess (u32 sa_index, u8 is_add) +{ + return 0; +} +#endif + u32 ipsec_get_sa_index_by_sa_id (u32 sa_id) { @@ -433,6 +449,7 @@ ipsec_add_del_sa (vlib_main_t * vm, ipsec_sa_t * new_sa, int is_add) return VNET_API_ERROR_SYSCALL_ERROR_1; /* sa used in policy */ } hash_unset (im->sa_index_by_sa_id, sa->id); + add_del_sa_sess (sa_index, is_add); pool_put (im->sad, sa); } else /* create new SA */ @@ -441,6 +458,8 @@ ipsec_add_del_sa (vlib_main_t * vm, ipsec_sa_t * new_sa, int is_add) clib_memcpy (sa, new_sa, sizeof (*sa)); sa_index = sa - im->sad; hash_set (im->sa_index_by_sa_id, sa->id, sa_index); + if (add_del_sa_sess (sa_index, is_add) < 0) + return VNET_API_ERROR_SYSCALL_ERROR_1; } return 0; } @@ -476,6 +495,12 @@ ipsec_set_sa_key (vlib_main_t * vm, ipsec_sa_t * sa_update) sa->integ_key_len = sa_update->integ_key_len; } + if (sa->crypto_key_len + sa->integ_key_len > 0) + { + if (add_del_sa_sess (sa_index, 0) < 0) + return VNET_API_ERROR_SYSCALL_ERROR_1; + } + return 0; } @@ -522,7 +547,8 @@ ipsec_init (vlib_main_t * vm) ASSERT (node); im->error_drop_node_index = node->index; - node = vlib_get_node_by_name (vm, (u8 *) "esp-encrypt"); + node = vlib_get_node_by_name (vm, (u8 *) ESP_NODE); + ASSERT (node); im->esp_encrypt_node_index = node->index; @@ -530,7 +556,6 @@ ipsec_init (vlib_main_t * vm) ASSERT (node); im->ip4_lookup_node_index = node->index; - if ((error = vlib_call_init_function (vm, ipsec_cli_init))) return error; diff --git a/vnet/vnet/ipsec/ipsec.h b/vnet/vnet/ipsec/ipsec.h index d33df383..65d7bad3 100644 --- a/vnet/vnet/ipsec/ipsec.h +++ b/vnet/vnet/ipsec/ipsec.h @@ -12,6 +12,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#ifndef __IPSEC_H__ +#define __IPSEC_H__ + #define IPSEC_FLAG_IPSEC_GRE_TUNNEL (1 << 0) #define foreach_ipsec_policy_action \ @@ -307,6 +310,8 @@ get_next_output_feature_node_index (vlib_buffer_t * b, return node->next_nodes[next]; } +#endif /* __IPSEC_H__ */ + /* * fd.io coding-style-patch-verification: ON * diff --git a/vnet/vnet/ipsec/ipsec_cli.c b/vnet/vnet/ipsec/ipsec_cli.c index 785e040b..8920924d 100644 --- a/vnet/vnet/ipsec/ipsec_cli.c +++ b/vnet/vnet/ipsec/ipsec_cli.c @@ -768,7 +768,6 @@ VLIB_CLI_COMMAND (set_interface_key_command, static) = { }; /* *INDENT-ON* */ - clib_error_t * ipsec_cli_init (vlib_main_t * vm) { diff --git a/vnet/vnet/ipsec/ipsec_if.c b/vnet/vnet/ipsec/ipsec_if.c index 77d5d19a..a8da046f 100644 --- a/vnet/vnet/ipsec/ipsec_if.c +++ b/vnet/vnet/ipsec/ipsec_if.c @@ -20,6 +20,20 @@ #include #include +#if DPDK_CRYPTO==1 +#include +#else +#include +#endif + +#if DPDK_CRYPTO==0 +/* dummy function */ +static int +add_del_sa_sess (u32 sa_index, u8 is_add) +{ + return 0; +} +#endif void vl_api_rpc_call_main_thread (void *fp, u8 * data, u32 data_length); @@ -124,6 +138,8 @@ ipsec_add_del_tunnel_if_internal (vnet_main_t * vnm, args->remote_crypto_key_len); } + add_del_sa_sess (t->input_sa_index, args->is_add); + pool_get (im->sad, sa); memset (sa, 0, sizeof (*sa)); t->output_sa_index = sa - im->sad; @@ -149,6 +165,8 @@ ipsec_add_del_tunnel_if_internal (vnet_main_t * vnm, args->local_crypto_key_len); } + add_del_sa_sess (t->output_sa_index, args->is_add); + hash_set (im->ipsec_if_pool_index_by_key, key, t - im->tunnel_interfaces); @@ -192,8 +210,17 @@ ipsec_add_del_tunnel_if_internal (vnet_main_t * vnm, /* delete input and output SA */ sa = pool_elt_at_index (im->sad, t->input_sa_index); + + if (add_del_sa_sess (t->input_sa_index, args->is_add) < 0) + return VNET_API_ERROR_SYSCALL_ERROR_1; + pool_put (im->sad, sa); + sa = pool_elt_at_index (im->sad, t->output_sa_index); + + if (add_del_sa_sess (t->output_sa_index, args->is_add) < 0) + return VNET_API_ERROR_SYSCALL_ERROR_1; + pool_put (im->sad, sa); hash_unset (im->ipsec_if_pool_index_by_key, key); @@ -282,6 +309,9 @@ ipsec_set_interface_key (vnet_main_t * vnm, u32 hw_if_index, sa->crypto_alg = alg; sa->crypto_key_len = vec_len (key); clib_memcpy (sa->crypto_key, key, vec_len (key)); + + if (add_del_sa_sess (t->input_sa_index, 0) < 0) + return VNET_API_ERROR_SYSCALL_ERROR_1; } else if (type == IPSEC_IF_SET_KEY_TYPE_LOCAL_INTEG) { @@ -289,6 +319,9 @@ ipsec_set_interface_key (vnet_main_t * vnm, u32 hw_if_index, sa->integ_alg = alg; sa->integ_key_len = vec_len (key); clib_memcpy (sa->integ_key, key, vec_len (key)); + + if (add_del_sa_sess (t->output_sa_index, 0) < 0) + return VNET_API_ERROR_SYSCALL_ERROR_1; } else if (type == IPSEC_IF_SET_KEY_TYPE_REMOTE_CRYPTO) { @@ -296,6 +329,9 @@ ipsec_set_interface_key (vnet_main_t * vnm, u32 hw_if_index, sa->crypto_alg = alg; sa->crypto_key_len = vec_len (key); clib_memcpy (sa->crypto_key, key, vec_len (key)); + + if (add_del_sa_sess (t->input_sa_index, 0) < 0) + return VNET_API_ERROR_SYSCALL_ERROR_1; } else if (type == IPSEC_IF_SET_KEY_TYPE_REMOTE_INTEG) { @@ -303,6 +339,9 @@ ipsec_set_interface_key (vnet_main_t * vnm, u32 hw_if_index, sa->integ_alg = alg; sa->integ_key_len = vec_len (key); clib_memcpy (sa->integ_key, key, vec_len (key)); + + if (add_del_sa_sess (t->output_sa_index, 0) < 0) + return VNET_API_ERROR_SYSCALL_ERROR_1; } else return VNET_API_ERROR_INVALID_VALUE; diff --git a/vnet/vnet/ipsec/ipsec_if_in.c b/vnet/vnet/ipsec/ipsec_if_in.c index 93cedce2..db75ab92 100644 --- a/vnet/vnet/ipsec/ipsec_if_in.c +++ b/vnet/vnet/ipsec/ipsec_if_in.c @@ -22,6 +22,12 @@ #include #include +#if DPDK_CRYPTO==1 +#define ESP_NODE "dpdk-esp-decrypt" +#else +#define ESP_NODE "esp-decrypt" +#endif + /* Statistics (not really errors) */ #define foreach_ipsec_if_input_error \ _(RX, "good packets received") @@ -153,8 +159,8 @@ VLIB_REGISTER_NODE (ipsec_if_input_node) = { .n_next_nodes = IPSEC_IF_INPUT_N_NEXT, .next_nodes = { - [IPSEC_IF_INPUT_NEXT_ESP_DECRYPT] = "esp-decrypt", - [IPSEC_IF_INPUT_NEXT_DROP] = "error-drop", + [IPSEC_IF_INPUT_NEXT_ESP_DECRYPT] = ESP_NODE, + [IPSEC_IF_INPUT_NEXT_DROP] = "error-drop", }, }; /* *INDENT-ON* */ diff --git a/vnet/vnet/ipsec/ipsec_if_out.c b/vnet/vnet/ipsec/ipsec_if_out.c index a605874e..8f062828 100644 --- a/vnet/vnet/ipsec/ipsec_if_out.c +++ b/vnet/vnet/ipsec/ipsec_if_out.c @@ -21,6 +21,11 @@ #include +#if DPDK_CRYPTO==1 +#define ESP_NODE "dpdk-esp-encrypt" +#else +#define ESP_NODE "esp-encrypt" +#endif /* Statistics (not really errors) */ #define foreach_ipsec_if_output_error \ @@ -140,7 +145,7 @@ VLIB_REGISTER_NODE (ipsec_if_output_node) = { .n_next_nodes = IPSEC_IF_OUTPUT_N_NEXT, .next_nodes = { - [IPSEC_IF_OUTPUT_NEXT_ESP_ENCRYPT] = "esp-encrypt", + [IPSEC_IF_OUTPUT_NEXT_ESP_ENCRYPT] = ESP_NODE, [IPSEC_IF_OUTPUT_NEXT_DROP] = "error-drop", }, }; diff --git a/vnet/vnet/ipsec/ipsec_input.c b/vnet/vnet/ipsec/ipsec_input.c index 8360a1d5..4662c1a1 100644 --- a/vnet/vnet/ipsec/ipsec_input.c +++ b/vnet/vnet/ipsec/ipsec_input.c @@ -23,9 +23,15 @@ #include #include +#if DPDK_CRYPTO==1 +#define ESP_NODE "dpdk-esp-decrypt" +#else +#define ESP_NODE "esp-decrypt" +#endif + #define foreach_ipsec_input_next \ _(DROP, "error-drop") \ -_(ESP_DECRYPT, "esp-decrypt") +_(ESP_DECRYPT, ESP_NODE) #define _(v, s) IPSEC_INPUT_NEXT_##v, typedef enum diff --git a/vnet/vnet/ipsec/ipsec_output.c b/vnet/vnet/ipsec/ipsec_output.c index 3810520d..97977899 100644 --- a/vnet/vnet/ipsec/ipsec_output.c +++ b/vnet/vnet/ipsec/ipsec_output.c @@ -21,11 +21,17 @@ #include +#if DPDK_CRYPTO==1 +#define ESP_NODE "dpdk-esp-encrypt" +#else +#define ESP_NODE "esp-encrypt" +#endif + #if IPSEC > 0 #define foreach_ipsec_output_next \ _(DROP, "error-drop") \ -_(ESP_ENCRYPT, "esp-encrypt") +_(ESP_ENCRYPT, ESP_NODE) #define _(v, s) IPSEC_OUTPUT_NEXT_##v, typedef enum diff --git a/vpp/Makefile.am b/vpp/Makefile.am index 52ce0655..214cc743 100644 --- a/vpp/Makefile.am +++ b/vpp/Makefile.am @@ -13,7 +13,7 @@ AUTOMAKE_OPTIONS = foreign subdir-objects -AM_CFLAGS = -Wall @DPDK@ @IPSEC@ @VCGN@ @IPV6SR@ +AM_CFLAGS = -Wall @DPDK@ @DPDK_CRYPTO@ @IPSEC@ @VCGN@ @IPV6SR@ noinst_PROGRAMS = BUILT_SOURCES = @@ -110,6 +110,9 @@ else vpp_LDFLAGS += -l:libdpdk.a endif vpp_LDFLAGS += -Wl,--no-whole-archive +if WITH_DPDK_CRYPTO +vpp_LDADD += -L$(AESNI_MULTI_BUFFER_LIB_PATH) -lIPSec_MB +endif endif vpp_LDADD += -lvppinfra -lm -lpthread -ldl diff --git a/vpp/configure.ac b/vpp/configure.ac index 0bc13e63..d36695cc 100644 --- a/vpp/configure.ac +++ b/vpp/configure.ac @@ -9,6 +9,11 @@ AC_ARG_WITH(dpdk, [with_dpdk=1], [with_dpdk=0]) +AC_ARG_WITH(dpdk_crypto, + AC_HELP_STRING([--with-dpdk-crypto],[Use DPDK cryptodev]), + [with_dpdk_crypto=1], + [with_dpdk_crypto=0]) + AC_ARG_ENABLE(dpdk-shared, AC_HELP_STRING([--enable-dpdk-shared],[Link with DPDK shared lib]), [enable_dpdk_shared=1], @@ -32,6 +37,9 @@ AC_ARG_WITH(ipv6sr, AM_CONDITIONAL(WITH_DPDK, test "$with_dpdk" = "1") AM_CONDITIONAL(ENABLE_DPDK_SHARED, test "$enable_dpdk_shared" = "1") AC_SUBST(DPDK,["-DDPDK=${with_dpdk} -DDPDK_SHARED_LIB=${enable_dpdk_shared}"]) +AM_CONDITIONAL(WITH_DPDK_CRYPTO, test "$with_dpdk_crypto" = "1") +AC_SUBST(DPDK_CRYPTO,[-DDPDK_CRYPTO=${with_dpdk_crypto}]) + AM_COND_IF( [ENABLE_DPDK_SHARED], -- cgit 1.2.3-korg From 696f1adec0df3b8f161862566dd9c86174302658 Mon Sep 17 00:00:00 2001 From: Damjan Marion Date: Fri, 23 Dec 2016 22:42:41 +0100 Subject: dpdk: Add support for Mellanox ConnectX-4 devices Due to external library dependency support for Mellanox devices is disabled. To enable it uncoment following line: vpp_uses_dpdk_mlx5_pmd = yes in build-data/platforms/vpp.mk and install OFED libraries. Change-Id: I131d52b5d449a958349f31f9cc04311948f78b71 Signed-off-by: Damjan Marion --- build-data/packages/dpdk.mk | 5 +++ build-data/packages/vnet.mk | 3 ++ build-data/packages/vpp.mk | 3 ++ build-data/platforms/vpp.mk | 1 + dpdk/Makefile | 4 +- vnet/vnet/devices/dpdk/dpdk.h | 2 + vnet/vnet/devices/dpdk/dpdk_priv.h | 9 +--- vnet/vnet/devices/dpdk/format.c | 8 ++++ vnet/vnet/devices/dpdk/init.c | 86 ++++++++++++++++++++++++++------------ vpp/Makefile.am | 3 ++ vpp/configure.ac | 7 +++- 11 files changed, 96 insertions(+), 35 deletions(-) (limited to 'build-data/platforms/vpp.mk') diff --git a/build-data/packages/dpdk.mk b/build-data/packages/dpdk.mk index a529e365..2dcf4093 100644 --- a/build-data/packages/dpdk.mk +++ b/build-data/packages/dpdk.mk @@ -27,6 +27,11 @@ ifneq ($(DPDK_CRYPTO_PMD),) DPDK_MAKE_ARGS += DPDK_CRYPTO_PMD=y endif +DPDK_MLX5_PMD=$(strip $($(PLATFORM)_uses_dpdk_mlx5_pmd)) +ifneq ($(DPDK_MLX5_PMD),) +DPDK_MAKE_ARGS += DPDK_MLX5_PMD=y +endif + DPDK_PLATFORM_TARGET=$(strip $($(PLATFORM)_dpdk_target)) ifneq ($(DPDK_PLATFORM_TARGET),) DPDK_MAKE_ARGS += DPDK_TARGET=$(DPDK_PLATFORM_TARGET) diff --git a/build-data/packages/vnet.mk b/build-data/packages/vnet.mk index 399ca1b4..57c444e8 100644 --- a/build-data/packages/vnet.mk +++ b/build-data/packages/vnet.mk @@ -41,4 +41,7 @@ endif ifeq ($($(PLATFORM)_uses_dpdk_cryptodev),yes) vnet_configure_args += --with-dpdk-crypto endif +ifeq ($($(PLATFORM)_uses_dpdk_mlx5_pmd),yes) +vnet_configure_args += --with-dpdk-mlx5-pmd +endif endif diff --git a/build-data/packages/vpp.mk b/build-data/packages/vpp.mk index 6831c6b8..a3d60528 100644 --- a/build-data/packages/vpp.mk +++ b/build-data/packages/vpp.mk @@ -48,4 +48,7 @@ endif ifeq ($($(PLATFORM)_uses_dpdk_cryptodev),yes) vpp_configure_args += --with-dpdk-crypto endif +ifeq ($($(PLATFORM)_uses_dpdk_mlx5_pmd),yes) +vpp_configure_args += --with-dpdk-mlx5-pmd +endif endif diff --git a/build-data/platforms/vpp.mk b/build-data/platforms/vpp.mk index 15d4dc39..97ddc57d 100644 --- a/build-data/platforms/vpp.mk +++ b/build-data/platforms/vpp.mk @@ -42,6 +42,7 @@ plugins_configure_args_vpp = --with-dpdk # DPDK configuration parameters # vpp_uses_dpdk_cryptodev = yes +# vpp_uses_dpdk_mlx5_pmd = yes # vpp_uses_external_dpdk = yes # vpp_dpdk_inc_dir = /usr/include/dpdk # vpp_dpdk_lib_dir = /usr/lib diff --git a/dpdk/Makefile b/dpdk/Makefile index 46cc3db1..178c30c6 100644 --- a/dpdk/Makefile +++ b/dpdk/Makefile @@ -21,7 +21,8 @@ DPDK_DOWNLOAD_DIR ?= $(HOME)/Downloads DPDK_MARCH ?= native DPDK_TUNE ?= generic DPDK_DEBUG ?= n -DPDK_CRYPTO_PMD ?= n +DPDK_CRYPTO_PMD ?= n +DPDK_MLX5_PMD ?= n B := $(DPDK_BUILD_DIR) I := $(DPDK_INSTALL_DIR) @@ -122,6 +123,7 @@ $(B)/custom-config: $(B)/.patch.ok Makefile $(call set,RTE_LIBRTE_PMD_AESNI_MB,$(DPDK_CRYPTO_PMD)) $(call set,RTE_LIBRTE_PMD_AESNI_GCM,$(DPDK_CRYPTO_PMD)) $(call set,RTE_LIBRTE_PMD_QAT,$(DPDK_CRYPTO_PMD)) + $(call set,RTE_LIBRTE_MLX5_PMD,$(DPDK_MLX5_PMD)) @# not needed $(call set,RTE_LIBRTE_TIMER,n) $(call set,RTE_LIBRTE_CFGFILE,n) diff --git a/vnet/vnet/devices/dpdk/dpdk.h b/vnet/vnet/devices/dpdk/dpdk.h index 3669bc5f..d8f378d2 100644 --- a/vnet/vnet/devices/dpdk/dpdk.h +++ b/vnet/vnet/devices/dpdk/dpdk.h @@ -83,6 +83,7 @@ extern vlib_node_registration_t handoff_dispatch_node; _ ("rte_bond_pmd", BOND) \ _ ("net_fm10k", FM10K) \ _ ("net_cxgbe", CXGBE) \ + _ ("net_mlx5", MLX5) \ _ ("net_dpaa2", DPAA2) #else #define foreach_dpdk_pmd \ @@ -118,6 +119,7 @@ typedef enum VNET_DPDK_PORT_TYPE_ETH_1G, VNET_DPDK_PORT_TYPE_ETH_10G, VNET_DPDK_PORT_TYPE_ETH_40G, + VNET_DPDK_PORT_TYPE_ETH_100G, VNET_DPDK_PORT_TYPE_ETH_BOND, VNET_DPDK_PORT_TYPE_ETH_SWITCH, VNET_DPDK_PORT_TYPE_AF_PACKET, diff --git a/vnet/vnet/devices/dpdk/dpdk_priv.h b/vnet/vnet/devices/dpdk/dpdk_priv.h index eb13df2c..0c81dbc3 100644 --- a/vnet/vnet/devices/dpdk/dpdk_priv.h +++ b/vnet/vnet/devices/dpdk/dpdk_priv.h @@ -13,15 +13,10 @@ * limitations under the License. */ -#define DPDK_NB_RX_DESC_DEFAULT 512 -#define DPDK_NB_TX_DESC_DEFAULT 512 +#define DPDK_NB_RX_DESC_DEFAULT 1024 +#define DPDK_NB_TX_DESC_DEFAULT 1024 #define DPDK_NB_RX_DESC_VIRTIO 256 #define DPDK_NB_TX_DESC_VIRTIO 256 -#define DPDK_NB_RX_DESC_10GE 1024 -#define DPDK_NB_TX_DESC_10GE 1024 -#define DPDK_NB_RX_DESC_40GE 1024 -#define DPDK_NB_TX_DESC_40GE 1024 -#define DPDK_NB_RX_DESC_ENIC 1024 #define I40E_DEV_ID_SFP_XL710 0x1572 #define I40E_DEV_ID_QSFP_A 0x1583 diff --git a/vnet/vnet/devices/dpdk/format.c b/vnet/vnet/devices/dpdk/format.c index 0b8a6939..ff7c7a5a 100644 --- a/vnet/vnet/devices/dpdk/format.c +++ b/vnet/vnet/devices/dpdk/format.c @@ -184,6 +184,10 @@ format_dpdk_device_name (u8 * s, va_list * args) device_name = "FortyGigabitEthernet"; break; + case VNET_DPDK_PORT_TYPE_ETH_100G: + device_name = "HundredGigabitEthernet"; + break; + case VNET_DPDK_PORT_TYPE_ETH_BOND: return format (s, "BondEthernet%d", dm->devices[i].device_index); @@ -268,6 +272,10 @@ format_dpdk_device_type (u8 * s, va_list * args) dev_type = "Chelsio T4/T5"; break; + case VNET_DPDK_PMD_MLX5: + dev_type = "Mellanox ConnectX-4 Family"; + break; + case VNET_DPDK_PMD_VMXNET3: dev_type = "VMware VMXNET3"; break; diff --git a/vnet/vnet/devices/dpdk/init.c b/vnet/vnet/devices/dpdk/init.c index 0448c15f..693ca985 100755 --- a/vnet/vnet/devices/dpdk/init.c +++ b/vnet/vnet/devices/dpdk/init.c @@ -293,11 +293,6 @@ dpdk_lib_init (dpdk_main_t * dm) vec_validate_aligned (dm->hqos_threads, tm->n_vlib_mains - 1, CLIB_CACHE_LINE_BYTES); -#ifdef NETMAP - if (rte_netmap_probe () < 0) - return clib_error_return (0, "rte netmap probe failed"); -#endif - nports = rte_eth_dev_count (); if (nports < 1) { @@ -448,6 +443,9 @@ dpdk_lib_init (dpdk_main_t * dm) else xd->pmd = VNET_DPDK_PMD_UNKNOWN; + xd->port_type = VNET_DPDK_PORT_TYPE_UNKNOWN; + xd->nb_rx_desc = DPDK_NB_RX_DESC_DEFAULT; + xd->nb_tx_desc = DPDK_NB_TX_DESC_DEFAULT; switch (xd->pmd) { @@ -463,8 +461,6 @@ dpdk_lib_init (dpdk_main_t * dm) case VNET_DPDK_PMD_IXGBEVF: case VNET_DPDK_PMD_THUNDERX: xd->port_type = VNET_DPDK_PORT_TYPE_ETH_10G; - xd->nb_rx_desc = DPDK_NB_RX_DESC_10GE; - xd->nb_tx_desc = DPDK_NB_TX_DESC_10GE; break; case VNET_DPDK_PMD_DPAA2: xd->port_type = VNET_DPDK_PORT_TYPE_ETH_10G; @@ -474,17 +470,10 @@ dpdk_lib_init (dpdk_main_t * dm) case VNET_DPDK_PMD_ENIC: rte_eth_link_get_nowait (i, &l); xd->flags |= DPDK_DEVICE_FLAG_PMD_SUPPORTS_PTYPE; - xd->nb_rx_desc = DPDK_NB_RX_DESC_ENIC; if (l.link_speed == 40000) - { - xd->port_type = VNET_DPDK_PORT_TYPE_ETH_40G; - xd->nb_tx_desc = DPDK_NB_TX_DESC_40GE; - } + xd->port_type = VNET_DPDK_PORT_TYPE_ETH_40G; else - { - xd->port_type = VNET_DPDK_PORT_TYPE_ETH_10G; - xd->nb_tx_desc = DPDK_NB_TX_DESC_10GE; - } + xd->port_type = VNET_DPDK_PORT_TYPE_ETH_10G; break; /* Intel Fortville */ @@ -492,8 +481,6 @@ dpdk_lib_init (dpdk_main_t * dm) case VNET_DPDK_PMD_I40EVF: xd->flags |= DPDK_DEVICE_FLAG_PMD_SUPPORTS_PTYPE; xd->port_type = VNET_DPDK_PORT_TYPE_ETH_40G; - xd->nb_rx_desc = DPDK_NB_RX_DESC_40GE; - xd->nb_tx_desc = DPDK_NB_TX_DESC_40GE; switch (dev_info.pci_dev->id.device_id) { @@ -521,27 +508,74 @@ dpdk_lib_init (dpdk_main_t * dm) { case 0x540d: /* T580-CR */ case 0x5410: /* T580-LP-cr */ - xd->nb_rx_desc = DPDK_NB_RX_DESC_40GE; - xd->nb_tx_desc = DPDK_NB_TX_DESC_40GE; xd->port_type = VNET_DPDK_PORT_TYPE_ETH_40G; break; case 0x5403: /* T540-CR */ - xd->nb_rx_desc = DPDK_NB_RX_DESC_10GE; - xd->nb_tx_desc = DPDK_NB_TX_DESC_10GE; xd->port_type = VNET_DPDK_PORT_TYPE_ETH_10G; break; default: - xd->nb_rx_desc = DPDK_NB_RX_DESC_10GE; - xd->nb_tx_desc = DPDK_NB_TX_DESC_10GE; xd->port_type = VNET_DPDK_PORT_TYPE_UNKNOWN; } break; + case VNET_DPDK_PMD_MLX5: + { + char *pn_100g[] = { "MCX415A-CCAT", "MCX416A-CCAT", 0 }; + char *pn_40g[] = { "MCX413A-BCAT", "MCX414A-BCAT", + "MCX415A-BCAT", "MCX416A-BCAT", "MCX4131A-BCAT", 0 + }; + char *pn_10g[] = { "MCX4111A-XCAT", "MCX4121A-XCAT", 0 }; + + vlib_pci_device_t *pd = vlib_get_pci_device (&pci_addr); + u8 *pn = 0; + char **c; + int found = 0; + pn = format (0, "%U%c", + format_vlib_pci_vpd, pd->vpd_r, "PN", 0); + + if (!pn) + break; + + c = pn_100g; + while (!found && c[0]) + { + if (strncmp ((char *) pn, c[0], strlen (c[0])) == 0) + { + xd->port_type = VNET_DPDK_PORT_TYPE_ETH_100G; + break; + } + c++; + } + + c = pn_40g; + while (!found && c[0]) + { + if (strncmp ((char *) pn, c[0], strlen (c[0])) == 0) + { + xd->port_type = VNET_DPDK_PORT_TYPE_ETH_40G; + break; + } + c++; + } + + c = pn_10g; + while (!found && c[0]) + { + if (strncmp ((char *) pn, c[0], strlen (c[0])) == 0) + { + xd->port_type = VNET_DPDK_PORT_TYPE_ETH_10G; + break; + } + c++; + } + + vec_free (pn); + } + + break; /* Intel Red Rock Canyon */ case VNET_DPDK_PMD_FM10K: xd->port_type = VNET_DPDK_PORT_TYPE_ETH_SWITCH; - xd->nb_rx_desc = DPDK_NB_RX_DESC_40GE; - xd->nb_tx_desc = DPDK_NB_TX_DESC_40GE; break; /* virtio */ diff --git a/vpp/Makefile.am b/vpp/Makefile.am index f90cb647..25d72749 100644 --- a/vpp/Makefile.am +++ b/vpp/Makefile.am @@ -121,6 +121,9 @@ vpp_LDFLAGS += -Wl,--no-whole-archive if WITH_DPDK_CRYPTO vpp_LDADD += -L$(AESNI_MULTI_BUFFER_LIB_PATH) -lIPSec_MB endif +if WITH_DPDK_MLX5_PMD +vpp_LDFLAGS += -libverbs -lmlx5 -lnuma +endif endif vpp_LDADD += -lvppinfra -lm -lpthread -ldl diff --git a/vpp/configure.ac b/vpp/configure.ac index 2ade3d2a..8c333fd1 100644 --- a/vpp/configure.ac +++ b/vpp/configure.ac @@ -14,6 +14,11 @@ AC_ARG_WITH(dpdk_crypto, [with_dpdk_crypto=1], [with_dpdk_crypto=0]) +AC_ARG_WITH(dpdk_mlx5_pmd, + AC_HELP_STRING([--with-dpdk-mlx5-pmd],[Use Mellanox ConnetxX-4 DPDK PMD]), + [with_dpdk_mlx5_pmd=1], + [with_dpdk_mlx5_pmd=0]) + AC_ARG_ENABLE(dpdk-shared, AC_HELP_STRING([--enable-dpdk-shared],[Link with DPDK shared lib]), [enable_dpdk_shared=1], @@ -44,7 +49,7 @@ AM_CONDITIONAL(ENABLE_DPDK_SHARED, test "$enable_dpdk_shared" = "1") AC_SUBST(DPDK,["-DDPDK=${with_dpdk} -DDPDK_SHARED_LIB=${enable_dpdk_shared}"]) AM_CONDITIONAL(WITH_DPDK_CRYPTO, test "$with_dpdk_crypto" = "1") AC_SUBST(DPDK_CRYPTO,[-DDPDK_CRYPTO=${with_dpdk_crypto}]) - +AM_CONDITIONAL(WITH_DPDK_MLX5_PMD, test "$with_dpdk_mlx5_pmd" = "1") AM_COND_IF( [ENABLE_DPDK_SHARED], -- cgit 1.2.3-korg From 7cd468a3d7dee7d6c92f69a0bb7061ae208ec727 Mon Sep 17 00:00:00 2001 From: Damjan Marion Date: Mon, 19 Dec 2016 23:05:39 +0100 Subject: Reorganize source tree to use single autotools instance Change-Id: I7b51f88292e057c6443b12224486f2d0c9f8ae23 Signed-off-by: Damjan Marion --- Makefile | 4 +- build-data/packages/cavium-dpdk.mk | 55 - build-data/packages/g2.mk | 6 +- build-data/packages/gmod.mk | 6 +- build-data/packages/perftool.mk | 5 +- build-data/packages/plugins.mk | 25 +- build-data/packages/src.mk | 0 build-data/packages/svm.mk | 5 - build-data/packages/vlib-api-cavium-dpdk.mk | 6 - build-data/packages/vlib-api.mk | 4 - build-data/packages/vlib-cavium-dpdk.mk | 7 - build-data/packages/vlib.mk | 16 - build-data/packages/vnet-cavium-dpdk.mk | 29 - build-data/packages/vpp-api-test-cavium-dpdk.mk | 32 - build-data/packages/vpp-api-test.mk | 39 - build-data/packages/vpp-api.mk | 16 +- build-data/packages/vpp-cavium-dpdk.mk | 30 - build-data/packages/vpp.mk | 29 +- build-data/packages/vppinfra.mk | 5 - build-data/platforms.mk | 6 +- build-data/platforms/vpp.mk | 4 +- build-data/platforms/vpp_lite.mk | 3 +- build-data/suffix-rules.mk | 27 - build-root/bootstrap.sh | 2 +- build-root/packages/src.mk | 4 + build-root/packages/tools.mk | 3 + build-root/packages/vppapigen.mk | 5 - build-root/rpm/vpp.spec | 24 +- build-root/scripts/find-plugins-contents | 6 +- build-root/scripts/find-python-api-contents | 2 +- g2/Makefile.am | 34 - g2/clib.c | 154 - g2/configure.ac | 12 - g2/cpel.c | 470 - g2/cpel.h | 83 - g2/events.c | 475 - g2/g2.h | 195 - g2/g2version.c | 19 - g2/main.c | 196 - g2/menu1.c | 565 - g2/mkversion.c | 77 - g2/pointsel.c | 854 - g2/props.c | 279 - g2/props.h | 21 - g2/view1.c | 3077 ---- gmod/gmod/mod_vpp.c | 2 +- perftool/Makefile.am | 44 - perftool/c2cpel.c | 248 - perftool/configure.ac | 12 - perftool/cpel.h | 83 - perftool/cpel_util.c | 456 - perftool/cpel_util.h | 68 - perftool/cpelatency.c | 927 - perftool/cpeldump.c | 638 - perftool/cpelinreg.c | 892 - perftool/cpelstate.c | 822 - perftool/delsvec.c | 315 - perftool/linreg.c | 78 - perftool/new.cpel | Bin 1672 -> 0 bytes perftool/new.elog | Bin 4525 -> 0 bytes perftool/props.c | 280 - plugins/Makefile.am | 12 - plugins/configure.ac | 3 - plugins/flowperpkt-plugin/Makefile.am | 64 - plugins/flowperpkt-plugin/configure.ac | 9 - .../flowperpkt-plugin/flowperpkt/flowperpkt.api | 42 - plugins/flowperpkt-plugin/flowperpkt/flowperpkt.c | 671 - plugins/flowperpkt-plugin/flowperpkt/flowperpkt.h | 90 - .../flowperpkt/flowperpkt_all_api_h.h | 18 - .../flowperpkt/flowperpkt_msg_enum.h | 31 - .../flowperpkt-plugin/flowperpkt/flowperpkt_test.c | 234 - plugins/flowperpkt-plugin/flowperpkt/l2_node.c | 561 - plugins/flowperpkt-plugin/flowperpkt/node.c | 574 - plugins/flowperpkt-plugin/flowperpkt_plugin_doc.md | 13 - plugins/ila-plugin/Makefile.am | 29 - plugins/ila-plugin/configure.ac | 9 - plugins/ila-plugin/ila/ila.c | 1070 -- plugins/ila-plugin/ila/ila.h | 116 - plugins/sixrd-plugin/Makefile.am | 38 - plugins/sixrd-plugin/configure.ac | 9 - plugins/sixrd-plugin/sixrd/ip4_sixrd.c | 127 - plugins/sixrd-plugin/sixrd/ip6_sixrd.c | 129 - plugins/sixrd-plugin/sixrd/sixrd.c | 369 - plugins/sixrd-plugin/sixrd/sixrd.h | 141 - plugins/sixrd-plugin/sixrd/sixrd_dpo.c | 132 - plugins/sixrd-plugin/sixrd/sixrd_dpo.h | 61 - src/Makefile.am | 101 + src/configure.ac | 195 + src/examples/vlib/dir.dox | 22 + src/examples/vlib/main_stub.c | 418 + src/examples/vlib/mc_test.c | 384 + src/examples/vlib/plex_test.c | 527 + src/g2.am | 32 + src/perftool.am | 41 + src/plugins/Makefile.am | 60 + src/plugins/flowperpkt.am | 38 + src/plugins/flowperpkt/flowperpkt.api | 42 + src/plugins/flowperpkt/flowperpkt.c | 671 + src/plugins/flowperpkt/flowperpkt.h | 90 + src/plugins/flowperpkt/flowperpkt_all_api_h.h | 18 + src/plugins/flowperpkt/flowperpkt_msg_enum.h | 31 + src/plugins/flowperpkt/flowperpkt_plugin_doc.md | 13 + src/plugins/flowperpkt/flowperpkt_test.c | 234 + src/plugins/flowperpkt/l2_node.c | 561 + src/plugins/flowperpkt/node.c | 574 + src/plugins/ila.am | 20 + src/plugins/ila/ila.c | 1070 ++ src/plugins/ila/ila.h | 116 + src/plugins/sixrd.am | 26 + src/plugins/sixrd/ip4_sixrd.c | 127 + src/plugins/sixrd/ip6_sixrd.c | 129 + src/plugins/sixrd/sixrd.c | 369 + src/plugins/sixrd/sixrd.h | 141 + src/plugins/sixrd/sixrd_dpo.c | 132 + src/plugins/sixrd/sixrd_dpo.h | 61 + src/scripts/vnet/arp4 | 21 + src/scripts/vnet/arp4-mpls | 24 + src/scripts/vnet/arp6 | 21 + src/scripts/vnet/bvi | 76 + src/scripts/vnet/dhcp/dhcpd.conf | 8 + src/scripts/vnet/dhcp/left-ping-target.sh | 4 + src/scripts/vnet/dhcp/leftpeer.conf | 17 + src/scripts/vnet/icmp | 16 + src/scripts/vnet/icmp6 | 16 + src/scripts/vnet/ige | 19 + src/scripts/vnet/ip6 | 15 + src/scripts/vnet/ip6-hbh | 84 + src/scripts/vnet/ixge | 15 + src/scripts/vnet/l2efpfilter | 83 + src/scripts/vnet/l2efpfilter_perf | 58 + src/scripts/vnet/l2fib | 46 + src/scripts/vnet/l2fib_perf | 29 + src/scripts/vnet/l2fib_xc | 31 + src/scripts/vnet/l2flood | 42 + src/scripts/vnet/l2tp | 134 + src/scripts/vnet/leftpeer/leftpeer-classify | 8 + src/scripts/vnet/leftpeer/leftpeer-classify6 | 5 + src/scripts/vnet/leftpeer/leftpeer-classifyl2 | 8 + src/scripts/vnet/leftpeer/leftpeer-dhcp | 23 + src/scripts/vnet/leftpeer/leftpeer-ioam.conf | 15 + src/scripts/vnet/leftpeer/leftpeer-l3vxlan.conf | 12 + src/scripts/vnet/leftpeer/leftpeer-lisp.conf | 18 + src/scripts/vnet/leftpeer/leftpeer-mpls.conf | 17 + src/scripts/vnet/leftpeer/leftpeer-sr.conf | 24 + src/scripts/vnet/leftpeer/leftpeer-vxlan.conf | 17 + src/scripts/vnet/leftpeer/leftpeer.script | 9 + src/scripts/vnet/lfib/ip4-to-mpls | 26 + src/scripts/vnet/lfib/mpls-pop-to-mpls | 28 + src/scripts/vnet/lfib/mpls-to-ip4 | 27 + src/scripts/vnet/lfib/mpls-to-mpls | 26 + src/scripts/vnet/mpls-o-ethernet/leftpeer.conf | 17 + src/scripts/vnet/mpls-o-ethernet/pg | 10 + src/scripts/vnet/mpls-o-ethernet/rightpeer.conf | 15 + src/scripts/vnet/mpls-o-ethernet/single.conf | 17 + src/scripts/vnet/mpls-o-gre/dhcpd.conf | 116 + src/scripts/vnet/mpls-o-gre/leftpeer.conf | 14 + src/scripts/vnet/mpls-o-gre/rightpeer.conf | 14 + src/scripts/vnet/mpls-tunnel | 87 + src/scripts/vnet/pcap | 18 + src/scripts/vnet/probe4 | 11 + src/scripts/vnet/probe6 | 7 + src/scripts/vnet/rewrite | 62 + src/scripts/vnet/rightpeer/rightpeer-ioam.conf | 14 + src/scripts/vnet/rightpeer/rightpeer-l3vxlan.conf | 9 + src/scripts/vnet/rightpeer/rightpeer-lisp.conf | 16 + src/scripts/vnet/rightpeer/rightpeer-mpls-l2.conf | 24 + src/scripts/vnet/rightpeer/rightpeer-mpls.conf | 17 + src/scripts/vnet/rightpeer/rightpeer-sr.conf | 28 + src/scripts/vnet/rightpeer/rightpeer-vxlan.conf | 16 + src/scripts/vnet/rightpeer/rightpeer.script | 9 + src/scripts/vnet/rpf | 18 + src/scripts/vnet/rtt-test | 31 + src/scripts/vnet/snat | 34 + src/scripts/vnet/snat_static | 44 + src/scripts/vnet/snat_static_with_port | 44 + src/scripts/vnet/source_and_port_range_check | 63 + src/scripts/vnet/speed | 14 + src/scripts/vnet/sr/left-linux-ping.sh | 3 + src/scripts/vnet/sr/leftpeer.conf | 27 + src/scripts/vnet/sr/right-linux-ping.sh | 4 + src/scripts/vnet/sr/rightpeer.conf | 22 + src/scripts/vnet/sr/srlocal.sh | 4 + src/scripts/vnet/srp | 27 + src/scripts/vnet/tcp | 16 + src/scripts/vnet/tcp-test | 6 + src/scripts/vnet/tf-ucs-1 | 16 + src/scripts/vnet/urpf | 86 + src/scripts/vnet/virl/ip6sr.virl | 874 + src/scripts/vnet/virl/ip6sr_notes.txt | 38 + src/scripts/vnet/virl/mplsogre.virl | 319 + src/scripts/vnet/virl/simple.virl | 389 + src/scripts/vnet/vlan | 23 + src/scripts/vppctl | 121 + src/suffix-rules.mk | 27 + src/svm.am | 31 + src/svm/dir.dox | 21 + src/svm/persist.c | 258 + src/svm/ssvm.c | 178 + src/svm/ssvm.h | 155 + src/svm/svm.c | 1237 ++ src/svm/svm.h | 207 + src/svm/svm_test.c | 79 + src/svm/svmdb.c | 671 + src/svm/svmdb.h | 135 + src/svm/svmdbtool.c | 537 + src/svm/svmtool.c | 528 + src/tests/vnet/README | 10 + src/tests/vnet/lisp-cp/test_cp_serdes.c | 639 + src/tests/vnet/lisp-cp/test_lisp_types.c | 565 + src/tests/vnet/lisp-gpe/test.c | 18 + src/tools/elftool/dir.dox | 19 + src/tools/elftool/elftool.c | 464 + src/tools/g2/clib.c | 154 + src/tools/g2/configure.ac | 12 + src/tools/g2/cpel.c | 470 + src/tools/g2/cpel.h | 83 + src/tools/g2/events.c | 475 + src/tools/g2/g2.h | 195 + src/tools/g2/g2version.c | 19 + src/tools/g2/main.c | 196 + src/tools/g2/menu1.c | 565 + src/tools/g2/mkversion.c | 77 + src/tools/g2/pointsel.c | 854 + src/tools/g2/props.c | 279 + src/tools/g2/props.h | 21 + src/tools/g2/view1.c | 3077 ++++ src/tools/perftool/c2cpel.c | 248 + src/tools/perftool/configure.ac | 12 + src/tools/perftool/cpel.h | 83 + src/tools/perftool/cpel_util.c | 456 + src/tools/perftool/cpel_util.h | 68 + src/tools/perftool/cpelatency.c | 927 + src/tools/perftool/cpeldump.c | 638 + src/tools/perftool/cpelinreg.c | 892 + src/tools/perftool/cpelstate.c | 822 + src/tools/perftool/delsvec.c | 315 + src/tools/perftool/linreg.c | 78 + src/tools/perftool/new.cpel | Bin 0 -> 1672 bytes src/tools/perftool/new.elog | Bin 0 -> 4525 bytes src/tools/perftool/props.c | 280 + src/tools/vppapigen/configure.ac | 14 + src/tools/vppapigen/gram.y | 90 + src/tools/vppapigen/lex.c | 1067 ++ src/tools/vppapigen/lex.h | 50 + src/tools/vppapigen/node.c | 1527 ++ src/tools/vppapigen/node.h | 94 + src/vat/api_format.c | 17829 +++++++++++++++++++ src/vat/json_format.c | 304 + src/vat/json_format.h | 254 + src/vat/json_test.c | 75 + src/vat/main.c | 421 + src/vat/plugin.c | 201 + src/vat/plugin.h | 61 + src/vat/plugin_api.c | 216 + src/vat/restart.c | 246 + src/vat/vat.h | 257 + src/vlib-api.am | 73 + src/vlib.am | 103 + src/vlib/buffer.c | 1987 +++ src/vlib/buffer.h | 417 + src/vlib/buffer_funcs.h | 755 + src/vlib/buffer_node.h | 337 + src/vlib/cli.c | 1173 ++ src/vlib/cli.h | 192 + src/vlib/cli_funcs.h | 58 + src/vlib/counter.c | 151 + src/vlib/counter.h | 379 + src/vlib/defs.h | 82 + src/vlib/dir.dox | 23 + src/vlib/elog_samples.c | 122 + src/vlib/error.c | 338 + src/vlib/error.h | 101 + src/vlib/error_funcs.h | 88 + src/vlib/format.c | 196 + src/vlib/format_funcs.h | 75 + src/vlib/global_funcs.h | 45 + src/vlib/i2c.c | 231 + src/vlib/i2c.h | 67 + src/vlib/init.c | 168 + src/vlib/init.h | 238 + src/vlib/lex.c | 271 + src/vlib/lex.h | 145 + src/vlib/main.c | 1703 ++ src/vlib/main.h | 333 + src/vlib/mc.c | 2609 +++ src/vlib/mc.h | 687 + src/vlib/node.c | 631 + src/vlib/node.h | 725 + src/vlib/node_cli.c | 466 + src/vlib/node_format.c | 187 + src/vlib/node_funcs.h | 1130 ++ src/vlib/parse.c | 1007 ++ src/vlib/parse.h | 221 + src/vlib/parse_builtin.c | 150 + src/vlib/pci/linux_pci.c | 642 + src/vlib/pci/pci.c | 264 + src/vlib/pci/pci.h | 251 + src/vlib/pci/pci_config.h | 731 + src/vlib/physmem.h | 108 + src/vlib/threads.c | 1492 ++ src/vlib/threads.h | 470 + src/vlib/threads_cli.c | 579 + src/vlib/trace.c | 545 + src/vlib/trace.h | 100 + src/vlib/trace_funcs.h | 185 + src/vlib/unix/cj.c | 271 + src/vlib/unix/cj.h | 79 + src/vlib/unix/cli.c | 2989 ++++ src/vlib/unix/dir.dox | 28 + src/vlib/unix/input.c | 265 + src/vlib/unix/main.c | 557 + src/vlib/unix/mc_socket.c | 1049 ++ src/vlib/unix/mc_socket.h | 137 + src/vlib/unix/physmem.c | 470 + src/vlib/unix/physmem.h | 65 + src/vlib/unix/plugin.c | 260 + src/vlib/unix/plugin.h | 98 + src/vlib/unix/unix.h | 232 + src/vlib/unix/util.c | 231 + src/vlib/vlib.h | 86 + src/vlib/vlib_process_doc.h | 147 + src/vlibapi/api.h | 281 + src/vlibapi/api_helper_macros.h | 243 + src/vlibapi/api_shared.c | 1375 ++ src/vlibapi/node_serialize.c | 399 + src/vlibmemory/api.h | 163 + src/vlibmemory/memclnt.api | 91 + src/vlibmemory/memory_client.c | 283 + src/vlibmemory/memory_shared.c | 852 + src/vlibmemory/memory_vlib.c | 1346 ++ src/vlibmemory/unix_shared_memory_queue.c | 324 + src/vlibmemory/unix_shared_memory_queue.h | 69 + src/vlibmemory/vl_memory_api_h.h | 32 + src/vlibmemory/vl_memory_msg_enum.h | 42 + src/vlibsocket/api.h | 87 + src/vlibsocket/sock_test.c | 155 + src/vlibsocket/sockclnt.api | 50 + src/vlibsocket/sockclnt_vlib.c | 209 + src/vlibsocket/socksvr_vlib.c | 706 + src/vlibsocket/vl_socket_api_h.h | 33 + src/vlibsocket/vl_socket_msg_enum.h | 42 + src/vnet.am | 972 + src/vnet/adj/adj.c | 454 + src/vnet/adj/adj.h | 122 + src/vnet/adj/adj_glean.c | 285 + src/vnet/adj/adj_glean.h | 61 + src/vnet/adj/adj_internal.h | 104 + src/vnet/adj/adj_l2.c | 194 + src/vnet/adj/adj_l2.h | 24 + src/vnet/adj/adj_midchain.c | 559 + src/vnet/adj/adj_midchain.h | 102 + src/vnet/adj/adj_nbr.c | 1087 ++ src/vnet/adj/adj_nbr.h | 176 + src/vnet/adj/adj_rewrite.c | 53 + src/vnet/adj/adj_rewrite.h | 49 + src/vnet/adj/adj_types.h | 53 + src/vnet/api_errno.h | 113 + src/vnet/bfd/bfd.api | 205 + src/vnet/bfd/bfd_api.c | 262 + src/vnet/bfd/bfd_api.h | 46 + src/vnet/bfd/bfd_debug.h | 79 + src/vnet/bfd/bfd_doc.md | 1 + src/vnet/bfd/bfd_main.c | 969 + src/vnet/bfd/bfd_main.h | 220 + src/vnet/bfd/bfd_protocol.c | 74 + src/vnet/bfd/bfd_protocol.h | 154 + src/vnet/bfd/bfd_udp.c | 639 + src/vnet/bfd/bfd_udp.h | 56 + src/vnet/bfd/dir.dox | 18 + src/vnet/buffer.h | 381 + src/vnet/cdp/cdp.pg | 7 + src/vnet/cdp/cdp_input.c | 506 + src/vnet/cdp/cdp_node.c | 208 + src/vnet/cdp/cdp_node.h | 147 + src/vnet/cdp/cdp_periodic.c | 512 + src/vnet/cdp/cdp_protocol.h | 186 + src/vnet/classify/README | 180 + src/vnet/classify/flow_classify.c | 212 + src/vnet/classify/flow_classify.h | 51 + src/vnet/classify/flow_classify_node.c | 338 + src/vnet/classify/input_acl.c | 283 + src/vnet/classify/input_acl.h | 54 + src/vnet/classify/ip_classify.c | 365 + src/vnet/classify/policer_classify.c | 227 + src/vnet/classify/policer_classify.h | 55 + src/vnet/classify/vnet_classify.c | 2436 +++ src/vnet/classify/vnet_classify.h | 523 + src/vnet/config.c | 361 + src/vnet/config.h | 176 + src/vnet/cop/cop.c | 387 + src/vnet/cop/cop.h | 89 + src/vnet/cop/ip4_whitelist.c | 356 + src/vnet/cop/ip6_whitelist.c | 298 + src/vnet/cop/node1.c | 319 + src/vnet/devices/af_packet/af_packet.api | 71 + src/vnet/devices/af_packet/af_packet.c | 366 + src/vnet/devices/af_packet/af_packet.h | 69 + src/vnet/devices/af_packet/af_packet_api.c | 143 + src/vnet/devices/af_packet/cli.c | 144 + src/vnet/devices/af_packet/device.c | 250 + src/vnet/devices/af_packet/node.c | 288 + src/vnet/devices/devices.c | 91 + src/vnet/devices/devices.h | 53 + src/vnet/devices/dpdk/cli.c | 1296 ++ src/vnet/devices/dpdk/device.c | 840 + src/vnet/devices/dpdk/dpdk.h | 534 + src/vnet/devices/dpdk/dpdk_priv.h | 132 + src/vnet/devices/dpdk/format.c | 763 + src/vnet/devices/dpdk/hqos.c | 775 + src/vnet/devices/dpdk/init.c | 1803 ++ src/vnet/devices/dpdk/ipsec/cli.c | 141 + src/vnet/devices/dpdk/ipsec/crypto_node.c | 210 + src/vnet/devices/dpdk/ipsec/dir.dox | 18 + .../devices/dpdk/ipsec/dpdk_crypto_ipsec_doc.md | 73 + src/vnet/devices/dpdk/ipsec/esp.h | 295 + src/vnet/devices/dpdk/ipsec/esp_decrypt.c | 583 + src/vnet/devices/dpdk/ipsec/esp_encrypt.c | 598 + src/vnet/devices/dpdk/ipsec/ipsec.c | 313 + src/vnet/devices/dpdk/ipsec/ipsec.h | 227 + src/vnet/devices/dpdk/node.c | 687 + src/vnet/devices/dpdk/qos_doc.md | 404 + src/vnet/devices/netmap/cli.c | 146 + src/vnet/devices/netmap/device.c | 261 + src/vnet/devices/netmap/net_netmap.h | 650 + src/vnet/devices/netmap/netmap.api | 74 + src/vnet/devices/netmap/netmap.c | 316 + src/vnet/devices/netmap/netmap.h | 164 + src/vnet/devices/netmap/netmap_api.c | 137 + src/vnet/devices/netmap/node.c | 300 + src/vnet/devices/nic/ixge.c | 2938 +++ src/vnet/devices/nic/ixge.h | 1293 ++ src/vnet/devices/nic/sfp.c | 117 + src/vnet/devices/nic/sfp.h | 117 + src/vnet/devices/ssvm/node.c | 343 + src/vnet/devices/ssvm/ssvm_eth.c | 491 + src/vnet/devices/ssvm/ssvm_eth.h | 141 + src/vnet/devices/virtio/dir.dox | 27 + src/vnet/devices/virtio/vhost-user.c | 3314 ++++ src/vnet/devices/virtio/vhost-user.h | 350 + src/vnet/devices/virtio/vhost_user.api | 125 + src/vnet/devices/virtio/vhost_user_api.c | 262 + src/vnet/dhcp/client.c | 1031 ++ src/vnet/dhcp/client.h | 118 + src/vnet/dhcp/packet.h | 61 + src/vnet/dhcp/proxy.h | 92 + src/vnet/dhcp/proxy_error.def | 30 + src/vnet/dhcp/proxy_node.c | 1114 ++ src/vnet/dhcpv6/packet.h | 183 + src/vnet/dhcpv6/proxy.h | 95 + src/vnet/dhcpv6/proxy_error.def | 29 + src/vnet/dhcpv6/proxy_node.c | 1191 ++ src/vnet/dpo/classify_dpo.c | 131 + src/vnet/dpo/classify_dpo.h | 56 + src/vnet/dpo/dpo.c | 500 + src/vnet/dpo/dpo.h | 381 + src/vnet/dpo/drop_dpo.c | 106 + src/vnet/dpo/drop_dpo.h | 31 + src/vnet/dpo/ip_null_dpo.c | 408 + src/vnet/dpo/ip_null_dpo.h | 56 + src/vnet/dpo/load_balance.c | 993 ++ src/vnet/dpo/load_balance.h | 211 + src/vnet/dpo/load_balance_map.c | 575 + src/vnet/dpo/load_balance_map.h | 79 + src/vnet/dpo/lookup_dpo.c | 1185 ++ src/vnet/dpo/lookup_dpo.h | 108 + src/vnet/dpo/mpls_label_dpo.c | 570 + src/vnet/dpo/mpls_label_dpo.h | 101 + src/vnet/dpo/punt_dpo.c | 100 + src/vnet/dpo/punt_dpo.h | 30 + src/vnet/dpo/receive_dpo.c | 165 + src/vnet/dpo/receive_dpo.h | 62 + src/vnet/ethernet/arp.c | 2355 +++ src/vnet/ethernet/arp_packet.h | 173 + src/vnet/ethernet/dir.dox | 24 + src/vnet/ethernet/error.def | 46 + src/vnet/ethernet/ethernet.h | 561 + src/vnet/ethernet/format.c | 366 + src/vnet/ethernet/init.c | 128 + src/vnet/ethernet/interface.c | 730 + src/vnet/ethernet/mac_swap.c | 397 + src/vnet/ethernet/node.c | 1368 ++ src/vnet/ethernet/packet.h | 152 + src/vnet/ethernet/pg.c | 183 + src/vnet/ethernet/types.def | 113 + src/vnet/feature/feature.c | 463 + src/vnet/feature/feature.h | 382 + src/vnet/feature/registration.c | 301 + src/vnet/fib/fib.c | 41 + src/vnet/fib/fib.h | 652 + src/vnet/fib/fib_api.h | 54 + src/vnet/fib/fib_attached_export.c | 572 + src/vnet/fib/fib_attached_export.h | 57 + src/vnet/fib/fib_entry.c | 1503 ++ src/vnet/fib/fib_entry.h | 530 + src/vnet/fib/fib_entry_cover.c | 225 + src/vnet/fib/fib_entry_cover.h | 47 + src/vnet/fib/fib_entry_delegate.c | 149 + src/vnet/fib/fib_entry_delegate.h | 124 + src/vnet/fib/fib_entry_src.c | 1456 ++ src/vnet/fib/fib_entry_src.h | 296 + src/vnet/fib/fib_entry_src_adj.c | 207 + src/vnet/fib/fib_entry_src_api.c | 119 + src/vnet/fib/fib_entry_src_default.c | 121 + src/vnet/fib/fib_entry_src_default_route.c | 58 + src/vnet/fib/fib_entry_src_interface.c | 195 + src/vnet/fib/fib_entry_src_lisp.c | 133 + src/vnet/fib/fib_entry_src_mpls.c | 196 + src/vnet/fib/fib_entry_src_rr.c | 293 + src/vnet/fib/fib_entry_src_special.c | 71 + src/vnet/fib/fib_internal.h | 69 + src/vnet/fib/fib_node.c | 277 + src/vnet/fib/fib_node.h | 371 + src/vnet/fib/fib_node_list.c | 390 + src/vnet/fib/fib_node_list.h | 64 + src/vnet/fib/fib_path.c | 2001 +++ src/vnet/fib/fib_path.h | 158 + src/vnet/fib/fib_path_ext.c | 231 + src/vnet/fib/fib_path_ext.h | 69 + src/vnet/fib/fib_path_list.c | 1223 ++ src/vnet/fib/fib_path_list.h | 158 + src/vnet/fib/fib_table.c | 1104 ++ src/vnet/fib/fib_table.h | 732 + src/vnet/fib/fib_test.c | 7112 ++++++++ src/vnet/fib/fib_types.c | 326 + src/vnet/fib/fib_types.h | 340 + src/vnet/fib/fib_urpf_list.c | 260 + src/vnet/fib/fib_urpf_list.h | 146 + src/vnet/fib/fib_walk.c | 1108 ++ src/vnet/fib/fib_walk.h | 58 + src/vnet/fib/ip4_fib.c | 664 + src/vnet/fib/ip4_fib.h | 141 + src/vnet/fib/ip6_fib.c | 784 + src/vnet/fib/ip6_fib.h | 130 + src/vnet/fib/mpls_fib.c | 439 + src/vnet/fib/mpls_fib.h | 106 + src/vnet/flow/flow_report.c | 502 + src/vnet/flow/flow_report.h | 145 + src/vnet/flow/flow_report_classify.c | 529 + src/vnet/flow/flow_report_classify.h | 122 + src/vnet/flow/ipfix_info_elements.h | 429 + src/vnet/flow/ipfix_packet.h | 188 + src/vnet/global_funcs.h | 32 + src/vnet/gre/error.def | 23 + src/vnet/gre/gre.api | 57 + src/vnet/gre/gre.c | 455 + src/vnet/gre/gre.h | 235 + src/vnet/gre/gre_api.c | 204 + src/vnet/gre/interface.c | 606 + src/vnet/gre/node.c | 531 + src/vnet/gre/packet.h | 55 + src/vnet/gre/pg.c | 77 + src/vnet/handoff.c | 594 + src/vnet/handoff.h | 259 + src/vnet/hdlc/error.def | 42 + src/vnet/hdlc/hdlc.c | 249 + src/vnet/hdlc/hdlc.h | 127 + src/vnet/hdlc/node.c | 351 + src/vnet/hdlc/packet.h | 72 + src/vnet/hdlc/pg.c | 105 + src/vnet/interface.api | 339 + src/vnet/interface.c | 1398 ++ src/vnet/interface.h | 658 + src/vnet/interface_api.c | 725 + src/vnet/interface_cli.c | 1165 ++ src/vnet/interface_format.c | 401 + src/vnet/interface_funcs.h | 318 + src/vnet/interface_output.c | 1404 ++ src/vnet/ip/dir.dox | 26 + src/vnet/ip/format.c | 121 + src/vnet/ip/format.h | 114 + src/vnet/ip/icmp4.c | 784 + src/vnet/ip/icmp4.h | 60 + src/vnet/ip/icmp46_packet.h | 398 + src/vnet/ip/icmp6.c | 882 + src/vnet/ip/icmp6.h | 86 + src/vnet/ip/igmp_packet.h | 155 + src/vnet/ip/ip.api | 434 + src/vnet/ip/ip.h | 195 + src/vnet/ip/ip4.h | 322 + src/vnet/ip/ip46_cli.c | 236 + src/vnet/ip/ip4_error.h | 95 + src/vnet/ip/ip4_format.c | 256 + src/vnet/ip/ip4_forward.c | 3345 ++++ src/vnet/ip/ip4_input.c | 507 + src/vnet/ip/ip4_mtrie.c | 568 + src/vnet/ip/ip4_mtrie.h | 188 + src/vnet/ip/ip4_packet.h | 384 + src/vnet/ip/ip4_pg.c | 387 + src/vnet/ip/ip4_source_and_port_range_check.c | 1415 ++ src/vnet/ip/ip4_source_check.c | 573 + src/vnet/ip/ip4_test.c | 340 + src/vnet/ip/ip6.h | 476 + src/vnet/ip/ip6_error.h | 92 + src/vnet/ip/ip6_format.c | 383 + src/vnet/ip/ip6_forward.c | 3402 ++++ src/vnet/ip/ip6_hop_by_hop.c | 1194 ++ src/vnet/ip/ip6_hop_by_hop.h | 217 + src/vnet/ip/ip6_hop_by_hop_packet.h | 66 + src/vnet/ip/ip6_input.c | 353 + src/vnet/ip/ip6_neighbor.c | 4088 +++++ src/vnet/ip/ip6_neighbor.h | 52 + src/vnet/ip/ip6_packet.h | 499 + src/vnet/ip/ip6_pg.c | 231 + src/vnet/ip/ip_api.c | 1196 ++ src/vnet/ip/ip_checksum.c | 228 + src/vnet/ip/ip_frag.c | 581 + src/vnet/ip/ip_frag.h | 96 + src/vnet/ip/ip_init.c | 152 + src/vnet/ip/ip_input_acl.c | 450 + src/vnet/ip/ip_packet.h | 180 + src/vnet/ip/ip_source_and_port_range_check.h | 148 + src/vnet/ip/lookup.c | 967 + src/vnet/ip/lookup.h | 498 + src/vnet/ip/ping.c | 888 + src/vnet/ip/ping.h | 108 + src/vnet/ip/ports.def | 757 + src/vnet/ip/protocols.def | 162 + src/vnet/ip/punt.c | 323 + src/vnet/ip/punt.h | 43 + src/vnet/ip/punt_error.def | 19 + src/vnet/ip/tcp_packet.h | 138 + src/vnet/ip/udp.h | 313 + src/vnet/ip/udp_error.def | 21 + src/vnet/ip/udp_format.c | 91 + src/vnet/ip/udp_init.c | 71 + src/vnet/ip/udp_local.c | 645 + src/vnet/ip/udp_packet.h | 65 + src/vnet/ip/udp_pg.c | 237 + src/vnet/ipsec-gre/dir.dox | 18 + src/vnet/ipsec-gre/error.def | 26 + src/vnet/ipsec-gre/interface.c | 311 + src/vnet/ipsec-gre/ipsec_gre.api | 79 + src/vnet/ipsec-gre/ipsec_gre.c | 407 + src/vnet/ipsec-gre/ipsec_gre.h | 114 + src/vnet/ipsec-gre/ipsec_gre_api.c | 190 + src/vnet/ipsec-gre/ipsec_gre_doc.md | 74 + src/vnet/ipsec-gre/node.c | 433 + src/vnet/ipsec/esp.h | 320 + src/vnet/ipsec/esp_decrypt.c | 430 + src/vnet/ipsec/esp_encrypt.c | 425 + src/vnet/ipsec/ikev2.c | 2186 +++ src/vnet/ipsec/ikev2.h | 410 + src/vnet/ipsec/ikev2_cli.c | 479 + src/vnet/ipsec/ikev2_crypto.c | 765 + src/vnet/ipsec/ikev2_format.c | 155 + src/vnet/ipsec/ikev2_payload.c | 535 + src/vnet/ipsec/ikev2_priv.h | 321 + src/vnet/ipsec/ipsec.api | 457 + src/vnet/ipsec/ipsec.c | 581 + src/vnet/ipsec/ipsec.h | 344 + src/vnet/ipsec/ipsec_api.c | 537 + src/vnet/ipsec/ipsec_cli.c | 807 + src/vnet/ipsec/ipsec_format.c | 141 + src/vnet/ipsec/ipsec_if.c | 372 + src/vnet/ipsec/ipsec_if_in.c | 175 + src/vnet/ipsec/ipsec_if_out.c | 161 + src/vnet/ipsec/ipsec_input.c | 455 + src/vnet/ipsec/ipsec_output.c | 478 + src/vnet/l2/dir.dox | 24 + src/vnet/l2/feat_bitmap.c | 185 + src/vnet/l2/feat_bitmap.h | 96 + src/vnet/l2/l2.api | 38 + src/vnet/l2/l2_api.c | 140 + src/vnet/l2/l2_bd.c | 1079 ++ src/vnet/l2/l2_bd.h | 150 + src/vnet/l2/l2_bvi.c | 40 + src/vnet/l2/l2_bvi.h | 117 + src/vnet/l2/l2_classify.h | 116 + src/vnet/l2/l2_efp_filter.c | 614 + src/vnet/l2/l2_efp_filter.h | 33 + src/vnet/l2/l2_fib.c | 857 + src/vnet/l2/l2_fib.h | 341 + src/vnet/l2/l2_flood.c | 568 + src/vnet/l2/l2_flood.h | 35 + src/vnet/l2/l2_fwd.c | 544 + src/vnet/l2/l2_fwd.h | 36 + src/vnet/l2/l2_input.c | 1116 ++ src/vnet/l2/l2_input.h | 266 + src/vnet/l2/l2_input_acl.c | 434 + src/vnet/l2/l2_input_classify.c | 655 + src/vnet/l2/l2_input_vtr.c | 401 + src/vnet/l2/l2_input_vtr.h | 54 + src/vnet/l2/l2_learn.c | 597 + src/vnet/l2/l2_learn.h | 64 + src/vnet/l2/l2_output.c | 708 + src/vnet/l2/l2_output.h | 285 + src/vnet/l2/l2_output_acl.c | 358 + src/vnet/l2/l2_output_classify.c | 657 + src/vnet/l2/l2_patch.c | 452 + src/vnet/l2/l2_rw.c | 719 + src/vnet/l2/l2_rw.h | 95 + src/vnet/l2/l2_vtr.c | 770 + src/vnet/l2/l2_vtr.h | 270 + src/vnet/l2/l2_xcrw.c | 591 + src/vnet/l2/l2_xcrw.h | 91 + src/vnet/l2tp/decap.c | 309 + src/vnet/l2tp/encap.c | 238 + src/vnet/l2tp/l2tp.api | 126 + src/vnet/l2tp/l2tp.c | 739 + src/vnet/l2tp/l2tp.h | 147 + src/vnet/l2tp/l2tp_api.c | 267 + src/vnet/l2tp/packet.h | 44 + src/vnet/l2tp/pg.c | 106 + src/vnet/l3_types.h | 59 + src/vnet/lawful-intercept/lawful_intercept.c | 112 + src/vnet/lawful-intercept/lawful_intercept.h | 45 + src/vnet/lawful-intercept/node.c | 275 + src/vnet/lisp-cp/control.c | 4950 +++++ src/vnet/lisp-cp/control.h | 314 + src/vnet/lisp-cp/gid_dictionary.c | 865 + src/vnet/lisp-cp/gid_dictionary.h | 120 + src/vnet/lisp-cp/lisp.api | 835 + src/vnet/lisp-cp/lisp_api.c | 1257 ++ src/vnet/lisp-cp/lisp_cp_dpo.c | 117 + src/vnet/lisp-cp/lisp_cp_dpo.h | 45 + src/vnet/lisp-cp/lisp_cp_messages.h | 613 + src/vnet/lisp-cp/lisp_msg_serdes.c | 372 + src/vnet/lisp-cp/lisp_msg_serdes.h | 58 + src/vnet/lisp-cp/lisp_types.c | 1574 ++ src/vnet/lisp-cp/lisp_types.h | 354 + src/vnet/lisp-cp/packets.c | 269 + src/vnet/lisp-cp/packets.h | 82 + src/vnet/lisp-gpe/decap.c | 501 + src/vnet/lisp-gpe/dir.dox | 26 + src/vnet/lisp-gpe/interface.c | 709 + src/vnet/lisp-gpe/lisp_gpe.api | 143 + src/vnet/lisp-gpe/lisp_gpe.c | 327 + src/vnet/lisp-gpe/lisp_gpe.h | 257 + src/vnet/lisp-gpe/lisp_gpe_adjacency.c | 542 + src/vnet/lisp-gpe/lisp_gpe_adjacency.h | 136 + src/vnet/lisp-gpe/lisp_gpe_api.c | 304 + src/vnet/lisp-gpe/lisp_gpe_error.def | 18 + src/vnet/lisp-gpe/lisp_gpe_fwd_entry.c | 1053 ++ src/vnet/lisp-gpe/lisp_gpe_fwd_entry.h | 188 + src/vnet/lisp-gpe/lisp_gpe_packet.h | 149 + src/vnet/lisp-gpe/lisp_gpe_sub_interface.c | 278 + src/vnet/lisp-gpe/lisp_gpe_sub_interface.h | 157 + src/vnet/lisp-gpe/lisp_gpe_tenant.c | 330 + src/vnet/lisp-gpe/lisp_gpe_tenant.h | 88 + src/vnet/lisp-gpe/lisp_gpe_tunnel.c | 289 + src/vnet/lisp-gpe/lisp_gpe_tunnel.h | 89 + src/vnet/lisp-gpe/rfc.txt | 826 + src/vnet/llc/llc.c | 241 + src/vnet/llc/llc.h | 194 + src/vnet/llc/node.c | 331 + src/vnet/llc/pg.c | 113 + src/vnet/lldp/dir.dox | 18 + src/vnet/lldp/lldp_cli.c | 646 + src/vnet/lldp/lldp_doc.md | 84 + src/vnet/lldp/lldp_input.c | 302 + src/vnet/lldp/lldp_node.c | 341 + src/vnet/lldp/lldp_node.h | 145 + src/vnet/lldp/lldp_output.c | 216 + src/vnet/lldp/lldp_protocol.h | 142 + src/vnet/map/examples/gen-rules.py | 186 + src/vnet/map/examples/health_check.c | 109 + src/vnet/map/examples/test_map.py | 141 + src/vnet/map/gen-rules.py | 107 + src/vnet/map/ip4_map.c | 813 + src/vnet/map/ip4_map_t.c | 1363 ++ src/vnet/map/ip6_map.c | 1269 ++ src/vnet/map/ip6_map_t.c | 1517 ++ src/vnet/map/map.api | 178 + src/vnet/map/map.c | 2166 +++ src/vnet/map/map.h | 591 + src/vnet/map/map_api.c | 295 + src/vnet/map/map_doc.md | 69 + src/vnet/map/map_dpo.c | 191 + src/vnet/map/map_dpo.h | 67 + src/vnet/map/test.c | 205 + src/vnet/mcast/mcast.c | 565 + src/vnet/mcast/mcast.h | 50 + src/vnet/mcast/mcast_test.c | 149 + src/vnet/misc.c | 124 + src/vnet/mpls/error.def | 31 + src/vnet/mpls/interface.c | 121 + src/vnet/mpls/mpls.c | 511 + src/vnet/mpls/mpls.h | 172 + src/vnet/mpls/mpls_features.c | 156 + src/vnet/mpls/mpls_lookup.c | 531 + src/vnet/mpls/mpls_output.c | 479 + src/vnet/mpls/mpls_tunnel.c | 787 + src/vnet/mpls/mpls_tunnel.h | 98 + src/vnet/mpls/mpls_types.h | 39 + src/vnet/mpls/node.c | 303 + src/vnet/mpls/packet.h | 125 + src/vnet/mpls/pg.c | 71 + src/vnet/osi/node.c | 326 + src/vnet/osi/osi.c | 201 + src/vnet/osi/osi.h | 171 + src/vnet/osi/pg.c | 106 + src/vnet/pg/cli.c | 636 + src/vnet/pg/edit.c | 186 + src/vnet/pg/edit.h | 210 + src/vnet/pg/example.script | 6 + src/vnet/pg/init.c | 72 + src/vnet/pg/input.c | 1667 ++ src/vnet/pg/output.c | 85 + src/vnet/pg/pg.h | 383 + src/vnet/pg/stream.c | 497 + src/vnet/pipeline.h | 456 + src/vnet/plugin/p1.c | 52 + src/vnet/plugin/plugin.h | 32 + src/vnet/policer/node_funcs.c | 938 + src/vnet/policer/police.h | 214 + src/vnet/policer/policer.c | 528 + src/vnet/policer/policer.h | 107 + src/vnet/policer/xlate.c | 1505 ++ src/vnet/policer/xlate.h | 186 + src/vnet/ppp/error.def | 42 + src/vnet/ppp/node.c | 368 + src/vnet/ppp/packet.h | 199 + src/vnet/ppp/pg.c | 114 + src/vnet/ppp/ppp.c | 261 + src/vnet/ppp/ppp.h | 135 + src/vnet/replication.c | 293 + src/vnet/replication.h | 136 + src/vnet/rewrite.c | 329 + src/vnet/rewrite.h | 305 + src/vnet/snap/node.c | 353 + src/vnet/snap/pg.c | 116 + src/vnet/snap/snap.c | 204 + src/vnet/snap/snap.h | 209 + src/vnet/span/node.c | 286 + src/vnet/span/span.api | 60 + src/vnet/span/span.c | 197 + src/vnet/span/span.h | 62 + src/vnet/span/span.md | 65 + src/vnet/span/span_api.c | 153 + src/vnet/sr/dir.dox | 25 + src/vnet/sr/examples/sr_multicastmap.script | 4 + src/vnet/sr/rfc_draft_05.txt | 1265 ++ src/vnet/sr/sr.c | 3333 ++++ src/vnet/sr/sr.h | 262 + src/vnet/sr/sr_error.def | 20 + src/vnet/sr/sr_fix_dst_error.def | 17 + src/vnet/sr/sr_packet.h | 251 + src/vnet/sr/sr_replicate.c | 490 + src/vnet/srp/format.c | 147 + src/vnet/srp/interface.c | 458 + src/vnet/srp/node.c | 932 + src/vnet/srp/packet.h | 204 + src/vnet/srp/pg.c | 157 + src/vnet/srp/srp.h | 222 + src/vnet/unix/gdb_funcs.c | 171 + src/vnet/unix/pcap.c | 241 + src/vnet/unix/pcap.h | 230 + src/vnet/unix/pcap2pg.c | 182 + src/vnet/unix/tap.api | 123 + src/vnet/unix/tap_api.c | 257 + src/vnet/unix/tapcli.c | 1328 ++ src/vnet/unix/tapcli.h | 52 + src/vnet/unix/tuntap.c | 1000 ++ src/vnet/unix/tuntap.h | 36 + src/vnet/vnet.h | 96 + src/vnet/vnet_all_api_h.h | 57 + src/vnet/vnet_msg_enum.h | 37 + src/vnet/vxlan-gpe/decap.c | 733 + src/vnet/vxlan-gpe/dir.dox | 32 + src/vnet/vxlan-gpe/encap.c | 388 + src/vnet/vxlan-gpe/vxlan-gpe-rfc.txt | 868 + src/vnet/vxlan-gpe/vxlan_gpe.api | 61 + src/vnet/vxlan-gpe/vxlan_gpe.c | 659 + src/vnet/vxlan-gpe/vxlan_gpe.h | 221 + src/vnet/vxlan-gpe/vxlan_gpe_api.c | 249 + src/vnet/vxlan-gpe/vxlan_gpe_error.def | 16 + src/vnet/vxlan-gpe/vxlan_gpe_packet.h | 110 + src/vnet/vxlan/decap.c | 1130 ++ src/vnet/vxlan/dir.dox | 24 + src/vnet/vxlan/encap.c | 553 + src/vnet/vxlan/vxlan.api | 81 + src/vnet/vxlan/vxlan.c | 899 + src/vnet/vxlan/vxlan.h | 199 + src/vnet/vxlan/vxlan_api.c | 253 + src/vnet/vxlan/vxlan_error.def | 17 + src/vnet/vxlan/vxlan_packet.h | 69 + src/vpp-api-test.am | 64 + src/vpp-api/python/Makefile.am | 60 + src/vpp-api/python/README.rst | 0 src/vpp-api/python/pneum/pneum.c | 259 + src/vpp-api/python/pneum/pneum.h | 31 + src/vpp-api/python/pneum/test_pneum.c | 143 + src/vpp-api/python/setup.cfg | 5 + src/vpp-api/python/setup.py | 34 + src/vpp-api/python/tests/test_cli.py | 52 + src/vpp-api/python/tests/test_modules.py | 18 + src/vpp-api/python/tests/test_papi.py | 119 + src/vpp-api/python/tests/test_version.py | 35 + src/vpp-api/python/tests/test_vpp_papi2.py | 487 + src/vpp-api/python/vpp_papi/__init__.py | 3 + src/vpp-api/python/vpp_papi/pneum_wrap.c | 200 + src/vpp-api/python/vpp_papi/vpp_papi.py | 450 + src/vpp.am | 159 + src/vpp/api/api.c | 4922 +++++ src/vpp/api/api_format.c | 1 + src/vpp/api/api_main.c | 192 + src/vpp/api/custom_dump.c | 3139 ++++ src/vpp/api/gmon.c | 319 + src/vpp/api/json_format.c | 304 + src/vpp/api/json_format.h | 254 + src/vpp/api/summary_stats_client.c | 302 + src/vpp/api/test_client.c | 1531 ++ src/vpp/api/test_ha.c | 249 + src/vpp/api/vat.h | 1 + src/vpp/api/vpe.api | 2782 +++ src/vpp/api/vpe_all_api_h.h | 37 + src/vpp/api/vpe_msg_enum.h | 37 + src/vpp/api/vpp_get_metrics.c | 253 + src/vpp/app/l2t.c | 557 + src/vpp/app/l2t_l2.c | 267 + src/vpp/app/sticky_hash.c | 581 + src/vpp/app/version.c | 102 + src/vpp/app/vpe_cli.c | 123 + src/vpp/conf/80-vpp.conf | 15 + src/vpp/conf/startup.conf | 99 + src/vpp/conf/startup.uiopcigeneric.conf | 18 + src/vpp/oam/oam.c | 648 + src/vpp/oam/oam.h | 96 + src/vpp/stats/stats.c | 987 + src/vpp/stats/stats.h | 76 + src/vpp/vnet/main.c | 415 + src/vppapigen.am | 27 + src/vppinfra.am | 276 + src/vppinfra/README | 43 + src/vppinfra/anneal.c | 172 + src/vppinfra/anneal.h | 89 + src/vppinfra/asm_mips.h | 351 + src/vppinfra/asm_x86.c | 1947 ++ src/vppinfra/asm_x86.h | 125 + src/vppinfra/backtrace.c | 267 + src/vppinfra/bihash_24_8.h | 85 + src/vppinfra/bihash_8_8.h | 98 + src/vppinfra/bihash_doc.h | 149 + src/vppinfra/bihash_template.c | 455 + src/vppinfra/bihash_template.h | 214 + src/vppinfra/bitmap.h | 774 + src/vppinfra/bitops.h | 179 + src/vppinfra/byte_order.h | 202 + src/vppinfra/cache.h | 104 + src/vppinfra/clib.h | 359 + src/vppinfra/cpu.c | 133 + src/vppinfra/cpu.h | 112 + src/vppinfra/dir.dox | 19 + src/vppinfra/dlist.h | 156 + src/vppinfra/elf.c | 2040 +++ src/vppinfra/elf.h | 1062 ++ src/vppinfra/elf_clib.c | 377 + src/vppinfra/elf_clib.h | 144 + src/vppinfra/elog.c | 1061 ++ src/vppinfra/elog.h | 460 + src/vppinfra/error.c | 292 + src/vppinfra/error.h | 201 + src/vppinfra/error_bootstrap.h | 106 + src/vppinfra/fheap.c | 473 + src/vppinfra/fheap.h | 140 + src/vppinfra/fifo.c | 137 + src/vppinfra/fifo.h | 304 + src/vppinfra/format.c | 814 + src/vppinfra/format.h | 331 + src/vppinfra/graph.c | 182 + src/vppinfra/graph.h | 127 + src/vppinfra/hash.c | 1095 ++ src/vppinfra/hash.h | 699 + src/vppinfra/heap.c | 828 + src/vppinfra/heap.h | 357 + src/vppinfra/longjmp.S | 690 + src/vppinfra/longjmp.h | 124 + src/vppinfra/macros.c | 266 + src/vppinfra/macros.h | 54 + src/vppinfra/math.h | 63 + src/vppinfra/md5.c | 317 + src/vppinfra/md5.h | 57 + src/vppinfra/mem.h | 291 + src/vppinfra/mem_mheap.c | 165 + src/vppinfra/memcheck.h | 317 + src/vppinfra/memcpy_avx.h | 293 + src/vppinfra/memcpy_sse3.h | 355 + src/vppinfra/mhash.c | 408 + src/vppinfra/mhash.h | 179 + src/vppinfra/mheap.c | 1649 ++ src/vppinfra/mheap.h | 94 + src/vppinfra/mheap_bootstrap.h | 374 + src/vppinfra/mod_test_hash.c | 27 + src/vppinfra/os.h | 72 + src/vppinfra/pfhash.c | 689 + src/vppinfra/pfhash.h | 276 + src/vppinfra/phash.c | 1017 ++ src/vppinfra/phash.h | 194 + src/vppinfra/pipeline.h | 176 + src/vppinfra/pool.h | 405 + src/vppinfra/ptclosure.c | 125 + src/vppinfra/ptclosure.h | 40 + src/vppinfra/qhash.c | 858 + src/vppinfra/qhash.h | 169 + src/vppinfra/qsort.c | 269 + src/vppinfra/random.c | 51 + src/vppinfra/random.h | 178 + src/vppinfra/random_buffer.c | 86 + src/vppinfra/random_buffer.h | 118 + src/vppinfra/random_isaac.c | 434 + src/vppinfra/random_isaac.h | 81 + src/vppinfra/serialize.c | 1254 ++ src/vppinfra/serialize.h | 443 + src/vppinfra/slist.c | 336 + src/vppinfra/slist.h | 145 + src/vppinfra/smp.c | 325 + src/vppinfra/smp.h | 81 + src/vppinfra/smp_fifo.c | 91 + src/vppinfra/smp_fifo.h | 313 + src/vppinfra/socket.c | 422 + src/vppinfra/socket.h | 160 + src/vppinfra/sparse_vec.h | 244 + src/vppinfra/std-formats.c | 330 + src/vppinfra/string.c | 94 + src/vppinfra/string.h | 83 + src/vppinfra/test_bihash_template.c | 297 + src/vppinfra/test_dlist.c | 193 + src/vppinfra/test_elf.c | 217 + src/vppinfra/test_elog.c | 262 + src/vppinfra/test_fifo.c | 144 + src/vppinfra/test_format.c | 199 + src/vppinfra/test_hash.c | 458 + src/vppinfra/test_heap.c | 198 + src/vppinfra/test_longjmp.c | 129 + src/vppinfra/test_macros.c | 64 + src/vppinfra/test_md5.c | 141 + src/vppinfra/test_mheap.c | 242 + src/vppinfra/test_pfhash.c | 322 + src/vppinfra/test_phash.c | 149 + src/vppinfra/test_pool.c | 86 + src/vppinfra/test_pool_iterate.c | 59 + src/vppinfra/test_ptclosure.c | 212 + src/vppinfra/test_qhash.c | 333 + src/vppinfra/test_random.c | 148 + src/vppinfra/test_random_isaac.c | 142 + src/vppinfra/test_serialize.c | 274 + src/vppinfra/test_slist.c | 228 + src/vppinfra/test_socket.c | 134 + src/vppinfra/test_time.c | 104 + src/vppinfra/test_timing_wheel.c | 389 + src/vppinfra/test_vec.c | 1159 ++ src/vppinfra/test_vec.h | 243 + src/vppinfra/test_vhash.c | 757 + src/vppinfra/test_zvec.c | 117 + src/vppinfra/time.c | 226 + src/vppinfra/time.h | 298 + src/vppinfra/timer.c | 322 + src/vppinfra/timer.h | 46 + src/vppinfra/timing_wheel.c | 750 + src/vppinfra/timing_wheel.h | 155 + src/vppinfra/types.h | 174 + src/vppinfra/unformat.c | 1077 ++ src/vppinfra/unix-formats.c | 918 + src/vppinfra/unix-kelog.c | 415 + src/vppinfra/unix-misc.c | 242 + src/vppinfra/unix.h | 64 + src/vppinfra/unix_error.def | 145 + src/vppinfra/valgrind.h | 4030 +++++ src/vppinfra/vec.c | 171 + src/vppinfra/vec.h | 973 + src/vppinfra/vec_bootstrap.h | 201 + src/vppinfra/vector.c | 54 + src/vppinfra/vector.h | 268 + src/vppinfra/vector_altivec.h | 178 + src/vppinfra/vector_funcs.h | 334 + src/vppinfra/vector_iwmmxt.h | 149 + src/vppinfra/vector_neon.h | 71 + src/vppinfra/vector_sse2.h | 711 + src/vppinfra/vhash.c | 772 + src/vppinfra/vhash.h | 850 + src/vppinfra/vm_linux_kernel.h | 78 + src/vppinfra/vm_standalone.h | 74 + src/vppinfra/vm_unix.h | 106 + src/vppinfra/xxhash.h | 86 + src/vppinfra/xy.h | 56 + src/vppinfra/zvec.c | 442 + src/vppinfra/zvec.h | 166 + svm/Makefile.am | 30 - svm/configure.ac | 7 - svm/dir.dox | 21 - svm/persist.c | 258 - svm/ssvm.c | 178 - svm/ssvm.h | 155 - svm/svm.c | 1237 -- svm/svm.h | 207 - svm/svm_test.c | 79 - svm/svmdb.c | 671 - svm/svmdb.h | 135 - svm/svmdbtool.c | 537 - svm/svmtool.c | 528 - vlib-api/Makefile.am | 84 - vlib-api/configure.ac | 9 - vlib-api/suffix-rules.mk | 1 - vlib-api/vlibapi/api.h | 281 - vlib-api/vlibapi/api_helper_macros.h | 243 - vlib-api/vlibapi/api_shared.c | 1375 -- vlib-api/vlibapi/node_serialize.c | 399 - vlib-api/vlibmemory/api.h | 163 - vlib-api/vlibmemory/memclnt.api | 91 - vlib-api/vlibmemory/memory_client.c | 283 - vlib-api/vlibmemory/memory_shared.c | 852 - vlib-api/vlibmemory/memory_vlib.c | 1346 -- vlib-api/vlibmemory/unix_shared_memory_queue.c | 324 - vlib-api/vlibmemory/unix_shared_memory_queue.h | 69 - vlib-api/vlibmemory/vl_memory_api_h.h | 32 - vlib-api/vlibmemory/vl_memory_msg_enum.h | 42 - vlib-api/vlibsocket/api.h | 87 - vlib-api/vlibsocket/sock_test.c | 155 - vlib-api/vlibsocket/sockclnt.api | 50 - vlib-api/vlibsocket/sockclnt_vlib.c | 209 - vlib-api/vlibsocket/socksvr_vlib.c | 706 - vlib-api/vlibsocket/vl_socket_api_h.h | 33 - vlib-api/vlibsocket/vl_socket_msg_enum.h | 42 - vlib/.gitignore | 1 - vlib/Makefile.am | 104 - vlib/configure.ac | 25 - vlib/dir.dox | 21 - vlib/example/dir.dox | 22 - vlib/example/main_stub.c | 418 - vlib/example/mc_test.c | 384 - vlib/example/plex_test.c | 527 - vlib/vlib/buffer.c | 1987 --- vlib/vlib/buffer.h | 417 - vlib/vlib/buffer_funcs.h | 755 - vlib/vlib/buffer_node.h | 337 - vlib/vlib/cli.c | 1173 -- vlib/vlib/cli.h | 192 - vlib/vlib/cli_funcs.h | 58 - vlib/vlib/counter.c | 151 - vlib/vlib/counter.h | 379 - vlib/vlib/defs.h | 82 - vlib/vlib/dir.dox | 23 - vlib/vlib/elog_samples.c | 122 - vlib/vlib/error.c | 338 - vlib/vlib/error.h | 101 - vlib/vlib/error_funcs.h | 88 - vlib/vlib/format.c | 196 - vlib/vlib/format_funcs.h | 75 - vlib/vlib/global_funcs.h | 45 - vlib/vlib/i2c.c | 231 - vlib/vlib/i2c.h | 67 - vlib/vlib/init.c | 168 - vlib/vlib/init.h | 238 - vlib/vlib/lex.c | 271 - vlib/vlib/lex.h | 145 - vlib/vlib/main.c | 1703 -- vlib/vlib/main.h | 333 - vlib/vlib/mc.c | 2609 --- vlib/vlib/mc.h | 687 - vlib/vlib/node.c | 631 - vlib/vlib/node.h | 725 - vlib/vlib/node_cli.c | 466 - vlib/vlib/node_format.c | 187 - vlib/vlib/node_funcs.h | 1130 -- vlib/vlib/parse.c | 1007 -- vlib/vlib/parse.h | 221 - vlib/vlib/parse_builtin.c | 150 - vlib/vlib/pci/linux_pci.c | 642 - vlib/vlib/pci/pci.c | 264 - vlib/vlib/pci/pci.h | 251 - vlib/vlib/pci/pci_config.h | 731 - vlib/vlib/physmem.h | 108 - vlib/vlib/threads.c | 1492 -- vlib/vlib/threads.h | 470 - vlib/vlib/threads_cli.c | 579 - vlib/vlib/trace.c | 545 - vlib/vlib/trace.h | 100 - vlib/vlib/trace_funcs.h | 185 - vlib/vlib/unix/cj.c | 271 - vlib/vlib/unix/cj.h | 79 - vlib/vlib/unix/cli.c | 2989 ---- vlib/vlib/unix/dir.dox | 28 - vlib/vlib/unix/input.c | 265 - vlib/vlib/unix/main.c | 557 - vlib/vlib/unix/mc_socket.c | 1049 -- vlib/vlib/unix/mc_socket.h | 137 - vlib/vlib/unix/physmem.c | 470 - vlib/vlib/unix/physmem.h | 65 - vlib/vlib/unix/plugin.c | 260 - vlib/vlib/unix/plugin.h | 98 - vlib/vlib/unix/unix.h | 232 - vlib/vlib/unix/util.c | 231 - vlib/vlib/vlib.h | 86 - vlib/vlib/vlib_process_doc.h | 147 - vnet/.gitignore | 1 - vnet/Makefile.am | 993 -- vnet/configure.ac | 49 - vnet/etc/scripts/arp4 | 21 - vnet/etc/scripts/arp4-mpls | 24 - vnet/etc/scripts/arp6 | 21 - vnet/etc/scripts/bvi | 76 - vnet/etc/scripts/dhcp/dhcpd.conf | 8 - vnet/etc/scripts/dhcp/left-ping-target.sh | 4 - vnet/etc/scripts/dhcp/leftpeer.conf | 17 - vnet/etc/scripts/icmp | 16 - vnet/etc/scripts/icmp6 | 16 - vnet/etc/scripts/ige | 19 - vnet/etc/scripts/ip6 | 15 - vnet/etc/scripts/ip6-hbh | 84 - vnet/etc/scripts/ixge | 15 - vnet/etc/scripts/l2efpfilter | 83 - vnet/etc/scripts/l2efpfilter_perf | 58 - vnet/etc/scripts/l2fib | 46 - vnet/etc/scripts/l2fib_perf | 29 - vnet/etc/scripts/l2fib_xc | 31 - vnet/etc/scripts/l2flood | 42 - vnet/etc/scripts/l2tp | 134 - vnet/etc/scripts/leftpeer/leftpeer-classify | 8 - vnet/etc/scripts/leftpeer/leftpeer-classify6 | 5 - vnet/etc/scripts/leftpeer/leftpeer-classifyl2 | 8 - vnet/etc/scripts/leftpeer/leftpeer-dhcp | 23 - vnet/etc/scripts/leftpeer/leftpeer-ioam.conf | 15 - vnet/etc/scripts/leftpeer/leftpeer-l3vxlan.conf | 12 - vnet/etc/scripts/leftpeer/leftpeer-lisp.conf | 18 - vnet/etc/scripts/leftpeer/leftpeer-mpls.conf | 17 - vnet/etc/scripts/leftpeer/leftpeer-sr.conf | 24 - vnet/etc/scripts/leftpeer/leftpeer-vxlan.conf | 17 - vnet/etc/scripts/leftpeer/leftpeer.script | 9 - vnet/etc/scripts/lfib/ip4-to-mpls | 26 - vnet/etc/scripts/lfib/mpls-pop-to-mpls | 28 - vnet/etc/scripts/lfib/mpls-to-ip4 | 27 - vnet/etc/scripts/lfib/mpls-to-mpls | 26 - vnet/etc/scripts/mpls-o-ethernet/leftpeer.conf | 17 - vnet/etc/scripts/mpls-o-ethernet/pg | 10 - vnet/etc/scripts/mpls-o-ethernet/rightpeer.conf | 15 - vnet/etc/scripts/mpls-o-ethernet/single.conf | 17 - vnet/etc/scripts/mpls-o-gre/dhcpd.conf | 116 - vnet/etc/scripts/mpls-o-gre/leftpeer.conf | 14 - vnet/etc/scripts/mpls-o-gre/rightpeer.conf | 14 - vnet/etc/scripts/mpls-tunnel | 87 - vnet/etc/scripts/pcap | 18 - vnet/etc/scripts/probe4 | 11 - vnet/etc/scripts/probe6 | 7 - vnet/etc/scripts/rewrite | 62 - vnet/etc/scripts/rightpeer/rightpeer-ioam.conf | 14 - vnet/etc/scripts/rightpeer/rightpeer-l3vxlan.conf | 9 - vnet/etc/scripts/rightpeer/rightpeer-lisp.conf | 16 - vnet/etc/scripts/rightpeer/rightpeer-mpls-l2.conf | 24 - vnet/etc/scripts/rightpeer/rightpeer-mpls.conf | 17 - vnet/etc/scripts/rightpeer/rightpeer-sr.conf | 28 - vnet/etc/scripts/rightpeer/rightpeer-vxlan.conf | 16 - vnet/etc/scripts/rightpeer/rightpeer.script | 9 - vnet/etc/scripts/rpf | 18 - vnet/etc/scripts/rtt-test | 31 - vnet/etc/scripts/snat | 34 - vnet/etc/scripts/snat_static | 44 - vnet/etc/scripts/snat_static_with_port | 44 - vnet/etc/scripts/source_and_port_range_check | 63 - vnet/etc/scripts/speed | 14 - vnet/etc/scripts/sr/left-linux-ping.sh | 3 - vnet/etc/scripts/sr/leftpeer.conf | 27 - vnet/etc/scripts/sr/right-linux-ping.sh | 4 - vnet/etc/scripts/sr/rightpeer.conf | 22 - vnet/etc/scripts/sr/srlocal.sh | 4 - vnet/etc/scripts/srp | 27 - vnet/etc/scripts/tcp | 16 - vnet/etc/scripts/tcp-test | 6 - vnet/etc/scripts/tf-ucs-1 | 16 - vnet/etc/scripts/urpf | 86 - vnet/etc/scripts/virl/ip6sr.virl | 874 - vnet/etc/scripts/virl/ip6sr_notes.txt | 38 - vnet/etc/scripts/virl/mplsogre.virl | 319 - vnet/etc/scripts/virl/simple.virl | 389 - vnet/etc/scripts/vlan | 23 - vnet/suffix-rules.mk | 1 - vnet/test/README | 10 - vnet/test/lisp-cp/test_cp_serdes.c | 635 - vnet/test/lisp-cp/test_lisp_types.c | 561 - vnet/test/lisp-gpe/test.c | 18 - vnet/vnet/adj/adj.c | 454 - vnet/vnet/adj/adj.h | 122 - vnet/vnet/adj/adj_glean.c | 285 - vnet/vnet/adj/adj_glean.h | 61 - vnet/vnet/adj/adj_internal.h | 104 - vnet/vnet/adj/adj_l2.c | 194 - vnet/vnet/adj/adj_l2.h | 24 - vnet/vnet/adj/adj_midchain.c | 559 - vnet/vnet/adj/adj_midchain.h | 102 - vnet/vnet/adj/adj_nbr.c | 1087 -- vnet/vnet/adj/adj_nbr.h | 176 - vnet/vnet/adj/adj_rewrite.c | 53 - vnet/vnet/adj/adj_rewrite.h | 49 - vnet/vnet/adj/adj_types.h | 53 - vnet/vnet/api_errno.h | 113 - vnet/vnet/bfd/bfd.api | 205 - vnet/vnet/bfd/bfd_api.c | 262 - vnet/vnet/bfd/bfd_api.h | 46 - vnet/vnet/bfd/bfd_debug.h | 79 - vnet/vnet/bfd/bfd_doc.md | 1 - vnet/vnet/bfd/bfd_main.c | 969 - vnet/vnet/bfd/bfd_main.h | 220 - vnet/vnet/bfd/bfd_protocol.c | 74 - vnet/vnet/bfd/bfd_protocol.h | 154 - vnet/vnet/bfd/bfd_udp.c | 639 - vnet/vnet/bfd/bfd_udp.h | 56 - vnet/vnet/bfd/dir.dox | 18 - vnet/vnet/buffer.h | 381 - vnet/vnet/cdp/cdp.pg | 7 - vnet/vnet/cdp/cdp_input.c | 506 - vnet/vnet/cdp/cdp_node.c | 208 - vnet/vnet/cdp/cdp_node.h | 147 - vnet/vnet/cdp/cdp_periodic.c | 512 - vnet/vnet/cdp/cdp_protocol.h | 186 - vnet/vnet/classify/README | 180 - vnet/vnet/classify/flow_classify.c | 212 - vnet/vnet/classify/flow_classify.h | 51 - vnet/vnet/classify/flow_classify_node.c | 338 - vnet/vnet/classify/input_acl.c | 283 - vnet/vnet/classify/input_acl.h | 54 - vnet/vnet/classify/ip_classify.c | 365 - vnet/vnet/classify/policer_classify.c | 227 - vnet/vnet/classify/policer_classify.h | 55 - vnet/vnet/classify/vnet_classify.c | 2436 --- vnet/vnet/classify/vnet_classify.h | 523 - vnet/vnet/config.c | 361 - vnet/vnet/config.h | 176 - vnet/vnet/cop/cop.c | 387 - vnet/vnet/cop/cop.h | 89 - vnet/vnet/cop/ip4_whitelist.c | 356 - vnet/vnet/cop/ip6_whitelist.c | 298 - vnet/vnet/cop/node1.c | 319 - vnet/vnet/devices/af_packet/af_packet.api | 71 - vnet/vnet/devices/af_packet/af_packet.c | 366 - vnet/vnet/devices/af_packet/af_packet.h | 69 - vnet/vnet/devices/af_packet/af_packet_api.c | 143 - vnet/vnet/devices/af_packet/cli.c | 144 - vnet/vnet/devices/af_packet/device.c | 250 - vnet/vnet/devices/af_packet/node.c | 288 - vnet/vnet/devices/devices.c | 91 - vnet/vnet/devices/devices.h | 53 - vnet/vnet/devices/dpdk/cli.c | 1296 -- vnet/vnet/devices/dpdk/device.c | 840 - vnet/vnet/devices/dpdk/dpdk.h | 534 - vnet/vnet/devices/dpdk/dpdk_priv.h | 132 - vnet/vnet/devices/dpdk/format.c | 763 - vnet/vnet/devices/dpdk/hqos.c | 775 - vnet/vnet/devices/dpdk/init.c | 1803 -- vnet/vnet/devices/dpdk/ipsec/cli.c | 141 - vnet/vnet/devices/dpdk/ipsec/crypto_node.c | 210 - vnet/vnet/devices/dpdk/ipsec/dir.dox | 18 - .../devices/dpdk/ipsec/dpdk_crypto_ipsec_doc.md | 73 - vnet/vnet/devices/dpdk/ipsec/esp.h | 295 - vnet/vnet/devices/dpdk/ipsec/esp_decrypt.c | 583 - vnet/vnet/devices/dpdk/ipsec/esp_encrypt.c | 598 - vnet/vnet/devices/dpdk/ipsec/ipsec.c | 313 - vnet/vnet/devices/dpdk/ipsec/ipsec.h | 227 - vnet/vnet/devices/dpdk/node.c | 687 - vnet/vnet/devices/dpdk/qos_doc.md | 404 - vnet/vnet/devices/netmap/cli.c | 146 - vnet/vnet/devices/netmap/device.c | 261 - vnet/vnet/devices/netmap/net_netmap.h | 650 - vnet/vnet/devices/netmap/netmap.api | 74 - vnet/vnet/devices/netmap/netmap.c | 316 - vnet/vnet/devices/netmap/netmap.h | 164 - vnet/vnet/devices/netmap/netmap_api.c | 137 - vnet/vnet/devices/netmap/node.c | 300 - vnet/vnet/devices/nic/ixge.c | 2938 --- vnet/vnet/devices/nic/ixge.h | 1293 -- vnet/vnet/devices/nic/sfp.c | 117 - vnet/vnet/devices/nic/sfp.h | 117 - vnet/vnet/devices/ssvm/node.c | 343 - vnet/vnet/devices/ssvm/ssvm_eth.c | 491 - vnet/vnet/devices/ssvm/ssvm_eth.h | 141 - vnet/vnet/devices/virtio/dir.dox | 27 - vnet/vnet/devices/virtio/vhost-user.c | 3314 ---- vnet/vnet/devices/virtio/vhost-user.h | 350 - vnet/vnet/devices/virtio/vhost_user.api | 125 - vnet/vnet/devices/virtio/vhost_user_api.c | 262 - vnet/vnet/dhcp/client.c | 1031 -- vnet/vnet/dhcp/client.h | 118 - vnet/vnet/dhcp/packet.h | 61 - vnet/vnet/dhcp/proxy.h | 92 - vnet/vnet/dhcp/proxy_error.def | 30 - vnet/vnet/dhcp/proxy_node.c | 1114 -- vnet/vnet/dhcpv6/packet.h | 183 - vnet/vnet/dhcpv6/proxy.h | 95 - vnet/vnet/dhcpv6/proxy_error.def | 29 - vnet/vnet/dhcpv6/proxy_node.c | 1191 -- vnet/vnet/dpo/classify_dpo.c | 131 - vnet/vnet/dpo/classify_dpo.h | 56 - vnet/vnet/dpo/dpo.c | 500 - vnet/vnet/dpo/dpo.h | 381 - vnet/vnet/dpo/drop_dpo.c | 106 - vnet/vnet/dpo/drop_dpo.h | 31 - vnet/vnet/dpo/ip_null_dpo.c | 408 - vnet/vnet/dpo/ip_null_dpo.h | 56 - vnet/vnet/dpo/load_balance.c | 993 -- vnet/vnet/dpo/load_balance.h | 211 - vnet/vnet/dpo/load_balance_map.c | 575 - vnet/vnet/dpo/load_balance_map.h | 79 - vnet/vnet/dpo/lookup_dpo.c | 1185 -- vnet/vnet/dpo/lookup_dpo.h | 108 - vnet/vnet/dpo/mpls_label_dpo.c | 570 - vnet/vnet/dpo/mpls_label_dpo.h | 101 - vnet/vnet/dpo/punt_dpo.c | 100 - vnet/vnet/dpo/punt_dpo.h | 30 - vnet/vnet/dpo/receive_dpo.c | 165 - vnet/vnet/dpo/receive_dpo.h | 62 - vnet/vnet/ethernet/arp.c | 2355 --- vnet/vnet/ethernet/arp_packet.h | 173 - vnet/vnet/ethernet/dir.dox | 24 - vnet/vnet/ethernet/error.def | 46 - vnet/vnet/ethernet/ethernet.h | 561 - vnet/vnet/ethernet/format.c | 366 - vnet/vnet/ethernet/init.c | 128 - vnet/vnet/ethernet/interface.c | 730 - vnet/vnet/ethernet/mac_swap.c | 397 - vnet/vnet/ethernet/node.c | 1368 -- vnet/vnet/ethernet/packet.h | 152 - vnet/vnet/ethernet/pg.c | 183 - vnet/vnet/ethernet/types.def | 113 - vnet/vnet/feature/feature.c | 463 - vnet/vnet/feature/feature.h | 382 - vnet/vnet/feature/registration.c | 301 - vnet/vnet/fib/fib.c | 41 - vnet/vnet/fib/fib.h | 652 - vnet/vnet/fib/fib_api.h | 54 - vnet/vnet/fib/fib_attached_export.c | 572 - vnet/vnet/fib/fib_attached_export.h | 57 - vnet/vnet/fib/fib_entry.c | 1503 -- vnet/vnet/fib/fib_entry.h | 530 - vnet/vnet/fib/fib_entry_cover.c | 225 - vnet/vnet/fib/fib_entry_cover.h | 47 - vnet/vnet/fib/fib_entry_delegate.c | 149 - vnet/vnet/fib/fib_entry_delegate.h | 124 - vnet/vnet/fib/fib_entry_src.c | 1456 -- vnet/vnet/fib/fib_entry_src.h | 296 - vnet/vnet/fib/fib_entry_src_adj.c | 207 - vnet/vnet/fib/fib_entry_src_api.c | 119 - vnet/vnet/fib/fib_entry_src_default.c | 121 - vnet/vnet/fib/fib_entry_src_default_route.c | 58 - vnet/vnet/fib/fib_entry_src_interface.c | 195 - vnet/vnet/fib/fib_entry_src_lisp.c | 133 - vnet/vnet/fib/fib_entry_src_mpls.c | 196 - vnet/vnet/fib/fib_entry_src_rr.c | 293 - vnet/vnet/fib/fib_entry_src_special.c | 71 - vnet/vnet/fib/fib_internal.h | 69 - vnet/vnet/fib/fib_node.c | 277 - vnet/vnet/fib/fib_node.h | 371 - vnet/vnet/fib/fib_node_list.c | 390 - vnet/vnet/fib/fib_node_list.h | 64 - vnet/vnet/fib/fib_path.c | 2001 --- vnet/vnet/fib/fib_path.h | 158 - vnet/vnet/fib/fib_path_ext.c | 231 - vnet/vnet/fib/fib_path_ext.h | 69 - vnet/vnet/fib/fib_path_list.c | 1223 -- vnet/vnet/fib/fib_path_list.h | 158 - vnet/vnet/fib/fib_table.c | 1104 -- vnet/vnet/fib/fib_table.h | 732 - vnet/vnet/fib/fib_test.c | 7112 -------- vnet/vnet/fib/fib_types.c | 326 - vnet/vnet/fib/fib_types.h | 340 - vnet/vnet/fib/fib_urpf_list.c | 260 - vnet/vnet/fib/fib_urpf_list.h | 146 - vnet/vnet/fib/fib_walk.c | 1108 -- vnet/vnet/fib/fib_walk.h | 58 - vnet/vnet/fib/ip4_fib.c | 664 - vnet/vnet/fib/ip4_fib.h | 141 - vnet/vnet/fib/ip6_fib.c | 784 - vnet/vnet/fib/ip6_fib.h | 130 - vnet/vnet/fib/mpls_fib.c | 439 - vnet/vnet/fib/mpls_fib.h | 106 - vnet/vnet/flow/flow_report.c | 502 - vnet/vnet/flow/flow_report.h | 145 - vnet/vnet/flow/flow_report_classify.c | 529 - vnet/vnet/flow/flow_report_classify.h | 122 - vnet/vnet/flow/ipfix_info_elements.h | 429 - vnet/vnet/flow/ipfix_packet.h | 188 - vnet/vnet/global_funcs.h | 32 - vnet/vnet/gre/error.def | 23 - vnet/vnet/gre/gre.api | 57 - vnet/vnet/gre/gre.c | 455 - vnet/vnet/gre/gre.h | 235 - vnet/vnet/gre/gre_api.c | 204 - vnet/vnet/gre/interface.c | 606 - vnet/vnet/gre/node.c | 531 - vnet/vnet/gre/packet.h | 55 - vnet/vnet/gre/pg.c | 77 - vnet/vnet/handoff.c | 594 - vnet/vnet/handoff.h | 259 - vnet/vnet/hdlc/error.def | 42 - vnet/vnet/hdlc/hdlc.c | 249 - vnet/vnet/hdlc/hdlc.h | 127 - vnet/vnet/hdlc/node.c | 351 - vnet/vnet/hdlc/packet.h | 72 - vnet/vnet/hdlc/pg.c | 105 - vnet/vnet/interface.api | 339 - vnet/vnet/interface.c | 1398 -- vnet/vnet/interface.h | 658 - vnet/vnet/interface_api.c | 725 - vnet/vnet/interface_cli.c | 1165 -- vnet/vnet/interface_format.c | 401 - vnet/vnet/interface_funcs.h | 318 - vnet/vnet/interface_output.c | 1404 -- vnet/vnet/ip/dir.dox | 26 - vnet/vnet/ip/format.c | 121 - vnet/vnet/ip/format.h | 114 - vnet/vnet/ip/icmp4.c | 784 - vnet/vnet/ip/icmp4.h | 60 - vnet/vnet/ip/icmp46_packet.h | 398 - vnet/vnet/ip/icmp6.c | 882 - vnet/vnet/ip/icmp6.h | 86 - vnet/vnet/ip/igmp_packet.h | 155 - vnet/vnet/ip/ip.api | 434 - vnet/vnet/ip/ip.h | 195 - vnet/vnet/ip/ip4.h | 322 - vnet/vnet/ip/ip46_cli.c | 236 - vnet/vnet/ip/ip4_error.h | 95 - vnet/vnet/ip/ip4_format.c | 256 - vnet/vnet/ip/ip4_forward.c | 3345 ---- vnet/vnet/ip/ip4_input.c | 507 - vnet/vnet/ip/ip4_mtrie.c | 568 - vnet/vnet/ip/ip4_mtrie.h | 188 - vnet/vnet/ip/ip4_packet.h | 384 - vnet/vnet/ip/ip4_pg.c | 387 - vnet/vnet/ip/ip4_source_and_port_range_check.c | 1415 -- vnet/vnet/ip/ip4_source_check.c | 573 - vnet/vnet/ip/ip4_test.c | 340 - vnet/vnet/ip/ip6.h | 476 - vnet/vnet/ip/ip6_error.h | 92 - vnet/vnet/ip/ip6_format.c | 383 - vnet/vnet/ip/ip6_forward.c | 3402 ---- vnet/vnet/ip/ip6_hop_by_hop.c | 1194 -- vnet/vnet/ip/ip6_hop_by_hop.h | 217 - vnet/vnet/ip/ip6_hop_by_hop_packet.h | 66 - vnet/vnet/ip/ip6_input.c | 353 - vnet/vnet/ip/ip6_neighbor.c | 4088 ----- vnet/vnet/ip/ip6_neighbor.h | 52 - vnet/vnet/ip/ip6_packet.h | 499 - vnet/vnet/ip/ip6_pg.c | 231 - vnet/vnet/ip/ip_api.c | 1196 -- vnet/vnet/ip/ip_checksum.c | 228 - vnet/vnet/ip/ip_frag.c | 581 - vnet/vnet/ip/ip_frag.h | 96 - vnet/vnet/ip/ip_init.c | 152 - vnet/vnet/ip/ip_input_acl.c | 450 - vnet/vnet/ip/ip_packet.h | 180 - vnet/vnet/ip/ip_source_and_port_range_check.h | 148 - vnet/vnet/ip/lookup.c | 967 - vnet/vnet/ip/lookup.h | 498 - vnet/vnet/ip/ping.c | 888 - vnet/vnet/ip/ping.h | 108 - vnet/vnet/ip/ports.def | 757 - vnet/vnet/ip/protocols.def | 162 - vnet/vnet/ip/punt.c | 323 - vnet/vnet/ip/punt.h | 43 - vnet/vnet/ip/punt_error.def | 19 - vnet/vnet/ip/tcp_packet.h | 138 - vnet/vnet/ip/udp.h | 313 - vnet/vnet/ip/udp_error.def | 21 - vnet/vnet/ip/udp_format.c | 91 - vnet/vnet/ip/udp_init.c | 71 - vnet/vnet/ip/udp_local.c | 645 - vnet/vnet/ip/udp_packet.h | 65 - vnet/vnet/ip/udp_pg.c | 237 - vnet/vnet/ipsec-gre/dir.dox | 18 - vnet/vnet/ipsec-gre/error.def | 26 - vnet/vnet/ipsec-gre/interface.c | 311 - vnet/vnet/ipsec-gre/ipsec_gre.api | 79 - vnet/vnet/ipsec-gre/ipsec_gre.c | 407 - vnet/vnet/ipsec-gre/ipsec_gre.h | 114 - vnet/vnet/ipsec-gre/ipsec_gre_api.c | 190 - vnet/vnet/ipsec-gre/ipsec_gre_doc.md | 74 - vnet/vnet/ipsec-gre/node.c | 433 - vnet/vnet/ipsec/esp.h | 320 - vnet/vnet/ipsec/esp_decrypt.c | 430 - vnet/vnet/ipsec/esp_encrypt.c | 425 - vnet/vnet/ipsec/ikev2.c | 2186 --- vnet/vnet/ipsec/ikev2.h | 410 - vnet/vnet/ipsec/ikev2_cli.c | 479 - vnet/vnet/ipsec/ikev2_crypto.c | 765 - vnet/vnet/ipsec/ikev2_format.c | 155 - vnet/vnet/ipsec/ikev2_payload.c | 535 - vnet/vnet/ipsec/ikev2_priv.h | 321 - vnet/vnet/ipsec/ipsec.api | 457 - vnet/vnet/ipsec/ipsec.c | 581 - vnet/vnet/ipsec/ipsec.h | 344 - vnet/vnet/ipsec/ipsec_api.c | 537 - vnet/vnet/ipsec/ipsec_cli.c | 807 - vnet/vnet/ipsec/ipsec_format.c | 141 - vnet/vnet/ipsec/ipsec_if.c | 372 - vnet/vnet/ipsec/ipsec_if_in.c | 175 - vnet/vnet/ipsec/ipsec_if_out.c | 161 - vnet/vnet/ipsec/ipsec_input.c | 455 - vnet/vnet/ipsec/ipsec_output.c | 478 - vnet/vnet/l2/dir.dox | 24 - vnet/vnet/l2/feat_bitmap.c | 185 - vnet/vnet/l2/feat_bitmap.h | 96 - vnet/vnet/l2/l2.api | 38 - vnet/vnet/l2/l2_api.c | 140 - vnet/vnet/l2/l2_bd.c | 1079 -- vnet/vnet/l2/l2_bd.h | 150 - vnet/vnet/l2/l2_bvi.c | 40 - vnet/vnet/l2/l2_bvi.h | 117 - vnet/vnet/l2/l2_classify.h | 116 - vnet/vnet/l2/l2_efp_filter.c | 614 - vnet/vnet/l2/l2_efp_filter.h | 33 - vnet/vnet/l2/l2_fib.c | 857 - vnet/vnet/l2/l2_fib.h | 341 - vnet/vnet/l2/l2_flood.c | 568 - vnet/vnet/l2/l2_flood.h | 35 - vnet/vnet/l2/l2_fwd.c | 544 - vnet/vnet/l2/l2_fwd.h | 36 - vnet/vnet/l2/l2_input.c | 1116 -- vnet/vnet/l2/l2_input.h | 266 - vnet/vnet/l2/l2_input_acl.c | 434 - vnet/vnet/l2/l2_input_classify.c | 655 - vnet/vnet/l2/l2_input_vtr.c | 401 - vnet/vnet/l2/l2_input_vtr.h | 54 - vnet/vnet/l2/l2_learn.c | 597 - vnet/vnet/l2/l2_learn.h | 64 - vnet/vnet/l2/l2_output.c | 708 - vnet/vnet/l2/l2_output.h | 285 - vnet/vnet/l2/l2_output_acl.c | 358 - vnet/vnet/l2/l2_output_classify.c | 657 - vnet/vnet/l2/l2_patch.c | 452 - vnet/vnet/l2/l2_rw.c | 719 - vnet/vnet/l2/l2_rw.h | 95 - vnet/vnet/l2/l2_vtr.c | 770 - vnet/vnet/l2/l2_vtr.h | 270 - vnet/vnet/l2/l2_xcrw.c | 591 - vnet/vnet/l2/l2_xcrw.h | 91 - vnet/vnet/l2tp/decap.c | 309 - vnet/vnet/l2tp/encap.c | 238 - vnet/vnet/l2tp/l2tp.api | 126 - vnet/vnet/l2tp/l2tp.c | 739 - vnet/vnet/l2tp/l2tp.h | 147 - vnet/vnet/l2tp/l2tp_api.c | 267 - vnet/vnet/l2tp/packet.h | 44 - vnet/vnet/l2tp/pg.c | 106 - vnet/vnet/l3_types.h | 59 - vnet/vnet/lawful-intercept/lawful_intercept.c | 112 - vnet/vnet/lawful-intercept/lawful_intercept.h | 45 - vnet/vnet/lawful-intercept/node.c | 275 - vnet/vnet/lisp-cp/control.c | 4950 ----- vnet/vnet/lisp-cp/control.h | 314 - vnet/vnet/lisp-cp/gid_dictionary.c | 865 - vnet/vnet/lisp-cp/gid_dictionary.h | 120 - vnet/vnet/lisp-cp/lisp.api | 835 - vnet/vnet/lisp-cp/lisp_api.c | 1257 -- vnet/vnet/lisp-cp/lisp_cp_dpo.c | 117 - vnet/vnet/lisp-cp/lisp_cp_dpo.h | 45 - vnet/vnet/lisp-cp/lisp_cp_messages.h | 613 - vnet/vnet/lisp-cp/lisp_msg_serdes.c | 372 - vnet/vnet/lisp-cp/lisp_msg_serdes.h | 58 - vnet/vnet/lisp-cp/lisp_types.c | 1574 -- vnet/vnet/lisp-cp/lisp_types.h | 354 - vnet/vnet/lisp-cp/packets.c | 269 - vnet/vnet/lisp-cp/packets.h | 82 - vnet/vnet/lisp-gpe/decap.c | 501 - vnet/vnet/lisp-gpe/dir.dox | 26 - vnet/vnet/lisp-gpe/interface.c | 709 - vnet/vnet/lisp-gpe/lisp_gpe.api | 143 - vnet/vnet/lisp-gpe/lisp_gpe.c | 327 - vnet/vnet/lisp-gpe/lisp_gpe.h | 257 - vnet/vnet/lisp-gpe/lisp_gpe_adjacency.c | 542 - vnet/vnet/lisp-gpe/lisp_gpe_adjacency.h | 136 - vnet/vnet/lisp-gpe/lisp_gpe_api.c | 304 - vnet/vnet/lisp-gpe/lisp_gpe_error.def | 18 - vnet/vnet/lisp-gpe/lisp_gpe_fwd_entry.c | 1053 -- vnet/vnet/lisp-gpe/lisp_gpe_fwd_entry.h | 188 - vnet/vnet/lisp-gpe/lisp_gpe_packet.h | 149 - vnet/vnet/lisp-gpe/lisp_gpe_sub_interface.c | 278 - vnet/vnet/lisp-gpe/lisp_gpe_sub_interface.h | 157 - vnet/vnet/lisp-gpe/lisp_gpe_tenant.c | 330 - vnet/vnet/lisp-gpe/lisp_gpe_tenant.h | 88 - vnet/vnet/lisp-gpe/lisp_gpe_tunnel.c | 289 - vnet/vnet/lisp-gpe/lisp_gpe_tunnel.h | 89 - vnet/vnet/lisp-gpe/rfc.txt | 826 - vnet/vnet/llc/llc.c | 241 - vnet/vnet/llc/llc.h | 194 - vnet/vnet/llc/node.c | 331 - vnet/vnet/llc/pg.c | 113 - vnet/vnet/lldp/dir.dox | 18 - vnet/vnet/lldp/lldp_cli.c | 646 - vnet/vnet/lldp/lldp_doc.md | 84 - vnet/vnet/lldp/lldp_input.c | 302 - vnet/vnet/lldp/lldp_node.c | 341 - vnet/vnet/lldp/lldp_node.h | 145 - vnet/vnet/lldp/lldp_output.c | 216 - vnet/vnet/lldp/lldp_protocol.h | 142 - vnet/vnet/map/examples/gen-rules.py | 186 - vnet/vnet/map/examples/health_check.c | 109 - vnet/vnet/map/examples/test_map.py | 141 - vnet/vnet/map/gen-rules.py | 107 - vnet/vnet/map/ip4_map.c | 813 - vnet/vnet/map/ip4_map_t.c | 1363 -- vnet/vnet/map/ip6_map.c | 1269 -- vnet/vnet/map/ip6_map_t.c | 1517 -- vnet/vnet/map/map.api | 178 - vnet/vnet/map/map.c | 2166 --- vnet/vnet/map/map.h | 591 - vnet/vnet/map/map_api.c | 295 - vnet/vnet/map/map_doc.md | 69 - vnet/vnet/map/map_dpo.c | 191 - vnet/vnet/map/map_dpo.h | 67 - vnet/vnet/map/test.c | 205 - vnet/vnet/mcast/mcast.c | 565 - vnet/vnet/mcast/mcast.h | 50 - vnet/vnet/mcast/mcast_test.c | 149 - vnet/vnet/misc.c | 124 - vnet/vnet/mpls/error.def | 31 - vnet/vnet/mpls/interface.c | 121 - vnet/vnet/mpls/mpls.c | 511 - vnet/vnet/mpls/mpls.h | 172 - vnet/vnet/mpls/mpls_features.c | 156 - vnet/vnet/mpls/mpls_lookup.c | 531 - vnet/vnet/mpls/mpls_output.c | 479 - vnet/vnet/mpls/mpls_tunnel.c | 787 - vnet/vnet/mpls/mpls_tunnel.h | 98 - vnet/vnet/mpls/mpls_types.h | 39 - vnet/vnet/mpls/node.c | 303 - vnet/vnet/mpls/packet.h | 125 - vnet/vnet/mpls/pg.c | 71 - vnet/vnet/osi/node.c | 326 - vnet/vnet/osi/osi.c | 201 - vnet/vnet/osi/osi.h | 171 - vnet/vnet/osi/pg.c | 106 - vnet/vnet/pg/cli.c | 636 - vnet/vnet/pg/edit.c | 186 - vnet/vnet/pg/edit.h | 210 - vnet/vnet/pg/example.script | 6 - vnet/vnet/pg/init.c | 72 - vnet/vnet/pg/input.c | 1667 -- vnet/vnet/pg/output.c | 85 - vnet/vnet/pg/pg.h | 383 - vnet/vnet/pg/stream.c | 497 - vnet/vnet/pipeline.h | 456 - vnet/vnet/plugin/p1.c | 52 - vnet/vnet/plugin/plugin.h | 32 - vnet/vnet/policer/node_funcs.c | 938 - vnet/vnet/policer/police.h | 214 - vnet/vnet/policer/policer.c | 528 - vnet/vnet/policer/policer.h | 107 - vnet/vnet/policer/xlate.c | 1505 -- vnet/vnet/policer/xlate.h | 186 - vnet/vnet/ppp/error.def | 42 - vnet/vnet/ppp/node.c | 368 - vnet/vnet/ppp/packet.h | 199 - vnet/vnet/ppp/pg.c | 114 - vnet/vnet/ppp/ppp.c | 261 - vnet/vnet/ppp/ppp.h | 135 - vnet/vnet/replication.c | 293 - vnet/vnet/replication.h | 136 - vnet/vnet/rewrite.c | 329 - vnet/vnet/rewrite.h | 305 - vnet/vnet/snap/node.c | 353 - vnet/vnet/snap/pg.c | 116 - vnet/vnet/snap/snap.c | 204 - vnet/vnet/snap/snap.h | 209 - vnet/vnet/span/node.c | 286 - vnet/vnet/span/span.api | 60 - vnet/vnet/span/span.c | 197 - vnet/vnet/span/span.h | 62 - vnet/vnet/span/span.md | 65 - vnet/vnet/span/span_api.c | 153 - vnet/vnet/sr/dir.dox | 25 - vnet/vnet/sr/examples/sr_multicastmap.script | 4 - vnet/vnet/sr/rfc_draft_05.txt | 1265 -- vnet/vnet/sr/sr.c | 3333 ---- vnet/vnet/sr/sr.h | 262 - vnet/vnet/sr/sr_error.def | 20 - vnet/vnet/sr/sr_fix_dst_error.def | 17 - vnet/vnet/sr/sr_packet.h | 251 - vnet/vnet/sr/sr_replicate.c | 490 - vnet/vnet/srp/format.c | 147 - vnet/vnet/srp/interface.c | 458 - vnet/vnet/srp/node.c | 932 - vnet/vnet/srp/packet.h | 204 - vnet/vnet/srp/pg.c | 157 - vnet/vnet/srp/srp.h | 222 - vnet/vnet/unix/gdb_funcs.c | 171 - vnet/vnet/unix/pcap.c | 241 - vnet/vnet/unix/pcap.h | 230 - vnet/vnet/unix/pcap2pg.c | 182 - vnet/vnet/unix/tap.api | 123 - vnet/vnet/unix/tap_api.c | 257 - vnet/vnet/unix/tapcli.c | 1328 -- vnet/vnet/unix/tapcli.h | 52 - vnet/vnet/unix/tuntap.c | 1000 -- vnet/vnet/unix/tuntap.h | 36 - vnet/vnet/vnet.h | 96 - vnet/vnet/vnet_all_api_h.h | 57 - vnet/vnet/vnet_msg_enum.h | 37 - vnet/vnet/vxlan-gpe/decap.c | 733 - vnet/vnet/vxlan-gpe/dir.dox | 32 - vnet/vnet/vxlan-gpe/encap.c | 388 - vnet/vnet/vxlan-gpe/vxlan-gpe-rfc.txt | 868 - vnet/vnet/vxlan-gpe/vxlan_gpe.api | 61 - vnet/vnet/vxlan-gpe/vxlan_gpe.c | 659 - vnet/vnet/vxlan-gpe/vxlan_gpe.h | 221 - vnet/vnet/vxlan-gpe/vxlan_gpe_api.c | 249 - vnet/vnet/vxlan-gpe/vxlan_gpe_error.def | 16 - vnet/vnet/vxlan-gpe/vxlan_gpe_packet.h | 110 - vnet/vnet/vxlan/decap.c | 1130 -- vnet/vnet/vxlan/dir.dox | 24 - vnet/vnet/vxlan/encap.c | 553 - vnet/vnet/vxlan/vxlan.api | 81 - vnet/vnet/vxlan/vxlan.c | 899 - vnet/vnet/vxlan/vxlan.h | 199 - vnet/vnet/vxlan/vxlan_api.c | 253 - vnet/vnet/vxlan/vxlan_error.def | 17 - vnet/vnet/vxlan/vxlan_packet.h | 69 - vpp-api-test/Makefile.am | 37 - vpp-api-test/configure.ac | 40 - vpp-api-test/scripts/vppctl | 121 - vpp-api-test/vat/api_format.c | 17827 ------------------ vpp-api-test/vat/json_format.c | 304 - vpp-api-test/vat/json_format.h | 254 - vpp-api-test/vat/json_test.c | 75 - vpp-api-test/vat/main.c | 418 - vpp-api-test/vat/plugin.c | 201 - vpp-api-test/vat/plugin.h | 61 - vpp-api-test/vat/plugin_api.c | 216 - vpp-api-test/vat/restart.c | 246 - vpp-api-test/vat/vat.h | 257 - vpp-api/Makefile.am | 4 +- vpp-api/configure.ac | 1 - vpp-api/java/Makefile.am | 3 +- vpp-api/java/jvpp-core/jvpp_core.c | 8 +- vpp-api/java/jvpp-registry/jvpp_registry.c | 10 +- vpp-api/java/jvpp/gen/jvpp_gen.py | 5 + vpp-api/python/Makefile.am | 51 - vpp-api/python/README.rst | 0 vpp-api/python/pneum/pneum.c | 259 - vpp-api/python/pneum/pneum.h | 31 - vpp-api/python/pneum/test_pneum.c | 143 - vpp-api/python/setup.cfg | 5 - vpp-api/python/setup.py | 34 - vpp-api/python/tests/test_cli.py | 52 - vpp-api/python/tests/test_modules.py | 18 - vpp-api/python/tests/test_papi.py | 119 - vpp-api/python/tests/test_version.py | 35 - vpp-api/python/tests/test_vpp_papi2.py | 487 - vpp-api/python/vpp_papi/__init__.py | 3 - vpp-api/python/vpp_papi/pneum_wrap.c | 200 - vpp-api/python/vpp_papi/vpp_papi.py | 450 - vpp/Makefile.am | 166 - vpp/app/l2t.c | 557 - vpp/app/l2t_l2.c | 267 - vpp/app/sticky_hash.c | 581 - vpp/app/version.c | 102 - vpp/app/vpe_cli.c | 123 - vpp/conf/80-vpp.conf | 15 - vpp/conf/startup.conf | 99 - vpp/conf/startup.uiopcigeneric.conf | 18 - vpp/configure.ac | 80 - vpp/oam/oam.c | 648 - vpp/oam/oam.h | 96 - vpp/stats/stats.c | 987 - vpp/stats/stats.h | 76 - vpp/suffix-rules.mk | 1 - vpp/vnet/main.c | 414 - vpp/vpp-api/api.c | 4921 ----- vpp/vpp-api/api_format.c | 1 - vpp/vpp-api/api_main.c | 192 - vpp/vpp-api/custom_dump.c | 3139 ---- vpp/vpp-api/gmon.c | 319 - vpp/vpp-api/json_format.c | 304 - vpp/vpp-api/json_format.h | 254 - vpp/vpp-api/summary_stats_client.c | 302 - vpp/vpp-api/test_client.c | 1531 -- vpp/vpp-api/test_ha.c | 249 - vpp/vpp-api/vat.h | 1 - vpp/vpp-api/vpe.api | 2782 --- vpp/vpp-api/vpe_all_api_h.h | 37 - vpp/vpp-api/vpe_msg_enum.h | 37 - vpp/vpp-api/vpp_get_metrics.c | 253 - vppapigen/Makefile.am | 29 - vppapigen/configure.ac | 14 - vppapigen/gram.y | 90 - vppapigen/lex.c | 1067 -- vppapigen/lex.h | 50 - vppapigen/node.c | 1531 -- vppapigen/node.h | 94 - vppinfra/.gitignore | 1 - vppinfra/INSTALL | 236 - vppinfra/Make.defs | 129 - vppinfra/Makefile.am | 275 - vppinfra/README | 43 - vppinfra/configure.ac | 52 - vppinfra/dir.dox | 19 - vppinfra/mkinstalldirs | 111 - vppinfra/tools/dir.dox | 19 - vppinfra/tools/elftool.c | 464 - vppinfra/unix_error.def | 145 - vppinfra/vppinfra/anneal.c | 172 - vppinfra/vppinfra/anneal.h | 89 - vppinfra/vppinfra/asm_mips.h | 351 - vppinfra/vppinfra/asm_x86.c | 1947 -- vppinfra/vppinfra/asm_x86.h | 125 - vppinfra/vppinfra/backtrace.c | 267 - vppinfra/vppinfra/bihash_24_8.h | 85 - vppinfra/vppinfra/bihash_8_8.h | 98 - vppinfra/vppinfra/bihash_doc.h | 149 - vppinfra/vppinfra/bihash_template.c | 455 - vppinfra/vppinfra/bihash_template.h | 214 - vppinfra/vppinfra/bitmap.h | 774 - vppinfra/vppinfra/bitops.h | 179 - vppinfra/vppinfra/byte_order.h | 202 - vppinfra/vppinfra/cache.h | 104 - vppinfra/vppinfra/clib.h | 359 - vppinfra/vppinfra/cpu.c | 133 - vppinfra/vppinfra/cpu.h | 112 - vppinfra/vppinfra/dir.dox | 19 - vppinfra/vppinfra/dlist.h | 156 - vppinfra/vppinfra/elf.c | 2040 --- vppinfra/vppinfra/elf.h | 1062 -- vppinfra/vppinfra/elf_clib.c | 377 - vppinfra/vppinfra/elf_clib.h | 144 - vppinfra/vppinfra/elog.c | 1061 -- vppinfra/vppinfra/elog.h | 460 - vppinfra/vppinfra/error.c | 292 - vppinfra/vppinfra/error.h | 201 - vppinfra/vppinfra/error_bootstrap.h | 106 - vppinfra/vppinfra/fheap.c | 473 - vppinfra/vppinfra/fheap.h | 140 - vppinfra/vppinfra/fifo.c | 137 - vppinfra/vppinfra/fifo.h | 304 - vppinfra/vppinfra/format.c | 814 - vppinfra/vppinfra/format.h | 331 - vppinfra/vppinfra/graph.c | 182 - vppinfra/vppinfra/graph.h | 127 - vppinfra/vppinfra/hash.c | 1095 -- vppinfra/vppinfra/hash.h | 699 - vppinfra/vppinfra/heap.c | 828 - vppinfra/vppinfra/heap.h | 357 - vppinfra/vppinfra/longjmp.S | 690 - vppinfra/vppinfra/longjmp.h | 124 - vppinfra/vppinfra/macros.c | 266 - vppinfra/vppinfra/macros.h | 54 - vppinfra/vppinfra/math.h | 63 - vppinfra/vppinfra/md5.c | 317 - vppinfra/vppinfra/md5.h | 57 - vppinfra/vppinfra/mem.h | 291 - vppinfra/vppinfra/mem_mheap.c | 165 - vppinfra/vppinfra/memcheck.h | 317 - vppinfra/vppinfra/memcpy_avx.h | 293 - vppinfra/vppinfra/memcpy_sse3.h | 355 - vppinfra/vppinfra/mhash.c | 408 - vppinfra/vppinfra/mhash.h | 179 - vppinfra/vppinfra/mheap.c | 1649 -- vppinfra/vppinfra/mheap.h | 94 - vppinfra/vppinfra/mheap_bootstrap.h | 374 - vppinfra/vppinfra/mod_test_hash.c | 27 - vppinfra/vppinfra/os.h | 72 - vppinfra/vppinfra/pfhash.c | 689 - vppinfra/vppinfra/pfhash.h | 276 - vppinfra/vppinfra/phash.c | 1017 -- vppinfra/vppinfra/phash.h | 194 - vppinfra/vppinfra/pipeline.h | 176 - vppinfra/vppinfra/pool.h | 405 - vppinfra/vppinfra/ptclosure.c | 125 - vppinfra/vppinfra/ptclosure.h | 40 - vppinfra/vppinfra/qhash.c | 858 - vppinfra/vppinfra/qhash.h | 169 - vppinfra/vppinfra/qsort.c | 269 - vppinfra/vppinfra/random.c | 51 - vppinfra/vppinfra/random.h | 178 - vppinfra/vppinfra/random_buffer.c | 86 - vppinfra/vppinfra/random_buffer.h | 118 - vppinfra/vppinfra/random_isaac.c | 434 - vppinfra/vppinfra/random_isaac.h | 81 - vppinfra/vppinfra/serialize.c | 1254 -- vppinfra/vppinfra/serialize.h | 443 - vppinfra/vppinfra/slist.c | 336 - vppinfra/vppinfra/slist.h | 145 - vppinfra/vppinfra/smp.c | 325 - vppinfra/vppinfra/smp.h | 81 - vppinfra/vppinfra/smp_fifo.c | 91 - vppinfra/vppinfra/smp_fifo.h | 313 - vppinfra/vppinfra/socket.c | 422 - vppinfra/vppinfra/socket.h | 160 - vppinfra/vppinfra/sparse_vec.h | 244 - vppinfra/vppinfra/std-formats.c | 330 - vppinfra/vppinfra/string.c | 94 - vppinfra/vppinfra/string.h | 83 - vppinfra/vppinfra/test_bihash_template.c | 297 - vppinfra/vppinfra/test_dlist.c | 193 - vppinfra/vppinfra/test_elf.c | 217 - vppinfra/vppinfra/test_elog.c | 262 - vppinfra/vppinfra/test_fifo.c | 144 - vppinfra/vppinfra/test_format.c | 199 - vppinfra/vppinfra/test_hash.c | 458 - vppinfra/vppinfra/test_heap.c | 198 - vppinfra/vppinfra/test_longjmp.c | 129 - vppinfra/vppinfra/test_macros.c | 64 - vppinfra/vppinfra/test_md5.c | 141 - vppinfra/vppinfra/test_mheap.c | 242 - vppinfra/vppinfra/test_pfhash.c | 322 - vppinfra/vppinfra/test_phash.c | 149 - vppinfra/vppinfra/test_pool.c | 86 - vppinfra/vppinfra/test_pool_iterate.c | 59 - vppinfra/vppinfra/test_ptclosure.c | 212 - vppinfra/vppinfra/test_qhash.c | 333 - vppinfra/vppinfra/test_random.c | 148 - vppinfra/vppinfra/test_random_isaac.c | 142 - vppinfra/vppinfra/test_serialize.c | 274 - vppinfra/vppinfra/test_slist.c | 228 - vppinfra/vppinfra/test_socket.c | 134 - vppinfra/vppinfra/test_time.c | 104 - vppinfra/vppinfra/test_timing_wheel.c | 389 - vppinfra/vppinfra/test_vec.c | 1159 -- vppinfra/vppinfra/test_vec.h | 243 - vppinfra/vppinfra/test_vhash.c | 757 - vppinfra/vppinfra/test_zvec.c | 117 - vppinfra/vppinfra/time.c | 226 - vppinfra/vppinfra/time.h | 298 - vppinfra/vppinfra/timer.c | 322 - vppinfra/vppinfra/timer.h | 46 - vppinfra/vppinfra/timing_wheel.c | 750 - vppinfra/vppinfra/timing_wheel.h | 155 - vppinfra/vppinfra/types.h | 174 - vppinfra/vppinfra/unformat.c | 1077 -- vppinfra/vppinfra/unix-formats.c | 918 - vppinfra/vppinfra/unix-kelog.c | 415 - vppinfra/vppinfra/unix-misc.c | 242 - vppinfra/vppinfra/unix.h | 64 - vppinfra/vppinfra/valgrind.h | 4030 ----- vppinfra/vppinfra/vec.c | 171 - vppinfra/vppinfra/vec.h | 973 - vppinfra/vppinfra/vec_bootstrap.h | 201 - vppinfra/vppinfra/vector.c | 54 - vppinfra/vppinfra/vector.h | 268 - vppinfra/vppinfra/vector_altivec.h | 178 - vppinfra/vppinfra/vector_funcs.h | 334 - vppinfra/vppinfra/vector_iwmmxt.h | 149 - vppinfra/vppinfra/vector_neon.h | 71 - vppinfra/vppinfra/vector_sse2.h | 711 - vppinfra/vppinfra/vhash.c | 772 - vppinfra/vppinfra/vhash.h | 850 - vppinfra/vppinfra/vm_linux_kernel.h | 78 - vppinfra/vppinfra/vm_standalone.h | 74 - vppinfra/vppinfra/vm_unix.h | 106 - vppinfra/vppinfra/xxhash.h | 86 - vppinfra/vppinfra/xy.h | 56 - vppinfra/vppinfra/zvec.c | 442 - vppinfra/vppinfra/zvec.h | 166 - 2038 files changed, 380675 insertions(+), 381455 deletions(-) delete mode 100644 build-data/packages/cavium-dpdk.mk create mode 100644 build-data/packages/src.mk delete mode 100644 build-data/packages/svm.mk delete mode 100644 build-data/packages/vlib-api-cavium-dpdk.mk delete mode 100644 build-data/packages/vlib-api.mk delete mode 100644 build-data/packages/vlib-cavium-dpdk.mk delete mode 100644 build-data/packages/vlib.mk delete mode 100644 build-data/packages/vnet-cavium-dpdk.mk delete mode 100644 build-data/packages/vpp-api-test-cavium-dpdk.mk delete mode 100644 build-data/packages/vpp-api-test.mk delete mode 100644 build-data/packages/vpp-cavium-dpdk.mk delete mode 100644 build-data/packages/vppinfra.mk delete mode 100644 build-data/suffix-rules.mk create mode 100644 build-root/packages/src.mk create mode 100644 build-root/packages/tools.mk delete mode 100644 build-root/packages/vppapigen.mk delete mode 100644 g2/Makefile.am delete mode 100644 g2/clib.c delete mode 100644 g2/configure.ac delete mode 100644 g2/cpel.c delete mode 100644 g2/cpel.h delete mode 100644 g2/events.c delete mode 100644 g2/g2.h delete mode 100644 g2/g2version.c delete mode 100644 g2/main.c delete mode 100644 g2/menu1.c delete mode 100644 g2/mkversion.c delete mode 100644 g2/pointsel.c delete mode 100644 g2/props.c delete mode 100644 g2/props.h delete mode 100644 g2/view1.c delete mode 100644 perftool/Makefile.am delete mode 100644 perftool/c2cpel.c delete mode 100644 perftool/configure.ac delete mode 100644 perftool/cpel.h delete mode 100644 perftool/cpel_util.c delete mode 100644 perftool/cpel_util.h delete mode 100644 perftool/cpelatency.c delete mode 100644 perftool/cpeldump.c delete mode 100644 perftool/cpelinreg.c delete mode 100644 perftool/cpelstate.c delete mode 100644 perftool/delsvec.c delete mode 100644 perftool/linreg.c delete mode 100644 perftool/new.cpel delete mode 100644 perftool/new.elog delete mode 100644 perftool/props.c delete mode 100644 plugins/flowperpkt-plugin/Makefile.am delete mode 100644 plugins/flowperpkt-plugin/configure.ac delete mode 100644 plugins/flowperpkt-plugin/flowperpkt/flowperpkt.api delete mode 100644 plugins/flowperpkt-plugin/flowperpkt/flowperpkt.c delete mode 100644 plugins/flowperpkt-plugin/flowperpkt/flowperpkt.h delete mode 100644 plugins/flowperpkt-plugin/flowperpkt/flowperpkt_all_api_h.h delete mode 100644 plugins/flowperpkt-plugin/flowperpkt/flowperpkt_msg_enum.h delete mode 100644 plugins/flowperpkt-plugin/flowperpkt/flowperpkt_test.c delete mode 100644 plugins/flowperpkt-plugin/flowperpkt/l2_node.c delete mode 100644 plugins/flowperpkt-plugin/flowperpkt/node.c delete mode 100644 plugins/flowperpkt-plugin/flowperpkt_plugin_doc.md delete mode 100644 plugins/ila-plugin/Makefile.am delete mode 100644 plugins/ila-plugin/configure.ac delete mode 100644 plugins/ila-plugin/ila/ila.c delete mode 100644 plugins/ila-plugin/ila/ila.h delete mode 100644 plugins/sixrd-plugin/Makefile.am delete mode 100644 plugins/sixrd-plugin/configure.ac delete mode 100644 plugins/sixrd-plugin/sixrd/ip4_sixrd.c delete mode 100644 plugins/sixrd-plugin/sixrd/ip6_sixrd.c delete mode 100644 plugins/sixrd-plugin/sixrd/sixrd.c delete mode 100644 plugins/sixrd-plugin/sixrd/sixrd.h delete mode 100644 plugins/sixrd-plugin/sixrd/sixrd_dpo.c delete mode 100644 plugins/sixrd-plugin/sixrd/sixrd_dpo.h create mode 100644 src/Makefile.am create mode 100644 src/configure.ac create mode 100644 src/examples/vlib/dir.dox create mode 100644 src/examples/vlib/main_stub.c create mode 100644 src/examples/vlib/mc_test.c create mode 100644 src/examples/vlib/plex_test.c create mode 100644 src/g2.am create mode 100644 src/perftool.am create mode 100644 src/plugins/Makefile.am create mode 100644 src/plugins/flowperpkt.am create mode 100644 src/plugins/flowperpkt/flowperpkt.api create mode 100644 src/plugins/flowperpkt/flowperpkt.c create mode 100644 src/plugins/flowperpkt/flowperpkt.h create mode 100644 src/plugins/flowperpkt/flowperpkt_all_api_h.h create mode 100644 src/plugins/flowperpkt/flowperpkt_msg_enum.h create mode 100644 src/plugins/flowperpkt/flowperpkt_plugin_doc.md create mode 100644 src/plugins/flowperpkt/flowperpkt_test.c create mode 100644 src/plugins/flowperpkt/l2_node.c create mode 100644 src/plugins/flowperpkt/node.c create mode 100644 src/plugins/ila.am create mode 100644 src/plugins/ila/ila.c create mode 100644 src/plugins/ila/ila.h create mode 100644 src/plugins/sixrd.am create mode 100644 src/plugins/sixrd/ip4_sixrd.c create mode 100644 src/plugins/sixrd/ip6_sixrd.c create mode 100644 src/plugins/sixrd/sixrd.c create mode 100644 src/plugins/sixrd/sixrd.h create mode 100644 src/plugins/sixrd/sixrd_dpo.c create mode 100644 src/plugins/sixrd/sixrd_dpo.h create mode 100644 src/scripts/vnet/arp4 create mode 100644 src/scripts/vnet/arp4-mpls create mode 100644 src/scripts/vnet/arp6 create mode 100644 src/scripts/vnet/bvi create mode 100644 src/scripts/vnet/dhcp/dhcpd.conf create mode 100644 src/scripts/vnet/dhcp/left-ping-target.sh create mode 100644 src/scripts/vnet/dhcp/leftpeer.conf create mode 100644 src/scripts/vnet/icmp create mode 100644 src/scripts/vnet/icmp6 create mode 100644 src/scripts/vnet/ige create mode 100644 src/scripts/vnet/ip6 create mode 100644 src/scripts/vnet/ip6-hbh create mode 100644 src/scripts/vnet/ixge create mode 100644 src/scripts/vnet/l2efpfilter create mode 100644 src/scripts/vnet/l2efpfilter_perf create mode 100644 src/scripts/vnet/l2fib create mode 100644 src/scripts/vnet/l2fib_perf create mode 100644 src/scripts/vnet/l2fib_xc create mode 100644 src/scripts/vnet/l2flood create mode 100644 src/scripts/vnet/l2tp create mode 100755 src/scripts/vnet/leftpeer/leftpeer-classify create mode 100644 src/scripts/vnet/leftpeer/leftpeer-classify6 create mode 100644 src/scripts/vnet/leftpeer/leftpeer-classifyl2 create mode 100644 src/scripts/vnet/leftpeer/leftpeer-dhcp create mode 100644 src/scripts/vnet/leftpeer/leftpeer-ioam.conf create mode 100644 src/scripts/vnet/leftpeer/leftpeer-l3vxlan.conf create mode 100644 src/scripts/vnet/leftpeer/leftpeer-lisp.conf create mode 100644 src/scripts/vnet/leftpeer/leftpeer-mpls.conf create mode 100644 src/scripts/vnet/leftpeer/leftpeer-sr.conf create mode 100644 src/scripts/vnet/leftpeer/leftpeer-vxlan.conf create mode 100644 src/scripts/vnet/leftpeer/leftpeer.script create mode 100644 src/scripts/vnet/lfib/ip4-to-mpls create mode 100644 src/scripts/vnet/lfib/mpls-pop-to-mpls create mode 100644 src/scripts/vnet/lfib/mpls-to-ip4 create mode 100644 src/scripts/vnet/lfib/mpls-to-mpls create mode 100644 src/scripts/vnet/mpls-o-ethernet/leftpeer.conf create mode 100644 src/scripts/vnet/mpls-o-ethernet/pg create mode 100644 src/scripts/vnet/mpls-o-ethernet/rightpeer.conf create mode 100644 src/scripts/vnet/mpls-o-ethernet/single.conf create mode 100644 src/scripts/vnet/mpls-o-gre/dhcpd.conf create mode 100644 src/scripts/vnet/mpls-o-gre/leftpeer.conf create mode 100644 src/scripts/vnet/mpls-o-gre/rightpeer.conf create mode 100644 src/scripts/vnet/mpls-tunnel create mode 100644 src/scripts/vnet/pcap create mode 100644 src/scripts/vnet/probe4 create mode 100644 src/scripts/vnet/probe6 create mode 100644 src/scripts/vnet/rewrite create mode 100644 src/scripts/vnet/rightpeer/rightpeer-ioam.conf create mode 100644 src/scripts/vnet/rightpeer/rightpeer-l3vxlan.conf create mode 100644 src/scripts/vnet/rightpeer/rightpeer-lisp.conf create mode 100644 src/scripts/vnet/rightpeer/rightpeer-mpls-l2.conf create mode 100644 src/scripts/vnet/rightpeer/rightpeer-mpls.conf create mode 100644 src/scripts/vnet/rightpeer/rightpeer-sr.conf create mode 100644 src/scripts/vnet/rightpeer/rightpeer-vxlan.conf create mode 100644 src/scripts/vnet/rightpeer/rightpeer.script create mode 100644 src/scripts/vnet/rpf create mode 100644 src/scripts/vnet/rtt-test create mode 100644 src/scripts/vnet/snat create mode 100644 src/scripts/vnet/snat_static create mode 100644 src/scripts/vnet/snat_static_with_port create mode 100644 src/scripts/vnet/source_and_port_range_check create mode 100644 src/scripts/vnet/speed create mode 100755 src/scripts/vnet/sr/left-linux-ping.sh create mode 100644 src/scripts/vnet/sr/leftpeer.conf create mode 100755 src/scripts/vnet/sr/right-linux-ping.sh create mode 100644 src/scripts/vnet/sr/rightpeer.conf create mode 100755 src/scripts/vnet/sr/srlocal.sh create mode 100644 src/scripts/vnet/srp create mode 100644 src/scripts/vnet/tcp create mode 100644 src/scripts/vnet/tcp-test create mode 100644 src/scripts/vnet/tf-ucs-1 create mode 100644 src/scripts/vnet/urpf create mode 100644 src/scripts/vnet/virl/ip6sr.virl create mode 100644 src/scripts/vnet/virl/ip6sr_notes.txt create mode 100644 src/scripts/vnet/virl/mplsogre.virl create mode 100644 src/scripts/vnet/virl/simple.virl create mode 100644 src/scripts/vnet/vlan create mode 100755 src/scripts/vppctl create mode 100644 src/suffix-rules.mk create mode 100644 src/svm.am create mode 100644 src/svm/dir.dox create mode 100644 src/svm/persist.c create mode 100644 src/svm/ssvm.c create mode 100644 src/svm/ssvm.h create mode 100644 src/svm/svm.c create mode 100644 src/svm/svm.h create mode 100644 src/svm/svm_test.c create mode 100644 src/svm/svmdb.c create mode 100644 src/svm/svmdb.h create mode 100644 src/svm/svmdbtool.c create mode 100644 src/svm/svmtool.c create mode 100644 src/tests/vnet/README create mode 100644 src/tests/vnet/lisp-cp/test_cp_serdes.c create mode 100644 src/tests/vnet/lisp-cp/test_lisp_types.c create mode 100644 src/tests/vnet/lisp-gpe/test.c create mode 100644 src/tools/elftool/dir.dox create mode 100644 src/tools/elftool/elftool.c create mode 100644 src/tools/g2/clib.c create mode 100644 src/tools/g2/configure.ac create mode 100644 src/tools/g2/cpel.c create mode 100644 src/tools/g2/cpel.h create mode 100644 src/tools/g2/events.c create mode 100644 src/tools/g2/g2.h create mode 100644 src/tools/g2/g2version.c create mode 100644 src/tools/g2/main.c create mode 100644 src/tools/g2/menu1.c create mode 100644 src/tools/g2/mkversion.c create mode 100644 src/tools/g2/pointsel.c create mode 100644 src/tools/g2/props.c create mode 100644 src/tools/g2/props.h create mode 100644 src/tools/g2/view1.c create mode 100644 src/tools/perftool/c2cpel.c create mode 100644 src/tools/perftool/configure.ac create mode 100644 src/tools/perftool/cpel.h create mode 100644 src/tools/perftool/cpel_util.c create mode 100644 src/tools/perftool/cpel_util.h create mode 100644 src/tools/perftool/cpelatency.c create mode 100644 src/tools/perftool/cpeldump.c create mode 100644 src/tools/perftool/cpelinreg.c create mode 100644 src/tools/perftool/cpelstate.c create mode 100644 src/tools/perftool/delsvec.c create mode 100644 src/tools/perftool/linreg.c create mode 100644 src/tools/perftool/new.cpel create mode 100644 src/tools/perftool/new.elog create mode 100644 src/tools/perftool/props.c create mode 100644 src/tools/vppapigen/configure.ac create mode 100644 src/tools/vppapigen/gram.y create mode 100644 src/tools/vppapigen/lex.c create mode 100644 src/tools/vppapigen/lex.h create mode 100644 src/tools/vppapigen/node.c create mode 100644 src/tools/vppapigen/node.h create mode 100644 src/vat/api_format.c create mode 100644 src/vat/json_format.c create mode 100644 src/vat/json_format.h create mode 100644 src/vat/json_test.c create mode 100644 src/vat/main.c create mode 100644 src/vat/plugin.c create mode 100644 src/vat/plugin.h create mode 100644 src/vat/plugin_api.c create mode 100644 src/vat/restart.c create mode 100644 src/vat/vat.h create mode 100644 src/vlib-api.am create mode 100644 src/vlib.am create mode 100644 src/vlib/buffer.c create mode 100644 src/vlib/buffer.h create mode 100644 src/vlib/buffer_funcs.h create mode 100644 src/vlib/buffer_node.h create mode 100644 src/vlib/cli.c create mode 100644 src/vlib/cli.h create mode 100644 src/vlib/cli_funcs.h create mode 100644 src/vlib/counter.c create mode 100644 src/vlib/counter.h create mode 100644 src/vlib/defs.h create mode 100644 src/vlib/dir.dox create mode 100644 src/vlib/elog_samples.c create mode 100644 src/vlib/error.c create mode 100644 src/vlib/error.h create mode 100644 src/vlib/error_funcs.h create mode 100644 src/vlib/format.c create mode 100644 src/vlib/format_funcs.h create mode 100644 src/vlib/global_funcs.h create mode 100644 src/vlib/i2c.c create mode 100644 src/vlib/i2c.h create mode 100644 src/vlib/init.c create mode 100644 src/vlib/init.h create mode 100644 src/vlib/lex.c create mode 100644 src/vlib/lex.h create mode 100644 src/vlib/main.c create mode 100644 src/vlib/main.h create mode 100644 src/vlib/mc.c create mode 100644 src/vlib/mc.h create mode 100644 src/vlib/node.c create mode 100644 src/vlib/node.h create mode 100644 src/vlib/node_cli.c create mode 100644 src/vlib/node_format.c create mode 100644 src/vlib/node_funcs.h create mode 100644 src/vlib/parse.c create mode 100644 src/vlib/parse.h create mode 100644 src/vlib/parse_builtin.c create mode 100644 src/vlib/pci/linux_pci.c create mode 100644 src/vlib/pci/pci.c create mode 100644 src/vlib/pci/pci.h create mode 100644 src/vlib/pci/pci_config.h create mode 100644 src/vlib/physmem.h create mode 100644 src/vlib/threads.c create mode 100644 src/vlib/threads.h create mode 100644 src/vlib/threads_cli.c create mode 100644 src/vlib/trace.c create mode 100644 src/vlib/trace.h create mode 100644 src/vlib/trace_funcs.h create mode 100644 src/vlib/unix/cj.c create mode 100644 src/vlib/unix/cj.h create mode 100644 src/vlib/unix/cli.c create mode 100644 src/vlib/unix/dir.dox create mode 100644 src/vlib/unix/input.c create mode 100644 src/vlib/unix/main.c create mode 100644 src/vlib/unix/mc_socket.c create mode 100644 src/vlib/unix/mc_socket.h create mode 100644 src/vlib/unix/physmem.c create mode 100644 src/vlib/unix/physmem.h create mode 100644 src/vlib/unix/plugin.c create mode 100644 src/vlib/unix/plugin.h create mode 100644 src/vlib/unix/unix.h create mode 100644 src/vlib/unix/util.c create mode 100644 src/vlib/vlib.h create mode 100644 src/vlib/vlib_process_doc.h create mode 100644 src/vlibapi/api.h create mode 100644 src/vlibapi/api_helper_macros.h create mode 100644 src/vlibapi/api_shared.c create mode 100644 src/vlibapi/node_serialize.c create mode 100644 src/vlibmemory/api.h create mode 100644 src/vlibmemory/memclnt.api create mode 100644 src/vlibmemory/memory_client.c create mode 100644 src/vlibmemory/memory_shared.c create mode 100644 src/vlibmemory/memory_vlib.c create mode 100644 src/vlibmemory/unix_shared_memory_queue.c create mode 100644 src/vlibmemory/unix_shared_memory_queue.h create mode 100644 src/vlibmemory/vl_memory_api_h.h create mode 100644 src/vlibmemory/vl_memory_msg_enum.h create mode 100644 src/vlibsocket/api.h create mode 100644 src/vlibsocket/sock_test.c create mode 100644 src/vlibsocket/sockclnt.api create mode 100644 src/vlibsocket/sockclnt_vlib.c create mode 100644 src/vlibsocket/socksvr_vlib.c create mode 100644 src/vlibsocket/vl_socket_api_h.h create mode 100644 src/vlibsocket/vl_socket_msg_enum.h create mode 100644 src/vnet.am create mode 100644 src/vnet/adj/adj.c create mode 100644 src/vnet/adj/adj.h create mode 100644 src/vnet/adj/adj_glean.c create mode 100644 src/vnet/adj/adj_glean.h create mode 100644 src/vnet/adj/adj_internal.h create mode 100644 src/vnet/adj/adj_l2.c create mode 100644 src/vnet/adj/adj_l2.h create mode 100644 src/vnet/adj/adj_midchain.c create mode 100644 src/vnet/adj/adj_midchain.h create mode 100644 src/vnet/adj/adj_nbr.c create mode 100644 src/vnet/adj/adj_nbr.h create mode 100644 src/vnet/adj/adj_rewrite.c create mode 100644 src/vnet/adj/adj_rewrite.h create mode 100644 src/vnet/adj/adj_types.h create mode 100644 src/vnet/api_errno.h create mode 100644 src/vnet/bfd/bfd.api create mode 100644 src/vnet/bfd/bfd_api.c create mode 100644 src/vnet/bfd/bfd_api.h create mode 100644 src/vnet/bfd/bfd_debug.h create mode 100644 src/vnet/bfd/bfd_doc.md create mode 100644 src/vnet/bfd/bfd_main.c create mode 100644 src/vnet/bfd/bfd_main.h create mode 100644 src/vnet/bfd/bfd_protocol.c create mode 100644 src/vnet/bfd/bfd_protocol.h create mode 100644 src/vnet/bfd/bfd_udp.c create mode 100644 src/vnet/bfd/bfd_udp.h create mode 100644 src/vnet/bfd/dir.dox create mode 100644 src/vnet/buffer.h create mode 100644 src/vnet/cdp/cdp.pg create mode 100644 src/vnet/cdp/cdp_input.c create mode 100644 src/vnet/cdp/cdp_node.c create mode 100644 src/vnet/cdp/cdp_node.h create mode 100644 src/vnet/cdp/cdp_periodic.c create mode 100644 src/vnet/cdp/cdp_protocol.h create mode 100644 src/vnet/classify/README create mode 100644 src/vnet/classify/flow_classify.c create mode 100644 src/vnet/classify/flow_classify.h create mode 100644 src/vnet/classify/flow_classify_node.c create mode 100644 src/vnet/classify/input_acl.c create mode 100644 src/vnet/classify/input_acl.h create mode 100644 src/vnet/classify/ip_classify.c create mode 100644 src/vnet/classify/policer_classify.c create mode 100644 src/vnet/classify/policer_classify.h create mode 100644 src/vnet/classify/vnet_classify.c create mode 100644 src/vnet/classify/vnet_classify.h create mode 100644 src/vnet/config.c create mode 100644 src/vnet/config.h create mode 100644 src/vnet/cop/cop.c create mode 100644 src/vnet/cop/cop.h create mode 100644 src/vnet/cop/ip4_whitelist.c create mode 100644 src/vnet/cop/ip6_whitelist.c create mode 100644 src/vnet/cop/node1.c create mode 100644 src/vnet/devices/af_packet/af_packet.api create mode 100644 src/vnet/devices/af_packet/af_packet.c create mode 100644 src/vnet/devices/af_packet/af_packet.h create mode 100644 src/vnet/devices/af_packet/af_packet_api.c create mode 100644 src/vnet/devices/af_packet/cli.c create mode 100644 src/vnet/devices/af_packet/device.c create mode 100644 src/vnet/devices/af_packet/node.c create mode 100644 src/vnet/devices/devices.c create mode 100644 src/vnet/devices/devices.h create mode 100644 src/vnet/devices/dpdk/cli.c create mode 100644 src/vnet/devices/dpdk/device.c create mode 100644 src/vnet/devices/dpdk/dpdk.h create mode 100644 src/vnet/devices/dpdk/dpdk_priv.h create mode 100644 src/vnet/devices/dpdk/format.c create mode 100644 src/vnet/devices/dpdk/hqos.c create mode 100755 src/vnet/devices/dpdk/init.c create mode 100644 src/vnet/devices/dpdk/ipsec/cli.c create mode 100644 src/vnet/devices/dpdk/ipsec/crypto_node.c create mode 100644 src/vnet/devices/dpdk/ipsec/dir.dox create mode 100644 src/vnet/devices/dpdk/ipsec/dpdk_crypto_ipsec_doc.md create mode 100644 src/vnet/devices/dpdk/ipsec/esp.h create mode 100644 src/vnet/devices/dpdk/ipsec/esp_decrypt.c create mode 100644 src/vnet/devices/dpdk/ipsec/esp_encrypt.c create mode 100644 src/vnet/devices/dpdk/ipsec/ipsec.c create mode 100644 src/vnet/devices/dpdk/ipsec/ipsec.h create mode 100644 src/vnet/devices/dpdk/node.c create mode 100644 src/vnet/devices/dpdk/qos_doc.md create mode 100644 src/vnet/devices/netmap/cli.c create mode 100644 src/vnet/devices/netmap/device.c create mode 100644 src/vnet/devices/netmap/net_netmap.h create mode 100644 src/vnet/devices/netmap/netmap.api create mode 100644 src/vnet/devices/netmap/netmap.c create mode 100644 src/vnet/devices/netmap/netmap.h create mode 100644 src/vnet/devices/netmap/netmap_api.c create mode 100644 src/vnet/devices/netmap/node.c create mode 100644 src/vnet/devices/nic/ixge.c create mode 100644 src/vnet/devices/nic/ixge.h create mode 100644 src/vnet/devices/nic/sfp.c create mode 100644 src/vnet/devices/nic/sfp.h create mode 100644 src/vnet/devices/ssvm/node.c create mode 100644 src/vnet/devices/ssvm/ssvm_eth.c create mode 100644 src/vnet/devices/ssvm/ssvm_eth.h create mode 100644 src/vnet/devices/virtio/dir.dox create mode 100644 src/vnet/devices/virtio/vhost-user.c create mode 100644 src/vnet/devices/virtio/vhost-user.h create mode 100644 src/vnet/devices/virtio/vhost_user.api create mode 100644 src/vnet/devices/virtio/vhost_user_api.c create mode 100644 src/vnet/dhcp/client.c create mode 100644 src/vnet/dhcp/client.h create mode 100644 src/vnet/dhcp/packet.h create mode 100644 src/vnet/dhcp/proxy.h create mode 100644 src/vnet/dhcp/proxy_error.def create mode 100644 src/vnet/dhcp/proxy_node.c create mode 100644 src/vnet/dhcpv6/packet.h create mode 100644 src/vnet/dhcpv6/proxy.h create mode 100644 src/vnet/dhcpv6/proxy_error.def create mode 100644 src/vnet/dhcpv6/proxy_node.c create mode 100644 src/vnet/dpo/classify_dpo.c create mode 100644 src/vnet/dpo/classify_dpo.h create mode 100644 src/vnet/dpo/dpo.c create mode 100644 src/vnet/dpo/dpo.h create mode 100644 src/vnet/dpo/drop_dpo.c create mode 100644 src/vnet/dpo/drop_dpo.h create mode 100644 src/vnet/dpo/ip_null_dpo.c create mode 100644 src/vnet/dpo/ip_null_dpo.h create mode 100644 src/vnet/dpo/load_balance.c create mode 100644 src/vnet/dpo/load_balance.h create mode 100644 src/vnet/dpo/load_balance_map.c create mode 100644 src/vnet/dpo/load_balance_map.h create mode 100644 src/vnet/dpo/lookup_dpo.c create mode 100644 src/vnet/dpo/lookup_dpo.h create mode 100644 src/vnet/dpo/mpls_label_dpo.c create mode 100644 src/vnet/dpo/mpls_label_dpo.h create mode 100644 src/vnet/dpo/punt_dpo.c create mode 100644 src/vnet/dpo/punt_dpo.h create mode 100644 src/vnet/dpo/receive_dpo.c create mode 100644 src/vnet/dpo/receive_dpo.h create mode 100644 src/vnet/ethernet/arp.c create mode 100644 src/vnet/ethernet/arp_packet.h create mode 100644 src/vnet/ethernet/dir.dox create mode 100644 src/vnet/ethernet/error.def create mode 100644 src/vnet/ethernet/ethernet.h create mode 100644 src/vnet/ethernet/format.c create mode 100644 src/vnet/ethernet/init.c create mode 100644 src/vnet/ethernet/interface.c create mode 100644 src/vnet/ethernet/mac_swap.c create mode 100755 src/vnet/ethernet/node.c create mode 100644 src/vnet/ethernet/packet.h create mode 100644 src/vnet/ethernet/pg.c create mode 100644 src/vnet/ethernet/types.def create mode 100644 src/vnet/feature/feature.c create mode 100644 src/vnet/feature/feature.h create mode 100644 src/vnet/feature/registration.c create mode 100644 src/vnet/fib/fib.c create mode 100644 src/vnet/fib/fib.h create mode 100644 src/vnet/fib/fib_api.h create mode 100644 src/vnet/fib/fib_attached_export.c create mode 100644 src/vnet/fib/fib_attached_export.h create mode 100644 src/vnet/fib/fib_entry.c create mode 100644 src/vnet/fib/fib_entry.h create mode 100644 src/vnet/fib/fib_entry_cover.c create mode 100644 src/vnet/fib/fib_entry_cover.h create mode 100644 src/vnet/fib/fib_entry_delegate.c create mode 100644 src/vnet/fib/fib_entry_delegate.h create mode 100644 src/vnet/fib/fib_entry_src.c create mode 100644 src/vnet/fib/fib_entry_src.h create mode 100644 src/vnet/fib/fib_entry_src_adj.c create mode 100644 src/vnet/fib/fib_entry_src_api.c create mode 100644 src/vnet/fib/fib_entry_src_default.c create mode 100644 src/vnet/fib/fib_entry_src_default_route.c create mode 100644 src/vnet/fib/fib_entry_src_interface.c create mode 100644 src/vnet/fib/fib_entry_src_lisp.c create mode 100644 src/vnet/fib/fib_entry_src_mpls.c create mode 100644 src/vnet/fib/fib_entry_src_rr.c create mode 100644 src/vnet/fib/fib_entry_src_special.c create mode 100644 src/vnet/fib/fib_internal.h create mode 100644 src/vnet/fib/fib_node.c create mode 100644 src/vnet/fib/fib_node.h create mode 100644 src/vnet/fib/fib_node_list.c create mode 100644 src/vnet/fib/fib_node_list.h create mode 100644 src/vnet/fib/fib_path.c create mode 100644 src/vnet/fib/fib_path.h create mode 100644 src/vnet/fib/fib_path_ext.c create mode 100644 src/vnet/fib/fib_path_ext.h create mode 100644 src/vnet/fib/fib_path_list.c create mode 100644 src/vnet/fib/fib_path_list.h create mode 100644 src/vnet/fib/fib_table.c create mode 100644 src/vnet/fib/fib_table.h create mode 100644 src/vnet/fib/fib_test.c create mode 100644 src/vnet/fib/fib_types.c create mode 100644 src/vnet/fib/fib_types.h create mode 100644 src/vnet/fib/fib_urpf_list.c create mode 100644 src/vnet/fib/fib_urpf_list.h create mode 100644 src/vnet/fib/fib_walk.c create mode 100644 src/vnet/fib/fib_walk.h create mode 100644 src/vnet/fib/ip4_fib.c create mode 100644 src/vnet/fib/ip4_fib.h create mode 100644 src/vnet/fib/ip6_fib.c create mode 100644 src/vnet/fib/ip6_fib.h create mode 100644 src/vnet/fib/mpls_fib.c create mode 100644 src/vnet/fib/mpls_fib.h create mode 100644 src/vnet/flow/flow_report.c create mode 100644 src/vnet/flow/flow_report.h create mode 100644 src/vnet/flow/flow_report_classify.c create mode 100644 src/vnet/flow/flow_report_classify.h create mode 100644 src/vnet/flow/ipfix_info_elements.h create mode 100644 src/vnet/flow/ipfix_packet.h create mode 100644 src/vnet/global_funcs.h create mode 100644 src/vnet/gre/error.def create mode 100644 src/vnet/gre/gre.api create mode 100644 src/vnet/gre/gre.c create mode 100644 src/vnet/gre/gre.h create mode 100644 src/vnet/gre/gre_api.c create mode 100644 src/vnet/gre/interface.c create mode 100644 src/vnet/gre/node.c create mode 100644 src/vnet/gre/packet.h create mode 100644 src/vnet/gre/pg.c create mode 100644 src/vnet/handoff.c create mode 100644 src/vnet/handoff.h create mode 100644 src/vnet/hdlc/error.def create mode 100644 src/vnet/hdlc/hdlc.c create mode 100644 src/vnet/hdlc/hdlc.h create mode 100644 src/vnet/hdlc/node.c create mode 100644 src/vnet/hdlc/packet.h create mode 100644 src/vnet/hdlc/pg.c create mode 100644 src/vnet/interface.api create mode 100644 src/vnet/interface.c create mode 100644 src/vnet/interface.h create mode 100644 src/vnet/interface_api.c create mode 100644 src/vnet/interface_cli.c create mode 100644 src/vnet/interface_format.c create mode 100644 src/vnet/interface_funcs.h create mode 100644 src/vnet/interface_output.c create mode 100644 src/vnet/ip/dir.dox create mode 100644 src/vnet/ip/format.c create mode 100644 src/vnet/ip/format.h create mode 100644 src/vnet/ip/icmp4.c create mode 100644 src/vnet/ip/icmp4.h create mode 100644 src/vnet/ip/icmp46_packet.h create mode 100644 src/vnet/ip/icmp6.c create mode 100644 src/vnet/ip/icmp6.h create mode 100644 src/vnet/ip/igmp_packet.h create mode 100644 src/vnet/ip/ip.api create mode 100644 src/vnet/ip/ip.h create mode 100644 src/vnet/ip/ip4.h create mode 100644 src/vnet/ip/ip46_cli.c create mode 100644 src/vnet/ip/ip4_error.h create mode 100644 src/vnet/ip/ip4_format.c create mode 100644 src/vnet/ip/ip4_forward.c create mode 100644 src/vnet/ip/ip4_input.c create mode 100644 src/vnet/ip/ip4_mtrie.c create mode 100644 src/vnet/ip/ip4_mtrie.h create mode 100644 src/vnet/ip/ip4_packet.h create mode 100644 src/vnet/ip/ip4_pg.c create mode 100644 src/vnet/ip/ip4_source_and_port_range_check.c create mode 100644 src/vnet/ip/ip4_source_check.c create mode 100644 src/vnet/ip/ip4_test.c create mode 100644 src/vnet/ip/ip6.h create mode 100644 src/vnet/ip/ip6_error.h create mode 100644 src/vnet/ip/ip6_format.c create mode 100644 src/vnet/ip/ip6_forward.c create mode 100644 src/vnet/ip/ip6_hop_by_hop.c create mode 100644 src/vnet/ip/ip6_hop_by_hop.h create mode 100644 src/vnet/ip/ip6_hop_by_hop_packet.h create mode 100644 src/vnet/ip/ip6_input.c create mode 100644 src/vnet/ip/ip6_neighbor.c create mode 100644 src/vnet/ip/ip6_neighbor.h create mode 100644 src/vnet/ip/ip6_packet.h create mode 100644 src/vnet/ip/ip6_pg.c create mode 100644 src/vnet/ip/ip_api.c create mode 100644 src/vnet/ip/ip_checksum.c create mode 100644 src/vnet/ip/ip_frag.c create mode 100644 src/vnet/ip/ip_frag.h create mode 100644 src/vnet/ip/ip_init.c create mode 100644 src/vnet/ip/ip_input_acl.c create mode 100644 src/vnet/ip/ip_packet.h create mode 100644 src/vnet/ip/ip_source_and_port_range_check.h create mode 100644 src/vnet/ip/lookup.c create mode 100644 src/vnet/ip/lookup.h create mode 100644 src/vnet/ip/ping.c create mode 100644 src/vnet/ip/ping.h create mode 100644 src/vnet/ip/ports.def create mode 100644 src/vnet/ip/protocols.def create mode 100644 src/vnet/ip/punt.c create mode 100644 src/vnet/ip/punt.h create mode 100644 src/vnet/ip/punt_error.def create mode 100644 src/vnet/ip/tcp_packet.h create mode 100644 src/vnet/ip/udp.h create mode 100644 src/vnet/ip/udp_error.def create mode 100644 src/vnet/ip/udp_format.c create mode 100644 src/vnet/ip/udp_init.c create mode 100644 src/vnet/ip/udp_local.c create mode 100644 src/vnet/ip/udp_packet.h create mode 100644 src/vnet/ip/udp_pg.c create mode 100644 src/vnet/ipsec-gre/dir.dox create mode 100644 src/vnet/ipsec-gre/error.def create mode 100644 src/vnet/ipsec-gre/interface.c create mode 100644 src/vnet/ipsec-gre/ipsec_gre.api create mode 100644 src/vnet/ipsec-gre/ipsec_gre.c create mode 100644 src/vnet/ipsec-gre/ipsec_gre.h create mode 100644 src/vnet/ipsec-gre/ipsec_gre_api.c create mode 100644 src/vnet/ipsec-gre/ipsec_gre_doc.md create mode 100644 src/vnet/ipsec-gre/node.c create mode 100644 src/vnet/ipsec/esp.h create mode 100644 src/vnet/ipsec/esp_decrypt.c create mode 100644 src/vnet/ipsec/esp_encrypt.c create mode 100644 src/vnet/ipsec/ikev2.c create mode 100644 src/vnet/ipsec/ikev2.h create mode 100644 src/vnet/ipsec/ikev2_cli.c create mode 100644 src/vnet/ipsec/ikev2_crypto.c create mode 100644 src/vnet/ipsec/ikev2_format.c create mode 100644 src/vnet/ipsec/ikev2_payload.c create mode 100644 src/vnet/ipsec/ikev2_priv.h create mode 100644 src/vnet/ipsec/ipsec.api create mode 100644 src/vnet/ipsec/ipsec.c create mode 100644 src/vnet/ipsec/ipsec.h create mode 100644 src/vnet/ipsec/ipsec_api.c create mode 100644 src/vnet/ipsec/ipsec_cli.c create mode 100644 src/vnet/ipsec/ipsec_format.c create mode 100644 src/vnet/ipsec/ipsec_if.c create mode 100644 src/vnet/ipsec/ipsec_if_in.c create mode 100644 src/vnet/ipsec/ipsec_if_out.c create mode 100644 src/vnet/ipsec/ipsec_input.c create mode 100644 src/vnet/ipsec/ipsec_output.c create mode 100644 src/vnet/l2/dir.dox create mode 100644 src/vnet/l2/feat_bitmap.c create mode 100644 src/vnet/l2/feat_bitmap.h create mode 100644 src/vnet/l2/l2.api create mode 100644 src/vnet/l2/l2_api.c create mode 100644 src/vnet/l2/l2_bd.c create mode 100644 src/vnet/l2/l2_bd.h create mode 100644 src/vnet/l2/l2_bvi.c create mode 100644 src/vnet/l2/l2_bvi.h create mode 100644 src/vnet/l2/l2_classify.h create mode 100644 src/vnet/l2/l2_efp_filter.c create mode 100644 src/vnet/l2/l2_efp_filter.h create mode 100644 src/vnet/l2/l2_fib.c create mode 100644 src/vnet/l2/l2_fib.h create mode 100644 src/vnet/l2/l2_flood.c create mode 100644 src/vnet/l2/l2_flood.h create mode 100644 src/vnet/l2/l2_fwd.c create mode 100644 src/vnet/l2/l2_fwd.h create mode 100644 src/vnet/l2/l2_input.c create mode 100644 src/vnet/l2/l2_input.h create mode 100644 src/vnet/l2/l2_input_acl.c create mode 100644 src/vnet/l2/l2_input_classify.c create mode 100644 src/vnet/l2/l2_input_vtr.c create mode 100644 src/vnet/l2/l2_input_vtr.h create mode 100644 src/vnet/l2/l2_learn.c create mode 100644 src/vnet/l2/l2_learn.h create mode 100644 src/vnet/l2/l2_output.c create mode 100644 src/vnet/l2/l2_output.h create mode 100644 src/vnet/l2/l2_output_acl.c create mode 100644 src/vnet/l2/l2_output_classify.c create mode 100644 src/vnet/l2/l2_patch.c create mode 100644 src/vnet/l2/l2_rw.c create mode 100644 src/vnet/l2/l2_rw.h create mode 100644 src/vnet/l2/l2_vtr.c create mode 100644 src/vnet/l2/l2_vtr.h create mode 100644 src/vnet/l2/l2_xcrw.c create mode 100644 src/vnet/l2/l2_xcrw.h create mode 100644 src/vnet/l2tp/decap.c create mode 100644 src/vnet/l2tp/encap.c create mode 100644 src/vnet/l2tp/l2tp.api create mode 100644 src/vnet/l2tp/l2tp.c create mode 100644 src/vnet/l2tp/l2tp.h create mode 100644 src/vnet/l2tp/l2tp_api.c create mode 100644 src/vnet/l2tp/packet.h create mode 100644 src/vnet/l2tp/pg.c create mode 100644 src/vnet/l3_types.h create mode 100644 src/vnet/lawful-intercept/lawful_intercept.c create mode 100644 src/vnet/lawful-intercept/lawful_intercept.h create mode 100644 src/vnet/lawful-intercept/node.c create mode 100644 src/vnet/lisp-cp/control.c create mode 100644 src/vnet/lisp-cp/control.h create mode 100644 src/vnet/lisp-cp/gid_dictionary.c create mode 100644 src/vnet/lisp-cp/gid_dictionary.h create mode 100644 src/vnet/lisp-cp/lisp.api create mode 100644 src/vnet/lisp-cp/lisp_api.c create mode 100644 src/vnet/lisp-cp/lisp_cp_dpo.c create mode 100644 src/vnet/lisp-cp/lisp_cp_dpo.h create mode 100644 src/vnet/lisp-cp/lisp_cp_messages.h create mode 100644 src/vnet/lisp-cp/lisp_msg_serdes.c create mode 100644 src/vnet/lisp-cp/lisp_msg_serdes.h create mode 100644 src/vnet/lisp-cp/lisp_types.c create mode 100644 src/vnet/lisp-cp/lisp_types.h create mode 100644 src/vnet/lisp-cp/packets.c create mode 100644 src/vnet/lisp-cp/packets.h create mode 100644 src/vnet/lisp-gpe/decap.c create mode 100644 src/vnet/lisp-gpe/dir.dox create mode 100644 src/vnet/lisp-gpe/interface.c create mode 100644 src/vnet/lisp-gpe/lisp_gpe.api create mode 100644 src/vnet/lisp-gpe/lisp_gpe.c create mode 100644 src/vnet/lisp-gpe/lisp_gpe.h create mode 100644 src/vnet/lisp-gpe/lisp_gpe_adjacency.c create mode 100644 src/vnet/lisp-gpe/lisp_gpe_adjacency.h create mode 100644 src/vnet/lisp-gpe/lisp_gpe_api.c create mode 100644 src/vnet/lisp-gpe/lisp_gpe_error.def create mode 100644 src/vnet/lisp-gpe/lisp_gpe_fwd_entry.c create mode 100644 src/vnet/lisp-gpe/lisp_gpe_fwd_entry.h create mode 100644 src/vnet/lisp-gpe/lisp_gpe_packet.h create mode 100644 src/vnet/lisp-gpe/lisp_gpe_sub_interface.c create mode 100644 src/vnet/lisp-gpe/lisp_gpe_sub_interface.h create mode 100644 src/vnet/lisp-gpe/lisp_gpe_tenant.c create mode 100644 src/vnet/lisp-gpe/lisp_gpe_tenant.h create mode 100644 src/vnet/lisp-gpe/lisp_gpe_tunnel.c create mode 100644 src/vnet/lisp-gpe/lisp_gpe_tunnel.h create mode 100644 src/vnet/lisp-gpe/rfc.txt create mode 100644 src/vnet/llc/llc.c create mode 100644 src/vnet/llc/llc.h create mode 100644 src/vnet/llc/node.c create mode 100644 src/vnet/llc/pg.c create mode 100644 src/vnet/lldp/dir.dox create mode 100644 src/vnet/lldp/lldp_cli.c create mode 100644 src/vnet/lldp/lldp_doc.md create mode 100644 src/vnet/lldp/lldp_input.c create mode 100644 src/vnet/lldp/lldp_node.c create mode 100644 src/vnet/lldp/lldp_node.h create mode 100644 src/vnet/lldp/lldp_output.c create mode 100644 src/vnet/lldp/lldp_protocol.h create mode 100755 src/vnet/map/examples/gen-rules.py create mode 100644 src/vnet/map/examples/health_check.c create mode 100755 src/vnet/map/examples/test_map.py create mode 100755 src/vnet/map/gen-rules.py create mode 100644 src/vnet/map/ip4_map.c create mode 100644 src/vnet/map/ip4_map_t.c create mode 100644 src/vnet/map/ip6_map.c create mode 100644 src/vnet/map/ip6_map_t.c create mode 100644 src/vnet/map/map.api create mode 100644 src/vnet/map/map.c create mode 100644 src/vnet/map/map.h create mode 100644 src/vnet/map/map_api.c create mode 100644 src/vnet/map/map_doc.md create mode 100644 src/vnet/map/map_dpo.c create mode 100644 src/vnet/map/map_dpo.h create mode 100644 src/vnet/map/test.c create mode 100644 src/vnet/mcast/mcast.c create mode 100644 src/vnet/mcast/mcast.h create mode 100644 src/vnet/mcast/mcast_test.c create mode 100644 src/vnet/misc.c create mode 100644 src/vnet/mpls/error.def create mode 100644 src/vnet/mpls/interface.c create mode 100644 src/vnet/mpls/mpls.c create mode 100644 src/vnet/mpls/mpls.h create mode 100644 src/vnet/mpls/mpls_features.c create mode 100644 src/vnet/mpls/mpls_lookup.c create mode 100644 src/vnet/mpls/mpls_output.c create mode 100644 src/vnet/mpls/mpls_tunnel.c create mode 100644 src/vnet/mpls/mpls_tunnel.h create mode 100644 src/vnet/mpls/mpls_types.h create mode 100644 src/vnet/mpls/node.c create mode 100644 src/vnet/mpls/packet.h create mode 100644 src/vnet/mpls/pg.c create mode 100644 src/vnet/osi/node.c create mode 100644 src/vnet/osi/osi.c create mode 100644 src/vnet/osi/osi.h create mode 100644 src/vnet/osi/pg.c create mode 100644 src/vnet/pg/cli.c create mode 100644 src/vnet/pg/edit.c create mode 100644 src/vnet/pg/edit.h create mode 100644 src/vnet/pg/example.script create mode 100644 src/vnet/pg/init.c create mode 100644 src/vnet/pg/input.c create mode 100644 src/vnet/pg/output.c create mode 100644 src/vnet/pg/pg.h create mode 100644 src/vnet/pg/stream.c create mode 100644 src/vnet/pipeline.h create mode 100644 src/vnet/plugin/p1.c create mode 100644 src/vnet/plugin/plugin.h create mode 100644 src/vnet/policer/node_funcs.c create mode 100644 src/vnet/policer/police.h create mode 100644 src/vnet/policer/policer.c create mode 100644 src/vnet/policer/policer.h create mode 100644 src/vnet/policer/xlate.c create mode 100644 src/vnet/policer/xlate.h create mode 100644 src/vnet/ppp/error.def create mode 100644 src/vnet/ppp/node.c create mode 100644 src/vnet/ppp/packet.h create mode 100644 src/vnet/ppp/pg.c create mode 100644 src/vnet/ppp/ppp.c create mode 100644 src/vnet/ppp/ppp.h create mode 100644 src/vnet/replication.c create mode 100644 src/vnet/replication.h create mode 100644 src/vnet/rewrite.c create mode 100644 src/vnet/rewrite.h create mode 100644 src/vnet/snap/node.c create mode 100644 src/vnet/snap/pg.c create mode 100644 src/vnet/snap/snap.c create mode 100644 src/vnet/snap/snap.h create mode 100644 src/vnet/span/node.c create mode 100644 src/vnet/span/span.api create mode 100644 src/vnet/span/span.c create mode 100644 src/vnet/span/span.h create mode 100644 src/vnet/span/span.md create mode 100644 src/vnet/span/span_api.c create mode 100644 src/vnet/sr/dir.dox create mode 100644 src/vnet/sr/examples/sr_multicastmap.script create mode 100644 src/vnet/sr/rfc_draft_05.txt create mode 100644 src/vnet/sr/sr.c create mode 100644 src/vnet/sr/sr.h create mode 100644 src/vnet/sr/sr_error.def create mode 100644 src/vnet/sr/sr_fix_dst_error.def create mode 100644 src/vnet/sr/sr_packet.h create mode 100644 src/vnet/sr/sr_replicate.c create mode 100644 src/vnet/srp/format.c create mode 100644 src/vnet/srp/interface.c create mode 100644 src/vnet/srp/node.c create mode 100644 src/vnet/srp/packet.h create mode 100644 src/vnet/srp/pg.c create mode 100644 src/vnet/srp/srp.h create mode 100644 src/vnet/unix/gdb_funcs.c create mode 100644 src/vnet/unix/pcap.c create mode 100644 src/vnet/unix/pcap.h create mode 100644 src/vnet/unix/pcap2pg.c create mode 100644 src/vnet/unix/tap.api create mode 100644 src/vnet/unix/tap_api.c create mode 100644 src/vnet/unix/tapcli.c create mode 100644 src/vnet/unix/tapcli.h create mode 100644 src/vnet/unix/tuntap.c create mode 100644 src/vnet/unix/tuntap.h create mode 100644 src/vnet/vnet.h create mode 100644 src/vnet/vnet_all_api_h.h create mode 100644 src/vnet/vnet_msg_enum.h create mode 100644 src/vnet/vxlan-gpe/decap.c create mode 100644 src/vnet/vxlan-gpe/dir.dox create mode 100644 src/vnet/vxlan-gpe/encap.c create mode 100644 src/vnet/vxlan-gpe/vxlan-gpe-rfc.txt create mode 100644 src/vnet/vxlan-gpe/vxlan_gpe.api create mode 100644 src/vnet/vxlan-gpe/vxlan_gpe.c create mode 100644 src/vnet/vxlan-gpe/vxlan_gpe.h create mode 100644 src/vnet/vxlan-gpe/vxlan_gpe_api.c create mode 100644 src/vnet/vxlan-gpe/vxlan_gpe_error.def create mode 100644 src/vnet/vxlan-gpe/vxlan_gpe_packet.h create mode 100644 src/vnet/vxlan/decap.c create mode 100644 src/vnet/vxlan/dir.dox create mode 100644 src/vnet/vxlan/encap.c create mode 100644 src/vnet/vxlan/vxlan.api create mode 100644 src/vnet/vxlan/vxlan.c create mode 100644 src/vnet/vxlan/vxlan.h create mode 100644 src/vnet/vxlan/vxlan_api.c create mode 100644 src/vnet/vxlan/vxlan_error.def create mode 100644 src/vnet/vxlan/vxlan_packet.h create mode 100644 src/vpp-api-test.am create mode 100644 src/vpp-api/python/Makefile.am create mode 100644 src/vpp-api/python/README.rst create mode 100644 src/vpp-api/python/pneum/pneum.c create mode 100644 src/vpp-api/python/pneum/pneum.h create mode 100644 src/vpp-api/python/pneum/test_pneum.c create mode 100644 src/vpp-api/python/setup.cfg create mode 100644 src/vpp-api/python/setup.py create mode 100755 src/vpp-api/python/tests/test_cli.py create mode 100755 src/vpp-api/python/tests/test_modules.py create mode 100755 src/vpp-api/python/tests/test_papi.py create mode 100755 src/vpp-api/python/tests/test_version.py create mode 100755 src/vpp-api/python/tests/test_vpp_papi2.py create mode 100644 src/vpp-api/python/vpp_papi/__init__.py create mode 100644 src/vpp-api/python/vpp_papi/pneum_wrap.c create mode 100644 src/vpp-api/python/vpp_papi/vpp_papi.py create mode 100644 src/vpp.am create mode 100644 src/vpp/api/api.c create mode 120000 src/vpp/api/api_format.c create mode 100644 src/vpp/api/api_main.c create mode 100644 src/vpp/api/custom_dump.c create mode 100644 src/vpp/api/gmon.c create mode 100644 src/vpp/api/json_format.c create mode 100644 src/vpp/api/json_format.h create mode 100644 src/vpp/api/summary_stats_client.c create mode 100644 src/vpp/api/test_client.c create mode 100644 src/vpp/api/test_ha.c create mode 120000 src/vpp/api/vat.h create mode 100644 src/vpp/api/vpe.api create mode 100644 src/vpp/api/vpe_all_api_h.h create mode 100644 src/vpp/api/vpe_msg_enum.h create mode 100644 src/vpp/api/vpp_get_metrics.c create mode 100644 src/vpp/app/l2t.c create mode 100644 src/vpp/app/l2t_l2.c create mode 100644 src/vpp/app/sticky_hash.c create mode 100644 src/vpp/app/version.c create mode 100644 src/vpp/app/vpe_cli.c create mode 100644 src/vpp/conf/80-vpp.conf create mode 100644 src/vpp/conf/startup.conf create mode 100644 src/vpp/conf/startup.uiopcigeneric.conf create mode 100644 src/vpp/oam/oam.c create mode 100644 src/vpp/oam/oam.h create mode 100644 src/vpp/stats/stats.c create mode 100644 src/vpp/stats/stats.h create mode 100644 src/vpp/vnet/main.c create mode 100644 src/vppapigen.am create mode 100644 src/vppinfra.am create mode 100644 src/vppinfra/README create mode 100644 src/vppinfra/anneal.c create mode 100644 src/vppinfra/anneal.h create mode 100644 src/vppinfra/asm_mips.h create mode 100644 src/vppinfra/asm_x86.c create mode 100644 src/vppinfra/asm_x86.h create mode 100644 src/vppinfra/backtrace.c create mode 100644 src/vppinfra/bihash_24_8.h create mode 100644 src/vppinfra/bihash_8_8.h create mode 100644 src/vppinfra/bihash_doc.h create mode 100644 src/vppinfra/bihash_template.c create mode 100644 src/vppinfra/bihash_template.h create mode 100644 src/vppinfra/bitmap.h create mode 100644 src/vppinfra/bitops.h create mode 100644 src/vppinfra/byte_order.h create mode 100644 src/vppinfra/cache.h create mode 100644 src/vppinfra/clib.h create mode 100644 src/vppinfra/cpu.c create mode 100644 src/vppinfra/cpu.h create mode 100644 src/vppinfra/dir.dox create mode 100644 src/vppinfra/dlist.h create mode 100644 src/vppinfra/elf.c create mode 100644 src/vppinfra/elf.h create mode 100644 src/vppinfra/elf_clib.c create mode 100644 src/vppinfra/elf_clib.h create mode 100644 src/vppinfra/elog.c create mode 100644 src/vppinfra/elog.h create mode 100644 src/vppinfra/error.c create mode 100644 src/vppinfra/error.h create mode 100644 src/vppinfra/error_bootstrap.h create mode 100644 src/vppinfra/fheap.c create mode 100644 src/vppinfra/fheap.h create mode 100644 src/vppinfra/fifo.c create mode 100644 src/vppinfra/fifo.h create mode 100644 src/vppinfra/format.c create mode 100644 src/vppinfra/format.h create mode 100644 src/vppinfra/graph.c create mode 100644 src/vppinfra/graph.h create mode 100644 src/vppinfra/hash.c create mode 100644 src/vppinfra/hash.h create mode 100644 src/vppinfra/heap.c create mode 100644 src/vppinfra/heap.h create mode 100644 src/vppinfra/longjmp.S create mode 100644 src/vppinfra/longjmp.h create mode 100644 src/vppinfra/macros.c create mode 100644 src/vppinfra/macros.h create mode 100644 src/vppinfra/math.h create mode 100644 src/vppinfra/md5.c create mode 100644 src/vppinfra/md5.h create mode 100644 src/vppinfra/mem.h create mode 100644 src/vppinfra/mem_mheap.c create mode 100644 src/vppinfra/memcheck.h create mode 100644 src/vppinfra/memcpy_avx.h create mode 100644 src/vppinfra/memcpy_sse3.h create mode 100644 src/vppinfra/mhash.c create mode 100644 src/vppinfra/mhash.h create mode 100644 src/vppinfra/mheap.c create mode 100644 src/vppinfra/mheap.h create mode 100644 src/vppinfra/mheap_bootstrap.h create mode 100644 src/vppinfra/mod_test_hash.c create mode 100644 src/vppinfra/os.h create mode 100644 src/vppinfra/pfhash.c create mode 100644 src/vppinfra/pfhash.h create mode 100644 src/vppinfra/phash.c create mode 100644 src/vppinfra/phash.h create mode 100644 src/vppinfra/pipeline.h create mode 100644 src/vppinfra/pool.h create mode 100644 src/vppinfra/ptclosure.c create mode 100644 src/vppinfra/ptclosure.h create mode 100644 src/vppinfra/qhash.c create mode 100644 src/vppinfra/qhash.h create mode 100644 src/vppinfra/qsort.c create mode 100644 src/vppinfra/random.c create mode 100644 src/vppinfra/random.h create mode 100644 src/vppinfra/random_buffer.c create mode 100644 src/vppinfra/random_buffer.h create mode 100644 src/vppinfra/random_isaac.c create mode 100644 src/vppinfra/random_isaac.h create mode 100644 src/vppinfra/serialize.c create mode 100644 src/vppinfra/serialize.h create mode 100644 src/vppinfra/slist.c create mode 100644 src/vppinfra/slist.h create mode 100644 src/vppinfra/smp.c create mode 100644 src/vppinfra/smp.h create mode 100644 src/vppinfra/smp_fifo.c create mode 100644 src/vppinfra/smp_fifo.h create mode 100644 src/vppinfra/socket.c create mode 100644 src/vppinfra/socket.h create mode 100644 src/vppinfra/sparse_vec.h create mode 100644 src/vppinfra/std-formats.c create mode 100644 src/vppinfra/string.c create mode 100644 src/vppinfra/string.h create mode 100644 src/vppinfra/test_bihash_template.c create mode 100644 src/vppinfra/test_dlist.c create mode 100644 src/vppinfra/test_elf.c create mode 100644 src/vppinfra/test_elog.c create mode 100644 src/vppinfra/test_fifo.c create mode 100644 src/vppinfra/test_format.c create mode 100644 src/vppinfra/test_hash.c create mode 100644 src/vppinfra/test_heap.c create mode 100644 src/vppinfra/test_longjmp.c create mode 100644 src/vppinfra/test_macros.c create mode 100644 src/vppinfra/test_md5.c create mode 100644 src/vppinfra/test_mheap.c create mode 100644 src/vppinfra/test_pfhash.c create mode 100644 src/vppinfra/test_phash.c create mode 100644 src/vppinfra/test_pool.c create mode 100644 src/vppinfra/test_pool_iterate.c create mode 100644 src/vppinfra/test_ptclosure.c create mode 100644 src/vppinfra/test_qhash.c create mode 100644 src/vppinfra/test_random.c create mode 100644 src/vppinfra/test_random_isaac.c create mode 100644 src/vppinfra/test_serialize.c create mode 100644 src/vppinfra/test_slist.c create mode 100644 src/vppinfra/test_socket.c create mode 100644 src/vppinfra/test_time.c create mode 100644 src/vppinfra/test_timing_wheel.c create mode 100644 src/vppinfra/test_vec.c create mode 100644 src/vppinfra/test_vec.h create mode 100644 src/vppinfra/test_vhash.c create mode 100644 src/vppinfra/test_zvec.c create mode 100644 src/vppinfra/time.c create mode 100644 src/vppinfra/time.h create mode 100644 src/vppinfra/timer.c create mode 100644 src/vppinfra/timer.h create mode 100644 src/vppinfra/timing_wheel.c create mode 100644 src/vppinfra/timing_wheel.h create mode 100644 src/vppinfra/types.h create mode 100644 src/vppinfra/unformat.c create mode 100644 src/vppinfra/unix-formats.c create mode 100644 src/vppinfra/unix-kelog.c create mode 100644 src/vppinfra/unix-misc.c create mode 100644 src/vppinfra/unix.h create mode 100644 src/vppinfra/unix_error.def create mode 100644 src/vppinfra/valgrind.h create mode 100644 src/vppinfra/vec.c create mode 100644 src/vppinfra/vec.h create mode 100644 src/vppinfra/vec_bootstrap.h create mode 100644 src/vppinfra/vector.c create mode 100644 src/vppinfra/vector.h create mode 100644 src/vppinfra/vector_altivec.h create mode 100644 src/vppinfra/vector_funcs.h create mode 100644 src/vppinfra/vector_iwmmxt.h create mode 100644 src/vppinfra/vector_neon.h create mode 100644 src/vppinfra/vector_sse2.h create mode 100644 src/vppinfra/vhash.c create mode 100644 src/vppinfra/vhash.h create mode 100644 src/vppinfra/vm_linux_kernel.h create mode 100644 src/vppinfra/vm_standalone.h create mode 100644 src/vppinfra/vm_unix.h create mode 100644 src/vppinfra/xxhash.h create mode 100644 src/vppinfra/xy.h create mode 100644 src/vppinfra/zvec.c create mode 100644 src/vppinfra/zvec.h delete mode 100644 svm/Makefile.am delete mode 100644 svm/configure.ac delete mode 100644 svm/dir.dox delete mode 100644 svm/persist.c delete mode 100644 svm/ssvm.c delete mode 100644 svm/ssvm.h delete mode 100644 svm/svm.c delete mode 100644 svm/svm.h delete mode 100644 svm/svm_test.c delete mode 100644 svm/svmdb.c delete mode 100644 svm/svmdb.h delete mode 100644 svm/svmdbtool.c delete mode 100644 svm/svmtool.c delete mode 100644 vlib-api/Makefile.am delete mode 100644 vlib-api/configure.ac delete mode 120000 vlib-api/suffix-rules.mk delete mode 100644 vlib-api/vlibapi/api.h delete mode 100644 vlib-api/vlibapi/api_helper_macros.h delete mode 100644 vlib-api/vlibapi/api_shared.c delete mode 100644 vlib-api/vlibapi/node_serialize.c delete mode 100644 vlib-api/vlibmemory/api.h delete mode 100644 vlib-api/vlibmemory/memclnt.api delete mode 100644 vlib-api/vlibmemory/memory_client.c delete mode 100644 vlib-api/vlibmemory/memory_shared.c delete mode 100644 vlib-api/vlibmemory/memory_vlib.c delete mode 100644 vlib-api/vlibmemory/unix_shared_memory_queue.c delete mode 100644 vlib-api/vlibmemory/unix_shared_memory_queue.h delete mode 100644 vlib-api/vlibmemory/vl_memory_api_h.h delete mode 100644 vlib-api/vlibmemory/vl_memory_msg_enum.h delete mode 100644 vlib-api/vlibsocket/api.h delete mode 100644 vlib-api/vlibsocket/sock_test.c delete mode 100644 vlib-api/vlibsocket/sockclnt.api delete mode 100644 vlib-api/vlibsocket/sockclnt_vlib.c delete mode 100644 vlib-api/vlibsocket/socksvr_vlib.c delete mode 100644 vlib-api/vlibsocket/vl_socket_api_h.h delete mode 100644 vlib-api/vlibsocket/vl_socket_msg_enum.h delete mode 100644 vlib/.gitignore delete mode 100644 vlib/Makefile.am delete mode 100644 vlib/configure.ac delete mode 100644 vlib/dir.dox delete mode 100644 vlib/example/dir.dox delete mode 100644 vlib/example/main_stub.c delete mode 100644 vlib/example/mc_test.c delete mode 100644 vlib/example/plex_test.c delete mode 100644 vlib/vlib/buffer.c delete mode 100644 vlib/vlib/buffer.h delete mode 100644 vlib/vlib/buffer_funcs.h delete mode 100644 vlib/vlib/buffer_node.h delete mode 100644 vlib/vlib/cli.c delete mode 100644 vlib/vlib/cli.h delete mode 100644 vlib/vlib/cli_funcs.h delete mode 100644 vlib/vlib/counter.c delete mode 100644 vlib/vlib/counter.h delete mode 100644 vlib/vlib/defs.h delete mode 100644 vlib/vlib/dir.dox delete mode 100644 vlib/vlib/elog_samples.c delete mode 100644 vlib/vlib/error.c delete mode 100644 vlib/vlib/error.h delete mode 100644 vlib/vlib/error_funcs.h delete mode 100644 vlib/vlib/format.c delete mode 100644 vlib/vlib/format_funcs.h delete mode 100644 vlib/vlib/global_funcs.h delete mode 100644 vlib/vlib/i2c.c delete mode 100644 vlib/vlib/i2c.h delete mode 100644 vlib/vlib/init.c delete mode 100644 vlib/vlib/init.h delete mode 100644 vlib/vlib/lex.c delete mode 100644 vlib/vlib/lex.h delete mode 100644 vlib/vlib/main.c delete mode 100644 vlib/vlib/main.h delete mode 100644 vlib/vlib/mc.c delete mode 100644 vlib/vlib/mc.h delete mode 100644 vlib/vlib/node.c delete mode 100644 vlib/vlib/node.h delete mode 100644 vlib/vlib/node_cli.c delete mode 100644 vlib/vlib/node_format.c delete mode 100644 vlib/vlib/node_funcs.h delete mode 100644 vlib/vlib/parse.c delete mode 100644 vlib/vlib/parse.h delete mode 100644 vlib/vlib/parse_builtin.c delete mode 100644 vlib/vlib/pci/linux_pci.c delete mode 100644 vlib/vlib/pci/pci.c delete mode 100644 vlib/vlib/pci/pci.h delete mode 100644 vlib/vlib/pci/pci_config.h delete mode 100644 vlib/vlib/physmem.h delete mode 100644 vlib/vlib/threads.c delete mode 100644 vlib/vlib/threads.h delete mode 100644 vlib/vlib/threads_cli.c delete mode 100644 vlib/vlib/trace.c delete mode 100644 vlib/vlib/trace.h delete mode 100644 vlib/vlib/trace_funcs.h delete mode 100644 vlib/vlib/unix/cj.c delete mode 100644 vlib/vlib/unix/cj.h delete mode 100644 vlib/vlib/unix/cli.c delete mode 100644 vlib/vlib/unix/dir.dox delete mode 100644 vlib/vlib/unix/input.c delete mode 100644 vlib/vlib/unix/main.c delete mode 100644 vlib/vlib/unix/mc_socket.c delete mode 100644 vlib/vlib/unix/mc_socket.h delete mode 100644 vlib/vlib/unix/physmem.c delete mode 100644 vlib/vlib/unix/physmem.h delete mode 100644 vlib/vlib/unix/plugin.c delete mode 100644 vlib/vlib/unix/plugin.h delete mode 100644 vlib/vlib/unix/unix.h delete mode 100644 vlib/vlib/unix/util.c delete mode 100644 vlib/vlib/vlib.h delete mode 100644 vlib/vlib/vlib_process_doc.h delete mode 100644 vnet/.gitignore delete mode 100644 vnet/Makefile.am delete mode 100644 vnet/configure.ac delete mode 100644 vnet/etc/scripts/arp4 delete mode 100644 vnet/etc/scripts/arp4-mpls delete mode 100644 vnet/etc/scripts/arp6 delete mode 100644 vnet/etc/scripts/bvi delete mode 100644 vnet/etc/scripts/dhcp/dhcpd.conf delete mode 100644 vnet/etc/scripts/dhcp/left-ping-target.sh delete mode 100644 vnet/etc/scripts/dhcp/leftpeer.conf delete mode 100644 vnet/etc/scripts/icmp delete mode 100644 vnet/etc/scripts/icmp6 delete mode 100644 vnet/etc/scripts/ige delete mode 100644 vnet/etc/scripts/ip6 delete mode 100644 vnet/etc/scripts/ip6-hbh delete mode 100644 vnet/etc/scripts/ixge delete mode 100644 vnet/etc/scripts/l2efpfilter delete mode 100644 vnet/etc/scripts/l2efpfilter_perf delete mode 100644 vnet/etc/scripts/l2fib delete mode 100644 vnet/etc/scripts/l2fib_perf delete mode 100644 vnet/etc/scripts/l2fib_xc delete mode 100644 vnet/etc/scripts/l2flood delete mode 100644 vnet/etc/scripts/l2tp delete mode 100755 vnet/etc/scripts/leftpeer/leftpeer-classify delete mode 100644 vnet/etc/scripts/leftpeer/leftpeer-classify6 delete mode 100644 vnet/etc/scripts/leftpeer/leftpeer-classifyl2 delete mode 100644 vnet/etc/scripts/leftpeer/leftpeer-dhcp delete mode 100644 vnet/etc/scripts/leftpeer/leftpeer-ioam.conf delete mode 100644 vnet/etc/scripts/leftpeer/leftpeer-l3vxlan.conf delete mode 100644 vnet/etc/scripts/leftpeer/leftpeer-lisp.conf delete mode 100644 vnet/etc/scripts/leftpeer/leftpeer-mpls.conf delete mode 100644 vnet/etc/scripts/leftpeer/leftpeer-sr.conf delete mode 100644 vnet/etc/scripts/leftpeer/leftpeer-vxlan.conf delete mode 100644 vnet/etc/scripts/leftpeer/leftpeer.script delete mode 100644 vnet/etc/scripts/lfib/ip4-to-mpls delete mode 100644 vnet/etc/scripts/lfib/mpls-pop-to-mpls delete mode 100644 vnet/etc/scripts/lfib/mpls-to-ip4 delete mode 100644 vnet/etc/scripts/lfib/mpls-to-mpls delete mode 100644 vnet/etc/scripts/mpls-o-ethernet/leftpeer.conf delete mode 100644 vnet/etc/scripts/mpls-o-ethernet/pg delete mode 100644 vnet/etc/scripts/mpls-o-ethernet/rightpeer.conf delete mode 100644 vnet/etc/scripts/mpls-o-ethernet/single.conf delete mode 100644 vnet/etc/scripts/mpls-o-gre/dhcpd.conf delete mode 100644 vnet/etc/scripts/mpls-o-gre/leftpeer.conf delete mode 100644 vnet/etc/scripts/mpls-o-gre/rightpeer.conf delete mode 100644 vnet/etc/scripts/mpls-tunnel delete mode 100644 vnet/etc/scripts/pcap delete mode 100644 vnet/etc/scripts/probe4 delete mode 100644 vnet/etc/scripts/probe6 delete mode 100644 vnet/etc/scripts/rewrite delete mode 100644 vnet/etc/scripts/rightpeer/rightpeer-ioam.conf delete mode 100644 vnet/etc/scripts/rightpeer/rightpeer-l3vxlan.conf delete mode 100644 vnet/etc/scripts/rightpeer/rightpeer-lisp.conf delete mode 100644 vnet/etc/scripts/rightpeer/rightpeer-mpls-l2.conf delete mode 100644 vnet/etc/scripts/rightpeer/rightpeer-mpls.conf delete mode 100644 vnet/etc/scripts/rightpeer/rightpeer-sr.conf delete mode 100644 vnet/etc/scripts/rightpeer/rightpeer-vxlan.conf delete mode 100644 vnet/etc/scripts/rightpeer/rightpeer.script delete mode 100644 vnet/etc/scripts/rpf delete mode 100644 vnet/etc/scripts/rtt-test delete mode 100644 vnet/etc/scripts/snat delete mode 100644 vnet/etc/scripts/snat_static delete mode 100644 vnet/etc/scripts/snat_static_with_port delete mode 100644 vnet/etc/scripts/source_and_port_range_check delete mode 100644 vnet/etc/scripts/speed delete mode 100755 vnet/etc/scripts/sr/left-linux-ping.sh delete mode 100644 vnet/etc/scripts/sr/leftpeer.conf delete mode 100755 vnet/etc/scripts/sr/right-linux-ping.sh delete mode 100644 vnet/etc/scripts/sr/rightpeer.conf delete mode 100755 vnet/etc/scripts/sr/srlocal.sh delete mode 100644 vnet/etc/scripts/srp delete mode 100644 vnet/etc/scripts/tcp delete mode 100644 vnet/etc/scripts/tcp-test delete mode 100644 vnet/etc/scripts/tf-ucs-1 delete mode 100644 vnet/etc/scripts/urpf delete mode 100644 vnet/etc/scripts/virl/ip6sr.virl delete mode 100644 vnet/etc/scripts/virl/ip6sr_notes.txt delete mode 100644 vnet/etc/scripts/virl/mplsogre.virl delete mode 100644 vnet/etc/scripts/virl/simple.virl delete mode 100644 vnet/etc/scripts/vlan delete mode 120000 vnet/suffix-rules.mk delete mode 100644 vnet/test/README delete mode 100644 vnet/test/lisp-cp/test_cp_serdes.c delete mode 100644 vnet/test/lisp-cp/test_lisp_types.c delete mode 100644 vnet/test/lisp-gpe/test.c delete mode 100644 vnet/vnet/adj/adj.c delete mode 100644 vnet/vnet/adj/adj.h delete mode 100644 vnet/vnet/adj/adj_glean.c delete mode 100644 vnet/vnet/adj/adj_glean.h delete mode 100644 vnet/vnet/adj/adj_internal.h delete mode 100644 vnet/vnet/adj/adj_l2.c delete mode 100644 vnet/vnet/adj/adj_l2.h delete mode 100644 vnet/vnet/adj/adj_midchain.c delete mode 100644 vnet/vnet/adj/adj_midchain.h delete mode 100644 vnet/vnet/adj/adj_nbr.c delete mode 100644 vnet/vnet/adj/adj_nbr.h delete mode 100644 vnet/vnet/adj/adj_rewrite.c delete mode 100644 vnet/vnet/adj/adj_rewrite.h delete mode 100644 vnet/vnet/adj/adj_types.h delete mode 100644 vnet/vnet/api_errno.h delete mode 100644 vnet/vnet/bfd/bfd.api delete mode 100644 vnet/vnet/bfd/bfd_api.c delete mode 100644 vnet/vnet/bfd/bfd_api.h delete mode 100644 vnet/vnet/bfd/bfd_debug.h delete mode 100644 vnet/vnet/bfd/bfd_doc.md delete mode 100644 vnet/vnet/bfd/bfd_main.c delete mode 100644 vnet/vnet/bfd/bfd_main.h delete mode 100644 vnet/vnet/bfd/bfd_protocol.c delete mode 100644 vnet/vnet/bfd/bfd_protocol.h delete mode 100644 vnet/vnet/bfd/bfd_udp.c delete mode 100644 vnet/vnet/bfd/bfd_udp.h delete mode 100644 vnet/vnet/bfd/dir.dox delete mode 100644 vnet/vnet/buffer.h delete mode 100644 vnet/vnet/cdp/cdp.pg delete mode 100644 vnet/vnet/cdp/cdp_input.c delete mode 100644 vnet/vnet/cdp/cdp_node.c delete mode 100644 vnet/vnet/cdp/cdp_node.h delete mode 100644 vnet/vnet/cdp/cdp_periodic.c delete mode 100644 vnet/vnet/cdp/cdp_protocol.h delete mode 100644 vnet/vnet/classify/README delete mode 100644 vnet/vnet/classify/flow_classify.c delete mode 100644 vnet/vnet/classify/flow_classify.h delete mode 100644 vnet/vnet/classify/flow_classify_node.c delete mode 100644 vnet/vnet/classify/input_acl.c delete mode 100644 vnet/vnet/classify/input_acl.h delete mode 100644 vnet/vnet/classify/ip_classify.c delete mode 100644 vnet/vnet/classify/policer_classify.c delete mode 100644 vnet/vnet/classify/policer_classify.h delete mode 100644 vnet/vnet/classify/vnet_classify.c delete mode 100644 vnet/vnet/classify/vnet_classify.h delete mode 100644 vnet/vnet/config.c delete mode 100644 vnet/vnet/config.h delete mode 100644 vnet/vnet/cop/cop.c delete mode 100644 vnet/vnet/cop/cop.h delete mode 100644 vnet/vnet/cop/ip4_whitelist.c delete mode 100644 vnet/vnet/cop/ip6_whitelist.c delete mode 100644 vnet/vnet/cop/node1.c delete mode 100644 vnet/vnet/devices/af_packet/af_packet.api delete mode 100644 vnet/vnet/devices/af_packet/af_packet.c delete mode 100644 vnet/vnet/devices/af_packet/af_packet.h delete mode 100644 vnet/vnet/devices/af_packet/af_packet_api.c delete mode 100644 vnet/vnet/devices/af_packet/cli.c delete mode 100644 vnet/vnet/devices/af_packet/device.c delete mode 100644 vnet/vnet/devices/af_packet/node.c delete mode 100644 vnet/vnet/devices/devices.c delete mode 100644 vnet/vnet/devices/devices.h delete mode 100644 vnet/vnet/devices/dpdk/cli.c delete mode 100644 vnet/vnet/devices/dpdk/device.c delete mode 100644 vnet/vnet/devices/dpdk/dpdk.h delete mode 100644 vnet/vnet/devices/dpdk/dpdk_priv.h delete mode 100644 vnet/vnet/devices/dpdk/format.c delete mode 100644 vnet/vnet/devices/dpdk/hqos.c delete mode 100755 vnet/vnet/devices/dpdk/init.c delete mode 100644 vnet/vnet/devices/dpdk/ipsec/cli.c delete mode 100644 vnet/vnet/devices/dpdk/ipsec/crypto_node.c delete mode 100644 vnet/vnet/devices/dpdk/ipsec/dir.dox delete mode 100644 vnet/vnet/devices/dpdk/ipsec/dpdk_crypto_ipsec_doc.md delete mode 100644 vnet/vnet/devices/dpdk/ipsec/esp.h delete mode 100644 vnet/vnet/devices/dpdk/ipsec/esp_decrypt.c delete mode 100644 vnet/vnet/devices/dpdk/ipsec/esp_encrypt.c delete mode 100644 vnet/vnet/devices/dpdk/ipsec/ipsec.c delete mode 100644 vnet/vnet/devices/dpdk/ipsec/ipsec.h delete mode 100644 vnet/vnet/devices/dpdk/node.c delete mode 100644 vnet/vnet/devices/dpdk/qos_doc.md delete mode 100644 vnet/vnet/devices/netmap/cli.c delete mode 100644 vnet/vnet/devices/netmap/device.c delete mode 100644 vnet/vnet/devices/netmap/net_netmap.h delete mode 100644 vnet/vnet/devices/netmap/netmap.api delete mode 100644 vnet/vnet/devices/netmap/netmap.c delete mode 100644 vnet/vnet/devices/netmap/netmap.h delete mode 100644 vnet/vnet/devices/netmap/netmap_api.c delete mode 100644 vnet/vnet/devices/netmap/node.c delete mode 100644 vnet/vnet/devices/nic/ixge.c delete mode 100644 vnet/vnet/devices/nic/ixge.h delete mode 100644 vnet/vnet/devices/nic/sfp.c delete mode 100644 vnet/vnet/devices/nic/sfp.h delete mode 100644 vnet/vnet/devices/ssvm/node.c delete mode 100644 vnet/vnet/devices/ssvm/ssvm_eth.c delete mode 100644 vnet/vnet/devices/ssvm/ssvm_eth.h delete mode 100644 vnet/vnet/devices/virtio/dir.dox delete mode 100644 vnet/vnet/devices/virtio/vhost-user.c delete mode 100644 vnet/vnet/devices/virtio/vhost-user.h delete mode 100644 vnet/vnet/devices/virtio/vhost_user.api delete mode 100644 vnet/vnet/devices/virtio/vhost_user_api.c delete mode 100644 vnet/vnet/dhcp/client.c delete mode 100644 vnet/vnet/dhcp/client.h delete mode 100644 vnet/vnet/dhcp/packet.h delete mode 100644 vnet/vnet/dhcp/proxy.h delete mode 100644 vnet/vnet/dhcp/proxy_error.def delete mode 100644 vnet/vnet/dhcp/proxy_node.c delete mode 100644 vnet/vnet/dhcpv6/packet.h delete mode 100644 vnet/vnet/dhcpv6/proxy.h delete mode 100644 vnet/vnet/dhcpv6/proxy_error.def delete mode 100644 vnet/vnet/dhcpv6/proxy_node.c delete mode 100644 vnet/vnet/dpo/classify_dpo.c delete mode 100644 vnet/vnet/dpo/classify_dpo.h delete mode 100644 vnet/vnet/dpo/dpo.c delete mode 100644 vnet/vnet/dpo/dpo.h delete mode 100644 vnet/vnet/dpo/drop_dpo.c delete mode 100644 vnet/vnet/dpo/drop_dpo.h delete mode 100644 vnet/vnet/dpo/ip_null_dpo.c delete mode 100644 vnet/vnet/dpo/ip_null_dpo.h delete mode 100644 vnet/vnet/dpo/load_balance.c delete mode 100644 vnet/vnet/dpo/load_balance.h delete mode 100644 vnet/vnet/dpo/load_balance_map.c delete mode 100644 vnet/vnet/dpo/load_balance_map.h delete mode 100644 vnet/vnet/dpo/lookup_dpo.c delete mode 100644 vnet/vnet/dpo/lookup_dpo.h delete mode 100644 vnet/vnet/dpo/mpls_label_dpo.c delete mode 100644 vnet/vnet/dpo/mpls_label_dpo.h delete mode 100644 vnet/vnet/dpo/punt_dpo.c delete mode 100644 vnet/vnet/dpo/punt_dpo.h delete mode 100644 vnet/vnet/dpo/receive_dpo.c delete mode 100644 vnet/vnet/dpo/receive_dpo.h delete mode 100644 vnet/vnet/ethernet/arp.c delete mode 100644 vnet/vnet/ethernet/arp_packet.h delete mode 100644 vnet/vnet/ethernet/dir.dox delete mode 100644 vnet/vnet/ethernet/error.def delete mode 100644 vnet/vnet/ethernet/ethernet.h delete mode 100644 vnet/vnet/ethernet/format.c delete mode 100644 vnet/vnet/ethernet/init.c delete mode 100644 vnet/vnet/ethernet/interface.c delete mode 100644 vnet/vnet/ethernet/mac_swap.c delete mode 100755 vnet/vnet/ethernet/node.c delete mode 100644 vnet/vnet/ethernet/packet.h delete mode 100644 vnet/vnet/ethernet/pg.c delete mode 100644 vnet/vnet/ethernet/types.def delete mode 100644 vnet/vnet/feature/feature.c delete mode 100644 vnet/vnet/feature/feature.h delete mode 100644 vnet/vnet/feature/registration.c delete mode 100644 vnet/vnet/fib/fib.c delete mode 100644 vnet/vnet/fib/fib.h delete mode 100644 vnet/vnet/fib/fib_api.h delete mode 100644 vnet/vnet/fib/fib_attached_export.c delete mode 100644 vnet/vnet/fib/fib_attached_export.h delete mode 100644 vnet/vnet/fib/fib_entry.c delete mode 100644 vnet/vnet/fib/fib_entry.h delete mode 100644 vnet/vnet/fib/fib_entry_cover.c delete mode 100644 vnet/vnet/fib/fib_entry_cover.h delete mode 100644 vnet/vnet/fib/fib_entry_delegate.c delete mode 100644 vnet/vnet/fib/fib_entry_delegate.h delete mode 100644 vnet/vnet/fib/fib_entry_src.c delete mode 100644 vnet/vnet/fib/fib_entry_src.h delete mode 100644 vnet/vnet/fib/fib_entry_src_adj.c delete mode 100644 vnet/vnet/fib/fib_entry_src_api.c delete mode 100644 vnet/vnet/fib/fib_entry_src_default.c delete mode 100644 vnet/vnet/fib/fib_entry_src_default_route.c delete mode 100644 vnet/vnet/fib/fib_entry_src_interface.c delete mode 100644 vnet/vnet/fib/fib_entry_src_lisp.c delete mode 100644 vnet/vnet/fib/fib_entry_src_mpls.c delete mode 100644 vnet/vnet/fib/fib_entry_src_rr.c delete mode 100644 vnet/vnet/fib/fib_entry_src_special.c delete mode 100644 vnet/vnet/fib/fib_internal.h delete mode 100644 vnet/vnet/fib/fib_node.c delete mode 100644 vnet/vnet/fib/fib_node.h delete mode 100644 vnet/vnet/fib/fib_node_list.c delete mode 100644 vnet/vnet/fib/fib_node_list.h delete mode 100644 vnet/vnet/fib/fib_path.c delete mode 100644 vnet/vnet/fib/fib_path.h delete mode 100644 vnet/vnet/fib/fib_path_ext.c delete mode 100644 vnet/vnet/fib/fib_path_ext.h delete mode 100644 vnet/vnet/fib/fib_path_list.c delete mode 100644 vnet/vnet/fib/fib_path_list.h delete mode 100644 vnet/vnet/fib/fib_table.c delete mode 100644 vnet/vnet/fib/fib_table.h delete mode 100644 vnet/vnet/fib/fib_test.c delete mode 100644 vnet/vnet/fib/fib_types.c delete mode 100644 vnet/vnet/fib/fib_types.h delete mode 100644 vnet/vnet/fib/fib_urpf_list.c delete mode 100644 vnet/vnet/fib/fib_urpf_list.h delete mode 100644 vnet/vnet/fib/fib_walk.c delete mode 100644 vnet/vnet/fib/fib_walk.h delete mode 100644 vnet/vnet/fib/ip4_fib.c delete mode 100644 vnet/vnet/fib/ip4_fib.h delete mode 100644 vnet/vnet/fib/ip6_fib.c delete mode 100644 vnet/vnet/fib/ip6_fib.h delete mode 100644 vnet/vnet/fib/mpls_fib.c delete mode 100644 vnet/vnet/fib/mpls_fib.h delete mode 100644 vnet/vnet/flow/flow_report.c delete mode 100644 vnet/vnet/flow/flow_report.h delete mode 100644 vnet/vnet/flow/flow_report_classify.c delete mode 100644 vnet/vnet/flow/flow_report_classify.h delete mode 100644 vnet/vnet/flow/ipfix_info_elements.h delete mode 100644 vnet/vnet/flow/ipfix_packet.h delete mode 100644 vnet/vnet/global_funcs.h delete mode 100644 vnet/vnet/gre/error.def delete mode 100644 vnet/vnet/gre/gre.api delete mode 100644 vnet/vnet/gre/gre.c delete mode 100644 vnet/vnet/gre/gre.h delete mode 100644 vnet/vnet/gre/gre_api.c delete mode 100644 vnet/vnet/gre/interface.c delete mode 100644 vnet/vnet/gre/node.c delete mode 100644 vnet/vnet/gre/packet.h delete mode 100644 vnet/vnet/gre/pg.c delete mode 100644 vnet/vnet/handoff.c delete mode 100644 vnet/vnet/handoff.h delete mode 100644 vnet/vnet/hdlc/error.def delete mode 100644 vnet/vnet/hdlc/hdlc.c delete mode 100644 vnet/vnet/hdlc/hdlc.h delete mode 100644 vnet/vnet/hdlc/node.c delete mode 100644 vnet/vnet/hdlc/packet.h delete mode 100644 vnet/vnet/hdlc/pg.c delete mode 100644 vnet/vnet/interface.api delete mode 100644 vnet/vnet/interface.c delete mode 100644 vnet/vnet/interface.h delete mode 100644 vnet/vnet/interface_api.c delete mode 100644 vnet/vnet/interface_cli.c delete mode 100644 vnet/vnet/interface_format.c delete mode 100644 vnet/vnet/interface_funcs.h delete mode 100644 vnet/vnet/interface_output.c delete mode 100644 vnet/vnet/ip/dir.dox delete mode 100644 vnet/vnet/ip/format.c delete mode 100644 vnet/vnet/ip/format.h delete mode 100644 vnet/vnet/ip/icmp4.c delete mode 100644 vnet/vnet/ip/icmp4.h delete mode 100644 vnet/vnet/ip/icmp46_packet.h delete mode 100644 vnet/vnet/ip/icmp6.c delete mode 100644 vnet/vnet/ip/icmp6.h delete mode 100644 vnet/vnet/ip/igmp_packet.h delete mode 100644 vnet/vnet/ip/ip.api delete mode 100644 vnet/vnet/ip/ip.h delete mode 100644 vnet/vnet/ip/ip4.h delete mode 100644 vnet/vnet/ip/ip46_cli.c delete mode 100644 vnet/vnet/ip/ip4_error.h delete mode 100644 vnet/vnet/ip/ip4_format.c delete mode 100644 vnet/vnet/ip/ip4_forward.c delete mode 100644 vnet/vnet/ip/ip4_input.c delete mode 100644 vnet/vnet/ip/ip4_mtrie.c delete mode 100644 vnet/vnet/ip/ip4_mtrie.h delete mode 100644 vnet/vnet/ip/ip4_packet.h delete mode 100644 vnet/vnet/ip/ip4_pg.c delete mode 100644 vnet/vnet/ip/ip4_source_and_port_range_check.c delete mode 100644 vnet/vnet/ip/ip4_source_check.c delete mode 100644 vnet/vnet/ip/ip4_test.c delete mode 100644 vnet/vnet/ip/ip6.h delete mode 100644 vnet/vnet/ip/ip6_error.h delete mode 100644 vnet/vnet/ip/ip6_format.c delete mode 100644 vnet/vnet/ip/ip6_forward.c delete mode 100644 vnet/vnet/ip/ip6_hop_by_hop.c delete mode 100644 vnet/vnet/ip/ip6_hop_by_hop.h delete mode 100644 vnet/vnet/ip/ip6_hop_by_hop_packet.h delete mode 100644 vnet/vnet/ip/ip6_input.c delete mode 100644 vnet/vnet/ip/ip6_neighbor.c delete mode 100644 vnet/vnet/ip/ip6_neighbor.h delete mode 100644 vnet/vnet/ip/ip6_packet.h delete mode 100644 vnet/vnet/ip/ip6_pg.c delete mode 100644 vnet/vnet/ip/ip_api.c delete mode 100644 vnet/vnet/ip/ip_checksum.c delete mode 100644 vnet/vnet/ip/ip_frag.c delete mode 100644 vnet/vnet/ip/ip_frag.h delete mode 100644 vnet/vnet/ip/ip_init.c delete mode 100644 vnet/vnet/ip/ip_input_acl.c delete mode 100644 vnet/vnet/ip/ip_packet.h delete mode 100644 vnet/vnet/ip/ip_source_and_port_range_check.h delete mode 100644 vnet/vnet/ip/lookup.c delete mode 100644 vnet/vnet/ip/lookup.h delete mode 100644 vnet/vnet/ip/ping.c delete mode 100644 vnet/vnet/ip/ping.h delete mode 100644 vnet/vnet/ip/ports.def delete mode 100644 vnet/vnet/ip/protocols.def delete mode 100644 vnet/vnet/ip/punt.c delete mode 100644 vnet/vnet/ip/punt.h delete mode 100644 vnet/vnet/ip/punt_error.def delete mode 100644 vnet/vnet/ip/tcp_packet.h delete mode 100644 vnet/vnet/ip/udp.h delete mode 100644 vnet/vnet/ip/udp_error.def delete mode 100644 vnet/vnet/ip/udp_format.c delete mode 100644 vnet/vnet/ip/udp_init.c delete mode 100644 vnet/vnet/ip/udp_local.c delete mode 100644 vnet/vnet/ip/udp_packet.h delete mode 100644 vnet/vnet/ip/udp_pg.c delete mode 100644 vnet/vnet/ipsec-gre/dir.dox delete mode 100644 vnet/vnet/ipsec-gre/error.def delete mode 100644 vnet/vnet/ipsec-gre/interface.c delete mode 100644 vnet/vnet/ipsec-gre/ipsec_gre.api delete mode 100644 vnet/vnet/ipsec-gre/ipsec_gre.c delete mode 100644 vnet/vnet/ipsec-gre/ipsec_gre.h delete mode 100644 vnet/vnet/ipsec-gre/ipsec_gre_api.c delete mode 100644 vnet/vnet/ipsec-gre/ipsec_gre_doc.md delete mode 100644 vnet/vnet/ipsec-gre/node.c delete mode 100644 vnet/vnet/ipsec/esp.h delete mode 100644 vnet/vnet/ipsec/esp_decrypt.c delete mode 100644 vnet/vnet/ipsec/esp_encrypt.c delete mode 100644 vnet/vnet/ipsec/ikev2.c delete mode 100644 vnet/vnet/ipsec/ikev2.h delete mode 100644 vnet/vnet/ipsec/ikev2_cli.c delete mode 100644 vnet/vnet/ipsec/ikev2_crypto.c delete mode 100644 vnet/vnet/ipsec/ikev2_format.c delete mode 100644 vnet/vnet/ipsec/ikev2_payload.c delete mode 100644 vnet/vnet/ipsec/ikev2_priv.h delete mode 100644 vnet/vnet/ipsec/ipsec.api delete mode 100644 vnet/vnet/ipsec/ipsec.c delete mode 100644 vnet/vnet/ipsec/ipsec.h delete mode 100644 vnet/vnet/ipsec/ipsec_api.c delete mode 100644 vnet/vnet/ipsec/ipsec_cli.c delete mode 100644 vnet/vnet/ipsec/ipsec_format.c delete mode 100644 vnet/vnet/ipsec/ipsec_if.c delete mode 100644 vnet/vnet/ipsec/ipsec_if_in.c delete mode 100644 vnet/vnet/ipsec/ipsec_if_out.c delete mode 100644 vnet/vnet/ipsec/ipsec_input.c delete mode 100644 vnet/vnet/ipsec/ipsec_output.c delete mode 100644 vnet/vnet/l2/dir.dox delete mode 100644 vnet/vnet/l2/feat_bitmap.c delete mode 100644 vnet/vnet/l2/feat_bitmap.h delete mode 100644 vnet/vnet/l2/l2.api delete mode 100644 vnet/vnet/l2/l2_api.c delete mode 100644 vnet/vnet/l2/l2_bd.c delete mode 100644 vnet/vnet/l2/l2_bd.h delete mode 100644 vnet/vnet/l2/l2_bvi.c delete mode 100644 vnet/vnet/l2/l2_bvi.h delete mode 100644 vnet/vnet/l2/l2_classify.h delete mode 100644 vnet/vnet/l2/l2_efp_filter.c delete mode 100644 vnet/vnet/l2/l2_efp_filter.h delete mode 100644 vnet/vnet/l2/l2_fib.c delete mode 100644 vnet/vnet/l2/l2_fib.h delete mode 100644 vnet/vnet/l2/l2_flood.c delete mode 100644 vnet/vnet/l2/l2_flood.h delete mode 100644 vnet/vnet/l2/l2_fwd.c delete mode 100644 vnet/vnet/l2/l2_fwd.h delete mode 100644 vnet/vnet/l2/l2_input.c delete mode 100644 vnet/vnet/l2/l2_input.h delete mode 100644 vnet/vnet/l2/l2_input_acl.c delete mode 100644 vnet/vnet/l2/l2_input_classify.c delete mode 100644 vnet/vnet/l2/l2_input_vtr.c delete mode 100644 vnet/vnet/l2/l2_input_vtr.h delete mode 100644 vnet/vnet/l2/l2_learn.c delete mode 100644 vnet/vnet/l2/l2_learn.h delete mode 100644 vnet/vnet/l2/l2_output.c delete mode 100644 vnet/vnet/l2/l2_output.h delete mode 100644 vnet/vnet/l2/l2_output_acl.c delete mode 100644 vnet/vnet/l2/l2_output_classify.c delete mode 100644 vnet/vnet/l2/l2_patch.c delete mode 100644 vnet/vnet/l2/l2_rw.c delete mode 100644 vnet/vnet/l2/l2_rw.h delete mode 100644 vnet/vnet/l2/l2_vtr.c delete mode 100644 vnet/vnet/l2/l2_vtr.h delete mode 100644 vnet/vnet/l2/l2_xcrw.c delete mode 100644 vnet/vnet/l2/l2_xcrw.h delete mode 100644 vnet/vnet/l2tp/decap.c delete mode 100644 vnet/vnet/l2tp/encap.c delete mode 100644 vnet/vnet/l2tp/l2tp.api delete mode 100644 vnet/vnet/l2tp/l2tp.c delete mode 100644 vnet/vnet/l2tp/l2tp.h delete mode 100644 vnet/vnet/l2tp/l2tp_api.c delete mode 100644 vnet/vnet/l2tp/packet.h delete mode 100644 vnet/vnet/l2tp/pg.c delete mode 100644 vnet/vnet/l3_types.h delete mode 100644 vnet/vnet/lawful-intercept/lawful_intercept.c delete mode 100644 vnet/vnet/lawful-intercept/lawful_intercept.h delete mode 100644 vnet/vnet/lawful-intercept/node.c delete mode 100644 vnet/vnet/lisp-cp/control.c delete mode 100644 vnet/vnet/lisp-cp/control.h delete mode 100644 vnet/vnet/lisp-cp/gid_dictionary.c delete mode 100644 vnet/vnet/lisp-cp/gid_dictionary.h delete mode 100644 vnet/vnet/lisp-cp/lisp.api delete mode 100644 vnet/vnet/lisp-cp/lisp_api.c delete mode 100644 vnet/vnet/lisp-cp/lisp_cp_dpo.c delete mode 100644 vnet/vnet/lisp-cp/lisp_cp_dpo.h delete mode 100644 vnet/vnet/lisp-cp/lisp_cp_messages.h delete mode 100644 vnet/vnet/lisp-cp/lisp_msg_serdes.c delete mode 100644 vnet/vnet/lisp-cp/lisp_msg_serdes.h delete mode 100644 vnet/vnet/lisp-cp/lisp_types.c delete mode 100644 vnet/vnet/lisp-cp/lisp_types.h delete mode 100644 vnet/vnet/lisp-cp/packets.c delete mode 100644 vnet/vnet/lisp-cp/packets.h delete mode 100644 vnet/vnet/lisp-gpe/decap.c delete mode 100644 vnet/vnet/lisp-gpe/dir.dox delete mode 100644 vnet/vnet/lisp-gpe/interface.c delete mode 100644 vnet/vnet/lisp-gpe/lisp_gpe.api delete mode 100644 vnet/vnet/lisp-gpe/lisp_gpe.c delete mode 100644 vnet/vnet/lisp-gpe/lisp_gpe.h delete mode 100644 vnet/vnet/lisp-gpe/lisp_gpe_adjacency.c delete mode 100644 vnet/vnet/lisp-gpe/lisp_gpe_adjacency.h delete mode 100644 vnet/vnet/lisp-gpe/lisp_gpe_api.c delete mode 100644 vnet/vnet/lisp-gpe/lisp_gpe_error.def delete mode 100644 vnet/vnet/lisp-gpe/lisp_gpe_fwd_entry.c delete mode 100644 vnet/vnet/lisp-gpe/lisp_gpe_fwd_entry.h delete mode 100644 vnet/vnet/lisp-gpe/lisp_gpe_packet.h delete mode 100644 vnet/vnet/lisp-gpe/lisp_gpe_sub_interface.c delete mode 100644 vnet/vnet/lisp-gpe/lisp_gpe_sub_interface.h delete mode 100644 vnet/vnet/lisp-gpe/lisp_gpe_tenant.c delete mode 100644 vnet/vnet/lisp-gpe/lisp_gpe_tenant.h delete mode 100644 vnet/vnet/lisp-gpe/lisp_gpe_tunnel.c delete mode 100644 vnet/vnet/lisp-gpe/lisp_gpe_tunnel.h delete mode 100644 vnet/vnet/lisp-gpe/rfc.txt delete mode 100644 vnet/vnet/llc/llc.c delete mode 100644 vnet/vnet/llc/llc.h delete mode 100644 vnet/vnet/llc/node.c delete mode 100644 vnet/vnet/llc/pg.c delete mode 100644 vnet/vnet/lldp/dir.dox delete mode 100644 vnet/vnet/lldp/lldp_cli.c delete mode 100644 vnet/vnet/lldp/lldp_doc.md delete mode 100644 vnet/vnet/lldp/lldp_input.c delete mode 100644 vnet/vnet/lldp/lldp_node.c delete mode 100644 vnet/vnet/lldp/lldp_node.h delete mode 100644 vnet/vnet/lldp/lldp_output.c delete mode 100644 vnet/vnet/lldp/lldp_protocol.h delete mode 100755 vnet/vnet/map/examples/gen-rules.py delete mode 100644 vnet/vnet/map/examples/health_check.c delete mode 100755 vnet/vnet/map/examples/test_map.py delete mode 100755 vnet/vnet/map/gen-rules.py delete mode 100644 vnet/vnet/map/ip4_map.c delete mode 100644 vnet/vnet/map/ip4_map_t.c delete mode 100644 vnet/vnet/map/ip6_map.c delete mode 100644 vnet/vnet/map/ip6_map_t.c delete mode 100644 vnet/vnet/map/map.api delete mode 100644 vnet/vnet/map/map.c delete mode 100644 vnet/vnet/map/map.h delete mode 100644 vnet/vnet/map/map_api.c delete mode 100644 vnet/vnet/map/map_doc.md delete mode 100644 vnet/vnet/map/map_dpo.c delete mode 100644 vnet/vnet/map/map_dpo.h delete mode 100644 vnet/vnet/map/test.c delete mode 100644 vnet/vnet/mcast/mcast.c delete mode 100644 vnet/vnet/mcast/mcast.h delete mode 100644 vnet/vnet/mcast/mcast_test.c delete mode 100644 vnet/vnet/misc.c delete mode 100644 vnet/vnet/mpls/error.def delete mode 100644 vnet/vnet/mpls/interface.c delete mode 100644 vnet/vnet/mpls/mpls.c delete mode 100644 vnet/vnet/mpls/mpls.h delete mode 100644 vnet/vnet/mpls/mpls_features.c delete mode 100644 vnet/vnet/mpls/mpls_lookup.c delete mode 100644 vnet/vnet/mpls/mpls_output.c delete mode 100644 vnet/vnet/mpls/mpls_tunnel.c delete mode 100644 vnet/vnet/mpls/mpls_tunnel.h delete mode 100644 vnet/vnet/mpls/mpls_types.h delete mode 100644 vnet/vnet/mpls/node.c delete mode 100644 vnet/vnet/mpls/packet.h delete mode 100644 vnet/vnet/mpls/pg.c delete mode 100644 vnet/vnet/osi/node.c delete mode 100644 vnet/vnet/osi/osi.c delete mode 100644 vnet/vnet/osi/osi.h delete mode 100644 vnet/vnet/osi/pg.c delete mode 100644 vnet/vnet/pg/cli.c delete mode 100644 vnet/vnet/pg/edit.c delete mode 100644 vnet/vnet/pg/edit.h delete mode 100644 vnet/vnet/pg/example.script delete mode 100644 vnet/vnet/pg/init.c delete mode 100644 vnet/vnet/pg/input.c delete mode 100644 vnet/vnet/pg/output.c delete mode 100644 vnet/vnet/pg/pg.h delete mode 100644 vnet/vnet/pg/stream.c delete mode 100644 vnet/vnet/pipeline.h delete mode 100644 vnet/vnet/plugin/p1.c delete mode 100644 vnet/vnet/plugin/plugin.h delete mode 100644 vnet/vnet/policer/node_funcs.c delete mode 100644 vnet/vnet/policer/police.h delete mode 100644 vnet/vnet/policer/policer.c delete mode 100644 vnet/vnet/policer/policer.h delete mode 100644 vnet/vnet/policer/xlate.c delete mode 100644 vnet/vnet/policer/xlate.h delete mode 100644 vnet/vnet/ppp/error.def delete mode 100644 vnet/vnet/ppp/node.c delete mode 100644 vnet/vnet/ppp/packet.h delete mode 100644 vnet/vnet/ppp/pg.c delete mode 100644 vnet/vnet/ppp/ppp.c delete mode 100644 vnet/vnet/ppp/ppp.h delete mode 100644 vnet/vnet/replication.c delete mode 100644 vnet/vnet/replication.h delete mode 100644 vnet/vnet/rewrite.c delete mode 100644 vnet/vnet/rewrite.h delete mode 100644 vnet/vnet/snap/node.c delete mode 100644 vnet/vnet/snap/pg.c delete mode 100644 vnet/vnet/snap/snap.c delete mode 100644 vnet/vnet/snap/snap.h delete mode 100644 vnet/vnet/span/node.c delete mode 100644 vnet/vnet/span/span.api delete mode 100644 vnet/vnet/span/span.c delete mode 100644 vnet/vnet/span/span.h delete mode 100644 vnet/vnet/span/span.md delete mode 100644 vnet/vnet/span/span_api.c delete mode 100644 vnet/vnet/sr/dir.dox delete mode 100644 vnet/vnet/sr/examples/sr_multicastmap.script delete mode 100644 vnet/vnet/sr/rfc_draft_05.txt delete mode 100644 vnet/vnet/sr/sr.c delete mode 100644 vnet/vnet/sr/sr.h delete mode 100644 vnet/vnet/sr/sr_error.def delete mode 100644 vnet/vnet/sr/sr_fix_dst_error.def delete mode 100644 vnet/vnet/sr/sr_packet.h delete mode 100644 vnet/vnet/sr/sr_replicate.c delete mode 100644 vnet/vnet/srp/format.c delete mode 100644 vnet/vnet/srp/interface.c delete mode 100644 vnet/vnet/srp/node.c delete mode 100644 vnet/vnet/srp/packet.h delete mode 100644 vnet/vnet/srp/pg.c delete mode 100644 vnet/vnet/srp/srp.h delete mode 100644 vnet/vnet/unix/gdb_funcs.c delete mode 100644 vnet/vnet/unix/pcap.c delete mode 100644 vnet/vnet/unix/pcap.h delete mode 100644 vnet/vnet/unix/pcap2pg.c delete mode 100644 vnet/vnet/unix/tap.api delete mode 100644 vnet/vnet/unix/tap_api.c delete mode 100644 vnet/vnet/unix/tapcli.c delete mode 100644 vnet/vnet/unix/tapcli.h delete mode 100644 vnet/vnet/unix/tuntap.c delete mode 100644 vnet/vnet/unix/tuntap.h delete mode 100644 vnet/vnet/vnet.h delete mode 100644 vnet/vnet/vnet_all_api_h.h delete mode 100644 vnet/vnet/vnet_msg_enum.h delete mode 100644 vnet/vnet/vxlan-gpe/decap.c delete mode 100644 vnet/vnet/vxlan-gpe/dir.dox delete mode 100644 vnet/vnet/vxlan-gpe/encap.c delete mode 100644 vnet/vnet/vxlan-gpe/vxlan-gpe-rfc.txt delete mode 100644 vnet/vnet/vxlan-gpe/vxlan_gpe.api delete mode 100644 vnet/vnet/vxlan-gpe/vxlan_gpe.c delete mode 100644 vnet/vnet/vxlan-gpe/vxlan_gpe.h delete mode 100644 vnet/vnet/vxlan-gpe/vxlan_gpe_api.c delete mode 100644 vnet/vnet/vxlan-gpe/vxlan_gpe_error.def delete mode 100644 vnet/vnet/vxlan-gpe/vxlan_gpe_packet.h delete mode 100644 vnet/vnet/vxlan/decap.c delete mode 100644 vnet/vnet/vxlan/dir.dox delete mode 100644 vnet/vnet/vxlan/encap.c delete mode 100644 vnet/vnet/vxlan/vxlan.api delete mode 100644 vnet/vnet/vxlan/vxlan.c delete mode 100644 vnet/vnet/vxlan/vxlan.h delete mode 100644 vnet/vnet/vxlan/vxlan_api.c delete mode 100644 vnet/vnet/vxlan/vxlan_error.def delete mode 100644 vnet/vnet/vxlan/vxlan_packet.h delete mode 100644 vpp-api-test/Makefile.am delete mode 100644 vpp-api-test/configure.ac delete mode 100755 vpp-api-test/scripts/vppctl delete mode 100644 vpp-api-test/vat/api_format.c delete mode 100644 vpp-api-test/vat/json_format.c delete mode 100644 vpp-api-test/vat/json_format.h delete mode 100644 vpp-api-test/vat/json_test.c delete mode 100644 vpp-api-test/vat/main.c delete mode 100644 vpp-api-test/vat/plugin.c delete mode 100644 vpp-api-test/vat/plugin.h delete mode 100644 vpp-api-test/vat/plugin_api.c delete mode 100644 vpp-api-test/vat/restart.c delete mode 100644 vpp-api-test/vat/vat.h delete mode 100644 vpp-api/python/Makefile.am delete mode 100644 vpp-api/python/README.rst delete mode 100644 vpp-api/python/pneum/pneum.c delete mode 100644 vpp-api/python/pneum/pneum.h delete mode 100644 vpp-api/python/pneum/test_pneum.c delete mode 100644 vpp-api/python/setup.cfg delete mode 100644 vpp-api/python/setup.py delete mode 100755 vpp-api/python/tests/test_cli.py delete mode 100755 vpp-api/python/tests/test_modules.py delete mode 100755 vpp-api/python/tests/test_papi.py delete mode 100755 vpp-api/python/tests/test_version.py delete mode 100755 vpp-api/python/tests/test_vpp_papi2.py delete mode 100644 vpp-api/python/vpp_papi/__init__.py delete mode 100644 vpp-api/python/vpp_papi/pneum_wrap.c delete mode 100644 vpp-api/python/vpp_papi/vpp_papi.py delete mode 100644 vpp/Makefile.am delete mode 100644 vpp/app/l2t.c delete mode 100644 vpp/app/l2t_l2.c delete mode 100644 vpp/app/sticky_hash.c delete mode 100644 vpp/app/version.c delete mode 100644 vpp/app/vpe_cli.c delete mode 100644 vpp/conf/80-vpp.conf delete mode 100644 vpp/conf/startup.conf delete mode 100644 vpp/conf/startup.uiopcigeneric.conf delete mode 100644 vpp/configure.ac delete mode 100644 vpp/oam/oam.c delete mode 100644 vpp/oam/oam.h delete mode 100644 vpp/stats/stats.c delete mode 100644 vpp/stats/stats.h delete mode 120000 vpp/suffix-rules.mk delete mode 100644 vpp/vnet/main.c delete mode 100644 vpp/vpp-api/api.c delete mode 120000 vpp/vpp-api/api_format.c delete mode 100644 vpp/vpp-api/api_main.c delete mode 100644 vpp/vpp-api/custom_dump.c delete mode 100644 vpp/vpp-api/gmon.c delete mode 100644 vpp/vpp-api/json_format.c delete mode 100644 vpp/vpp-api/json_format.h delete mode 100644 vpp/vpp-api/summary_stats_client.c delete mode 100644 vpp/vpp-api/test_client.c delete mode 100644 vpp/vpp-api/test_ha.c delete mode 120000 vpp/vpp-api/vat.h delete mode 100644 vpp/vpp-api/vpe.api delete mode 100644 vpp/vpp-api/vpe_all_api_h.h delete mode 100644 vpp/vpp-api/vpe_msg_enum.h delete mode 100644 vpp/vpp-api/vpp_get_metrics.c delete mode 100644 vppapigen/Makefile.am delete mode 100644 vppapigen/configure.ac delete mode 100644 vppapigen/gram.y delete mode 100644 vppapigen/lex.c delete mode 100644 vppapigen/lex.h delete mode 100644 vppapigen/node.c delete mode 100644 vppapigen/node.h delete mode 100644 vppinfra/.gitignore delete mode 100644 vppinfra/INSTALL delete mode 100644 vppinfra/Make.defs delete mode 100644 vppinfra/Makefile.am delete mode 100644 vppinfra/README delete mode 100644 vppinfra/configure.ac delete mode 100644 vppinfra/dir.dox delete mode 100755 vppinfra/mkinstalldirs delete mode 100644 vppinfra/tools/dir.dox delete mode 100644 vppinfra/tools/elftool.c delete mode 100644 vppinfra/unix_error.def delete mode 100644 vppinfra/vppinfra/anneal.c delete mode 100644 vppinfra/vppinfra/anneal.h delete mode 100644 vppinfra/vppinfra/asm_mips.h delete mode 100644 vppinfra/vppinfra/asm_x86.c delete mode 100644 vppinfra/vppinfra/asm_x86.h delete mode 100644 vppinfra/vppinfra/backtrace.c delete mode 100644 vppinfra/vppinfra/bihash_24_8.h delete mode 100644 vppinfra/vppinfra/bihash_8_8.h delete mode 100644 vppinfra/vppinfra/bihash_doc.h delete mode 100644 vppinfra/vppinfra/bihash_template.c delete mode 100644 vppinfra/vppinfra/bihash_template.h delete mode 100644 vppinfra/vppinfra/bitmap.h delete mode 100644 vppinfra/vppinfra/bitops.h delete mode 100644 vppinfra/vppinfra/byte_order.h delete mode 100644 vppinfra/vppinfra/cache.h delete mode 100644 vppinfra/vppinfra/clib.h delete mode 100644 vppinfra/vppinfra/cpu.c delete mode 100644 vppinfra/vppinfra/cpu.h delete mode 100644 vppinfra/vppinfra/dir.dox delete mode 100644 vppinfra/vppinfra/dlist.h delete mode 100644 vppinfra/vppinfra/elf.c delete mode 100644 vppinfra/vppinfra/elf.h delete mode 100644 vppinfra/vppinfra/elf_clib.c delete mode 100644 vppinfra/vppinfra/elf_clib.h delete mode 100644 vppinfra/vppinfra/elog.c delete mode 100644 vppinfra/vppinfra/elog.h delete mode 100644 vppinfra/vppinfra/error.c delete mode 100644 vppinfra/vppinfra/error.h delete mode 100644 vppinfra/vppinfra/error_bootstrap.h delete mode 100644 vppinfra/vppinfra/fheap.c delete mode 100644 vppinfra/vppinfra/fheap.h delete mode 100644 vppinfra/vppinfra/fifo.c delete mode 100644 vppinfra/vppinfra/fifo.h delete mode 100644 vppinfra/vppinfra/format.c delete mode 100644 vppinfra/vppinfra/format.h delete mode 100644 vppinfra/vppinfra/graph.c delete mode 100644 vppinfra/vppinfra/graph.h delete mode 100644 vppinfra/vppinfra/hash.c delete mode 100644 vppinfra/vppinfra/hash.h delete mode 100644 vppinfra/vppinfra/heap.c delete mode 100644 vppinfra/vppinfra/heap.h delete mode 100644 vppinfra/vppinfra/longjmp.S delete mode 100644 vppinfra/vppinfra/longjmp.h delete mode 100644 vppinfra/vppinfra/macros.c delete mode 100644 vppinfra/vppinfra/macros.h delete mode 100644 vppinfra/vppinfra/math.h delete mode 100644 vppinfra/vppinfra/md5.c delete mode 100644 vppinfra/vppinfra/md5.h delete mode 100644 vppinfra/vppinfra/mem.h delete mode 100644 vppinfra/vppinfra/mem_mheap.c delete mode 100644 vppinfra/vppinfra/memcheck.h delete mode 100644 vppinfra/vppinfra/memcpy_avx.h delete mode 100644 vppinfra/vppinfra/memcpy_sse3.h delete mode 100644 vppinfra/vppinfra/mhash.c delete mode 100644 vppinfra/vppinfra/mhash.h delete mode 100644 vppinfra/vppinfra/mheap.c delete mode 100644 vppinfra/vppinfra/mheap.h delete mode 100644 vppinfra/vppinfra/mheap_bootstrap.h delete mode 100644 vppinfra/vppinfra/mod_test_hash.c delete mode 100644 vppinfra/vppinfra/os.h delete mode 100644 vppinfra/vppinfra/pfhash.c delete mode 100644 vppinfra/vppinfra/pfhash.h delete mode 100644 vppinfra/vppinfra/phash.c delete mode 100644 vppinfra/vppinfra/phash.h delete mode 100644 vppinfra/vppinfra/pipeline.h delete mode 100644 vppinfra/vppinfra/pool.h delete mode 100644 vppinfra/vppinfra/ptclosure.c delete mode 100644 vppinfra/vppinfra/ptclosure.h delete mode 100644 vppinfra/vppinfra/qhash.c delete mode 100644 vppinfra/vppinfra/qhash.h delete mode 100644 vppinfra/vppinfra/qsort.c delete mode 100644 vppinfra/vppinfra/random.c delete mode 100644 vppinfra/vppinfra/random.h delete mode 100644 vppinfra/vppinfra/random_buffer.c delete mode 100644 vppinfra/vppinfra/random_buffer.h delete mode 100644 vppinfra/vppinfra/random_isaac.c delete mode 100644 vppinfra/vppinfra/random_isaac.h delete mode 100644 vppinfra/vppinfra/serialize.c delete mode 100644 vppinfra/vppinfra/serialize.h delete mode 100644 vppinfra/vppinfra/slist.c delete mode 100644 vppinfra/vppinfra/slist.h delete mode 100644 vppinfra/vppinfra/smp.c delete mode 100644 vppinfra/vppinfra/smp.h delete mode 100644 vppinfra/vppinfra/smp_fifo.c delete mode 100644 vppinfra/vppinfra/smp_fifo.h delete mode 100644 vppinfra/vppinfra/socket.c delete mode 100644 vppinfra/vppinfra/socket.h delete mode 100644 vppinfra/vppinfra/sparse_vec.h delete mode 100644 vppinfra/vppinfra/std-formats.c delete mode 100644 vppinfra/vppinfra/string.c delete mode 100644 vppinfra/vppinfra/string.h delete mode 100644 vppinfra/vppinfra/test_bihash_template.c delete mode 100644 vppinfra/vppinfra/test_dlist.c delete mode 100644 vppinfra/vppinfra/test_elf.c delete mode 100644 vppinfra/vppinfra/test_elog.c delete mode 100644 vppinfra/vppinfra/test_fifo.c delete mode 100644 vppinfra/vppinfra/test_format.c delete mode 100644 vppinfra/vppinfra/test_hash.c delete mode 100644 vppinfra/vppinfra/test_heap.c delete mode 100644 vppinfra/vppinfra/test_longjmp.c delete mode 100644 vppinfra/vppinfra/test_macros.c delete mode 100644 vppinfra/vppinfra/test_md5.c delete mode 100644 vppinfra/vppinfra/test_mheap.c delete mode 100644 vppinfra/vppinfra/test_pfhash.c delete mode 100644 vppinfra/vppinfra/test_phash.c delete mode 100644 vppinfra/vppinfra/test_pool.c delete mode 100644 vppinfra/vppinfra/test_pool_iterate.c delete mode 100644 vppinfra/vppinfra/test_ptclosure.c delete mode 100644 vppinfra/vppinfra/test_qhash.c delete mode 100644 vppinfra/vppinfra/test_random.c delete mode 100644 vppinfra/vppinfra/test_random_isaac.c delete mode 100644 vppinfra/vppinfra/test_serialize.c delete mode 100644 vppinfra/vppinfra/test_slist.c delete mode 100644 vppinfra/vppinfra/test_socket.c delete mode 100644 vppinfra/vppinfra/test_time.c delete mode 100644 vppinfra/vppinfra/test_timing_wheel.c delete mode 100644 vppinfra/vppinfra/test_vec.c delete mode 100644 vppinfra/vppinfra/test_vec.h delete mode 100644 vppinfra/vppinfra/test_vhash.c delete mode 100644 vppinfra/vppinfra/test_zvec.c delete mode 100644 vppinfra/vppinfra/time.c delete mode 100644 vppinfra/vppinfra/time.h delete mode 100644 vppinfra/vppinfra/timer.c delete mode 100644 vppinfra/vppinfra/timer.h delete mode 100644 vppinfra/vppinfra/timing_wheel.c delete mode 100644 vppinfra/vppinfra/timing_wheel.h delete mode 100644 vppinfra/vppinfra/types.h delete mode 100644 vppinfra/vppinfra/unformat.c delete mode 100644 vppinfra/vppinfra/unix-formats.c delete mode 100644 vppinfra/vppinfra/unix-kelog.c delete mode 100644 vppinfra/vppinfra/unix-misc.c delete mode 100644 vppinfra/vppinfra/unix.h delete mode 100644 vppinfra/vppinfra/valgrind.h delete mode 100644 vppinfra/vppinfra/vec.c delete mode 100644 vppinfra/vppinfra/vec.h delete mode 100644 vppinfra/vppinfra/vec_bootstrap.h delete mode 100644 vppinfra/vppinfra/vector.c delete mode 100644 vppinfra/vppinfra/vector.h delete mode 100644 vppinfra/vppinfra/vector_altivec.h delete mode 100644 vppinfra/vppinfra/vector_funcs.h delete mode 100644 vppinfra/vppinfra/vector_iwmmxt.h delete mode 100644 vppinfra/vppinfra/vector_neon.h delete mode 100644 vppinfra/vppinfra/vector_sse2.h delete mode 100644 vppinfra/vppinfra/vhash.c delete mode 100644 vppinfra/vppinfra/vhash.h delete mode 100644 vppinfra/vppinfra/vm_linux_kernel.h delete mode 100644 vppinfra/vppinfra/vm_standalone.h delete mode 100644 vppinfra/vppinfra/vm_unix.h delete mode 100644 vppinfra/vppinfra/xxhash.h delete mode 100644 vppinfra/vppinfra/xy.h delete mode 100644 vppinfra/vppinfra/zvec.c delete mode 100644 vppinfra/vppinfra/zvec.h (limited to 'build-data/platforms/vpp.mk') diff --git a/Makefile b/Makefile index 292b0d28..1b75779a 100644 --- a/Makefile +++ b/Makefile @@ -32,7 +32,7 @@ endif DEB_DEPENDS = curl build-essential autoconf automake bison libssl-dev ccache DEB_DEPENDS += debhelper dkms git libtool libganglia1-dev libapr1-dev dh-systemd -DEB_DEPENDS += libconfuse-dev git-review exuberant-ctags cscope +DEB_DEPENDS += libconfuse-dev git-review exuberant-ctags cscope pkg-config DEB_DEPENDS += python-dev python-virtualenv python-pip lcov chrpath autoconf ifeq ($(OS_VERSION_ID),14.04) DEB_DEPENDS += openjdk-8-jdk-headless @@ -147,7 +147,7 @@ else @ln -s /usr/bin/ccache $(BR)/tools/ccache-bin/gcc @ln -s /usr/bin/ccache $(BR)/tools/ccache-bin/g++ endif - @make -C $(BR) V=$(V) is_build_tool=yes vppapigen-install + @make -C $(BR) V=$(V) is_build_tool=yes tools-install @touch $@ bootstrap: $(BR)/.bootstrap.ok diff --git a/build-data/packages/cavium-dpdk.mk b/build-data/packages/cavium-dpdk.mk deleted file mode 100644 index ce8ee228..00000000 --- a/build-data/packages/cavium-dpdk.mk +++ /dev/null @@ -1,55 +0,0 @@ -# Temporary until Cavium upstreams their work - -cavium-dpdk_configure = \ - src_dir=$(call find_source_fn,$(PACKAGE_SOURCE)) ; \ - dst_dir=$(PACKAGE_BUILD_DIR) ; \ - tar -C $${src_dir} -cf - . | tar -C $${dst_dir} -xf - ; \ - cd $${dst_dir} ; \ - : colossal hemorrhoid to configure headroom ; \ - if [ x$($(PACKAGE)_configure_args_$(PLATFORM)) = "x" ] ; then \ - HR=256 ; \ - else \ - dpdk_configure_args=$($(PACKAGE)_configure_args_$(PLATFORM)) ; \ - if [ $$dpdk_configure_args = "--with-headroom=256" ] ; then \ - HR=256 ; \ - elif [ $$dpdk_configure_args = "--with-headroom=384" ] ; then \ - HR=384 ; \ - else \ - HR=256 ; \ - fi ; \ - fi ; \ - env HR=$$HR \ - spp -o \ - $(PACKAGE_BUILD_DIR)/config/common_linuxapp \ - $(PACKAGE_BUILD_DIR)/config/common_linuxapp.spp \ - ; \ - env $(CONFIGURE_ENV) \ - make config T=arm64-thunderx-linuxapp-gcc RTE_ARCH=arm64 \ - CC=aarch64-thunderx-linux-gnu-gcc V=0 \ - RTE_SDK=$(PACKAGE_BUILD_DIR) \ - RTE_TARGET=arm-default-linuxapp-gcc - -# Note: add e.g. "-O0" to EXTRA_CFLAGS if desired: EXTRA_CFLAGS='-g -O0' - -cavium-dpdk_make_args = install T=arm64-thunderx-linuxapp-gcc RTE_ARCH=arm64 \ - CC=aarch64-thunderx-linux-gnu-gcc V=0 \ - RTE_SDK=$(PACKAGE_BUILD_DIR) \ - RTE_TARGET=arm-default-linuxapp-gcc - -cavium-dpdk_install = \ - src_dir=$(PACKAGE_BUILD_DIR) ; \ - dst_dir=$(PACKAGE_INSTALL_DIR) ; \ - tar -h -C $${src_dir}/arm64-thunderx-linuxapp-gcc -cf - . \ - | tar -C $${dst_dir} -xf - - -# dpdk libraries end up in .../lib not .../lib64. Fix it. -cavium-dpdk_post_install = \ - if [ "$(arch_lib_dir)" != "lib" ] ; then \ - mkdir -p $(PACKAGE_INSTALL_DIR)/$(arch_lib_dir) ; \ - cd $(PACKAGE_INSTALL_DIR)/lib ; \ - tar cf - . | ( cd $(PACKAGE_INSTALL_DIR)/$(arch_lib_dir); tar xf - ) ; \ - fi - -# nothing to install, all static libraries -cavium-dpdk_image_include = echo - diff --git a/build-data/packages/g2.mk b/build-data/packages/g2.mk index 258eff1d..9b760e63 100644 --- a/build-data/packages/g2.mk +++ b/build-data/packages/g2.mk @@ -1,5 +1,3 @@ -g2_configure_depend = vppinfra-install +g2_source = src -g2_CPPFLAGS = $(call installed_includes_fn, vppinfra) - -g2_LDFLAGS = $(call installed_libs_fn, vppinfra) +g2_configure_args = --disable-vlib --disable-svm --enable-g2 diff --git a/build-data/packages/gmod.mk b/build-data/packages/gmod.mk index a6ba42d0..6fa7e0f1 100644 --- a/build-data/packages/gmod.mk +++ b/build-data/packages/gmod.mk @@ -1,9 +1,9 @@ -gmod_configure_depend = vppinfra-install svm-install +gmod_configure_depend = vpp-install gmod_configure_args = --libdir=$(PACKAGE_INSTALL_DIR)/$(arch_lib_dir)/ganglia -gmod_CPPFLAGS = $(call installed_includes_fn, vppinfra svm) +gmod_CPPFLAGS = $(call installed_includes_fn, vpp) gmod_CPPFLAGS += -I/usr/include/apr-1.0 -I/usr/include/apr-1 -I/usr/include -gmod_LDFLAGS = $(call installed_libs_fn, vppinfra svm) +gmod_LDFLAGS = $(call installed_libs_fn, vpp) gmod_image_include = echo $(arch_lib_dir)/ganglia/libgmodvpp.so etc diff --git a/build-data/packages/perftool.mk b/build-data/packages/perftool.mk index 300f902b..e582c316 100644 --- a/build-data/packages/perftool.mk +++ b/build-data/packages/perftool.mk @@ -1,5 +1,4 @@ -perftool_configure_depend = vppinfra-install +perftool_source = src -perftool_CPPFLAGS = $(call installed_includes_fn, vppinfra) +perftool_configure_args = --disable-vlib --disable-svm --enable-perftool -perftool_LDFLAGS = $(call installed_libs_fn, vppinfra) diff --git a/build-data/packages/plugins.mk b/build-data/packages/plugins.mk index 44a8e2bd..b4d67a28 100644 --- a/build-data/packages/plugins.mk +++ b/build-data/packages/plugins.mk @@ -1,24 +1,13 @@ plugins_configure_depend = \ - vppinfra-install \ - vlib-api-install \ - vpp-api-test-install \ - vnet-install \ - vlib-install \ - vpp-api-install + vpp-api-install \ + vpp-install -plugins_CPPFLAGS = $(call installed_includes_fn, \ - vppinfra \ - vlib \ - vnet \ - svm \ - vpp-api-test \ - vlib-api \ - vpp-api) +plugins_CPPFLAGS = $(call installed_includes_fn, \ + vpp \ + vpp-api) -plugins_LDFLAGS = $(call installed_libs_fn, \ - vppinfra \ - vlib \ - vlib-api) +plugins_LDFLAGS = $(call installed_libs_fn, \ + vpp) ifeq ($($(PLATFORM)_enable_tests),yes) plugins_configure_args += --enable-tests diff --git a/build-data/packages/src.mk b/build-data/packages/src.mk new file mode 100644 index 00000000..e69de29b diff --git a/build-data/packages/svm.mk b/build-data/packages/svm.mk deleted file mode 100644 index 3971fe82..00000000 --- a/build-data/packages/svm.mk +++ /dev/null @@ -1,5 +0,0 @@ -svm_top_srcdir = $(call find_source_fn,svm) -svm_configure_depend = vppinfra-install - -svm_CPPFLAGS = $(call installed_includes_fn, vppinfra) -svm_LDFLAGS = $(call installed_libs_fn, vppinfra) diff --git a/build-data/packages/vlib-api-cavium-dpdk.mk b/build-data/packages/vlib-api-cavium-dpdk.mk deleted file mode 100644 index 7a4fe2cd..00000000 --- a/build-data/packages/vlib-api-cavium-dpdk.mk +++ /dev/null @@ -1,6 +0,0 @@ -vlib-api-cavium-dpdk_source = vlib-api - -vlib-api-cavium-dpdk_configure_depend = vppinfra-install svm-install vlib-cavium-dpdk-install - -vlib-api-cavium-dpdk_CPPFLAGS = $(call installed_includes_fn, vppinfra svm vlib-cavium-dpdk) -vlib-api-cavium-dpdk_LDFLAGS = $(call installed_libs_fn, vppinfra svm vlib-cavium-dpdk) diff --git a/build-data/packages/vlib-api.mk b/build-data/packages/vlib-api.mk deleted file mode 100644 index 29b0d17d..00000000 --- a/build-data/packages/vlib-api.mk +++ /dev/null @@ -1,4 +0,0 @@ -vlib-api_configure_depend = vppinfra-install svm-install vlib-install - -vlib-api_CPPFLAGS = $(call installed_includes_fn, vppinfra svm vlib) -vlib-api_LDFLAGS = $(call installed_libs_fn, vppinfra svm vlib) diff --git a/build-data/packages/vlib-cavium-dpdk.mk b/build-data/packages/vlib-cavium-dpdk.mk deleted file mode 100644 index 0f2f132d..00000000 --- a/build-data/packages/vlib-cavium-dpdk.mk +++ /dev/null @@ -1,7 +0,0 @@ -vlib-cavium-dpdk_source = vlib -vlib-cavium-dpdk_configure_depend = vppinfra-install cavium-dpdk-install - -vlib-cavium-dpdk_configure_args += --with-dpdk - -vlib-cavium-dpdk_CPPFLAGS = $(call installed_includes_fn, vppinfra cavium-dpdk) -vlib-cavium-dpdk_LDFLAGS = $(call installed_libs_fn, vppinfra cavium-dpdk) diff --git a/build-data/packages/vlib.mk b/build-data/packages/vlib.mk deleted file mode 100644 index 2172708d..00000000 --- a/build-data/packages/vlib.mk +++ /dev/null @@ -1,16 +0,0 @@ -vlib_configure_depend = vppinfra-install - -vlib_CPPFLAGS = $(call installed_includes_fn, vppinfra) -vlib_LDFLAGS = $(call installed_libs_fn, vppinfra) - -ifneq ($($(PLATFORM)_uses_dpdk),no) -vlib_configure_args += --with-dpdk -ifeq ($($(PLATFORM)_uses_external_dpdk),yes) -vlib_CPPFLAGS += -I$($(PLATFORM)_dpdk_inc_dir) -vlib_LDFLAGS += -L$($(PLATFORM)_dpdk_lib_dir) -else -vlib_configure_depend += dpdk-install -vlib_CPPFLAGS += $(call installed_includes_fn, dpdk) -vlib_LDFLAGS += $(call installed_libs_fn, dpdk) -endif -endif diff --git a/build-data/packages/vnet-cavium-dpdk.mk b/build-data/packages/vnet-cavium-dpdk.mk deleted file mode 100644 index 4c35b04d..00000000 --- a/build-data/packages/vnet-cavium-dpdk.mk +++ /dev/null @@ -1,29 +0,0 @@ -vnet-cavium-dpdk_source = vnet - -vnet-cavium-dpdk_configure_depend = \ - vppinfra-install \ - cavium-dpdk-install \ - svm-install \ - vlib-api-cavium-dpdk-install \ - vlib-cavium-dpdk-install - - -vnet-cavium-dpdk_CPPFLAGS = $(call installed_includes_fn, \ - vppinfra \ - cavium-dpdk \ - openssl \ - svm \ - vlib-cavium-dpdk \ - vlib-api-cavium-dpdk) - -vnet-cavium-dpdk_LDFLAGS = $(call installed_libs_fn, \ - vppinfra \ - cavium-dpdk \ - openssl \ - svm \ - vlib-cavium-dpdk \ - vlib-api-cavium-dpdk) - -# Platform dependent configure flags -vnet-cavium-dpdk_configure_args += $(vnet-cavium-dpdk_configure_args_$(PLATFORM)) - diff --git a/build-data/packages/vpp-api-test-cavium-dpdk.mk b/build-data/packages/vpp-api-test-cavium-dpdk.mk deleted file mode 100644 index e352317f..00000000 --- a/build-data/packages/vpp-api-test-cavium-dpdk.mk +++ /dev/null @@ -1,32 +0,0 @@ -vpp-api-test-cavium-dpdk_source = vpp-api-test - -vpp-api-test-cavium-dpdk_configure_depend = \ - vppinfra-install \ - cavium-dpdk-install \ - svm-install \ - vlib-api-cavium-dpdk-install \ - vlib-cavium-dpdk-install \ - vnet-cavium-dpdk-install \ - vpp-cavium-dpdk-install - -# -vpp-api-test-cavium-dpdk_configure_args = --with-dpdk - -vpp-api-test-cavium-dpdk_CPPFLAGS = $(call installed_includes_fn, \ - vppinfra \ - cavium-dpdk \ - svm \ - vlib-cavium-dpdk \ - vlib-api-cavium-dpdk \ - vnet-cavium-dpdk \ - vpp-cavium-dpdk) - -vpp-api-test-cavium-dpdk_LDFLAGS = $(call installed_libs_fn, \ - vppinfra \ - cavium-dpdk \ - svm \ - vlib-cavium-dpdk \ - vlib-api-cavium-dpdk \ - vnet-cavium-dpdk \ - vpp-cavium-dpdk) - diff --git a/build-data/packages/vpp-api-test.mk b/build-data/packages/vpp-api-test.mk deleted file mode 100644 index c9eae367..00000000 --- a/build-data/packages/vpp-api-test.mk +++ /dev/null @@ -1,39 +0,0 @@ -vpp-api-test_configure_depend = \ - vppinfra-install \ - svm-install \ - vlib-api-install \ - vlib-install \ - vnet-install \ - vpp-install - -vpp-api-test_CPPFLAGS = $(call installed_includes_fn, \ - vppinfra \ - svm \ - vlib \ - vlib-api \ - vnet \ - vpp) - -vpp-api-test_LDFLAGS = $(call installed_libs_fn, \ - vppinfra \ - svm \ - vlib \ - vlib-api \ - vnet \ - vpp) - -ifneq ($($(PLATFORM)_uses_dpdk),no) -vpp-api-test_configure_args = --with-dpdk -ifeq ($($(PLATFORM)_uses_external_dpdk),yes) -vpp-api-test_CPPFLAGS += -I$($(PLATFORM)_dpdk_inc_dir) -vpp-api-test_LDFLAGS += -L$($(PLATFORM)_dpdk_lib_dir) -else -vpp-api-test_configure_depend += dpdk-install -vpp-api-test_CPPFLAGS += $(call installed_includes_fn, dpdk) -vpp-api-test_LDFLAGS += $(call installed_libs_fn, dpdk) -endif -endif -ifeq ($($(PLATFORM)_uses_dpdk_cryptodev),yes) -vpp-api-test_configure_args += --with-dpdk-crypto -endif - diff --git a/build-data/packages/vpp-api.mk b/build-data/packages/vpp-api.mk index 4937023a..d9e8d72e 100644 --- a/build-data/packages/vpp-api.mk +++ b/build-data/packages/vpp-api.mk @@ -1,23 +1,9 @@ vpp-api_configure_depend = \ - vppinfra-install \ - svm-install \ - vlib-api-install \ - vlib-install \ - vnet-install \ vpp-install vpp-api_CPPFLAGS = $(call installed_includes_fn, \ - vppinfra \ - svm \ - vlib \ - vlib-api \ - vnet \ vpp) -vpp-api_LDFLAGS = $(call installed_libs_fn, \ - vppinfra \ - svm \ - vlib \ - vlib-api) +vpp-api_LDFLAGS = vpp-api_CPPFLAGS += -I/usr/lib/jvm/java-8-openjdk-amd64/include diff --git a/build-data/packages/vpp-cavium-dpdk.mk b/build-data/packages/vpp-cavium-dpdk.mk deleted file mode 100644 index 704e3a95..00000000 --- a/build-data/packages/vpp-cavium-dpdk.mk +++ /dev/null @@ -1,30 +0,0 @@ -vpp-cavium-dpdk_source = vpp - -vpp-cavium-dpdk_configure_depend = \ - vppinfra-install \ - cavium-dpdk-install \ - svm-install \ - vlib-api-cavium-dpdk-install \ - vlib-cavium-dpdk-install \ - vnet-cavium-dpdk-install - -# Platform dependent configure flags -vpp-cavium-dpdk_configure_args += $(vpp-cavium-dpdk_configure_args_$(PLATFORM)) - -vpp-cavium-dpdk_CPPFLAGS = $(call installed_includes_fn, \ - vppinfra \ - cavium-dpdk \ - openssl \ - svm \ - vlib-cavium-dpdk \ - vlib-api-cavium-dpdk \ - vnet-cavium-dpdk) - -vpp-cavium-dpdk_LDFLAGS = $(call installed_libs_fn, \ - vppinfra \ - cavium-dpdk \ - openssl \ - svm \ - vlib-cavium-dpdk \ - vlib-api-cavium-dpdk \ - vnet-cavium-dpdk) diff --git a/build-data/packages/vpp.mk b/build-data/packages/vpp.mk index a3d60528..fe68cd82 100644 --- a/build-data/packages/vpp.mk +++ b/build-data/packages/vpp.mk @@ -1,11 +1,5 @@ -vpp_configure_depend = \ - vppinfra-install \ - svm-install \ - vlib-api-install \ - vlib-install \ - vnet-install \ +vpp_source = src -# ifeq ($($(PLATFORM)_dpdk_shared_lib),yes) vpp_configure_args = --enable-dpdk-shared else @@ -16,25 +10,8 @@ endif vpp_configure_args += $(vpp_configure_args_$(PLATFORM)) -vpp_CPPFLAGS = $(call installed_includes_fn, \ - vppinfra \ - svm \ - vlib \ - vlib-api \ - vnet) - -vpp_LDFLAGS = $(call installed_libs_fn, \ - vppinfra \ - svm \ - vlib \ - vlib-api \ - vnet) - -# include & link with openssl only if needed -ifneq ($($(PLATFORM)_uses_openssl),no) -vpp_CPPFLAGS += $(call installed_includes_fn, openssl) -vpp_LDFLAGS += $(call installed_libs_fn, openssl) -endif +vpp_CPPFLAGS = +vpp_LDFLAGS = ifneq ($($(PLATFORM)_uses_dpdk),no) ifeq ($($(PLATFORM)_uses_external_dpdk),yes) diff --git a/build-data/packages/vppinfra.mk b/build-data/packages/vppinfra.mk deleted file mode 100644 index 6ca6eb24..00000000 --- a/build-data/packages/vppinfra.mk +++ /dev/null @@ -1,5 +0,0 @@ - -ifeq ($($(PLATFORM)_enable_tests),yes) -vppinfra_configure_args += --enable-tests -endif - diff --git a/build-data/platforms.mk b/build-data/platforms.mk index a568c7a0..88dd3ed8 100644 --- a/build-data/platforms.mk +++ b/build-data/platforms.mk @@ -60,15 +60,15 @@ install-deb: $(patsubst %,%-find-source,$(ROOT_PACKAGES)) deb/debian/vpp-dpdk-dev.install ; \ \ : bin package needs startup config ; \ - echo ../../vpp/conf/startup.conf /etc/vpp \ + echo ../../src/vpp/conf/startup.conf /etc/vpp \ >> deb/debian/vpp.install ; \ \ : and sysctl config ; \ - echo ../../vpp/conf/80-vpp.conf /etc/sysctl.d \ + echo ../../src/vpp/conf/80-vpp.conf /etc/sysctl.d \ >> deb/debian/vpp.install ; \ \ : dev package needs a couple of additions ; \ - echo ../build-tool-native/vppapigen/vppapigen /usr/bin \ + echo ../build-tool-native/tools/vppapigen /usr/bin \ >> deb/debian/vpp-dev.install ; \ echo ../../vpp-api/java/jvpp/gen/jvpp_gen.py /usr/bin \ >> deb/debian/vpp-dev.install ; \ diff --git a/build-data/platforms/vpp.mk b/build-data/platforms/vpp.mk index 97ddc57d..513a4db4 100644 --- a/build-data/platforms/vpp.mk +++ b/build-data/platforms/vpp.mk @@ -29,11 +29,9 @@ vpp_uses_dpdk = yes # Uncoment to enable building unit tests # vpp_enable_tests = yes -vpp_root_packages = vpp vlib vlib-api vnet svm vpp-api-test \ - vpp-api gmod plugins +vpp_root_packages = vpp vpp-api gmod plugins vpp_configure_args_vpp = --with-dpdk -vnet_configure_args_vpp = --with-dpdk # Set these parameters carefully. The vlib_buffer_t is 128 bytes, i.e. vlib_configure_args_vpp = --with-pre-data=128 diff --git a/build-data/platforms/vpp_lite.mk b/build-data/platforms/vpp_lite.mk index ef2ec444..55805d10 100644 --- a/build-data/platforms/vpp_lite.mk +++ b/build-data/platforms/vpp_lite.mk @@ -27,8 +27,7 @@ vpp_lite_uses_dpdk = no # Uncoment to enable building unit tests #vpp_lite_enable_tests = yes -vpp_lite_root_packages = vpp vlib vlib-api vnet svm vpp-api-test \ - vpp-api gmod +vpp_lite_root_packages = vpp vpp-api gmod vlib_configure_args_vpp_lite = --with-pre-data=128 diff --git a/build-data/suffix-rules.mk b/build-data/suffix-rules.mk deleted file mode 100644 index e3eeb922..00000000 --- a/build-data/suffix-rules.mk +++ /dev/null @@ -1,27 +0,0 @@ -# Copyright (c) 2016 Cisco and/or its affiliates. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at: -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# Shared suffix rules -# Please do not set "SUFFIXES = .api.h .api" here - -%.api.h: %.api - @echo " APIGEN " $@ ; \ - mkdir -p `dirname $@` ; \ - $(CC) $(CPPFLAGS) -E -P -C -x c $^ \ - | vppapigen --input - --output $@ --show-name $@ - -%.api.json: %.api - @echo " JSON APIGEN " $@ ; \ - mkdir -p `dirname $@` ; \ - $(CC) $(CPPFLAGS) -E -P -C -x c $^ \ - | vppapigen --input - --json $@ diff --git a/build-root/bootstrap.sh b/build-root/bootstrap.sh index f83734fd..2949c180 100755 --- a/build-root/bootstrap.sh +++ b/build-root/bootstrap.sh @@ -45,7 +45,7 @@ cd $wsroot cd $build_root echo Compile native tools -for tool in vppapigen +for tool in tools do make V=0 is_build_tool=yes $tool-install done diff --git a/build-root/packages/src.mk b/build-root/packages/src.mk new file mode 100644 index 00000000..db48ed58 --- /dev/null +++ b/build-root/packages/src.mk @@ -0,0 +1,4 @@ +# nothing + + + diff --git a/build-root/packages/tools.mk b/build-root/packages/tools.mk new file mode 100644 index 00000000..506e024b --- /dev/null +++ b/build-root/packages/tools.mk @@ -0,0 +1,3 @@ +tools_source = src +tools_configure_args = --disable-vlib + diff --git a/build-root/packages/vppapigen.mk b/build-root/packages/vppapigen.mk deleted file mode 100644 index 0d284631..00000000 --- a/build-root/packages/vppapigen.mk +++ /dev/null @@ -1,5 +0,0 @@ -vppapigen_configure_depend = vppinfra-install - -vppapigen_CPPFLAGS = $(call installed_includes_fn, vppinfra) - -vppapigen_LDFLAGS = $(call installed_libs_fn, vppinfra) diff --git a/build-root/rpm/vpp.spec b/build-root/rpm/vpp.spec index 194d205f..654424c0 100644 --- a/build-root/rpm/vpp.spec +++ b/build-root/rpm/vpp.spec @@ -97,12 +97,10 @@ groupadd -f -r vpp mkdir -p -m755 %{buildroot}%{_bindir} mkdir -p -m755 %{buildroot}%{_unitdir} install -p -m 755 %{_mu_build_dir}/%{_vpp_install_dir}/*/bin/* %{buildroot}%{_bindir} -install -p -m 755 %{_mu_build_dir}/%{_vpp_build_dir}/vppapigen/vppapigen %{buildroot}%{_bindir} +install -p -m 755 %{_mu_build_dir}/%{_vpp_build_dir}/tools/vppapigen %{buildroot}%{_bindir} -# core api +# api mkdir -p -m755 %{buildroot}/usr/share/vpp/api -install -p -m 644 %{_mu_build_dir}/%{_vpp_install_dir}/vpp/vpp-api/vpe.api.json %{buildroot}/usr/share/vpp/api -install -p -m 644 %{_mu_build_dir}/%{_vpp_install_dir}/vlib-api/vlibmemory/memclnt.api.json %{buildroot}/usr/share/vpp/api # # configs @@ -110,8 +108,8 @@ install -p -m 644 %{_mu_build_dir}/%{_vpp_install_dir}/vlib-api/vlibmemory/memcl mkdir -p -m755 %{buildroot}/etc/vpp mkdir -p -m755 %{buildroot}/etc/sysctl.d install -p -m 644 %{_mu_build_dir}/rpm/vpp.service %{buildroot}%{_unitdir} -install -p -m 644 %{_mu_build_dir}/../vpp/conf/startup.uiopcigeneric.conf %{buildroot}/etc/vpp/startup.conf -install -p -m 644 %{_mu_build_dir}/../vpp/conf/80-vpp.conf %{buildroot}/etc/sysctl.d +install -p -m 644 %{_mu_build_dir}/../src/vpp/conf/startup.uiopcigeneric.conf %{buildroot}/etc/vpp/startup.conf +install -p -m 644 %{_mu_build_dir}/../src/vpp/conf/80-vpp.conf %{buildroot}/etc/sysctl.d # # libraries # @@ -128,7 +126,7 @@ do ( cd %{buildroot}%{_libdir} && ln -fs $file $(echo $file | sed -e 's/\(\.so\)\.[0-9]\+.*/\1/') ) done -for file in $(find %{_mu_build_dir}/%{_vpp_install_dir}/vnet -type f -name '*.api.json' -print ) +for file in $(find %{_mu_build_dir}/%{_vpp_install_dir}/vpp/share/vpp/api -type f -name '*.api.json' -print ) do install -p -m 644 $file %{buildroot}/usr/share/vpp/api done @@ -178,12 +176,24 @@ do %{buildroot}/usr/lib/vpp_plugins/$file done +for file in $(cd %{_mu_build_dir}/%{_vpp_install_dir}/vpp/lib64/vpp_plugins && find -type f -print) +do + install -p -m 644 %{_mu_build_dir}/%{_vpp_install_dir}/vpp/lib64/vpp_plugins/$file \ + %{buildroot}/usr/lib/vpp_plugins/$file +done + for file in $(cd %{_mu_build_dir}/%{_vpp_install_dir}/plugins/lib64/vpp_api_test_plugins && find -type f -print) do install -p -m 644 %{_mu_build_dir}/%{_vpp_install_dir}/plugins/lib64/vpp_api_test_plugins/$file \ %{buildroot}/usr/lib/vpp_api_test_plugins/$file done +for file in $(cd %{_mu_build_dir}/%{_vpp_install_dir}/vpp/lib64/vpp_api_test_plugins && find -type f -print) +do + install -p -m 644 %{_mu_build_dir}/%{_vpp_install_dir}/vpp/lib64/vpp_api_test_plugins/$file \ + %{buildroot}/usr/lib/vpp_api_test_plugins/$file +done + for file in $(find %{_mu_build_dir}/%{_vpp_install_dir}/plugins -type f -name '*.api.json' -print ) do install -p -m 644 $file %{buildroot}/usr/share/vpp/api diff --git a/build-root/scripts/find-plugins-contents b/build-root/scripts/find-plugins-contents index a5a52acf..4108f790 100755 --- a/build-root/scripts/find-plugins-contents +++ b/build-root/scripts/find-plugins-contents @@ -2,14 +2,14 @@ rm -f $2 -for i in ${1}/plugins/lib64/vpp_plugins/*.so; do +for i in ${1}/{plugins,vpp}/lib64/vpp_plugins/*.so; do echo ../${i} /usr/lib/vpp_plugins >> ${2} done -for i in ${1}/plugins/lib64/vpp_api_test_plugins/*.so; do +for i in ${1}/{plugins,vpp}/lib64/vpp_api_test_plugins/*.so; do echo ../${i} /usr/lib/vpp_api_test_plugins >> ${2} done -for i in $(find ${1}/plugins -name *.api.json -type f -print); do +for i in $(find ${1}/plugins ${1}/vpp/share/vpp/api/plugins/ -name *.api.json -type f -print); do echo ../${i} /usr/share/vpp/api/ >> ${2} done diff --git a/build-root/scripts/find-python-api-contents b/build-root/scripts/find-python-api-contents index 9b390e75..24e8532c 100755 --- a/build-root/scripts/find-python-api-contents +++ b/build-root/scripts/find-python-api-contents @@ -2,7 +2,7 @@ rm -f $2 -for i in $(find ${1}/vpp-api/lib/python2.7/site-packages/ -type f -print); do +for i in $(find ${1}/{vpp,vpp-api}/lib/python2.7/site-packages/ -type f -print); do echo ../${i} /usr/lib/python2.7/site-packages/vpp_papi >> ${2} done diff --git a/g2/Makefile.am b/g2/Makefile.am deleted file mode 100644 index 8457c272..00000000 --- a/g2/Makefile.am +++ /dev/null @@ -1,34 +0,0 @@ -# Copyright (c) 2016 Cisco and/or its affiliates. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at: -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -AUTOMAKE_OPTIONS = foreign - -bin_PROGRAMS = g2 - -AM_CFLAGS = -Wall - -g2_SOURCES = \ - clib.c \ - cpel.c \ - cpel.h \ - events.c \ - g2.h \ - main.c \ - menu1.c \ - pointsel.c \ - props.c \ - props.h \ - g2version.c \ - view1.c - -g2_LDADD = $(g2_LIBS) -lvppinfra -lpthread -lm diff --git a/g2/clib.c b/g2/clib.c deleted file mode 100644 index d0cd6195..00000000 --- a/g2/clib.c +++ /dev/null @@ -1,154 +0,0 @@ -/* - *------------------------------------------------------------------ - * Copyright (c) 2009-2016 Cisco and/or its affiliates. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "cpel.h" -#include "g2.h" - -int widest_track_format; - -typedef struct bound_track_ { - u32 track; - u8 *track_str; -} bound_track_t; - -bound_track_t *bound_tracks; - -uword *the_evtdef_hash; /* (event-id, event-definition) hash */ -uword *the_trackdef_hash; /* (track-id, track-definition) hash */ - -elog_main_t elog_main; - -void *get_clib_event (unsigned int datum) -{ - elog_event_t *ep = vec_elt_at_index (elog_main.events, datum); - return (void *)ep; -} - -/* - * read_clib_file - */ -int read_clib_file(char *clib_file) -{ - static FILE *ofp; - clib_error_t *error = 0; - int i; - elog_main_t *em = &elog_main; - double starttime, delta; - - vec_free(em->events); - vec_free(em->event_types); - if (the_trackdef_hash) - hash_free(the_trackdef_hash); - - the_trackdef_hash = hash_create (0, sizeof (uword)); - - error = elog_read_file (&elog_main, clib_file); - - if (error) { - fformat(stderr, "%U", format_clib_error, error); - return (1); - } - - if (ofp == NULL) { - ofp = fdopen(2, "w"); - if (ofp == NULL) { - fprintf(stderr, "Couldn't fdopen(2)?\n"); - exit(1); - } - } - - em = &elog_main; - - for (i = 0; i < vec_len (em->tracks); i++) { - u32 track_code; - bound_track_t * btp; - elog_track_t * t; - uword * p; - int track_strlen; - - t = &em->tracks[i]; - track_code = i; - p = hash_get(the_trackdef_hash, track_code); - if (p) { - fprintf(ofp, "track %d redefined, retain first definition\n", - track_code); - continue; - } - vec_add2(bound_tracks, btp, 1); - btp->track = track_code; - btp->track_str = t->name; - hash_set(the_trackdef_hash, track_code, btp - bound_tracks); - - track_strlen = strlen((char *)btp->track_str); - if (track_strlen > widest_track_format) - widest_track_format = track_strlen; - } - - initialize_events(); - - for (i = 0; i < vec_len (em->event_types); i++) { - elog_event_type_t *ep; - u8 *tmp; - - ep = vec_elt_at_index(em->event_types, i); - tmp = (u8 *) vec_dup(ep->format); - vec_add1(tmp,0); - add_event_from_clib_file (ep->type_index_plus_one, (char *) tmp, i); - vec_free(tmp); - } - - finalize_events(); - - em->events = elog_get_events (em); - - cpel_event_init(vec_len(em->events)); - - starttime = em->events[0].time; - - for (i = 0; i < vec_len (em->events); i++) { - elog_event_t *ep; - - ep = vec_elt_at_index(em->events, i); - - delta = ep->time - starttime; - - add_clib_event (delta, ep->track, ep->type + 1, i); - } - - cpel_event_finalize(); - - set_pid_ax_width(8*widest_track_format); - - return(0); -} diff --git a/g2/configure.ac b/g2/configure.ac deleted file mode 100644 index c8af7747..00000000 --- a/g2/configure.ac +++ /dev/null @@ -1,12 +0,0 @@ -AC_INIT(g2, 3.0) -AM_INIT_AUTOMAKE -AM_SILENT_RULES([yes]) - -AC_CHECK_LIB([vppinfra], [clib_mem_get_page_size],, - AC_MSG_ERROR([Please install the vpp-lib package])) -AC_CHECK_HEADER([vppinfra/clib.h],, - AC_MSG_ERROR([Please install the vpp-dev package])) - -PKG_CHECK_MODULES(g2, gtk+-2.0) - -AC_OUTPUT([Makefile]) diff --git a/g2/cpel.c b/g2/cpel.c deleted file mode 100644 index 8bcc91e6..00000000 --- a/g2/cpel.c +++ /dev/null @@ -1,470 +0,0 @@ -/* - *------------------------------------------------------------------ - * Copyright (c) 2005-2016 Cisco and/or its affiliates. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "cpel.h" -#include "g2.h" - -typedef struct bound_event_ { - u32 event_code; - u8 *event_str; - u8 *datum_str; -} bound_event_t; - -bound_event_t *bound_events; - -int widest_track_format=8; - -typedef struct bound_track_ { - u32 track; - u8 *track_str; -} bound_track_t; - -bound_track_t *bound_tracks; - -uword *the_strtab_hash; /* (name, base-VA) hash of all string tables */ -uword *the_evtdef_hash; /* (event-id, event-definition) hash */ -uword *the_trackdef_hash; /* (track-id, track-definition) hash */ -u8 *event_strtab; /* event string-table */ - -void fatal(char *s) -{ - fprintf(stderr, "%s", s); - exit(1); -} - -typedef enum { - PASS1=1, - PASS2=2, -} pass_t; - -typedef struct { - int (*pass1)(cpel_section_header_t *, int, FILE *); - int (*pass2)(cpel_section_header_t *, int, FILE *); -} section_processor_t; - -int bad_section(cpel_section_header_t *sh, int verbose, FILE *ofp) -{ - fprintf(ofp, "Bad (type 0) section, skipped...\n"); - return(0); -} - -int noop_pass(cpel_section_header_t *sh, int verbose, FILE *ofp) -{ - return(0); -} - -int strtab_pass1(cpel_section_header_t *sh, int verbose, FILE *ofp) -{ - uword *p; - u8 *strtab_data_area = (u8 *)(sh+1); - - /* Multiple string tables with the same name are Bad... */ - p = hash_get_mem(the_strtab_hash, strtab_data_area); - if (p) { - fprintf(ofp, "Duplicate string table name %s", strtab_data_area); - } - /* - * Looks funny, but we really do want key = first string in the - * table, value = address(first string in the table) - */ - hash_set_mem(the_strtab_hash, strtab_data_area, strtab_data_area); - if (verbose) { - fprintf(ofp, "String Table %s\n", strtab_data_area); - } - return(0); -} - -int evtdef_pass1(cpel_section_header_t *sh, int verbose, FILE *ofp) -{ - int i, nevents; - event_definition_section_header_t *edh; - event_definition_t *ep; - u8 *this_strtab; - u32 event_code; - uword *p; - bound_event_t *bp; - - edh = (event_definition_section_header_t *)(sh+1); - nevents = ntohl(edh->number_of_event_definitions); - - if (verbose) { - fprintf(ofp, "Event Definition Section: %d definitions\n", - nevents); - } - - p = hash_get_mem(the_strtab_hash, edh->string_table_name); - if (!p) { - fprintf(ofp, "Fatal: couldn't find string table\n"); - return(1); - } - this_strtab = (u8 *)p[0]; - - initialize_events(); - - ep = (event_definition_t *)(edh+1); - - for (i = 0; i < nevents; i++) { - event_code = ntohl(ep->event); - p = hash_get(the_evtdef_hash, event_code); - if (p) { - fprintf(ofp, "Event %d redefined, retain first definition\n", - event_code); - continue; - } - vec_add2(bound_events, bp, 1); - bp->event_code = event_code; - bp->event_str = this_strtab + ntohl(ep->event_format); - bp->datum_str = this_strtab + ntohl(ep->datum_format); - hash_set(the_evtdef_hash, event_code, bp - bound_events); - - add_event_from_cpel_file(event_code, (char *) bp->event_str, - (char *)bp->datum_str); - - ep++; - } - - finalize_events(); - return (0); -} - -int trackdef_pass1(cpel_section_header_t *sh, int verbose, FILE *ofp) -{ - int i, nevents; - track_definition_section_header_t *tdh; - track_definition_t *tp; - u8 *this_strtab; - u32 track_code; - uword *p; - bound_track_t *btp; - int track_strlen; - - tdh = (track_definition_section_header_t *)(sh+1); - nevents = ntohl(tdh->number_of_track_definitions); - - if (verbose) { - fprintf(ofp, "Track Definition Section: %d definitions\n", - nevents); - } - - p = hash_get_mem(the_strtab_hash, tdh->string_table_name); - if (!p) { - fprintf(ofp, "Fatal: couldn't find string table\n"); - return(1); - } - this_strtab = (u8 *)p[0]; - - tp = (track_definition_t *)(tdh+1); - - for (i = 0; i < nevents; i++) { - track_code = ntohl(tp->track); - p = hash_get(the_trackdef_hash, track_code); - if (p) { - fprintf(ofp, "track %d redefined, retain first definition\n", - track_code); - continue; - } - vec_add2(bound_tracks, btp, 1); - btp->track = track_code; - btp->track_str = this_strtab + ntohl(tp->track_format); - hash_set(the_trackdef_hash, track_code, btp - bound_tracks); - - track_strlen = strlen((char *)btp->track_str); - if (track_strlen > widest_track_format) - widest_track_format = track_strlen; - tp++; - } - return (0); -} - -int unsupported_pass (cpel_section_header_t *sh, int verbose, FILE *ofp) -{ - if (verbose) { - fprintf(ofp, "Unsupported type %d section\n", - ntohl(sh->section_type)); - } - return(0); -} - -int event_pass2(cpel_section_header_t *sh, int verbose, FILE *ofp) -{ - event_section_header_t *eh; - u32 event_code, track_code, datum; - u64 starttime = ~0ULL; - int nevents; - int i; - event_entry_t *ep; - u64 now; - u64 delta; - u32 time0, time1; - double d; - uword *p; - - eh = (event_section_header_t *)(sh+1); - nevents = ntohl(eh->number_of_events); - ticks_per_ns = ntohl(eh->clock_ticks_per_second)/1e9; - ep = (event_entry_t *)(eh+1); - - p = hash_get_mem(the_strtab_hash, eh->string_table_name); - if (!p) { - fprintf(ofp, "Fatal: couldn't find string table\n"); - return(1); - } - event_strtab = (u8 *)p[0]; - - cpel_event_init(nevents); - - for (i = 0; i < nevents; i++) { - time0 = ntohl (ep->time[0]); - time1 = ntohl (ep->time[1]); - - now = (((u64) time0)<<32) | time1; - - /* Convert from bus ticks to usec */ - d = now; - d /= ticks_per_ns; - - now = d; - - if (starttime == ~0ULL) - starttime = now; - - delta = now - starttime; - - /* Delta = time since first event, in usec */ - event_code = ntohl(ep->event_code); - track_code = ntohl(ep->track); - datum = ntohl(ep->event_datum); - - add_cpel_event(delta, track_code, event_code, datum); - - ep++; - } - cpel_event_finalize(); - return(0); -} - -char *strtab_ref(unsigned long datum) -{ - return ((char *)(event_strtab + datum)); -} - -/* - * Note: If necessary, add passes / columns to this table to - * handle section order dependencies. - */ - -section_processor_t processors[CPEL_NUM_SECTION_TYPES+1] = -{ - {bad_section, noop_pass}, /* type 0 -- f**ked */ - {strtab_pass1, noop_pass}, /* type 1 -- STRTAB */ - {unsupported_pass, noop_pass}, /* type 2 -- SYMTAB */ - {evtdef_pass1, noop_pass}, /* type 3 -- EVTDEF */ - {trackdef_pass1, noop_pass}, /* type 4 -- TRACKDEF */ - {noop_pass, event_pass2}, /* type 5 -- EVENTS */ -}; - - -int process_section(cpel_section_header_t *sh, int verbose, FILE *ofp, - pass_t pass) -{ - u32 type; - type = ntohl(sh->section_type); - int rv; - int (*fp)(cpel_section_header_t *, int, FILE *); - - if (type > CPEL_NUM_SECTION_TYPES) { - fprintf(stderr, "Unknown section type %d\n", type); - return(1); - } - switch(pass) { - case PASS1: - fp = processors[type].pass1; - break; - - case PASS2: - fp = processors[type].pass2; - break; - - default: - fprintf(stderr, "Unknown pass %d\n", pass); - return(1); - } - - rv = (*fp)(sh, verbose, ofp); - - return(rv); -} - -int cpel_dump_file_header(cpel_file_header_t *fh, int verbose, FILE *ofp) -{ - time_t file_time; - - if (verbose) { - fprintf(ofp, "CPEL file: %s-endian, version %d\n", - ((fh->endian_version & CPEL_FILE_LITTLE_ENDIAN) ? - "little" : "big"), - fh->endian_version & CPEL_FILE_VERSION_MASK); - - file_time = ntohl(fh->file_date); - - fprintf(ofp, "File created %s", ctime(&file_time)); - } - - return(0); -} - - -int cpel_process(u8 *cpel, int verbose, FILE *ofp) -{ - cpel_file_header_t *fh; - cpel_section_header_t *sh; - u16 nsections; - u32 section_size; - int i; - - /* First, the file header */ - fh = (cpel_file_header_t *)cpel; - if (fh->endian_version != CPEL_FILE_VERSION) { - if (fh->endian_version & CPEL_FILE_LITTLE_ENDIAN) { - fprintf(stderr, "Little endian data format not supported\n"); - return(1); - } - fprintf(stderr, "Unsupported file version 0x%x\n", - fh->endian_version); - return(1); - } - cpel_dump_file_header(fh, verbose, ofp); - nsections = ntohs(fh->nsections); - - /* - * Take two passes through the file. PASS1 builds - * data structures, PASS2 actually dumps the file. - * Just in case the sections are in an unobvious order. - */ - sh = (cpel_section_header_t *)(fh+1); - for (i = 0; i < nsections; i++) { - section_size = ntohl(sh->data_length); - - if(verbose) { - fprintf(ofp, "Section type %d, size %d\n", ntohl(sh->section_type), - section_size); - } - - if(process_section(sh, verbose, ofp, PASS1)) - return(1); - - sh++; - sh = (cpel_section_header_t *)(((u8 *)sh)+section_size); - } - - sh = (cpel_section_header_t *)(fh+1); - for (i = 0; i < nsections; i++) { - if(process_section(sh, verbose, ofp, PASS2)) - return(1); - section_size = ntohl(sh->data_length); - sh++; - sh = (cpel_section_header_t *)(((u8 *)sh)+section_size); - } - - - return(0); -} - -/* - * read_cpel_file - */ -int read_cpel_file(char *cpel_file) -{ - int verbose = 0; - int rv; - static u8 *cpel; - static unsigned long size; - static FILE *ofp; - - if (cpel) { - unmapfile((char *)cpel, size); - hash_free(the_strtab_hash); - the_strtab_hash = 0; - hash_free(the_evtdef_hash); - the_evtdef_hash = 0; - hash_free(the_trackdef_hash); - the_trackdef_hash = 0; - } - - cpel = (u8 *)mapfile((char *)cpel_file, &size); - if (cpel == 0) { - fprintf(stderr, "Couldn't map %s...\n", cpel_file); - exit(1); - } - - if (ofp == NULL) { - ofp = fdopen(2, "w"); - if (ofp == NULL) { - fprintf(stderr, "Couldn't fdopen(2)?\n"); - exit(1); - } - } - - the_strtab_hash = hash_create_string (0, sizeof (uword)); - the_evtdef_hash = hash_create (0, sizeof (uword)); - the_trackdef_hash = hash_create (0, sizeof (uword)); - - rv = cpel_process(cpel, verbose, ofp); - - set_pid_ax_width(8*widest_track_format); - - return(rv); -} - -static bound_track_t generic_hex_track = {0, (u8 *) "0x%08x"}; -static bound_track_t generic_decimal_track = {0, (u8 *) "%8ld"}; - -/* - * get_track_label - */ -char *get_track_label(unsigned long track) -{ - uword *p; - bound_track_t *tp; - - p = hash_get(the_trackdef_hash, track); - if (p) { - tp = &bound_tracks[p[0]]; - } else { - if (track > 65535) - tp = &generic_hex_track; - else - tp = &generic_decimal_track; - } - return((char *)tp->track_str); -} diff --git a/g2/cpel.h b/g2/cpel.h deleted file mode 100644 index 73e4aea5..00000000 --- a/g2/cpel.h +++ /dev/null @@ -1,83 +0,0 @@ -/* - *------------------------------------------------------------------ - * Copyright (c) 2005-2016 Cisco and/or its affiliates. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef _CPEL_H_ -#define _CPEL_H_ 1 - -typedef struct cpel_file_header_ { - unsigned char endian_version; - unsigned char pad; - unsigned short nsections; - unsigned file_date; -} cpel_file_header_t; - -#define CPEL_FILE_LITTLE_ENDIAN 0x80 -#define CPEL_FILE_VERSION 0x01 -#define CPEL_FILE_VERSION_MASK 0x7F - -typedef struct cpel_section_header_ { - unsigned int section_type; - unsigned int data_length; /* does NOT include type and itself */ -} cpel_section_header_t; - -#define CPEL_SECTION_STRTAB 1 -/* string at offset 0 is the name of the table */ - -#define CPEL_SECTION_SYMTAB 2 -#define CPEL_SECTION_EVTDEF 3 - -typedef struct event_definition_section_header_ { - char string_table_name[64]; - unsigned int number_of_event_definitions; -} event_definition_section_header_t; - -typedef struct event_definition_ { - unsigned int event; - unsigned int event_format; - unsigned int datum_format; -} event_definition_t; - -#define CPEL_SECTION_TRACKDEF 4 - -typedef struct track_definition_section_header_ { - char string_table_name[64]; - unsigned int number_of_track_definitions; -} track_definition_section_header_t; - -typedef struct track_definition_ { - unsigned int track; - unsigned int track_format; -} track_definition_t; - -#define CPEL_SECTION_EVENT 5 - -typedef struct event_section_header_ { - char string_table_name[64]; - unsigned int number_of_events; - unsigned int clock_ticks_per_second; -} event_section_header_t; - -typedef struct event_entry_ { - unsigned int time[2]; - unsigned int track; - unsigned int event_code; - unsigned int event_datum; -} event_entry_t; - -#define CPEL_NUM_SECTION_TYPES 5 - -#endif /* _CPEL_H_ */ - diff --git a/g2/events.c b/g2/events.c deleted file mode 100644 index d4333bb0..00000000 --- a/g2/events.c +++ /dev/null @@ -1,475 +0,0 @@ -/* - *------------------------------------------------------------------ - * Copyright (c) 2005-2016 Cisco and/or its affiliates. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include "g2.h" -#include -#include -#include -#include - -/* - * globals - */ -boolean g_little_endian; -event_t *g_events; -ulong g_nevents; -pid_sort_t *g_pids; -pid_sort_t *g_original_pids; -int g_npids; -pid_data_t *g_pid_data_list; - -/* - * locals - */ -pid_data_t **s_pidhash; - -/* - * config parameters - */ - -double ticks_per_ns=1000.0; -boolean ticks_per_ns_set; - -/**************************************************************************** -* event_init -****************************************************************************/ - -void event_init(void) -{ - ulong endian; - char *ep; - char *askstr; - int tmp; - - ep = (char *)&endian; - endian = 0x12345678; - if (*ep != 0x12) - g_little_endian = TRUE; - else - g_little_endian = FALSE; - - askstr = getprop("dont_ask_ticks_per_ns_initially"); - - if (askstr && (*askstr == 't' || *askstr == 'T')) { - tmp = atol(getprop_default("ticks_per_ns", 0)); - if (tmp > 0) { - ticks_per_ns = tmp; - ticks_per_ns_set = TRUE; - } - } -} - -/**************************************************************************** -* find_or_add_pid -****************************************************************************/ - -pid_data_t *find_or_add_pid (ulong pid) -{ - pid_data_t *pp; - ulong bucket; - - bucket = pid % PIDHASH_NBUCKETS; - - pp = s_pidhash[bucket]; - - if (pp == 0) { - pp = g_malloc0(sizeof(pid_data_t)); - pp->pid_value = pid; - s_pidhash[bucket] = pp; - g_npids++; - return(pp); - } - while (pp) { - if (pp->pid_value == pid) - return(pp); - pp = pp->next; - } - - pp = g_malloc0(sizeof(pid_data_t)); - pp->pid_value = pid; - pp->next = s_pidhash[bucket]; - s_pidhash[bucket] = pp; - g_npids++; - return(pp); -} - -/**************************************************************************** -* pid_cmp -****************************************************************************/ - -int pid_cmp(const void *a1, const void *a2) -{ - pid_sort_t *p1 = (pid_sort_t *)a1; - pid_sort_t *p2 = (pid_sort_t *)a2; - - if (p1->pid_value < p2->pid_value) - return(-1); - else if (p1->pid_value == p2->pid_value) - return(0); - else - return(1); -} - -/**************************************************************************** -* make_sorted_pid_vector -****************************************************************************/ - -static void make_sorted_pid_vector(void) -{ - pid_data_t *pp; - pid_data_t **p_previous; - pid_sort_t *psp; - int i; - - psp = g_pids = g_malloc(sizeof(pid_sort_t)*g_npids); - - for (i = 0; i < PIDHASH_NBUCKETS; i++) { - pp = s_pidhash[i]; - while(pp) { - psp->pid = pp; - psp->pid_value = pp->pid_value; - psp++; - pp = pp->next; - } - } - - qsort(&g_pids[0], g_npids, sizeof(pid_sort_t), pid_cmp); - - /* put the sort order into the pid objects */ - psp = g_pids; - - /* - * This is rather gross. - * - * We happen to know that whenever this function is called, the hash table - * structure itself is immediately torn down. So the "next" pointers in the - * pid_data_t elements are about to become useless. - * - * So we re-use them, to link all the pid_data_t elements together into a - * single unified linked list, with g_pid_data_list pointing to the head. - * This means we can walk all the pid_data_t objects if we really want to. - * Reading snapshots from disk is one example. - * - * Alternatively we could just leave the hash table in place; this is - * far nicer, but as it happens, trading O(n) lookups for O(1) lookups - * isn't actually a problem for the restricted post-tear-down usage. So for - * now we take the memory savings and swap our hash table for a list. - */ - p_previous = &g_pid_data_list; - for (i = 0; i < g_npids; i++) { - pp = psp->pid; - pp->pid_index = i; - *p_previous = pp; - p_previous = &pp->next; - psp++; - } - *p_previous = NULL; - - /* - * Squirrel away original (sorted) vector, so we can - * toggle between "chase" mode, snapshots, and the original - * display method on short notice - */ - g_original_pids = g_malloc(sizeof(pid_sort_t)*g_npids); - memcpy (g_original_pids, g_pids, sizeof(pid_sort_t)*g_npids); -} - -/**************************************************************************** -* read_events -****************************************************************************/ - -void read_events(char *filename) -{ - ulong *ulp; - ulong size; - event_t *ep; - raw_event_t *rep; - ulonglong start_time=0ULL; - ulonglong low_time; - boolean once=TRUE; - int i; - char tmpbuf [128]; - - ulp = (ulong *)mapfile(filename, &size); - - if (ulp == NULL) { - sprintf(tmpbuf, "Couldn't open %s\n", filename); - infobox("Read Event Log Failure", tmpbuf); - return; - } - - g_nevents = ntohl(*ulp); - - if (size != (g_nevents*sizeof(raw_event_t) + sizeof(g_nevents))) { - sprintf(tmpbuf, "%s was damaged, or isn't an event log.\n", filename); - infobox("Bad Input File", tmpbuf); - g_nevents = 0; - unmapfile((char *)ulp, size); - return; - } - - rep = (raw_event_t *)(ulp+1); - - if (g_events) - g_free(g_events); - - g_events = (event_t *)g_malloc(g_nevents * sizeof(event_t)); - ep = g_events; - - while (g_npids > 0) { - g_free((g_pids + g_npids-1)->pid); - g_npids--; - } - if (g_pids) { - g_free(g_pids); - g_free(g_original_pids); - g_pids = 0; - g_original_pids = 0; - } - - s_pidhash = (pid_data_t **)g_malloc0( - PIDHASH_NBUCKETS*sizeof(pid_data_t *)); - - /* $$$ add a SEGV handler... */ - for (i = 0; i < g_nevents; i++) { - if (once) { - once = FALSE; - start_time = ((ulonglong)ntohl(rep->time[0])); - start_time <<= 32; - low_time = ntohl(rep->time[1]); - low_time &= 0xFFFFFFFF; - start_time |= low_time; - ep->time = 0LL; - } else { - ep->time = ((ulonglong)ntohl(rep->time[0])); - ep->time <<= 32; - low_time = ntohl(rep->time[1]); - low_time &= 0xFFFFFFFF; - ep->time |= low_time; - ep->time -= start_time; - ep->time /= ticks_per_ns; - } - ep->code = ntohl(rep->code); - ep->pid = find_or_add_pid(ntohl(rep->pid)); - ep->datum = ntohl(rep->datum); - ep->flags = 0; - ep++; - rep++; - } - - unmapfile((char *)ulp, size); - - make_sorted_pid_vector(); - g_free(s_pidhash); - s_pidhash = 0; - - /* Give the view-1 world a chance to reset a few things... */ - view1_read_events_callback(); -} - -static event_t *add_ep; - -/**************************************************************************** -* cpel_event_init -****************************************************************************/ -void cpel_event_init (ulong nevents) -{ - g_nevents = nevents; - if (g_events) - g_free(g_events); - add_ep = g_events = (event_t *)g_malloc(g_nevents * sizeof(event_t)); - while (g_npids > 0) { - g_free((g_pids + g_npids-1)->pid); - g_npids--; - } - if (g_pids) { - g_free(g_pids); - g_free(g_original_pids); - g_pids = 0; - g_original_pids = 0; - } - s_pidhash = (pid_data_t **)g_malloc0( - PIDHASH_NBUCKETS*sizeof(pid_data_t *)); -} - -/**************************************************************************** -* add_cpel_event -****************************************************************************/ - -void add_cpel_event(ulonglong delta, ulong track, ulong event, ulong datum) -{ - event_t *ep; - - ep = add_ep++; - ep->time = delta; - ep->pid = find_or_add_pid(track); - ep->code = event; - ep->datum = datum; - ep->flags = 0; -} - -/**************************************************************************** -* add_clib_event -****************************************************************************/ - -void add_clib_event(double delta, unsigned short track, - unsigned short event, unsigned int index) -{ - event_t *ep; - - ep = add_ep++; - ep->time = (ulonglong) (delta * 1e9); /* time in intger nanoseconds */ - ep->pid = find_or_add_pid(track); - ep->code = event; - ep->datum = index; - ep->flags = EVENT_FLAG_CLIB; -} - -/**************************************************************************** -* cpel_event_finalize -****************************************************************************/ - -void cpel_event_finalize(void) -{ - make_sorted_pid_vector(); - g_free(s_pidhash); - s_pidhash = 0; - - /* Give the view-1 world a chance to reset a few things... */ - view1_read_events_callback(); -} - -/**************************************************************************** -* mapfile -****************************************************************************/ - -char *mapfile (char *file, ulong *sizep) -{ - struct stat statb; - char *rv; - int maphfile; - size_t mapfsize; - - maphfile = open (file, O_RDONLY); - - if (maphfile < 0) - return (NULL); - - if (fstat (maphfile, &statb) < 0) { - return (NULL); - } - - /* Don't try to mmap directories, FIFOs, semaphores, etc. */ - if (! (statb.st_mode & S_IFREG)) { - return (NULL); - } - - mapfsize = statb.st_size; - - if (mapfsize < 3) { - close (maphfile); - return (NULL); - } - - rv = mmap (0, mapfsize, PROT_READ, MAP_SHARED, maphfile, 0); - - if (rv == 0) { - g_error ("%s mapping problem, I quit...\n", file); - } - - close (maphfile); - - if (madvise (rv, mapfsize, MADV_SEQUENTIAL) < 0) { - return (rv); - } - - if (sizep) { - *sizep = mapfsize; - } - return (rv); -} - -/**************************************************************************** -* unmapfile -****************************************************************************/ - -boolean unmapfile (char *addr, ulong size) -{ - if (munmap (addr, size) < 0) { - g_warning("Unmap error, addr 0x%lx size 0x%x\n", - (unsigned long) addr, (unsigned int)size); - return(FALSE); - } - return(TRUE); -} - -/**************************************************************************** -* find_event_index -* Binary search for first event whose time is >= t -****************************************************************************/ - -int find_event_index (ulonglong t) -{ - int index, bottom, top; - event_t *ep; - - bottom = g_nevents-1; - top = 0; - - while (1) { - index = (bottom + top) / 2; - - ep = (g_events + index); - - if (ep->time == t) - return(index); - - if (top >= bottom) { - while (index > 0 && ep->time > t) { - ep--; - index--; - } - while (index < g_nevents && ep->time < t) { - ep++; - index++; - } - return(index); - } - - if (ep->time < t) - top = index + 1; - else - bottom = index - 1; - } -} - -/**************************************************************************** -* events_about -****************************************************************************/ - -void events_about (char *tmpbuf) -{ - sprintf(tmpbuf+strlen(tmpbuf), "%d total events, %.3f ticks per us\n", - (int)g_nevents, ticks_per_ns); -} diff --git a/g2/g2.h b/g2/g2.h deleted file mode 100644 index 1ab42191..00000000 --- a/g2/g2.h +++ /dev/null @@ -1,195 +0,0 @@ -/* - *------------------------------------------------------------------ - * Copyright (c) 2005-2016 Cisco and/or its affiliates. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * typedefs and so forth - */ -#include -#include -#include -#include "props.h" - -typedef char boolean; -typedef unsigned long long ulonglong; - -/* - * main.c - */ - -GtkWidget *g_mainwindow; -GtkWidget *g_mainvbox; -GtkWidget *g_mainhbox; - -/* - * pointsel.c - */ -void point_selector_init(void); -boolean read_event_definitions (char *filename); -char *sxerox(char *); -void pointsel_about(char *); -void pointsel_next_snapshot(void); -void initialize_events(void); -void finalize_events(void); - -#define NEVENTS 100000 - -typedef struct event_def_ { - ulong event; - char *name; - char *format; - boolean selected; - boolean is_clib; - char pad[2]; -} event_def_t; - -event_def_t *find_event_definition (ulong code); - -event_def_t g_eventdefs[NEVENTS]; - -/* - * config params - */ -int c_maxpointsel; /* max # points shown in selector dlg */ -gint c_view1_draw_width; -gint c_view1_draw_height; - -/* - * menu1.c - */ - -void menu1_init(void); -void modal_dialog (char *label_text, char *retry_text, char *default_value, - boolean (*cb)(char *)); -void infobox(char *label_text, char *text); -/* - * view1.c - */ -GdkFont *g_font; -GdkColor fg_black, bg_white; -void view1_init(void); -void view1_display(void); -void view1_read_events_callback(void); -void view1_display_when_idle(void); -void view1_print_callback(GtkToggleButton *item, gpointer data); -void view1_about(char *); -void set_pid_ax_width(int width); -void set_window_title(const char *filename); - -enum view1_tbox_fn { - TBOX_DRAW_BOXED = 1, /* note: order counts */ - TBOX_DRAW_EVENT, - TBOX_DRAW_PLAIN, - TBOX_PRINT_BOXED, - TBOX_PRINT_EVENT, - TBOX_PRINT_PLAIN, /* end restriction */ - TBOX_GETRECT_BOXED, - TBOX_GETRECT_EVENT, - TBOX_GETRECT_PLAIN, -}; - -enum view1_line_fn { - LINE_DRAW_BLACK = 1, - LINE_DRAW_WHITE, - LINE_PRINT, -}; - -GdkRectangle *tbox (char *s, int x, int y, enum view1_tbox_fn function); -void line (int x1, int y1, int x2, int y2, enum view1_line_fn function); -gint view1_handle_key_press_event (GtkWidget *widget, GdkEventKey *event); - -/* - * events.c - */ - -void events_about (char *); - -typedef struct raw_event { - unsigned long time[2]; - unsigned long pid; - unsigned long code; - unsigned long datum; -} raw_event_t; - -void event_init(void); -char *mapfile (char *file, ulong *sizep); -boolean unmapfile (char *addr, ulong size); -void read_events (char *); -int find_event_index (ulonglong t); -int read_cpel_file(char *file); -int read_clib_file(char *file); -void cpel_event_init(ulong); -void add_event_from_cpel_file(ulong, char * , char *); -void add_event_from_clib_file(unsigned int event, char *name, - unsigned int vec_index); -void add_cpel_event(ulonglong delta, ulong, ulong, ulong); -void add_clib_event(double delta, unsigned short track, - unsigned short event, unsigned int index); -void cpel_event_finalize(void); -void *get_clib_event (unsigned int datum); - -typedef struct pid_data { - struct pid_data *next; - ulong pid_value; /* The actual pid value */ - ulong pid_index; /* Index in pid sort order */ -} pid_data_t; - -#define EVENT_FLAG_SELECT 0x00000001 /* This event is selected */ -#define EVENT_FLAG_SEARCHRSLT 0x00000002 /* This event is the search rslt */ -#define EVENT_FLAG_CLIB 0x00000004 /* clib event */ - -typedef struct pid_sort { - struct pid_data *pid; - ulong pid_value; - /* - * This is a bit of a hack, since this is used only by the view: - */ - unsigned color_index; -} pid_sort_t; - -typedef struct event { - ulonglong time; - ulong code; - pid_data_t *pid; - ulong datum; - ulong flags; -} event_t; - - -boolean g_little_endian; -event_t *g_events; -ulong g_nevents; -pid_sort_t *g_pids; -pid_sort_t *g_original_pids; -int g_npids; -pid_data_t *g_pid_data_list; - -#define PIDHASH_NBUCKETS 20021 /* Should be prime */ - -boolean ticks_per_ns_set; -double ticks_per_ns; - -/* - * version.c - */ -const char *version_string; -const char *minor_v_string; - -/* - * cpel.c - */ -char *get_track_label(unsigned long); -int widest_track_format; -char *strtab_ref(unsigned long); diff --git a/g2/g2version.c b/g2/g2version.c deleted file mode 100644 index 4b6f9313..00000000 --- a/g2/g2version.c +++ /dev/null @@ -1,19 +0,0 @@ -/* - *------------------------------------------------------------------ - * Copyright (c) 2005-2016 Cisco and/or its affiliates. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -const char *version_string = "G2 (x86_64 GNU/Linux) major version 3.0"; -const char *minor_v_string = - "Built Wed Feb 3 10:58:12 EST 2016"; diff --git a/g2/main.c b/g2/main.c deleted file mode 100644 index a782e17f..00000000 --- a/g2/main.c +++ /dev/null @@ -1,196 +0,0 @@ -/* - *------------------------------------------------------------------ - * Copyright (c) 2005-2016 Cisco and/or its affiliates. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "g2.h" -#include "props.h" -#include -#include -#include -#include -#include - -/* - * globals - */ - -GtkWidget *g_mainwindow; /* The main window */ - -/* Graphical object heirarchy - * - * [main window] - * [main vbox] - * [main (e.g. file) menubar] - * [view hbox] - * [view bottom menu] - */ - -GtkWidget *g_mainvbox; -GtkWidget *g_mainhbox; - -gint delete_event(GtkWidget *widget, GdkEvent *event, gpointer data) -{ - /* Allow window to be destroyed */ - return(FALSE); -} - -void destroy(GtkWidget *widget, gpointer data) -{ - gtk_main_quit(); -} - -int main (int argc, char **argv) -{ - char tmpbuf [128]; - struct passwd *pw; - char *event_file = 0; - char *cpel_file = 0; - char *clib_file =0; - char *title = "none"; - int curarg=1; - char *homedir; - - gtk_init(&argc, &argv); - - homedir = getenv ("HOME"); - tmpbuf[0] = 0; - - if (homedir) { - sprintf(tmpbuf, "%s/.g2", homedir); - } else { - pw = getpwuid(geteuid()); - if (pw) { - sprintf(tmpbuf, "%s/.g2", pw->pw_dir); - } - } - if (tmpbuf[0]) - readprops(tmpbuf); - - g_mainwindow = gtk_window_new (GTK_WINDOW_TOPLEVEL); - - gtk_signal_connect (GTK_OBJECT(g_mainwindow), "delete_event", - GTK_SIGNAL_FUNC (delete_event), NULL); - - gtk_signal_connect (GTK_OBJECT(g_mainwindow), "destroy", - GTK_SIGNAL_FUNC (destroy), NULL); - - gtk_container_set_border_width(GTK_CONTAINER(g_mainwindow), 5); - - g_mainvbox = gtk_vbox_new(FALSE, 0); - g_mainhbox = gtk_hbox_new(FALSE, 0); - - /* - * init routines - */ - - menu1_init(); - point_selector_init(); - view1_init(); - event_init(); - - /* - * Now that we're ready to rock 'n roll, see if we've been asked to - * press a few buttons... - */ - - while (curarg < argc) { - if (!strncmp(argv[curarg], "--cpel-input", 4)) { - curarg++; - if (curarg < argc) { - cpel_file = argv[curarg]; - curarg++; - break; - } - g_error("Missing filename after --cpel-input"); - } - if (!strncmp(argv[curarg], "--clib-input", 4)) { - curarg++; - if (curarg < argc) { - clib_file = argv[curarg]; - curarg++; - break; - } - g_error("Missing filename after --cpel-input"); - } - - if (!strncmp(argv[curarg], "--pointdefs", 3)) { - curarg++; - if (curarg < argc) { - read_event_definitions(argv[curarg]); - curarg++; - continue; - } - g_error ("Missing filename after --pointdefs\n"); - } - if (!strncmp(argv[curarg], "--event-log", 3)) { - curarg++; - if (curarg < argc) { - event_file = argv[curarg]; - curarg++; - continue; - } - g_error ("Missing filename after --event-log\n"); - } - - if (!strncmp(argv[curarg], "--ticks-per-us", 3)) { - curarg++; - if (curarg < argc) { - ticks_per_ns = 0.0; - ticks_per_ns = atof(argv[curarg]); - if (ticks_per_ns == 0.0) { - g_error("ticks-per-ns (%s) didn't convert properly\n", - argv[curarg]); - } - ticks_per_ns_set = TRUE; - curarg++; - continue; - } - g_error ("Missing filename after --event-log\n"); - } - - fprintf(stderr, - "g2 [--pointdefs ] [--event-log ]\n"); - fprintf(stderr, " [--ticks-per-us ]\n"); - fprintf(stderr, - " [--cpel-input ] [--clib-input \n"); - fprintf(stderr, - "%s\n%s\n", version_string, minor_v_string); - exit(0); - } - - if (clib_file) { - read_clib_file (clib_file); - title = clib_file; - } else if (cpel_file) { - read_cpel_file(cpel_file); - title = cpel_file; - } else if (event_file) { - read_events(event_file); - title = event_file; - } - - set_window_title(title); - - gtk_signal_connect (GTK_OBJECT (g_mainwindow), "key_press_event", - (GtkSignalFunc) view1_handle_key_press_event, NULL); - gtk_container_add(GTK_CONTAINER(g_mainvbox), g_mainhbox); - gtk_widget_show(g_mainhbox); - gtk_container_add(GTK_CONTAINER(g_mainwindow), g_mainvbox); - gtk_widget_show(g_mainvbox); - gtk_widget_show(g_mainwindow); - - gtk_main(); - return(0); -} diff --git a/g2/menu1.c b/g2/menu1.c deleted file mode 100644 index fce81fa6..00000000 --- a/g2/menu1.c +++ /dev/null @@ -1,565 +0,0 @@ -/* - *------------------------------------------------------------------ - * Copyright (c) 2006-2016 Cisco and/or its affiliates. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#define GTK_ENABLE_BROKEN // DGMS -#include -#include -#include "g2.h" -#include - -/* - * locals - */ -static GtkWidget *s_mainmenubar; -static GtkWidget *s_filemenu; -static GtkWidget *s_readdefs; -static GtkWidget *s_readevents; -static GtkWidget *s_readeventsclock; -static GtkWidget *s_readcpel; -static GtkWidget *s_readclib; -static GtkWidget *s_print; -static GtkWidget *s_quit; - -static GtkWidget *s_mainfilemenu; -static GtkWidget *s_help_general; -static GtkWidget *s_help_about; -static GtkWidget *s_mainhelpmenu; -static GtkWidget *s_helpmenu; - -static GtkWidget *s_filesel; -static GtkWidget *s_eventsel; - -typedef struct md_ { - GtkWidget *entry; - GtkWidget *label; - GtkWidget *dialog; - boolean (*callback)(char *); - char *retry_text; -} md_t; - -char *general_help = "\n" -"G2 is a performance event visualization tool.\n" -"\n" -"To view CPEL-format event data:\n" -"g2 --cpel \n" -"or use the File Menu->Read CPEL file option.\n" -"\n" -"To view vppinfra-format (.../open-repo/vppinfra/vppinfra/elog.h) event data:\n" -"g2 --clib \n" -"or use the File Menu->Read clib file option.\n" -"\n" -"To toggle event detail boxes, left-mouse-click on an event.\n" -"\n" -"To zoom to an area, depress the left mouse button. Move the\n" -"mouse. Release the mouse.\n" -"\n" -"To use the time ruler, depress the right mouse button. Move the\n" -"mouse. Release when done.\n" -"\n" -"To push a track to the bottom, \n" -"\n" -"To pull a track to the top, \n" -"\n" -"To selectively color/uncolor a track, \n" -"\n" -"To make the mouse scrollwheel faster, press \n" -"\n" -"Hotkeys, supposedly Quake-like:\n" -" w - zoom-in\n" -" s - zoom-out\n" -" a - pan-left\n" -" d - pan-right\n" -" r - pan-up\n" -" f - pan-down\n" -" t - less traces\n" -" g - more traces\n" -"\n" -" e - toggle summary-mode\n" -" c - toggle color-mode\n" -"\n" -" x - take snapshot\n" -" z - go to next snapshot\n" -" p - put snapshots to snapshots.g2 \n" -" l - load snapshots from snapshots.g2\n" -"\n" -"q - quit\n" -"Send comments / bug reports to the \"fd.io\" mailing list.\n"; - -/**************************************************************************** -* debug_dialog_callback -****************************************************************************/ - -boolean debug_dialog_callback (char *s) -{ - g_print("Dialog result: %s", s); - return (TRUE); -} - -/**************************************************************************** -* get_dialog_value -****************************************************************************/ - -static void get_dialog_value (GtkWidget *dialog, gpointer user_data) -{ - md_t *md = (md_t *)user_data; - char * cb_arg; - - cb_arg = (char *) gtk_entry_get_text(GTK_ENTRY(md->entry)); - - if ((*md->callback)(cb_arg)) { - gtk_grab_remove(md->dialog); - gtk_widget_destroy(md->dialog); - } else { - gtk_label_set_text (GTK_LABEL(md->label), md->retry_text); - } -} - -/**************************************************************************** -* modal_dialog -****************************************************************************/ - -void modal_dialog (char *label_text, char *retry_text, char *default_value, - boolean (*cb)(char *)) -{ - GtkWidget *dialog, *label, *ok_button, *entry; - static md_t dlg; - md_t *md = &dlg; - - dialog = gtk_dialog_new(); - label = gtk_label_new(label_text); - - entry = gtk_entry_new(); - if (default_value) - gtk_entry_set_text(GTK_ENTRY(entry), default_value); - - ok_button = gtk_button_new_with_label("OK"); - - md->entry = entry; - md->label = label; - md->retry_text = retry_text; - md->dialog = dialog; - if (cb) - md->callback = cb; - else - md->callback = debug_dialog_callback; - - gtk_signal_connect (GTK_OBJECT (ok_button), "clicked", - GTK_SIGNAL_FUNC(get_dialog_value), (gpointer) md); - - gtk_signal_connect (GTK_OBJECT (entry), "activate", - GTK_SIGNAL_FUNC(get_dialog_value), (gpointer) md); - - gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->action_area), - entry); - - gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->action_area), - ok_button); - gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), label); - gtk_widget_show_all(dialog); - gtk_widget_grab_focus(entry); - gtk_grab_add(dialog); -} - -/**************************************************************************** -* get_eventdef_name -****************************************************************************/ - -static void get_eventdef_name (GtkFileSelection *sel, gpointer user_data) -{ - char *filename = (char *) gtk_file_selection_get_filename ( - GTK_FILE_SELECTION(s_filesel)); - read_event_definitions(filename); - set_window_title(filename); -} - -/**************************************************************************** -* read_eventdef_callback -****************************************************************************/ - -static void read_eventdef_callback(GtkToggleButton *item, gpointer data) -{ - - s_filesel = gtk_file_selection_new("Read Event Definitions From..."); - - gtk_file_selection_set_filename(GTK_FILE_SELECTION(s_filesel), - "../h/elog.h"); - - gtk_signal_connect (GTK_OBJECT ( - GTK_FILE_SELECTION(s_filesel)->ok_button), - "clicked", - GTK_SIGNAL_FUNC(get_eventdef_name), NULL); - - gtk_signal_connect_object (GTK_OBJECT ( - GTK_FILE_SELECTION(s_filesel)->ok_button), - "clicked", - GTK_SIGNAL_FUNC (gtk_widget_destroy), - (gpointer) s_filesel); - - gtk_signal_connect_object (GTK_OBJECT ( - GTK_FILE_SELECTION(s_filesel)->cancel_button), - "clicked", - GTK_SIGNAL_FUNC (gtk_widget_destroy), - (gpointer) s_filesel); - gtk_file_selection_hide_fileop_buttons(GTK_FILE_SELECTION(s_filesel)); - gtk_widget_show (s_filesel); -} - -/**************************************************************************** -* get_events_name -****************************************************************************/ - -static void get_events_name (GtkFileSelection *sel, gpointer user_data) -{ - char *filename = (char *) gtk_file_selection_get_filename ( - GTK_FILE_SELECTION(s_eventsel)); - read_events(filename); - view1_display_when_idle(); -} - - -/**************************************************************************** -* get_ticks_per_ns -****************************************************************************/ - -static boolean get_ticks_per_ns (char *value) -{ - double rv; - - rv = atof (value); - - if (rv == 0.0 || rv > 100000) - return(FALSE); - - ticks_per_ns = rv; - ticks_per_ns_set = TRUE; - - gtk_widget_show(s_eventsel); - return(TRUE); -} - -/**************************************************************************** -* read_events_callback -****************************************************************************/ - -static void read_events_callback(GtkToggleButton *item, gpointer data) -{ - char tmpbuf [32]; - - s_eventsel = gtk_file_selection_new("Read Events From..."); - - gtk_signal_connect (GTK_OBJECT ( - GTK_FILE_SELECTION(s_eventsel)->ok_button), - "clicked", - GTK_SIGNAL_FUNC(get_events_name), NULL); - - gtk_signal_connect_object (GTK_OBJECT ( - GTK_FILE_SELECTION(s_eventsel)->ok_button), - "clicked", - GTK_SIGNAL_FUNC (gtk_widget_destroy), - (gpointer) s_eventsel); - - gtk_signal_connect_object (GTK_OBJECT ( - GTK_FILE_SELECTION(s_eventsel)->cancel_button), - "clicked", - GTK_SIGNAL_FUNC (gtk_widget_destroy), - (gpointer) s_eventsel); - gtk_file_selection_hide_fileop_buttons(GTK_FILE_SELECTION(s_eventsel)); - - if (ticks_per_ns_set) - gtk_widget_show (s_eventsel); - else { - sprintf(tmpbuf, "%.3f", ticks_per_ns); - modal_dialog ("Please enter clock ticks per nanosecond", - "Invalid: Please enter clock ticks per nanosecond", - tmpbuf, get_ticks_per_ns); - } -} - -/**************************************************************************** -* read_eventclock_callback -****************************************************************************/ - -static void read_eventsclock_callback(GtkToggleButton *item, gpointer data) -{ - ticks_per_ns_set = FALSE; - read_events_callback(item, data); -} - -/**************************************************************************** -* infobox_size_request -****************************************************************************/ - -void infobox_size_request (GtkWidget *widget, GtkRequisition *req, - gpointer user_data) -{ - char *text = (char *)user_data; - char *cp; - int widest_line_in_chars; - int w; - int nlines; - - /* - * You'd think that the string extent function would work here. - * You'd be wrong. - */ - nlines = w = widest_line_in_chars = 0; - for (cp = text; *cp; cp++) { - if (*cp == '\n') { - if (w > widest_line_in_chars) { - widest_line_in_chars = w; - } - w = 0; - nlines++; - } - w++; - } - - nlines++; - - req->width = (widest_line_in_chars * 8) + 20; - req->height = (nlines * 13) + 10; -} - -/**************************************************************************** -* infobox -****************************************************************************/ - -void infobox(char *label_text, char *text) -{ - GtkWidget *dialog, *label, *ok_button, *entry; - GtkWidget *box; - - dialog = gtk_dialog_new(); - label = gtk_label_new(label_text); - - entry = gtk_text_new(NULL, NULL); - - gtk_signal_connect (GTK_OBJECT (entry), "size-request", - GTK_SIGNAL_FUNC(infobox_size_request), - (gpointer) text); - - gtk_text_insert(GTK_TEXT(entry), g_font, &fg_black, &bg_white, - text, -1); - - gtk_text_set_editable(GTK_TEXT(entry), FALSE); - - ok_button = gtk_button_new_with_label("OK"); - - gtk_signal_connect_object (GTK_OBJECT (ok_button), "clicked", - GTK_SIGNAL_FUNC(gtk_widget_destroy), - (gpointer) GTK_OBJECT(dialog)); - - box = gtk_vbox_new(FALSE, 5); - - - gtk_box_pack_start(GTK_BOX(box), entry, TRUE, TRUE, 0); - gtk_box_pack_start(GTK_BOX(box), ok_button, FALSE, FALSE, 0); - - gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->action_area), - box); - - gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), label); - gtk_widget_show_all(dialog); -} - -/**************************************************************************** -* help_general_callback -****************************************************************************/ - -static void help_general_callback(GtkToggleButton *item, gpointer data) -{ - infobox("General Help", general_help); -} - -/**************************************************************************** -* help_about_callback -****************************************************************************/ - -static void help_about_callback(GtkToggleButton *item, gpointer data) -{ - char tmpbuf [1024]; - sprintf (tmpbuf, "G2 -- Graphical Event Viewer\n\n"); - view1_about(tmpbuf); - pointsel_about(tmpbuf); - events_about(tmpbuf); - sprintf (tmpbuf+strlen(tmpbuf), "\n%s\n", version_string); - sprintf (tmpbuf+strlen(tmpbuf), "%s\n", minor_v_string); - infobox("About", tmpbuf); -} - - -/**************************************************************************** -* get_cpel_name -****************************************************************************/ - -static void get_cpel_name (GtkFileSelection *sel, gpointer user_data) -{ - char *filename = (char *)gtk_file_selection_get_filename ( - GTK_FILE_SELECTION(s_filesel)); - read_cpel_file(filename); - set_window_title(filename); -} - -/**************************************************************************** -* get_clib_name -****************************************************************************/ - -static void get_clib_name (GtkFileSelection *sel, gpointer user_data) -{ - char *filename = (char *) gtk_file_selection_get_filename ( - GTK_FILE_SELECTION(s_filesel)); - read_clib_file(filename); - set_window_title(filename); -} - -/**************************************************************************** -* read_cpel_callback -****************************************************************************/ - -static void read_cpel_callback(GtkToggleButton *item, gpointer data) -{ - - s_filesel = gtk_file_selection_new("Read CPEL data from..."); - - gtk_file_selection_set_filename(GTK_FILE_SELECTION(s_filesel), - "cpel.out"); - - gtk_signal_connect (GTK_OBJECT ( - GTK_FILE_SELECTION(s_filesel)->ok_button), - "clicked", - GTK_SIGNAL_FUNC(get_cpel_name), NULL); - - gtk_signal_connect_object (GTK_OBJECT ( - GTK_FILE_SELECTION(s_filesel)->ok_button), - "clicked", - GTK_SIGNAL_FUNC (gtk_widget_destroy), - (gpointer) s_filesel); - - gtk_signal_connect_object (GTK_OBJECT ( - GTK_FILE_SELECTION(s_filesel)->cancel_button), - "clicked", - GTK_SIGNAL_FUNC (gtk_widget_destroy), - (gpointer) s_filesel); - gtk_file_selection_hide_fileop_buttons(GTK_FILE_SELECTION(s_filesel)); - gtk_widget_show (s_filesel); -} - -/**************************************************************************** -* read_clib_callback -****************************************************************************/ - -static void read_clib_callback(GtkToggleButton *item, gpointer data) -{ - - s_filesel = gtk_file_selection_new("Read clib data From..."); - - gtk_file_selection_set_filename(GTK_FILE_SELECTION(s_filesel), - "clib.out"); - - gtk_signal_connect (GTK_OBJECT ( - GTK_FILE_SELECTION(s_filesel)->ok_button), - "clicked", - GTK_SIGNAL_FUNC(get_clib_name), NULL); - - gtk_signal_connect_object (GTK_OBJECT ( - GTK_FILE_SELECTION(s_filesel)->ok_button), - "clicked", - GTK_SIGNAL_FUNC (gtk_widget_destroy), - (gpointer) s_filesel); - - gtk_signal_connect_object (GTK_OBJECT ( - GTK_FILE_SELECTION(s_filesel)->cancel_button), - "clicked", - GTK_SIGNAL_FUNC (gtk_widget_destroy), - (gpointer) s_filesel); - gtk_file_selection_hide_fileop_buttons(GTK_FILE_SELECTION(s_filesel)); - gtk_widget_show (s_filesel); -} - -/**************************************************************************** -* menu1_init -****************************************************************************/ - -void menu1_init(void) -{ - - s_filemenu = gtk_menu_new(); - - s_readcpel = gtk_menu_item_new_with_label - ("Read CPEL file"); - gtk_menu_append(GTK_MENU(s_filemenu), s_readcpel); - gtk_signal_connect(GTK_OBJECT(s_readcpel), "activate", - GTK_SIGNAL_FUNC(read_cpel_callback), 0); - - s_readclib = gtk_menu_item_new_with_label - ("Read CLIB file"); - gtk_menu_append(GTK_MENU(s_filemenu), s_readclib); - gtk_signal_connect(GTK_OBJECT(s_readclib), "activate", - GTK_SIGNAL_FUNC(read_clib_callback), 0); - - s_readdefs = gtk_menu_item_new_with_label ("Read Event Definitions"); - gtk_menu_append(GTK_MENU(s_filemenu), s_readdefs); - gtk_signal_connect(GTK_OBJECT(s_readdefs), "activate", - GTK_SIGNAL_FUNC(read_eventdef_callback), 0); - - s_readevents = gtk_menu_item_new_with_label ("Read Event Log"); - gtk_menu_append(GTK_MENU(s_filemenu), s_readevents); - gtk_signal_connect(GTK_OBJECT(s_readevents), "activate", - GTK_SIGNAL_FUNC(read_events_callback), 0); - - s_readeventsclock = gtk_menu_item_new_with_label - ("Read Event Log with Different Clock Rate"); - gtk_menu_append(GTK_MENU(s_filemenu), s_readeventsclock); - gtk_signal_connect(GTK_OBJECT(s_readeventsclock), "activate", - GTK_SIGNAL_FUNC(read_eventsclock_callback), 0); - - s_print = gtk_menu_item_new_with_label ("Print"); - gtk_menu_append(GTK_MENU(s_filemenu), s_print); - gtk_signal_connect(GTK_OBJECT(s_print), "activate", - GTK_SIGNAL_FUNC(view1_print_callback), 0); - - s_quit = gtk_menu_item_new_with_label ("Exit"); - gtk_menu_append(GTK_MENU(s_filemenu), s_quit); - gtk_signal_connect(GTK_OBJECT(s_quit), "activate", - GTK_SIGNAL_FUNC(gtk_main_quit), 0); - - s_mainfilemenu = gtk_menu_item_new_with_label("File"); - gtk_menu_item_set_submenu(GTK_MENU_ITEM(s_mainfilemenu), s_filemenu); - - s_helpmenu = gtk_menu_new(); - - s_help_general = gtk_menu_item_new_with_label ("General"); - gtk_menu_append(GTK_MENU(s_helpmenu), s_help_general); - gtk_signal_connect(GTK_OBJECT(s_help_general), "activate", - GTK_SIGNAL_FUNC(help_general_callback), 0); - - s_help_about = gtk_menu_item_new_with_label ("About"); - gtk_menu_append(GTK_MENU(s_helpmenu), s_help_about); - gtk_signal_connect(GTK_OBJECT(s_help_about), "activate", - GTK_SIGNAL_FUNC(help_about_callback), 0); - - s_mainhelpmenu = gtk_menu_item_new_with_label("Help"); - gtk_menu_item_set_submenu(GTK_MENU_ITEM(s_mainhelpmenu), s_helpmenu); - - s_mainmenubar = gtk_menu_bar_new(); - gtk_menu_bar_append(GTK_MENU_BAR(s_mainmenubar), s_mainfilemenu); - gtk_menu_bar_append(GTK_MENU_BAR(s_mainmenubar), s_mainhelpmenu); - gtk_widget_show_all(s_mainmenubar); - - gtk_box_pack_start(GTK_BOX(g_mainvbox), s_mainmenubar, FALSE, FALSE, 0); -} diff --git a/g2/mkversion.c b/g2/mkversion.c deleted file mode 100644 index 3523fbe6..00000000 --- a/g2/mkversion.c +++ /dev/null @@ -1,77 +0,0 @@ -/* - *------------------------------------------------------------------ - * Copyright (c) 1997-2016 Cisco and/or its affiliates. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include - -int main (int argc, char **argv) -{ - time_t now; - FILE *ofp; - char *dateval; - char *username; - char *userstr; - char *datestr; - int i; - char propname[32]; - char *propvalue; - char timestr[64]; - char *cp; - - if (argc < 4) { - printf ("usage: mkversion ostype version outputfile\n"); - exit (1); - } - - ofp = fopen (argv[3], "w"); - if (ofp == NULL) { - printf ("Couldn't create %s\n", argv[3]); - exit (1); - } - - now = time (0); - - fprintf (ofp, "/*\n"); - fprintf (ofp, " * G2 Version Stamp, %s", - ctime (&now)); - fprintf (ofp, " * Automatically generated, hand edits are pointless.\n"); - fprintf (ofp, " */\n\n"); - - fprintf (ofp, - "const char *version_string = \"G2 (%s) major version %s\";\n", - argv[1], argv[2]); - - username = (char *) cuserid (0); - - strcpy(timestr, ctime(&now)); - - cp = timestr; - - while (*cp) { - cp++; - } - if (*--cp == '\n') - *cp = 0; - - fprintf (ofp, - "const char *minor_v_string = \"Built by %s at %s\";\n", - username, timestr); - - exit (0); -} - - diff --git a/g2/pointsel.c b/g2/pointsel.c deleted file mode 100644 index 018dc213..00000000 --- a/g2/pointsel.c +++ /dev/null @@ -1,854 +0,0 @@ -/* - *------------------------------------------------------------------ - * Copyright (c) 2005-2016 Cisco and/or its affiliates. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include -#include -#include -#include "g2.h" - -/* - * globals - */ -event_def_t g_eventdefs[NEVENTS]; - -/* - * locals - */ -static GtkWidget *s_pointselbox; -static FILE *s_hfp; -static FILE *s_elog_hfp; -static int s_basenum; -static GtkWidget *s_event_buttons[NEVENTS]; -static int s_min_shown_pointsel; -static int s_max_shown_pointsel; -static GtkWidget *s_allbutton; -static GtkWidget *s_nonebutton; -static GtkWidget *s_pointselbuttons; -static GtkWidget *s_ps_vscroll; -static GtkObject *s_ps_vsadj; -static int g_neventdefs; - -enum button_click { - ALL_BUTTON=1, - NONE_BUTTON, -}; - -/* - * config params - */ -int c_maxpointsel; - -/**************************************************************************** -* recompute_vscrollbar -****************************************************************************/ - -static void recompute_ps_vscrollbar (void) -{ - GtkAdjustment *adj; - ulong limit; - - adj = GTK_ADJUSTMENT(s_ps_vsadj); - -#ifdef NOTDEF - /* This seems like the right calculation, but seems not to work */ - if (g_neventdefs > c_maxpointsel) - limit = g_neventdefs - c_maxpointsel; - else - limit = g_neventdefs; -#else - limit = g_neventdefs-1; -#endif - - adj->lower = (gfloat)0.00; - adj->upper = (gfloat)limit; - adj->value = (gfloat)0.00; - adj->step_increment = (gfloat)1.00; - adj->page_increment = (gfloat)(c_maxpointsel / 3); - adj->page_size = (gfloat)c_maxpointsel; - gtk_adjustment_changed(adj); - gtk_adjustment_value_changed(adj); - gtk_widget_show(s_ps_vscroll); -} - -/**************************************************************************** -* point_select_callback -****************************************************************************/ - -static void point_select_callback(GtkToggleButton *item, gpointer data) -{ - int i = (int) (unsigned long long) data; - - g_eventdefs[i].selected = gtk_toggle_button_get_active( - GTK_TOGGLE_BUTTON(s_event_buttons[i])); - view1_display_when_idle(); -} - -/**************************************************************************** -* up_button -****************************************************************************/ - -static void up_button(void) -{ - int i; - int increment = c_maxpointsel/4; - - if (s_min_shown_pointsel == 0) - return; - - s_min_shown_pointsel -= increment; - - if (s_min_shown_pointsel < 0) - s_min_shown_pointsel = 0; - - s_max_shown_pointsel = s_min_shown_pointsel + c_maxpointsel; - - for (i = 0; i < g_neventdefs; i++) { - if (i >= s_min_shown_pointsel && - i <= s_max_shown_pointsel) - gtk_widget_show(s_event_buttons[i]); - else - gtk_widget_hide(s_event_buttons[i]); - } - -} - -#ifdef NOTDEF -/**************************************************************************** -* down_button -****************************************************************************/ - -static void down_button(void) -{ - int i; - int increment = c_maxpointsel/4; - - if (s_max_shown_pointsel == g_neventdefs) - return; - - s_max_shown_pointsel += increment; - - if (s_max_shown_pointsel >= g_neventdefs) - s_max_shown_pointsel = (g_neventdefs-1); - - s_min_shown_pointsel = s_max_shown_pointsel - c_maxpointsel; - - if (s_min_shown_pointsel < 0) - s_min_shown_pointsel = 0; - - for (i = 0; i < g_neventdefs; i++) { - if (i >= s_min_shown_pointsel && - i <= s_max_shown_pointsel) - gtk_widget_show(s_event_buttons[i]); - else - gtk_widget_hide(s_event_buttons[i]); - } - -} -#endif - -/**************************************************************************** -* button_click_callback -****************************************************************************/ - -static void button_click_callback(GtkButton *item, gpointer data) -{ - int i; - enum button_click click = (enum button_click)data; - - switch (click) { - case ALL_BUTTON: - for (i = 0; i < g_neventdefs; i++) { - gtk_toggle_button_set_active ( - GTK_TOGGLE_BUTTON(s_event_buttons[i]), TRUE); - g_eventdefs[i].selected = TRUE; - } - break; - - case NONE_BUTTON: - for (i = 0; i < g_neventdefs; i++) { - gtk_toggle_button_set_active ( - GTK_TOGGLE_BUTTON(s_event_buttons[i]), FALSE); - g_eventdefs[i].selected = FALSE; - } - break; - } -} - -/**************************************************************************** -* scroll_callback -****************************************************************************/ - -static void scroll_callback (GtkAdjustment *adj, GtkWidget *notused) -{ - int i; - - s_min_shown_pointsel = (int)adj->value; - s_max_shown_pointsel = s_min_shown_pointsel + c_maxpointsel; - - for (i = 0; i < g_neventdefs; i++) { - if (i >= s_min_shown_pointsel && - i <= s_max_shown_pointsel) - gtk_widget_show(s_event_buttons[i]); - else - gtk_widget_hide(s_event_buttons[i]); - } -} - -/**************************************************************************** -* point_selector_init -****************************************************************************/ - -void point_selector_init(void) -{ - - c_maxpointsel = atol(getprop_default("event_selector_lines", "20")); - - s_pointselbox = gtk_vbox_new(FALSE,5); - - s_pointselbuttons = gtk_hbox_new(FALSE,5); - - s_allbutton = gtk_button_new_with_label("ALL"); - gtk_widget_show(s_allbutton); - s_nonebutton = gtk_button_new_with_label("NONE"); - gtk_widget_show(s_nonebutton); - - gtk_signal_connect (GTK_OBJECT(s_allbutton), "clicked", - GTK_SIGNAL_FUNC(button_click_callback), - (gpointer) ALL_BUTTON); - - gtk_signal_connect (GTK_OBJECT(s_nonebutton), "clicked", - GTK_SIGNAL_FUNC(button_click_callback), - (gpointer) NONE_BUTTON); - - gtk_box_pack_start(GTK_BOX(s_pointselbuttons), s_allbutton, FALSE, - FALSE, 0); - gtk_box_pack_start(GTK_BOX(s_pointselbuttons), s_nonebutton, FALSE, - FALSE, 0); - - gtk_widget_show(s_pointselbuttons); - gtk_widget_ref(s_pointselbuttons); - - gtk_box_pack_start(GTK_BOX(s_pointselbox), s_pointselbuttons, FALSE, - FALSE, 0); - - gtk_box_pack_end (GTK_BOX(g_mainhbox), s_pointselbox, - FALSE, FALSE, 0); - - s_ps_vsadj = gtk_adjustment_new(0.0 /* initial value */, - 0.0 /* minimum value */, - 2000.0 /* maximum value */, - 0.1 /* step increment */, - 10.0/* page increment */, - 10.0/* page size */); - - s_ps_vscroll = gtk_vscrollbar_new (GTK_ADJUSTMENT(s_ps_vsadj)); - gtk_signal_connect (GTK_OBJECT (s_ps_vsadj), "value-changed", - GTK_SIGNAL_FUNC (scroll_callback), - (gpointer)s_ps_vscroll); - gtk_box_pack_end(GTK_BOX(g_mainhbox), s_ps_vscroll, FALSE, FALSE, 0); -} - -/**************************************************************************** -* sxerox -****************************************************************************/ - -char *sxerox (char *s) -{ - char *rv; - - /* Note: g_malloc does or dies... */ - rv = (char *)g_malloc(strlen(s)+1); - strcpy (rv, s); - return (rv); -} - -/**************************************************************************** -* reset_point_selector -****************************************************************************/ - -static void reset_point_selector(void) -{ - int i; - - gtk_widget_hide(s_pointselbox); - gtk_widget_hide(s_pointselbuttons); - gtk_widget_hide(s_ps_vscroll); - gtk_container_remove(GTK_CONTAINER(s_pointselbox), - s_pointselbuttons); - - for (i = 0; i < g_neventdefs; i++) { - if (s_event_buttons[i]) { - gtk_container_remove(GTK_CONTAINER(s_pointselbox), - s_event_buttons[i]); - s_event_buttons[i] = 0; - } - } -} - -/**************************************************************************** -* create_point_selector -****************************************************************************/ - -static void create_point_selector(void) -{ - int i; - char tmpbuf [1024]; - event_def_t *ep; - GtkWidget *wp; - - for (i = 0; i < g_neventdefs; i++) { - ep = &g_eventdefs[i]; - sprintf(tmpbuf, "[%lu] %s", ep->event, - ep->name ? ep->name : "(none)"); - /* Hack to reduce width of point selectors */ - if (strlen(tmpbuf) > 50) { - tmpbuf[50] = 0; - } - - wp = gtk_check_button_new_with_label (tmpbuf); - s_event_buttons[i] = wp; - gtk_signal_connect (GTK_OBJECT(wp), "toggled", - GTK_SIGNAL_FUNC(point_select_callback), - (gpointer) (unsigned long long) i); - gtk_toggle_button_set_active ( - GTK_TOGGLE_BUTTON(wp), TRUE); - gtk_box_pack_start(GTK_BOX(s_pointselbox), wp, FALSE, FALSE, 0); - } - - /* set up scroll parameters by faking an up-button */ - s_min_shown_pointsel = 1; - up_button(); - - gtk_box_pack_start(GTK_BOX(s_pointselbox), s_pointselbuttons, FALSE, - FALSE, 0); - gtk_widget_show(s_pointselbuttons); - gtk_widget_show(s_pointselbox); - gtk_widget_show(s_ps_vscroll); -} - -/**************************************************************************** -* remove_all_events -****************************************************************************/ - -static void remove_all_events(void) -{ - event_def_t *ep; - int i; - - for (i = 0; i < g_neventdefs; i++) { - ep = &g_eventdefs[i]; - if (!ep->is_clib) { - if (ep->name) - g_free(ep->name); - if(ep->format) - g_free(ep->format); - } - } - g_neventdefs = 0; -} - -/**************************************************************************** -* add_event -****************************************************************************/ - -static void add_event(ulong event, char *name, char *format) -{ - int i; - event_def_t *ep; - - if (g_neventdefs >= NEVENTS) { - g_error("Too many event definitions, increase NEVENTS!"); - /*NOTREACHED*/ - } - - /* Simple dup check, probably not needed very often */ - for (i = 0; i < g_neventdefs; i++) { - if (g_eventdefs[i].event == event) { - g_warning("Duplicate def event %lu: first definition retained\n", - event); - return; - } - } - - ep = &g_eventdefs[g_neventdefs++]; - - ep->event = event; - ep->name = sxerox(name); - ep->format = sxerox(format); - ep->selected = TRUE; -} - -/**************************************************************************** -* add_event_from_cpel_file -****************************************************************************/ - -void add_event_from_cpel_file(ulong event, char *event_format, - char *datum_format) -{ - event_def_t *ep; - - if (g_neventdefs >= NEVENTS) { - g_error("Too many event definitions, increase NEVENTS!"); - /*NOTREACHED*/ - } - - ep = &g_eventdefs[g_neventdefs++]; - - ep->event = event; - /* - * Duplicate the strings for backward compatibility. Otherwise, - * the g_free above will barf because the name/format strings are - * actually in mmap'ed memory - */ - ep->name = sxerox(event_format); - ep->format = sxerox(datum_format); - ep->selected = TRUE; -} - -/**************************************************************************** -* add_event_from_clib_file -****************************************************************************/ - -void add_event_from_clib_file(unsigned int event, char *name, - unsigned int vec_index) -{ - event_def_t *ep; - - if (g_neventdefs >= NEVENTS) { - g_error("Too many event definitions, increase NEVENTS!"); - /*NOTREACHED*/ - } - - ep = &g_eventdefs[g_neventdefs++]; - - ep->event = event; - - ep->name = sxerox(name); - ep->format = (void *)(unsigned long long) vec_index; - ep->selected = TRUE; - ep->is_clib = TRUE; -} - -/**************************************************************************** -* read_header_file - eats header file lines of the form -* -* #define EVENT_FOO 123 / * name: %d * / -* -****************************************************************************/ - -static void read_header_file (void) -{ - char tmpbuf [1024]; - char *name, *format; - char *cp; - unsigned long event; - int ev_num_flag; - - while (fgets (tmpbuf, sizeof (tmpbuf), s_hfp)) - { - cp = tmpbuf; - ev_num_flag = 0; - - if (strncmp (cp, "#define", 7)) - continue; - - /* skip #define */ - while (*cp && !(isspace ((int)*cp))) - cp++; - - if (*cp == 0) - continue; - - /* skip ws after #define */ - while (*cp && isspace ((int)*cp)) - cp++; - - if (*cp == 0) - continue; - - /* skip symbolic name */ - while (*cp && !(isspace ((int)*cp))) - cp++; - - if (*cp == 0) - continue; - - /* skip ws after symbolic name */ - while (*cp && isspace ((int)*cp)) - cp++; - - if (*cp == 0) - continue; - - event = 0; - - if (!strncmp(cp, "EV_NUM", 6)) { - cp += 6; - ev_num_flag = 1; - - while (*cp && *cp != '(') - cp++; - - if (*cp == 0) - continue; - - cp++; - - while (*cp && isspace ((int)*cp)) - cp++; - - } - - /* eat event code. */ - while (*cp && isdigit ((int)*cp)) - { - event = event * 10 + (*cp - '0'); - cp++; - } - - if (*cp == 0) - continue; - - if (ev_num_flag) { - while (*cp && *cp != ')') - cp++; - if (*cp == 0) - continue; - cp++; - event += s_basenum; - } - - /* skip ws after event code */ - while (*cp && isspace ((int)*cp)) - cp++; - - if (*cp != '/') - continue; - - cp++; - - if (*cp != '*') - continue; - - cp++; - - /* skip ws after comment start */ - while (*cp && isspace ((int)*cp)) - cp++; - - if (*cp == 0) - continue; - - name = cp; - - /* accumulate name */ - while (*cp && *cp != ':' && *cp != '*') - cp++; - - if (*cp == 0) - continue; - - *cp++ = 0; - - /* skip ws after name: */ - while (*cp && isspace ((int)*cp)) - cp++; - - if (*cp == 0 || *cp == '/') - { - format = " "; - goto write_it; - } - - format = cp; - - /* accumulate format string */ - while (*cp && !isspace ((int)*cp)) - cp++; - - *cp = 0; - - write_it: - - add_event (event, name, format); - } -} - -/**************************************************************************** -* read_header_files - eats header file lines of the form -* -* #define FILE1_BASE 100 / * pointdefs: ../vpn/vpn_points.h * / -* -****************************************************************************/ - -static boolean read_header_files (void) -{ - char *cp, *name; - char tmpbuf [1024]; - int basenum; - boolean rv=FALSE; - - while (fgets (tmpbuf, sizeof (tmpbuf), s_elog_hfp)) - { - cp = tmpbuf; - - if (strncmp (cp, "#define", 7)) - continue; - - cp += 7; - - /* skip ws after #define */ - while (*cp && isspace ((int)*cp)) - cp++; - - if (*cp == 0) - continue; - - /* skip EV_COMPxxx_START */ - while (*cp && !isspace((int)*cp)) - cp++; - - if (*cp == 0) - continue; - - /* skip ws after EV_COMPxxx_START */ - while (*cp && isspace ((int)*cp)) - cp++; - - if (*cp == 0) - continue; - - basenum = atol (cp); - - /* skip #define */ - while (*cp && (*cp != '/')) - cp++; - - if (*cp == 0) - continue; - - cp++; - if (*cp != '*') - continue; - - cp++; - - /* skip ws after comment start */ - while (*cp && isspace ((int)*cp)) - cp++; - - if (*cp == 0) - continue; - - if (strncmp (cp, "pointdefs:", 10)) - continue; - - cp += 10; - - /* skip ws after comment start */ - while (*cp && isspace ((int)*cp)) - cp++; - - name = cp; - - while (*cp && !isspace ((int)*cp)) - cp++; - - *cp = 0; - - s_hfp = fopen (name, "rt"); - - if (s_hfp == NULL) { - g_warning ("Couldn't open header file %s\n", name); - continue; - } - rv = TRUE; - - s_basenum = basenum; - - read_header_file(); - - fclose (s_hfp); - } - return(rv); -} - -/**************************************************************************** -* event_def_cmp -****************************************************************************/ - -int event_def_cmp(const void *a1, const void *a2) -{ - event_def_t *e1 = (event_def_t *)a1; - event_def_t *e2 = (event_def_t *)a2; - - if (e1->event < e2->event) - return(-1); - else if (e1->event == e2->event) - return(0); - else - return(1); -} - -/**************************************************************************** -* sort_event_definitions -****************************************************************************/ - -void sort_event_definitions(void) -{ - qsort(&g_eventdefs[0], g_neventdefs, sizeof(event_def_t), event_def_cmp); -} - -static boolean remove_needed=TRUE; - -void finalize_events(void) -{ - sort_event_definitions(); - create_point_selector(); - recompute_ps_vscrollbar(); - view1_display_when_idle(); - remove_needed = TRUE; -} - -void initialize_events(void) -{ - if (remove_needed) { - reset_point_selector(); - remove_all_events(); - remove_needed = FALSE; - } -} - -/**************************************************************************** -* read_event_definitions -****************************************************************************/ - -boolean read_event_definitions (char *filename) -{ - char tmpbuf [128]; - - initialize_events(); - - s_elog_hfp = fopen (filename, "rt"); - if (s_elog_hfp == NULL) { - sprintf (tmpbuf, "Couldn't open %s\n", filename); - infobox ("Open Failed", tmpbuf); - return(FALSE); - } - /* Presume "elog.h". Note fallthrough... */ - if (read_header_files()) { - sort_event_definitions(); - create_point_selector(); - recompute_ps_vscrollbar(); - fclose(s_elog_hfp); - view1_display_when_idle(); - remove_needed = TRUE; - return(TRUE); - } - fclose(s_elog_hfp); - - s_hfp = fopen (filename, "rt"); - if (s_hfp == NULL) { - sprintf (tmpbuf, "Couldn't open %s\n", filename); - infobox ("Read Event Definition Failure", tmpbuf); - return(FALSE); - } - - read_header_file(); - - /* Happens if the user feeds us the wrong file, for example */ - if (g_neventdefs == 0) { - sprintf (tmpbuf, "No event definitions found in %s\n", filename); - infobox ("No Event Definitions?", tmpbuf); - return(FALSE); - } - finalize_events(); - return(TRUE); -} - -static event_def_t dummy_event; -static char dummy_string[32]; - -/**************************************************************************** -* find_event_definition -* Binary search for first event whose time is >= t -****************************************************************************/ - -event_def_t *find_event_definition (ulong code) -{ - int index, bottom, top; - event_def_t *edp; - - if (g_neventdefs == 0) - goto use_dummy; - - bottom = g_neventdefs-1; - top = 0; - - while (1) { - index = (bottom + top) / 2; - - edp = (g_eventdefs + index); - - if (edp->event == code) - return(edp); - - if (top >= bottom) { - use_dummy: - edp = &dummy_event; - edp->selected = TRUE; - edp->event = code; - edp->format = "0x%x"; - sprintf (dummy_string, "E%lu", code); - edp->name = &dummy_string[0]; - return(edp); - } - - if (edp->event < code) - top = index + 1; - else - bottom = index - 1; - } -} - -/**************************************************************************** -* pointsel_next_snapshot -* Set dialog buttons from snapshot -****************************************************************************/ - -void pointsel_next_snapshot(void) -{ - int i; - - for (i = 0; i < g_neventdefs; i++) { - gtk_toggle_button_set_active ( - GTK_TOGGLE_BUTTON(s_event_buttons[i]), - g_eventdefs[i].selected); - } -} - -/**************************************************************************** -* pointsel_about -****************************************************************************/ - -void pointsel_about (char *tmpbuf) -{ - sprintf (tmpbuf+strlen(tmpbuf), "%d event definitions\n", - g_neventdefs); -} diff --git a/g2/props.c b/g2/props.c deleted file mode 100644 index a23dc050..00000000 --- a/g2/props.c +++ /dev/null @@ -1,279 +0,0 @@ -/* - *------------------------------------------------------------------ - * Copyright (c) 1997-2016 Cisco and/or its affiliates. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#include -#include -#include -#include -#include -#include - -static char *sxerox (char *s); -void exit(int); - -#define NBUCKETS 97 - -typedef struct prop_ { - struct prop_ *next; - char *name; - char *value; -} prop_t; - -static prop_t *buckets [NBUCKETS]; -static int hash_shifts[4] = {24, 16, 8, 0}; - -/* - * getprop - */ - -char *getprop (char *name) -{ - unsigned char *cp; - unsigned long hash=0; - prop_t *bp; - int i=0; - - for (cp = (unsigned char *) name; *cp; cp++) - hash ^= (*cp)<<(hash_shifts[(i++)&0x3]); - - bp = buckets [hash%NBUCKETS]; - - while (bp && strcmp (bp->name, name)) { - bp = bp->next; - } - - if (bp == NULL) - return (0); - else - return (bp->value); -} - -/* - * getprop_default - */ - -char *getprop_default (char *name, char *def) -{ - char *rv; - rv = getprop (name); - if (rv) - return (rv); - else - return (def); -} - -/* - * addprop - */ - -void addprop (char *name, char *value) -{ - unsigned char *cp; - unsigned long hash=0; - prop_t **bpp; - prop_t *bp; - int i=0; - - bp = (prop_t *)g_malloc (sizeof (prop_t)); - - bp->next = 0; - bp->name = sxerox (name); - bp->value = sxerox (value); - - for (cp = (unsigned char *)name; *cp; cp++) - hash ^= (*cp)<<(hash_shifts[(i++)&0x3]); - - bpp = &buckets [hash%NBUCKETS]; - - if (*bpp == NULL) - *bpp = bp; - else { - bp->next = *bpp; - *bpp = bp; - } -} - -/* - * sxerox - */ - -static char *sxerox (char *s) -{ - char *rv = (char *) g_malloc (strlen (s) + 1); - strcpy (rv, s); - return rv; -} - -/* - * readprops - */ - -#define START 0 -#define READNAME 1 -#define READVALUE 2 -#define C_COMMENT 3 -#define CPP_COMMENT 4 - -int readprops (char *filename) -{ - FILE *ifp; - unsigned char c; - int state=START; - int linenum=1; - char namebuf [128]; - char valbuf [512]; - int i; - - ifp = fopen (filename, "r"); - - if (ifp == NULL) - return (-1); - - while (1) { - - readchar: - c = getc (ifp); - - again: - switch (state) { - case START: - if (feof (ifp)) { - fclose (ifp); - return (0); - } - - if (c == ' ' || c == '\t') - goto readchar; - - if (c == '\n') { - linenum++; - goto readchar; - } - if (isalpha (c) || (c == '_')) { - state = READNAME; - goto again; - } - if (c == '/') { - c = getc (ifp); - if (c == '/') { - state = CPP_COMMENT; - goto readchar; - } else if (c == '*') { - state = C_COMMENT; - goto readchar; - } else { - fprintf (stderr, "unknown token '/' line %d\n", - linenum); - exit (1); - } - } - fprintf (stderr, "unknown token '%c' line %d\n", - c, linenum); - exit (1); - break; - - case CPP_COMMENT: - while (1) { - c = getc (ifp); - if (feof (ifp)) - return (0); - if (c == '\n') { - linenum++; - state = START; - goto readchar; - } - } - break; - - case C_COMMENT: - while (1) { - c = getc (ifp); - if (feof (ifp)) { - fprintf (stderr, "unterminated comment, line %d\n", - linenum); - exit (1); - } - if (c == '*') { - staragain: - c = getc (ifp); - if (c == '/') { - state = START; - goto readchar; - } - if (c == '*') - goto staragain; - } - } - break; - - case READNAME: - i = 0; - namebuf[i++] = c; - while (1) { - c = getc (ifp); - if (feof (ifp)) { - fprintf (stderr, "EOF while reading a name, line %d\n", - linenum); - exit (1); - } - if ((!isalnum (c)) && (c != '_')) { - namebuf [i] = 0; - state = READVALUE; - goto again; - } - namebuf [i++] = c; - } - break; - - case READVALUE: - i = 0; - while ((c == ' ') || (c == '\t') || (c == '=')) { - c = getc (ifp); - if (feof (ifp)) { - fprintf (stderr, "EOF while reading a value, line %d\n", - linenum); - exit (1); - } - } - goto firsttime; - while (1) { - c = getc (ifp); - - firsttime: - if (c == '\\') { - c = getc (ifp); - if (feof (ifp)) { - fprintf (stderr, "EOF after '\\', line %d\n", - linenum); - exit (1); - } - valbuf[i++] = c; - continue; - } - if (c == '\n') { - linenum++; - while (valbuf [i-1] == ' ' || valbuf[i-1] == '\t') - i--; - valbuf[i] = 0; - addprop (namebuf, valbuf); - state = START; - goto readchar; - } - valbuf[i++] = c; - } - - } - } -} diff --git a/g2/props.h b/g2/props.h deleted file mode 100644 index 6289941d..00000000 --- a/g2/props.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - *------------------------------------------------------------------ - * Copyright (c) 1997-2016 Cisco and/or its affiliates. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -extern char *getprop (char *name); -extern char *getprop_default (char *name, char *def); -extern void addprop (char *name, char *value); -extern int readprops (char *filename); -extern int writeprops (char *filename); diff --git a/g2/view1.c b/g2/view1.c deleted file mode 100644 index ec394cc3..00000000 --- a/g2/view1.c +++ /dev/null @@ -1,3077 +0,0 @@ -/* - *------------------------------------------------------------------ - * Copyright (c) 2005-2016 Cisco and/or its affiliates. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include -#include -#include "g2.h" -#include -#include -#include -#include - -/* - * The main event display view. - * - * Important variables: - * - * "da" -- the drawing area, aka the screen representation of the - * event view. - * - * "pm" -- the backing pixmap for the drawing area. Note that - * all graphics operations target this backing - * store, then call gtk_widget_draw to copy a rectangle from - * the backing store onto the screen. - * - * "s_v1" -- pointer to the current v1_geometry_t object. - * - * Box heirarchy: - * s_view1_vbox - * s_view1_hbox - * da s_view1_vmenubox - * s_view1_topbutton("Top") - * s_view1_vscroll (vertical scrollbar) - * s_view1_bottombutton("Bottom") - * s_view1_hmenubox - * s_view1_startbutton("Start"); - * s_view1_hscroll(horizontal scrollbar) - * s_view1_endbutton("End") - * s_view1_zoominbutton("Zoomin") - * s_view1_searchbutton("Search") - * s_view1_searchagainbutton("Search Again") - * s_view1_zoomoutbutton("Zoomout") - * s_view1_label - */ - -/* - * Globals - */ - -GdkFont *g_font; /* a fixed-width font to use */ -GdkColor fg_black = {0, 0, 0, 0}; -GdkColor bg_white = {0, 65535, 65535, 65535}; -static boolean summary_mode = TRUE; /* start out in summary mode */ -static boolean color_mode = FALSE; /* start out in color mode */ - -/* - * Locals - */ - -/* - * user_data values passed to view1_button_click_callback, - * which is used by the various action buttons noted above - */ -enum view1_button_click { - TOP_BUTTON=1, - BOTTOM_BUTTON, - START_BUTTON, - ZOOMIN_BUTTON, - SEARCH_BUTTON, - SEARCH_AGAIN_BUTTON, - ZOOMOUT_BUTTON, - END_BUTTON, - MORE_TRACES_BUTTON, - LESS_TRACES_BUTTON, - SNAP_BUTTON, - NEXT_BUTTON, - DEL_BUTTON, - CHASE_EVENT_BUTTON, - CHASE_DATUM_BUTTON, - CHASE_TRACK_BUTTON, - UNCHASE_BUTTON, - FORWARD_BUTTON, - BACKWARD_BUTTON, - SUMMARY_BUTTON, - NOSUMMARY_BUTTON, -}; - -enum chase_mode { - CHASE_EVENT=1, - CHASE_DATUM, - CHASE_TRACK, -}; - -enum sc_dir { - SRCH_CHASE_FORWARD = 0, - SRCH_CHASE_BACKWARD = 1, -}; - -static GtkWidget *s_view1_hbox; /* see box heirarchy chart */ -static GtkWidget *s_view1_vbox; /* see box heirarchy chart */ -static GtkWidget *da; /* main drawing area */ -static GdkPixmap *pm; /* and its backing pixmap */ -static GdkCursor *norm_cursor; /* the "normal" cursor */ - -/* - * view geometry parameters - * - * Remember: - * Y increases down the page. - * Strip origin is at the top - * Payday is Friday - * Don't put your fingers in your mouth. - * - * Most of these values are in pixels - */ - -typedef struct v1_geometry { - int pid_ax_width; /* Width of the PID axis */ - int time_ax_height; /* Height of the time axis */ - int time_ax_spacing; /* TimeAxis: Space between tick-marks */ - int strip_height; /* Height of a regular PID trace */ - int pop_offset; /* Vertical offset of the detail box */ - int pid_ax_offset; /* Vertical offset of the PID axis */ - int event_offset; /* Vertical offset of the event boxes */ - int total_height; /* total height of da, see configure_event */ - int total_width; /* ditto, for width */ - - /* Derived values */ - int first_pid_index; /* Index of first displayed PID */ - int npids; /* Max number of displayed pids */ - ulonglong minvistime; /* in usec */ - ulonglong maxvistime; /* in usec */ -} v1_geometry_t; - - -/* The active geometry object */ -static v1_geometry_t s_v1record; -static v1_geometry_t *s_v1 = &s_v1record; - -/* The color array */ -static GdkColor *s_color; - -/* Snapshot ring */ -typedef struct snapshot { - struct snapshot *next; - /* Screen geometry */ - v1_geometry_t geometry; - boolean show_event[NEVENTS]; - pid_sort_t *pidvec; - /* - * Note: not worth recomputing the vertical scrollbar, just save - * its value here - */ - gfloat vscroll_value; - boolean summary_mode; - boolean color_mode; -} snapshot_t; - -static snapshot_t *s_snapshots; -static snapshot_t *s_cursnap; -static event_t *s_last_selected_event; - -/* - * various widgets, see the box heirarchy chart above - * The toolkit keeps track of these things, we could lose many of - * these pointers. - */ -static GtkWidget *s_view1_vmenubox; -static GtkWidget *s_view1_topbutton; -static GtkWidget *s_view1_bottombutton; -static GtkWidget *s_view1_more_traces_button; -static GtkWidget *s_view1_less_traces_button; - -static GtkWidget *s_view1_hmenubox; -static GtkWidget *s_view1_hmenubox2; -static GtkWidget *s_view1_startbutton; -static GtkWidget *s_view1_zoominbutton; -static GtkWidget *s_view1_searchbutton; -static GtkWidget *s_view1_srchagainbutton; -static GtkWidget *s_view1_zoomoutbutton; -static GtkWidget *s_view1_endbutton; - -static GtkWidget *s_view1_snapbutton; -static GtkWidget *s_view1_nextbutton; -static GtkWidget *s_view1_delbutton; - -static GtkWidget *s_view1_chase_event_button; -static GtkWidget *s_view1_chase_datum_button; -static GtkWidget *s_view1_chase_track_button; -static GtkWidget *s_view1_unchasebutton; - -static GtkWidget *s_view1_forward_button; -static GtkWidget *s_view1_backward_button; - -static GtkWidget *s_view1_summary_button; -static GtkWidget *s_view1_nosummary_button; - -static GtkWidget *s_view1_hscroll; -static GtkObject *s_view1_hsadj; - -static GtkWidget *s_view1_vscroll; -static GtkObject *s_view1_vsadj; - -static GtkWidget *s_view1_label; - -/* - * Search context - */ -static ulong s_srchcode; /* search event code */ -static int s_srchindex; /* last hit was at this event index */ -static boolean s_result_up; /* The SEARCH RESULT dongle is displayed */ -static boolean s_srchfail_up; /* The status line "Search Failed" is up */ -static int srch_chase_dir; /* search/chase dir, 0=>forward */ - - -/* - * Print context - */ -static int s_print_offset; /* Magic offset added to line, tbox fn codes */ -static FILE *s_printfp; - -/* - * Forward reference prototypes - */ -static void display_pid_axis(v1_geometry_t *vp); -static void display_event_data(v1_geometry_t *vp); -static void display_time_axis(v1_geometry_t *vp); -static void view1_button_click_callback(GtkButton *item, gpointer data); - -/* - * config params - */ - -gint c_view1_draw_width; -gint c_view1_draw_height; - -/* - * Zoom-In / Time Ruler cursor - */ - -#define zi_width 32 -#define zi_height 32 -#define zi_x_hot 22 -#define zi_y_hot 14 -static unsigned char zi_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, - 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, - 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, - 0x00, 0x00, 0x82, 0x00, 0x00, 0x00, 0x84, 0x00, 0x00, 0x00, 0x88, 0x00, - 0x00, 0x00, 0x90, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x00, 0x00, 0xc0, 0x00, - 0x00, 0xfc, 0xff, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0xa0, 0x00, - 0x00, 0x00, 0x90, 0x00, 0x00, 0x00, 0x88, 0x00, 0x00, 0x00, 0x84, 0x00, - 0x00, 0x00, 0x82, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, - 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, - 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; - -static unsigned char zi_bkgd[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, - 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, - 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, - 0x00, 0x00, 0x82, 0x00, 0x00, 0x00, 0x84, 0x00, 0x00, 0x00, 0x88, 0x00, - 0x00, 0x00, 0x90, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x00, 0x00, 0xc0, 0x00, - 0x00, 0xfc, 0xff, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0xa0, 0x00, - 0x00, 0x00, 0x90, 0x00, 0x00, 0x00, 0x88, 0x00, 0x00, 0x00, 0x84, 0x00, - 0x00, 0x00, 0x82, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, - 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, - 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; - -static GdkCursor *zi_cursor; -static GdkPixmap *zi_source, *zi_mask; - -/* - * Frequently-used small computations, best - * done correctly once and instantiated. - */ - -/**************************************************************************** -* dtime_per_pixel -****************************************************************************/ - -static inline double dtime_per_pixel(v1_geometry_t *vp) -{ - return ((double)(vp->maxvistime - vp->minvistime)) / - ((double)(vp->total_width - vp->pid_ax_width)); -} - -/**************************************************************************** -* message_line -* Changes the status line. Pass "" to clear the status line. -****************************************************************************/ - -void message_line (char *s) -{ - gtk_label_set_text (GTK_LABEL(s_view1_label), s); -} - -/**************************************************************************** -* set_window_title -* Changes the window title to include the specified filename. -****************************************************************************/ - -void set_window_title (const char *filename) -{ - char title[128]; - snprintf(title, sizeof(title), "g2 (%s)", filename); - gtk_window_set_title(GTK_WINDOW(g_mainwindow), title); -} - -/**************************************************************************** -* recompute_hscrollbar -* Adjust the horizontal scrollbar's adjustment object. -* -* GtkAdjustments are really cool, but have to be set up exactly -* right or the various client objects screw up completely. -* -* Note: this function is *not* called when the user clicks the scrollbar. -****************************************************************************/ - -static void recompute_hscrollbar (void) -{ - ulonglong current_width; - ulonglong event_incdec; - GtkAdjustment *adj; - event_t *ep; - - if (g_nevents == 0) - return; - - ep = (g_events + (g_nevents-1)); - current_width = s_v1->maxvistime - s_v1->minvistime; - event_incdec = (current_width) / 6; - - adj = GTK_ADJUSTMENT(s_view1_hsadj); - - /* - * Structure member decoder ring - * ----------------------------- - * lower the minimum possible value - * value the current value - * upper the maximum possible value - * step_increment end button click increment - * page_increment click in trough increment - * page_size size of currently visible area - */ - - adj->lower = (gfloat)0.00; - adj->value = (gfloat)s_v1->minvistime; - - /* Minor click: move about 1/6 of a page */ - adj->step_increment = (gfloat)event_incdec; - - /* Major click: move about 1/3 of a page. */ - adj->page_increment = (gfloat)(2*event_incdec); - - /* allow the user to go a bit past the end */ - adj->upper = adj->page_increment/3 + (gfloat)(ep->time); - adj->page_size = (gfloat)(current_width); - - /* - * Tell all clients (e.g. the visible scrollbar) to - * make themselves look right - */ - gtk_adjustment_changed(adj); - gtk_adjustment_value_changed(adj); -} - -/**************************************************************************** -* recompute_vscrollbar -* Ditto, for the vertical scrollbar -****************************************************************************/ - -static void recompute_vscrollbar (void) -{ - GtkAdjustment *adj; - - adj = GTK_ADJUSTMENT(s_view1_vsadj); - - adj->lower = (gfloat)0.00; - adj->upper = (gfloat)g_npids; - adj->value = (gfloat)0.00; - adj->step_increment = 1.00; - adj->page_increment = (gfloat)(s_v1->npids / 3); - adj->page_size = (gfloat)s_v1->npids; - gtk_adjustment_changed(adj); - gtk_adjustment_value_changed(adj); -} - -/**************************************************************************** -* format_popbox_string -****************************************************************************/ - -elog_main_t elog_main; - -void format_popbox_string (char *tmpbuf, int len, event_t *ep, event_def_t *edp) -{ - char *fp; - -#ifdef NOTDEF - sprintf(tmpbuf,"%d:", ep->code); -#endif - if (ep->flags & EVENT_FLAG_CLIB) { - elog_event_t *eep; - u8 *s; - - eep = get_clib_event (ep->datum); - - s = format (0, "%U", format_elog_event, &elog_main, eep); - memcpy (tmpbuf, s, vec_len(s)); - tmpbuf[vec_len(s)] = 0; - vec_free(s); - return; - } - - snprintf(tmpbuf, len, "%s", edp->name); - fp = edp->format; - /* Make sure there's a real format string. If so, add it */ - while (fp && *fp) { - if (*fp != ' ') { - snprintf(tmpbuf+strlen(tmpbuf), len - strlen(tmpbuf), ": "); - /* %s only supported for cpel files */ - if (fp[1] == 's') { - snprintf(tmpbuf+strlen(tmpbuf), len - strlen(tmpbuf), - edp->format, strtab_ref(ep->datum)); - } else { - snprintf(tmpbuf+strlen(tmpbuf), len - strlen(tmpbuf), - edp->format, ep->datum); - } - return; - } - fp++; - } -} - -/**************************************************************************** - * add_snapshot - ****************************************************************************/ - -static void add_snapshot(void) -{ - int i; - snapshot_t *new = g_malloc(sizeof(snapshot_t)); - - memcpy(&new->geometry, s_v1, sizeof(new->geometry)); - for (i = 0; i < NEVENTS; i++) { - new->show_event[i] = g_eventdefs[i].selected; - } - new->pidvec = g_malloc(sizeof(pid_sort_t)*g_npids); - memcpy(new->pidvec, g_pids, sizeof(pid_sort_t)*g_npids); - new->vscroll_value = GTK_ADJUSTMENT(s_view1_vsadj)->value; - new->summary_mode = summary_mode; - new->color_mode = color_mode; - - if (s_snapshots) { - new->next = s_snapshots; - s_snapshots = new; - } else { - new->next = 0; - s_snapshots = new; - } - s_cursnap = new; -} - -/**************************************************************************** - * next_snapshot - ****************************************************************************/ - -static void next_snapshot(void) -{ - snapshot_t *next; - int i; - pid_sort_t *psp; - pid_data_t *pp; - - if (!s_snapshots) { - infobox("No snapshots", "\nNo snapshots in the ring...\n"); - return; - } - - next = s_cursnap->next; - if (next == 0) - next = s_snapshots; - - s_cursnap = next; - - memcpy(s_v1, &next->geometry, sizeof(next->geometry)); - for (i = 0; i < NEVENTS; i++) { - g_eventdefs[i].selected = next->show_event[i]; - } - memcpy(g_pids, next->pidvec, sizeof(pid_sort_t)*g_npids); - color_mode = next->color_mode; - /* - * Update summary mode via a button push so that the button state is - * updated accordingly. (Should ideally clean up the view/controller - * separation properly one day.) - */ - if (summary_mode != next->summary_mode) { - view1_button_click_callback - (NULL, (gpointer)(unsigned long long) - (summary_mode ? NOSUMMARY_BUTTON : SUMMARY_BUTTON)); - } - - /* Fix the pid structure index mappings */ - psp = g_pids; - - for (i = 0; i < g_npids; i++) { - pp = psp->pid; - pp->pid_index = i; - psp++; - } - GTK_ADJUSTMENT(s_view1_vsadj)->value = next->vscroll_value; - gtk_adjustment_value_changed(GTK_ADJUSTMENT(s_view1_vsadj)); - recompute_hscrollbar(); - pointsel_next_snapshot(); - view1_display_when_idle(); -} - - -/**************************************************************************** - * del_snapshot - ****************************************************************************/ - -static void del_snapshot(void) -{ - snapshot_t *prev; - snapshot_t *this; - - if (!s_snapshots) { - infobox("No snapshots", "\nNo snapshots to delete...\n"); - return; - } - - prev = NULL; - this = s_snapshots; - - while (this && this != s_cursnap) { - prev = this; - this = this->next; - } - - if (this != s_cursnap) { - infobox("BUG", "\nSnapshot AWOL!\n"); - return; - } - - s_cursnap = this->next; - - /* middle of the list? */ - if (prev) { - prev->next = this->next; - g_free(this->pidvec); - g_free(this); - } else { /* start of the list */ - s_snapshots = this->next; - g_free(this->pidvec); - g_free(this); - } - - /* Note: both will be NULL after last delete */ - if (s_cursnap == NULL) - s_cursnap = s_snapshots; -} - -/**************************************************************************** - * write_snapshot - * - * VERY primitive right now - not endian or version independent, and only - * writes to "snapshots.g2" in the current directory - ****************************************************************************/ -static void write_snapshot(void) -{ - FILE *file = NULL; - snapshot_t *snap; - char *error = NULL; - int records = 0; - - if (s_snapshots == NULL) { - error = "No snapshots defined"; - errno = 0; - } - - if (!error) { - file = fopen("snapshots.g2", "w"); - if (file == NULL) { - error = "Unable to open snapshots.g2"; - } - } - - /* - * Simply serialize the arch-dependent binary data, without a care in the - * world. Don't come running to me if you try to read it and crash. - */ - for (snap = s_snapshots; !error && snap != NULL; snap = snap->next) { - if (fwrite(&snap->geometry, - sizeof(snap->geometry), 1, file) != 1 || - fwrite(&snap->show_event, - sizeof(snap->show_event), 1, file) != 1 || - fwrite(snap->pidvec, - sizeof(pid_sort_t) * g_npids, 1, file) != 1 || - fwrite(&snap->vscroll_value, - sizeof(snap->vscroll_value), 1, file) != 1 || - fwrite(&snap->summary_mode, - sizeof(snap->summary_mode), 1, file) != 1 || - fwrite(&snap->color_mode, - sizeof(snap->color_mode), 1, file) != 1) { - error = "Error writing data"; - } - records++; - } - - if (!error) { - if (fclose(file)) { - error = "Unable to close file"; - } - } - - if (error) { - infobox(error, strerror(errno)); - } else { - char buf[64]; - snprintf(buf, sizeof(buf), "Wrote %d snapshots to snapshots.g2", - records); - message_line(buf); - } -} - -/**************************************************************************** - * read_snapshot - * - * VERY primitive right now - not endian or version independent, and only reads - * from "snapshots.g2" in the current directory - ****************************************************************************/ -static void read_snapshot(void) -{ - FILE *file; - snapshot_t *snap, *next_snap; - snapshot_t *new_snaps = NULL; - char *error = NULL; - int len, i, records = 0; - pid_data_t *pp; - - file = fopen("snapshots.g2", "r"); - if (file == NULL) { - error = "Unable to open snapshots.g2"; - } - - /* - * Read in the snapshots and link them together. We insert them backwards, - * but that's tolerable. If the data is in anyway not what we expect, we'll - * probably crash. Sorry. - */ - while (!error && !feof(file)) { - snap = g_malloc(sizeof(*snap)); - snap->pidvec = NULL; /* so we can free this if there's an error */ - - len = fread(&snap->geometry, sizeof(snap->geometry), 1, file); - if (len == 0) { - /* EOF */ - g_free(snap); - break; - } else { - /* insert into list straight away */ - snap->next = new_snaps; - new_snaps = snap; - } - if (len != 1) { - error = "Problem reading first item from file"; - break; - } - if (fread(&snap->show_event, sizeof(snap->show_event), 1, file) != 1) { - error = "Problem reading second item from file"; - break; - } - len = sizeof(pid_sort_t) * g_npids; - snap->pidvec = g_malloc(len); - if (fread(snap->pidvec, len, 1, file) != 1) { - error = "Problem reading third item from file"; - break; - } - if (fread(&snap->vscroll_value, - sizeof(snap->vscroll_value), 1, file) != 1 || - fread(&snap->summary_mode, - sizeof(snap->summary_mode), 1, file) != 1 || - fread(&snap->color_mode, - sizeof(snap->color_mode), 1, file) != 1) { - error = "Problem reading final items from file"; - break; - } - - /* - * Fix up the pointers from the sorted pid vector back into our pid - * data objects, by walking the linked list of pid_data_t objects for - * every one looking for a match. This is O(n^2) grossness, but in real - * life there aren't that many pids, and it seems zippy enough. - */ - for (i = 0; i < g_npids; i++) { - for (pp = g_pid_data_list; pp != NULL; pp = pp->next) { - if (pp->pid_value == snap->pidvec[i].pid_value) { - break; - } - } - if (pp != NULL) { - snap->pidvec[i].pid = pp; - } else { - error = "Snapshot file referenced unknown pids"; - break; - } - } - - records++; - } - - if (!error) { - if (fclose(file)) { - error = "Unable to close file"; - } - } - - if (error) { - /* - * Problem - clear up any detritus - */ - infobox(error, strerror(errno)); - for (snap = new_snaps; snap != NULL; snap = next_snap) { - next_snap = snap->next; - g_free(snap); - g_free(snap->pidvec); - } - } else { - /* - * Success! trash the old snapshots and replace with the new - */ - for (snap = s_snapshots; snap != NULL; snap = next_snap) { - next_snap = snap->next; - g_free(snap->pidvec); - g_free(snap); - } - - s_cursnap = s_snapshots = new_snaps; - } - - if (error) { - infobox(error, strerror(errno)); - } else { - char buf[64]; - snprintf(buf, sizeof(buf), - "Read %d snapshots from snapshots.g2", records); - message_line(buf); - } -} - -/**************************************************************************** -* set_color -* -* Set the color for the specified pid_index, or COLOR_DEFAULT to return it -* to the usual black. -****************************************************************************/ -#define COLOR_DEFAULT (-1) -static void set_color(int pid_index) -{ - if (pid_index == COLOR_DEFAULT || !color_mode) { - gdk_gc_set_foreground(da->style->black_gc, &fg_black); - } else { - gdk_gc_set_foreground(da->style->black_gc, - &s_color[g_pids[pid_index].color_index]); - } -} - -/**************************************************************************** -* toggle_event_select -****************************************************************************/ - -static void toggle_event_select(GdkEventButton *event, v1_geometry_t *vp) -{ - int pid_index, start_index; - int x, y; - GdkRectangle *rp; - GdkRectangle hit_rect; - GdkRectangle dummy; - event_t *ep; - event_def_t *edp; - char tmpbuf [1024]; - double time_per_pixel; - - if (g_nevents == 0) - return; - - time_per_pixel = dtime_per_pixel(vp); - - start_index = find_event_index (vp->minvistime); - - /* Too far right? */ - if (start_index >= g_nevents) - return; - - /* - * To see if the mouse hit a visible event, use a variant - * of the event display loop. - */ - - hit_rect.x = (int)event->x; - hit_rect.y = (int)event->y; - hit_rect.width = 1; - hit_rect.height = 1; - - ep = (g_events + start_index); - - while ((ep->time < vp->maxvistime) && - (ep < (g_events + g_nevents))) { - pid_index = ep->pid->pid_index; - - /* First filter: pid out of range */ - if ((pid_index < vp->first_pid_index) || - (pid_index >= vp->first_pid_index + vp->npids)) { - ep++; - continue; - } - - /* Second filter: event hidden */ - edp = find_event_definition (ep->code); - if (!edp->selected) { - ep++; - continue; - } - - /* - * At this point, we know that the point is at least on the - * screen. See if the mouse hit within the bounding box - */ - - /* - * $$$$ maybe keep looping until off the edge, - * maintain a "best hit", then declare that one the winner? - */ - - pid_index -= vp->first_pid_index; - - y = pid_index*vp->strip_height + vp->event_offset; - - x = vp->pid_ax_width + - (int)(((double)(ep->time - vp->minvistime)) / time_per_pixel); - - /* Perhaps we're trying to toggle the detail box? */ - if (ep->flags & EVENT_FLAG_SELECT) { - /* Figure out the dimensions of the detail box */ - format_popbox_string(tmpbuf, sizeof(tmpbuf), ep, edp); - rp = tbox(tmpbuf, x, y - vp->pop_offset, TBOX_GETRECT_BOXED); - if (gdk_rectangle_intersect(rp, &hit_rect, &dummy)) { - ep->flags &= ~EVENT_FLAG_SELECT; - view1_display_when_idle(); - break; - } - } - - sprintf(tmpbuf, "%ld", ep->code); - - /* Figure out the dimensions of the regular box */ - rp = tbox(tmpbuf, x, y, TBOX_GETRECT_EVENT); - - if (gdk_rectangle_intersect(rp, &hit_rect, &dummy)) { - /* we hit the rectangle. */ - if (ep->flags & EVENT_FLAG_SELECT) { - ep->flags &= ~EVENT_FLAG_SELECT; - view1_display_when_idle(); - break; - } else { - set_color(ep->pid->pid_index); - - /* It wasn't selected, so put up the detail box */ - format_popbox_string(tmpbuf, sizeof(tmpbuf), ep, edp); - tbox(tmpbuf, x, y - vp->pop_offset, TBOX_DRAW_BOXED); - line(x, y-vp->pop_offset, x, y, LINE_DRAW_BLACK); - ep->flags |= EVENT_FLAG_SELECT; - ep->flags &= ~EVENT_FLAG_SEARCHRSLT; - s_last_selected_event = ep; - } - break; - } - ep++; - } -} - -/**************************************************************************** -* move_current_track -****************************************************************************/ - -typedef enum { MOVE_TOP, MOVE_BOTTOM } move_type; - -static void move_current_track(GdkEventButton *event, - v1_geometry_t *vp, - move_type type) -{ - int i; - int pid_index; - int y, delta_y; - pid_sort_t *new_pidvec; - pid_sort_t *psp; - pid_sort_t *pold, *pnew; - pid_data_t *pp; - - if (g_nevents == 0) - return; - - /* Scan pid/track axis locations, looking for a match */ - for (i = 0; i < vp->npids; i++) { - y = i*vp->strip_height + vp->pid_ax_offset; - delta_y = y - event->y; - if (delta_y < 0) - delta_y = -delta_y; - if (delta_y < 10) { - goto found; - } - - } - infobox("NOTE", "\nNo PID/Track In Range\nPlease Try Again"); - return; - - found: - pid_index = i + vp->first_pid_index; - - new_pidvec = g_malloc(sizeof(pid_sort_t)*g_npids); - pold = g_pids; - pnew = new_pidvec; - - if (type == MOVE_TOP) { - /* move to top */ - *pnew++ = g_pids[pid_index]; - for (i = 0; i < pid_index; i++) - *pnew++ = *pold++; - pold++; - i++; - for (; i < g_npids; i++) - *pnew++ = *pold++; - } else { - /* move to bottom */ - for (i = 0; i < pid_index; i++) - *pnew++ = *pold++; - pold++; - i++; - for (; i < g_npids; i++) - *pnew++ = *pold++; - *pnew = g_pids[pid_index]; - } - - g_free(g_pids); - g_pids = new_pidvec; - - /* - * Revert the pid_index mapping to an identity map, - */ - psp = g_pids; - - for (i = 0; i < g_npids; i++) { - pp = psp->pid; - pp->pid_index = i; - psp++; - } - view1_display_when_idle(); -} - -/**************************************************************************** -* zoom_event -* Process a zoom gesture. The use of doubles is required to avoid -* truncating the various variable values, which in turn would lead to -* some pretty random-looking zoom responses. -****************************************************************************/ - -void zoom_event(GdkEventButton *e1, GdkEventButton *e2, v1_geometry_t *vp) -{ - double xrange; - double time_per_pixel; - double width_in_pixels; - double center_on_time, width_in_time; - double center_on_pixel; - - /* - * Clip the zoom area to the event display area. - * Otherwise, center_on_time - width_in_time is in hyperspace - * to the left of zero - */ - - if (e1->x < vp->pid_ax_width) - e1->x = vp->pid_ax_width; - - if (e2->x < vp->pid_ax_width) - e2->x = vp->pid_ax_width; - - if (e2->x == e1->x) - goto loser_zoom_repaint; - - xrange = (double) (e2->x - e1->x); - if (xrange < 0.00) - xrange = -xrange; - - /* Actually, width in pixels of half the zoom area */ - width_in_pixels = xrange / 2.00; - time_per_pixel = dtime_per_pixel(vp); - width_in_time = width_in_pixels * time_per_pixel; - - /* Center the screen on the center of the zoom area */ - center_on_pixel = (double)((e2->x + e1->x) / 2.00) - - (double)vp->pid_ax_width; - center_on_time = center_on_pixel*time_per_pixel + (double)vp->minvistime; - - /* - * Transform back to 64-bit integer microseconds, reset the - * scrollbar, schedule a repaint. - */ - vp->minvistime = (ulonglong)(center_on_time - width_in_time); - vp->maxvistime = (ulonglong)(center_on_time + width_in_time); - -loser_zoom_repaint: - recompute_hscrollbar(); - - view1_display_when_idle(); -} - -/**************************************************************************** -* scroll_y -* -* Scroll up or down by the specified delta -* -****************************************************************************/ -static void scroll_y(int delta) -{ - int new_index = s_v1->first_pid_index + delta; - if (new_index + s_v1->npids > g_npids) - new_index = g_npids - s_v1->npids; - if (new_index < 0) - new_index = 0; - - if (new_index != s_v1->first_pid_index) { - s_v1->first_pid_index = new_index; - GTK_ADJUSTMENT(s_view1_vsadj)->value = (gdouble)new_index; - gtk_adjustment_value_changed(GTK_ADJUSTMENT(s_view1_vsadj)); - view1_display_when_idle(); - } -} - -/**************************************************************************** -* view1_handle_key_press_event -* Relevant definitions in: /usr/include/gtk-1.2/gdk/gdktypes.h -* -* This routine implements hotkeys for the Quake generation: -* -* W - zoom in -* S - zoom out -* A - pan left -* D - pan right -* R - pan up -* F - pan down -* T - more traces -* G - fewer traces -* -* E - toggle summary mode -* C - toggle color mode -* -* X - take snapshot -* Z - next snapshot -* P - persist snapshots to file -* L - load snapshots from file -* -* ctrl-Q - exit -* -****************************************************************************/ -gint -view1_handle_key_press_event (GtkWidget *widget, GdkEventKey *event) -{ - long long delta; - - switch (event->keyval) { - case GDK_w: // zoom in - view1_button_click_callback(NULL, (gpointer)ZOOMIN_BUTTON); - break; - - case GDK_s: // zoom out - view1_button_click_callback(NULL, (gpointer)ZOOMOUT_BUTTON); - break; - - case GDK_a: // pan left - delta = (s_v1->maxvistime - s_v1->minvistime) / 6; - if (s_v1->minvistime < delta) { - delta = s_v1->minvistime; - } - s_v1->minvistime -= delta; - s_v1->maxvistime -= delta; - recompute_hscrollbar(); - break; - - case GDK_d: // pan right - delta = (s_v1->maxvistime - s_v1->minvistime) / 6; - if (s_v1->maxvistime + delta > g_events[g_nevents - 1].time) { - /* - * @@@ this doesn't seem to quite reach the far right hand - * side correctly - not sure why. - */ - delta = g_events[g_nevents - 1].time - s_v1->maxvistime; - } - s_v1->minvistime += delta; - s_v1->maxvistime += delta; - recompute_hscrollbar(); - break; - - case GDK_r: // pan up - scroll_y(-1); - break; - - case GDK_f: // pan down - scroll_y(+1); - break; - - case GDK_t: // fewer tracks - view1_button_click_callback(NULL, (gpointer)LESS_TRACES_BUTTON); - break; - - case GDK_g: // more tracks - view1_button_click_callback(NULL, (gpointer)MORE_TRACES_BUTTON); - break; - - case GDK_e: // toggle summary mode - view1_button_click_callback - (NULL, (gpointer)(unsigned long long) - (summary_mode ? NOSUMMARY_BUTTON : SUMMARY_BUTTON)); - break; - - case GDK_c: // toggle color mode - color_mode ^= 1; - view1_display_when_idle(); - break; - - case GDK_p: // persist snapshots - write_snapshot(); - break; - - case GDK_l: // load snapshots - read_snapshot(); - break; - - case GDK_x: // take snapshot - view1_button_click_callback(NULL, (gpointer)SNAP_BUTTON); - break; - - case GDK_z: // next snapshot - view1_button_click_callback(NULL, (gpointer)NEXT_BUTTON); - break; - - case GDK_q: // ctrl-q is exit - if (event->state & GDK_CONTROL_MASK) { - gtk_main_quit(); - } - break; - } - return TRUE; -} - -/**************************************************************************** -* button_press_event -* Relevant definitions in: /usr/include/gtk-1.2/gdk/gdktypes.h -* -* This routine implements three functions: zoom-to-area, time ruler, and -* show/hide event detail popup. -* -* The left mouse button (button 1) has two simultaneous functions: event -* detail popup, and zoom-to-area. If the press and release events occur -* within a small delta-x, it's a detail popup event. Otherwise, it's -* an area zoom. -* -* The right mouse button (button 3) implements the time ruler. -****************************************************************************/ - -static gint -button_press_event (GtkWidget *widget, GdkEventButton *event) -{ - static GdkEventButton press1_event; - static boolean press1_valid; - static GdkEventButton press3_event; - static guint32 last_truler_time; - static boolean press3_valid; - static boolean zoom_bar_up; - int time_ax_y, xdelta; - char tmpbuf [128]; - double time_per_pixel; - - time_ax_y = 0; - - switch(event->type) { - case GDK_BUTTON_PRESS: - /* Capture the appropriate starting point */ - if (event->button == 1) { - press1_valid = TRUE; - press1_event = *event; - return(TRUE); - } - if (event->button == 3) { - press3_valid = TRUE; - press3_event = *event; - return(TRUE); - } - return(TRUE); - - case GDK_BUTTON_RELEASE: - /* Time ruler */ - if (press3_valid) { - press3_valid = FALSE; - /* Fix the cursor, and repaint the screen from scratch */ - gdk_window_set_cursor (da->window, norm_cursor); - view1_display_when_idle(); - return(TRUE); - } - /* Event select / zoom-to-area */ - if (press1_valid) { - press1_valid = FALSE; - xdelta = (int)(press1_event.x - event->x); - if (xdelta < 0) - xdelta = -xdelta; - - /* is the mouse more or less where it started? */ - if (xdelta < 10) { - /* Control-left-mouse => sink the track */ - /* Shift-left-mouse => raise the track */ - if ((press1_event.state & GDK_CONTROL_MASK) == - GDK_CONTROL_MASK) { - move_current_track(event, s_v1, MOVE_BOTTOM); - } else if ((press1_event.state & GDK_SHIFT_MASK) == - GDK_SHIFT_MASK) { - move_current_track(event, s_v1, MOVE_TOP); - } else { - /* No modifiers: toggle the event */ - toggle_event_select(event, s_v1); - } - /* Repaint to get rid of the zoom bar */ - if (zoom_bar_up) { - /* Fix the cursor and leave. No zoom */ - gdk_window_set_cursor (da->window, norm_cursor); - zoom_bar_up = FALSE; - break; - } - } else { /* mouse moved enough to zoom */ - zoom_event(&press1_event, event, s_v1); - gdk_window_set_cursor (da->window, norm_cursor); - zoom_bar_up = FALSE; - } - } else if (event->button == 4) { - /* scroll wheel up */ - scroll_y(event->state & GDK_SHIFT_MASK ? -10 : -1); - } else if (event->button == 5) { - /* scroll wheel down */ - scroll_y(event->state & GDK_SHIFT_MASK ? +10 : +1); - } - return(TRUE); - - case GDK_MOTION_NOTIFY: - /* Button one followed by motion: draw zoom fence and fix cursor */ - if (press1_valid) { - /* Fence, cursor already set */ - if (zoom_bar_up) - return(TRUE); - - xdelta = (int)(press1_event.x - event->x); - if (xdelta < 0) - xdelta = -xdelta; - - /* Haven't moved enough to declare a zoom sequence yet */ - if (xdelta < 10) - return(TRUE); - - /* Draw the zoom fence, use the key-down X coordinate */ - time_ax_y = s_v1->npids * s_v1->strip_height + s_v1->pid_ax_offset; - - line((int)(press1_event.x), s_v1->pop_offset, - (int)(press1_event.x), time_ax_y, LINE_DRAW_BLACK); - tbox("Zoom From Here...", (int)(press1_event.x), s_v1->pop_offset, - TBOX_DRAW_BOXED); - gdk_window_set_cursor(da->window, zi_cursor); - zoom_bar_up = TRUE; - return(TRUE); - } - if (press3_valid) { - double nsec; - - gdk_window_set_cursor(da->window, zi_cursor); - - /* - * Some filtration is needed on Solaris, or the server will hang - */ - if (event->time - last_truler_time < 75) - return(TRUE); - - last_truler_time = event->time; - - line((int)(press3_event.x), s_v1->pop_offset, - (int)(press3_event.x), time_ax_y, LINE_DRAW_BLACK); - - xdelta = (int)(press3_event.x - event->x); - if (xdelta < 0) - xdelta = -xdelta; - - time_per_pixel = ((double)(s_v1->maxvistime - s_v1->minvistime)) / - ((double)(s_v1->total_width - s_v1->pid_ax_width)); - - time_ax_y = s_v1->npids * s_v1->strip_height + s_v1->pid_ax_offset; - - line((int)(press3_event.x), s_v1->pop_offset, - (int)(press3_event.x), time_ax_y, LINE_DRAW_BLACK); - /* - * Note: use a fixed-width format so it looks like we're - * erasing and redrawing the box. - */ - nsec = ((double)xdelta)*time_per_pixel; - if (nsec >1e9) { - sprintf(tmpbuf, "%8.3f sec ", nsec/1e9); - } else if (nsec > 1e6) { - sprintf(tmpbuf, "%8.3f msec", nsec/1e6); - } else if (nsec > 1e3) { - sprintf(tmpbuf, "%8.3f usec", nsec/1e3); - } else { - sprintf(tmpbuf, "%8.0f nsec", nsec); - } - tbox(tmpbuf, (int)(press3_event.x), s_v1->pop_offset, - TBOX_DRAW_BOXED); - return(TRUE); - } - - default: - break; -#ifdef DEBUG - g_print("button:\ttype = %d\n", event->type); - g_print("\twindow = 0x%x\n", event->window); - g_print("\tsend_event = %d\n", event->send_event); - g_print("\ttime = %d\n", event->time); - g_print("\tx = %6.2f\n", event->x); - g_print("\ty = %6.2f\n", event->y); - g_print("\tpressure = %6.2f\n", event->pressure); - g_print("\txtilt = %6.2f\n", event->xtilt); - g_print("\tytilt = %6.2f\n", event->ytilt); - g_print("\tstate = %d\n", event->state); - g_print("\tbutton = %d\n", event->button); - g_print("\tsource = %d\n", event->source); - g_print("\tdeviceid = %d\n", event->deviceid); - g_print("\tx_root = %6.2f\n", event->x_root); - g_print("\ty_root = %6.2f\n", event->y_root); - return(TRUE); -#endif - } - - view1_display_when_idle(); - - return(TRUE); -} - -/**************************************************************************** -* configure_event -* Happens when the window manager resizes the viewer's main window. -****************************************************************************/ - -static gint -configure_event (GtkWidget *widget, GdkEventConfigure *event) -{ - /* Toss the previous drawing area backing store pixmap */ - if (pm) - gdk_pixmap_unref(pm); - - /* Create a new pixmap, paint it */ - pm = gdk_pixmap_new(widget->window, - widget->allocation.width, - widget->allocation.height, - -1); - gdk_draw_rectangle (pm, - widget->style->white_gc, - TRUE, - 0, 0, - widget->allocation.width, - widget->allocation.height); - - /* Reset the view geometry parameters, as required */ - s_v1->total_width = widget->allocation.width; - s_v1->total_height = widget->allocation.height; - s_v1->npids = (s_v1->total_height - s_v1->time_ax_height) / - s_v1->strip_height; - - /* Schedule a repaint */ - view1_display_when_idle(); - return(TRUE); -} - -/**************************************************************************** -* expose_event -* Use backing store to fix the screen. -****************************************************************************/ -static gint expose_event (GtkWidget *widget, GdkEventExpose *event) -{ - gdk_draw_pixmap(widget->window, - widget->style->fg_gc[GTK_WIDGET_STATE (widget)], - pm, - event->area.x, event->area.y, - event->area.x, event->area.y, - event->area.width, event->area.height); - - return(FALSE); -} - -/**************************************************************************** -* event_search_internal -* This routine searches forward from s_srchindex, looking for s_srchcode; -* wraps at the end of the buffer. -****************************************************************************/ - -boolean event_search_internal (void) -{ - event_t *ep; - int i; - int index; - int pid_index; - boolean full_redisplay = FALSE; - ulonglong current_width; - char tmpbuf [64]; - - /* No events yet? Act like the search worked, to avoid a loop */ - if (g_nevents == 0) - return(TRUE); - - ep = (g_events + s_srchindex); - ep->flags &= ~EVENT_FLAG_SEARCHRSLT; - - /* - * Assume the user wants to search [plus or minus] - * from where they are. - */ -#ifdef notdef - if (ep->time < s_v1->minvistime) - s_srchindex = find_event_index (s_v1->minvistime); -#endif - - for (i = 1; i <= g_nevents; i++) { - index = (srch_chase_dir == SRCH_CHASE_BACKWARD) ? - (s_srchindex - i) % g_nevents : - (i + s_srchindex) % g_nevents; - - ep = (g_events + index); - - if (ep->code == s_srchcode) { - if (s_srchfail_up) - message_line(""); - s_srchindex = index; - pid_index = ep->pid->pid_index; - - /* Need a vertical scroll? */ - if ((pid_index < s_v1->first_pid_index) || - (pid_index >= s_v1->first_pid_index + s_v1->npids)) { - if (pid_index > (g_npids - s_v1->npids)) - pid_index = (g_npids - s_v1->npids); - s_v1->first_pid_index = pid_index; - GTK_ADJUSTMENT(s_view1_vsadj)->value = - (gdouble)s_v1->first_pid_index; - gtk_adjustment_value_changed(GTK_ADJUSTMENT(s_view1_vsadj)); - full_redisplay = TRUE; - } - - /* Need a horizontal scroll? */ - if (ep->time < s_v1->minvistime || ep->time > s_v1->maxvistime) { - current_width = (s_v1->maxvistime - s_v1->minvistime); - if (ep->time < ((current_width+1) / 2)) { - s_v1->minvistime = 0ll; - s_v1->maxvistime = current_width; - } else { - s_v1->minvistime = ep->time - ((current_width+1)/2); - s_v1->maxvistime = ep->time + ((current_width+1)/2); - } - recompute_hscrollbar(); - full_redisplay = TRUE; - } - ep->flags |= EVENT_FLAG_SEARCHRSLT; - full_redisplay = TRUE; - -#ifdef NOTDEF - if (!full_redisplay){ - if (!s_result_up) { - s_result_up = TRUE; - time_per_pixel = dtime_per_pixel(s_v1); - - y = pid_index*s_v1->strip_height + s_v1->event_offset; - x = s_v1->pid_ax_width + - (int)(((double)(ep->time - s_v1->minvistime)) / - time_per_pixel); - sprintf(tmpbuf, "SEARCH RESULT"); - tbox(tmpbuf, x, y - s_v1->pop_offset, TBOX_DRAW_BOXED); - line(x, y-s_v1->pop_offset, x, y, LINE_DRAW_BLACK); - } else { - full_redisplay = TRUE; - } - } -#endif - - if (full_redisplay) - view1_display_when_idle(); - return(TRUE); - } - } - sprintf (tmpbuf, "Search for event %ld failed...\n", s_srchcode); - message_line(tmpbuf); - s_srchfail_up = TRUE; - return(TRUE); -} - -/**************************************************************************** -* event_search_callback -****************************************************************************/ - -boolean event_search_callback (char *s) -{ - /* No events yet? Act like the search worked, to avoid a loop */ - if (g_nevents == 0) - return(TRUE); - - s_srchcode = atol(s); - - if (s_srchcode == 0) - return(FALSE); - - return(event_search_internal()); -} - -/**************************************************************************** -* event_search -****************************************************************************/ - -static void event_search (void) -{ - modal_dialog ("Event Search: Please Enter Event Code", - "Invalid: Please Reenter Event Code", NULL, - event_search_callback); -} - -/**************************************************************************** -* init_track_colors -****************************************************************************/ -static void init_track_colors(void) -{ - int i; - unsigned hash; - char *label_char; - unsigned RGB[3]; - gboolean dont_care[g_npids]; - - /* - * If we've already allocated the colors once, then in theory we should - * just be able to re-order the GCs already created to match the new track - * order; the track -> color mapping doesn't currently change at runtime. - * However, it's easier just to allocate everything from fresh. As a nod in - * the direction of politeness towards our poor abused X server, we at - * least mop up the previously allocated GCs first, although in practice - * even omitting this didn't seem to cause a problem. - */ - if (s_color != NULL ) { - gdk_colormap_free_colors(gtk_widget_get_colormap(da), - s_color, g_npids); - memset(s_color, 0, sizeof(GdkColor) * g_npids); - } else { - /* - * First time through: allocate the array to hold the GCs. - */ - s_color = g_malloc(sizeof(GdkColor) * g_npids); - } - - /* - * Go through and assign a color for each track. - */ - for (i = 0; i < g_npids; i++) { - /* - * We compute the color from a hash of the thread name. That way we get - * a distribution of different colors, and the same thread has the same - * color across multiple data sets. Unfortunately, even though the - * process name and thread id are invariant across data sets, the - * process id isn't, so we want to exclude that from the hash. Since - * the pid appears in parentheses after the process name and tid, we - * can just stop at the '(' character. - * - * We could create a substring and use the CLIB Jenkins hash, but given - * we're hashing ascii data, a suitable Bernstein hash is pretty much - * just as good, and it's easiest just to compute it inline. - */ - label_char = get_track_label(g_pids[i].pid_value); - hash = 0; - while (*label_char != '\0' && *label_char != '(') { - hash = hash * 33 + *label_char++; - } - hash += hash >> 5; /* even out the lower order bits a touch */ - - /* - * OK, now we have our hash. We get the color by using the first three - * bytes of the hash for the RGB values (expanded from 8 to 16 bits), - * and then use the fourth byte to choose one of R, G, B and mask this - * one down. This ensures the color can't be too close to white and - * therefore hard to see. - * - * We also drop the top bit of the green, since bright green on its own - * is hard to see against white. Generally we err on the side of - * keeping it dark, rather than using the full spectrum of colors. This - * does result in something of a preponderance of muddy colors and a - * bit of a lack of cheery bright ones, but at least you can read - * everything. It would be nice to do better. - */ - RGB[0] = (hash & 0xff000000) >> 16; - RGB[1] = (hash & 0x007f0000) >> 8; - RGB[2] = (hash & 0x0000ff00); - RGB[hash % 3] &= 0x1fff; - - { - GdkColor color = {0, RGB[0], RGB[1], RGB[2]}; - s_color[i] = color; - g_pids[i].color_index = i; - } - } - - /* - * Actually allocate the colors in one bulk operation. We ignore the return - * values. - */ - gdk_colormap_alloc_colors(gtk_widget_get_colormap(da), - s_color, g_npids, FALSE, TRUE, dont_care); -} - - -/**************************************************************************** -* chase_event_etc -* Reorder the pid_index fields so the viewer "chases" the last selected -* event. -****************************************************************************/ - -static void chase_event_etc(enum chase_mode mode) -{ - pid_sort_t *psp, *new_pidvec; - pid_data_t *pp; - event_t *ep; - int pids_mapped; - ulong code_to_chase; - ulong datum_to_chase; - ulong pid_to_chase; - int i; - int winner; - - if (!s_last_selected_event) { - infobox("No selected event", - "\nPlease select an event and try again...\n"); - return; - } - - /* Clear all index assignments */ - psp = g_pids; - for (i = 0; i < g_npids; i++) { - pp = psp->pid; - pp->pid_index = 0xFFFFFFFF; - psp++; - } - - ep = s_last_selected_event; - code_to_chase = ep->code; - datum_to_chase = ep->datum; - pid_to_chase = ep->pid->pid_value; - pids_mapped = 0; - new_pidvec = g_malloc(sizeof(pid_sort_t)*g_npids); - - while (1) { - if (srch_chase_dir == SRCH_CHASE_FORWARD) { - if (ep >= g_events + g_nevents) - break; - } else { - if (ep < g_events) - break; - } - - winner = 0; - switch(mode) { - case CHASE_EVENT: - if (ep->code == code_to_chase) { - winner = 1; - } - break; - - case CHASE_DATUM: - if (ep->datum == datum_to_chase) { - winner = 1; - } - break; - - case CHASE_TRACK: - if (ep->pid->pid_value == pid_to_chase) { - winner = 1; - } - break; - - default: - infobox("BUG", "unknown mode in chase_event_etc\n"); - break; - } - - if (winner) { - if (ep->pid->pid_index == 0xFFFFFFFF) { - ep->pid->pid_index = pids_mapped; - new_pidvec[pids_mapped].pid = ep->pid; - new_pidvec[pids_mapped].pid_value = ep->pid->pid_value; - new_pidvec[pids_mapped].color_index = 0; - pids_mapped++; - if (pids_mapped == g_npids) - break; - } - } - if (srch_chase_dir == SRCH_CHASE_FORWARD) - ep++; - else - ep--; - } - - /* Pass 2, first-to-last, to collect stragglers */ - ep = g_events; - - while (ep < g_events + g_nevents) { - if (ep->pid->pid_index == 0xFFFFFFFF) { - ep->pid->pid_index = pids_mapped; - new_pidvec[pids_mapped].pid = ep->pid; - new_pidvec[pids_mapped].pid_value = ep->pid->pid_value; - new_pidvec[pids_mapped].color_index = 0; - pids_mapped++; - if (pids_mapped == g_npids) - break; - } - ep++; - } - - if (pids_mapped != g_npids) { - infobox("BUG", "\nDidn't map all pids in chase_event_etc\n"); - } - - g_free (g_pids); - g_pids = new_pidvec; - - /* - * The new g_pids vector contains the "chase" sort, so we revert - * the pid_index mapping to an identity map - */ - psp = g_pids; - - for (i = 0; i < g_npids; i++) { - pp = psp->pid; - pp->pid_index = i; - psp++; - } - - /* AutoScroll the PID axis so we show the first "chased" event */ - s_v1->first_pid_index = 0; - GTK_ADJUSTMENT(s_view1_vsadj)->value = 0.00; - gtk_adjustment_value_changed(GTK_ADJUSTMENT(s_view1_vsadj)); - init_track_colors(); - view1_display_when_idle(); -} - -/**************************************************************************** -* unchase_event_etc -* Copy g_original_pids to g_pids, revert index mapping -****************************************************************************/ -static void unchase_event_etc(void) -{ - int i; - pid_sort_t *psp; - pid_data_t *pp; - - memcpy (g_pids, g_original_pids, sizeof(pid_sort_t)*g_npids); - - /* Fix the pid structure index mappings */ - psp = g_pids; - - for (i = 0; i < g_npids; i++) { - pp = psp->pid; - pp->pid_index = i; - psp++; - } - - /* Scroll PID axis to the top */ - s_v1->first_pid_index = 0; - GTK_ADJUSTMENT(s_view1_vsadj)->value = 0.00; - gtk_adjustment_value_changed(GTK_ADJUSTMENT(s_view1_vsadj)); - init_track_colors(); - view1_display_when_idle(); -} - -/**************************************************************************** -* print_ps_header -* To fit a reasonable-sized landscape mode plot onto letter-size paper, -* scale everything by .75. -****************************************************************************/ - -static void print_ps_header (v1_geometry_t *vp, char *filename) -{ - time_t now; - - now = time(0); - - fprintf(s_printfp, "%%%%!PS-Adobe-3.0 EPSF-3.0\n"); - fprintf(s_printfp, "%%%%Creator: G2 Event Viewer\n"); - fprintf(s_printfp, "%%%%Title: %s\n", filename); - fprintf(s_printfp, "%%%%CreationDate: %s", ctime(&now)); - fprintf(s_printfp, "%%%%DocumentData: Clean7Bit\n"); - fprintf(s_printfp, "%%%%Origin: 0 0\n"); - fprintf(s_printfp, "%%%%BoundingBox: 0 0 %d %d\n", vp->total_height, - vp->total_width); - fprintf(s_printfp, "%%%%LanguageLevel: 2\n"); - fprintf(s_printfp, "%%%%Pages: 1\n"); - fprintf(s_printfp, "%%%%Page: 1 1\n"); - fprintf(s_printfp, "%%%%EOF\n"); - fprintf(s_printfp, "/Times-Roman findfont\n"); - fprintf(s_printfp, "12 scalefont\n"); - fprintf(s_printfp, "setfont\n"); - fprintf(s_printfp, ".75 .75 scale\n"); -} - -/**************************************************************************** -* xrt -* Xcoordinate rotate and translate. We need to emit postscript that -* has a reasonable aspect ratio for printing. To do that, we rotate the -* intended picture by 90 degrees, using the standard 2D rotation -* formula: -* -* Xr = x*cos(theta) - y*sin(theta); -* Yr = x*sin(theta) + y*cos(theta); -* -* If we let theta = 90, this reduces to -* Xr = -y -* Yr = x -* -* Translate back to the origin in X by adding Ymax, yielding -* Xrt = Ymax - y -****************************************************************************/ - -static inline int xrt(int x, int y) -{ - return (s_v1->total_height - y); -} - -static inline int yrt(int x, int y) -{ - return(x); -} - -/**************************************************************************** -* print_screen_callback -****************************************************************************/ - -static boolean print_screen_callback(char *filename) -{ - s_printfp = fopen (filename, "wt"); - - if (s_printfp == NULL) - return(FALSE); - - /* - * This variable allows us to magically turn the view1 display - * code into a print-driver, with a minimum of fuss. The idea is to - * magically change TBOX_DRAW_XXX into TBOX_PRINT_XXX by adding - * the required value, aka s_print_offset. - * Make sure to fix g2.h if you mess here, or vice versa. - */ - s_print_offset = TBOX_PRINT_PLAIN - TBOX_DRAW_PLAIN; - - print_ps_header(s_v1, filename); - - display_pid_axis(s_v1); - display_event_data(s_v1); - display_time_axis(s_v1); - - fclose (s_printfp); - s_printfp = 0; - s_print_offset = 0; - - /* For tactile feedback */ - view1_display_when_idle(); - return(TRUE); -} - -/**************************************************************************** -* view1_button_click_callback -****************************************************************************/ - -static void view1_button_click_callback(GtkButton *item, gpointer data) -{ - enum view1_button_click click = (enum view1_button_click) data; - event_t *ep; - ulonglong event_incdec; - ulonglong current_width; - ulonglong zoom_delta; - - - current_width = s_v1->maxvistime - s_v1->minvistime; - event_incdec = (current_width) / 3; - - if (event_incdec == 0LL) - event_incdec = 1; - - zoom_delta = (s_v1->maxvistime - s_v1->minvistime) / 6; - - switch(click) { - case TOP_BUTTON: - /* First PID to top of window */ - s_v1->first_pid_index = 0; - GTK_ADJUSTMENT(s_view1_vsadj)->value = 0.00; - gtk_adjustment_value_changed(GTK_ADJUSTMENT(s_view1_vsadj)); - break; - - case BOTTOM_BUTTON: - s_v1->first_pid_index = g_npids - s_v1->npids; - if (s_v1->first_pid_index < 0) - s_v1->first_pid_index = 0; - GTK_ADJUSTMENT(s_view1_vsadj)->value = (gdouble)s_v1->first_pid_index; - gtk_adjustment_value_changed(GTK_ADJUSTMENT(s_view1_vsadj)); - break; - - case SNAP_BUTTON: - add_snapshot(); - break; - - case NEXT_BUTTON: - next_snapshot(); - break; - - case DEL_BUTTON: - del_snapshot(); - break; - - case CHASE_EVENT_BUTTON: - chase_event_etc(CHASE_EVENT); - break; - - case CHASE_DATUM_BUTTON: - chase_event_etc(CHASE_DATUM); - break; - - case CHASE_TRACK_BUTTON: - chase_event_etc(CHASE_TRACK); - break; - - case UNCHASE_BUTTON: - unchase_event_etc(); - break; - - case START_BUTTON: - start_button: - s_v1->minvistime = 0LL; - s_v1->maxvistime = current_width; - recompute_hscrollbar(); - break; - - case ZOOMIN_BUTTON: - s_v1->minvistime += zoom_delta; - s_v1->maxvistime -= zoom_delta; - recompute_hscrollbar(); - break; - - case SEARCH_AGAIN_BUTTON: - if (s_srchcode) { - event_search_internal(); - break; - } - /* NOTE FALLTHROUGH */ - - case SEARCH_BUTTON: - event_search(); - break; - - case ZOOMOUT_BUTTON: - if (zoom_delta == 0LL) - zoom_delta = 1; - - if (s_v1->minvistime >= zoom_delta) { - s_v1->minvistime -= zoom_delta; - s_v1->maxvistime += zoom_delta; - } else { - s_v1->minvistime = 0; - s_v1->maxvistime += zoom_delta*2; - } - - if ((s_v1->maxvistime - s_v1->minvistime) * 8 > - g_events[g_nevents-1].time * 9) { - s_v1->minvistime = 0; - s_v1->maxvistime = g_events[g_nevents-1].time * 9 / 8; - } - recompute_hscrollbar(); - break; - - case END_BUTTON: - ep = (g_events + g_nevents - 1); - s_v1->maxvistime = ep->time + event_incdec/3; - s_v1->minvistime = s_v1->maxvistime - current_width; - if (s_v1->minvistime > s_v1->maxvistime) - goto start_button; - recompute_hscrollbar(); - break; - - case MORE_TRACES_BUTTON: - /* Reduce the strip height to fit more traces on screen */ - s_v1->strip_height -= 1; - - if (s_v1->strip_height < 1) { - s_v1->strip_height = 1; - } - - /* Recalculate the number of strips on the screen */ - s_v1->npids = (s_v1->total_height - s_v1->time_ax_height) / - s_v1->strip_height; - recompute_vscrollbar(); - break; - - case LESS_TRACES_BUTTON: - /* Increase the strip height to fit fewer on the screen */ - s_v1->strip_height += 1; - if (s_v1->strip_height > 80) { - s_v1->strip_height = 80; - } - - /* Recalculate the number of strips on the screen */ - s_v1->npids = (s_v1->total_height - s_v1->time_ax_height) / - s_v1->strip_height; - recompute_vscrollbar(); - break; - - case FORWARD_BUTTON: - srch_chase_dir = SRCH_CHASE_FORWARD; - gtk_widget_hide (s_view1_forward_button); - gtk_widget_show (s_view1_backward_button); - break; - - case BACKWARD_BUTTON: - srch_chase_dir = SRCH_CHASE_BACKWARD; - gtk_widget_show (s_view1_forward_button); - gtk_widget_hide (s_view1_backward_button); - break; - - case SUMMARY_BUTTON: - summary_mode = TRUE; - gtk_widget_hide (s_view1_summary_button); - gtk_widget_show (s_view1_nosummary_button); - break; - - case NOSUMMARY_BUTTON: - summary_mode = FALSE; - gtk_widget_show (s_view1_summary_button); - gtk_widget_hide (s_view1_nosummary_button); - break; - } - - view1_display_when_idle(); -} - -/**************************************************************************** -* view1_print_callback -****************************************************************************/ - -void view1_print_callback (GtkToggleButton *notused, gpointer nu2) -{ - modal_dialog("Print Screen (PostScript format) to file:", - "Invalid file: Print Screen to file:", - "g2.ps", print_screen_callback); -} - -/**************************************************************************** -* view1_hscroll -****************************************************************************/ - -static void view1_hscroll (GtkAdjustment *adj, GtkWidget *notused) -{ - ulonglong current_width; - - current_width = (s_v1->maxvistime - s_v1->minvistime); - - s_v1->minvistime = (ulonglong)(adj->value); - s_v1->maxvistime = s_v1->minvistime + current_width; - - view1_display_when_idle(); - -#ifdef NOTDEF - g_print ("adj->lower = %.2f\n", adj->lower); - g_print ("adj->upper = %.2f\n", adj->upper); - g_print ("adj->value = %.2f\n", adj->value); - g_print ("adj->step_increment = %.2f\n", adj->step_increment); - g_print ("adj->page_increment = %.2f\n", adj->page_increment); - g_print ("adj->page_size = %.2f\n", adj->page_size); -#endif -} - -/**************************************************************************** -* view1_vscroll -****************************************************************************/ - -static void view1_vscroll (GtkAdjustment *adj, GtkWidget *notused) -{ - s_v1->first_pid_index = (int)adj->value; - view1_display_when_idle(); -} - -void set_pid_ax_width(int width) -{ - s_v1->pid_ax_width = width; - view1_display_when_idle(); -} - -/**************************************************************************** -* view1_init -****************************************************************************/ - -void view1_init(void) -{ - - c_view1_draw_width = atol(getprop_default("drawbox_width", "700")); - c_view1_draw_height = atol(getprop_default("drawbox_height", "400")); - - s_v1->pid_ax_width = 80; - s_v1->time_ax_height = 80; - s_v1->time_ax_spacing = 100; - s_v1->strip_height = 25; - s_v1->pop_offset = 20; - s_v1->pid_ax_offset = 34; - s_v1->event_offset = 40; - s_v1->total_height = c_view1_draw_height; - s_v1->total_width = c_view1_draw_width; - s_v1->first_pid_index = 0; - - s_v1->npids = (s_v1->total_height - s_v1->time_ax_height) / - s_v1->strip_height; - - s_v1->minvistime = 0; - s_v1->maxvistime = 200; - - s_view1_vbox = gtk_vbox_new(FALSE, 5); - - s_view1_hbox = gtk_hbox_new(FALSE, 5); - - da = gtk_drawing_area_new(); - gtk_drawing_area_size(GTK_DRAWING_AREA(da), c_view1_draw_width, - c_view1_draw_height); - -#ifdef NOTDEF - gtk_signal_connect (GTK_OBJECT (da), "motion_notify_event", - (GtkSignalFunc) motion_notify_event, NULL); -#endif - - gtk_signal_connect (GTK_OBJECT (da), "expose_event", - (GtkSignalFunc) expose_event, NULL); - - gtk_signal_connect (GTK_OBJECT(da),"configure_event", - (GtkSignalFunc) configure_event, NULL); - - gtk_signal_connect (GTK_OBJECT (da), "button_press_event", - (GtkSignalFunc) button_press_event, NULL); - - gtk_signal_connect (GTK_OBJECT (da), "button_release_event", - (GtkSignalFunc) button_press_event, NULL); - - gtk_signal_connect (GTK_OBJECT (da), "motion_notify_event", - (GtkSignalFunc) button_press_event, NULL); - - gtk_widget_set_events (da, GDK_BUTTON_PRESS_MASK - | GDK_BUTTON_RELEASE_MASK | GDK_EXPOSURE_MASK - | GDK_BUTTON_MOTION_MASK); - - - gtk_box_pack_start(GTK_BOX(s_view1_hbox), da, TRUE, TRUE, 0); - - g_font = gdk_font_load ("8x13"); - if (g_font == NULL) { - g_error("Couldn't load 8x13 font...\n"); - } - gdk_font_ref(g_font); - - /* PID axis menu */ - s_view1_vmenubox = gtk_vbox_new(FALSE, 5); - - s_view1_vsadj = gtk_adjustment_new(0.0 /* initial value */, - 0.0 /* minimum value */, - 2000.0 /* maximum value */, - 0.1 /* step increment */, - 10.0/* page increment */, - 10.0/* page size */); - - s_view1_vscroll = gtk_vscrollbar_new (GTK_ADJUSTMENT(s_view1_vsadj)); - - gtk_signal_connect (GTK_OBJECT (s_view1_vsadj), "value-changed", - GTK_SIGNAL_FUNC (view1_vscroll), - (gpointer)s_view1_vscroll); - - s_view1_topbutton = gtk_button_new_with_label("Top"); - s_view1_bottombutton = gtk_button_new_with_label("Bottom"); - - gtk_signal_connect (GTK_OBJECT(s_view1_topbutton), "clicked", - GTK_SIGNAL_FUNC(view1_button_click_callback), - (gpointer) TOP_BUTTON); - - gtk_signal_connect (GTK_OBJECT(s_view1_bottombutton), "clicked", - GTK_SIGNAL_FUNC(view1_button_click_callback), - (gpointer) BOTTOM_BUTTON); - - /* More Traces button and Less Traces button */ - s_view1_more_traces_button = gtk_button_new_with_label("More Traces"); - s_view1_less_traces_button = gtk_button_new_with_label("Less Traces"); - gtk_signal_connect (GTK_OBJECT(s_view1_more_traces_button), "clicked", - GTK_SIGNAL_FUNC(view1_button_click_callback), - (gpointer) MORE_TRACES_BUTTON); - gtk_signal_connect (GTK_OBJECT(s_view1_less_traces_button), "clicked", - GTK_SIGNAL_FUNC(view1_button_click_callback), - (gpointer) LESS_TRACES_BUTTON); - -#ifdef NOTDEF - /* Trick to bottom-justify the menu: */ - s_view1_pad1 = gtk_vbox_new(FALSE, 0); - gtk_box_pack_start (GTK_BOX(s_view1_vmenubox), s_view1_pad1, - TRUE, FALSE, 0); - -#endif - - gtk_box_pack_start (GTK_BOX(s_view1_vmenubox), s_view1_topbutton, - FALSE, FALSE, 0); - - gtk_box_pack_start (GTK_BOX(s_view1_vmenubox), s_view1_vscroll, - TRUE, TRUE, 0); - - gtk_box_pack_start (GTK_BOX(s_view1_vmenubox), s_view1_bottombutton, - FALSE, FALSE, 0); - - gtk_box_pack_start (GTK_BOX(s_view1_vmenubox), s_view1_more_traces_button, - FALSE, FALSE, 0); - - gtk_box_pack_start (GTK_BOX(s_view1_vmenubox), s_view1_less_traces_button, - FALSE, FALSE, 0); - - gtk_box_pack_start (GTK_BOX(s_view1_hbox), s_view1_vmenubox, - FALSE, FALSE, 0); - - /* Time axis menu */ - - s_view1_hmenubox = gtk_hbox_new(FALSE, 5); - - s_view1_startbutton = gtk_button_new_with_label("Start"); - - s_view1_zoominbutton = gtk_button_new_with_label("ZoomIn"); - - s_view1_searchbutton = gtk_button_new_with_label("Search"); - - s_view1_srchagainbutton = gtk_button_new_with_label("Search Again"); - - s_view1_zoomoutbutton = gtk_button_new_with_label("ZoomOut"); - - s_view1_endbutton = gtk_button_new_with_label("End"); - - gtk_signal_connect (GTK_OBJECT(s_view1_startbutton), "clicked", - GTK_SIGNAL_FUNC(view1_button_click_callback), - (gpointer) START_BUTTON); - - gtk_signal_connect (GTK_OBJECT(s_view1_zoominbutton), "clicked", - GTK_SIGNAL_FUNC(view1_button_click_callback), - (gpointer) ZOOMIN_BUTTON); - - gtk_signal_connect (GTK_OBJECT(s_view1_searchbutton), "clicked", - GTK_SIGNAL_FUNC(view1_button_click_callback), - (gpointer) SEARCH_BUTTON); - - gtk_signal_connect (GTK_OBJECT(s_view1_srchagainbutton), "clicked", - GTK_SIGNAL_FUNC(view1_button_click_callback), - (gpointer) SEARCH_AGAIN_BUTTON); - - gtk_signal_connect (GTK_OBJECT(s_view1_zoomoutbutton), "clicked", - GTK_SIGNAL_FUNC(view1_button_click_callback), - (gpointer) ZOOMOUT_BUTTON); - - gtk_signal_connect (GTK_OBJECT(s_view1_endbutton), "clicked", - GTK_SIGNAL_FUNC(view1_button_click_callback), - (gpointer) END_BUTTON); - - s_view1_hsadj = gtk_adjustment_new(0.0 /* initial value */, - 0.0 /* minimum value */, - 2000.0 /* maximum value */, - 0.1 /* step increment */, - 10.0/* page increment */, - 10.0/* page size */); - - s_view1_hscroll = gtk_hscrollbar_new (GTK_ADJUSTMENT(s_view1_hsadj)); - - gtk_signal_connect (GTK_OBJECT (s_view1_hsadj), "value-changed", - GTK_SIGNAL_FUNC (view1_hscroll), - (gpointer)s_view1_hscroll); - - gtk_box_pack_start (GTK_BOX(s_view1_hmenubox), s_view1_startbutton, - FALSE, FALSE, 0); - - gtk_box_pack_start (GTK_BOX(s_view1_hmenubox), s_view1_hscroll, - TRUE, TRUE, 0); - - gtk_box_pack_start (GTK_BOX(s_view1_hmenubox), s_view1_endbutton, - FALSE, FALSE, 0); - - gtk_box_pack_start (GTK_BOX(s_view1_hmenubox), s_view1_zoominbutton, - FALSE, FALSE, 0); - - gtk_box_pack_start (GTK_BOX(s_view1_hmenubox), s_view1_searchbutton, - FALSE, FALSE, 0); - - gtk_box_pack_start (GTK_BOX(s_view1_hmenubox), s_view1_srchagainbutton, - FALSE, FALSE, 0); - - gtk_box_pack_start (GTK_BOX(s_view1_hmenubox), s_view1_zoomoutbutton, - FALSE, FALSE, 0); - - gtk_box_pack_start (GTK_BOX(s_view1_vbox), s_view1_hbox, - TRUE, TRUE, 0); - - gtk_box_pack_start (GTK_BOX(s_view1_vbox), s_view1_hmenubox, - FALSE, FALSE, 0); - - - s_view1_hmenubox2 = gtk_hbox_new(FALSE, 5); - - s_view1_snapbutton = gtk_button_new_with_label("Snap"); - - s_view1_nextbutton = gtk_button_new_with_label("Next"); - - s_view1_delbutton = gtk_button_new_with_label("Del"); - - s_view1_chase_event_button = gtk_button_new_with_label("ChaseEvent"); - - s_view1_chase_datum_button = gtk_button_new_with_label("ChaseDatum"); - - s_view1_chase_track_button = gtk_button_new_with_label("ChaseTrack"); - - s_view1_unchasebutton = gtk_button_new_with_label("NoChase"); - - s_view1_forward_button = gtk_button_new_with_label("->SrchChase(is<-)"); - s_view1_backward_button = gtk_button_new_with_label("<-SrchChase(is->)"); - - s_view1_summary_button = gtk_button_new_with_label("Summary"); - s_view1_nosummary_button = gtk_button_new_with_label("NoSummary"); - - gtk_signal_connect (GTK_OBJECT(s_view1_snapbutton), "clicked", - GTK_SIGNAL_FUNC(view1_button_click_callback), - (gpointer) SNAP_BUTTON); - - gtk_signal_connect (GTK_OBJECT(s_view1_nextbutton), "clicked", - GTK_SIGNAL_FUNC(view1_button_click_callback), - (gpointer) NEXT_BUTTON); - - gtk_signal_connect (GTK_OBJECT(s_view1_delbutton), "clicked", - GTK_SIGNAL_FUNC(view1_button_click_callback), - (gpointer) DEL_BUTTON); - - gtk_signal_connect (GTK_OBJECT(s_view1_chase_event_button), "clicked", - GTK_SIGNAL_FUNC(view1_button_click_callback), - (gpointer) CHASE_EVENT_BUTTON); - - gtk_signal_connect (GTK_OBJECT(s_view1_chase_datum_button), "clicked", - GTK_SIGNAL_FUNC(view1_button_click_callback), - (gpointer) CHASE_DATUM_BUTTON); - - gtk_signal_connect (GTK_OBJECT(s_view1_chase_track_button), "clicked", - GTK_SIGNAL_FUNC(view1_button_click_callback), - (gpointer) CHASE_TRACK_BUTTON); - - gtk_signal_connect (GTK_OBJECT(s_view1_unchasebutton), "clicked", - GTK_SIGNAL_FUNC(view1_button_click_callback), - (gpointer) UNCHASE_BUTTON); - - gtk_signal_connect (GTK_OBJECT(s_view1_forward_button), "clicked", - GTK_SIGNAL_FUNC(view1_button_click_callback), - (gpointer) FORWARD_BUTTON); - - gtk_signal_connect (GTK_OBJECT(s_view1_backward_button), "clicked", - GTK_SIGNAL_FUNC(view1_button_click_callback), - (gpointer) BACKWARD_BUTTON); - - gtk_signal_connect (GTK_OBJECT(s_view1_summary_button), "clicked", - GTK_SIGNAL_FUNC(view1_button_click_callback), - (gpointer) SUMMARY_BUTTON); - - gtk_signal_connect (GTK_OBJECT(s_view1_nosummary_button), "clicked", - GTK_SIGNAL_FUNC(view1_button_click_callback), - (gpointer) NOSUMMARY_BUTTON); - - gtk_box_pack_start (GTK_BOX(s_view1_vbox), s_view1_hmenubox2, - FALSE, FALSE, 0); - - gtk_box_pack_start (GTK_BOX(s_view1_hmenubox2), s_view1_snapbutton, - FALSE, FALSE, 0); - - gtk_box_pack_start (GTK_BOX(s_view1_hmenubox2), s_view1_nextbutton, - FALSE, FALSE, 0); - - gtk_box_pack_start (GTK_BOX(s_view1_hmenubox2), s_view1_delbutton, - FALSE, FALSE, 0); - - gtk_box_pack_start (GTK_BOX(s_view1_hmenubox2), s_view1_chase_event_button, - FALSE, FALSE, 0); - - gtk_box_pack_start (GTK_BOX(s_view1_hmenubox2), s_view1_chase_datum_button, - FALSE, FALSE, 0); - - gtk_box_pack_start (GTK_BOX(s_view1_hmenubox2), s_view1_chase_track_button, - FALSE, FALSE, 0); - - gtk_box_pack_start (GTK_BOX(s_view1_hmenubox2), s_view1_unchasebutton, - FALSE, FALSE, 0); - - gtk_box_pack_start (GTK_BOX(s_view1_hmenubox2), s_view1_forward_button, - FALSE, FALSE, 0); - - gtk_box_pack_start (GTK_BOX(s_view1_hmenubox2), s_view1_backward_button, - FALSE, FALSE, 0); - - gtk_box_pack_start (GTK_BOX(s_view1_hmenubox2), s_view1_summary_button, - FALSE, FALSE, 0); - - gtk_box_pack_start (GTK_BOX(s_view1_hmenubox2), s_view1_nosummary_button, - FALSE, FALSE, 0); - - s_view1_label = gtk_label_new(NULL); - - gtk_box_pack_start (GTK_BOX(s_view1_vbox), s_view1_label, - FALSE, FALSE, 0); - - gtk_box_pack_start (GTK_BOX(g_mainhbox), s_view1_vbox, - TRUE, TRUE, 0); - - gtk_widget_show_all (s_view1_vbox); - GTK_WIDGET_SET_FLAGS(da, GTK_CAN_FOCUS); - gtk_widget_grab_focus(da); - - gtk_widget_hide (s_view1_forward_button); - gtk_widget_hide (summary_mode ? s_view1_summary_button - : s_view1_nosummary_button); - - zi_source = gdk_bitmap_create_from_data (NULL, (char *)zi_bits, zi_width, - zi_height); - zi_mask = gdk_bitmap_create_from_data (NULL, (char *)zi_bkgd, zi_width, - zi_height); - - zi_cursor = (GdkCursor *) gdk_cursor_new_from_pixmap (zi_source, - zi_mask, &fg_black, - &bg_white, zi_x_hot, - zi_y_hot); - gdk_pixmap_unref (zi_source); - gdk_pixmap_unref (zi_mask); - - norm_cursor = (GdkCursor *) gdk_cursor_new (GDK_TOP_LEFT_ARROW); -} - -/**************************************************************************** -* line_print -****************************************************************************/ - -void line_print (int x1, int y1, int x2, int y2) -{ - fprintf(s_printfp, "newpath\n"); - fprintf(s_printfp, "%d %d moveto\n", xrt(x1, s_v1->total_height - y1), - yrt(x1, s_v1->total_height - y1)); - - fprintf(s_printfp, "%d %d lineto\n", xrt (x2, s_v1->total_height - y2), - yrt (x2, s_v1->total_height - y2)); - fprintf(s_printfp, "1 setlinewidth\n"); - fprintf(s_printfp, "stroke\n"); -} - -/**************************************************************************** -* tbox_print -****************************************************************************/ -GdkRectangle *tbox_print (char *s, int x, int y, enum view1_tbox_fn function, - GdkRectangle *rp) -{ - if (function == TBOX_PRINT_BOXED) { - rp->width -= 4; - } - - if ((function == TBOX_PRINT_BOXED) || - (function == TBOX_PRINT_EVENT)) { - - fprintf(s_printfp, "newpath\n"); - fprintf(s_printfp, "0 setlinewidth\n"); - fprintf(s_printfp, "%d %d moveto\n", - xrt(rp->x, s_v1->total_height - rp->y), - yrt(rp->x, s_v1->total_height - rp->y)); - - fprintf(s_printfp, "%d %d lineto\n", - xrt (rp->x+rp->width, s_v1->total_height - rp->y), - yrt (rp->x+rp->width, s_v1->total_height - rp->y)); - - fprintf(s_printfp, "%d %d lineto\n", - xrt(rp->x+rp->width, s_v1->total_height - (rp->y+rp->height)), - yrt(rp->x+rp->width, s_v1->total_height - (rp->y+rp->height))); - - fprintf(s_printfp, "%d %d lineto\n", - xrt(rp->x, s_v1->total_height - (rp->y+rp->height)), - yrt(rp->x, s_v1->total_height - (rp->y+rp->height))); - - fprintf(s_printfp, "%d %d lineto\n", - xrt(rp->x, s_v1->total_height - rp->y), - yrt(rp->x, s_v1->total_height - rp->y)); - - fprintf(s_printfp, "stroke\n"); - } - - if ((function == TBOX_PRINT_BOXED) || - (function == TBOX_PRINT_PLAIN)) { - - fprintf(s_printfp, "newpath\n"); - fprintf(s_printfp, "%d %d moveto\n", - xrt(x, s_v1->total_height - (y-2)), - yrt(x, s_v1->total_height - (y-2))); - fprintf(s_printfp, "gsave\n"); - fprintf(s_printfp, "90 rotate\n"); - fprintf(s_printfp, "(%s) show\n", s); - fprintf(s_printfp, "grestore\n"); - } - - return(rp); -} - -/**************************************************************************** -* tbox - draws an optionally boxed string whose lower lefthand -* corner is at (x, y). As usual, Y is backwards. -****************************************************************************/ - -GdkRectangle *tbox (char *s, int x, int y, enum view1_tbox_fn function) -{ - static GdkRectangle update_rect; - gint lbearing, rbearing, width, ascent, descent; - - gdk_string_extents (g_font, s, - &lbearing, &rbearing, - &width, &ascent, &descent); - - /* - * If we have enough room to display full size events, then just - * use the BOXED function instead of the EVENT function. - */ - if (s_v1->strip_height > 9) { - switch (function) { - case TBOX_DRAW_EVENT: function = TBOX_DRAW_BOXED; break; - case TBOX_GETRECT_EVENT: function = TBOX_GETRECT_BOXED; break; - case TBOX_PRINT_EVENT: function = TBOX_PRINT_BOXED; break; - default: - break; - /* Nothing */ - } - } - - switch (function) { - case TBOX_DRAW_BOXED: - gdk_draw_rectangle (pm, da->style->white_gc, TRUE, - x, y - (ascent+descent+3), width + 2, - ascent + descent + 3); - - gdk_draw_rectangle (pm, da->style->black_gc, FALSE, - x, y - (ascent+descent+3), width + 2, - ascent + descent + 3); - - gdk_draw_string (pm, g_font, da->style->black_gc, - x + 1, y - 1, (const gchar *)s); - /* NOTE FALLTHROUGH */ - case TBOX_GETRECT_BOXED: - update_rect.x = x; - update_rect.y = y -(ascent+descent+3); - update_rect.width = width + 3; - update_rect.height = ascent + descent + 4; - if (function == TBOX_DRAW_BOXED) - gtk_widget_draw (da, &update_rect); - break; - - case TBOX_DRAW_EVENT: - /* We have a small event to draw...no text */ - gdk_draw_rectangle (pm, da->style->black_gc, FALSE, - x, y - 1, 3, 3); - /* NOTE FALLTHROUGH */ - case TBOX_GETRECT_EVENT: - update_rect.x = x; - update_rect.y = y - 1; - update_rect.width = 4; - update_rect.height = 4; - if (function == TBOX_DRAW_EVENT) - gtk_widget_draw (da, &update_rect); - break; - - - case TBOX_DRAW_PLAIN: - - gdk_draw_string (pm, g_font, da->style->black_gc, - x + 1, y - 1, (const gchar *)s); - /* NOTE FALLTHROUGH */ - case TBOX_GETRECT_PLAIN: - update_rect.x = x; - update_rect.y = y -(ascent+descent+1); - update_rect.width = width; - update_rect.height = ascent + descent; - if (function == TBOX_DRAW_PLAIN) - gtk_widget_draw (da, &update_rect); - break; - - case TBOX_PRINT_BOXED: - update_rect.x = x; - update_rect.y = y -(ascent+descent+3); - update_rect.width = width + 3; - update_rect.height = ascent + descent + 4; - /* note fallthrough */ - case TBOX_PRINT_PLAIN: - return(tbox_print(s, x, y, function, &update_rect)); - - case TBOX_PRINT_EVENT: - /* We have a small event box to print...no text */ - update_rect.x = x; - update_rect.y = y - 1; - update_rect.width = 4; - update_rect.height = 4; - return(tbox_print(s, x, y, function, &update_rect)); - } - return(&update_rect); -} - -/**************************************************************************** -* line -* -* For lines there is a primitive batching facility, that doesn't update -* the drawing area until the batch is complete. This is handy for drawing -* the pid axis and for summary mode. -* -* line_batch_mode contains the state for this: -* -* BATCH_OFF: no batching, update for every line -* BATCH_NEW: just entered a batch, so initialize the area to update from -* scratch -* BATCH_EXISTING: have drawn at least one line in batch mode, so the update -* area should only be expanded from now on to include the -* union of the "rectangular hull" of all lines -****************************************************************************/ - -static enum { BATCH_OFF, BATCH_NEW, BATCH_EXISTING } line_batch_mode; -static int line_batch_count; -static int line_minx, line_miny, line_maxx, line_maxy; - -void line_batch_start (void) -{ - line_batch_mode = BATCH_NEW; - line_batch_count = 0; -} - -void line_batch_end (void) -{ - GdkRectangle update_rect; - if (line_batch_count > 0) { - update_rect.x = line_minx; - update_rect.y = line_miny; - update_rect.width = (line_maxx - line_minx) + 1; - update_rect.height = (line_maxy - line_miny) + 1; - gtk_widget_draw (da, &update_rect); - } - line_batch_mode = BATCH_OFF; -} - -void line (int x1, int y1, int x2, int y2, enum view1_line_fn function) -{ - GdkRectangle update_rect; - GdkGC *gc = NULL; - - switch(function) { - case LINE_DRAW_BLACK: - gc = da->style->black_gc; - break; - - case LINE_DRAW_WHITE: - gc = da->style->white_gc; - break; - - case LINE_PRINT: - line_print (x1, y1, x2, y2); - return; - } - - gdk_draw_line (pm, gc, x1, y1, x2, y2); - - switch (line_batch_mode) { - case BATCH_OFF: - update_rect.x = x1; - update_rect.y = y1; - update_rect.width = (x2-x1) + 1; - update_rect.height = (y2-y1) + 1; - gtk_widget_draw (da, &update_rect); - break; - - case BATCH_NEW: - line_minx = x1; - line_maxx = x2; - line_miny = y1; - line_maxy = y2; - line_batch_mode = BATCH_EXISTING; - line_batch_count = 1; - break; - - case BATCH_EXISTING: - if (line_minx > x1) - line_minx = x1; - if (line_miny > y1) - line_miny = y1; - if (line_maxx < x2) - line_maxx = x2; - if (line_maxy < y2) - line_maxy = y2; - line_batch_count++; - break; - } -} - - -/**************************************************************************** -* display_pid_axis -****************************************************************************/ - -static void display_pid_axis(v1_geometry_t *vp) -{ - int y, i, label_tick; - int last_printed_y = -vp->strip_height; - pid_sort_t *pp; - int pid_index; - char *label_fmt; - char tmpbuf [128]; - - /* No pids yet? Outta here */ - if (g_pids == NULL) - return; - - line_batch_start(); - - for (i = 0; i < vp->npids; i++) { - pid_index = vp->first_pid_index + i; - if (pid_index >= g_npids) - break; - - set_color(pid_index); - pp = (g_pids + pid_index); - - label_fmt = get_track_label(pp->pid_value); - snprintf(tmpbuf, sizeof(tmpbuf)-1, label_fmt, pp->pid_value); - - y = i*vp->strip_height + vp->pid_ax_offset; - - /* - * Have we incremented enough space to have another label not - * overlap the previous label? - */ - if (y - last_printed_y > 9) { - /* Draw label */ - tbox(tmpbuf, 0, y +4, TBOX_DRAW_PLAIN+s_print_offset); - - last_printed_y = y; - - /* - * And let the line stick out a bit more to indicate this label - * relates to the following line. - */ - label_tick = 4; - } - else { - label_tick = 0; - } - - /* Draw axis line, but only if the lines aren't too close together */ - if (vp->strip_height > 4) { - line(vp->pid_ax_width - label_tick, y+4*s_print_offset, - vp->total_width, y+4*s_print_offset, - LINE_DRAW_BLACK+s_print_offset); - } - } - - set_color(COLOR_DEFAULT); - line_batch_end(); -} - -/**************************************************************************** -* view1_read_events_callback -* New event data just showed up, reset a few things. -****************************************************************************/ - -void view1_read_events_callback(void) -{ - int max_vis_index; - - s_v1->first_pid_index = 0; - - max_vis_index = 300; - if (max_vis_index > g_nevents) - max_vis_index = g_nevents-1; - - s_v1->minvistime = 0LL; - s_v1->maxvistime = (g_events[g_nevents - 1].time * 9)/ 8; - s_srchindex = 0; - s_srchcode = 0; - s_last_selected_event = 0; - - init_track_colors(); - - recompute_hscrollbar(); - recompute_vscrollbar(); -} - -/**************************************************************************** -* display_event_data -****************************************************************************/ - -static void display_event_data(v1_geometry_t *vp) -{ - int start_index; - int pid_index; - int x, y; - event_t *ep; - event_def_t *edp; - double time_per_pixel; - char tmpbuf[1024]; - GdkRectangle *print_rect; - int *last_x_used; - - /* Happens if one loads the event def header first, for example. */ - if (g_nevents == 0) - return; - - time_per_pixel = dtime_per_pixel(vp); - - start_index = find_event_index (vp->minvistime); - - /* Scrolled too far right? */ - if (start_index >= g_nevents) - return; - - ep = (g_events + start_index); - - if (s_print_offset || summary_mode) { - last_x_used = (int *)g_malloc0(vp->npids * sizeof(int)); - } else { - last_x_used = NULL; - } - - line_batch_start(); - - while (ep < (g_events + g_nevents) && - (ep->time < vp->maxvistime)) { - pid_index = ep->pid->pid_index; - set_color(pid_index); - - /* First filter: pid out of range */ - if ((pid_index < vp->first_pid_index) || - (pid_index >= vp->first_pid_index + vp->npids)) { - ep++; - continue; - } - - /* Second filter: event hidden */ - edp = find_event_definition (ep->code); - if (!edp->selected) { - ep++; - continue; - } - - /* Display it... */ - - pid_index -= vp->first_pid_index; - - y = pid_index*vp->strip_height + vp->event_offset; - - x = vp->pid_ax_width + - (int)(((double)(ep->time - vp->minvistime)) / time_per_pixel); - - if (last_x_used != NULL && x < last_x_used[pid_index]) { - ep++; - continue; - } - - if (ep->flags & (EVENT_FLAG_SELECT | EVENT_FLAG_SEARCHRSLT)) { - if (ep->flags & EVENT_FLAG_SELECT) { - format_popbox_string(tmpbuf, sizeof(tmpbuf), ep, edp); -#ifdef NOTDEF - sprintf(tmpbuf, edp->name); - sprintf(tmpbuf+strlen(tmpbuf), ": "); - sprintf(tmpbuf+strlen(tmpbuf), edp->format, ep->datum); -#endif - } else { - sprintf(tmpbuf, "SEARCH RESULT"); - } - print_rect = tbox(tmpbuf, x, y - vp->pop_offset, - TBOX_DRAW_BOXED+s_print_offset); - line(x, y-vp->pop_offset, x, y, LINE_DRAW_BLACK+s_print_offset); - if (last_x_used != NULL) - last_x_used[pid_index] = x + print_rect->width; - } - if (summary_mode) { - int delta = vp->strip_height / 3; - if (delta < 1) - delta = 1; - y = pid_index*vp->strip_height + vp->pid_ax_offset; - line(x, y - delta, x, y + delta, LINE_DRAW_BLACK); - last_x_used[pid_index] = x + 1; - } else { - sprintf(tmpbuf, "%ld", ep->code); - print_rect = tbox(tmpbuf, x, y, TBOX_DRAW_EVENT+s_print_offset); - if (last_x_used != NULL) - last_x_used[pid_index] = x + print_rect->width; - } - - ep++; - } - if (last_x_used) - g_free(last_x_used); - line_batch_end(); - set_color(COLOR_DEFAULT); -} - -/**************************************************************************** -* display_clear -****************************************************************************/ - -static void display_clear(void) -{ - GdkRectangle update_rect; - - gdk_draw_rectangle (pm, da->style->white_gc, TRUE, - 0, 0, da->allocation.width, - da->allocation.height); - - update_rect.x = 0; - update_rect.y = 0; - update_rect.width = da->allocation.width; - update_rect.height = da->allocation.height; - - gtk_widget_draw (da, &update_rect); -} - -/**************************************************************************** -* display_time_axis -****************************************************************************/ - -static void display_time_axis(v1_geometry_t *vp) -{ - int x, y, i; - int xoffset, nticks; - char tmpbuf [128]; - double unit_divisor; - double time; - char *units; - double time_per_pixel; - - y = vp->npids * vp->strip_height + vp->pid_ax_offset; - - x = vp->pid_ax_width; - - nticks = (vp->total_width - vp->pid_ax_width) / vp->time_ax_spacing; - - time_per_pixel = dtime_per_pixel(vp); - - units = "ns"; - unit_divisor = 1.00; - - if ((vp->maxvistime / unit_divisor) > 1000) { - units = "us"; - unit_divisor = 1000.00; - } - - if ((vp->maxvistime / unit_divisor) > 1000) { - units = "ms"; - unit_divisor = 1000.00*1000.00; - } - if ((vp->maxvistime / unit_divisor) > 1000) { - units = "s"; - unit_divisor = 1000.00*1000.00*1000.00; - } - - /* Draw line */ - line(x, y, vp->total_width, y, LINE_DRAW_BLACK+s_print_offset); - - xoffset = 0; - - for (i = 0; i < nticks; i++) { - /* Tick mark */ - line(x+xoffset, y-3, x+xoffset, y+3, LINE_DRAW_BLACK+s_print_offset); - - time = (double)(x + xoffset - vp->pid_ax_width); - time *= time_per_pixel; - time += (double)(vp->minvistime); - time /= unit_divisor; - - sprintf (tmpbuf, "%.2f%s", time, units); - - tbox(tmpbuf, x+xoffset, y+15, TBOX_DRAW_PLAIN+s_print_offset); - - xoffset += vp->time_ax_spacing; - } -} - -/**************************************************************************** -* clear_scoreboard -* Forget about any temporary displays, they're gone now... -****************************************************************************/ - -static void clear_scoreboard(void) -{ - s_result_up = FALSE; -} - -/**************************************************************************** -* view1_display -****************************************************************************/ - -void view1_display(void) -{ - display_clear(); - display_pid_axis(s_v1); - display_event_data(s_v1); - display_time_axis(s_v1); - clear_scoreboard(); -} - -static gint idle_tag; - -/**************************************************************************** -* view1_display_eventually -****************************************************************************/ - -static void view1_display_eventually(void) -{ - gtk_idle_remove(idle_tag); - idle_tag = 0; - view1_display(); -} - - -/**************************************************************************** -* view1_display_when_idle -****************************************************************************/ - -void view1_display_when_idle(void) -{ - if (idle_tag == 0) { - idle_tag = gtk_idle_add((GtkFunction) view1_display_eventually, 0); - } -} - -/**************************************************************************** -* view1_about -****************************************************************************/ - -void view1_about (char *tmpbuf) -{ - int nsnaps; - snapshot_t *snaps; - - sprintf(tmpbuf+strlen(tmpbuf), "Minvistime %lld\nMaxvistime %lld\n", - s_v1->minvistime, s_v1->maxvistime); - sprintf(tmpbuf+strlen(tmpbuf), "Strip Height %d\n", - s_v1->strip_height); - - for (nsnaps = 0, snaps = s_snapshots; snaps; snaps = snaps->next) { - nsnaps++; - } - sprintf(tmpbuf+strlen(tmpbuf), "%d snapshots in the ring\n", nsnaps); -} diff --git a/gmod/gmod/mod_vpp.c b/gmod/gmod/mod_vpp.c index 4a1da83c..572f9ef5 100644 --- a/gmod/gmod/mod_vpp.c +++ b/gmod/gmod/mod_vpp.c @@ -21,7 +21,7 @@ #include #include #include -#include +#include #include mmodule vpp_module; diff --git a/perftool/Makefile.am b/perftool/Makefile.am deleted file mode 100644 index ac652aa6..00000000 --- a/perftool/Makefile.am +++ /dev/null @@ -1,44 +0,0 @@ -# Copyright (c) 2016 Cisco and/or its affiliates. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at: -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -AUTOMAKE_OPTIONS = foreign -AM_CFLAGS = -Wall - -bin_PROGRAMS = c2cpel cpelatency cpeldump cpelinreg cpelstate - -lib_LTLIBRARIES = libcperf.la - -libcperf_la_SOURCES = delsvec.c linreg.c props.c cpel_util.c - -TOOL_LIBS = libcperf.la -lvppinfra -lm - -c2cpel_SOURCE = c2cpel.c -c2cpel_LDADD = $(TOOL_LIBS) - -cpelatency_SOURCE = cpelatency.c -cpelatency_LDADD = $(TOOL_LIBS) - -cpeldump_SOURCE = cpeldump.c -cpeldump_LDADD = $(TOOL_LIBS) - -cpelinreg_SOURCE = cpelinreg.c -cpelinreg_LDADD = $(TOOL_LIBS) - -cpelstate_SOURCE = cpelstate.c -cpelstate_LDADD = $(TOOL_LIBS) - - - - - - diff --git a/perftool/c2cpel.c b/perftool/c2cpel.c deleted file mode 100644 index 38e6fe52..00000000 --- a/perftool/c2cpel.c +++ /dev/null @@ -1,248 +0,0 @@ -/* - *------------------------------------------------------------------ - * Copyright (c) 2006-2016 Cisco and/or its affiliates. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "cpel.h" -#include "cpel_util.h" - -static elog_main_t elog_main; - -/* - * convert_clib_file - */ -void convert_clib_file(char *clib_file) -{ - clib_error_t *error = 0; - int i; - elog_main_t *em = &elog_main; - double starttime, delta; - - error = elog_read_file (&elog_main, clib_file); - - if (error) { - clib_warning("%U", format_clib_error, error); - exit (1); - } - - em = &elog_main; - - starttime = em->events[0].time; - - for (i = 0; i < vec_len (em->events); i++) { - elog_event_t *e; /* clib event */ - evt_t *ep; /* xxx2cpel event */ - u8 *s; - u64 timestamp; - elog_event_type_t *t; - u8 *brief_event_name; - u8 *track_name; - int j; - - e = vec_elt_at_index(em->events, i); - - /* Seconds since start of log */ - delta = e->time - starttime; - - /* u64 nanoseconds since start of log */ - timestamp = delta * 1e9; - - s = format (0, "%U%c", format_elog_event, em, e, 0); - - /* allocate an event instance */ - vec_add2(the_events, ep, 1); - ep->timestamp = timestamp; - - /* convert string event code to a real number */ - t = vec_elt_at_index (em->event_types, e->type); - - /* - * Construct a reasonable event name. - * Truncate the format string at the first whitespace break - * or printf format character. - */ - brief_event_name = format (0, "%s", t->format); - - for (j = 0; j < vec_len (brief_event_name); j++) { - if (brief_event_name[j] == ' ' || - brief_event_name[j] == '%' || - brief_event_name[j] == '(') { - brief_event_name[j] = 0; - break; - } - } - /* Throw away that much of the formatted event */ - vec_delete (s, j+1, 0); - - ep->event_id = find_or_add_event(brief_event_name, "%s"); - - track_name = format (0, "%U%c", format_elog_track, em, e, 0); - - ep->track_id = find_or_add_track (track_name); - - ep->datum = find_or_add_strtab(s); - - vec_free (track_name); - vec_free(brief_event_name); - vec_free(s); - } -} - -u8 *vec_basename (char *s) -{ - u8 * rv; - char *cp = s; - - while (*cp) - cp++; - - cp--; - - while (cp > s && *cp != '/') - cp--; - - if (cp > s) - cp++; - - rv = format (0, "%s", cp); - return rv; -} - - -int event_compare (const void *a0, const void *a1) -{ - evt_t *e0 = (evt_t *)a0; - evt_t *e1 = (evt_t *)a1; - - if (e0->timestamp < e1->timestamp) - return -1; - else if (e0->timestamp > e1->timestamp) - return 1; - return 0; -} - -int main (int argc, char **argv) -{ - int curarg=1; - char **inputfiles = 0; - char *outputfile = 0; - FILE *ofp; - - if (argc < 3) - goto usage; - - while (curarg < argc) { - if (!strncmp(argv[curarg], "--input-file", 3)) { - curarg++; - if (curarg < argc) { - vec_add1 (inputfiles, argv[curarg]); - curarg++; - continue; - } - clib_warning("Missing filename after --input-file\n"); - exit (1); - } - - if (!strncmp(argv[curarg], "--output-file", 3)) { - curarg ++; - if (curarg < argc) { - outputfile = argv[curarg]; - curarg ++; - continue; - } - clib_warning("Missing filename after --output-file\n"); - exit(1); - } - vec_add1 (inputfiles, argv[curarg]); - curarg++; - continue; - - usage: - fformat(stderr, - "c2cpel [--input-file] --output-file \n"); - exit(1); - } - - if (vec_len(inputfiles) == 0 || outputfile == 0) - goto usage; - - if (vec_len(inputfiles) > 1) - goto usage; - - cpel_util_init(); - - convert_clib_file (inputfiles[0]); - - ofp = fopen (outputfile, "w"); - if (ofp == NULL) { - clib_unix_warning ("couldn't create %s", outputfile); - exit (1); - } - - alpha_sort_tracks(); - fixup_event_tracks(); - - /* - * Four sections: string-table, event definitions, track defs, events. - */ - if (!write_cpel_header(ofp, 4)) { - clib_warning ("Error writing cpel header to %s...\n", outputfile); - unlink(outputfile); - exit(1); - } - - if (!write_string_table(ofp)) { - clib_warning ("Error writing string table to %s...\n", outputfile); - unlink(outputfile); - exit(1); - } - - if (!write_event_defs(ofp)) { - clib_warning ("Error writing event defs to %s...\n", outputfile); - unlink(outputfile); - exit(1); - } - - if (!write_track_defs(ofp)) { - clib_warning ("Error writing track defs to %s...\n", outputfile); - unlink(outputfile); - exit(1); - } - - if (!write_events(ofp, (u64) 1e9)) { - clib_warning ("Error writing events to %s...\n", outputfile); - unlink(outputfile); - exit(1); - - } - fclose(ofp); - exit (0); -} diff --git a/perftool/configure.ac b/perftool/configure.ac deleted file mode 100644 index f4a98697..00000000 --- a/perftool/configure.ac +++ /dev/null @@ -1,12 +0,0 @@ -AC_INIT(perftool, 2.0) -AM_INIT_AUTOMAKE -AM_SILENT_RULES([yes]) - -AC_CHECK_LIB([vppinfra], [clib_mem_get_page_size],, - AC_MSG_ERROR([Please install the vpp-lib package])) -AC_CHECK_HEADER([vppinfra/clib.h],, - AC_MSG_ERROR([Please install the vpp-dev package])) - -AM_PROG_LIBTOOL - -AC_OUTPUT([Makefile]) diff --git a/perftool/cpel.h b/perftool/cpel.h deleted file mode 100644 index 0bfb1a68..00000000 --- a/perftool/cpel.h +++ /dev/null @@ -1,83 +0,0 @@ -/* - *------------------------------------------------------------------ - * Copyright (c) 2005-2016 Cisco and/or its affiliates. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef _CPEL_H_ -#define _CPEL_H_ 1 - -typedef struct cpel_file_header_ { - unsigned char endian_version; - unsigned char pad; - unsigned short nsections; - unsigned int file_date; -} cpel_file_header_t; - -#define CPEL_FILE_LITTLE_ENDIAN 0x80 -#define CPEL_FILE_VERSION 0x01 -#define CPEL_FILE_VERSION_MASK 0x7F - -typedef struct cpel_section_header_ { - unsigned int section_type; - unsigned int data_length; /* does NOT include type and itself */ -} cpel_section_header_t; - -#define CPEL_SECTION_STRTAB 1 -/* string at offset 0 is the name of the table */ - -#define CPEL_SECTION_SYMTAB 2 -#define CPEL_SECTION_EVTDEF 3 - -typedef struct event_definition_section_header_ { - char string_table_name[64]; - unsigned int number_of_event_definitions; -} event_definition_section_header_t; - -typedef struct event_definition_ { - unsigned int event; - unsigned int event_format; - unsigned int datum_format; -} event_definition_t; - -#define CPEL_SECTION_TRACKDEF 4 - -typedef struct track_definition_section_header_ { - char string_table_name[64]; - unsigned int number_of_track_definitions; -} track_definition_section_header_t; - -typedef struct track_definition_ { - unsigned int track; - unsigned int track_format; -} track_definition_t; - -#define CPEL_SECTION_EVENT 5 - -typedef struct event_section_header_ { - char string_table_name[64]; - unsigned int number_of_events; - unsigned int clock_ticks_per_second; -} event_section_header_t; - -typedef struct event_entry_ { - unsigned int time[2]; - unsigned int track; - unsigned int event_code; - unsigned int event_datum; -} event_entry_t; - -#define CPEL_NUM_SECTION_TYPES 5 - -#endif /* _CPEL_H_ */ - diff --git a/perftool/cpel_util.c b/perftool/cpel_util.c deleted file mode 100644 index 7ee9b6e2..00000000 --- a/perftool/cpel_util.c +++ /dev/null @@ -1,456 +0,0 @@ -/* - *------------------------------------------------------------------ - * Copyright (c) 2006-2016 Cisco and/or its affiliates. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "cpel.h" -#include "cpel_util.h" - -evt_t *the_events; - -track_t *the_tracks; -u32 *track_alpha_map; - -event_definition_t *the_event_definitions; -i64 min_timestamp; - -/* Hash tables, used to find previous instances of the same items */ -uword *the_track_hash; -uword *the_msg_event_hash; -uword *the_strtab_hash; -uword *the_pidtid_hash; -uword *the_pid_to_name_hash; -u8 *the_strtab; - -uword *the_event_id_bitmap; - -/* - * find_or_add_strtab - * Finds or adds a string to the string table - */ -u32 find_or_add_strtab(void *s_arg) -{ - uword *p; - int len; - u8 *this_string; - u8 *scopy=0; - char *s = s_arg; - - p = hash_get_mem(the_strtab_hash, s); - if (p) { - return (p[0]); - } - - /* - * Here's a CLIB bear-trap. We can't add the string-table - * strings to the to the hash table (directly), since it - * expands and moves periodically. All of the hash table - * entries turn into dangling references, yadda yadda. - */ - - len = strlen(s)+1; - vec_add2(the_strtab, this_string, len); - memcpy(this_string, s, len); - - /* Make a copy which won't be moving around... */ - vec_validate(scopy, len); - memcpy(scopy, s, len); - - hash_set_mem(the_strtab_hash, scopy, this_string - the_strtab); - - return(this_string - the_strtab); -} - -/* - * find_or_add_track - * returns index in track table - */ -u32 find_or_add_track(void *s_arg) -{ - uword *p; - track_t *this_track; - u8 *copy_s; - char *s=s_arg; - - p = hash_get_mem(the_track_hash, s); - if (p) { - return (p[0]); - } - vec_add2(the_tracks, this_track, 1); - - this_track->original_index = this_track - the_tracks; - this_track->strtab_offset = find_or_add_strtab(s); - - copy_s = (u8 *)vec_dup(s); - - hash_set_mem(the_track_hash, copy_s, this_track - the_tracks); - return(this_track - the_tracks); -} - -/* - * find_or_add_event - * Adds an event to the event definition vector and add it to - * the event hash table - */ - -u32 find_or_add_event(void *s_arg, char *datum_format) -{ - uword *p; - u8 *copy_s; - event_definition_t *this_event_definition; - u32 event_id; - char *s=s_arg; - - p = hash_get_mem(the_msg_event_hash, s); - if (p) { - return (p[0]); - } - vec_add2(the_event_definitions, this_event_definition, 1); - - /* Allocate a new event-id */ - event_id = clib_bitmap_first_clear (the_event_id_bitmap); - the_event_id_bitmap = clib_bitmap_set(the_event_id_bitmap, event_id, 1); - this_event_definition->event = event_id; - this_event_definition->event_format = find_or_add_strtab(s); - this_event_definition->datum_format = find_or_add_strtab(datum_format); - - copy_s = (u8 *)vec_dup(s); - - hash_set_mem(the_msg_event_hash, copy_s, event_id); - - return(event_id); -} - -/* - * write_string_table - */ -int write_string_table(FILE *ofp) -{ - cpel_section_header_t sh; - - /* Round up string table size */ - while (vec_len(the_strtab) & 0x7) - vec_add1(the_strtab, 0); - - sh.section_type = ntohl(CPEL_SECTION_STRTAB); - sh.data_length = ntohl(vec_len(the_strtab)); - - if (fwrite(&sh, sizeof(sh), 1, ofp) != 1) - return(0); - - if (fwrite(the_strtab, 1, vec_len(the_strtab), ofp) != - vec_len(the_strtab)) - return(0); - - return(1); -} - -/* - * write_cpel_header - */ -int write_cpel_header(FILE *ofp, u32 nsections) -{ - cpel_file_header_t h; - - h.endian_version = CPEL_FILE_VERSION; - h.pad = 0; - h.nsections = ntohs(nsections); - h.file_date = ntohl(time(0)); - if (fwrite(&h, sizeof(h), 1, ofp) != 1) - return (0); - - return(1); -} - -/* - * write_event_defs - */ -int write_event_defs(FILE *ofp) -{ - cpel_section_header_t sh; - event_definition_section_header_t edsh; - event_definition_t *this_event_definition; - int i; - - /* Next, the event definitions */ - sh.section_type = ntohl(CPEL_SECTION_EVTDEF); - sh.data_length = ntohl(vec_len(the_event_definitions) - *sizeof(the_event_definitions[0]) - + sizeof(event_definition_section_header_t)); - - if (fwrite(&sh, sizeof(sh), 1, ofp) != 1) - return(0); - - memset(&edsh, 0, sizeof(edsh)); - - strcpy(edsh.string_table_name, "FileStrtab"); - edsh.number_of_event_definitions = ntohl(vec_len(the_event_definitions)); - - if (fwrite(&edsh, sizeof(edsh), 1, ofp) != 1) - return(0); - - for (i = 0; i < vec_len(the_event_definitions); i++) { - this_event_definition = &the_event_definitions[i]; - /* Endian fixup */ - this_event_definition->event = ntohl(this_event_definition->event); - this_event_definition->event_format = - ntohl(this_event_definition->event_format); - this_event_definition->datum_format = - ntohl(this_event_definition->datum_format); - - if (fwrite(this_event_definition, sizeof(the_event_definitions[0]), - 1, ofp) != 1) - return(0); - } - return(1); -} - -/* - * ntohll - */ -u64 ntohll (u64 x) { - if (clib_arch_is_little_endian) - x = ((((x >> 0) & 0xff) << 56) - | (((x >> 8) & 0xff) << 48) - | (((x >> 16) & 0xff) << 40) - | (((x >> 24) & 0xff) << 32) - | (((x >> 32) & 0xff) << 24) - | (((x >> 40) & 0xff) << 16) - | (((x >> 48) & 0xff) << 8) - | (((x >> 56) & 0xff) << 0)); - - return x; -} - -/* - * write_events - */ -int write_events(FILE *ofp, u64 clock_ticks_per_second) -{ - cpel_section_header_t sh; - event_section_header_t eh; - u32 number_of_events; - int i; - event_entry_t e; - u64 net_timestamp; - evt_t *this_event; - u32 time0, time1; - - number_of_events = vec_len(the_events); - - sh.section_type = ntohl(CPEL_SECTION_EVENT); - sh.data_length = ntohl(number_of_events * sizeof(e) + - sizeof(event_section_header_t)); - - if (fwrite(&sh, sizeof(sh), 1, ofp) != 1) - return(0); - - memset(&eh, 0, sizeof(eh)); - strcpy(eh.string_table_name, "FileStrtab"); - eh.number_of_events = ntohl(number_of_events); - eh.clock_ticks_per_second = ntohl(clock_ticks_per_second); - - if (fwrite(&eh, sizeof(eh), 1, ofp) != 1) - return(0); - - for (i = 0; i < number_of_events; i++) { - this_event = &the_events[i]; - net_timestamp = ntohll(this_event->timestamp); - - time1 = net_timestamp>>32; - time0 = net_timestamp & 0xFFFFFFFF; - - e.time[0] = time0; - e.time[1] = time1; - e.track = ntohl(this_event->track_id); - e.event_code = ntohl(this_event->event_id); - e.event_datum = ntohl(this_event->datum); - - if (fwrite(&e, sizeof(e), 1, ofp) != 1) - return(0); - } - return(1); -} - -/* - * write_track_defs - */ -int write_track_defs(FILE *ofp) -{ - cpel_section_header_t sh; - track_definition_section_header_t tdsh; - track_definition_t record; - track_definition_t *this_track_definition = &record; - int i; - event_definition_section_header_t edsh; - - /* Next, the event definitions */ - sh.section_type = ntohl(CPEL_SECTION_TRACKDEF); - sh.data_length = ntohl(vec_len(the_tracks) - *sizeof(this_track_definition[0]) - + sizeof(track_definition_section_header_t)); - - if (fwrite(&sh, sizeof(sh), 1, ofp) != 1) - return(0); - - memset(&tdsh, 0, sizeof(tdsh)); - - strcpy(tdsh.string_table_name, "FileStrtab"); - tdsh.number_of_track_definitions = ntohl(vec_len(the_tracks)); - - if (fwrite(&tdsh, sizeof(edsh), 1, ofp) != 1) - return(0); - - for (i = 0; i < vec_len(the_tracks); i++) { - this_track_definition->track = ntohl(i); - this_track_definition->track_format = - ntohl(the_tracks[i].strtab_offset); - - if (fwrite(this_track_definition, sizeof(this_track_definition[0]), - 1, ofp) != 1) - return(0); - } - return(1); -} - -void cpel_util_init (void) -{ - u8 *eventstr; - - the_strtab_hash = hash_create_string (0, sizeof (uword)); - the_msg_event_hash = hash_create_string (0, sizeof (uword)); - the_track_hash = hash_create_string (0, sizeof (uword)); - the_pidtid_hash = hash_create_string (0, sizeof(uword)); - the_pid_to_name_hash = hash_create(0, sizeof(uword)); - - /* Must be first, or no supper... */ - find_or_add_strtab("FileStrtab"); - - /* Historical canned events, no longer used. */ - if (0) { - /* event 0 (not used) */ - eventstr = format(0, "PlaceholderNotUsed"); - vec_add1(eventstr, 0); - find_or_add_event(eventstr, "%s"); - vec_free(eventstr); - - /* event 1 (thread on CPU) */ - eventstr = format(0, "THREAD/THRUNNING"); - vec_add1(eventstr, 0); - find_or_add_event(eventstr, "%s"); - vec_free(eventstr); - - /* event 2 (thread ready) */ - eventstr = format(0, "THREAD/THREADY"); - vec_add1(eventstr, 0); - find_or_add_event(eventstr, "%s"); - vec_free(eventstr); - - /* event 3 (function enter) */ - eventstr = format(0, "FUNC/ENTER"); - vec_add1(eventstr, 0); - find_or_add_event(eventstr, "0x%x"); - vec_free(eventstr); - - /* event 4 (function enter) */ - eventstr = format(0, "FUNC/EXIT"); - vec_add1(eventstr, 0); - find_or_add_event(eventstr, "0x%x"); - vec_free(eventstr); - } -} - -/* - * alpha_compare_tracks - */ -static int alpha_compare_tracks(const void *a1, const void *a2) -{ - int i; - track_t *t1 = (track_t *)a1; - track_t *t2 = (track_t *)a2; - u8 *s1 = &the_strtab[t1->strtab_offset]; - u8 *s2 = &the_strtab[t2->strtab_offset]; - - for (i = 0; s1[i] && s2[i]; i++) { - if (s1[i] < s2[i]) - return(-1); - if (s1[i] > s2[i]) - return(1); - } - return(0); -} - -/* - * alpha_sort_tracks - * Alphabetically sort tracks, set up a mapping - * vector so we can quickly map the original track index to - * the new/improved/alpha-sorted index - */ -void alpha_sort_tracks(void) -{ - track_t *this_track; - int i; - - qsort(the_tracks, vec_len(the_tracks), sizeof(track_t), - alpha_compare_tracks); - - vec_validate(track_alpha_map, vec_len(the_tracks)); - _vec_len(track_alpha_map) = vec_len(the_tracks); - - for (i = 0; i < vec_len(the_tracks); i++) { - this_track = &the_tracks[i]; - track_alpha_map[this_track->original_index] = i; - } -} - -/* - * fixup_event_tracks - * Use the track alpha mapping to account for the alphabetic - * sort performed by the previous routine - */ -void fixup_event_tracks(void) -{ - int i; - u32 old_track; - - for (i = 0; i < vec_len(the_events); i++) { - old_track = the_events[i].track_id; - the_events[i].track_id = track_alpha_map[old_track]; - } -} - -/* Indispensable for debugging in gdb... */ - -u32 vl(void *x) -{ - return vec_len(x); -} diff --git a/perftool/cpel_util.h b/perftool/cpel_util.h deleted file mode 100644 index b76f7a4b..00000000 --- a/perftool/cpel_util.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - *------------------------------------------------------------------ - * Copyright (c) 2006-2016 Cisco and/or its affiliates. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef __cpel_util_h__ -#define __cpel_util_h__ - -/* - * Our idea of an event, as opposed to a CPEL event - */ -typedef struct evt_ { - u64 timestamp; - u32 track_id; - u32 event_id; - u32 datum; -} evt_t; - -evt_t *the_events; - -/* - * Track object, so we can sort the tracks alphabetically and - * fix the events later - */ -typedef struct track_ { - u32 original_index; - u32 strtab_offset; -} track_t; - -track_t *the_tracks; -u32 *track_alpha_map; - -event_definition_t *the_event_definitions; -i64 min_timestamp; - -/* Hash tables, used to find previous instances of the same items */ -uword *the_track_hash; -uword *the_msg_event_hash; -uword *the_strtab_hash; -uword *the_pidtid_hash; -uword *the_pid_to_name_hash; -u8 *the_strtab; - -u32 find_or_add_strtab(void *s_arg); -u32 find_or_add_track(void *s_arg); -u32 find_or_add_event(void *s_arg, char *datum_format); -int write_string_table(FILE *ofp); -int write_cpel_header(FILE *ofp, u32 nsections); -int write_event_defs(FILE *ofp); -u64 ntohll (u64 x); -int write_events(FILE *ofp, u64 clock_ticks_per_second); -int write_track_defs(FILE *ofp); -void cpel_util_init (void); -void alpha_sort_tracks(void); -void fixup_event_tracks(void); - -#endif /* __cpel_util_h__ */ diff --git a/perftool/cpelatency.c b/perftool/cpelatency.c deleted file mode 100644 index f40a1fb1..00000000 --- a/perftool/cpelatency.c +++ /dev/null @@ -1,927 +0,0 @@ -/* - *------------------------------------------------------------------ - * Copyright (c) 2006-2016 Cisco and/or its affiliates. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "cpel.h" -#include - -char *time_format = "%.03d:%.02d:%.02d:%.03d:%.03d "; -static char version[] = "cpelatency 2.0"; - -#define USEC_PER_MS 1000LL -#define USEC_PER_SECOND (1000*USEC_PER_MS) -#define USEC_PER_MINUTE (60*USEC_PER_SECOND) -#define USEC_PER_HOUR (60*USEC_PER_MINUTE) - -uword *the_strtab_hash; /* (name, base-VA) hash of all string tables */ -uword *the_evtdef_hash; /* (event-id, event-definition) hash */ -uword *the_trackdef_hash; /* (track-id, track-definition) hash */ -uword *the_pidtid_hash; /* ("pid:xxx tid:yy", track-definition) hash */ - -f64 ticks_per_us; -u32 start_event_code = 2; /* default: XR thread ready event */ -u32 end_event_code = 1; /* default: XR thread running event */ -int exclude_kernel_from_summary_stats=1; -int summary_stats_only; -int scatterplot; -u8 *name_filter; -int have_trackdefs; - -typedef enum { - SORT_MAX_TIME=1, - SORT_MAX_OCCURRENCES, - SORT_NAME, -} sort_t; - -sort_t sort_type = SORT_MAX_TIME; - -int widest_name_format=5; -int widest_track_format=20; - -typedef struct bound_event_ { - u32 event_code; - u8 *event_str; - u8 *datum_str; - u32 is_strtab_ref; -} bound_event_t; - -bound_event_t *bound_events; - -typedef struct bound_track_ { - u32 track; - u8 *track_str; - u64 state_start_ticks; - u64 *ticks_in_state; /* vector of state occurrences */ - f64 mean_ticks_in_state; - f64 variance_ticks_in_state; - f64 total_ticks_in_state; -} bound_track_t; - -bound_track_t *bound_tracks; - -void fatal(char *s) -{ - fprintf(stderr, "%s", s); - exit(1); -} - -typedef enum { - PASS1=1, - PASS2=2, -} pass_t; - -typedef struct { - int (*pass1)(cpel_section_header_t *, int, FILE *); - int (*pass2)(cpel_section_header_t *, int, FILE *); -} section_processor_t; - -int bad_section(cpel_section_header_t *sh, int verbose, FILE *ofp) -{ - fprintf(ofp, "Bad (type 0) section, skipped...\n"); - return(0); -} - -int noop_pass(cpel_section_header_t *sh, int verbose, FILE *ofp) -{ - return(0); -} - -int strtab_pass1(cpel_section_header_t *sh, int verbose, FILE *ofp) -{ - uword *p; - u8 *strtab_data_area = (u8 *)(sh+1); - - /* Multiple string tables with the same name are Bad... */ - p = hash_get_mem(the_strtab_hash, strtab_data_area); - if (p) { - fprintf(ofp, "Duplicate string table name %s", strtab_data_area); - } - /* - * Looks funny, but we really do want key = first string in the - * table, value = address(first string in the table) - */ - hash_set_mem(the_strtab_hash, strtab_data_area, strtab_data_area); - if (verbose) { - fprintf(ofp, "String Table %s\n", strtab_data_area); - } - return(0); -} - -int evtdef_pass1(cpel_section_header_t *sh, int verbose, FILE *ofp) -{ - int i, nevents; - event_definition_section_header_t *edh; - event_definition_t *ep; - u8 *this_strtab; - u32 event_code; - uword *p; - bound_event_t *bp; - int thislen; - - edh = (event_definition_section_header_t *)(sh+1); - nevents = ntohl(edh->number_of_event_definitions); - - if (verbose) { - fprintf(ofp, "Event Definition Section: %d definitions\n", - nevents); - } - - p = hash_get_mem(the_strtab_hash, edh->string_table_name); - if (!p) { - fprintf(ofp, "Fatal: couldn't find string table\n"); - return(1); - } - this_strtab = (u8 *)p[0]; - - ep = (event_definition_t *)(edh+1); - - for (i = 0; i < nevents; i++) { - event_code = ntohl(ep->event); - p = hash_get(the_evtdef_hash, event_code); - if (p) { - fprintf(ofp, "Event %d redefined, retain first definition\n", - event_code); - continue; - } - vec_add2(bound_events, bp, 1); - bp->event_code = event_code; - bp->event_str = this_strtab + ntohl(ep->event_format); - bp->datum_str = this_strtab + ntohl(ep->datum_format); - bp->is_strtab_ref = 0; - /* Decide if the datum format is a %s format => strtab reference */ - { - int j; - int seen_percent=0; - - for (j = 0; j < strlen((char *) bp->datum_str); j++) { - if (bp->datum_str[j] == '%'){ - seen_percent=1; - continue; - } - if (seen_percent && bp->datum_str[j] == 's') { - bp->is_strtab_ref = 1; - } - } - } - - hash_set(the_evtdef_hash, event_code, bp - bound_events); - - thislen = strlen((char *) bp->event_str); - if (thislen > widest_name_format) - widest_name_format = thislen; - - ep++; - } - return (0); -} - -int trackdef_pass1(cpel_section_header_t *sh, int verbose, FILE *ofp) -{ - int i, nevents; - track_definition_section_header_t *tdh; - track_definition_t *tp; - u8 *this_strtab; - u32 track_code; - uword *p; - bound_track_t *btp; - int thislen; - u8 *pidstr; - u8 *pidtid_str; - u8 *cp; - int tid, pid; - - tdh = (track_definition_section_header_t *)(sh+1); - nevents = ntohl(tdh->number_of_track_definitions); - - if (verbose) { - fprintf(ofp, "Track Definition Section: %d definitions\n", - nevents); - } - - p = hash_get_mem(the_strtab_hash, tdh->string_table_name); - if (!p) { - fprintf(ofp, "Fatal: couldn't find string table\n"); - return(1); - } - this_strtab = (u8 *)p[0]; - - tp = (track_definition_t *)(tdh+1); - - for (i = 0; i < nevents; i++) { - track_code = ntohl(tp->track); - p = hash_get(the_trackdef_hash, track_code); - if (p) { - fprintf(stderr, "track %d redefined, retain first definition\n", - track_code); - continue; - } - vec_add2(bound_tracks, btp, 1); - btp->track = track_code; - btp->track_str = this_strtab + ntohl(tp->track_format); - hash_set(the_trackdef_hash, track_code, btp - bound_tracks); - - if (verbose) { - fprintf(stderr, "adding track '%s'\n", btp->track_str); - } - - thislen = strlen((char *) btp->track_str); - if (thislen > widest_track_format) - widest_track_format = thislen; - - /* convert track_str "eth_server t11(20498)" to "pid:20498 tid:11" */ - cp = btp->track_str; - while (*cp && *cp != '(') - cp++; - if (!*cp) { - fprintf(stderr, "error canonicalizing '%s'\n", btp->track_str); - goto out; - } - pidstr = cp+1; /* remember location of PID */ - - while (cp > btp->track_str && *cp != 't') - cp--; - - if (cp == btp->track_str) { - fprintf(stderr, "error canonicalizing '%s'\n", btp->track_str); - goto out; - } - tid = atol((char *)(cp+1)); - pid = atol((char *) pidstr); - pidtid_str = format(0, "pid:%d tid:%d", pid, tid); - vec_add1(pidtid_str, 0); - - /* - * Note: duplicates are possible due to thread create / - * thread destroy operations. - */ - p = hash_get_mem(the_pidtid_hash, pidtid_str); - if (p) { - vec_free(pidtid_str); - goto out; - } - hash_set_mem(the_pidtid_hash, pidtid_str, btp - bound_tracks); - - out: - tp++; - } - have_trackdefs = 1; - return (0); -} - -int unsupported_pass (cpel_section_header_t *sh, int verbose, FILE *ofp) -{ - if (verbose) { - fprintf(ofp, "Unsupported type %d section\n", - ntohl(sh->section_type)); - } - return(0); -} - -int event_pass2(cpel_section_header_t *sh, int verbose, FILE *ofp) -{ - event_section_header_t *eh; - int nevents; - int i; - uword *p; - event_entry_t *ep; - u64 now; - u32 time0, time1; - u32 track_code; - u8 *this_strtab; - u64 ticks_in_state; - bound_track_t *btp; - bound_track_t *state_track=0; - u8 *pidtid_str; - u8 *pidtid_dup; - u8 *ecp; - u32 event_code; - - eh = (event_section_header_t *)(sh+1); - nevents = ntohl(eh->number_of_events); - ticks_per_us = ((double)ntohl(eh->clock_ticks_per_second)) / 1e6; - - if (verbose) { - fprintf(ofp, "%.3f ticks_per_us\n", ticks_per_us); - } - - ep = (event_entry_t *)(eh+1); - - p = hash_get_mem(the_strtab_hash, eh->string_table_name); - if (!p) { - fprintf(ofp, "Fatal: couldn't find string table\n"); - return(1); - } - this_strtab = (u8 *)p[0]; - - /* - * Some logger implementation that doesn't produce - * trackdef sections, synthesize the bound_tracks vector - */ - if (!have_trackdefs) { - for (i = 0; i < nevents; i++) { - track_code = ntohl(ep->track); - pidtid_dup = format(0, "%d", track_code); - vec_add1(pidtid_dup, 0); - p = hash_get_mem(the_pidtid_hash, pidtid_dup); - if (!p) { - vec_add2(bound_tracks, btp, 1); - btp->track = track_code; - btp->track_str = pidtid_dup; - hash_set(the_trackdef_hash, track_code, btp - bound_tracks); - hash_set_mem(the_pidtid_hash, pidtid_dup, btp - bound_tracks); - } else { - vec_free(pidtid_dup); - } - ep++; - } - } - - ep = (event_entry_t *)(eh+1); - - for (i = 0; i < nevents; i++) { - time0 = ntohl (ep->time[0]); - time1 = ntohl (ep->time[1]); - - now = (((u64) time0)<<32) | time1; - - event_code = ntohl(ep->event_code); - - /* Find the corresponding track via the pidtid hash table */ - if (event_code == start_event_code || event_code == end_event_code) { - if (have_trackdefs) { - pidtid_str = this_strtab + ntohl(ep->event_datum); - pidtid_dup = format(0, (char *) pidtid_str); - vec_add1(pidtid_dup, 0); - ecp = &pidtid_dup[vec_len(pidtid_dup)-1]; - while (*--ecp == ' ') - *ecp = 0; - } else { - pidtid_dup = format(0, "%d", ntohl(ep->track)); - vec_add1(pidtid_dup, 0); - } - - p = hash_get_mem(the_pidtid_hash, pidtid_dup); - if (!p) { - fprintf(stderr, "warning: couldn't find '%s'\n", - pidtid_dup); - vec_free(pidtid_dup); - ep++; - continue; - } - state_track = &bound_tracks[p[0]]; - } - /* Found the start-event code ? */ - if (event_code == start_event_code) { - state_track->state_start_ticks = now; - } else if (event_code == end_event_code) { - /* - * Add a ticks-in-state record, unless - * e.g. the log started with the exit event - */ - if (state_track->state_start_ticks) { - ticks_in_state = now - state_track->state_start_ticks; - vec_add1(state_track->ticks_in_state, ticks_in_state); - state_track->state_start_ticks = 0; - } - /* Otherwise, nothing */ - } - ep++; - } - return(0); -} - -/* - * Note: If necessary, add passes / columns to this table to - * handle section order dependencies. - */ - -section_processor_t processors[CPEL_NUM_SECTION_TYPES+1] = -{ - {bad_section, noop_pass}, /* type 0 -- f**ked */ - {strtab_pass1, noop_pass}, /* type 1 -- STRTAB */ - {unsupported_pass, noop_pass}, /* type 2 -- SYMTAB */ - {evtdef_pass1, noop_pass}, /* type 3 -- EVTDEF */ - {trackdef_pass1, noop_pass}, /* type 4 -- TRACKDEF */ - {noop_pass, event_pass2}, /* type 5 -- EVENTS */ -}; - - -int process_section(cpel_section_header_t *sh, int verbose, FILE *ofp, - pass_t pass) -{ - u32 type; - type = ntohl(sh->section_type); - int rv; - int (*fp)(cpel_section_header_t *, int, FILE *); - - if (type > CPEL_NUM_SECTION_TYPES) { - fprintf(stderr, "Unknown section type %d\n", type); - return(1); - } - switch(pass) { - case PASS1: - fp = processors[type].pass1; - break; - - case PASS2: - fp = processors[type].pass2; - break; - - default: - fprintf(stderr, "Unknown pass %d\n", pass); - return(1); - } - - rv = (*fp)(sh, verbose, ofp); - - return(rv); -} - -int cpel_dump_file_header(cpel_file_header_t *fh, int verbose, FILE *ofp) -{ - time_t file_time; - - if (verbose) { - fprintf(ofp, "CPEL file: %s-endian, version %d\n", - ((fh->endian_version & CPEL_FILE_LITTLE_ENDIAN) ? - "little" : "big"), - fh->endian_version & CPEL_FILE_VERSION_MASK); - - file_time = ntohl(fh->file_date); - - fprintf(ofp, "File created %s", ctime(&file_time)); - fprintf(ofp, "File has %d sections\n", - ntohs(fh->nsections)); - } - - return(0); -} - - -int cpel_dump(u8 *cpel, int verbose, FILE *ofp) -{ - cpel_file_header_t *fh; - cpel_section_header_t *sh; - u16 nsections; - u32 section_size; - int i; - - /* First, the file header */ - fh = (cpel_file_header_t *)cpel; - if (fh->endian_version != CPEL_FILE_VERSION) { - if (fh->endian_version & CPEL_FILE_LITTLE_ENDIAN) { - fprintf(stderr, "Little endian data format not supported\n"); - return(1); - } - fprintf(stderr, "Unsupported file version 0x%x\n", - fh->endian_version); - return(1); - } - cpel_dump_file_header(fh, verbose, ofp); - nsections = ntohs(fh->nsections); - - /* - * Take two passes through the file. PASS1 builds - * data structures, PASS2 actually dumps the file. - * Just in case the sections are in an unobvious order. - */ - sh = (cpel_section_header_t *)(fh+1); - for (i = 0; i < nsections; i++) { - section_size = ntohl(sh->data_length); - - if(verbose) { - fprintf(ofp, "Section type %d, size %d\n", ntohl(sh->section_type), - section_size); - } - - if(process_section(sh, verbose, ofp, PASS1)) - return(1); - - sh++; - sh = (cpel_section_header_t *)(((u8 *)sh)+section_size); - } - - sh = (cpel_section_header_t *)(fh+1); - for (i = 0; i < nsections; i++) { - if(process_section(sh, verbose, ofp, PASS2)) - return(1); - section_size = ntohl(sh->data_length); - sh++; - sh = (cpel_section_header_t *)(((u8 *)sh)+section_size); - } - return(0); -} - -void compute_state_statistics(int verbose, FILE *ofp) -{ - int i, j; - bound_track_t *bp; - f64 fticks; - - /* Across the bound tracks */ - for (i = 0; i < vec_len(bound_tracks); i++) { - bp = &bound_tracks[i]; - bp->mean_ticks_in_state = 0.0; - bp->variance_ticks_in_state = 0.0; - bp->total_ticks_in_state = 0.0; - for (j = 0; j < vec_len(bp->ticks_in_state); j++) { - bp->total_ticks_in_state += (f64) bp->ticks_in_state[j]; - } - /* Compute mean */ - if (vec_len(bp->ticks_in_state)) { - bp->mean_ticks_in_state = bp->total_ticks_in_state / - ((f64) vec_len(bp->ticks_in_state)); - } - /* Accumulate sum: (Xi-Xbar)**2 */ - for (j = 0; j < vec_len(bp->ticks_in_state); j++) { - fticks = bp->ticks_in_state[j]; - bp->variance_ticks_in_state += - (fticks - bp->mean_ticks_in_state)* - (fticks - bp->mean_ticks_in_state); - } - /* Compute s**2, the unbiased estimator of sigma**2 */ - if (vec_len(bp->ticks_in_state) > 1) { - bp->variance_ticks_in_state /= (f64) - (vec_len(bp->ticks_in_state)-1); - } - } -} - -int track_compare_max (const void *arg1, const void *arg2) -{ - bound_track_t *a1 = (bound_track_t *)arg1; - bound_track_t *a2 = (bound_track_t *)arg2; - f64 v1, v2; - - v1 = a1->total_ticks_in_state; - v2 = a2->total_ticks_in_state; - - if (v1 < v2) - return (1); - else if (v1 == v2) - return (0); - else return (-1); -} - -int track_compare_occurrences (const void *arg1, const void *arg2) -{ - bound_track_t *a1 = (bound_track_t *)arg1; - bound_track_t *a2 = (bound_track_t *)arg2; - f64 v1, v2; - - v1 = (f64) vec_len(a1->ticks_in_state); - v2 = (f64) vec_len(a2->ticks_in_state); - - if (v1 < v2) - return (1); - else if (v1 == v2) - return (0); - else return (-1); -} - -int track_compare_name (const void *arg1, const void *arg2) -{ - bound_track_t *a1 = (bound_track_t *)arg1; - bound_track_t *a2 = (bound_track_t *)arg2; - - return (strcmp((char *)(a1->track_str), (char *)(a2->track_str))); -} - -void sort_state_statistics(sort_t type, FILE *ofp) -{ - int (*compare)(const void *, const void *); - - if (summary_stats_only) - return; - - switch(type) { - case SORT_MAX_TIME: - fprintf(ofp, "Results sorted by max time in state.\n\n"); - compare = track_compare_max; - break; - - case SORT_MAX_OCCURRENCES: - fprintf(ofp, "Results sorted by max occurrences of state.\n\n"); - compare = track_compare_occurrences; - break; - - case SORT_NAME: - compare = track_compare_name; - fprintf(ofp, "Results sorted by process name, thread ID, PID\n\n"); - break; - - default: - fatal("sort type not set?"); - } - - qsort (bound_tracks, vec_len(bound_tracks), - sizeof (bound_track_t), compare); -} - -void print_state_statistics(int verbose, FILE *ofp) -{ - int i,j; - u8 *trackpad; - bound_track_t *bp; - f64 total_time = 0.0; - f64 total_switches = 0.0; - - trackpad = format(0, "%%-%ds ", widest_track_format); - vec_add1(trackpad, 0); - - if (!summary_stats_only) { - fprintf(ofp, (char *)trackpad, "ProcName Thread(PID)"); - fprintf(ofp, " Mean(us) Stdev(us) Total(us) N\n"); - } - - for (i = 0; i < vec_len(bound_tracks); i++) { - bp = &bound_tracks[i]; - if (bp->mean_ticks_in_state == 0.0) - continue; - - if (name_filter && - strncmp((char *)bp->track_str, (char *)name_filter, - strlen((char *)name_filter))) - continue; - - /* - * Exclude kernel threads (e.g. idle thread) from - * state statistics - */ - if (exclude_kernel_from_summary_stats && - !strncmp((char *) bp->track_str, "kernel ", 7)) - continue; - - total_switches += (f64) vec_len(bp->ticks_in_state); - - if (!summary_stats_only) { - fprintf(ofp, (char *) trackpad, bp->track_str); - fprintf(ofp, "%10.3f +- %10.3f", - bp->mean_ticks_in_state / ticks_per_us, - sqrt(bp->variance_ticks_in_state) - / ticks_per_us); - fprintf(ofp, "%12.3f", - bp->total_ticks_in_state / ticks_per_us); - fprintf(ofp, "%8d\n", vec_len(bp->ticks_in_state)); - } - - if (scatterplot) { - for (j = 0; j < vec_len(bp->ticks_in_state); j++) { - fprintf(ofp, "%.3f\n", - (f64)bp->ticks_in_state[j] / ticks_per_us); - } - } - - total_time += bp->total_ticks_in_state; - } - - if (!summary_stats_only) - fprintf(ofp, "\n"); - fprintf(ofp, "Note: the following statistics %s kernel-thread activity.\n", - exclude_kernel_from_summary_stats ? "exclude" : "include"); - if (name_filter) - fprintf(ofp, - "Note: only pid/proc/threads matching '%s' are included.\n", - name_filter); - - fprintf(ofp, - "Total time in state: %10.3f (us), Total state occurrences: %.0f\n", - total_time / ticks_per_us, total_switches); - fprintf(ofp, "Average time in state: %10.3f (us)\n", - (total_time / total_switches) / ticks_per_us); - fprintf(ofp, "State start event: %d, state end event: %d\n", - start_event_code, end_event_code); -} - -char *mapfile (char *file) -{ - struct stat statb; - char *rv; - int maphfile; - size_t mapfsize; - - maphfile = open (file, O_RDONLY); - - if (maphfile < 0) - { - fprintf (stderr, "Couldn't read %s, skipping it...\n", file); - return (NULL); - } - - if (fstat (maphfile, &statb) < 0) - { - fprintf (stderr, "Couldn't get size of %s, skipping it...\n", file); - return (NULL); - } - - /* Don't try to mmap directories, FIFOs, semaphores, etc. */ - if (! (statb.st_mode & S_IFREG)) { - fprintf (stderr, "%s is not a regular file, skipping it...\n", file); - return (NULL); - } - - mapfsize = statb.st_size; - - if (mapfsize < 3) - { - fprintf (stderr, "%s zero-length, skipping it...\n", file); - close (maphfile); - return (NULL); - } - - rv = mmap (0, mapfsize, PROT_READ, MAP_SHARED, maphfile, 0); - - if (rv == 0) - { - fprintf (stderr, "%s problem mapping, I quit...\n", file); - exit (-1); - } - close (maphfile); - return (rv); -} - -/* - * main - */ -int main (int argc, char **argv) -{ - char *cpel_file = 0; - char *outputfile = 0; - FILE *ofp; - char *cpel; - int verbose=0; - int curarg=1; - - while (curarg < argc) { - if (!strncmp(argv[curarg], "--input-file", 3)) { - curarg++; - if (curarg < argc) { - cpel_file = argv[curarg]; - curarg++; - continue; - } - fatal("Missing filename after --input-file\n"); - } - if (!strncmp(argv[curarg], "--output-file", 3)) { - curarg ++; - if (curarg < argc) { - outputfile = argv[curarg]; - curarg ++; - continue; - } - fatal("Missing filename after --output-file\n"); - } - if (!strncmp(argv[curarg], "--verbose", 3)) { - curarg++; - verbose++; - continue; - } - if (!strncmp(argv[curarg], "--scatterplot", 4)) { - curarg++; - scatterplot=1; - continue; - } - - if (!strncmp(argv[curarg], "--start-event", 4)) { - curarg++; - if (curarg < argc) { - start_event_code = atol(argv[curarg]); - curarg ++; - continue; - } - fatal("Missing integer after --start-event\n"); - } - if (!strncmp(argv[curarg], "--end-event", 4)) { - curarg++; - if (curarg < argc) { - end_event_code = atol(argv[curarg]); - curarg ++; - continue; - } - fatal("Missing integer after --end-event\n"); - } - if (!strncmp(argv[curarg], "--max-time-sort", 7)) { - sort_type = SORT_MAX_TIME; - curarg++; - continue; - } - if (!strncmp(argv[curarg], "--max-occurrence-sort", 7)) { - sort_type = SORT_MAX_OCCURRENCES; - curarg++; - continue; - } - if (!strncmp(argv[curarg], "--name-sort", 3)) { - sort_type = SORT_NAME; - curarg++; - continue; - } - if (!strncmp(argv[curarg], "--kernel-included", 3)) { - exclude_kernel_from_summary_stats = 0; - curarg++; - continue; - } - if (!strncmp(argv[curarg], "--summary", 3)) { - summary_stats_only=1; - curarg++; - continue; - } - if (!strncmp(argv[curarg], "--filter", 3)) { - curarg ++; - if (curarg < argc) { - name_filter = (u8 *) argv[curarg]; - curarg ++; - continue; - } - fatal("Missing filter string after --filter\n"); - } - - - usage: - fprintf(stderr, - "cpelatency --input-file [--output-file ]\n"); - fprintf(stderr, - " [--start-event ] [--verbose]\n"); - fprintf(stderr, - " [--end-event ]\n"); - fprintf(stderr, - " [--max-time-sort(default) | --max-occurrence-sort |\n"); - - fprintf(stderr, - " --name-sort-sort] [--kernel-included]\n"); - - fprintf(stderr, - " [--summary-stats-only] [--scatterplot]\n"); - - fprintf(stderr, "%s\n", version); - exit(1); - } - - if (cpel_file == 0) - goto usage; - - cpel = mapfile(cpel_file); - if (cpel == 0) { - fprintf(stderr, "Couldn't map %s...\n", cpel_file); - exit(1); - } - - if (!outputfile) { - ofp = fdopen(1, "w"); - if (ofp == NULL) { - fprintf(stderr, "Couldn't fdopen(1)?\n"); - exit(1); - } - } else { - ofp = fopen(outputfile, "w"); - if (ofp == NULL) { - fprintf(stderr, "Couldn't create %s...\n", outputfile); - exit(1); - } - } - - the_strtab_hash = hash_create_string (0, sizeof (uword)); - the_evtdef_hash = hash_create (0, sizeof (uword)); - the_trackdef_hash = hash_create (0, sizeof (uword)); - the_pidtid_hash = hash_create_string (0, sizeof(uword)); - - if (cpel_dump((u8 *)cpel, verbose, ofp)) { - if (outputfile) - unlink(outputfile); - } - - compute_state_statistics(verbose, ofp); - sort_state_statistics(sort_type, ofp); - print_state_statistics(verbose, ofp); - - fclose(ofp); - return(0); -} diff --git a/perftool/cpeldump.c b/perftool/cpeldump.c deleted file mode 100644 index 9011bd03..00000000 --- a/perftool/cpeldump.c +++ /dev/null @@ -1,638 +0,0 @@ -/* - *------------------------------------------------------------------ - * Copyright (c) 2006-2016 Cisco and/or its affiliates. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "cpel.h" - -char *time_format = "%.03d:%.02d:%.02d:%.03d:%.03d "; -static char version[] = "cpeldump 2.0"; - -#define USEC_PER_MS 1000LL -#define USEC_PER_SECOND (1000*USEC_PER_MS) -#define USEC_PER_MINUTE (60*USEC_PER_SECOND) -#define USEC_PER_HOUR (60*USEC_PER_MINUTE) - -uword *the_strtab_hash; /* (name, base-VA) hash of all string tables */ -uword *the_evtdef_hash; /* (event-id, event-definition) hash */ -uword *the_trackdef_hash; /* (track-id, track-definition) hash */ - -int widest_name_format=5; -int widest_track_format=5; - -typedef struct bound_event_ { - u32 event_code; - u8 *event_str; - u8 *datum_str; - u32 is_strtab_ref; -} bound_event_t; - -bound_event_t *bound_events; - -typedef struct bound_track_ { - u32 track; - u8 *track_str; -} bound_track_t; - -bound_track_t *bound_tracks; - -void fatal(char *s) -{ - fprintf(stderr, "%s", s); - exit(1); -} - -typedef enum { - PASS1=1, - PASS2=2, -} pass_t; - -typedef struct { - int (*pass1)(cpel_section_header_t *, int, FILE *); - int (*pass2)(cpel_section_header_t *, int, FILE *); -} section_processor_t; - -int bad_section(cpel_section_header_t *sh, int verbose, FILE *ofp) -{ - fprintf(ofp, "Bad (type 0) section, skipped...\n"); - return(0); -} - -int noop_pass(cpel_section_header_t *sh, int verbose, FILE *ofp) -{ - return(0); -} - -int strtab_pass1(cpel_section_header_t *sh, int verbose, FILE *ofp) -{ - uword *p; - u8 *strtab_data_area = (u8 *)(sh+1); - - /* Multiple string tables with the same name are Bad... */ - p = hash_get_mem(the_strtab_hash, strtab_data_area); - if (p) { - fprintf(ofp, "Duplicate string table name %s", strtab_data_area); - } - /* - * Looks funny, but we really do want key = first string in the - * table, value = address(first string in the table) - */ - hash_set_mem(the_strtab_hash, strtab_data_area, strtab_data_area); - if (verbose) { - fprintf(stderr, "String Table %s\n", strtab_data_area); - } - return(0); -} - -int evtdef_pass1(cpel_section_header_t *sh, int verbose, FILE *ofp) -{ - int i, nevents; - event_definition_section_header_t *edh; - event_definition_t *ep; - u8 *this_strtab; - u32 event_code; - uword *p; - bound_event_t *bp; - int thislen; - - edh = (event_definition_section_header_t *)(sh+1); - nevents = ntohl(edh->number_of_event_definitions); - - if (verbose) { - fprintf(stderr, "Event Definition Section: %d definitions\n", - nevents); - } - - p = hash_get_mem(the_strtab_hash, edh->string_table_name); - if (!p) { - fprintf(ofp, "Fatal: couldn't find string table\n"); - return(1); - } - this_strtab = (u8 *)p[0]; - - ep = (event_definition_t *)(edh+1); - - for (i = 0; i < nevents; i++) { - event_code = ntohl(ep->event); - p = hash_get(the_evtdef_hash, event_code); - if (p) { - fprintf(ofp, "Event %d redefined, retain first definition\n", - event_code); - continue; - } - vec_add2(bound_events, bp, 1); - bp->event_code = event_code; - bp->event_str = this_strtab + ntohl(ep->event_format); - bp->datum_str = this_strtab + ntohl(ep->datum_format); - bp->is_strtab_ref = 0; - /* Decide if the datum format is a %s format => strtab reference */ - { - int j; - int seen_percent=0; - - for (j = 0; j < strlen((char *)bp->datum_str); j++) { - if (bp->datum_str[j] == '%'){ - seen_percent=1; - continue; - } - if (seen_percent && bp->datum_str[j] == 's') { - bp->is_strtab_ref = 1; - } - } - } - - hash_set(the_evtdef_hash, event_code, bp - bound_events); - - thislen = strlen((char *)bp->event_str); - if (thislen > widest_name_format) - widest_name_format = thislen; - - ep++; - } - return (0); -} - -int trackdef_pass1(cpel_section_header_t *sh, int verbose, FILE *ofp) -{ - int i, nevents; - track_definition_section_header_t *tdh; - track_definition_t *tp; - u8 *this_strtab; - u32 track_code; - uword *p; - bound_track_t *btp; - int thislen; - - tdh = (track_definition_section_header_t *)(sh+1); - nevents = ntohl(tdh->number_of_track_definitions); - - if (verbose) { - fprintf(stderr, "Track Definition Section: %d definitions\n", - nevents); - } - - p = hash_get_mem(the_strtab_hash, tdh->string_table_name); - if (!p) { - fprintf(ofp, "Fatal: couldn't find string table\n"); - return(1); - } - this_strtab = (u8 *)p[0]; - - tp = (track_definition_t *)(tdh+1); - - for (i = 0; i < nevents; i++) { - track_code = ntohl(tp->track); - p = hash_get(the_trackdef_hash, track_code); - if (p) { - fprintf(ofp, "track %d redefined, retain first definition\n", - track_code); - continue; - } - vec_add2(bound_tracks, btp, 1); - btp->track = track_code; - btp->track_str = this_strtab + ntohl(tp->track_format); - hash_set(the_trackdef_hash, track_code, btp - bound_tracks); - - thislen = strlen((char *)btp->track_str); - if (thislen > widest_track_format) - widest_track_format = thislen; - tp++; - } - return (0); -} - -int unsupported_pass (cpel_section_header_t *sh, int verbose, FILE *ofp) -{ - if (verbose) { - fprintf(stderr, "Unsupported type %d section\n", - ntohl(sh->section_type)); - } - return(0); -} - -int event_pass2(cpel_section_header_t *sh, int verbose, FILE *ofp) -{ - event_section_header_t *eh; - f64 ticks_per_us; - u32 event_code, track_code; - u64 starttime = 0xFFFFFFFFFFFFFFFFULL; - int nevents; - int i; - uword *p; - event_entry_t *ep; - u64 now; - u64 delta; - u32 hours, minutes, seconds, msec, usec; - u32 time0, time1; - double d; - bound_event_t *bp; - bound_event_t generic_event; - bound_track_t *tp=0; - bound_track_t generic_track; - u32 last_track_code; - u8 *s, *evtpad, *trackpad; - u8 *this_strtab; - - generic_event.event_str = (u8 *)"%d"; - generic_event.datum_str = (u8 *)"0x%08x"; - generic_event.is_strtab_ref = 0; - - generic_track.track_str = (u8 *)"%d"; - last_track_code = 0xdeadbeef; - - eh = (event_section_header_t *)(sh+1); - nevents = ntohl(eh->number_of_events); - ticks_per_us = ((double)ntohl(eh->clock_ticks_per_second)) / 1e6; - - if (verbose) { - fprintf(stderr, "Event section: %d events, %.3f ticks_per_us\n", - nevents, ticks_per_us); - } - - ep = (event_entry_t *)(eh+1); - - p = hash_get_mem(the_strtab_hash, eh->string_table_name); - if (!p) { - fprintf(ofp, "Fatal: couldn't find string table\n"); - return(1); - } - this_strtab = (u8 *)p[0]; - - evtpad = format(0, "%%-%ds ", widest_name_format); - vec_add1(evtpad, 0); - trackpad = format(0, "%%-%ds ", widest_track_format); - vec_add1(trackpad, 0); - - for (i = 0; i < nevents; i++) { - time0 = ntohl (ep->time[0]); - time1 = ntohl (ep->time[1]); - - now = (((u64) time0)<<32) | time1; - - /* Convert from bus ticks to usec */ - d = now; - d /= ticks_per_us; - - now = d; - - if (starttime == 0xFFFFFFFFFFFFFFFFULL) - starttime = now; - - delta = now - starttime; - - /* Delta = time since first event, in usec */ - - hours = delta / USEC_PER_HOUR; - if (hours) - delta -= ((u64) hours * USEC_PER_HOUR); - minutes = delta / USEC_PER_MINUTE; - if (minutes) - delta -= ((u64) minutes * USEC_PER_MINUTE); - seconds = delta / USEC_PER_SECOND; - if (seconds) - delta -= ((u64) seconds * USEC_PER_SECOND); - msec = delta / USEC_PER_MS; - if (msec) - delta -= ((u64) msec * USEC_PER_MS); - - usec = delta; - - /* Output the timestamp */ - fprintf(ofp, time_format, hours, minutes, seconds, msec, usec); - - /* output the track */ - track_code = ntohl(ep->track); - - if (track_code != last_track_code) { - p = hash_get(the_trackdef_hash, track_code); - if (p) { - tp = &bound_tracks[p[0]]; - } else { - tp = &generic_track; - } - } - s = format(0, (char *)tp->track_str, track_code); - vec_add1(s, 0); - fprintf(ofp, (char *)trackpad, s); - vec_free(s); - - /* output the event and datum */ - if (0 && verbose) { - fprintf(stderr, "raw event code %d, raw event datum 0x%x\n", - ntohl(ep->event_code), ntohl(ep->event_datum)); - } - - event_code = ntohl(ep->event_code); - p = hash_get(the_evtdef_hash, event_code); - if (p) { - bp = &bound_events[p[0]]; - } else { - bp = &generic_event; - } - s = format(0, (char *)bp->event_str, ntohl(ep->event_code)); - vec_add1(s, 0); - fprintf(ofp, (char *)evtpad, s); - vec_free(s); - if (bp->is_strtab_ref) { - fprintf(ofp, (char *) bp->datum_str, - &this_strtab[ntohl(ep->event_datum)]); - } else { - fprintf(ofp, (char *) bp->datum_str, ntohl(ep->event_datum)); - } - fputs("\n", ofp); - ep++; - } - vec_free(evtpad); - vec_free(trackpad); - return(0); -} - -/* - * Note: If necessary, add passes / columns to this table to - * handle section order dependencies. - */ - -section_processor_t processors[CPEL_NUM_SECTION_TYPES+1] = -{ - {bad_section, noop_pass}, /* type 0 -- f**ked */ - {strtab_pass1, noop_pass}, /* type 1 -- STRTAB */ - {unsupported_pass, noop_pass}, /* type 2 -- SYMTAB */ - {evtdef_pass1, noop_pass}, /* type 3 -- EVTDEF */ - {trackdef_pass1, noop_pass}, /* type 4 -- TRACKDEF */ - {noop_pass, event_pass2}, /* type 5 -- EVENTS */ -}; - - -int process_section(cpel_section_header_t *sh, int verbose, FILE *ofp, - pass_t pass) -{ - u32 type; - type = ntohl(sh->section_type); - int rv; - int (*fp)(cpel_section_header_t *, int, FILE *); - - if (type > CPEL_NUM_SECTION_TYPES) { - fprintf(stderr, "Unknown section type %d\n", type); - return(1); - } - switch(pass) { - case PASS1: - fp = processors[type].pass1; - break; - - case PASS2: - fp = processors[type].pass2; - break; - - default: - fprintf(stderr, "Unknown pass %d\n", pass); - return(1); - } - - rv = (*fp)(sh, verbose, ofp); - - return(rv); -} - -int cpel_dump_file_header(cpel_file_header_t *fh, int verbose, FILE *ofp) -{ - time_t file_time; - - if (verbose) { - fprintf(stderr, "CPEL file: %s-endian, version %d\n", - ((fh->endian_version & CPEL_FILE_LITTLE_ENDIAN) ? - "little" : "big"), - fh->endian_version & CPEL_FILE_VERSION_MASK); - - file_time = ntohl(fh->file_date); - - fprintf(stderr, "File created %s", ctime(&file_time)); - fprintf(stderr, "File has %d sections\n", - ntohs(fh->nsections)); - } - - return(0); -} - - -int cpel_dump(u8 *cpel, int verbose, FILE *ofp) -{ - cpel_file_header_t *fh; - cpel_section_header_t *sh; - u16 nsections; - u32 section_size; - int i; - - /* First, the file header */ - fh = (cpel_file_header_t *)cpel; - if (fh->endian_version != CPEL_FILE_VERSION) { - if (fh->endian_version & CPEL_FILE_LITTLE_ENDIAN) { - fprintf(stderr, "Little endian data format not supported\n"); - return(1); - } - fprintf(stderr, "Unsupported file version 0x%x\n", - fh->endian_version); - return(1); - } - cpel_dump_file_header(fh, verbose, ofp); - nsections = ntohs(fh->nsections); - - /* - * Take two passes through the file. PASS1 builds - * data structures, PASS2 actually dumps the file. - * Just in case the sections are in an unobvious order. - */ - sh = (cpel_section_header_t *)(fh+1); - for (i = 0; i < nsections; i++) { - section_size = ntohl(sh->data_length); - - if(verbose) { - fprintf(stderr, - "Section type %d, size %d\n", ntohl(sh->section_type), - section_size); - } - - if(process_section(sh, verbose, ofp, PASS1)) - return(1); - - sh++; - sh = (cpel_section_header_t *)(((u8 *)sh)+section_size); - } - - sh = (cpel_section_header_t *)(fh+1); - for (i = 0; i < nsections; i++) { - if(process_section(sh, verbose, ofp, PASS2)) - return(1); - section_size = ntohl(sh->data_length); - sh++; - sh = (cpel_section_header_t *)(((u8 *)sh)+section_size); - } - return(0); -} - - -char *mapfile (char *file) -{ - struct stat statb; - char *rv; - int maphfile; - size_t mapfsize; - - maphfile = open (file, O_RDONLY); - - if (maphfile < 0) - { - fprintf (stderr, "Couldn't read %s, skipping it...\n", file); - return (NULL); - } - - if (fstat (maphfile, &statb) < 0) - { - fprintf (stderr, "Couldn't get size of %s, skipping it...\n", file); - return (NULL); - } - - /* Don't try to mmap directories, FIFOs, semaphores, etc. */ - if (! (statb.st_mode & S_IFREG)) { - fprintf (stderr, "%s is not a regular file, skipping it...\n", file); - return (NULL); - } - - mapfsize = statb.st_size; - - if (mapfsize < 3) - { - fprintf (stderr, "%s zero-length, skipping it...\n", file); - close (maphfile); - return (NULL); - } - - rv = mmap (0, mapfsize, PROT_READ, MAP_SHARED, maphfile, 0); - - if (rv == 0) - { - fprintf (stderr, "%s problem mapping, I quit...\n", file); - exit (-1); - } - close (maphfile); - return (rv); -} - -/* - * main - */ -int main (int argc, char **argv) -{ - char *cpel_file = 0; - char *outputfile = 0; - FILE *ofp; - char *cpel; - int verbose=0; - int curarg=1; - - while (curarg < argc) { - if (!strncmp(argv[curarg], "--input-file", 3)) { - curarg++; - if (curarg < argc) { - cpel_file = argv[curarg]; - curarg++; - continue; - } - fatal("Missing filename after --input-file\n"); - } - if (!strncmp(argv[curarg], "--output-file", 3)) { - curarg ++; - if (curarg < argc) { - outputfile = argv[curarg]; - curarg ++; - continue; - } - fatal("Missing filename after --output-file\n"); - } - if (!strncmp(argv[curarg], "--verbose", 3)) { - curarg++; - verbose = 1; - continue; - } - - usage: - fprintf(stderr, - "cpeldump --input-file [--output-file ]\n"); - fprintf(stderr, "%s\n", version); - exit(1); - } - - if (cpel_file == 0) - goto usage; - - cpel = mapfile(cpel_file); - if (cpel == 0) { - fprintf(stderr, "Couldn't map %s...\n", cpel_file); - exit(1); - } - - if (!outputfile) { - ofp = fdopen(1, "w"); - if (ofp == NULL) { - fprintf(stderr, "Couldn't fdopen(1)?\n"); - exit(1); - } - } else { - ofp = fopen(outputfile, "w"); - if (ofp == NULL) { - fprintf(stderr, "Couldn't create %s...\n", outputfile); - exit(1); - } - } - - the_strtab_hash = hash_create_string (0, sizeof (uword)); - the_evtdef_hash = hash_create (0, sizeof (uword)); - the_trackdef_hash = hash_create (0, sizeof (uword)); - -#ifdef TEST_TRACK_INFO - { - bound_track_t *btp; - vec_add2(bound_tracks, btp, 1); - btp->track = 0; - btp->track_str = "cpu %d"; - hash_set(the_trackdef_hash, 0, btp - bound_tracks); - hash_set(the_trackdef_hash, 1, btp - bound_tracks); - } -#endif - - if (cpel_dump((u8 *)cpel, verbose, ofp)) { - if (outputfile) - unlink(outputfile); - } - - fclose(ofp); - return(0); -} diff --git a/perftool/cpelinreg.c b/perftool/cpelinreg.c deleted file mode 100644 index 115afad7..00000000 --- a/perftool/cpelinreg.c +++ /dev/null @@ -1,892 +0,0 @@ -/* - *------------------------------------------------------------------ - * Copyright (c) 2008-2016 Cisco and/or its affiliates. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * Search for O(N**2) functions bracketed by before/after - * events. The "before" event's datum is used as a tag, e.g. which function - * did we call that's strongly O(N). - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "cpel.h" - -FILE *g_ifp; -char *g_ifile; - -typedef unsigned long long ulonglong; - -void process_traces (void); -void record_instance (ulong tag, ulonglong time); -void report_actors (void); -void scatterplot_data(void); -int entry_event, exit_event; -int nokey; -char *version = "cpelinreg 2.0"; -int model_these[10]; -int model_index; -int summary_stats; -ulonglong first_start_time; -ulonglong last_end_time; -ulonglong total_time; -ulong scatterkey; -int inline_mokus; - -typedef struct bound_track_ { - u32 track_code; - u32 *start_datum; - u8 *dup_event; - int state; - u64 *start_time; - u64 thread_timestamp; - u64 time_thread_on_cpu; -} bound_track_t; - -bound_track_t *bound_tracks; -uword *the_trackdef_hash; - - -#define MAXSTACK 128 - -typedef struct instance_ { - struct instance_ *next; - ulonglong time; -}instance_t; - -typedef struct actor_ { - struct actor_ *next; - ulong key; - struct instance_ *first; - struct instance_ *last; - double a; - double b; - double min; - double max; - double mean; - double r; - ulong ninst; -} actor_t; - -#define NBUCKETS 1811 - -actor_t *hash[NBUCKETS]; - -actor_t *find_or_create_actor (ulong key) -{ - ulong bucket; - actor_t *ap; - u8 *mem; - - bucket = key % NBUCKETS; - - ap = hash[bucket]; - - if (ap == NULL) { - /* Ensure 8-byte alignment to avoid (double) alignment faults */ - mem = malloc(sizeof(*ap) + 4); - if (((uword)(mem)) & 0x7) - mem += 4; - ap = (actor_t *)mem; - - if (ap == NULL) { - fprintf (stderr, "out of memory...\n"); - exit (1); - } - ap->next = 0; - ap->key = key; - ap->first = 0; - ap->last = 0; - ap->a = 0.00; - ap->b = 0.00; - hash [bucket] = ap; - return (ap); - } - - while (ap) { - if (ap->key == key) - return (ap); - ap = ap->next; - } - - mem = malloc(sizeof(*ap)+4); - if (((uword)(mem) & 0x7)) - mem += 4; - ap = (actor_t *)mem; - - if (ap == NULL) { - fprintf (stderr, "out of memory...\n"); - exit (1); - } - ap->key = key; - ap->first = 0; - ap->last = 0; - ap->a = 0.00; - ap->b = 0.00; - - ap->next = hash[bucket]; - hash[bucket] = ap; - - return (ap); -} - -void record_instance (ulong key, ulonglong time) -{ - actor_t *ap; - instance_t *ip; - - if (nokey) - key = 0; - - ap = find_or_create_actor (key); - - ip = (instance_t *)malloc(sizeof(*ip)); - if (ip == NULL) { - fprintf (stderr, "out of memory...\n"); - exit (1); - } - ip->time = time; - ip->next = 0; - - if (ap->first == 0) { - ap->first = ip; - ap->last = ip; - ap->ninst = 1; - } else { - ap->last->next = ip; - ap->last = ip; - ap->ninst++; - } -} - -#define NINSTANCE 200000 - -double x[NINSTANCE]; -double y[NINSTANCE]; - -int actor_compare (const void *arg1, const void *arg2) -{ - double e10k1, e10k2; - actor_t **a1 = (actor_t **)arg1; - actor_t **a2 = (actor_t **)arg2; - double ninst1, ninst2; - - ninst1 = ((double)((*a1)->ninst)); - ninst2 = ((double)((*a2)->ninst)); - - e10k1 = ninst1 * ((*a1)->mean); - e10k2 = ninst2 * ((*a2)->mean); - - if (e10k1 < e10k2) - return (1); - else if (e10k1 == e10k2) - return (0); - else - return (-1); -} - -void report_actors (void) -{ - int i; - actor_t *ap; - instance_t *ip; - int nactors = 0; - int ninstance; - actor_t **actor_vector; - double e10k; - extern void linreg (double *x, double *y, int nitems, double *a, double *b, - double *minp, double *maxp, double *meanp, double *r); - - for (i = 0; i < NBUCKETS; i++) { - ap = hash[i]; - if (ap == NULL) - continue; - while (ap) { - nactors++; - ninstance = 0; - - ip = ap->first; - - while (ip) { - if (ninstance < NINSTANCE) { - x[ninstance] = ninstance; - y[ninstance] = ((double)ip->time); - ninstance++; - } - ip = ip->next; - } - if (ninstance > 1) { -#if DEBUG > 0 - int j; - - for (j = 0; j < ninstance; j++) { - printf("x[%d] = %10.2f, y[%d] = %10.2f\n", - j, x[j], j, y[j]); - } -#endif - - linreg (x, y, ninstance, &ap->a, &ap->b, &ap->min, - &ap->max, &ap->mean, &ap->r); - } else { - ap->a = 0.00; - ap->b = 0.00; - } - - ap = ap->next; - } - } - - actor_vector = (actor_t **)malloc (nactors*sizeof(*actor_vector)); - nactors = 0; - - for (i = 0; i < NBUCKETS; i++) { - ap = hash[i]; - if (ap == NULL) - continue; - while (ap) { - if ((ap->a != 0.00) || (ap->b != 0.00)) { - actor_vector[nactors++] = ap; - } - ap = ap->next; - } - } - - qsort (actor_vector, nactors, sizeof (actor_t *), actor_compare); - - if (summary_stats) - printf("NInst Offset Slope T(Ninst) Min Max Avg %%InstTime R Key"); - else - printf("NInst Offset Slope T(Ninst) Key"); - - for (i = 0; i < model_index; i++) { - printf ("T @ %-8d ", model_these[i]); - } - - printf ("\n"); - - for (i = 0; i < nactors; i++) { - int j; - double ninst; - double pcttot; - ap = actor_vector[i]; - ninst = ap->ninst; - - e10k = ninst * (ap->a + ap->b*((ninst-1.0)/2.0)); - - if (ap->ninst) { - if (summary_stats) { - pcttot = (e10k / ((double)total_time)) * 100.0; - printf ("%6ld %11.2f %11.2f %11.2f %11.2f %11.2f %11.2f %11.2f %11.2f 0x%08lx ", - ap->ninst, ap->a, ap->b, e10k, ap->min, - ap->max, ap->mean, pcttot, ap->r, ap->key); - } - else - printf ("%6ld %11.2f %11.2f %11.2f 0x%08lx ", - ap->ninst, ap->a, ap->b, e10k, ap->key); - - for (j = 0; j < model_index; j++) { - ninst = model_these[j]; - e10k = ninst * (ap->a + ap->b*((ninst-1.0)/2.0)); - printf ("%10.2f ", e10k); - } - printf ("\n"); - } - } -} - -void scatterplot_data(void) -{ - actor_t *ap; - int i; - instance_t *ip; - double time; - int count=0; - - for (i = 0; i < NBUCKETS; i++) { - ap = hash[i]; - if (ap == NULL) - continue; - while (ap) { - if (ap->key == scatterkey){ - ip = ap->first; - while (ip) { - time = ((double)ip->time); - printf ("%d\t%.0f\n", count++, time); - ip = ip->next; - } - return; - } - ap = ap->next; - } - } -} - - -void fatal(char *s) -{ - fprintf(stderr, "%s", s); - fprintf(stderr, "\n"); - exit(1); -} - -typedef enum { - PASS1=1, -} pass_t; - -typedef struct { - int (*pass1)(cpel_section_header_t *, int, FILE *); -} section_processor_t; - -int bad_section(cpel_section_header_t *sh, int verbose, FILE *ofp) -{ - fprintf(ofp, "Bad (type 0) section, skipped...\n"); - return(0); -} - -int noop_pass(cpel_section_header_t *sh, int verbose, FILE *ofp) -{ - return(0); -} - -int unsupported_pass (cpel_section_header_t *sh, int verbose, FILE *ofp) -{ - if (verbose) { - fprintf(ofp, "Unsupported type %d section\n", - ntohl(sh->section_type)); - } - return(0); -} - -int trackdef_pass(cpel_section_header_t *sh, int verbose, FILE *ofp) -{ - int i, nevents; - track_definition_section_header_t *tdh; - track_definition_t *tp; - u32 track_code; - uword *p; - bound_track_t *btp; - - tdh = (track_definition_section_header_t *)(sh+1); - nevents = ntohl(tdh->number_of_track_definitions); - - if (verbose) { - fprintf(stderr, "Track Definition Section: %d definitions\n", - nevents); - } - - tp = (track_definition_t *)(tdh+1); - - for (i = 0; i < nevents; i++) { - track_code = ntohl(tp->track); - p = hash_get(the_trackdef_hash, track_code); - if (p) { - fprintf(ofp, "track %d redefined, retain first definition\n", - track_code); - continue; - } - vec_add2(bound_tracks, btp, 1); - btp->track_code = track_code; - hash_set(the_trackdef_hash, track_code, btp - bound_tracks); - tp++; - } - return (0); -} - - -int event_pass (cpel_section_header_t *sh, int verbose, FILE *ofp) -{ - event_section_header_t *eh; - event_entry_t *ep; - f64 ticks_per_us; - long output_count; - long dup_events = 0; - ulonglong end_time = 0; - double t; - int sp, ancestor; - int nevents, i; - u64 now; - u64 time0, time1; - double d; - u32 last_track_code = 0xdeafb00b; - u32 track_code; - u32 event_code, event_datum; - bound_track_t *tp = 0; - uword *p; - - output_count = 0; - total_time = 0; - - eh = (event_section_header_t *)(sh+1); - nevents = ntohl(eh->number_of_events); - ticks_per_us = ((double)ntohl(eh->clock_ticks_per_second))/1e6; - - if (verbose) { - fprintf(ofp, "%.3f ticks_per_us\n", ticks_per_us); - } - - ep = (event_entry_t *)(eh+1); - - time0 = ntohl (ep->time[0]); - time1 = ntohl (ep->time[1]); - - now = (((u64) time0)<<32) | time1; - d = now; - d /= ticks_per_us; - first_start_time = d; - - for (i = 0; i < nevents; i++) { - time0 = ntohl (ep->time[0]); - time1 = ntohl (ep->time[1]); - - now = (((u64) time0)<<32) | time1; - - /* Convert from bus ticks to usec */ - d = now; - d /= ticks_per_us; - - now = d; - - track_code = ntohl(ep->track); - event_code = ntohl(ep->event_code); - event_datum = ntohl(ep->event_datum); - - if (track_code != last_track_code) { - if (tp) { - tp->thread_timestamp += now - tp->time_thread_on_cpu; - tp->time_thread_on_cpu = 0; - } - p = hash_get(the_trackdef_hash, track_code); - if (!p) { - /* synthesize a new track */ - vec_add2(bound_tracks, tp, 1); - tp->track_code = track_code; - hash_set(the_trackdef_hash, track_code, tp - bound_tracks); - } else { - tp = bound_tracks + p[0]; - } - last_track_code = track_code; - tp->time_thread_on_cpu = now; - } - - if (event_code != entry_event && - event_code != exit_event) { - ep++; - continue; - } - - again: - switch (tp->state) { - case 0: /* not in state */ - /* Another exit event? Stack pop */ - if (event_code == exit_event) { - /* Only if we have something on the stack */ - if (vec_len(tp->start_datum) > 0) { - tp->state = 1; - goto again; - } else { - fprintf (stderr, - "End event before start event, key 0x%x.", - ntohl(ep->event_datum)); - fprintf (stderr, " Interpret results carefully...\n"); - } - } - - tp->state = 1; - if (vec_len(tp->start_datum) >= MAXSTACK) { - int j; - - fprintf (stderr, "stack overflow..\n"); - for (j = vec_len(tp->start_datum)-1; j >= 0; j--) { - fprintf(stderr, "stack[%d]: datum 0x%x\n", - j, tp->start_datum[j]); - } - fprintf (stderr, - "Stack overflow... This occurs when " - "(start, datum)...(end, datum) events\n" - "are not properly paired.\n\n" - "A typical scenario looks like this:\n\n" - " ...\n" - " ELOG(..., START_EVENT, datum);\n" - " if (condition)\n" - " return; /*oops, forgot the end event*/\n" - " ELOG(..., END_EVENT, datum);\n" - " ...\n\n" - "The datum stack dump (above) should make it clear\n" - "where to start looking for a sneak path...\n"); - - exit (1); - } - vec_add1(tp->start_datum, event_datum); - vec_add1(tp->start_time, (tp->thread_timestamp + (now - tp->time_thread_on_cpu))); -#ifdef HAVING_TROUBLE - printf ("sp %lld key 0x%x start time %llu\n", - (long long) vec_len(tp->start_time)-1, event_datum, - (unsigned long long) - tp->start_time [vec_len(tp->start_time)-1]); - printf ("timestamp %llu, now %llu, thread on cpu %llu\n", - (unsigned long long) tp->thread_timestamp, - (unsigned long long) now, - (unsigned long long) tp->time_thread_on_cpu); -#endif - - - - /* - * Multiple identical enter events? If the user knows that - * gcc is producing bogus events due to inline functions, - * trash the duplicate. - */ - if (inline_mokus - && vec_len (tp->start_datum) > 1 - && tp->start_datum [vec_len(tp->start_datum)-1] == - tp->start_datum [vec_len(tp->start_datum)-2]) { - vec_add1 (tp->dup_event, 1); - } else { - vec_add1 (tp->dup_event, 0); - } - - - ep++; - continue; - - case 1: /* in state */ - /* Another entry event? Stack push*/ - if (event_code == entry_event) { - tp->state = 0; - goto again; - } - - if (vec_len(tp->start_datum) == 0) { - fprintf (stderr, "Stack underflow...\n"); - exit (1); - } - - sp = vec_len(tp->start_time)-1; - - end_time = tp->thread_timestamp + (now - tp->time_thread_on_cpu); - - if (!tp->dup_event[sp]) { -#ifdef HAVING_TROUBLE - printf ("sp %d key 0x%x charged %llu\n", sp, - tp->start_datum[sp], end_time - tp->start_time[sp]); - printf (" start %llu, end %llu\n", (unsigned long long) tp->start_time[sp], - (unsigned long long) end_time); -#endif - - record_instance (tp->start_datum[sp], (end_time - - tp->start_time[sp])); - - /* Factor out our time from surrounding services, if any */ - for (ancestor = sp-1; ancestor >= 0; ancestor--) { -#ifdef HAVING_TROUBLE - printf ("Factor out %lld from key 0x%08x\n", - (end_time - tp->start_time[sp]), tp->start_datum[ancestor]); -#endif - tp->start_time[ancestor] += (end_time - tp->start_time[sp]); - } - output_count++; - total_time += (end_time - tp->start_time[sp]); - tp->state = 0; - } else { - dup_events++; - } - _vec_len(tp->start_datum) = sp; - _vec_len(tp->start_time) = sp; - _vec_len(tp->dup_event) = sp; - } - - ep++; - } - last_end_time = now; - - if (scatterkey) { - scatterplot_data(); - exit (0); - } - - if (output_count) { - t = (double)total_time; - printf ("%ld instances of state, %.2f microseconds average\n", - output_count, t / output_count); - - printf ("Total instrumented runtime: %.2f microseconds\n", - ((double)total_time)); - printf ("Total runtime: %lld microseconds\n", - last_end_time - first_start_time); - - t /= (double)(last_end_time - first_start_time); - t *= 100.0; - - if (dup_events) { - printf ("Suppressed %ld duplicate state entry events\n", - dup_events); - } - printf ("Instrumented code accounts for %.2f%% of total time.\n\n", - t); - report_actors(); - } else { - printf ("No instances of state...\n"); - } - - return(0); -} - -/* - * Note: If necessary, add passes / columns to this table to - * handle section order dependencies. - */ - -section_processor_t processors[CPEL_NUM_SECTION_TYPES+1] = -{ - {unsupported_pass}, /* type 0 -- f**ked */ - {noop_pass}, /* type 1 -- STRTAB */ - {noop_pass}, /* type 2 -- SYMTAB */ - {noop_pass}, /* type 3 -- EVTDEF */ - {trackdef_pass}, /* type 4 -- TRACKDEF */ - {event_pass}, /* type 5 -- EVENTS */ -}; - -int process_section(cpel_section_header_t *sh, int verbose, FILE *ofp, - pass_t pass) -{ - u32 type; - type = ntohl(sh->section_type); - int rv; - int (*fp)(cpel_section_header_t *, int, FILE *); - - if (type > CPEL_NUM_SECTION_TYPES) { - fprintf(stderr, "Unknown section type %d\n", type); - return(1); - } - switch(pass) { - case PASS1: - fp = processors[type].pass1; - break; - - default: - fprintf(stderr, "Unknown pass %d\n", pass); - return(1); - } - - rv = (*fp)(sh, verbose, ofp); - - return(rv); -} - -char *mapfile (char *file) -{ - struct stat statb; - char *rv; - int maphfile; - size_t mapfsize; - - maphfile = open (file, O_RDONLY); - - if (maphfile < 0) - { - fprintf (stderr, "Couldn't read %s, skipping it...\n", file); - return (NULL); - } - - if (fstat (maphfile, &statb) < 0) - { - fprintf (stderr, "Couldn't get size of %s, skipping it...\n", file); - return (NULL); - } - - /* Don't try to mmap directories, FIFOs, semaphores, etc. */ - if (! (statb.st_mode & S_IFREG)) { - fprintf (stderr, "%s is not a regular file, skipping it...\n", file); - return (NULL); - } - - mapfsize = statb.st_size; - - if (mapfsize < 3) - { - fprintf (stderr, "%s zero-length, skipping it...\n", file); - close (maphfile); - return (NULL); - } - - rv = mmap (0, mapfsize, PROT_READ, MAP_SHARED, maphfile, 0); - - if (rv == 0) - { - fprintf (stderr, "%s problem mapping, I quit...\n", file); - exit (-1); - } - close (maphfile); - return (rv); -} - -int process_file (u8 *cpel, int verbose) -{ - cpel_file_header_t *fh; - cpel_section_header_t *sh; - u16 nsections; - u32 section_size; - int i; - FILE *ofp = stderr; - - /* First, the file header */ - fh = (cpel_file_header_t *)cpel; - if (fh->endian_version != CPEL_FILE_VERSION) { - if (fh->endian_version & CPEL_FILE_LITTLE_ENDIAN) { - fprintf(stderr, "Little endian data format not supported\n"); - return(1); - } - fprintf(stderr, "Unsupported file version 0x%x\n", - fh->endian_version); - return(1); - } - nsections = ntohs(fh->nsections); - - /* - * Take a passe through the file. - */ - sh = (cpel_section_header_t *)(fh+1); - for (i = 0; i < nsections; i++) { - section_size = ntohl(sh->data_length); - - if(verbose) { - fprintf(ofp, "Section type %d, size %d\n", - ntohl(sh->section_type), - section_size); - } - - if(process_section(sh, verbose, ofp, PASS1)) - return(1); - - sh++; - sh = (cpel_section_header_t *)(((u8 *)sh)+section_size); - } - - return(0); -} - -/**************************************************************************** -* main - -****************************************************************************/ - -int main (int argc, char **argv) -{ - int curarg = 1; - u8 *cpel = 0; - int verbose = 0; - - if (argc < 6) - { - fprintf (stderr, "usage: cpelinreg -i \n"); - fprintf (stderr, " -s start-event --e end-event [-nokey]\n"); - fprintf (stderr, " [-m ][-xtra-stats]\n"); - fprintf (stderr, " [-keyscatterplot ]\n\n"); - fprintf (stderr, "%s\n", version); - exit (1); - } - - while (curarg < argc) { - if (!strncmp (argv[curarg], "-ifile", 2)) { - curarg++; - g_ifile = argv[curarg++]; - continue; - } - if (!strncmp (argv[curarg], "-start", 2)) { - curarg++; - entry_event = atol (argv [curarg++]); - continue; - } - if (!strncmp (argv[curarg], "-end", 2)) { - curarg++; - exit_event = atol (argv [curarg++]); - continue; - } - - if (!strncmp(argv[curarg], "-badinlines", 2)) { - curarg++; - inline_mokus = 1; - continue; - } - - if (!strncmp (argv[curarg], "-x", 2)) { - curarg++; - summary_stats=1; - continue; - } - if (!strncmp (argv[curarg], "-nokey", 2)) { - curarg++; - nokey = 1; - continue; - } - if (!strncmp (argv[curarg], "-keyscatterplot", 2)) { - curarg++; - sscanf (argv[curarg], "%lx", &scatterkey); - curarg++; - continue; - } - - if (!strncmp (argv[curarg], "-model", 2)) { - if (model_index >= sizeof(model_these) / sizeof(int)) { - fprintf (stderr, "Too many model requests\n"); - exit (1); - } - curarg++; - model_these[model_index++] = atol (argv [curarg++]); - continue; - } - if (!strncmp (argv[curarg], "-verbose", 2)) { - verbose++; - curarg++; - continue; - } - - fprintf (stderr, "unknown switch '%s'\n", argv[curarg]); - exit (1); - } - - cpel = (u8 *)mapfile(g_ifile); - - if (cpel == NULL) - { - fprintf (stderr, "Couldn't open %s\n", g_ifile); - exit (1); - } - - printf ("Extracting state info from %s\nentry_event %d, exit_event %d\n", - g_ifile, entry_event, exit_event); - if (nokey) { - printf ("All state instances mapped to a single actor chain\n"); - } - - the_trackdef_hash = hash_create (0, sizeof (uword)); - - process_file(cpel, verbose); - exit (0); -} diff --git a/perftool/cpelstate.c b/perftool/cpelstate.c deleted file mode 100644 index 3fd9ccb9..00000000 --- a/perftool/cpelstate.c +++ /dev/null @@ -1,822 +0,0 @@ -/* - *------------------------------------------------------------------ - * Copyright (c) 2006-2016 Cisco and/or its affiliates. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "cpel.h" -#include - -char *time_format = "%.03d:%.02d:%.02d:%.03d:%.03d "; -static char version[] = "cpelstate 2.0h"; - -#define USEC_PER_MS 1000LL -#define USEC_PER_SECOND (1000*USEC_PER_MS) -#define USEC_PER_MINUTE (60*USEC_PER_SECOND) -#define USEC_PER_HOUR (60*USEC_PER_MINUTE) - -uword *the_strtab_hash; /* (name, base-VA) hash of all string tables */ -uword *the_evtdef_hash; /* (event-id, event-definition) hash */ -uword *the_trackdef_hash; /* (track-id, track-definition) hash */ - -f64 ticks_per_us; -u32 state_event_code = 1; /* default: XR thread-on-cpu */ -int exclude_kernel_from_summary_stats=1; -int summary_stats_only; -int scatterplot; -u8 *name_filter; - -typedef enum { - SORT_MAX_TIME=1, - SORT_MAX_OCCURRENCES, - SORT_NAME, -} sort_t; - -sort_t sort_type = SORT_MAX_TIME; - -int widest_name_format=5; -int widest_track_format=5; - -typedef struct bound_event_ { - u32 event_code; - u8 *event_str; - u8 *datum_str; - u32 is_strtab_ref; -} bound_event_t; - -bound_event_t *bound_events; - -typedef struct bound_track_ { - u32 track; - u8 *track_str; - u64 *ticks_in_state; /* vector of state occurrences */ - f64 mean_ticks_in_state; - f64 variance_ticks_in_state; - f64 total_ticks_in_state; -} bound_track_t; - -bound_track_t *bound_tracks; - -void fatal(char *s) -{ - fprintf(stderr, "%s", s); - exit(1); -} - -typedef enum { - PASS1=1, - PASS2=2, -} pass_t; - -typedef struct { - int (*pass1)(cpel_section_header_t *, int, FILE *); - int (*pass2)(cpel_section_header_t *, int, FILE *); -} section_processor_t; - -int bad_section(cpel_section_header_t *sh, int verbose, FILE *ofp) -{ - fprintf(ofp, "Bad (type 0) section, skipped...\n"); - return(0); -} - -int noop_pass(cpel_section_header_t *sh, int verbose, FILE *ofp) -{ - return(0); -} - -int strtab_pass1(cpel_section_header_t *sh, int verbose, FILE *ofp) -{ - uword *p; - u8 *strtab_data_area = (u8 *)(sh+1); - - /* Multiple string tables with the same name are Bad... */ - p = hash_get_mem(the_strtab_hash, strtab_data_area); - if (p) { - fprintf(ofp, "Duplicate string table name %s", strtab_data_area); - } - /* - * Looks funny, but we really do want key = first string in the - * table, value = address(first string in the table) - */ - hash_set_mem(the_strtab_hash, strtab_data_area, strtab_data_area); - if (verbose) { - fprintf(ofp, "String Table %s\n", strtab_data_area); - } - return(0); -} - -int evtdef_pass1(cpel_section_header_t *sh, int verbose, FILE *ofp) -{ - int i, nevents; - event_definition_section_header_t *edh; - event_definition_t *ep; - u8 *this_strtab; - u32 event_code; - uword *p; - bound_event_t *bp; - int thislen; - - edh = (event_definition_section_header_t *)(sh+1); - nevents = ntohl(edh->number_of_event_definitions); - - if (verbose) { - fprintf(ofp, "Event Definition Section: %d definitions\n", - nevents); - } - - p = hash_get_mem(the_strtab_hash, edh->string_table_name); - if (!p) { - fprintf(ofp, "Fatal: couldn't find string table\n"); - return(1); - } - this_strtab = (u8 *)p[0]; - - ep = (event_definition_t *)(edh+1); - - for (i = 0; i < nevents; i++) { - event_code = ntohl(ep->event); - p = hash_get(the_evtdef_hash, event_code); - if (p) { - fprintf(ofp, "Event %d redefined, retain first definition\n", - event_code); - continue; - } - vec_add2(bound_events, bp, 1); - bp->event_code = event_code; - bp->event_str = this_strtab + ntohl(ep->event_format); - bp->datum_str = this_strtab + ntohl(ep->datum_format); - bp->is_strtab_ref = 0; - /* Decide if the datum format is a %s format => strtab reference */ - { - int j; - int seen_percent=0; - - for (j = 0; j < strlen((char *)(bp->datum_str)); j++) { - if (bp->datum_str[j] == '%'){ - seen_percent=1; - continue; - } - if (seen_percent && bp->datum_str[j] == 's') { - bp->is_strtab_ref = 1; - } - } - } - - hash_set(the_evtdef_hash, event_code, bp - bound_events); - - thislen = strlen((char *)bp->event_str); - if (thislen > widest_name_format) - widest_name_format = thislen; - - ep++; - } - return (0); -} - -int trackdef_pass1(cpel_section_header_t *sh, int verbose, FILE *ofp) -{ - int i, nevents; - track_definition_section_header_t *tdh; - track_definition_t *tp; - u8 *this_strtab; - u32 track_code; - uword *p; - bound_track_t *btp; - int thislen; - - tdh = (track_definition_section_header_t *)(sh+1); - nevents = ntohl(tdh->number_of_track_definitions); - - if (verbose) { - fprintf(ofp, "Track Definition Section: %d definitions\n", - nevents); - } - - p = hash_get_mem(the_strtab_hash, tdh->string_table_name); - if (!p) { - fprintf(ofp, "Fatal: couldn't find string table\n"); - return(1); - } - this_strtab = (u8 *)p[0]; - - tp = (track_definition_t *)(tdh+1); - - for (i = 0; i < nevents; i++) { - track_code = ntohl(tp->track); - p = hash_get(the_trackdef_hash, track_code); - if (p) { - fprintf(ofp, "track %d redefined, retain first definition\n", - track_code); - continue; - } - vec_add2(bound_tracks, btp, 1); - btp->track = track_code; - btp->track_str = this_strtab + ntohl(tp->track_format); - hash_set(the_trackdef_hash, track_code, btp - bound_tracks); - - thislen = strlen((char *)(btp->track_str)); - if (thislen > widest_track_format) - widest_track_format = thislen; - tp++; - } - return (0); -} - -int unsupported_pass (cpel_section_header_t *sh, int verbose, FILE *ofp) -{ - if (verbose) { - fprintf(ofp, "Unsupported type %d section\n", - ntohl(sh->section_type)); - } - return(0); -} - -int event_pass2(cpel_section_header_t *sh, int verbose, FILE *ofp) -{ - event_section_header_t *eh; - u32 track_code; - int nevents; - int i; - uword *p; - event_entry_t *ep; - u64 now; - u32 time0, time1; - bound_track_t generic_track; - u32 last_track_code; - u64 state_start_ticks=0; - u64 ticks_in_state; - bound_track_t *state_track=0; - int in_state=0; - generic_track.track_str = (u8 *) "%d"; - last_track_code = 0xdeafbeef; - - eh = (event_section_header_t *)(sh+1); - nevents = ntohl(eh->number_of_events); - ticks_per_us = ((double)ntohl(eh->clock_ticks_per_second))/1e6; - - if (verbose) { - fprintf(ofp, "%.3f ticks_per_us\n", ticks_per_us); - } - - ep = (event_entry_t *)(eh+1); - - p = hash_get_mem(the_strtab_hash, eh->string_table_name); - if (!p) { - fprintf(ofp, "Fatal: couldn't find string table\n"); - return(1); - } - - for (i = 0; i < nevents; i++) { - time0 = ntohl (ep->time[0]); - time1 = ntohl (ep->time[1]); - - now = (((u64) time0)<<32) | time1; - - /* Found the state-change event ? */ - if (ntohl(ep->event_code) == state_event_code) { - /* - * Add a ticks-in-state record, unless - * this is the "prime mover" event instance - */ - if (in_state) { - ticks_in_state = now - state_start_ticks; - vec_add1(state_track->ticks_in_state, ticks_in_state); - } - /* switch to now-current track */ - state_start_ticks = now; - track_code = ntohl(ep->track); - if (track_code != last_track_code) { - p = hash_get(the_trackdef_hash, track_code); - if (p) { - state_track = &bound_tracks[p[0]]; - } else { - state_track = &generic_track; - } - last_track_code = track_code; - } - in_state = 1; - } - ep++; - } - return(0); -} - -/* - * Note: If necessary, add passes / columns to this table to - * handle section order dependencies. - */ - -section_processor_t processors[CPEL_NUM_SECTION_TYPES+1] = -{ - {bad_section, noop_pass}, /* type 0 -- f**ked */ - {strtab_pass1, noop_pass}, /* type 1 -- STRTAB */ - {unsupported_pass, noop_pass}, /* type 2 -- SYMTAB */ - {evtdef_pass1, noop_pass}, /* type 3 -- EVTDEF */ - {trackdef_pass1, noop_pass}, /* type 4 -- TRACKDEF */ - {noop_pass, event_pass2}, /* type 5 -- EVENTS */ -}; - - -int process_section(cpel_section_header_t *sh, int verbose, FILE *ofp, - pass_t pass) -{ - u32 type; - type = ntohl(sh->section_type); - int rv; - int (*fp)(cpel_section_header_t *, int, FILE *); - - if (type > CPEL_NUM_SECTION_TYPES) { - fprintf(stderr, "Unknown section type %d\n", type); - return(1); - } - switch(pass) { - case PASS1: - fp = processors[type].pass1; - break; - - case PASS2: - fp = processors[type].pass2; - break; - - default: - fprintf(stderr, "Unknown pass %d\n", pass); - return(1); - } - - rv = (*fp)(sh, verbose, ofp); - - return(rv); -} - -int cpel_dump_file_header(cpel_file_header_t *fh, int verbose, FILE *ofp) -{ - time_t file_time; - - if (verbose) { - fprintf(ofp, "CPEL file: %s-endian, version %d\n", - ((fh->endian_version & CPEL_FILE_LITTLE_ENDIAN) ? - "little" : "big"), - fh->endian_version & CPEL_FILE_VERSION_MASK); - - file_time = ntohl(fh->file_date); - - fprintf(ofp, "File created %s", ctime(&file_time)); - fprintf(ofp, "File has %d sections\n", - ntohs(fh->nsections)); - } - - return(0); -} - - -int cpel_dump(u8 *cpel, int verbose, FILE *ofp) -{ - cpel_file_header_t *fh; - cpel_section_header_t *sh; - u16 nsections; - u32 section_size; - int i; - - /* First, the file header */ - fh = (cpel_file_header_t *)cpel; - if (fh->endian_version != CPEL_FILE_VERSION) { - if (fh->endian_version & CPEL_FILE_LITTLE_ENDIAN) { - fprintf(stderr, "Little endian data format not supported\n"); - return(1); - } - fprintf(stderr, "Unsupported file version 0x%x\n", - fh->endian_version); - return(1); - } - cpel_dump_file_header(fh, verbose, ofp); - nsections = ntohs(fh->nsections); - - /* - * Take two passes through the file. PASS1 builds - * data structures, PASS2 actually dumps the file. - * Just in case the sections are in an unobvious order. - */ - sh = (cpel_section_header_t *)(fh+1); - for (i = 0; i < nsections; i++) { - section_size = ntohl(sh->data_length); - - if(verbose) { - fprintf(ofp, "Section type %d, size %d\n", ntohl(sh->section_type), - section_size); - } - - if(process_section(sh, verbose, ofp, PASS1)) - return(1); - - sh++; - sh = (cpel_section_header_t *)(((u8 *)sh)+section_size); - } - - sh = (cpel_section_header_t *)(fh+1); - for (i = 0; i < nsections; i++) { - if(process_section(sh, verbose, ofp, PASS2)) - return(1); - section_size = ntohl(sh->data_length); - sh++; - sh = (cpel_section_header_t *)(((u8 *)sh)+section_size); - } - return(0); -} - -void compute_state_statistics(int verbose, FILE *ofp) -{ - int i, j; - bound_track_t *bp; - f64 fticks; - - /* Across the bound tracks */ - for (i = 0; i < vec_len(bound_tracks); i++) { - bp = &bound_tracks[i]; - bp->mean_ticks_in_state = 0.0; - bp->variance_ticks_in_state = 0.0; - bp->total_ticks_in_state = 0.0; - for (j = 0; j < vec_len(bp->ticks_in_state); j++) { - bp->total_ticks_in_state += (f64) bp->ticks_in_state[j]; - } - /* Compute mean */ - if (vec_len(bp->ticks_in_state)) { - bp->mean_ticks_in_state = bp->total_ticks_in_state / - ((f64) vec_len(bp->ticks_in_state)); - } - /* Accumulate sum: (Xi-Xbar)**2 */ - for (j = 0; j < vec_len(bp->ticks_in_state); j++) { - fticks = bp->ticks_in_state[j]; - bp->variance_ticks_in_state += - (fticks - bp->mean_ticks_in_state)* - (fticks - bp->mean_ticks_in_state); - } - /* Compute s**2, the unbiased estimator of sigma**2 */ - if (vec_len(bp->ticks_in_state) > 1) { - bp->variance_ticks_in_state /= (f64) - (vec_len(bp->ticks_in_state)-1); - } - } -} - -int track_compare_max (const void *arg1, const void *arg2) -{ - bound_track_t *a1 = (bound_track_t *)arg1; - bound_track_t *a2 = (bound_track_t *)arg2; - f64 v1, v2; - - v1 = a1->total_ticks_in_state; - v2 = a2->total_ticks_in_state; - - if (v1 < v2) - return (1); - else if (v1 == v2) - return (0); - else return (-1); -} - -int track_compare_occurrences (const void *arg1, const void *arg2) -{ - bound_track_t *a1 = (bound_track_t *)arg1; - bound_track_t *a2 = (bound_track_t *)arg2; - f64 v1, v2; - - v1 = (f64) vec_len(a1->ticks_in_state); - v2 = (f64) vec_len(a2->ticks_in_state); - - if (v1 < v2) - return (1); - else if (v1 == v2) - return (0); - else return (-1); -} - -int track_compare_name (const void *arg1, const void *arg2) -{ - bound_track_t *a1 = (bound_track_t *)arg1; - bound_track_t *a2 = (bound_track_t *)arg2; - - return (strcmp((char *)(a1->track_str), (char *)(a2->track_str))); -} - -void sort_state_statistics(sort_t type, FILE *ofp) -{ - int (*compare)(const void *, const void *)=0; - - if (summary_stats_only) - return; - - switch(type) { - case SORT_MAX_TIME: - fprintf(ofp, "Results sorted by max time in state.\n"); - compare = track_compare_max; - break; - - case SORT_MAX_OCCURRENCES: - fprintf(ofp, "Results sorted by max occurrences of state.\n"); - compare = track_compare_occurrences; - break; - - case SORT_NAME: - compare = track_compare_name; - fprintf(ofp, "Results sorted by process-id/name/thread ID\n"); - break; - - default: - fatal("sort type not set?"); - } - - qsort (bound_tracks, vec_len(bound_tracks), - sizeof (bound_track_t), compare); -} - -void print_state_statistics(int verbose, FILE *ofp) -{ - int i,j; - u8 *trackpad; - bound_track_t *bp; - f64 total_time = 0.0; - f64 total_switches = 0.0; - - trackpad = format(0, "%%-%ds ", widest_track_format); - vec_add1(trackpad, 0); - - if (!summary_stats_only) { - fprintf(ofp, (char *)trackpad, "ProcThread"); - fprintf(ofp, " Mean(us) Stdev(us) Total(us) N\n"); - } - - for (i = 0; i < vec_len(bound_tracks); i++) { - bp = &bound_tracks[i]; - if (bp->mean_ticks_in_state == 0.0) - continue; - - if (name_filter && - strncmp((char *)(bp->track_str), (char *)name_filter, - strlen((char *)name_filter))) - continue; - - /* - * Exclude kernel threads (e.g. idle thread) from - * state statistics - */ - if (exclude_kernel_from_summary_stats && - !strncmp((char *)(bp->track_str), "kernel ", 7)) - continue; - - total_switches += (f64) vec_len(bp->ticks_in_state); - - if (!summary_stats_only) { - fprintf(ofp, (char *) trackpad, bp->track_str); - fprintf(ofp, "%10.3f +- %10.3f", - bp->mean_ticks_in_state / ticks_per_us, - sqrt(bp->variance_ticks_in_state) - / (f64) ticks_per_us); - fprintf(ofp, "%12.3f", - bp->total_ticks_in_state / ticks_per_us); - fprintf(ofp, "%8d\n", (int)vec_len(bp->ticks_in_state)); - } - - if (scatterplot) { - for (j = 0; j < vec_len(bp->ticks_in_state); j++) { - fprintf(ofp, "%.3f\n", - (f64)bp->ticks_in_state[j] / ticks_per_us); - } - } - - total_time += bp->total_ticks_in_state; - } - - if (!summary_stats_only) - fprintf(ofp, "\n"); - fprintf(ofp, "Note: the following statistics %s kernel-thread activity.\n", - exclude_kernel_from_summary_stats ? "exclude" : "include"); - if (name_filter) - fprintf(ofp, - "Note: only pid/proc/threads matching '%s' are included.\n", - name_filter); - - fprintf(ofp, - "Total runtime: %10.3f (us), Total state switches: %.0f\n", - total_time / ticks_per_us, total_switches); - fprintf(ofp, "Average time in state: %10.3f (us)\n", - (total_time / total_switches) / ticks_per_us); -} - -char *mapfile (char *file) -{ - struct stat statb; - char *rv; - int maphfile; - size_t mapfsize; - - maphfile = open (file, O_RDONLY); - - if (maphfile < 0) - { - fprintf (stderr, "Couldn't read %s, skipping it...\n", file); - return (NULL); - } - - if (fstat (maphfile, &statb) < 0) - { - fprintf (stderr, "Couldn't get size of %s, skipping it...\n", file); - return (NULL); - } - - /* Don't try to mmap directories, FIFOs, semaphores, etc. */ - if (! (statb.st_mode & S_IFREG)) { - fprintf (stderr, "%s is not a regular file, skipping it...\n", file); - return (NULL); - } - - mapfsize = statb.st_size; - - if (mapfsize < 3) - { - fprintf (stderr, "%s zero-length, skipping it...\n", file); - close (maphfile); - return (NULL); - } - - rv = mmap (0, mapfsize, PROT_READ, MAP_SHARED, maphfile, 0); - - if (rv == 0) - { - fprintf (stderr, "%s problem mapping, I quit...\n", file); - exit (-1); - } - close (maphfile); - return (rv); -} - -/* - * main - */ -int main (int argc, char **argv) -{ - char *cpel_file = 0; - char *outputfile = 0; - FILE *ofp; - char *cpel; - int verbose=0; - int curarg=1; - - while (curarg < argc) { - if (!strncmp(argv[curarg], "--input-file", 3)) { - curarg++; - if (curarg < argc) { - cpel_file = argv[curarg]; - curarg++; - continue; - } - fatal("Missing filename after --input-file\n"); - } - if (!strncmp(argv[curarg], "--output-file", 3)) { - curarg ++; - if (curarg < argc) { - outputfile = argv[curarg]; - curarg ++; - continue; - } - fatal("Missing filename after --output-file\n"); - } - if (!strncmp(argv[curarg], "--verbose", 3)) { - curarg++; - verbose++; - continue; - } - if (!strncmp(argv[curarg], "--scatterplot", 4)) { - curarg++; - scatterplot=1; - continue; - } - - if (!strncmp(argv[curarg], "--state-event", 4)) { - curarg++; - if (curarg < argc) { - state_event_code = atol(argv[curarg]); - curarg ++; - continue; - } - fatal("Missing integer after --state-event\n"); - } - if (!strncmp(argv[curarg], "--max-time-sort", 7)) { - sort_type = SORT_MAX_TIME; - curarg++; - continue; - } - if (!strncmp(argv[curarg], "--max-occurrence-sort", 7)) { - sort_type = SORT_MAX_OCCURRENCES; - curarg++; - continue; - } - if (!strncmp(argv[curarg], "--name-sort", 3)) { - sort_type = SORT_NAME; - curarg++; - continue; - } - if (!strncmp(argv[curarg], "--kernel-included", 3)) { - exclude_kernel_from_summary_stats = 0; - curarg++; - continue; - } - if (!strncmp(argv[curarg], "--summary", 3)) { - summary_stats_only=1; - curarg++; - continue; - } - if (!strncmp(argv[curarg], "--filter", 3)) { - curarg ++; - if (curarg < argc) { - name_filter = (u8 *)argv[curarg]; - curarg ++; - continue; - } - fatal("Missing filter string after --filter\n"); - } - - - usage: - fprintf(stderr, - "cpelstate --input-file [--output-file ]\n"); - fprintf(stderr, - " [--state-event ] [--verbose]\n"); - fprintf(stderr, - " [--max-time-sort(default) | --max-occurrence-sort |\n"); - - fprintf(stderr, - " --name-sort-sort] [--kernel-included]\n"); - - fprintf(stderr, - " [--summary-stats-only] [--scatterplot]\n"); - - fprintf(stderr, "%s\n", version); - exit(1); - } - - if (cpel_file == 0) - goto usage; - - cpel = mapfile(cpel_file); - if (cpel == 0) { - fprintf(stderr, "Couldn't map %s...\n", cpel_file); - exit(1); - } - - if (!outputfile) { - ofp = fdopen(1, "w"); - if (ofp == NULL) { - fprintf(stderr, "Couldn't fdopen(1)?\n"); - exit(1); - } - } else { - ofp = fopen(outputfile, "w"); - if (ofp == NULL) { - fprintf(stderr, "Couldn't create %s...\n", outputfile); - exit(1); - } - } - - the_strtab_hash = hash_create_string (0, sizeof (uword)); - the_evtdef_hash = hash_create (0, sizeof (uword)); - the_trackdef_hash = hash_create (0, sizeof (uword)); - - if (cpel_dump((u8 *) cpel, verbose, ofp)) { - if (outputfile) - unlink(outputfile); - } - - compute_state_statistics(verbose, ofp); - sort_state_statistics(sort_type, ofp); - print_state_statistics(verbose, ofp); - - fclose(ofp); - return(0); -} diff --git a/perftool/delsvec.c b/perftool/delsvec.c deleted file mode 100644 index 724935d3..00000000 --- a/perftool/delsvec.c +++ /dev/null @@ -1,315 +0,0 @@ -/* - *------------------------------------------------------------------ - * Copyright (c) 2006-2016 Cisco and/or its affiliates. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* Break up a delimited string into a vector of substrings */ - -#include -#include -#include -#include -#include - -/* - * #define UNIT_TESTS 1 - * #define MATCH_TRACE 1 - */ - -/* - * delsvec - * break up an input string into a vector of [null-terminated] u8 *'s - * - * Each supplied delimiter character results in a string in the output - * vector, unless the delimiters occur back-to-back. When matched, - * a whitespace character in the delimiter consumes an arbitrary - * run of whitespace. See the unit tests at the end of this file - * for a set of examples. - * - * Returns a u8 **, or NULL if the input fails to match. It is assumed - * that both input and fmt are C strings, not necessarily vectors. - * - * Output strings are both vectors and proper C strings. - */ - -static u8 **string_cache; -static u8 **svec_cache; - -void delsvec_recycle_this_string (u8 *s) -{ - if (s) { - _vec_len (s) = 0; - vec_add1(string_cache, s); - } -} - -void delsvec_recycle_this_svec (u8 **svec) -{ - if (svec) { - if (svec_cache) { - vec_free (svec_cache); - } - _vec_len (svec) = 0; - svec_cache = svec; - } -} - -int pvl (char *a) -{ - return vec_len(a); -} - -u8 **delsvec(void *input_arg, char *fmt) -{ - u8 **rv = 0; - int input_index=0; - u8 *this; - int dirflag=0; - int i; - u8 *input = input_arg; - - if (svec_cache) { - rv = svec_cache; - svec_cache = 0; - } - - while (fmt) { - dirflag=0; - if (vec_len (string_cache) > 0) { - this = string_cache [vec_len(string_cache)-1]; - _vec_len (string_cache) = vec_len (string_cache) - 1; - } else - this = 0; - /* - * '*' means one of two things: match the rest of the input, - * or match as many characters as possible - */ - if (fmt[0] == '*') { - fmt++; - dirflag=1; - /* - * no more format: eat rest of string... - */ - if (!fmt[0]) { - for (;input[input_index]; input_index++) - vec_add1(this, input[input_index]); - if (vec_len(this)) { - vec_add1(this, 0); -#ifdef MATCH_TRACE - printf("final star-match adds: '%s'\n", this); -#endif - vec_add1(rv, this); - } else { - vec_add1(string_cache, this); - } - - return(rv); - } - } - /* - * Left-to-right scan, adding chars until next delimiter char - * appears. - */ - if (!dirflag) { - while (input[input_index]) { - if (input[input_index] == fmt[0]) { - /* If we just (exact) matched a whitespace delimiter */ - if (fmt[0] == ' '){ - /* scan forward eating whitespace */ - while (input[input_index] == ' ' || - input[input_index] == '\t' || - input[input_index] == '\n') - input_index++; - input_index--; - } - goto found; - } - /* If we're looking for whitespace */ - if (fmt[0] == ' ') { - /* and we have whitespace */ - if (input[input_index] == ' ' || - input[input_index] == '\t' || - input[input_index] == '\n') { - /* scan forward eating whitespace */ - while (input[input_index] == ' ' || - input[input_index] == '\t' || - input[input_index] == '\n') { - input_index++; - } - input_index--; - goto found; - } - } - /* Not a delimiter, save it */ - vec_add1(this, input[input_index]); - input_index++; - } - /* - * Fell off the wagon, clean up and bail out - */ - bail: - -#ifdef MATCH_TRACE - printf("failed, fmt[0] = '%c', input[%d]='%s'\n", - fmt[0], input_index, &input[input_index]); -#endif - delsvec_recycle_this_string(this); - for (i = 0; i < vec_len(rv); i++) - delsvec_recycle_this_string(rv[i]); - delsvec_recycle_this_svec(rv); - return(0); - - found: - /* - * Delimiter matched - */ - input_index++; - fmt++; - /* - * If we actually accumulated non-delimiter characters, - * add them to the result vector - */ - if (vec_len(this)) { - vec_add1(this, 0); -#ifdef MATCH_TRACE - printf("match: add '%s'\n", this); -#endif - vec_add1(rv, this); - } else { - vec_add1(string_cache, this); - } - } else { - /* - * right-to-left scan, '*' not at - * the end of the delimiter string - */ - i = input_index; - while (input[++i]) - ; /* scan forward */ - i--; - while (i > input_index) { - if (input[i] == fmt[0]) - goto found2; - - if (fmt[0] == ' ' || fmt[0] == '\t' || - fmt[0] == '\n') { - if (input[i] == ' ' || - input[i] == '\t' || - input[i] == '\n') - goto found2; - } - i--; - } - goto bail; - - found2: - for (; input_index < i; input_index++) { - vec_add1(this, input[input_index]); - } - input_index++; - fmt++; - vec_add1(this, 0); -#ifdef MATCH_TRACE - printf("inner '*' match: add '%s'\n", this); -#endif - vec_add1(rv, this); - } - } - return (rv); -} - -#ifdef UNIT_TESTS - -typedef struct utest_ { - char *string; - char *fmt; -} utest_t; - -utest_t tests[] = { -#ifdef NOTDEF - {"Dec 7 08:56", - " :*"}, - {"Dec 17 08:56", - " :*"}, - {"Dec 7 08:56:41.239 install/inst_repl 0/9/CPU0 t1 [40989] File List:Successfully blobbified file list. Took 1 milliseconds", - " ::. / // [] *"}, - {"RP/0/9/CPU0:Dec 7 08:55:28.550 : sam_server[291]: SAM backs up digest list to memory file", - "///: ::. : []: *"}, - /* Expected to fail */ - {"Dec 7 08:56:41.239 install/inst_repl 0/9/CPU0 t1 [40989] File List:Successfully blobbified file list. Took 1 milliseconds", - "///: ::. : : *"}, - /* Expected to fail */ - {"RP/0/9/CPU0:Dec 7 08:55:28.550 : sam_server[291]: SAM backs up digest list to memory file", - " ::. / // [] *"}, - {"THIS that and + theother", "*+ *"}, - {"Dec 12 15:33:07.103 ifmgr/errors 0/RP0/CPU0 3# t2 Failed to open IM connection: No such file or directory", " ::. / // *"}, - {"Dec 16 21:43:47.328 ifmgr/bulk 0/3/CPU0 t8 Bulk DPC async download complete. Partitions 1, node_count 1, total_out 0, out_offset 0, out_expected 0: No error"," ::. / // *"}, - {"t:0x53034bd6 CPU:00 PROCESS :PROCCREATE_NAME", - ": : :*"}, - {" pid:1", " *"}, - {"t:0x53034cbb CPU:00 THREAD :THCREATE pid:1 tid:1", - ": : : pid: tid:*"}, - {"t:0x5303f950 CPU:00 COMM :REC_PULSE scoid:0x40000003 pid:364659", - ": : : *"}, - {"/hfr-base-3.3.85/lib/libttyconnection.dll 0xfc000000 0x0000306c 0xfc027000 0x000001c8 1", - " *"}, - {"Feb 28 02:38:26.123 seqtrace 0/1/CPU0 t8 :msg_receive:ifmgr/t8:IMC_MSG_MTU_UPDATE:ppp_ma/t1", - " ::. // ::::*"}, - - {"Feb 28 02:38:26.123 seqtrace 0/1/CPU0 t8 :msg_send_event:call:ifmgr/t8:124/0:cdp/t1", - " ::. // :msg_send_event::::*"}, - - {"Feb 28 02:38:26.125 seqtrace 0/1/CPU0 t1 :msg_receive_event:cdp/t1:124/0", - " ::. // :msg_receive_event::*"} - {"t:0x645dd86d CPU:00 USREVENT:EVENT:100, d0:0x00000002 d1:0x00000000", - ": : USREVENT:EVENT:, d0: *"} - {"t:0x5303f950 CPU:00 COMM :REC_PULSE scoid:0x40000003 pid:364659", - ": : : *"}, - {"t:0x2ccf9f5a CPU:00 INT_ENTR:0x80000000 (-2147483648) IP:0x002d8b18", - ": : INT_ENTR: IP:*"} - {"t:0xd473951c CPU:00 KER_EXIT:SCHED_GET/88 ret_val:2 sched_priority:10", - ": : KER_EXIT:SCHED_GET : sched_priority:*"} - {"t:0x00000123 CPU:01 SYSTEM :FUNC_ENTER thisfn:0x40e62048 call_site:0x00000000", - ": : SYSTEM :FUNC_ thisfn: *"}, - {"t:0x5af8de95 CPU:00 INT_HANDLER_ENTR:0x0000004d (77) PID:8200 IP:0x00000000 AREA:0x0bf9b290", ": : INT_HANDLER_*"}, -#endif - {"t:0x6d1ff92f CPU:00 CONTROL: BUFFER sequence = 1053, num_events = 714", - ": : CONTROL*"}, - {"t:0x6d1ff92f CPU:00 CONTROL :TIME msb:0x0000003c lsb(offset):0x6d1ff921", - ": : CONTROL*"}, -}; - -int main (int argc, char **argv) -{ - int i, j; - u8 **svec; - - for (j = 0; j < ARRAY_LEN(tests); j++) { - printf ("input string: '%s'\n", tests[j].string); - printf ("delimiter arg: '%s'\n", tests[j].fmt); - printf ("parse trace:\n"); - svec = delsvec(tests[j].string, tests[j].fmt); - if (!svec) { - printf("index %d failed\n", j); - continue; - } - printf("%d substring vectors\n", vec_len(svec)); - for (i = 0; i < vec_len(svec); i++) { - printf("[%d]: '%s'\n", i, svec[i]); - } - printf ("-------------------\n"); - } - exit(0); -} -#endif diff --git a/perftool/linreg.c b/perftool/linreg.c deleted file mode 100644 index 084091bb..00000000 --- a/perftool/linreg.c +++ /dev/null @@ -1,78 +0,0 @@ -/* - *------------------------------------------------------------------ - * Copyright (c) 2006-2016 Cisco and/or its affiliates. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* see "Numerical Recipies in C, 2nd ed." p 665 */ - -#include -#include - -/* - * linreg - * Linear regression of (xi, yi), returns parameters for least-squares - * fit y = a + bx. Also, compute Pearson's R. - */ -void linreg (double *x, double *y, int nitems, double *a, double *b, - double *minp, double *maxp, double *meanp, double *r) -{ - double sx = 0.0; - double sy = 0.0; - double st2 = 0.0; - double min = y[0]; - double max = 0.0; - double ss, meanx, meany, t; - double errx, erry, prodsum, sqerrx, sqerry; - int i; - - *b = 0.0; - - for (i = 0; i < nitems; i++) { - sx += x[i]; - sy += y[i]; - if (y[i] < min) - min = y[i]; - if (y[i] > max) - max = y[i]; - } - ss = nitems; - meanx = sx / ss; - meany = *meanp = sy / ss; - *minp = min; - *maxp = max; - - for (i = 0; i < nitems; i++) { - t = x[i] - meanx; - st2 += t*t; - *b += t*y[i]; - } - - *b /= st2; - *a = (sy-sx*(*b))/ss; - - prodsum = 0.0; - sqerrx = 0.0; - sqerry = 0.0; - - /* Compute numerator of Pearson's R */ - for (i = 0; i < nitems; i++) { - errx = x[i] - meanx; - erry = y[i] - meany; - prodsum += errx * erry; - sqerrx += errx*errx; - sqerry += erry*erry; - } - - *r = prodsum / (sqrt(sqerrx)*sqrt(sqerry)); -} diff --git a/perftool/new.cpel b/perftool/new.cpel deleted file mode 100644 index b0f35958..00000000 Binary files a/perftool/new.cpel and /dev/null differ diff --git a/perftool/new.elog b/perftool/new.elog deleted file mode 100644 index 2d99bb16..00000000 Binary files a/perftool/new.elog and /dev/null differ diff --git a/perftool/props.c b/perftool/props.c deleted file mode 100644 index 84af5b1c..00000000 --- a/perftool/props.c +++ /dev/null @@ -1,280 +0,0 @@ -/* - *------------------------------------------------------------------ - * Copyright (c) 2006-2016 Cisco and/or its affiliates. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include -#include -#include -#include - -static char *sxerox (char *s); - -#define NBUCKETS 97 - -typedef struct prop_ { - struct prop_ *next; - char *name; - char *value; -} prop_t; - -static prop_t *buckets [NBUCKETS]; -static int hash_shifts[4] = {24, 16, 8, 0}; - -/* - * getprop - */ - -char *getprop (char *name) -{ - unsigned char *cp; - unsigned long hash=0; - prop_t *bp; - int i=0; - - for (cp = (unsigned char *) name; *cp; cp++) - hash ^= (*cp)<<(hash_shifts[(i++)&0x3]); - - bp = buckets [hash%NBUCKETS]; - - while (bp && strcmp(bp->name, name)) { - bp = bp->next; - } - - if (bp == NULL) - return (0); - else - return (bp->value); -} - -/* - * getprop_default - */ - -char *getprop_default (char *name, char *def) -{ - char *rv; - rv = getprop (name); - if (rv) - return (rv); - else - return (def); -} - -/* - * addprop - */ - -void addprop (char *name, char *value) -{ - unsigned char *cp; - unsigned long hash=0; - prop_t **bpp; - prop_t *bp; - int i=0; - - bp = (prop_t *)malloc (sizeof (prop_t)); - - bp->next = 0; - bp->name = sxerox (name); - bp->value = sxerox (value); - - for (cp = (unsigned char *)name; *cp; cp++) - hash ^= (*cp)<<(hash_shifts[(i++)&0x3]); - - bpp = &buckets [hash%NBUCKETS]; - - if (*bpp == NULL) - *bpp = bp; - else { - bp->next = *bpp; - *bpp = bp; - } -} - -/* - * sxerox - */ - -static char *sxerox (char *s) -{ - char *rv = (char *) malloc (strlen (s) + 1); - strcpy (rv, s); - return rv; -} - -/* - * readprops - */ - -#define START 0 -#define READNAME 1 -#define READVALUE 2 -#define C_COMMENT 3 -#define CPP_COMMENT 4 - -int readprops (char *filename) -{ - FILE *ifp; - unsigned char c; - int state=START; - int linenum=1; - char namebuf [128]; - char valbuf [512]; - int i; - - ifp = fopen (filename, "r"); - - if (ifp == NULL) - return (-1); - - while (1) { - - readchar: - c = getc (ifp); - - again: - switch (state) { - case START: - if (feof (ifp)) { - fclose (ifp); - return (0); - } - - if (c == ' ' || c == '\t') - goto readchar; - - if (c == '\n') { - linenum++; - goto readchar; - } - if (isalpha (c) || (c == '_')) { - state = READNAME; - goto again; - } - if (c == '/') { - c = getc (ifp); - if (c == '/') { - state = CPP_COMMENT; - goto readchar; - } else if (c == '*') { - state = C_COMMENT; - goto readchar; - } else { - fprintf (stderr, "unknown token '/' line %d\n", - linenum); - exit(1); - } - } - fprintf (stderr, "unknown token '%c' line %d\n", - c, linenum); - exit (1); - break; - - case CPP_COMMENT: - while (1) { - c = getc (ifp); - if (feof (ifp)) - return (0); - if (c == '\n') { - linenum++; - state = START; - goto readchar; - } - } - break; - - case C_COMMENT: - while (1) { - c = getc (ifp); - if (feof (ifp)) { - fprintf (stderr, "unterminated comment, line %d\n", - linenum); - exit (1); - } - if (c == '*') { - staragain: - c = getc (ifp); - if (c == '/') { - state = START; - goto readchar; - } - if (c == '*') - goto staragain; - } - } - break; - - case READNAME: - i = 0; - namebuf[i++] = c; - while (1) { - c = getc (ifp); - if (feof (ifp)) { - fprintf (stderr, "EOF while reading a name, line %d\n", - linenum); - exit (1); - } - if ((!isalnum (c)) && (c != '_')) { - namebuf [i] = 0; - state = READVALUE; - goto again; - } - namebuf [i++] = c; - } - break; - - case READVALUE: - i = 0; - while ((c == ' ') || (c == '\t') || (c == '=')) { - c = getc (ifp); - if (feof (ifp)) { - fprintf (stderr, "EOF while reading a value, line %d\n", - linenum); - exit (1); - } - } - goto firsttime; - while (1) { - c = getc (ifp); - - firsttime: - if (c == '\\') { - c = getc (ifp); - if (feof (ifp)) { - fprintf (stderr, "EOF after '\\', line %d\n", - linenum); - exit (1); - } - valbuf[i++] = c; - continue; - } - if (c == '\n') { - linenum++; - while (valbuf [i-1] == ' ' || valbuf[i-1] == '\t') - i--; - valbuf[i] = 0; - addprop (namebuf, valbuf); - state = START; - goto readchar; - } - valbuf[i++] = c; - } - - } - } -} diff --git a/plugins/Makefile.am b/plugins/Makefile.am index 100f089e..a101e47f 100644 --- a/plugins/Makefile.am +++ b/plugins/Makefile.am @@ -28,10 +28,6 @@ if ENABLE_sample_PLUGIN SUBDIRS += sample-plugin endif -if ENABLE_sixrd_PLUGIN -SUBDIRS += sixrd-plugin -endif - if ENABLE_ioam_PLUGIN SUBDIRS += ioam-plugin endif @@ -44,18 +40,10 @@ if ENABLE_snat_PLUGIN SUBDIRS += snat-plugin endif -if ENABLE_ila_PLUGIN -SUBDIRS += ila-plugin -endif - if ENABLE_lb_PLUGIN SUBDIRS += lb-plugin endif -if ENABLE_flowperpkt_PLUGIN -SUBDIRS += flowperpkt-plugin -endif - if ENABLE_acl_PLUGIN SUBDIRS += acl-plugin endif diff --git a/plugins/configure.ac b/plugins/configure.ac index 6e7d5b8a..9c631634 100644 --- a/plugins/configure.ac +++ b/plugins/configure.ac @@ -53,12 +53,9 @@ AM_CONDITIONAL(ENABLE_$1_PLUGIN, test "$enable_the_plugin" = "1") # SUBDIRS += new-plugin # endif -PLUGIN_ENABLED(sixrd) PLUGIN_ENABLED(ioam) PLUGIN_ENABLED(snat) -PLUGIN_ENABLED(ila) PLUGIN_ENABLED(lb) -PLUGIN_ENABLED(flowperpkt) PLUGIN_ENABLED(acl) # Disabled plugins, require --enable-XXX-plugin diff --git a/plugins/flowperpkt-plugin/Makefile.am b/plugins/flowperpkt-plugin/Makefile.am deleted file mode 100644 index 9354e26f..00000000 --- a/plugins/flowperpkt-plugin/Makefile.am +++ /dev/null @@ -1,64 +0,0 @@ - -# Copyright (c) -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at: -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -AUTOMAKE_OPTIONS = foreign subdir-objects - -AM_CFLAGS = -Wall -AM_LDFLAGS = -module -shared -avoid-version - -vppapitestpluginsdir = ${libdir}/vpp_api_test_plugins -vpppluginsdir = ${libdir}/vpp_plugins - -vppplugins_LTLIBRARIES = flowperpkt_plugin.la -vppapitestplugins_LTLIBRARIES = flowperpkt_test_plugin.la - -flowperpkt_plugin_la_SOURCES = flowperpkt/flowperpkt.c \ - flowperpkt/l2_node.c \ - flowperpkt/node.c \ - flowperpkt/flowperpkt_plugin.api.h -flowperpkt_plugin_la_LDFLAGS = -module - -BUILT_SOURCES = \ - flowperpkt/flowperpkt.api.h \ - flowperpkt/flowperpkt.api.json - -SUFFIXES = .api.h .api .api.json - -%.api.h: %.api - mkdir -p `dirname $@` ; \ - $(CC) $(CPPFLAGS) -E -P -C -x c $^ \ - | vppapigen --input - --output $@ --show-name $@ - -%.api.json: %.api - @echo " JSON APIGEN " $@ ; \ - mkdir -p `dirname $@` ; \ - $(CC) $(CPPFLAGS) -E -P -C -x c $^ \ - | vppapigen --input - --json $@ - -apidir = $(prefix)/flowperpkt/ -api_DATA = flowperpkt/flowperpkt.api.json - -noinst_HEADERS = \ - flowperpkt/flowperpkt_all_api_h.h \ - flowperpkt/flowperpkt_msg_enum.h \ - flowperpkt/flowperpkt.api.h - -flowperpkt_test_plugin_la_SOURCES = \ - flowperpkt/flowperpkt_test.c flowperpkt/flowperpkt_plugin.api.h - -# Remove *.la files -install-data-hook: - @(cd $(vpppluginsdir) && $(RM) $(vppplugins_LTLIBRARIES)) - @(cd $(vppapitestpluginsdir) && $(RM) $(vppapitestplugins_LTLIBRARIES)) - diff --git a/plugins/flowperpkt-plugin/configure.ac b/plugins/flowperpkt-plugin/configure.ac deleted file mode 100644 index 80546169..00000000 --- a/plugins/flowperpkt-plugin/configure.ac +++ /dev/null @@ -1,9 +0,0 @@ - -AC_INIT(flowperpkt_plugin, 1.0) -AM_INIT_AUTOMAKE -AM_SILENT_RULES([yes]) - -AC_PROG_LIBTOOL -AC_PROG_CC - -AC_OUTPUT([Makefile]) diff --git a/plugins/flowperpkt-plugin/flowperpkt/flowperpkt.api b/plugins/flowperpkt-plugin/flowperpkt/flowperpkt.api deleted file mode 100644 index fa878f21..00000000 --- a/plugins/flowperpkt-plugin/flowperpkt/flowperpkt.api +++ /dev/null @@ -1,42 +0,0 @@ -/* Define a simple enable-disable binary API to control the feature */ - -/** \file - This file defines the vpp control-plane API messages - used to control the flowperpkt plugin -*/ - -/** \brief Enable / disable per-packet IPFIX recording on an interface - @param client_index - opaque cookie to identify the sender - @param context - sender context, to match reply w/ request - @param is_add - add address if non-zero, else delete - @param is_ipv6 - if non-zero the address is ipv6, else ipv4 - @param sw_if_index - index of the interface -*/ -manual_print define flowperpkt_tx_interface_add_del -{ - /* Client identifier, set from api_main.my_client_index */ - u32 client_index; - - /* Arbitrary context, so client can match reply to request */ - u32 context; - - /* Enable / disable the feature */ - u8 is_add; - u8 which; /* 0 = ipv4, 1 = l2, 2 = ipv6 (not yet implemented) */ - - /* Interface handle */ - u32 sw_if_index; -}; - -/** \brief Reply to enable/disable per-packet IPFIX recording messages - @param context - returned sender context, to match reply w/ request - @param retval - return code -*/ -define flowperpkt_tx_interface_add_del_reply -{ - /* From the request */ - u32 context; - - /* Return value, zero means all OK */ - i32 retval; -}; diff --git a/plugins/flowperpkt-plugin/flowperpkt/flowperpkt.c b/plugins/flowperpkt-plugin/flowperpkt/flowperpkt.c deleted file mode 100644 index fb71d5b0..00000000 --- a/plugins/flowperpkt-plugin/flowperpkt/flowperpkt.c +++ /dev/null @@ -1,671 +0,0 @@ -/* - * flowperpkt.c - per-packet data capture flow report plugin - * - * Copyright (c) - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @file - * @brief Per-packet IPFIX flow record generator plugin - * - * This file implements vpp plugin registration mechanics, - * debug CLI, and binary API handling. - */ - -#include -#include -#include - -#include -#include -#include - -/* define message IDs */ -#include - -/* define message structures */ -#define vl_typedefs -#include -#undef vl_typedefs - -/* define generated endian-swappers */ -#define vl_endianfun -#include -#undef vl_endianfun - -/* instantiate all the print functions we know about */ -#define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__) -#define vl_printfun -#include -#undef vl_printfun - -flowperpkt_main_t flowperpkt_main; - -/* Get the API version number */ -#define vl_api_version(n,v) static u32 api_version=(v); -#include -#undef vl_api_version - -/* Define the per-interface configurable features */ -/* *INDENT-OFF* */ -VNET_FEATURE_INIT (flow_perpacket_ipv4, static) = -{ - .arc_name = "ip4-output", - .node_name = "flowperpkt-ipv4", - .runs_before = VNET_FEATURES ("interface-output"), -}; - -VNET_FEATURE_INIT (flow_perpacket_l2, static) = -{ - .arc_name = "interface-output", - .node_name = "flowperpkt-l2", - .runs_before = VNET_FEATURES ("interface-tx"), -}; -/* *INDENT-ON* */ - -/* - * A handy macro to set up a message reply. - * Assumes that the following variables are available: - * mp - pointer to request message - * rmp - pointer to reply message type - * rv - return value - */ -#define REPLY_MACRO(t) \ -do { \ - unix_shared_memory_queue_t * q = \ - vl_api_client_index_to_input_queue (mp->client_index); \ - if (!q) \ - return; \ - \ - rmp = vl_msg_api_alloc (sizeof (*rmp)); \ - rmp->_vl_msg_id = ntohs((t)+fm->msg_id_base); \ - rmp->context = mp->context; \ - rmp->retval = ntohl(rv); \ - \ - vl_msg_api_send_shmem (q, (u8 *)&rmp); \ -} while(0); - -/* Macro to finish up custom dump fns */ -#define FINISH \ - vec_add1 (s, 0); \ - vl_print (handle, (char *)s); \ - vec_free (s); \ - return handle; - -#define VALIDATE_SW_IF_INDEX(mp) \ - do { u32 __sw_if_index = ntohl(mp->sw_if_index); \ - vnet_main_t *__vnm = vnet_get_main(); \ - if (pool_is_free_index(__vnm->interface_main.sw_interfaces, \ - __sw_if_index)) { \ - rv = VNET_API_ERROR_INVALID_SW_IF_INDEX; \ - goto bad_sw_if_index; \ - } \ -} while(0); - -#define BAD_SW_IF_INDEX_LABEL \ -do { \ -bad_sw_if_index: \ - ; \ -} while (0); - -/** - * @brief Create an IPFIX template packet rewrite string - * @param frm flow_report_main_t * - * @param fr flow_report_t * - * @param collector_address ip4_address_t * the IPFIX collector address - * @param src_address ip4_address_t * the source address we should use - * @param collector_port u16 the collector port we should use, host byte order - * @returns u8 * vector containing the indicated IPFIX template packet - */ -static inline u8 * -flowperpkt_template_rewrite_inline (flow_report_main_t * frm, - flow_report_t * fr, - ip4_address_t * collector_address, - ip4_address_t * src_address, - u16 collector_port, int variant) -{ - ip4_header_t *ip; - udp_header_t *udp; - ipfix_message_header_t *h; - ipfix_set_header_t *s; - ipfix_template_header_t *t; - ipfix_field_specifier_t *f; - ipfix_field_specifier_t *first_field; - u8 *rewrite = 0; - ip4_ipfix_template_packet_t *tp; - u32 field_count = 0; - flow_report_stream_t *stream; - flowperpkt_main_t *fm = &flowperpkt_main; - - stream = &frm->streams[fr->stream_index]; - - if (variant == FLOW_VARIANT_IPV4) - { - /* - * ip4 Supported Fields: - * - * ingressInterface, TLV type 10, u32 - * egressInterface, TLV type 14, u32 - * sourceIpv4Address, TLV type 8, u32 - * destinationIPv4Address, TLV type 12, u32 - * ipClassOfService, TLV type 5, u8 - * flowStartNanoseconds, TLV type 156, dateTimeNanoseconds (f64) - * Implementation: f64 nanoseconds since VPP started - * warning: wireshark doesn't really understand this TLV - * dataLinkFrameSize, TLV type 312, u16 - * warning: wireshark doesn't understand this TLV at all - */ - - /* Currently 7 fields */ - field_count += 7; - - /* allocate rewrite space */ - vec_validate_aligned - (rewrite, - sizeof (ip4_ipfix_template_packet_t) - + field_count * sizeof (ipfix_field_specifier_t) - 1, - CLIB_CACHE_LINE_BYTES); - } - else if (variant == FLOW_VARIANT_L2) - { - /* - * L2 Supported Fields: - * - * ingressInterface, TLV type 10, u32 - * egressInterface, TLV type 14, u32 - * sourceMacAddress, TLV type 56, u8[6] we hope - * destinationMacAddress, TLV type 57, u8[6] we hope - * ethernetType, TLV type 256, u16 - * flowStartNanoseconds, TLV type 156, dateTimeNanoseconds (f64) - * Implementation: f64 nanoseconds since VPP started - * warning: wireshark doesn't really understand this TLV - * dataLinkFrameSize, TLV type 312, u16 - * warning: wireshark doesn't understand this TLV at all - */ - - /* Currently 7 fields */ - field_count += 7; - - /* allocate rewrite space */ - vec_validate_aligned - (rewrite, - sizeof (ip4_ipfix_template_packet_t) - + field_count * sizeof (ipfix_field_specifier_t) - 1, - CLIB_CACHE_LINE_BYTES); - } - - tp = (ip4_ipfix_template_packet_t *) rewrite; - ip = (ip4_header_t *) & tp->ip4; - udp = (udp_header_t *) (ip + 1); - h = (ipfix_message_header_t *) (udp + 1); - s = (ipfix_set_header_t *) (h + 1); - t = (ipfix_template_header_t *) (s + 1); - first_field = f = (ipfix_field_specifier_t *) (t + 1); - - ip->ip_version_and_header_length = 0x45; - ip->ttl = 254; - ip->protocol = IP_PROTOCOL_UDP; - ip->src_address.as_u32 = src_address->as_u32; - ip->dst_address.as_u32 = collector_address->as_u32; - udp->src_port = clib_host_to_net_u16 (stream->src_port); - udp->dst_port = clib_host_to_net_u16 (collector_port); - udp->length = clib_host_to_net_u16 (vec_len (rewrite) - sizeof (*ip)); - - /* FIXUP: message header export_time */ - /* FIXUP: message header sequence_number */ - h->domain_id = clib_host_to_net_u32 (stream->domain_id); - - /* Add TLVs to the template */ - if (variant == FLOW_VARIANT_IPV4) - { - f->e_id_length = - ipfix_e_id_length (0 /* enterprise */ , ingressInterface, - 4); - f++; - f->e_id_length = - ipfix_e_id_length (0 /* enterprise */ , egressInterface, - 4); - f++; - f->e_id_length = - ipfix_e_id_length (0 /* enterprise */ , sourceIPv4Address, - 4); - f++; - f->e_id_length = - ipfix_e_id_length (0 /* enterprise */ , destinationIPv4Address, 4); - f++; - f->e_id_length = - ipfix_e_id_length (0 /* enterprise */ , ipClassOfService, - 1); - f++; - f->e_id_length = - ipfix_e_id_length (0 /* enterprise */ , flowStartNanoseconds, - 8); - f++; - f->e_id_length = - ipfix_e_id_length (0 /* enterprise */ , dataLinkFrameSize, - 2); - f++; - } - else if (variant == FLOW_VARIANT_L2) - { - f->e_id_length = - ipfix_e_id_length (0 /* enterprise */ , ingressInterface, - 4); - f++; - f->e_id_length = - ipfix_e_id_length (0 /* enterprise */ , egressInterface, - 4); - f++; - f->e_id_length = - ipfix_e_id_length (0 /* enterprise */ , sourceMacAddress, - 6); - f++; - f->e_id_length = - ipfix_e_id_length (0 /* enterprise */ , destinationMacAddress, 6); - f++; - f->e_id_length = ipfix_e_id_length (0 /* enterprise */ , ethernetType, - 2); - f++; - f->e_id_length = - ipfix_e_id_length (0 /* enterprise */ , flowStartNanoseconds, - 8); - f++; - f->e_id_length = - ipfix_e_id_length (0 /* enterprise */ , dataLinkFrameSize, - 2); - f++; - } - - /* Extend in the obvious way, right here... */ - - /* Back to the template packet... */ - ip = (ip4_header_t *) & tp->ip4; - udp = (udp_header_t *) (ip + 1); - - ASSERT (f - first_field); - /* Field count in this template */ - t->id_count = ipfix_id_count (fr->template_id, f - first_field); - - if (variant == FLOW_VARIANT_IPV4) - fm->ipv4_report_id = fr->template_id; - else if (variant == FLOW_VARIANT_L2) - fm->l2_report_id = fr->template_id; - - /* set length in octets */ - s->set_id_length = - ipfix_set_id_length (2 /* set_id */ , (u8 *) f - (u8 *) s); - - /* message length in octets */ - h->version_length = version_length ((u8 *) f - (u8 *) h); - - ip->length = clib_host_to_net_u16 ((u8 *) f - (u8 *) ip); - ip->checksum = ip4_header_checksum (ip); - - return rewrite; -} - -u8 * -flowperpkt_template_rewrite_ipv4 (flow_report_main_t * frm, - flow_report_t * fr, - ip4_address_t * collector_address, - ip4_address_t * src_address, - u16 collector_port) -{ - return flowperpkt_template_rewrite_inline - (frm, fr, collector_address, src_address, collector_port, - FLOW_VARIANT_IPV4); -} - -u8 * -flowperpkt_template_rewrite_l2 (flow_report_main_t * frm, - flow_report_t * fr, - ip4_address_t * collector_address, - ip4_address_t * src_address, - u16 collector_port) -{ - return flowperpkt_template_rewrite_inline - (frm, fr, collector_address, src_address, collector_port, - FLOW_VARIANT_L2); -} - - -/** - * @brief Flush accumulated data - * @param frm flow_report_main_t * - * @param fr flow_report_t * - * @param f vlib_frame_t * - * - * Notes: - * This function must simply return the incoming frame, or no template packets - * will be sent. - */ -vlib_frame_t * -flowperpkt_data_callback_ipv4 (flow_report_main_t * frm, - flow_report_t * fr, - vlib_frame_t * f, u32 * to_next, - u32 node_index) -{ - flowperpkt_flush_callback_ipv4 (); - return f; -} - -vlib_frame_t * -flowperpkt_data_callback_l2 (flow_report_main_t * frm, - flow_report_t * fr, - vlib_frame_t * f, u32 * to_next, u32 node_index) -{ - flowperpkt_flush_callback_l2 (); - return f; -} - -/** - * @brief configure / deconfigure the IPFIX flow-per-packet - * @param fm flowperpkt_main_t * fm - * @param sw_if_index u32 the desired interface - * @param is_add int 1 to enable the feature, 0 to disable it - * @returns 0 if successful, non-zero otherwise - */ - -static int flowperpkt_tx_interface_add_del_feature - (flowperpkt_main_t * fm, u32 sw_if_index, int which, int is_add) -{ - flow_report_main_t *frm = &flow_report_main; - vnet_flow_report_add_del_args_t _a, *a = &_a; - int rv; - - if (which == FLOW_VARIANT_IPV4 && !fm->ipv4_report_created) - { - memset (a, 0, sizeof (*a)); - a->rewrite_callback = flowperpkt_template_rewrite_ipv4; - a->flow_data_callback = flowperpkt_data_callback_ipv4; - a->is_add = 1; - a->domain_id = 1; /*$$$$ config parameter */ - a->src_port = 4739; /*$$$$ config parameter */ - fm->ipv4_report_created = 1; - - rv = vnet_flow_report_add_del (frm, a); - if (rv) - { - clib_warning ("vnet_flow_report_add_del returned %d", rv); - return -1; - } - } - else if (which == FLOW_VARIANT_L2 && !fm->l2_report_created) - { - memset (a, 0, sizeof (*a)); - a->rewrite_callback = flowperpkt_template_rewrite_l2; - a->flow_data_callback = flowperpkt_data_callback_l2; - a->is_add = 1; - a->domain_id = 1; /*$$$$ config parameter */ - a->src_port = 4739; /*$$$$ config parameter */ - fm->l2_report_created = 1; - - rv = vnet_flow_report_add_del (frm, a); - if (rv) - { - clib_warning ("vnet_flow_report_add_del returned %d", rv); - return -1; - } - } - - if (which == FLOW_VARIANT_IPV4) - vnet_feature_enable_disable ("ip4-output", "flowperpkt-ipv4", - sw_if_index, is_add, 0, 0); - else if (which == FLOW_VARIANT_L2) - vnet_feature_enable_disable ("interface-output", "flowperpkt-l2", - sw_if_index, is_add, 0, 0); - - return 0; -} - -/** - * @brief API message handler - * @param mp vl_api_flowperpkt_tx_interface_add_del_t * mp the api message - */ -void vl_api_flowperpkt_tx_interface_add_del_t_handler - (vl_api_flowperpkt_tx_interface_add_del_t * mp) -{ - flowperpkt_main_t *fm = &flowperpkt_main; - vl_api_flowperpkt_tx_interface_add_del_reply_t *rmp; - u32 sw_if_index = ntohl (mp->sw_if_index); - int rv = 0; - - VALIDATE_SW_IF_INDEX (mp); - - if (mp->which != FLOW_VARIANT_IPV4 && mp->which != FLOW_VARIANT_L2) - { - rv = VNET_API_ERROR_UNIMPLEMENTED; - goto out; - } - - rv = flowperpkt_tx_interface_add_del_feature (fm, sw_if_index, mp->which, - mp->is_add); -out: - BAD_SW_IF_INDEX_LABEL; - - REPLY_MACRO (VL_API_FLOWPERPKT_TX_INTERFACE_ADD_DEL_REPLY); -} - -/** - * @brief API message custom-dump function - * @param mp vl_api_flowperpkt_tx_interface_add_del_t * mp the api message - * @param handle void * print function handle - * @returns u8 * output string - */ -static void *vl_api_flowperpkt_tx_interface_add_del_t_print - (vl_api_flowperpkt_tx_interface_add_del_t * mp, void *handle) -{ - u8 *s; - - s = format (0, "SCRIPT: flowperpkt_tx_interface_add_del "); - s = format (s, "sw_if_index %d is_add %d which %d ", - clib_host_to_net_u32 (mp->sw_if_index), - (int) mp->is_add, (int) mp->which); - FINISH; -} - -/* List of message types that this plugin understands */ -#define foreach_flowperpkt_plugin_api_msg \ -_(FLOWPERPKT_TX_INTERFACE_ADD_DEL, flowperpkt_tx_interface_add_del) - -/** - * @brief plugin-api required function - * @param vm vlib_main_t * vlib main data structure pointer - * @param h vlib_plugin_handoff_t * handoff structure - * @param from_early_init int notused - * - * Notes: - * This routine exists to convince the vlib plugin framework that - * we haven't accidentally copied a random .dll into the plugin directory. - * - * Also collects global variable pointers passed from the vpp engine - */ -clib_error_t * -vlib_plugin_register (vlib_main_t * vm, vnet_plugin_handoff_t * h, - int from_early_init) -{ - flowperpkt_main_t *fm = &flowperpkt_main; - clib_error_t *error = 0; - - fm->vlib_main = vm; - fm->vnet_main = h->vnet_main; - - return error; -} - -static clib_error_t * -flowperpkt_tx_interface_add_del_feature_command_fn (vlib_main_t * vm, - unformat_input_t * input, - vlib_cli_command_t * cmd) -{ - flowperpkt_main_t *fm = &flowperpkt_main; - u32 sw_if_index = ~0; - int is_add = 1; - u8 which = FLOW_VARIANT_IPV4; - - int rv; - - while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) - { - if (unformat (input, "disable")) - is_add = 0; - else if (unformat (input, "%U", unformat_vnet_sw_interface, - fm->vnet_main, &sw_if_index)); - else if (unformat (input, "l2")) - which = FLOW_VARIANT_L2; - else - break; - } - - if (sw_if_index == ~0) - return clib_error_return (0, "Please specify an interface..."); - - rv = - flowperpkt_tx_interface_add_del_feature (fm, sw_if_index, which, is_add); - switch (rv) - { - case 0: - break; - - case VNET_API_ERROR_INVALID_SW_IF_INDEX: - return clib_error_return - (0, "Invalid interface, only works on physical ports"); - break; - - case VNET_API_ERROR_UNIMPLEMENTED: - return clib_error_return (0, "ip6 not supported"); - break; - - default: - return clib_error_return (0, "flowperpkt_enable_disable returned %d", - rv); - } - return 0; -} - -/*? - * 'flowperpkt feature add-del' commands to enable/disable - * per-packet IPFIX flow record generation on an interface - * - * @cliexpar - * @parblock - * To enable per-packet IPFIX flow-record generation on an interface: - * @cliexcmd{flowperpkt feature add-del GigabitEthernet2/0/0} - * - * To disable per-packet IPFIX flow-record generation on an interface: - * @cliexcmd{flowperpkt feature add-del GigabitEthernet2/0/0 disable} - * @cliexend - * @endparblock -?*/ -/* *INDENT-OFF* */ -VLIB_CLI_COMMAND (flowperpkt_enable_disable_command, static) = { - .path = "flowperpkt feature add-del", - .short_help = - "flowperpkt feature add-del [disable]", - .function = flowperpkt_tx_interface_add_del_feature_command_fn, -}; -/* *INDENT-ON* */ - -/** - * @brief Set up the API message handling tables - * @param vm vlib_main_t * vlib main data structure pointer - * @returns 0 to indicate all is well - */ -static clib_error_t * -flowperpkt_plugin_api_hookup (vlib_main_t * vm) -{ - flowperpkt_main_t *fm = &flowperpkt_main; -#define _(N,n) \ - vl_msg_api_set_handlers((VL_API_##N + fm->msg_id_base), \ - #n, \ - vl_api_##n##_t_handler, \ - vl_noop_handler, \ - vl_api_##n##_t_endian, \ - vl_api_##n##_t_print, \ - sizeof(vl_api_##n##_t), 1); - foreach_flowperpkt_plugin_api_msg; -#undef _ - - return 0; -} - -#define vl_msg_name_crc_list -#include -#undef vl_msg_name_crc_list - -static void -setup_message_id_table (flowperpkt_main_t * fm, api_main_t * am) -{ -#define _(id,n,crc) \ - vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id + fm->msg_id_base); - foreach_vl_msg_name_crc_flowperpkt; -#undef _ -} - -/** - * @brief Set up the API message handling tables - * @param vm vlib_main_t * vlib main data structure pointer - * @returns 0 to indicate all is well, or a clib_error_t - */ -static clib_error_t * -flowperpkt_init (vlib_main_t * vm) -{ - flowperpkt_main_t *fm = &flowperpkt_main; - vlib_thread_main_t *tm = &vlib_thread_main; - clib_error_t *error = 0; - u32 num_threads; - u8 *name; - - /* Construct the API name */ - name = format (0, "flowperpkt_%08x%c", api_version, 0); - - /* Ask for a correctly-sized block of API message decode slots */ - fm->msg_id_base = vl_msg_api_get_msg_ids - ((char *) name, VL_MSG_FIRST_AVAILABLE); - - /* Hook up message handlers */ - error = flowperpkt_plugin_api_hookup (vm); - - /* Add our API messages to the global name_crc hash table */ - setup_message_id_table (fm, &api_main); - - vec_free (name); - - /* Decide how many worker threads we have */ - num_threads = 1 /* main thread */ + tm->n_eal_threads; - - /* Allocate per worker thread vectors */ - vec_validate (fm->ipv4_buffers_per_worker, num_threads - 1); - vec_validate (fm->l2_buffers_per_worker, num_threads - 1); - vec_validate (fm->ipv4_frames_per_worker, num_threads - 1); - vec_validate (fm->l2_frames_per_worker, num_threads - 1); - vec_validate (fm->ipv4_next_record_offset_per_worker, num_threads - 1); - vec_validate (fm->l2_next_record_offset_per_worker, num_threads - 1); - - /* Set up time reference pair */ - fm->vlib_time_0 = vlib_time_now (vm); - fm->nanosecond_time_0 = unix_time_now_nsec (); - - return error; -} - -VLIB_INIT_FUNCTION (flowperpkt_init); - -/* - * fd.io coding-style-patch-verification: ON - * - * Local Variables: - * eval: (c-set-style "gnu") - * End: - */ diff --git a/plugins/flowperpkt-plugin/flowperpkt/flowperpkt.h b/plugins/flowperpkt-plugin/flowperpkt/flowperpkt.h deleted file mode 100644 index 20f6939d..00000000 --- a/plugins/flowperpkt-plugin/flowperpkt/flowperpkt.h +++ /dev/null @@ -1,90 +0,0 @@ -/* - * flowperpkt.h - skeleton vpp engine plug-in header file - * - * Copyright (c) - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#ifndef __included_flowperpkt_h__ -#define __included_flowperpkt_h__ - -#include -#include -#include - -#include -#include -#include -#include - -/** - * @file - * @brief flow-per-packet plugin header file - */ -typedef struct -{ - /** API message ID base */ - u16 msg_id_base; - - /** Have the reports [templates] been created? */ - int ipv4_report_created; - int l2_report_created; - - /** stream/template IDs */ - u16 ipv4_report_id; - u16 l2_report_id; - - /** ipfix buffers under construction, per-worker thread */ - vlib_buffer_t **ipv4_buffers_per_worker; - vlib_buffer_t **l2_buffers_per_worker; - - /** frames containing ipfix buffers, per-worker thread */ - vlib_frame_t **ipv4_frames_per_worker; - vlib_frame_t **l2_frames_per_worker; - - /** next record offset, per worker thread */ - u16 *ipv4_next_record_offset_per_worker; - u16 *l2_next_record_offset_per_worker; - - /** Time reference pair */ - u64 nanosecond_time_0; - f64 vlib_time_0; - - /** convenience vlib_main_t pointer */ - vlib_main_t *vlib_main; - /** convenience vnet_main_t pointer */ - vnet_main_t *vnet_main; -} flowperpkt_main_t; - -typedef enum -{ - FLOW_VARIANT_IPV4, - FLOW_VARIANT_L2, - FLOW_N_VARIANTS, -} flowperpkt_variant_t; - -extern flowperpkt_main_t flowperpkt_main; - -extern vlib_node_registration_t flowperpkt_ipv4_node; - -void flowperpkt_flush_callback_ipv4 (void); -void flowperpkt_flush_callback_l2 (void); - -#endif /* __included_flowperpkt_h__ */ - -/* - * fd.io coding-style-patch-verification: ON - * - * Local Variables: - * eval: (c-set-style "gnu") - * End: - */ diff --git a/plugins/flowperpkt-plugin/flowperpkt/flowperpkt_all_api_h.h b/plugins/flowperpkt-plugin/flowperpkt/flowperpkt_all_api_h.h deleted file mode 100644 index 329c375a..00000000 --- a/plugins/flowperpkt-plugin/flowperpkt/flowperpkt_all_api_h.h +++ /dev/null @@ -1,18 +0,0 @@ -/* - * flowperpkt_all_api_h.h - plug-in api #include file - * - * Copyright (c) - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* Include the generated file, see BUILT_SOURCES in Makefile.am */ -#include diff --git a/plugins/flowperpkt-plugin/flowperpkt/flowperpkt_msg_enum.h b/plugins/flowperpkt-plugin/flowperpkt/flowperpkt_msg_enum.h deleted file mode 100644 index 3177e77a..00000000 --- a/plugins/flowperpkt-plugin/flowperpkt/flowperpkt_msg_enum.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * flowperpkt_msg_enum.h - vpp engine plug-in message enumeration - * - * Copyright (c) - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#ifndef included_flowperpkt_msg_enum_h -#define included_flowperpkt_msg_enum_h - -#include - -#define vl_msg_id(n,h) n, -typedef enum -{ -#include - /* We'll want to know how many messages IDs we need... */ - VL_MSG_FIRST_AVAILABLE, -} vl_msg_id_t; -#undef vl_msg_id - -#endif /* included_flowperpkt_msg_enum_h */ diff --git a/plugins/flowperpkt-plugin/flowperpkt/flowperpkt_test.c b/plugins/flowperpkt-plugin/flowperpkt/flowperpkt_test.c deleted file mode 100644 index 716818ff..00000000 --- a/plugins/flowperpkt-plugin/flowperpkt/flowperpkt_test.c +++ /dev/null @@ -1,234 +0,0 @@ -/* - * flowperpkt.c - skeleton vpp-api-test plug-in - * - * Copyright (c) - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#include -#include -#include -#include -#include - -/** - * @file vpp_api_test plugin - */ - -uword unformat_sw_if_index (unformat_input_t * input, va_list * args); - -/* Declare message IDs */ -#include - -/* define message structures */ -#define vl_typedefs -#include -#undef vl_typedefs - -/* declare message handlers for each api */ - -#define vl_endianfun /* define message structures */ -#include -#undef vl_endianfun - -/* instantiate all the print functions we know about */ -#define vl_print(handle, ...) -#define vl_printfun -#include -#undef vl_printfun - -/* Get the API version number. */ -#define vl_api_version(n,v) static u32 api_version=(v); -#include -#undef vl_api_version - -typedef struct -{ - /** API message ID base */ - u16 msg_id_base; - /** vat_main_t pointer */ - vat_main_t *vat_main; -} flowperpkt_test_main_t; - -flowperpkt_test_main_t flowperpkt_test_main; - -#define foreach_standard_reply_retval_handler \ -_(flowperpkt_tx_interface_add_del_reply) - -#define _(n) \ - static void vl_api_##n##_t_handler \ - (vl_api_##n##_t * mp) \ - { \ - vat_main_t * vam = flowperpkt_test_main.vat_main; \ - i32 retval = ntohl(mp->retval); \ - if (vam->async_mode) { \ - vam->async_errors += (retval < 0); \ - } else { \ - vam->retval = retval; \ - vam->result_ready = 1; \ - } \ - } -foreach_standard_reply_retval_handler; -#undef _ - -/* - * Table of message reply handlers, must include boilerplate handlers - * we just generated - */ -#define foreach_vpe_api_reply_msg \ -_(FLOWPERPKT_TX_INTERFACE_ADD_DEL_REPLY, \ - flowperpkt_tx_interface_add_del_reply) - - -/* M: construct, but don't yet send a message */ - -#define M(T,t) \ -do { \ - vam->result_ready = 0; \ - mp = vl_msg_api_alloc(sizeof(*mp)); \ - memset (mp, 0, sizeof (*mp)); \ - mp->_vl_msg_id = ntohs (VL_API_##T + sm->msg_id_base); \ - mp->client_index = vam->my_client_index; \ -} while(0); - -#define M2(T,t,n) \ -do { \ - vam->result_ready = 0; \ - mp = vl_msg_api_alloc(sizeof(*mp)+(n)); \ - memset (mp, 0, sizeof (*mp)); \ - mp->_vl_msg_id = ntohs (VL_API_##T + sm->msg_id_base); \ - mp->client_index = vam->my_client_index; \ -} while(0); - -/* S: send a message */ -#define S (vl_msg_api_send_shmem (vam->vl_input_queue, (u8 *)&mp)) - -/* W: wait for results, with timeout */ -#define W \ -do { \ - timeout = vat_time_now (vam) + 1.0; \ - \ - while (vat_time_now (vam) < timeout) { \ - if (vam->result_ready == 1) { \ - return (vam->retval); \ - } \ - } \ - return -99; \ -} while(0); - -static int -api_flowperpkt_tx_interface_add_del (vat_main_t * vam) -{ - flowperpkt_test_main_t *sm = &flowperpkt_test_main; - unformat_input_t *i = vam->input; - f64 timeout; - int enable_disable = 1; - u8 which = 0; /* ipv4 by default */ - u32 sw_if_index = ~0; - vl_api_flowperpkt_tx_interface_add_del_t *mp; - - /* Parse args required to build the message */ - while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) - { - if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index)) - ; - else if (unformat (i, "sw_if_index %d", &sw_if_index)) - ; - else if (unformat (i, "disable")) - enable_disable = 0; - else if (unformat (i, "l2")) - which = 1; - else - break; - } - - if (sw_if_index == ~0) - { - errmsg ("missing interface name / explicit sw_if_index number \n"); - return -99; - } - - /* Construct the API message */ - M (FLOWPERPKT_TX_INTERFACE_ADD_DEL, flowperpkt_tx_interface_add_del); - mp->sw_if_index = ntohl (sw_if_index); - mp->is_add = enable_disable; - mp->which = which; - - /* send it... */ - S; - - /* Wait for a reply... */ - W; -} - -/* - * List of messages that the api test plugin sends, - * and that the data plane plugin processes - */ -#define foreach_vpe_api_msg \ -_(flowperpkt_tx_interface_add_del, " [disable]") - -void -vat_api_hookup (vat_main_t * vam) -{ - flowperpkt_test_main_t *sm = &flowperpkt_test_main; - /* Hook up handlers for replies from the data plane plug-in */ -#define _(N,n) \ - vl_msg_api_set_handlers((VL_API_##N + sm->msg_id_base), \ - #n, \ - vl_api_##n##_t_handler, \ - vl_noop_handler, \ - vl_api_##n##_t_endian, \ - vl_api_##n##_t_print, \ - sizeof(vl_api_##n##_t), 1); - foreach_vpe_api_reply_msg; -#undef _ - - /* API messages we can send */ -#define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n); - foreach_vpe_api_msg; -#undef _ - - /* Help strings */ -#define _(n,h) hash_set_mem (vam->help_by_name, #n, h); - foreach_vpe_api_msg; -#undef _ -} - -clib_error_t * -vat_plugin_register (vat_main_t * vam) -{ - flowperpkt_test_main_t *sm = &flowperpkt_test_main; - u8 *name; - - sm->vat_main = vam; - - /* Ask the vpp engine for the first assigned message-id */ - name = format (0, "flowperpkt_%08x%c", api_version, 0); - sm->msg_id_base = vl_client_get_first_plugin_msg_id ((char *) name); - - /* Don't attempt to hook up API messages if the data plane plugin is AWOL */ - if (sm->msg_id_base != (u16) ~ 0) - vat_api_hookup (vam); - - vec_free (name); - - return 0; -} - -/* - * fd.io coding-style-patch-verification: ON - * - * Local Variables: - * eval: (c-set-style "gnu") - * End: - */ diff --git a/plugins/flowperpkt-plugin/flowperpkt/l2_node.c b/plugins/flowperpkt-plugin/flowperpkt/l2_node.c deleted file mode 100644 index 1c2f681e..00000000 --- a/plugins/flowperpkt-plugin/flowperpkt/l2_node.c +++ /dev/null @@ -1,561 +0,0 @@ -/* - * l2_node.c - l2 ipfix-per-packet graph node - * - * Copyright (c) - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#include -#include -#include -#include -#include - -/** - * @file l2 flow record generator graph node - */ - -typedef struct -{ - /** interface handle */ - u32 rx_sw_if_index; - u32 tx_sw_if_index; - /** src and dst L2 addresses */ - u8 src_mac[6]; - u8 dst_mac[6]; - /** Ethertype */ - u16 ethertype; - /** packet timestamp */ - u64 timestamp; - /** size of the buffer */ - u16 buffer_size; -} flowperpkt_l2_trace_t; - -/* packet trace format function */ -static u8 * -format_flowperpkt_l2_trace (u8 * s, va_list * args) -{ - CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *); - CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *); - flowperpkt_l2_trace_t *t = va_arg (*args, flowperpkt_l2_trace_t *); - - s = format (s, - "FLOWPERPKT-L2: rx_sw_if_index %d, tx_sw_if_index %d, src %U dst %U ethertype %0x2, timestamp %lld, size %d", - t->rx_sw_if_index, t->tx_sw_if_index, - format_ethernet_address, &t->src_mac, - format_ethernet_address, &t->dst_mac, - t->ethertype, t->timestamp, t->buffer_size); - return s; -} - -vlib_node_registration_t flowperpkt_l2_node; - -/* No counters at the moment */ -#define foreach_flowperpkt_l2_error - -typedef enum -{ -#define _(sym,str) FLOWPERPKT_ERROR_##sym, - foreach_flowperpkt_l2_error -#undef _ - FLOWPERPKT_N_ERROR, -} flowperpkt_l2_error_t; - -static char *flowperpkt_l2_error_strings[] = { -#define _(sym,string) string, - foreach_flowperpkt_l2_error -#undef _ -}; - -typedef enum -{ - FLOWPERPKT_L2_NEXT_DROP, - FLOWPERPKT_L2_NEXT_IP4_LOOKUP, - FLOWPERPKT_L2_N_NEXT, -} flowperpkt_l2_next_t; - -/** - * @brief add an entry to the flow record under construction - * @param vm vlib_main_t * current worker thread main structure pointer - * @param fm flowperpkt_main_t * flow-per-packet main structure pointer - * @param sw_if_index u32 interface handle - * @param tos u8 ToS bits from the packet - * @param timestamp u64 timestamp, nanoseconds since 1/1/70 - * @param length u16 ip length of the packet - * @param do_flush int 1 = flush all cached records, 0 = construct a record - */ - -static inline void -add_to_flow_record_l2 (vlib_main_t * vm, - vlib_node_runtime_t * node, - flowperpkt_main_t * fm, - u32 rx_sw_if_index, u32 tx_sw_if_index, - u8 * src_mac, u8 * dst_mac, - u16 ethertype, u64 timestamp, u16 length, int do_flush) -{ - u32 my_cpu_number = vm->cpu_index; - flow_report_main_t *frm = &flow_report_main; - ip4_header_t *ip; - udp_header_t *udp; - ip4_ipfix_template_packet_t *tp; - ipfix_message_header_t *h; - ipfix_set_header_t *s; - vlib_frame_t *f; - vlib_buffer_t *b0; - u16 offset; - u32 bi0; - vlib_buffer_free_list_t *fl; - - /* Find or allocate a buffer */ - b0 = fm->l2_buffers_per_worker[my_cpu_number]; - - /* Need to allocate a buffer? */ - if (PREDICT_FALSE (b0 == 0)) - { - /* Nothing to flush */ - if (do_flush) - return; - - /* $$$$ drop counter? */ - if (vlib_buffer_alloc (vm, &bi0, 1) != 1) - return; - - /* Initialize the buffer */ - b0 = fm->l2_buffers_per_worker[my_cpu_number] = - vlib_get_buffer (vm, bi0); - fl = - vlib_buffer_get_free_list (vm, VLIB_BUFFER_DEFAULT_FREE_LIST_INDEX); - vlib_buffer_init_for_free_list (b0, fl); - VLIB_BUFFER_TRACE_TRAJECTORY_INIT (b0); - offset = 0; - } - else - { - /* use the current buffer */ - bi0 = vlib_get_buffer_index (vm, b0); - offset = fm->l2_next_record_offset_per_worker[my_cpu_number]; - } - - /* Find or allocate a frame */ - f = fm->l2_frames_per_worker[my_cpu_number]; - if (PREDICT_FALSE (f == 0)) - { - u32 *to_next; - f = vlib_get_frame_to_node (vm, ip4_lookup_node.index); - fm->l2_frames_per_worker[my_cpu_number] = f; - - /* Enqueue the buffer */ - to_next = vlib_frame_vector_args (f); - to_next[0] = bi0; - f->n_vectors = 1; - } - - /* Fresh packet, construct header */ - if (PREDICT_FALSE (offset == 0)) - { - flow_report_stream_t *stream; - - stream = &frm->streams[0]; - - b0->current_data = 0; - b0->current_length = sizeof (*ip) + sizeof (*udp) + sizeof (*h) + - sizeof (*s); - b0->flags |= (VLIB_BUFFER_TOTAL_LENGTH_VALID | VLIB_BUFFER_FLOW_REPORT); - vnet_buffer (b0)->sw_if_index[VLIB_RX] = 0; - vnet_buffer (b0)->sw_if_index[VLIB_TX] = frm->fib_index; - - tp = vlib_buffer_get_current (b0); - ip = (ip4_header_t *) & tp->ip4; - udp = (udp_header_t *) (ip + 1); - h = (ipfix_message_header_t *) (udp + 1); - s = (ipfix_set_header_t *) (h + 1); - - ip->ip_version_and_header_length = 0x45; - ip->ttl = 254; - ip->protocol = IP_PROTOCOL_UDP; - ip->flags_and_fragment_offset = 0; - ip->src_address.as_u32 = frm->src_address.as_u32; - ip->dst_address.as_u32 = frm->ipfix_collector.as_u32; - udp->src_port = clib_host_to_net_u16 (UDP_DST_PORT_ipfix); - udp->dst_port = clib_host_to_net_u16 (UDP_DST_PORT_ipfix); - udp->checksum = 0; - - /* FIXUP: message header export_time */ - h->export_time = (u32) - (((f64) frm->unix_time_0) + - (vlib_time_now (frm->vlib_main) - frm->vlib_time_0)); - h->export_time = clib_host_to_net_u32 (h->export_time); - h->domain_id = clib_host_to_net_u32 (stream->domain_id); - - /* FIXUP: message header sequence_number */ - h->sequence_number = stream->sequence_number++; - h->sequence_number = clib_host_to_net_u32 (h->sequence_number); - - offset = (u32) (((u8 *) (s + 1)) - (u8 *) tp); - } - - /* Add data, unless we're flushing stale data */ - if (PREDICT_TRUE (do_flush == 0)) - { - - /* Add data */ - /* Ingress interface */ - { - u32 ingress_interface = clib_host_to_net_u32 (rx_sw_if_index); - clib_memcpy (b0->data + offset, &ingress_interface, - sizeof (ingress_interface)); - offset += sizeof (ingress_interface); - } - /* Egress interface */ - { - u32 egress_interface = clib_host_to_net_u32 (tx_sw_if_index); - clib_memcpy (b0->data + offset, &egress_interface, - sizeof (egress_interface)); - offset += sizeof (egress_interface); - } - /* src mac address */ - { - clib_memcpy (b0->data + offset, src_mac, 6); - offset += 6; - } - /* dst mac address */ - { - clib_memcpy (b0->data + offset, dst_mac, 6); - offset += 6; - } - - /* ethertype */ - b0->data[offset++] = ethertype >> 8; - b0->data[offset++] = ethertype & 0xFF; - - /* Timestamp */ - clib_memcpy (b0->data + offset, ×tamp, sizeof (f64)); - offset += sizeof (f64); - - /* pkt size */ - { - u16 pkt_size = clib_host_to_net_u16 (length); - clib_memcpy (b0->data + offset, &pkt_size, sizeof (pkt_size)); - offset += sizeof (pkt_size); - } - - b0->current_length += - /* 2*sw_if_index + 2*mac + ethertype + timestamp + length = 32 */ - 2 * sizeof (u32) + 12 + sizeof (u16) + sizeof (f64) + sizeof (u16); - - } - /* Time to flush the buffer? */ - if (PREDICT_FALSE - (do_flush || (offset + 2 * sizeof (u32) + 12 + sizeof (u16) + - +sizeof (f64) + sizeof (u16)) > frm->path_mtu)) - { - tp = vlib_buffer_get_current (b0); - ip = (ip4_header_t *) & tp->ip4; - udp = (udp_header_t *) (ip + 1); - h = (ipfix_message_header_t *) (udp + 1); - s = (ipfix_set_header_t *) (h + 1); - - s->set_id_length = ipfix_set_id_length (fm->l2_report_id, - b0->current_length - - (sizeof (*ip) + sizeof (*udp) + - sizeof (*h))); - h->version_length = version_length (b0->current_length - - (sizeof (*ip) + sizeof (*udp))); - - ip->length = clib_host_to_net_u16 (b0->current_length); - - ip->checksum = ip4_header_checksum (ip); - udp->length = clib_host_to_net_u16 (b0->current_length - sizeof (*ip)); - - if (frm->udp_checksum) - { - /* RFC 7011 section 10.3.2. */ - udp->checksum = ip4_tcp_udp_compute_checksum (vm, b0, ip); - if (udp->checksum == 0) - udp->checksum = 0xffff; - } - - ASSERT (ip->checksum == ip4_header_checksum (ip)); - - if (PREDICT_FALSE (vlib_get_trace_count (vm, node) > 0)) - { - vlib_trace_buffer (vm, node, FLOWPERPKT_L2_NEXT_IP4_LOOKUP, b0, - 0 /* follow chain */ ); - flowperpkt_l2_trace_t *t = - vlib_add_trace (vm, node, b0, sizeof (*t)); - memset (t, 0, sizeof (*t)); - t->rx_sw_if_index = vnet_buffer (b0)->sw_if_index[VLIB_RX]; - t->tx_sw_if_index = vnet_buffer (b0)->sw_if_index[VLIB_TX]; - t->buffer_size = b0->current_length; - } - - vlib_put_frame_to_node (vm, ip4_lookup_node.index, - fm->l2_frames_per_worker[my_cpu_number]); - fm->l2_frames_per_worker[my_cpu_number] = 0; - fm->l2_buffers_per_worker[my_cpu_number] = 0; - offset = 0; - } - - fm->l2_next_record_offset_per_worker[my_cpu_number] = offset; -} - -void -flowperpkt_flush_callback_l2 (void) -{ - vlib_main_t *vm = vlib_get_main (); - flowperpkt_main_t *fm = &flowperpkt_main; - vlib_node_runtime_t *node; - node = vlib_node_get_runtime (vm, flowperpkt_l2_node.index); - - add_to_flow_record_l2 (vm, node, fm, 0 /* rx_sw_if_index */ , - 0 /* tx_sw_if_index */ , - 0 /* src mac */ , - 0 /* dst mac */ , - 0 /* ethertype */ , - 0ULL /* timestamp */ , - 0 /* length */ , - 1 /* do_flush */ ); -} - - -static uword -flowperpkt_l2_node_fn (vlib_main_t * vm, - vlib_node_runtime_t * node, vlib_frame_t * frame) -{ - u32 n_left_from, *from, *to_next; - flowperpkt_l2_next_t next_index; - flowperpkt_main_t *fm = &flowperpkt_main; - u64 now; - - now = (u64) ((vlib_time_now (vm) - fm->vlib_time_0) * 1e9); - now += fm->nanosecond_time_0; - - from = vlib_frame_vector_args (frame); - n_left_from = frame->n_vectors; - next_index = node->cached_next_index; - - while (n_left_from > 0) - { - u32 n_left_to_next; - - vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next); - - while (n_left_from >= 4 && n_left_to_next >= 2) - { - u32 next0 = FLOWPERPKT_L2_NEXT_DROP; - u32 next1 = FLOWPERPKT_L2_NEXT_DROP; - ethernet_header_t *eh0, *eh1; - u16 len0, len1; - u32 bi0, bi1; - vlib_buffer_t *b0, *b1; - - /* Prefetch next iteration. */ - { - vlib_buffer_t *p2, *p3; - - p2 = vlib_get_buffer (vm, from[2]); - p3 = vlib_get_buffer (vm, from[3]); - - vlib_prefetch_buffer_header (p2, LOAD); - vlib_prefetch_buffer_header (p3, LOAD); - - CLIB_PREFETCH (p2->data, CLIB_CACHE_LINE_BYTES, STORE); - CLIB_PREFETCH (p3->data, CLIB_CACHE_LINE_BYTES, STORE); - } - - /* speculatively enqueue b0 and b1 to the current next frame */ - to_next[0] = bi0 = from[0]; - to_next[1] = bi1 = from[1]; - from += 2; - to_next += 2; - n_left_from -= 2; - n_left_to_next -= 2; - - b0 = vlib_get_buffer (vm, bi0); - b1 = vlib_get_buffer (vm, bi1); - - vnet_feature_next (vnet_buffer (b0)->sw_if_index[VLIB_TX], - &next0, b0); - vnet_feature_next (vnet_buffer (b1)->sw_if_index[VLIB_TX], - &next1, b1); - - eh0 = vlib_buffer_get_current (b0); - len0 = vlib_buffer_length_in_chain (vm, b0); - - if (PREDICT_TRUE ((b0->flags & VLIB_BUFFER_FLOW_REPORT) == 0)) - add_to_flow_record_l2 (vm, node, fm, - vnet_buffer (b0)->sw_if_index[VLIB_RX], - vnet_buffer (b0)->sw_if_index[VLIB_TX], - eh0->src_address, - eh0->dst_address, - eh0->type, now, len0, 0 /* flush */ ); - - eh1 = vlib_buffer_get_current (b0); - len1 = vlib_buffer_length_in_chain (vm, b0); - - if (PREDICT_TRUE ((b1->flags & VLIB_BUFFER_FLOW_REPORT) == 0)) - add_to_flow_record_l2 (vm, node, fm, - vnet_buffer (b1)->sw_if_index[VLIB_RX], - vnet_buffer (b1)->sw_if_index[VLIB_TX], - eh1->src_address, - eh1->dst_address, - eh1->type, now, len1, 0 /* flush */ ); - - if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE))) - { - if (b0->flags & VLIB_BUFFER_IS_TRACED) - { - flowperpkt_l2_trace_t *t = - vlib_add_trace (vm, node, b0, sizeof (*t)); - t->rx_sw_if_index = vnet_buffer (b0)->sw_if_index[VLIB_RX]; - t->tx_sw_if_index = vnet_buffer (b0)->sw_if_index[VLIB_TX]; - clib_memcpy (t->src_mac, eh0->src_address, 6); - clib_memcpy (t->dst_mac, eh0->dst_address, 6); - t->ethertype = clib_net_to_host_u16 (eh0->type); - t->timestamp = now; - t->buffer_size = len0; - } - if (b1->flags & VLIB_BUFFER_IS_TRACED) - { - flowperpkt_l2_trace_t *t = - vlib_add_trace (vm, node, b1, sizeof (*t)); - t->rx_sw_if_index = vnet_buffer (b1)->sw_if_index[VLIB_RX]; - t->tx_sw_if_index = vnet_buffer (b1)->sw_if_index[VLIB_TX]; - clib_memcpy (t->src_mac, eh1->src_address, 6); - clib_memcpy (t->dst_mac, eh1->dst_address, 6); - t->ethertype = clib_net_to_host_u16 (eh1->type); - t->timestamp = now; - t->buffer_size = len1; - } - } - - /* verify speculative enqueues, maybe switch current next frame */ - vlib_validate_buffer_enqueue_x2 (vm, node, next_index, - to_next, n_left_to_next, - bi0, bi1, next0, next1); - } - - while (n_left_from > 0 && n_left_to_next > 0) - { - u32 bi0; - vlib_buffer_t *b0; - u32 next0 = FLOWPERPKT_L2_NEXT_DROP; - ethernet_header_t *eh0; - u16 len0; - - /* speculatively enqueue b0 to the current next frame */ - bi0 = from[0]; - to_next[0] = bi0; - from += 1; - to_next += 1; - n_left_from -= 1; - n_left_to_next -= 1; - - b0 = vlib_get_buffer (vm, bi0); - - vnet_feature_next (vnet_buffer (b0)->sw_if_index[VLIB_TX], - &next0, b0); - - eh0 = vlib_buffer_get_current (b0); - len0 = vlib_buffer_length_in_chain (vm, b0); - - if (PREDICT_TRUE ((b0->flags & VLIB_BUFFER_FLOW_REPORT) == 0)) - add_to_flow_record_l2 (vm, node, fm, - vnet_buffer (b0)->sw_if_index[VLIB_RX], - vnet_buffer (b0)->sw_if_index[VLIB_TX], - eh0->src_address, - eh0->dst_address, - eh0->type, now, len0, 0 /* flush */ ); - - if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE) - && (b0->flags & VLIB_BUFFER_IS_TRACED))) - { - flowperpkt_l2_trace_t *t = - vlib_add_trace (vm, node, b0, sizeof (*t)); - t->rx_sw_if_index = vnet_buffer (b0)->sw_if_index[VLIB_RX]; - t->tx_sw_if_index = vnet_buffer (b0)->sw_if_index[VLIB_TX]; - clib_memcpy (t->src_mac, eh0->src_address, 6); - clib_memcpy (t->dst_mac, eh0->dst_address, 6); - t->ethertype = clib_net_to_host_u16 (eh0->type); - t->timestamp = now; - t->buffer_size = len0; - } - - /* verify speculative enqueue, maybe switch current next frame */ - vlib_validate_buffer_enqueue_x1 (vm, node, next_index, - to_next, n_left_to_next, - bi0, next0); - } - - vlib_put_next_frame (vm, node, next_index, n_left_to_next); - } - return frame->n_vectors; -} - -/** - * @brief IPFIX l2 flow-per-packet graph node - * @node flowperpkt-l2 - * - * This is the IPFIX flow-record-per-packet node. - * - * @param vm vlib_main_t corresponding to the current thread. - * @param node vlib_node_runtime_t data for this node. - * @param frame vlib_frame_t whose contents should be dispatched. - * - * @par Graph mechanics: buffer metadata, next index usage - * - * Uses: - * - vnet_buffer(b)->ip.save_rewrite_length - * - tells the node the length of the rewrite which was applied in - * ip4/6_rewrite_inline, allows the code to find the IP header without - * having to parse L2 headers, or make stupid assumptions about their - * length. - * - vnet_buffer(b)->flags & VLIB_BUFFER_FLOW_REPORT - * - Used to suppress flow record generation for flow record packets. - * - * Sets: - * - vnet_buffer(b)->flags & VLIB_BUFFER_FLOW_REPORT - * - To suppress flow record generation for flow record packets - * - * Next Index: - * - Next configured output feature on the interface, usually - * "interface-output." Generated flow records head for ip4-lookup - */ - -/* *INDENT-OFF* */ -VLIB_REGISTER_NODE (flowperpkt_l2_node) = { - .function = flowperpkt_l2_node_fn, - .name = "flowperpkt-l2", - .vector_size = sizeof (u32), - .format_trace = format_flowperpkt_l2_trace, - .type = VLIB_NODE_TYPE_INTERNAL, - - .n_errors = ARRAY_LEN(flowperpkt_l2_error_strings), - .error_strings = flowperpkt_l2_error_strings, - - .n_next_nodes = FLOWPERPKT_L2_N_NEXT, - - /* edit / add dispositions here */ - .next_nodes = { - [FLOWPERPKT_L2_NEXT_DROP] = "error-drop", - [FLOWPERPKT_L2_NEXT_IP4_LOOKUP] = "ip4-lookup", - }, -}; -/* *INDENT-ON* */ - -/* - * fd.io coding-style-patch-verification: ON - * - * Local Variables: - * eval: (c-set-style "gnu") - * End: - */ diff --git a/plugins/flowperpkt-plugin/flowperpkt/node.c b/plugins/flowperpkt-plugin/flowperpkt/node.c deleted file mode 100644 index f77f087d..00000000 --- a/plugins/flowperpkt-plugin/flowperpkt/node.c +++ /dev/null @@ -1,574 +0,0 @@ -/* - * node.c - ipv4 ipfix-per-packet graph node - * - * Copyright (c) - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#include -#include -#include -#include -#include - -/** - * @file ipv4 flow record generator graph node - */ - -typedef struct -{ - /** interface handle */ - u32 rx_sw_if_index; - u32 tx_sw_if_index; - u32 src_address; - u32 dst_address; - /** ToS bits */ - u8 tos; - /** packet timestamp */ - u64 timestamp; - /** size of the buffer */ - u16 buffer_size; -} flowperpkt_ipv4_trace_t; - -/* packet trace format function */ -static u8 * -format_flowperpkt_ipv4_trace (u8 * s, va_list * args) -{ - CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *); - CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *); - flowperpkt_ipv4_trace_t *t = va_arg (*args, flowperpkt_ipv4_trace_t *); - - s = format (s, - "FLOWPERPKT-V4: rx_sw_if_index %d, tx_sw_if_index %d, src %U dst %U tos %0x2, timestamp %lld, size %d", - t->rx_sw_if_index, t->tx_sw_if_index, - format_ip4_address, &t->src_address, - format_ip4_address, &t->dst_address, - t->tos, t->timestamp, t->buffer_size); - return s; -} - -vlib_node_registration_t flowperpkt_ipv4_node; - -/* No counters at the moment */ -#define foreach_flowperpkt_ipv4_error - -typedef enum -{ -#define _(sym,str) FLOWPERPKT_ERROR_##sym, - foreach_flowperpkt_ipv4_error -#undef _ - FLOWPERPKT_N_ERROR, -} flowperpkt_ipv4_error_t; - -static char *flowperpkt_ipv4_error_strings[] = { -#define _(sym,string) string, - foreach_flowperpkt_ipv4_error -#undef _ -}; - -typedef enum -{ - FLOWPERPKT_IPV4_NEXT_DROP, - FLOWPERPKT_IPV4_NEXT_LOOKUP, - FLOWPERPKT_IPV4_N_NEXT, -} flowperpkt_ipv4_next_t; - -/** - * @brief add an entry to the flow record under construction - * @param vm vlib_main_t * current worker thread main structure pointer - * @param fm flowperpkt_main_t * flow-per-packet main structure pointer - * @param sw_if_index u32 interface handle - * @param tos u8 ToS bits from the packet - * @param timestamp u64 timestamp, nanoseconds since 1/1/70 - * @param length u16 ip length of the packet - * @param do_flush int 1 = flush all cached records, 0 = construct a record - */ - -static inline void -add_to_flow_record_ipv4 (vlib_main_t * vm, - vlib_node_runtime_t * node, - flowperpkt_main_t * fm, - u32 rx_sw_if_index, u32 tx_sw_if_index, - u32 src_address, u32 dst_address, - u8 tos, u64 timestamp, u16 length, int do_flush) -{ - u32 my_cpu_number = vm->cpu_index; - flow_report_main_t *frm = &flow_report_main; - ip4_header_t *ip; - udp_header_t *udp; - ip4_ipfix_template_packet_t *tp; - ipfix_message_header_t *h; - ipfix_set_header_t *s; - vlib_frame_t *f; - vlib_buffer_t *b0; - u16 offset; - u32 bi0; - vlib_buffer_free_list_t *fl; - - /* Find or allocate a buffer */ - b0 = fm->ipv4_buffers_per_worker[my_cpu_number]; - - /* Need to allocate a buffer? */ - if (PREDICT_FALSE (b0 == 0)) - { - /* Nothing to flush */ - if (do_flush) - return; - - /* $$$$ drop counter? */ - if (vlib_buffer_alloc (vm, &bi0, 1) != 1) - return; - - /* Initialize the buffer */ - b0 = fm->ipv4_buffers_per_worker[my_cpu_number] = - vlib_get_buffer (vm, bi0); - fl = - vlib_buffer_get_free_list (vm, VLIB_BUFFER_DEFAULT_FREE_LIST_INDEX); - vlib_buffer_init_for_free_list (b0, fl); - VLIB_BUFFER_TRACE_TRAJECTORY_INIT (b0); - offset = 0; - } - else - { - /* use the current buffer */ - bi0 = vlib_get_buffer_index (vm, b0); - offset = fm->ipv4_next_record_offset_per_worker[my_cpu_number]; - } - - /* Find or allocate a frame */ - f = fm->ipv4_frames_per_worker[my_cpu_number]; - if (PREDICT_FALSE (f == 0)) - { - u32 *to_next; - f = vlib_get_frame_to_node (vm, ip4_lookup_node.index); - fm->ipv4_frames_per_worker[my_cpu_number] = f; - - /* Enqueue the buffer */ - to_next = vlib_frame_vector_args (f); - to_next[0] = bi0; - f->n_vectors = 1; - } - - /* Fresh packet, construct header */ - if (PREDICT_FALSE (offset == 0)) - { - flow_report_stream_t *stream; - - stream = &frm->streams[0]; - - b0->current_data = 0; - b0->current_length = sizeof (*ip) + sizeof (*udp) + sizeof (*h) + - sizeof (*s); - b0->flags |= (VLIB_BUFFER_TOTAL_LENGTH_VALID | VLIB_BUFFER_FLOW_REPORT); - vnet_buffer (b0)->sw_if_index[VLIB_RX] = 0; - vnet_buffer (b0)->sw_if_index[VLIB_TX] = frm->fib_index; - - tp = vlib_buffer_get_current (b0); - ip = (ip4_header_t *) & tp->ip4; - udp = (udp_header_t *) (ip + 1); - h = (ipfix_message_header_t *) (udp + 1); - s = (ipfix_set_header_t *) (h + 1); - - ip->ip_version_and_header_length = 0x45; - ip->ttl = 254; - ip->protocol = IP_PROTOCOL_UDP; - ip->flags_and_fragment_offset = 0; - ip->src_address.as_u32 = frm->src_address.as_u32; - ip->dst_address.as_u32 = frm->ipfix_collector.as_u32; - udp->src_port = clib_host_to_net_u16 (UDP_DST_PORT_ipfix); - udp->dst_port = clib_host_to_net_u16 (UDP_DST_PORT_ipfix); - udp->checksum = 0; - - /* FIXUP: message header export_time */ - h->export_time = (u32) - (((f64) frm->unix_time_0) + - (vlib_time_now (frm->vlib_main) - frm->vlib_time_0)); - h->export_time = clib_host_to_net_u32 (h->export_time); - h->domain_id = clib_host_to_net_u32 (stream->domain_id); - - /* FIXUP: message header sequence_number */ - h->sequence_number = stream->sequence_number++; - h->sequence_number = clib_host_to_net_u32 (h->sequence_number); - - offset = (u32) (((u8 *) (s + 1)) - (u8 *) tp); - } - - /* Add data, unless we're flushing stale data */ - if (PREDICT_TRUE (do_flush == 0)) - { - - /* Add data */ - /* Ingress interface */ - { - u32 ingress_interface = clib_host_to_net_u32 (rx_sw_if_index); - clib_memcpy (b0->data + offset, &ingress_interface, - sizeof (ingress_interface)); - offset += sizeof (ingress_interface); - } - /* Egress interface */ - { - u32 egress_interface = clib_host_to_net_u32 (tx_sw_if_index); - clib_memcpy (b0->data + offset, &egress_interface, - sizeof (egress_interface)); - offset += sizeof (egress_interface); - } - /* ip4 src address */ - { - clib_memcpy (b0->data + offset, &src_address, sizeof (src_address)); - offset += sizeof (src_address); - } - /* ip4 dst address */ - { - clib_memcpy (b0->data + offset, &dst_address, sizeof (dst_address)); - offset += sizeof (dst_address); - } - - /* ToS */ - b0->data[offset++] = tos; - - /* Timestamp */ - clib_memcpy (b0->data + offset, ×tamp, sizeof (f64)); - offset += sizeof (f64); - - /* pkt size */ - { - u16 pkt_size = clib_host_to_net_u16 (length); - clib_memcpy (b0->data + offset, &pkt_size, sizeof (pkt_size)); - offset += sizeof (pkt_size); - } - - b0->current_length += - /* sw_if_index + tos + timestamp + length = 15 */ - 4 * sizeof (u32) + sizeof (u8) + sizeof (f64) + sizeof (u16); - - } - /* Time to flush the buffer? */ - if (PREDICT_FALSE - (do_flush || (offset + 4 * sizeof (u32) + sizeof (u8) - + sizeof (f64) + sizeof (u16)) > frm->path_mtu)) - { - tp = vlib_buffer_get_current (b0); - ip = (ip4_header_t *) & tp->ip4; - udp = (udp_header_t *) (ip + 1); - h = (ipfix_message_header_t *) (udp + 1); - s = (ipfix_set_header_t *) (h + 1); - - s->set_id_length = ipfix_set_id_length (fm->ipv4_report_id, - b0->current_length - - (sizeof (*ip) + sizeof (*udp) + - sizeof (*h))); - h->version_length = version_length (b0->current_length - - (sizeof (*ip) + sizeof (*udp))); - - ip->length = clib_host_to_net_u16 (b0->current_length); - - ip->checksum = ip4_header_checksum (ip); - udp->length = clib_host_to_net_u16 (b0->current_length - sizeof (*ip)); - - if (frm->udp_checksum) - { - /* RFC 7011 section 10.3.2. */ - udp->checksum = ip4_tcp_udp_compute_checksum (vm, b0, ip); - if (udp->checksum == 0) - udp->checksum = 0xffff; - } - - ASSERT (ip->checksum == ip4_header_checksum (ip)); - - if (PREDICT_FALSE (vlib_get_trace_count (vm, node) > 0)) - { - vlib_trace_buffer (vm, node, FLOWPERPKT_IPV4_NEXT_LOOKUP, b0, - 0 /* follow chain */ ); - flowperpkt_ipv4_trace_t *t = - vlib_add_trace (vm, node, b0, sizeof (*t)); - t->rx_sw_if_index = vnet_buffer (b0)->sw_if_index[VLIB_RX]; - t->tx_sw_if_index = vnet_buffer (b0)->sw_if_index[VLIB_TX]; - t->src_address = 0; - t->dst_address = 0; - t->tos = 0; - t->timestamp = 0; - t->buffer_size = b0->current_length; - } - - vlib_put_frame_to_node (vm, ip4_lookup_node.index, - fm->ipv4_frames_per_worker[my_cpu_number]); - fm->ipv4_frames_per_worker[my_cpu_number] = 0; - fm->ipv4_buffers_per_worker[my_cpu_number] = 0; - offset = 0; - } - - fm->ipv4_next_record_offset_per_worker[my_cpu_number] = offset; -} - -void -flowperpkt_flush_callback_ipv4 (void) -{ - vlib_main_t *vm = vlib_get_main (); - flowperpkt_main_t *fm = &flowperpkt_main; - vlib_node_runtime_t *node; - node = vlib_node_get_runtime (vm, flowperpkt_ipv4_node.index); - - add_to_flow_record_ipv4 (vm, node, fm, 0 /* rx_sw_if_index */ , - 0 /* tx_sw_if_index */ , - 0 /* src_address */ , - 0 /* dst_address */ , - 0 /* ToS */ , - 0ULL /* timestamp */ , - 0 /* length */ , - 1 /* do_flush */ ); -} - - -static uword -flowperpkt_ipv4_node_fn (vlib_main_t * vm, - vlib_node_runtime_t * node, vlib_frame_t * frame) -{ - u32 n_left_from, *from, *to_next; - flowperpkt_ipv4_next_t next_index; - flowperpkt_main_t *fm = &flowperpkt_main; - u64 now; - - now = (u64) ((vlib_time_now (vm) - fm->vlib_time_0) * 1e9); - now += fm->nanosecond_time_0; - - from = vlib_frame_vector_args (frame); - n_left_from = frame->n_vectors; - next_index = node->cached_next_index; - - while (n_left_from > 0) - { - u32 n_left_to_next; - - vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next); - - while (n_left_from >= 4 && n_left_to_next >= 2) - { - u32 next0 = FLOWPERPKT_IPV4_NEXT_DROP; - u32 next1 = FLOWPERPKT_IPV4_NEXT_DROP; - ip4_header_t *ip0, *ip1; - u16 len0, len1; - u32 bi0, bi1; - vlib_buffer_t *b0, *b1; - - /* Prefetch next iteration. */ - { - vlib_buffer_t *p2, *p3; - - p2 = vlib_get_buffer (vm, from[2]); - p3 = vlib_get_buffer (vm, from[3]); - - vlib_prefetch_buffer_header (p2, LOAD); - vlib_prefetch_buffer_header (p3, LOAD); - - CLIB_PREFETCH (p2->data, CLIB_CACHE_LINE_BYTES, STORE); - CLIB_PREFETCH (p3->data, CLIB_CACHE_LINE_BYTES, STORE); - } - - /* speculatively enqueue b0 and b1 to the current next frame */ - to_next[0] = bi0 = from[0]; - to_next[1] = bi1 = from[1]; - from += 2; - to_next += 2; - n_left_from -= 2; - n_left_to_next -= 2; - - b0 = vlib_get_buffer (vm, bi0); - b1 = vlib_get_buffer (vm, bi1); - - vnet_feature_next (vnet_buffer (b0)->sw_if_index[VLIB_TX], - &next0, b0); - vnet_feature_next (vnet_buffer (b1)->sw_if_index[VLIB_TX], - &next1, b1); - - ip0 = (ip4_header_t *) ((u8 *) vlib_buffer_get_current (b0) + - vnet_buffer (b0)->ip.save_rewrite_length); - - len0 = vlib_buffer_length_in_chain (vm, b0); - - if (PREDICT_TRUE ((b0->flags & VLIB_BUFFER_FLOW_REPORT) == 0)) - add_to_flow_record_ipv4 (vm, node, fm, - vnet_buffer (b0)->sw_if_index[VLIB_RX], - vnet_buffer (b0)->sw_if_index[VLIB_TX], - ip0->src_address.as_u32, - ip0->dst_address.as_u32, - ip0->tos, now, len0, 0 /* flush */ ); - - ip1 = (ip4_header_t *) ((u8 *) vlib_buffer_get_current (b1) + - vnet_buffer (b1)->ip.save_rewrite_length); - len1 = vlib_buffer_length_in_chain (vm, b1); - - if (PREDICT_TRUE ((b1->flags & VLIB_BUFFER_FLOW_REPORT) == 0)) - add_to_flow_record_ipv4 (vm, node, fm, - vnet_buffer (b1)->sw_if_index[VLIB_RX], - vnet_buffer (b1)->sw_if_index[VLIB_TX], - ip1->src_address.as_u32, - ip1->dst_address.as_u32, - ip1->tos, now, len1, 0 /* flush */ ); - - if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE))) - { - if (b0->flags & VLIB_BUFFER_IS_TRACED) - { - flowperpkt_ipv4_trace_t *t = - vlib_add_trace (vm, node, b0, sizeof (*t)); - t->rx_sw_if_index = vnet_buffer (b0)->sw_if_index[VLIB_RX]; - t->tx_sw_if_index = vnet_buffer (b0)->sw_if_index[VLIB_TX]; - t->src_address = ip0->src_address.as_u32; - t->dst_address = ip0->dst_address.as_u32; - t->tos = ip0->tos; - t->timestamp = now; - t->buffer_size = len0; - } - if (b1->flags & VLIB_BUFFER_IS_TRACED) - { - flowperpkt_ipv4_trace_t *t = - vlib_add_trace (vm, node, b1, sizeof (*t)); - t->rx_sw_if_index = vnet_buffer (b1)->sw_if_index[VLIB_RX]; - t->tx_sw_if_index = vnet_buffer (b1)->sw_if_index[VLIB_TX]; - t->src_address = ip1->src_address.as_u32; - t->dst_address = ip1->dst_address.as_u32; - t->tos = ip1->tos; - t->timestamp = now; - t->buffer_size = len1; - } - } - - /* verify speculative enqueues, maybe switch current next frame */ - vlib_validate_buffer_enqueue_x2 (vm, node, next_index, - to_next, n_left_to_next, - bi0, bi1, next0, next1); - } - - while (n_left_from > 0 && n_left_to_next > 0) - { - u32 bi0; - vlib_buffer_t *b0; - u32 next0 = FLOWPERPKT_IPV4_NEXT_DROP; - ip4_header_t *ip0; - u16 len0; - - /* speculatively enqueue b0 to the current next frame */ - bi0 = from[0]; - to_next[0] = bi0; - from += 1; - to_next += 1; - n_left_from -= 1; - n_left_to_next -= 1; - - b0 = vlib_get_buffer (vm, bi0); - - vnet_feature_next (vnet_buffer (b0)->sw_if_index[VLIB_TX], - &next0, b0); - - ip0 = (ip4_header_t *) ((u8 *) vlib_buffer_get_current (b0) + - vnet_buffer (b0)->ip.save_rewrite_length); - /* - * egressInterface, TLV type 14, u32 - * ipClassOfService, TLV type 5, u8 - * flowStartNanoseconds, TLV type 156, dateTimeNanoseconds (f64) - * Implementation: f64 nanoseconds since VPP started - * dataLinkFrameSize, TLV type 312, u16 - */ - len0 = vlib_buffer_length_in_chain (vm, b0); - - if (PREDICT_TRUE ((b0->flags & VLIB_BUFFER_FLOW_REPORT) == 0)) - add_to_flow_record_ipv4 (vm, node, fm, - vnet_buffer (b0)->sw_if_index[VLIB_RX], - vnet_buffer (b0)->sw_if_index[VLIB_TX], - ip0->src_address.as_u32, - ip0->dst_address.as_u32, - ip0->tos, now, len0, 0 /* flush */ ); - - if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE) - && (b0->flags & VLIB_BUFFER_IS_TRACED))) - { - flowperpkt_ipv4_trace_t *t = - vlib_add_trace (vm, node, b0, sizeof (*t)); - t->rx_sw_if_index = vnet_buffer (b0)->sw_if_index[VLIB_RX]; - t->tx_sw_if_index = vnet_buffer (b0)->sw_if_index[VLIB_TX]; - t->src_address = ip0->src_address.as_u32; - t->dst_address = ip0->dst_address.as_u32; - t->tos = ip0->tos; - t->timestamp = now; - t->buffer_size = len0; - } - - /* verify speculative enqueue, maybe switch current next frame */ - vlib_validate_buffer_enqueue_x1 (vm, node, next_index, - to_next, n_left_to_next, - bi0, next0); - } - - vlib_put_next_frame (vm, node, next_index, n_left_to_next); - } - return frame->n_vectors; -} - -/** - * @brief IPFIX ipv4 flow-per-packet graph node - * @node flowperpkt-ipv4 - * - * This is the IPFIX flow-record-per-packet node. - * - * @param vm vlib_main_t corresponding to the current thread. - * @param node vlib_node_runtime_t data for this node. - * @param frame vlib_frame_t whose contents should be dispatched. - * - * @par Graph mechanics: buffer metadata, next index usage - * - * Uses: - * - vnet_buffer(b)->ip.save_rewrite_length - * - tells the node the length of the rewrite which was applied in - * ip4/6_rewrite_inline, allows the code to find the IP header without - * having to parse L2 headers, or make stupid assumptions about their - * length. - * - vnet_buffer(b)->flags & VLIB_BUFFER_FLOW_REPORT - * - Used to suppress flow record generation for flow record packets. - * - * Sets: - * - vnet_buffer(b)->flags & VLIB_BUFFER_FLOW_REPORT - * - To suppress flow record generation for flow record packets - * - * Next Index: - * - Next configured output feature on the interface, usually - * "interface-output." Generated flow records head for ip4-lookup - */ - -/* *INDENT-OFF* */ -VLIB_REGISTER_NODE (flowperpkt_ipv4_node) = { - .function = flowperpkt_ipv4_node_fn, - .name = "flowperpkt-ipv4", - .vector_size = sizeof (u32), - .format_trace = format_flowperpkt_ipv4_trace, - .type = VLIB_NODE_TYPE_INTERNAL, - - .n_errors = ARRAY_LEN(flowperpkt_ipv4_error_strings), - .error_strings = flowperpkt_ipv4_error_strings, - - .n_next_nodes = FLOWPERPKT_IPV4_N_NEXT, - - /* edit / add dispositions here */ - .next_nodes = { - [FLOWPERPKT_IPV4_NEXT_DROP] = "error-drop", - /* Used only to trace ipfix data packets */ - [FLOWPERPKT_IPV4_NEXT_LOOKUP] = "ip4-lookup", - }, -}; -/* *INDENT-ON* */ - -/* - * fd.io coding-style-patch-verification: ON - * - * Local Variables: - * eval: (c-set-style "gnu") - * End: - */ diff --git a/plugins/flowperpkt-plugin/flowperpkt_plugin_doc.md b/plugins/flowperpkt-plugin/flowperpkt_plugin_doc.md deleted file mode 100644 index ed76c45c..00000000 --- a/plugins/flowperpkt-plugin/flowperpkt_plugin_doc.md +++ /dev/null @@ -1,13 +0,0 @@ -Per-packet IPFIX flow record plugin {#flowperpkt_plugin_doc} -=================================== - -## Introduction - -This plugin generates one ipfix record entry per packet transmitted -on interfaces which have the feature enabled - -## Sample configuration - -set ipfix exporter collector 192.168.6.2 src 192.168.6.1 template-interval 20 port 4739 path-mtu 1500 - -flowperpkt feature add-del GigabitEthernet2/3/0 diff --git a/plugins/ila-plugin/Makefile.am b/plugins/ila-plugin/Makefile.am deleted file mode 100644 index fe785df9..00000000 --- a/plugins/ila-plugin/Makefile.am +++ /dev/null @@ -1,29 +0,0 @@ -# Copyright (c) 2016 Cisco Systems, Inc. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at: -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -AUTOMAKE_OPTIONS = foreign subdir-objects - -AM_CFLAGS = -Wall -AM_LDFLAGS = -module -shared -avoid-version - -vpppluginsdir = ${libdir}/vpp_plugins - -vppplugins_LTLIBRARIES = ila_plugin.la - -ila_plugin_la_SOURCES = ila/ila.c - -noinst_HEADERS = ila/ila.h - -# Remove *.la files -install-data-hook: - @(cd $(vpppluginsdir) && $(RM) $(vppplugins_LTLIBRARIES)) diff --git a/plugins/ila-plugin/configure.ac b/plugins/ila-plugin/configure.ac deleted file mode 100644 index 56016b4d..00000000 --- a/plugins/ila-plugin/configure.ac +++ /dev/null @@ -1,9 +0,0 @@ -AC_INIT(ila_plugin, 1.0) -AM_INIT_AUTOMAKE -AM_SILENT_RULES([yes]) -AC_PREFIX_DEFAULT([/usr]) - -AC_PROG_LIBTOOL -AC_PROG_CC - -AC_OUTPUT([Makefile]) diff --git a/plugins/ila-plugin/ila/ila.c b/plugins/ila-plugin/ila/ila.c deleted file mode 100644 index 336f4cf5..00000000 --- a/plugins/ila-plugin/ila/ila.c +++ /dev/null @@ -1,1070 +0,0 @@ -/* - * Copyright (c) 2016 Cisco and/or its affiliates. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include -#include - -static ila_main_t ila_main; - -#define ILA_TABLE_DEFAULT_HASH_NUM_BUCKETS (64 * 1024) -#define ILA_TABLE_DEFAULT_HASH_MEMORY_SIZE (32<<20) - -#define foreach_ila_error \ - _(NONE, "valid ILA packets") - -typedef enum { -#define _(sym,str) ILA_ERROR_##sym, - foreach_ila_error -#undef _ - ILA_N_ERROR, -} ila_error_t; - -static char *ila_error_strings[] = { -#define _(sym,string) string, - foreach_ila_error -#undef _ -}; - -typedef enum { - ILA_ILA2SIR_NEXT_DROP, - ILA_ILA2SIR_N_NEXT, -} ila_ila2sir_next_t; - -typedef struct { - u32 ila_index; - ip6_address_t initial_dst; - u32 adj_index; -} ila_ila2sir_trace_t; - -static ila_entry_t ila_sir2ila_default_entry = { - .csum_mode = ILA_CSUM_MODE_NO_ACTION, - .type = ILA_TYPE_IID, - .dir = ILA_DIR_ILA2SIR, //Will pass the packet with no -}; - -/** - * @brief Dynamically registered DPO Type for ILA - */ -static dpo_type_t ila_dpo_type; - -/** - * @brief Dynamically registered FIB node type for ILA - */ -static fib_node_type_t ila_fib_node_type; - -u8 * -format_half_ip6_address (u8 * s, va_list * va) -{ - u64 v = clib_net_to_host_u64 (va_arg (*va, u64)); - - return format (s, "%04x:%04x:%04x:%04x", - v >> 48, (v >> 32) & 0xffff, (v >> 16) & 0xffff, v & 0xffff); - -} - -u8 * -format_ila_direction (u8 * s, va_list * args) -{ - ila_direction_t t = va_arg (*args, ila_direction_t); -#define _(i,n,st) \ - if (t == ILA_DIR_##i) \ - return format(s, st); - ila_foreach_direction -#undef _ - return format (s, "invalid_ila_direction"); -} - -static u8 * -format_csum_mode (u8 * s, va_list * va) -{ - ila_csum_mode_t csum_mode = va_arg (*va, ila_csum_mode_t); - char *txt; - - switch (csum_mode) - { -#define _(i,n,st) \ - case ILA_CSUM_MODE_##i: \ - txt = st; \ - break; - ila_csum_foreach_type -#undef _ - default: - txt = "invalid_ila_csum_mode"; - break; - } - return format (s, txt); -} - -u8 * -format_ila_type (u8 * s, va_list * args) -{ - ila_type_t t = va_arg (*args, ila_type_t); -#define _(i,n,st) \ - if (t == ILA_TYPE_##i) \ - return format(s, st); - ila_foreach_type -#undef _ - return format (s, "invalid_ila_type"); -} - -static u8 * -format_ila_entry (u8 * s, va_list * va) -{ - vnet_main_t *vnm = va_arg (*va, vnet_main_t *); - ila_entry_t *e = va_arg (*va, ila_entry_t *); - - if (!e) - { - return format (s, "%-15s%=40s%=40s%+16s%+18s%+11s", "Type", "SIR Address", - "ILA Address", "Checksum Mode", "Direction", "Next DPO"); - } - else if (vnm) - { - if (ip6_address_is_zero(&e->next_hop)) - { - return format (s, "%-15U%=40U%=40U%18U%11U%s", - format_ila_type, e->type, - format_ip6_address, &e->sir_address, - format_ip6_address, &e->ila_address, - format_csum_mode, e->csum_mode, - format_ila_direction, e->dir, - "n/a"); - } - else - { - return format (s, "%-15U%=40U%=40U%18U%11U%U", - format_ila_type, e->type, - format_ip6_address, &e->sir_address, - format_ip6_address, &e->ila_address, - format_csum_mode, e->csum_mode, - format_ila_direction, e->dir, - format_dpo_id, &e->ila_dpo, 0); - } - } - - return NULL; -} - -u8 * -format_ila_ila2sir_trace (u8 * s, va_list * args) -{ - CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *); - CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *); - ila_ila2sir_trace_t *t = va_arg (*args, ila_ila2sir_trace_t *); - return format (s, - "ILA -> SIR adj index: %d entry index: %d initial_dst: %U", - t->adj_index, t->ila_index, format_ip6_address, - &t->initial_dst); -} - -static uword -unformat_ila_direction (unformat_input_t * input, va_list * args) -{ - ila_direction_t *result = va_arg (*args, ila_direction_t *); -#define _(i,n,s) \ - if (unformat(input, s)) \ - { \ - *result = ILA_DIR_##i; \ - return 1;\ - } - - ila_foreach_direction -#undef _ - return 0; -} - -static uword -unformat_ila_type (unformat_input_t * input, va_list * args) -{ - ila_type_t *result = va_arg (*args, ila_type_t *); -#define _(i,n,s) \ - if (unformat(input, s)) \ - { \ - *result = ILA_TYPE_##i; \ - return 1;\ - } - - ila_foreach_type -#undef _ - return 0; -} - -static uword -unformat_ila_csum_mode (unformat_input_t * input, va_list * args) -{ - ila_csum_mode_t *result = va_arg (*args, ila_csum_mode_t *); - if (unformat (input, "none") || unformat (input, "no-action")) - { - *result = ILA_CSUM_MODE_NO_ACTION; - return 1; - } - if (unformat (input, "neutral-map")) - { - *result = ILA_CSUM_MODE_NEUTRAL_MAP; - return 1; - } - if (unformat (input, "adjust-transport")) - { - *result = ILA_CSUM_MODE_ADJUST_TRANSPORT; - return 1; - } - return 0; -} - -static uword -unformat_half_ip6_address (unformat_input_t * input, va_list * args) -{ - u64 *result = va_arg (*args, u64 *); - u32 a[4]; - - if (!unformat (input, "%x:%x:%x:%x", &a[0], &a[1], &a[2], &a[3])) - return 0; - - if (a[0] > 0xFFFF || a[1] > 0xFFFF || a[2] > 0xFFFF || a[3] > 0xFFFF) - return 0; - - *result = clib_host_to_net_u64 ((((u64) a[0]) << 48) | - (((u64) a[1]) << 32) | - (((u64) a[2]) << 16) | (((u64) a[3]))); - - return 1; -} - -static vlib_node_registration_t ila_ila2sir_node; - -static uword -ila_ila2sir (vlib_main_t * vm, - vlib_node_runtime_t * node, vlib_frame_t * frame) -{ - u32 n_left_from, *from, next_index, *to_next, n_left_to_next; - ila_main_t *ilm = &ila_main; - - from = vlib_frame_vector_args (frame); - n_left_from = frame->n_vectors; - next_index = node->cached_next_index; - - while (n_left_from > 0) - { - vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next); - - while (n_left_from >= 4 && n_left_to_next >= 2) - { - u32 pi0, pi1; - vlib_buffer_t *p0, *p1; - ila_entry_t *ie0, *ie1; - ip6_header_t *ip60, *ip61; - ip6_address_t *sir_address0, *sir_address1; - - { - vlib_buffer_t *p2, *p3; - - p2 = vlib_get_buffer (vm, from[2]); - p3 = vlib_get_buffer (vm, from[3]); - - vlib_prefetch_buffer_header (p2, LOAD); - vlib_prefetch_buffer_header (p3, LOAD); - CLIB_PREFETCH (p2->data, sizeof (ip6_header_t), LOAD); - CLIB_PREFETCH (p3->data, sizeof (ip6_header_t), LOAD); - } - - pi0 = to_next[0] = from[0]; - pi1 = to_next[1] = from[1]; - from += 2; - n_left_from -= 2; - to_next += 2; - n_left_to_next -= 2; - - p0 = vlib_get_buffer (vm, pi0); - p1 = vlib_get_buffer (vm, pi1); - ip60 = vlib_buffer_get_current (p0); - ip61 = vlib_buffer_get_current (p1); - sir_address0 = &ip60->dst_address; - sir_address1 = &ip61->dst_address; - ie0 = pool_elt_at_index (ilm->entries, - vnet_buffer (p0)->ip.adj_index[VLIB_TX]); - ie1 = pool_elt_at_index (ilm->entries, - vnet_buffer (p1)->ip.adj_index[VLIB_TX]); - - if (PREDICT_FALSE (p0->flags & VLIB_BUFFER_IS_TRACED)) - { - ila_ila2sir_trace_t *tr = - vlib_add_trace (vm, node, p0, sizeof (*tr)); - tr->ila_index = ie0 - ilm->entries; - tr->initial_dst = ip60->dst_address; - tr->adj_index = vnet_buffer (p0)->ip.adj_index[VLIB_TX]; - } - - if (PREDICT_FALSE (p1->flags & VLIB_BUFFER_IS_TRACED)) - { - ila_ila2sir_trace_t *tr = - vlib_add_trace (vm, node, p1, sizeof (*tr)); - tr->ila_index = ie1 - ilm->entries; - tr->initial_dst = ip61->dst_address; - tr->adj_index = vnet_buffer (p1)->ip.adj_index[VLIB_TX]; - } - - sir_address0 = (ie0->dir != ILA_DIR_SIR2ILA) ? &ie0->sir_address : sir_address0; - sir_address1 = (ie1->dir != ILA_DIR_SIR2ILA) ? &ie1->sir_address : sir_address1; - ip60->dst_address.as_u64[0] = sir_address0->as_u64[0]; - ip60->dst_address.as_u64[1] = sir_address0->as_u64[1]; - ip61->dst_address.as_u64[0] = sir_address1->as_u64[0]; - ip61->dst_address.as_u64[1] = sir_address1->as_u64[1]; - - vnet_buffer (p0)->ip.adj_index[VLIB_TX] = ie0->ila_dpo.dpoi_index; - vnet_buffer (p1)->ip.adj_index[VLIB_TX] = ie1->ila_dpo.dpoi_index; - - vlib_validate_buffer_enqueue_x2 (vm, node, next_index, to_next, - n_left_to_next, pi0, pi1, - ie0->ila_dpo.dpoi_next_node, - ie1->ila_dpo.dpoi_next_node); - } - - /* Single loop */ - while (n_left_from > 0 && n_left_to_next > 0) - { - u32 pi0; - vlib_buffer_t *p0; - ila_entry_t *ie0; - ip6_header_t *ip60; - ip6_address_t *sir_address0; - - pi0 = to_next[0] = from[0]; - from += 1; - n_left_from -= 1; - to_next += 1; - n_left_to_next -= 1; - - p0 = vlib_get_buffer (vm, pi0); - ip60 = vlib_buffer_get_current (p0); - sir_address0 = &ip60->dst_address; - ie0 = pool_elt_at_index (ilm->entries, - vnet_buffer (p0)->ip.adj_index[VLIB_TX]); - - if (PREDICT_FALSE (p0->flags & VLIB_BUFFER_IS_TRACED)) - { - ila_ila2sir_trace_t *tr = - vlib_add_trace (vm, node, p0, sizeof (*tr)); - tr->ila_index = ie0 ? (ie0 - ilm->entries) : ~0; - tr->initial_dst = ip60->dst_address; - tr->adj_index = vnet_buffer (p0)->ip.adj_index[VLIB_TX]; - } - - sir_address0 = (ie0->dir != ILA_DIR_SIR2ILA) ? &ie0->sir_address : sir_address0; - ip60->dst_address.as_u64[0] = sir_address0->as_u64[0]; - ip60->dst_address.as_u64[1] = sir_address0->as_u64[1]; - vnet_buffer (p0)->ip.adj_index[VLIB_TX] = ie0->ila_dpo.dpoi_index; - - vlib_validate_buffer_enqueue_x1 (vm, node, next_index, to_next, - n_left_to_next, pi0, - ie0->ila_dpo.dpoi_next_node); - } - vlib_put_next_frame (vm, node, next_index, n_left_to_next); - } - - return frame->n_vectors; -} - -/** *INDENT-OFF* */ -VLIB_REGISTER_NODE (ila_ila2sir_node, static) = -{ - .function = ila_ila2sir, - .name = "ila-to-sir", - .vector_size = sizeof (u32), - .format_trace = format_ila_ila2sir_trace, - .n_errors = ILA_N_ERROR, - .error_strings = ila_error_strings, - .n_next_nodes = ILA_ILA2SIR_N_NEXT, - .next_nodes = - { - [ILA_ILA2SIR_NEXT_DROP] = "error-drop" - }, -}; -/** *INDENT-ON* */ - -typedef enum -{ - ILA_SIR2ILA_NEXT_DROP, - ILA_SIR2ILA_N_NEXT, -} ila_sir2ila_next_t; - -typedef struct -{ - u32 ila_index; - ip6_address_t initial_dst; -} ila_sir2ila_trace_t; - -u8 * -format_ila_sir2ila_trace (u8 * s, va_list * args) -{ - CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *); - CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *); - ila_sir2ila_trace_t *t = va_arg (*args, ila_sir2ila_trace_t *); - - return format (s, "SIR -> ILA entry index: %d initial_dst: %U", - t->ila_index, format_ip6_address, &t->initial_dst); -} - -static vlib_node_registration_t ila_sir2ila_node; - -static uword -ila_sir2ila (vlib_main_t * vm, - vlib_node_runtime_t * node, vlib_frame_t * frame) -{ - u32 n_left_from, *from, next_index, *to_next, n_left_to_next; - ila_main_t *ilm = &ila_main; - - from = vlib_frame_vector_args (frame); - n_left_from = frame->n_vectors; - next_index = node->cached_next_index; - - while (n_left_from > 0) - { - vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next); - - while (n_left_from >= 4 && n_left_to_next >= 2) - { - u32 pi0, pi1; - vlib_buffer_t *p0, *p1; - ip6_header_t *ip60, *ip61; - u32 next0 = ILA_SIR2ILA_NEXT_DROP; - u32 next1 = ILA_SIR2ILA_NEXT_DROP; - BVT (clib_bihash_kv) kv0, value0; - BVT (clib_bihash_kv) kv1, value1; - ila_entry_t *ie0 = &ila_sir2ila_default_entry; - ila_entry_t *ie1 = &ila_sir2ila_default_entry; - ip6_address_t *ila_address0, *ila_address1; - - { - vlib_buffer_t *p2, *p3; - - p2 = vlib_get_buffer (vm, from[2]); - p3 = vlib_get_buffer (vm, from[3]); - - vlib_prefetch_buffer_header (p2, LOAD); - vlib_prefetch_buffer_header (p3, LOAD); - CLIB_PREFETCH (p2->data, sizeof (ip6_header_t), LOAD); - CLIB_PREFETCH (p3->data, sizeof (ip6_header_t), LOAD); - } - - pi0 = to_next[0] = from[0]; - pi1 = to_next[1] = from[1]; - from += 2; - n_left_from -= 2; - to_next += 2; - n_left_to_next -= 2; - - p0 = vlib_get_buffer (vm, pi0); - p1 = vlib_get_buffer (vm, pi1); - ip60 = vlib_buffer_get_current (p0); - ip61 = vlib_buffer_get_current (p1); - ila_address0 = &ip60->dst_address; - ila_address1 = &ip61->dst_address; - kv0.key[0] = ip60->dst_address.as_u64[0]; - kv0.key[1] = ip60->dst_address.as_u64[1]; - kv0.key[2] = 0; - kv1.key[0] = ip61->dst_address.as_u64[0]; - kv1.key[1] = ip61->dst_address.as_u64[1]; - kv1.key[2] = 0; - - if (PREDICT_TRUE((BV (clib_bihash_search) - (&ilm->id_to_entry_table, &kv0, &value0)) == 0)) { - ie0 = &ilm->entries[value0.value]; - ila_address0 = (ie0->dir != ILA_DIR_ILA2SIR) ? &ie0->ila_address : ila_address0; - } - - if ((BV (clib_bihash_search) - (&ilm->id_to_entry_table, &kv1, &value1)) == 0) { - ie1 = &ilm->entries[value1.value]; - ila_address1 = (ie1->dir != ILA_DIR_ILA2SIR) ? &ie1->ila_address : ila_address1; - } - - if (PREDICT_FALSE (p0->flags & VLIB_BUFFER_IS_TRACED)) - { - ila_sir2ila_trace_t *tr = - vlib_add_trace (vm, node, p0, sizeof (*tr)); - tr->ila_index = - (ie0 != &ila_sir2ila_default_entry) ? (ie0 - ilm->entries) : ~0; - tr->initial_dst = ip60->dst_address; - } - - if (PREDICT_FALSE (p1->flags & VLIB_BUFFER_IS_TRACED)) - { - ila_sir2ila_trace_t *tr = - vlib_add_trace (vm, node, p1, sizeof (*tr)); - tr->ila_index = - (ie1 != &ila_sir2ila_default_entry) ? (ie1 - ilm->entries) : ~0; - tr->initial_dst = ip61->dst_address; - } - - ip60->dst_address.as_u64[0] = ila_address0->as_u64[0]; - ip60->dst_address.as_u64[1] = ila_address0->as_u64[1]; - ip61->dst_address.as_u64[0] = ila_address1->as_u64[0]; - ip61->dst_address.as_u64[1] = ila_address1->as_u64[1]; - - vnet_feature_next (vnet_buffer (p0)->sw_if_index[VLIB_RX], &next0, p0); - vnet_feature_next (vnet_buffer (p1)->sw_if_index[VLIB_RX], &next1, p1); - - vlib_validate_buffer_enqueue_x2 (vm, node, next_index, to_next, - n_left_to_next, pi0, pi1, next0, - next1); - } - - /* Single loop */ - while (n_left_from > 0 && n_left_to_next > 0) - { - u32 pi0; - vlib_buffer_t *p0; - ip6_header_t *ip60; - u32 next0 = ILA_SIR2ILA_NEXT_DROP; - BVT (clib_bihash_kv) kv0, value0; - ila_entry_t *ie0 = &ila_sir2ila_default_entry; - ip6_address_t *ila_address0; - - pi0 = to_next[0] = from[0]; - from += 1; - n_left_from -= 1; - to_next += 1; - n_left_to_next -= 1; - - p0 = vlib_get_buffer (vm, pi0); - ip60 = vlib_buffer_get_current (p0); - ila_address0 = &ip60->dst_address; - - kv0.key[0] = ip60->dst_address.as_u64[0]; - kv0.key[1] = ip60->dst_address.as_u64[1]; - kv0.key[2] = 0; - - if (PREDICT_TRUE((BV (clib_bihash_search) - (&ilm->id_to_entry_table, &kv0, &value0)) == 0)) { - ie0 = &ilm->entries[value0.value]; - ila_address0 = (ie0->dir != ILA_DIR_ILA2SIR) ? &ie0->ila_address : ila_address0; - } - - if (PREDICT_FALSE (p0->flags & VLIB_BUFFER_IS_TRACED)) - { - ila_sir2ila_trace_t *tr = - vlib_add_trace (vm, node, p0, sizeof (*tr)); - tr->ila_index = - (ie0 != &ila_sir2ila_default_entry) ? (ie0 - ilm->entries) : ~0; - tr->initial_dst = ip60->dst_address; - } - - //This operation should do everything for any type (except vnid4 obviously) - ip60->dst_address.as_u64[0] = ila_address0->as_u64[0]; - ip60->dst_address.as_u64[1] = ila_address0->as_u64[1]; - - vnet_feature_next (vnet_buffer (p0)->sw_if_index[VLIB_RX], &next0, p0); - - vlib_validate_buffer_enqueue_x1 (vm, node, next_index, to_next, - n_left_to_next, pi0, next0); - } - vlib_put_next_frame (vm, node, next_index, n_left_to_next); - } - - return frame->n_vectors; -} - -/** *INDENT-OFF* */ -VLIB_REGISTER_NODE (ila_sir2ila_node, static) = -{ - .function = ila_sir2ila,.name = "sir-to-ila", - .vector_size = sizeof (u32), - .format_trace = format_ila_sir2ila_trace, - .n_errors = ILA_N_ERROR, - .error_strings = ila_error_strings, - .n_next_nodes = ILA_SIR2ILA_N_NEXT, - .next_nodes = - { - [ILA_SIR2ILA_NEXT_DROP] = "error-drop" - }, -}; -/** *INDENT-ON* */ - -/** *INDENT-OFF* */ -VNET_FEATURE_INIT (ila_sir2ila, static) = -{ - .arc_name = "ip6-unicast", - .node_name = "sir-to-ila", - .runs_before = VNET_FEATURES ("ip6-lookup"), -}; -/** *INDENT-ON* */ - -static void -ila_entry_stack (ila_entry_t *ie) -{ - /* - * restack on the next-hop's FIB entry - */ - dpo_stack(ila_dpo_type, - DPO_PROTO_IP6, - &ie->ila_dpo, - fib_entry_contribute_ip_forwarding( - ie->next_hop_fib_entry_index)); -} - -int -ila_add_del_entry (ila_add_del_entry_args_t * args) -{ - ila_main_t *ilm = &ila_main; - BVT (clib_bihash_kv) kv, value; - - //Sanity check - if (args->type == ILA_TYPE_IID || args->type == ILA_TYPE_LUID) - { - if ((args->sir_address.as_u8[8] >> 5) != args->type) - { - clib_warning ("Incorrect SIR address (ILA type mismatch %d %d)", - args->sir_address.as_u8[8] >> 1, args->type); - return -1; - } - if (args->sir_address.as_u8[8] & 0x10) - { - clib_warning ("Checksum bit should not be set in SIR address"); - return -1; - } - } - else if (args->type == ILA_TYPE_VNIDM) - { - if (args->sir_address.as_u8[0] != 0xff || - (args->sir_address.as_u8[1] & 0xf0) != 0xf0) - { - clib_warning ("SIR multicast address must start with fff"); - return -1; - } - if (args->sir_address.as_u16[1] || args->sir_address.as_u16[2] || - args->sir_address.as_u16[3] || args->sir_address.as_u16[4] || - args->sir_address.as_u16[5] || (args->sir_address.as_u8[12] & 0xf0)) - { - clib_warning ("SIR multicast address must start with fff"); - return -1; - } - } - - if (!args->is_del) - { - ila_entry_t *e; - pool_get (ilm->entries, e); - e->type = args->type; - e->sir_address = args->sir_address; - e->next_hop = args->next_hop_address; - e->csum_mode = args->csum_mode; - e->dir = args->dir; - - //Construct ILA address - switch (e->type) - { - case ILA_TYPE_IID: - e->ila_address = e->sir_address; - break; - case ILA_TYPE_LUID: - e->ila_address.as_u64[0] = args->locator; - e->ila_address.as_u64[1] = args->sir_address.as_u64[1]; - break; - case ILA_TYPE_VNID6: - e->ila_address.as_u64[0] = args->locator; - e->ila_address.as_u8[8] = (ILA_TYPE_VNID6 << 1); - e->ila_address.as_u32[2] |= args->vnid; - e->ila_address.as_u32[3] = args->sir_address.as_u32[3]; - break; - case ILA_TYPE_VNIDM: - e->ila_address.as_u64[0] = args->locator; - e->ila_address.as_u8[8] = (ILA_TYPE_VNIDM << 1); - e->ila_address.as_u32[2] |= args->vnid; - e->ila_address.as_u32[3] = args->sir_address.as_u32[3]; - e->ila_address.as_u8[12] |= args->sir_address.as_u8[2] << 4; - break; - case ILA_TYPE_VNID4: - clib_warning ("ILA type '%U' is not supported", format_ila_type, - e->type); - return -1; - } - - //Modify ILA checksum if necessary - if (e->csum_mode == ILA_CSUM_MODE_NEUTRAL_MAP) - { - ip_csum_t csum = e->ila_address.as_u16[7]; - int i; - for (i = 0; i < 4; i++) - { - csum = ip_csum_sub_even (csum, e->sir_address.as_u32[i]); - csum = ip_csum_add_even (csum, e->ila_address.as_u32[i]); - } - csum = ip_csum_add_even (csum, clib_host_to_net_u16 (0x1000)); - e->ila_address.as_u16[7] = ip_csum_fold (csum); - e->ila_address.as_u8[8] |= 0x10; - } - - //Create entry with the sir address - kv.key[0] = e->sir_address.as_u64[0]; - kv.key[1] = e->sir_address.as_u64[1]; - kv.key[2] = 0; - kv.value = e - ilm->entries; - BV (clib_bihash_add_del) (&ilm->id_to_entry_table, &kv, - 1 /* is_add */ ); - - if (!ip6_address_is_zero(&e->next_hop)) - { - /* - * become a child of the FIB netry for the next-hop - * so we are informed when its forwarding changes - */ - fib_prefix_t next_hop = { - .fp_addr = { - .ip6 = e->next_hop, - }, - .fp_len = 128, - .fp_proto = FIB_PROTOCOL_IP6, - }; - - e->next_hop_fib_entry_index = - fib_table_entry_special_add(0, - &next_hop, - FIB_SOURCE_RR, - FIB_ENTRY_FLAG_NONE, - ADJ_INDEX_INVALID); - e->next_hop_child_index = - fib_entry_child_add(e->next_hop_fib_entry_index, - ila_fib_node_type, - e - ilm->entries); - - /* - * Create a route that results in the ILA entry - */ - dpo_id_t dpo = DPO_INVALID; - fib_prefix_t pfx = { - .fp_addr = { - .ip6 = e->ila_address, - }, - .fp_len = 128, - .fp_proto = FIB_PROTOCOL_IP6, - }; - - dpo_set(&dpo, ila_dpo_type, DPO_PROTO_IP6, e - ilm->entries); - - fib_table_entry_special_dpo_add(0, - &pfx, - FIB_SOURCE_PLUGIN_HI, - FIB_ENTRY_FLAG_EXCLUSIVE, - &dpo); - dpo_reset(&dpo); - - /* - * finally stack the ILA entry so it will forward to the next-hop - */ - ila_entry_stack (e); - } - } - else - { - ila_entry_t *e; - kv.key[0] = args->sir_address.as_u64[0]; - kv.key[1] = args->sir_address.as_u64[1]; - kv.key[2] = 0; - - if ((BV (clib_bihash_search) (&ilm->id_to_entry_table, &kv, &value) < - 0)) - { - return -1; - } - - e = &ilm->entries[value.value]; - - if (!ip6_address_is_zero(&e->next_hop)) - { - fib_prefix_t pfx = { - .fp_addr = { - .ip6 = e->ila_address, - }, - .fp_len = 128, - .fp_proto = FIB_PROTOCOL_IP6, - }; - - fib_table_entry_special_remove(0, &pfx, FIB_SOURCE_PLUGIN_HI); - /* - * remove this ILA entry as child of the FIB netry for the next-hop - */ - fib_entry_child_remove(e->next_hop_fib_entry_index, - e->next_hop_child_index); - fib_table_entry_delete_index(e->next_hop_fib_entry_index, - FIB_SOURCE_RR); - e->next_hop_fib_entry_index = FIB_NODE_INDEX_INVALID; - } - dpo_reset (&e->ila_dpo); - - BV (clib_bihash_add_del) (&ilm->id_to_entry_table, &kv, - 0 /* is_add */ ); - pool_put (ilm->entries, e); - } - return 0; -} - -int -ila_interface (u32 sw_if_index, u8 disable) -{ - vnet_feature_enable_disable ("ip4-unicast", "sir-to-ila", sw_if_index, - !disable, 0, 0); - return 0; -} - -clib_error_t * -vlib_plugin_register (vlib_main_t * vm, vnet_plugin_handoff_t * h, - int from_early_init) -{ - clib_error_t *error = 0; - - return error; -} - -u8 *format_ila_dpo (u8 * s, va_list * va) -{ - index_t index = va_arg (*va, index_t); - CLIB_UNUSED(u32 indent) = va_arg (*va, u32); - ila_main_t *ilm = &ila_main; - ila_entry_t *ie = pool_elt_at_index (ilm->entries, index); - return format(s, "ILA: idx:%d sir:%U", - index, - format_ip6_address, &ie->sir_address); -} - -/** - * @brief no-op lock function. - * The lifetime of the ILA entry is managed by the control plane - */ -static void -ila_dpo_lock (dpo_id_t *dpo) -{ -} - -/** - * @brief no-op unlock function. - * The lifetime of the ILA entry is managed by the control plane - */ -static void -ila_dpo_unlock (dpo_id_t *dpo) -{ -} - -const static dpo_vft_t ila_vft = { - .dv_lock = ila_dpo_lock, - .dv_unlock = ila_dpo_unlock, - .dv_format = format_ila_dpo, -}; -const static char* const ila_ip6_nodes[] = -{ - "ila-to-sir", - NULL, -}; -const static char* const * const ila_nodes[DPO_PROTO_NUM] = -{ - [DPO_PROTO_IP6] = ila_ip6_nodes, -}; - -static fib_node_t * -ila_fib_node_get_node (fib_node_index_t index) -{ - ila_main_t *ilm = &ila_main; - ila_entry_t *ie = pool_elt_at_index (ilm->entries, index); - - return (&ie->ila_fib_node); -} - -/** - * @brief no-op unlock function. - * The lifetime of the ILA entry is managed by the control plane - */ -static void -ila_fib_node_last_lock_gone (fib_node_t *node) -{ -} - -static ila_entry_t * -ila_entry_from_fib_node (fib_node_t *node) -{ - return ((ila_entry_t*)(((char*)node) - - STRUCT_OFFSET_OF(ila_entry_t, ila_fib_node))); -} - -/** - * @brief - * Callback function invoked when the forwarding changes for the ILA next-hop - */ -static fib_node_back_walk_rc_t -ila_fib_node_back_walk_notify (fib_node_t *node, - fib_node_back_walk_ctx_t *ctx) -{ - ila_entry_stack(ila_entry_from_fib_node(node)); - - return (FIB_NODE_BACK_WALK_CONTINUE); -} - -/* - * ILA's FIB graph node virtual function table - */ -static const fib_node_vft_t ila_fib_node_vft = { - .fnv_get = ila_fib_node_get_node, - .fnv_last_lock = ila_fib_node_last_lock_gone, - .fnv_back_walk = ila_fib_node_back_walk_notify, -}; - -clib_error_t * -ila_init (vlib_main_t * vm) -{ - ila_main_t *ilm = &ila_main; - ilm->entries = NULL; - - ilm->lookup_table_nbuckets = ILA_TABLE_DEFAULT_HASH_NUM_BUCKETS; - ilm->lookup_table_nbuckets = 1 << max_log2 (ilm->lookup_table_nbuckets); - ilm->lookup_table_size = ILA_TABLE_DEFAULT_HASH_MEMORY_SIZE; - - BV (clib_bihash_init) (&ilm->id_to_entry_table, - "ila id to entry index table", - ilm->lookup_table_nbuckets, ilm->lookup_table_size); - - ila_dpo_type = dpo_register_new_type(&ila_vft, ila_nodes); - ila_fib_node_type = fib_node_register_new_type(&ila_fib_node_vft); - - return NULL; -} - -VLIB_INIT_FUNCTION (ila_init); - -static clib_error_t * -ila_entry_command_fn (vlib_main_t * vm, - unformat_input_t * input, vlib_cli_command_t * cmd) -{ - unformat_input_t _line_input, *line_input = &_line_input; - ila_add_del_entry_args_t args = { 0 }; - u8 next_hop_set = 0; - int ret; - - args.type = ILA_TYPE_IID; - args.csum_mode = ILA_CSUM_MODE_NO_ACTION; - args.local_adj_index = ~0; - args.dir = ILA_DIR_BIDIR; - - if (!unformat_user (input, unformat_line_input, line_input)) - return 0; - - while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) - { - if (unformat (line_input, "type %U", unformat_ila_type, &args.type)) - ; - else if (unformat - (line_input, "sir-address %U", unformat_ip6_address, - &args.sir_address)) - ; - else if (unformat - (line_input, "locator %U", unformat_half_ip6_address, - &args.locator)) - ; - else if (unformat - (line_input, "csum-mode %U", unformat_ila_csum_mode, - &args.csum_mode)) - ; - else if (unformat (line_input, "vnid %x", &args.vnid)) - ; - else if (unformat - (line_input, "next-hop %U", unformat_ip6_address, - &args.next_hop_address)) - ; - else if (unformat - (line_input, "direction %U", unformat_ila_direction, &args.dir)) - next_hop_set = 1; - else if (unformat (line_input, "del")) - args.is_del = 1; - else - return clib_error_return (0, "parse error: '%U'", - format_unformat_error, line_input); - } - - unformat_free (line_input); - - if (!next_hop_set) - return clib_error_return (0, "Specified a next hop"); - - if ((ret = ila_add_del_entry (&args))) - return clib_error_return (0, "ila_add_del_entry returned error %d", ret); - - return NULL; -} - -VLIB_CLI_COMMAND (ila_entry_command, static) = -{ - .path = "ila entry", - .short_help = "ila entry [type ] [sir-address
] [locator ] [vnid ]" - " [adj-index ] [next-hop ] [direction (bidir|sir2ila|ila2sir)]" - " [csum-mode (no-action|neutral-map|transport-adjust)] [del]", - .function = ila_entry_command_fn, -}; - -static clib_error_t * -ila_interface_command_fn (vlib_main_t * vm, - unformat_input_t * input, vlib_cli_command_t * cmd) -{ - vnet_main_t *vnm = vnet_get_main (); - u32 sw_if_index = ~0; - u8 disable = 0; - - if (!unformat (input, "%U", unformat_vnet_sw_interface, vnm, &sw_if_index)) - { - return clib_error_return (0, "Invalid interface name"); - } - - if (unformat (input, "disable")) - { - disable = 1; - } - - int ret; - if ((ret = ila_interface (sw_if_index, disable))) - return clib_error_return (0, "ila_interface returned error %d", ret); - - return NULL; -} - -VLIB_CLI_COMMAND (ila_interface_command, static) = -{ - .path = "ila interface", - .short_help = "ila interface [disable]", - .function = ila_interface_command_fn, -}; - -static clib_error_t * -ila_show_entries_command_fn (vlib_main_t * vm, - unformat_input_t * input, - vlib_cli_command_t * cmd) -{ - vnet_main_t *vnm = vnet_get_main (); - ila_main_t *ilm = &ila_main; - ila_entry_t *e; - - vlib_cli_output (vm, " %U\n", format_ila_entry, vnm, NULL); - pool_foreach (e, ilm->entries, - ({ - vlib_cli_output (vm, " %U\n", format_ila_entry, vnm, e); - })); - - return NULL; -} - -VLIB_CLI_COMMAND (ila_show_entries_command, static) = -{ - .path = "show ila entries", - .short_help = "show ila entries", - .function = ila_show_entries_command_fn, -}; diff --git a/plugins/ila-plugin/ila/ila.h b/plugins/ila-plugin/ila/ila.h deleted file mode 100644 index 26620983..00000000 --- a/plugins/ila-plugin/ila/ila.h +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright (c) 2016 Cisco and/or its affiliates. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ILA_H -#define ILA_H - -#include -#include -#include - -#include -#include - -#define ila_foreach_type \ - _(IID, 0, "iid") \ - _(LUID, 1, "luid") \ - _(VNID4, 2, "vnid-ip4") \ - _(VNID6, 3, "vnid-ip6") \ - _(VNIDM, 4, "vnid-multicast") - -typedef enum { -#define _(i,n,s) ILA_TYPE_##i = n, - ila_foreach_type -#undef _ -} ila_type_t; - -#define ila_csum_foreach_type \ -_(NO_ACTION, 0, "no-action") \ -_(NEUTRAL_MAP, 1, "neutral-map") \ -_(ADJUST_TRANSPORT, 2, "adjust-transport") - -typedef enum { -#define _(i,n,s) ILA_CSUM_MODE_##i = n, - ila_csum_foreach_type -#undef _ - ILA_CSUM_N_TYPES -} ila_csum_mode_t; - -#define ila_foreach_direction \ -_(BIDIR, 0, "bidir") \ -_(SIR2ILA, 1, "sir2ila") \ -_(ILA2SIR, 2, "ila2sir") - -typedef enum { -#define _(i,n,s) ILA_DIR_##i = n, - ila_foreach_direction -#undef _ -} ila_direction_t; - -typedef struct { - /** - * Fib Node base class - */ - fib_node_t ila_fib_node; - ila_type_t type; - ip6_address_t sir_address; - ip6_address_t ila_address; - ip6_address_t next_hop; - ila_csum_mode_t csum_mode; - ila_direction_t dir; - - /** - * The FIB entry index for the next-hop - */ - fib_node_index_t next_hop_fib_entry_index; - - /** - * The child index on the FIB entry - */ - u32 next_hop_child_index; - - /** - * The next DPO in the grpah to follow - */ - dpo_id_t ila_dpo; -} ila_entry_t; - -typedef struct { - ila_entry_t *entries; //Pool of ILA entries - - u64 lookup_table_nbuckets; - u64 lookup_table_size; - clib_bihash_24_8_t id_to_entry_table; - - u32 ip6_lookup_next_index; -} ila_main_t; - - -typedef struct { - ila_type_t type; - ip6_address_t sir_address; - ip6_address_t next_hop_address; - u64 locator; - u32 vnid; - u32 local_adj_index; - ila_csum_mode_t csum_mode; - ila_direction_t dir; - u8 is_del; -} ila_add_del_entry_args_t; - -int ila_add_del_entry (ila_add_del_entry_args_t * args); -int ila_interface (u32 sw_if_index, u8 disable); - -#endif //ILA_H diff --git a/plugins/sixrd-plugin/Makefile.am b/plugins/sixrd-plugin/Makefile.am deleted file mode 100644 index eb0d806a..00000000 --- a/plugins/sixrd-plugin/Makefile.am +++ /dev/null @@ -1,38 +0,0 @@ -# Copyright (c) 2015 Cisco and/or its affiliates. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at: -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -AUTOMAKE_OPTIONS = foreign subdir-objects - -AM_CFLAGS = -Wall -AM_LDFLAGS = -module -shared -avoid-version - -libsixrd_plugin_la_SOURCES = \ - sixrd/sixrd.c \ - sixrd/sixrd_dpo.c \ - sixrd/ip4_sixrd.c \ - sixrd/ip6_sixrd.c - -noinst_HEADERS = \ - sixrd/sixrd.h \ - sixrd/sixrd_dpo.h - -BUILT_SOURCES = - -vpppluginsdir = ${libdir}/vpp_plugins - -vppplugins_LTLIBRARIES = libsixrd_plugin.la - - -# Remove *.la files -install-data-hook: - @(cd $(vpppluginsdir) && $(RM) $(vppplugins_LTLIBRARIES)) diff --git a/plugins/sixrd-plugin/configure.ac b/plugins/sixrd-plugin/configure.ac deleted file mode 100644 index 3aa4c425..00000000 --- a/plugins/sixrd-plugin/configure.ac +++ /dev/null @@ -1,9 +0,0 @@ -AC_INIT(sixrd_plugin, 1.0) -LT_INIT -AM_INIT_AUTOMAKE -AM_SILENT_RULES([yes]) -AC_PREFIX_DEFAULT([/usr]) - -AC_PROG_CC - -AC_OUTPUT([Makefile]) diff --git a/plugins/sixrd-plugin/sixrd/ip4_sixrd.c b/plugins/sixrd-plugin/sixrd/ip4_sixrd.c deleted file mode 100644 index 2fb8015d..00000000 --- a/plugins/sixrd-plugin/sixrd/ip4_sixrd.c +++ /dev/null @@ -1,127 +0,0 @@ -/*--------------------------------------------------------------------------- - * Copyright (c) 2009-2014 Cisco and/or its affiliates. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *--------------------------------------------------------------------------- - */ -#include "sixrd.h" - -static vlib_node_registration_t ip4_sixrd_node; - -typedef enum { - IP4_SIXRD_NEXT_IP6_LOOKUP, - IP4_SIXRD_NEXT_DROP, - IP4_SIXRD_N_NEXT, -} ip4_sixrd_next_t; - -/* - * ip4_sixrd_sec_check - */ -static_always_inline void -ip4_sixrd_sec_check (sixrd_domain_t *d, ip4_address_t sa4, ip6_address_t sa6, u8 *error) -{ - u32 a = sixrd_get_addr(d, sa6.as_u64[0]); - clib_warning("Security check: %U %U", format_ip4_address, &a, format_ip4_address, &sa4); - if (PREDICT_FALSE(sixrd_get_addr(d, sa6.as_u64[0]) != sa4.as_u32)) - *error = SIXRD_ERROR_SEC_CHECK; -} - -/* - * ip4_sixrd - */ -static uword -ip4_sixrd (vlib_main_t *vm, - vlib_node_runtime_t *node, - vlib_frame_t *frame) -{ - u32 n_left_from, *from, next_index, *to_next, n_left_to_next; - vlib_node_runtime_t *error_node = vlib_node_get_runtime(vm, ip4_sixrd_node.index); - u32 decap = 0; - - from = vlib_frame_vector_args(frame); - n_left_from = frame->n_vectors; - next_index = node->cached_next_index; - while (n_left_from > 0) { - vlib_get_next_frame(vm, node, next_index, to_next, n_left_to_next); - - /* Single loop */ - while (n_left_from > 0 && n_left_to_next > 0) { - u32 pi0; - vlib_buffer_t *p0; - u8 error0 = SIXRD_ERROR_NONE; - sixrd_domain_t *d0 = 0; - ip4_header_t *ip40; - ip6_header_t *ip60; - u32 sixrd_domain_index0 = ~0; - u32 next0; - - pi0 = to_next[0] = from[0]; - from += 1; - n_left_from -= 1; - to_next +=1; - n_left_to_next -= 1; - - p0 = vlib_get_buffer(vm, pi0); - ip40 = vlib_buffer_get_current(p0); - - /* Throw away anything that isn't IP in IP. */ - if (PREDICT_TRUE(ip40->protocol == IP_PROTOCOL_IPV6 && clib_net_to_host_u16(ip40->length) >= 60)) { - vlib_buffer_advance(p0, sizeof(ip4_header_t)); - ip60 = vlib_buffer_get_current(p0); - d0 = ip4_sixrd_get_domain(vnet_buffer(p0)->ip.adj_index[VLIB_TX], (ip6_address_t *)&ip60->src_address, - &sixrd_domain_index0, &error0); - } else { - error0 = SIXRD_ERROR_BAD_PROTOCOL; - } - if (d0) { - /* SIXRD inbound security check */ - ip4_sixrd_sec_check(d0, ip40->src_address, ip60->src_address, &error0); - } - - next0 = error0 == SIXRD_ERROR_NONE ? IP4_SIXRD_NEXT_IP6_LOOKUP : IP4_SIXRD_NEXT_DROP; - - if (PREDICT_FALSE(p0->flags & VLIB_BUFFER_IS_TRACED)) { - sixrd_trace_t *tr = vlib_add_trace(vm, node, p0, sizeof(*tr)); - tr->sixrd_domain_index = sixrd_domain_index0; - } - - p0->error = error_node->errors[error0]; - if (PREDICT_TRUE(error0 == SIXRD_ERROR_NONE)) decap++; - vlib_validate_buffer_enqueue_x1(vm, node, next_index, to_next, n_left_to_next, pi0, next0); - - } - vlib_put_next_frame(vm, node, next_index, n_left_to_next); - } - vlib_node_increment_counter(vm, ip4_sixrd_node.index, SIXRD_ERROR_DECAPSULATED, decap); - - return frame->n_vectors; -} - -static char *sixrd_error_strings[] = { -#define _(sym,string) string, - foreach_sixrd_error -#undef _ -}; - -VLIB_REGISTER_NODE(ip4_sixrd_node,static) = { - .function = ip4_sixrd, - .name = "ip4-sixrd", - .vector_size = sizeof(u32), - .format_trace = format_sixrd_trace, - .n_errors = SIXRD_N_ERROR, - .error_strings = sixrd_error_strings, - .n_next_nodes = IP4_SIXRD_N_NEXT, - .next_nodes = { - [IP4_SIXRD_NEXT_IP6_LOOKUP] = "ip6-lookup", - [IP4_SIXRD_NEXT_DROP] = "error-drop", - }, -}; diff --git a/plugins/sixrd-plugin/sixrd/ip6_sixrd.c b/plugins/sixrd-plugin/sixrd/ip6_sixrd.c deleted file mode 100644 index 36f3fab3..00000000 --- a/plugins/sixrd-plugin/sixrd/ip6_sixrd.c +++ /dev/null @@ -1,129 +0,0 @@ -/*--------------------------------------------------------------------------- - * Copyright (c) 2009-2014 Cisco and/or its affiliates. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *--------------------------------------------------------------------------- - */ -/* - * Defines used for testing various optimisation schemes - */ -#define SIXRD_ENCAP_DUAL 0 - -#include "sixrd.h" - -static vlib_node_registration_t ip6_sixrd_node; - -typedef enum { - IP6_SIXRD_NEXT_IP4_LOOKUP, - IP6_SIXRD_NEXT_DROP, - IP6_SIXRD_N_NEXT, -} ip6_sixrd_next_t; - -/* - * ip6_sixrd - */ -static uword -ip6_sixrd (vlib_main_t *vm, - vlib_node_runtime_t *node, - vlib_frame_t *frame) -{ - u32 n_left_from, *from, next_index, *to_next, n_left_to_next; - vlib_node_runtime_t *error_node = vlib_node_get_runtime(vm, ip6_sixrd_node.index); - u32 encap = 0; - from = vlib_frame_vector_args(frame); - n_left_from = frame->n_vectors; - next_index = node->cached_next_index; - - while (n_left_from > 0) { - vlib_get_next_frame(vm, node, next_index, to_next, n_left_to_next); - - while (n_left_from > 0 && n_left_to_next > 0) { - u32 pi0; - vlib_buffer_t *p0; - sixrd_domain_t *d0; - u8 error0 = SIXRD_ERROR_NONE; - ip6_header_t *ip60; - ip4_header_t *ip4h0; - u32 next0 = IP6_SIXRD_NEXT_IP4_LOOKUP; - u32 sixrd_domain_index0 = ~0; - - pi0 = to_next[0] = from[0]; - from += 1; - n_left_from -= 1; - to_next +=1; - n_left_to_next -= 1; - - p0 = vlib_get_buffer(vm, pi0); - ip60 = vlib_buffer_get_current(p0); - // p0->current_length = clib_net_to_host_u16(ip40->length); - d0 = ip6_sixrd_get_domain(vnet_buffer(p0)->ip.adj_index[VLIB_TX], &sixrd_domain_index0); - ASSERT(d0); - - /* SIXRD calc */ - u64 dal60 = clib_net_to_host_u64(ip60->dst_address.as_u64[0]); - u32 da40 = sixrd_get_addr(d0, dal60); - u16 len = clib_net_to_host_u16(ip60->payload_length) + 60; - if (da40 == 0) error0 = SIXRD_ERROR_UNKNOWN; - - /* construct ipv4 header */ - vlib_buffer_advance(p0, - (sizeof(ip4_header_t))); - ip4h0 = vlib_buffer_get_current(p0); - vnet_buffer(p0)->sw_if_index[VLIB_TX] = (u32)~0; - ip4h0->ip_version_and_header_length = 0x45; - ip4h0->tos = 0; - ip4h0->length = clib_host_to_net_u16(len); - ip4h0->fragment_id = 0; - ip4h0->flags_and_fragment_offset = 0; - ip4h0->ttl = 0x40; - ip4h0->protocol = IP_PROTOCOL_IPV6; - ip4h0->src_address = d0->ip4_src; - ip4h0->dst_address.as_u32 = clib_host_to_net_u32(da40); - ip4h0->checksum = ip4_header_checksum(ip4h0); - - next0 = error0 == SIXRD_ERROR_NONE ? IP6_SIXRD_NEXT_IP4_LOOKUP : IP6_SIXRD_NEXT_DROP; - - if (PREDICT_FALSE(p0->flags & VLIB_BUFFER_IS_TRACED)) { - sixrd_trace_t *tr = vlib_add_trace(vm, node, p0, sizeof(*tr)); - tr->sixrd_domain_index = sixrd_domain_index0; - } - - p0->error = error_node->errors[error0]; - if (PREDICT_TRUE(error0 == SIXRD_ERROR_NONE)) encap++; - - vlib_validate_buffer_enqueue_x1(vm, node, next_index, to_next, n_left_to_next, pi0, next0); - } - vlib_put_next_frame(vm, node, next_index, n_left_to_next); - } - vlib_node_increment_counter(vm, ip6_sixrd_node.index, SIXRD_ERROR_ENCAPSULATED, encap); - - return frame->n_vectors; -} - -static char *sixrd_error_strings[] = { -#define _(sym,string) string, - foreach_sixrd_error -#undef _ -}; - -VLIB_REGISTER_NODE(ip6_sixrd_node,static) = { - .function = ip6_sixrd, - .name = "ip6-sixrd", - .vector_size = sizeof(u32), - .format_trace = format_sixrd_trace, - .n_errors = SIXRD_N_ERROR, - .error_strings = sixrd_error_strings, - .n_next_nodes = IP6_SIXRD_N_NEXT, - .next_nodes = { - [IP6_SIXRD_NEXT_IP4_LOOKUP] = "ip4-lookup", - [IP6_SIXRD_NEXT_DROP] = "error-drop", - }, -}; diff --git a/plugins/sixrd-plugin/sixrd/sixrd.c b/plugins/sixrd-plugin/sixrd/sixrd.c deleted file mode 100644 index 66e631a2..00000000 --- a/plugins/sixrd-plugin/sixrd/sixrd.c +++ /dev/null @@ -1,369 +0,0 @@ -/* - * Copyright (c) 2015 Cisco and/or its affiliates. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "sixrd.h" -#include - -#include -#include -#include - -/* - * This code supports the following sixrd modes: - * - * 32 EA bits (Complete IPv4 address is embedded): - * ea_bits_len = 32 - * IPv4 suffix is embedded: - * ea_bits_len = < 32 - * No embedded address bits (1:1 mode): - * ea_bits_len = 0 - */ - -int -sixrd_create_domain (ip6_address_t *ip6_prefix, - u8 ip6_prefix_len, - ip4_address_t *ip4_prefix, - u8 ip4_prefix_len, - ip4_address_t *ip4_src, - u32 *sixrd_domain_index, - u16 mtu) -{ - dpo_id_t dpo_v6 = DPO_INVALID, dpo_v4 = DPO_INVALID; - sixrd_main_t *mm = &sixrd_main; - fib_node_index_t fei; - sixrd_domain_t *d; - - /* Get domain index */ - pool_get_aligned(mm->domains, d, CLIB_CACHE_LINE_BYTES); - memset(d, 0, sizeof (*d)); - *sixrd_domain_index = d - mm->domains; - - /* Init domain struct */ - d->ip4_prefix.as_u32 = ip4_prefix->as_u32; - d->ip4_prefix_len = ip4_prefix_len; - d->ip6_prefix = *ip6_prefix; - d->ip6_prefix_len = ip6_prefix_len; - d->ip4_src = *ip4_src; - d->mtu = mtu; - - if (ip4_prefix_len < 32) - d->shift = 64 - ip6_prefix_len + (32 - ip4_prefix_len); - - /* Create IPv6 route/adjacency */ - fib_prefix_t pfx6 = { - .fp_proto = FIB_PROTOCOL_IP6, - .fp_len = d->ip6_prefix_len, - .fp_addr = { - .ip6 = d->ip6_prefix, - }, - }; - sixrd_dpo_create(DPO_PROTO_IP6, - *sixrd_domain_index, - &dpo_v6); - fib_table_entry_special_dpo_add(0, &pfx6, - FIB_SOURCE_SIXRD, - FIB_ENTRY_FLAG_EXCLUSIVE, - &dpo_v6); - dpo_reset (&dpo_v6); - - /* - * Multiple SIXRD domains may share same source IPv4 TEP - * In this case the route will exist and be SixRD sourced. - * Find the adj (if any) already contributed and modify it - */ - fib_prefix_t pfx4 = { - .fp_proto = FIB_PROTOCOL_IP4, - .fp_len = 32, - .fp_addr = { - .ip4 = d->ip4_src, - }, - }; - fei = fib_table_lookup_exact_match(0, &pfx4); - - if (FIB_NODE_INDEX_INVALID != fei) - { - dpo_id_t dpo = DPO_INVALID; - - if (fib_entry_get_dpo_for_source (fei, FIB_SOURCE_SIXRD, &dpo)) - { - /* - * modify the existing adj to indicate it's shared - * skip to route add. - * It is locked to pair with the unlock below. - */ - const dpo_id_t *sd_dpo; - sixrd_dpo_t *sd; - - ASSERT(DPO_LOAD_BALANCE == dpo.dpoi_type); - - sd_dpo = load_balance_get_bucket(dpo.dpoi_index, 0); - sd = sixrd_dpo_get (sd_dpo->dpoi_index); - - sd->sd_domain = ~0; - dpo_copy (&dpo_v4, sd_dpo); - dpo_reset (&dpo); - - goto route_add; - } - } - /* first time addition of the route */ - sixrd_dpo_create(DPO_PROTO_IP4, - *sixrd_domain_index, - &dpo_v4); - -route_add: - /* - * Create ip4 route. This is a reference counted add. If the prefix - * already exists and is SixRD sourced, it is now SixRD source n+1 times - * and will need to be removed n+1 times. - */ - fib_table_entry_special_dpo_add(0, &pfx4, - FIB_SOURCE_SIXRD, - FIB_ENTRY_FLAG_EXCLUSIVE, - &dpo_v4); - dpo_reset (&dpo_v4); - - return 0; -} - -/* - * sixrd_delete_domain - */ -int -sixrd_delete_domain (u32 sixrd_domain_index) -{ - sixrd_main_t *mm = &sixrd_main; - sixrd_domain_t *d; - - if (pool_is_free_index(mm->domains, sixrd_domain_index)) { - clib_warning("SIXRD domain delete: domain does not exist: %d", - sixrd_domain_index); - return -1; - } - - d = pool_elt_at_index(mm->domains, sixrd_domain_index); - - fib_prefix_t pfx = { - .fp_proto = FIB_PROTOCOL_IP4, - .fp_len = 32, - .fp_addr = { - .ip4 = d->ip4_src, - }, - }; - fib_table_entry_special_remove(0, &pfx, FIB_SOURCE_SIXRD); - - fib_prefix_t pfx6 = { - .fp_proto = FIB_PROTOCOL_IP6, - .fp_len = d->ip6_prefix_len, - .fp_addr = { - .ip6 = d->ip6_prefix, - }, - }; - fib_table_entry_special_remove(0, &pfx6, FIB_SOURCE_SIXRD); - - pool_put(mm->domains, d); - - return 0; -} - -static clib_error_t * -sixrd_add_domain_command_fn (vlib_main_t *vm, - unformat_input_t *input, - vlib_cli_command_t *cmd) -{ - unformat_input_t _line_input, *line_input = &_line_input; - ip4_address_t ip4_prefix; - ip6_address_t ip6_prefix; - ip4_address_t ip4_src; - u32 ip6_prefix_len=0, ip4_prefix_len=0, sixrd_domain_index; - u32 num_m_args = 0; - /* Optional arguments */ - u32 mtu = 0; - - /* Get a line of input. */ - if (!unformat_user(input, unformat_line_input, line_input)) - return 0; - while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) { - if (unformat(line_input, "ip6-pfx %U/%d", unformat_ip6_address, &ip6_prefix, &ip6_prefix_len)) - num_m_args++; - else if (unformat(line_input, "ip4-pfx %U/%d", unformat_ip4_address, &ip4_prefix, &ip4_prefix_len)) - num_m_args++; - else if (unformat(line_input, "ip4-src %U", unformat_ip4_address, &ip4_src)) - num_m_args++; - else if (unformat(line_input, "mtu %d", &mtu)) - num_m_args++; - else - return clib_error_return(0, "unknown input `%U'", - format_unformat_error, input); - } - unformat_free(line_input); - - if (num_m_args < 3) - return clib_error_return(0, "mandatory argument(s) missing"); - - sixrd_create_domain(&ip6_prefix, ip6_prefix_len, &ip4_prefix, ip4_prefix_len, - &ip4_src, &sixrd_domain_index, mtu); - - return 0; -} - -static clib_error_t * -sixrd_del_domain_command_fn (vlib_main_t *vm, - unformat_input_t *input, - vlib_cli_command_t *cmd) -{ - unformat_input_t _line_input, *line_input = &_line_input; - u32 num_m_args = 0; - u32 sixrd_domain_index; - - /* Get a line of input. */ - if (! unformat_user(input, unformat_line_input, line_input)) - return 0; - - while (unformat_check_input(line_input) != UNFORMAT_END_OF_INPUT) { - if (unformat(line_input, "index %d", &sixrd_domain_index)) - num_m_args++; - else - return clib_error_return(0, "unknown input `%U'", - format_unformat_error, input); - } - unformat_free(line_input); - - if (num_m_args != 1) - return clib_error_return(0, "mandatory argument(s) missing"); - - sixrd_delete_domain(sixrd_domain_index); - - return 0; -} - -static u8 * -format_sixrd_domain (u8 *s, va_list *args) -{ - sixrd_domain_t *d = va_arg(*args, sixrd_domain_t *); - sixrd_main_t *mm = &sixrd_main; - - s = format(s, - "[%d] ip6-pfx %U/%d ip4-pfx %U/%d ip4-src %U mtu %d", - d - mm->domains, - format_ip6_address, &d->ip6_prefix, d->ip6_prefix_len, - format_ip4_address, &d->ip4_prefix, d->ip4_prefix_len, - format_ip4_address, &d->ip4_src, d->mtu); - - return s; -} - -static clib_error_t * -show_sixrd_domain_command_fn (vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd) -{ - sixrd_main_t *mm = &sixrd_main; - sixrd_domain_t *d; - - if (pool_elts(mm->domains) == 0) - vlib_cli_output(vm, "No SIXRD domains are configured..."); - - pool_foreach(d, mm->domains, ({vlib_cli_output(vm, "%U", format_sixrd_domain, d);})); - - return 0; - -} - -static clib_error_t * -show_sixrd_stats_command_fn (vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd) -{ - sixrd_main_t *mm = &sixrd_main; - sixrd_domain_t *d; - int domains = 0, domaincount = 0; - if (pool_elts (mm->domains) == 0) - vlib_cli_output (vm, "No SIXRD domains are configured..."); - - pool_foreach(d, mm->domains, ({ - domains += sizeof(*d); - domaincount++; - })); - - vlib_cli_output(vm, "SIXRD domains structure: %d\n", sizeof (sixrd_domain_t)); - vlib_cli_output(vm, "SIXRD domains: %d (%d bytes)\n", domaincount, domains); - - return 0; -} - -/* - * packet trace format function - */ -u8 * -format_sixrd_trace (u8 *s, va_list *args) -{ - CLIB_UNUSED(vlib_main_t *vm) = va_arg (*args, vlib_main_t *); - CLIB_UNUSED(vlib_node_t *node) = va_arg (*args, vlib_node_t *); - sixrd_trace_t *t = va_arg (*args, sixrd_trace_t *); - u32 sixrd_domain_index = t->sixrd_domain_index; - - s = format(s, "SIXRD domain index: %d", sixrd_domain_index); - - return s; -} - -VLIB_CLI_COMMAND(sixrd_add_domain_command, static) = { - .path = "sixrd add domain", - .short_help = - "sixrd add domain ip6-pfx ip4-pfx ip4-src ", - .function = sixrd_add_domain_command_fn, -}; - -VLIB_CLI_COMMAND(sixrd_del_command, static) = { - .path = "sixrd del domain", - .short_help = - "sixrd del domain index ", - .function = sixrd_del_domain_command_fn, -}; - -VLIB_CLI_COMMAND(show_sixrd_domain_command, static) = { - .path = "show sixrd domain", - .function = show_sixrd_domain_command_fn, -}; - -VLIB_CLI_COMMAND(show_sixrd_stats_command, static) = { - .path = "show sixrd stats", - .function = show_sixrd_stats_command_fn, -}; - -/* - * This routine exists to convince the vlib plugin framework that - * we haven't accidentally copied a random .dll into the plugin directory. - * - * Also collects global variable pointers passed from the vpp engine - */ -clib_error_t * -vlib_plugin_register (vlib_main_t * vm, vnet_plugin_handoff_t * h, - int from_early_init) -{ - clib_error_t * error = 0; - sixrd_main_t *mm = &sixrd_main; - - mm->vnet_main = vnet_get_main(); - mm->vlib_main = vm; - - return error; -} - -static clib_error_t * sixrd_init (vlib_main_t * vm) -{ - sixrd_dpo_module_init (); - - return (NULL); -} - -VLIB_INIT_FUNCTION (sixrd_init); diff --git a/plugins/sixrd-plugin/sixrd/sixrd.h b/plugins/sixrd-plugin/sixrd/sixrd.h deleted file mode 100644 index 56714c9e..00000000 --- a/plugins/sixrd-plugin/sixrd/sixrd.h +++ /dev/null @@ -1,141 +0,0 @@ -/*--------------------------------------------------------------------------- - * Copyright (c) 2009-2014 Cisco and/or its affiliates. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *--------------------------------------------------------------------------- - */ -#include -#include -#include -#include -#include - -#include "sixrd_dpo.h" - -int sixrd_create_domain(ip6_address_t *ip6_prefix, u8 ip6_prefix_len, - ip4_address_t *ip4_prefix, u8 ip4_prefix_len, - ip4_address_t *ip4_src, u32 *sixrd_domain_index, u16 mtu); -int sixrd_delete_domain(u32 sixrd_domain_index); -u8 *format_sixrd_trace(u8 *s, va_list *args); - -typedef struct { - ip6_address_t ip6_prefix; - ip4_address_t ip4_prefix; - ip4_address_t ip4_src; - u8 ip6_prefix_len; - u8 ip4_prefix_len; - - /* helpers */ - u8 shift; - - u16 mtu; -} sixrd_domain_t; - -typedef struct { - /* pool of SIXRD domains */ - sixrd_domain_t *domains; - - /* convenience */ - vlib_main_t *vlib_main; - vnet_main_t *vnet_main; -} sixrd_main_t; - -#define foreach_sixrd_error \ - /* Must be first. */ \ - _(NONE, "valid SIXRD packets") \ - _(BAD_PROTOCOL, "bad protocol") \ - _(WRONG_ICMP_TYPE, "wrong icmp type") \ - _(SEC_CHECK, "security check failed") \ - _(ICMP, "unable to translate ICMP") \ - _(UNKNOWN, "unknown") \ - _(NO_DOMAIN, "no domain") \ - _(ENCAPSULATED, "encapsulated") \ - _(DECAPSULATED, "decapsulated") \ - _(TRANSLATED_4TO6, "translated 4 to 6") \ - _(TRANSLATED_6TO4, "translated 6 to 4") \ - _(FRAGMENT, "fragment handling error") \ - _(FRAGMENT_QUEUED, "dropped, missing first fragment") \ - _(FRAGMENTED, "packets requiring fragmentation") \ - _(FRAGMENT_PARTS, "fragment parts") \ - _(MALFORMED, "malformed packet") - -typedef enum { -#define _(sym,str) SIXRD_ERROR_##sym, - foreach_sixrd_error -#undef _ - SIXRD_N_ERROR, - } sixrd_error_t; - -typedef struct { - u32 sixrd_domain_index; -} sixrd_trace_t; - -sixrd_main_t sixrd_main; - -/* - * sixrd_get_addr - */ -static_always_inline u32 -sixrd_get_addr (sixrd_domain_t *d, u64 dal) -{ - - /* 1:1 mode */ - if (d->ip4_prefix_len == 32) return (d->ip4_prefix.as_u32); - - /* Grab 32 - ip4_prefix_len bits out of IPv6 address from offset ip6_prefix_len */ - return (d->ip4_prefix.as_u32 | (u32)(dal >> d->shift)); -} - -/* - * Get the SIXRD domain from an IPv6 lookup adjacency. - */ -static_always_inline sixrd_domain_t * -ip6_sixrd_get_domain (u32 sdi, u32 *sixrd_domain_index) -{ - sixrd_main_t *mm = &sixrd_main; - sixrd_dpo_t *sd; - - sd = sixrd_dpo_get(sdi); - - ASSERT(sd); - *sixrd_domain_index = sd->sd_domain; - return pool_elt_at_index(mm->domains, *sixrd_domain_index); -} - -/* - * Get the SIXRD domain from an IPv4 lookup adjacency. - * If the IPv4 address is not shared, no lookup is required. - * The IPv6 address is used otherwise. - */ -static_always_inline sixrd_domain_t * -ip4_sixrd_get_domain (u32 sdi, ip6_address_t *addr, - u32 *sixrd_domain_index, u8 *error) -{ - sixrd_main_t *mm = &sixrd_main; - sixrd_dpo_t *sd; - - sd = sixrd_dpo_get(sdi); - *sixrd_domain_index = sd->sd_domain; - if (*sixrd_domain_index != ~0) - return pool_elt_at_index(mm->domains, *sixrd_domain_index); - - u32 lbi = ip6_fib_table_fwding_lookup(&ip6_main, 0, addr); - const dpo_id_t *dpo = load_balance_get_bucket(lbi, 0); - if (PREDICT_TRUE(dpo->dpoi_type == sixrd_dpo_type)) - { - sd = sixrd_dpo_get(dpo->dpoi_index); - *sixrd_domain_index = sd->sd_domain; - return pool_elt_at_index(mm->domains, *sixrd_domain_index); - } - *error = SIXRD_ERROR_NO_DOMAIN; - return NULL; -} diff --git a/plugins/sixrd-plugin/sixrd/sixrd_dpo.c b/plugins/sixrd-plugin/sixrd/sixrd_dpo.c deleted file mode 100644 index 88a07935..00000000 --- a/plugins/sixrd-plugin/sixrd/sixrd_dpo.c +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Copyright (c) 2016 Cisco and/or its affiliates. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "sixrd_dpo.h" -#include - -/** - * pool of all MPLS Label DPOs - */ -sixrd_dpo_t *sixrd_dpo_pool; - -/** - * The register SIXRD DPO type - */ -dpo_type_t sixrd_dpo_type; - -static sixrd_dpo_t * -sixrd_dpo_alloc (void) -{ - sixrd_dpo_t *sd; - - pool_get_aligned(sixrd_dpo_pool, sd, CLIB_CACHE_LINE_BYTES); - memset(sd, 0, sizeof(*sd)); - - return (sd); -} - -static index_t -sixrd_dpo_get_index (sixrd_dpo_t *sd) -{ - return (sd - sixrd_dpo_pool); -} - -void -sixrd_dpo_create (dpo_proto_t dproto, - u32 domain_index, - dpo_id_t *dpo) -{ - sixrd_dpo_t *sd; - - sd = sixrd_dpo_alloc(); - sd->sd_domain = domain_index; - sd->sd_proto = dproto; - - dpo_set(dpo, - sixrd_dpo_type, - dproto, - sixrd_dpo_get_index(sd)); -} - -u8* -format_sixrd_dpo (u8 *s, va_list *args) -{ - index_t index = va_arg (*args, index_t); - CLIB_UNUSED(u32 indent) = va_arg (*args, u32); - sixrd_dpo_t *sd; - - sd = sixrd_dpo_get(index); - - return (format(s, "sixrd:[%d]:%U domain:%d", - index, - format_dpo_proto, sd->sd_proto, - sd->sd_domain)); -} - - -static void -sixrd_dpo_lock (dpo_id_t *dpo) -{ - sixrd_dpo_t *sd; - - sd = sixrd_dpo_get(dpo->dpoi_index); - - sd->sd_locks++; -} - -static void -sixrd_dpo_unlock (dpo_id_t *dpo) -{ - sixrd_dpo_t *sd; - - sd = sixrd_dpo_get(dpo->dpoi_index); - - sd->sd_locks--; - - if (0 == sd->sd_locks) - { - pool_put(sixrd_dpo_pool, sd); - } -} - -const static dpo_vft_t sd_vft = { - .dv_lock = sixrd_dpo_lock, - .dv_unlock = sixrd_dpo_unlock, - .dv_format = format_sixrd_dpo, -}; - -const static char* const sixrd_ip4_nodes[] = -{ - "ip4-sixrd", - NULL, -}; -const static char* const sixrd_ip6_nodes[] = -{ - "ip6-sixrd", - NULL, -}; - -const static char* const * const sixrd_nodes[DPO_PROTO_NUM] = -{ - [DPO_PROTO_IP4] = sixrd_ip4_nodes, - [DPO_PROTO_IP6] = sixrd_ip6_nodes, - [DPO_PROTO_MPLS] = NULL, -}; - -void -sixrd_dpo_module_init (void) -{ - sixrd_dpo_type = dpo_register_new_type(&sd_vft, sixrd_nodes); -} diff --git a/plugins/sixrd-plugin/sixrd/sixrd_dpo.h b/plugins/sixrd-plugin/sixrd/sixrd_dpo.h deleted file mode 100644 index 17142288..00000000 --- a/plugins/sixrd-plugin/sixrd/sixrd_dpo.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2016 Cisco and/or its affiliates. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef __SIXRD_DPO_H__ -#define __SIXRD_DPO_H__ - -#include -#include - -/** - * A representation of a 6RD DPO - */ -typedef struct sixrd_dpo_t -{ - /** - * The dat-plane protocol - */ - dpo_proto_t sd_proto; - - /** - * the SIXRD domain index - */ - u32 sd_domain; - - /** - * Number of locks/users of the label - */ - u16 sd_locks; -} sixrd_dpo_t; - -extern void sixrd_dpo_create (dpo_proto_t dproto, - u32 domain_index, - dpo_id_t *dpo); - -/* - * Encapsulation violation for fast data-path access - */ -extern sixrd_dpo_t *sixrd_dpo_pool; -extern dpo_type_t sixrd_dpo_type; - -static inline sixrd_dpo_t * -sixrd_dpo_get (index_t index) -{ - return (pool_elt_at_index(sixrd_dpo_pool, index)); -} - -extern void sixrd_dpo_module_init(void); - -#endif diff --git a/src/Makefile.am b/src/Makefile.am new file mode 100644 index 00000000..e691a539 --- /dev/null +++ b/src/Makefile.am @@ -0,0 +1,101 @@ +# Copyright (c) 2016 Cisco and/or its affiliates. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +############################################################################### +# Global Defines +############################################################################### + +AUTOMAKE_OPTIONS = foreign subdir-objects +ACLOCAL_AMFLAGS = -I m4 + +AM_CFLAGS = -Wall + +SUBDIRS = . +SUFFIXES = .api.h .api .api.json +API_FILES = +noinst_HEADERS = +dist_bin_SCRIPTS = +lib_LTLIBRARIES = +BUILT_SOURCES = + +############################################################################### +# DPDK +############################################################################### + +if WITH_DPDK +if ENABLE_DPDK_SHARED +DPDK_LD_FLAGS = -Wl,--whole-archive,-ldpdk,--no-whole-archive +else +DPDK_LD_FLAGS = -Wl,--whole-archive,-l:libdpdk.a,--no-whole-archive +endif +if WITH_DPDK_CRYPTO +DPDK_LD_ADD = -L$(AESNI_MULTI_BUFFER_LIB_PATH) -lIPSec_MB +endif +if WITH_DPDK_MLX5_PMD +DPDK_LD_FLAGS += -libverbs -lmlx5 -lnuma +endif +else +DPDK_LD_FLAGS = +DPDK_LD_ADD = +endif + +############################################################################### +# Components +############################################################################### + +include vppinfra.am +include vppapigen.am + +if ENABLE_PERFTOOL +include perftool.am +endif + +if ENABLE_G2 +include g2.am +endif + +if ENABLE_SVM +include svm.am +endif + +if ENABLE_VLIB +include vlib.am +endif + +if ENABLE_SVM +if ENABLE_VLIB +include vlib-api.am +include vnet.am +include vpp.am +include vpp-api-test.am + +SUBDIRS += vpp-api/python plugins + +############################################################################### +# API +############################################################################### + +include suffix-rules.mk + +# Set the suffix list +apidir = $(prefix)/share/vpp/api/core + +api_DATA = \ + $(patsubst %.api,%.api.json,$(API_FILES)) + +BUILT_SOURCES += \ + $(patsubst %.api,%.api.json,$(API_FILES)) \ + $(patsubst %.api,%.api.h,$(API_FILES)) + +endif # if ENABLE_VLIB +endif # if ENABLE_SVM diff --git a/src/configure.ac b/src/configure.ac new file mode 100644 index 00000000..f8e4d94f --- /dev/null +++ b/src/configure.ac @@ -0,0 +1,195 @@ +AC_INIT([vpp], [17.04], [vpp-dev@fd.io]) +LT_INIT +AC_CONFIG_AUX_DIR([.]) +AM_INIT_AUTOMAKE([subdir-objects]) +AM_SILENT_RULES([yes]) +AC_CONFIG_FILES([Makefile plugins/Makefile vpp-api/python/Makefile]) + +AC_PROG_CC +AM_PROG_AS +AM_PROG_LIBTOOL +AC_PROG_YACC + +############################################################################### +# Macros +############################################################################### + +AC_DEFUN([ENABLE_ARG], +[ + AC_ARG_ENABLE($1, + AC_HELP_STRING(patsubst([--enable-$1],[_],[-]), $2), + [enable_$1=yes n_enable_$1=1], + [enable_$1=no n_enable_$1=0]) + AM_CONDITIONAL(m4_toupper(ENABLE_$1), test "$enable_$1" = "yes") + m4_append([list_of_enabled], [$1], [, ]) +]) + +AC_DEFUN([DISABLE_ARG], +[ + AC_ARG_ENABLE($1, + AC_HELP_STRING(patsubst([--disable-$1],[_],[-]), $2), + [enable_$1=no n_enable_$1=0], + [enable_$1=yes n_enable_$1=1]) + AM_CONDITIONAL(m4_toupper(ENABLE_$1), test "$enable_$1" = "yes") + m4_append([list_of_enabled], [$1], [, ]) +]) + +AC_DEFUN([WITH_ARG], +[ + AC_ARG_WITH($1, + AC_HELP_STRING(patsubst([--with-$1],[_],[-]), $2), + [with_$1=yes n_with_$1=1], + [with_$1=no n_with_$1=0]) + AM_CONDITIONAL(m4_toupper(WITH_$1), test "$with_$1" = "yes") + m4_append([list_of_with], [$1], [, ]) +]) + +AC_DEFUN([WITHOUT_ARG], +[ + AC_ARG_WITH($1, + AC_HELP_STRING(patsubst([--without-$1],[_],[-]), $2), + [with_$1=no n_with_$1=0], + [with_$1=yes n_with_$1=1]) + AM_CONDITIONAL(m4_toupper(WITH_$1), test "$with_$1" = "yes") + m4_append([list_of_with], [$1], [, ]) +]) + +AC_DEFUN([PLUGIN_ENABLED], +[ + AC_ARG_ENABLE($1_plugin, + AC_HELP_STRING([--disable-$1-plugin], [Do not build $1 plugin]), + [enable_$1_plugin=no], + [enable_$1_plugin=yes ]) + AM_CONDITIONAL(m4_toupper(ENABLE_$1_PLUGIN), test "$enable_$1_plugin" = "yes") + m4_append([list_of_plugins], [$1], [, ]) +]) + +AC_DEFUN([PLUGIN_DISABLED], +[ + AC_ARG_ENABLE($1_plugin, + AC_HELP_STRING([--enable-$1-plugin], [Build $1 plugin]), + [enable_$1_plugin=yes ], + [enable_$1_plugin=no]) + AM_CONDITIONAL(m4_toupper((ENABLE_$1_PLUGIN), test "$enable_$1_plugin" = "yes") + m4_append([list_of_plugins], [$1], [, ]) +]) + +AC_DEFUN([PRINT_VAL], [ AC_MSG_RESULT(AC_HELP_STRING($1,$2)) ]) + +############################################################################### +# configure arguments +############################################################################### + +# --enable-X +ENABLE_ARG(tests, [Enable unit tests]) +ENABLE_ARG(dpdk_shared, [Enable unit tests]) +ENABLE_ARG(perftool, [Enable perftool]) +ENABLE_ARG(g2, [Enable g2]) + +# --disable-X +DISABLE_ARG(vlib, [Disable vlib and dependant libs and binaries]) +DISABLE_ARG(svm, [Disable svm and dependant libs and binaries]) + +# --with-X +WITH_ARG(dpdk, [Use use DPDK]) +WITH_ARG(dpdk_crypto, [Use DPDK cryptodev]) +WITH_ARG(dpdk_mlx5_pmd, [Use DPDK with mlx5 PMD]) + +# --without-X +WITHOUT_ARG(ipsec, [Disable IPSec]) +WITHOUT_ARG(ipv6sr, [Disable IPv6 SR]) +WITHOUT_ARG(apicli, [Disable binary api CLI]) + +AC_ARG_WITH(unix, + AC_HELP_STRING([--with-unix],[Compile unix version of clib]), + [], + [case $host_os in + darwin* | linux*) with_unix=yes;; + *) with_unix=no;; + esac]) + +AM_CONDITIONAL(WITH_UNIX, test "$with_unix" = "yes") + +AC_ARG_WITH(pre-data, + AC_HELP_STRING([--with-pre-data],[Set buffer rewrite space]), + [case $with_pre_data in + 128) ;; + 256) ;; + *) with_pre_data="pre-data-not-set" ;; + esac], [with_pre_data=128]) + +############################################################################### +# Substitutions and defines +############################################################################### + +AC_SUBST(PRE_DATA_SIZE, [$with_pre_data]) +AC_SUBST(APICLI, [-DVPP_API_TEST_BUILTIN=${n_with_apicli}]) + +AC_DEFINE_UNQUOTED(DPDK, [${n_with_dpdk}]) +AC_DEFINE_UNQUOTED(DPDK_SHARED_LIB, [${n_enable_dpdk_shared}]) +AC_DEFINE_UNQUOTED(DPDK_CRYPTO, [${n_with_dpdk_crypto}]) +AC_DEFINE_UNQUOTED(IPSEC, [${n_with_ipsec}]) +AC_DEFINE_UNQUOTED(IPV6SR, [${n_with_ipv6sr}]) + +############################################################################### +# Dependency checks +############################################################################### + +AM_COND_IF([ENABLE_DPDK_SHARED], +[ + AC_CHECK_HEADERS([rte_config.h], + [], + [AC_MSG_ERROR([DPDK header files not found])],) + AC_CHECK_LIB( [dpdk], [rte_eal_init], + [], + [AC_MSG_ERROR([DPDK shared library not found])],) +]) + +AM_COND_IF([ENABLE_G2], +[ + PKG_CHECK_MODULES(g2, gtk+-2.0) +]) + +############################################################################### +# Plugins +############################################################################### + +PLUGIN_ENABLED(sixrd) +PLUGIN_ENABLED(ila) +PLUGIN_ENABLED(flowperpkt) + +############################################################################### +# Output +############################################################################### + +AC_OUTPUT + +AC_MSG_RESULT([==============================================================================]) +PRINT_VAL([version], $PACKAGE $VERSION) +PRINT_VAL([prefix], ${prefix}) +PRINT_VAL([libdir], ${libdir}) +PRINT_VAL([includedir], ${includedir}) +PRINT_VAL([CFLAGS], ${CFLAGS}) +PRINT_VAL([CPPFLAGS], ${CPPFLAGS}) +PRINT_VAL([LDFLAGS], ${LDFLAGS}) + +AC_MSG_RESULT([]) +AC_MSG_RESULT([with:]) +m4_foreach([x], m4_dquote(list_of_with), [ + AC_MSG_RESULT(AC_HELP_STRING(x, m4_join([], [${with_], x, [}]))) +]) + +AC_MSG_RESULT([]) +AC_MSG_RESULT([enabled:]) +m4_foreach([x], m4_dquote(list_of_enabled), [ + AC_MSG_RESULT(AC_HELP_STRING(x, m4_join([], [${enable_], x, [}]))) +]) + +AC_MSG_RESULT([]) +AC_MSG_RESULT([plugins:]) +m4_foreach([x], m4_dquote(list_of_plugins), [ + AC_MSG_RESULT(AC_HELP_STRING(x, m4_join([], [${enable_], x, [_plugin}]))) +]) +AC_MSG_RESULT([==============================================================================]) + + diff --git a/src/examples/vlib/dir.dox b/src/examples/vlib/dir.dox new file mode 100644 index 00000000..d3ac0ee4 --- /dev/null +++ b/src/examples/vlib/dir.dox @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2016 Cisco and/or its affiliates. + * Copyright (c) 2016 Comcast Cable Communications Management, LLC. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/* Doxygen directory documentation */ +/** +@dir +@brief Someone please fix this description +@todo This directory needs a description. +*/ diff --git a/src/examples/vlib/main_stub.c b/src/examples/vlib/main_stub.c new file mode 100644 index 00000000..4d74bd77 --- /dev/null +++ b/src/examples/vlib/main_stub.c @@ -0,0 +1,418 @@ +/* + * Copyright (c) 2015 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include +#include +#include + +int +main (int argc, char *argv[]) +{ + return vlib_unix_main (argc, argv); +} + +static clib_error_t * +main_stub_init (vlib_main_t * vm) +{ + clib_error_t *error; + + if ((error = + unix_physmem_init (vm, /* fail_if_physical_memory_not_present */ 0))) + return error; + + if ((error = vlib_call_init_function (vm, unix_cli_init))) + return error; + + return error; +} + +VLIB_INIT_FUNCTION (main_stub_init); + +#if 0 +/* Node test code. */ +typedef struct +{ + int scalar; + int vector[0]; +} my_frame_t; + +static u8 * +format_my_node_frame (u8 * s, va_list * va) +{ + vlib_frame_t *f = va_arg (*va, vlib_frame_t *); + my_frame_t *g = vlib_frame_args (f); + int i; + + s = format (s, "scalar %d, vector { ", g->scalar); + for (i = 0; i < f->n_vectors; i++) + s = format (s, "%d, ", g->vector[i]); + s = format (s, " }"); + + return s; +} + +static uword +my_func (vlib_main_t * vm, vlib_node_runtime_t * rt, vlib_frame_t * f) +{ + vlib_node_t *node; + my_frame_t *y; + u32 i, n_left = 0; + static int serial; + int verbose; + + node = vlib_get_node (vm, rt->node_index); + + verbose = 0; + + if (verbose && f) + vlib_cli_output (vm, "%v: call frame %p %U", node->name, + f, format_my_node_frame, f); + + if (rt->n_next_nodes > 0) + { + vlib_frame_t *next = vlib_get_next_frame (vm, rt, /* next index */ 0); + n_left = VLIB_FRAME_SIZE - next->n_vectors; + y = vlib_frame_args (next); + y->scalar = serial++; + } + else + y = 0; + + for (i = 0; i < 5; i++) + { + if (y) + { + ASSERT (n_left > 0); + n_left--; + y->vector[i] = y->scalar + i; + } + } + if (y) + vlib_put_next_frame (vm, rt, /* next index */ 0, n_left); + + if (verbose) + vlib_cli_output (vm, "%v: return frame %p", node->name, f); + + return i; +} + +/* *INDENT-OFF* */ +VLIB_REGISTER_NODE (my_node1,static) = { + .function = my_func, + .type = VLIB_NODE_TYPE_INPUT, + .name = "my-node1", + .scalar_size = sizeof (my_frame_t), + .vector_size = STRUCT_SIZE_OF (my_frame_t, vector[0]), + .n_next_nodes = 1, + .next_nodes = { + [0] = "my-node2", + }, +}; +/* *INDENT-ON* */ + +/* *INDENT-OFF* */ +VLIB_REGISTER_NODE (my_node2,static) = { + .function = my_func, + .name = "my-node2", + .scalar_size = sizeof (my_frame_t), + .vector_size = STRUCT_SIZE_OF (my_frame_t, vector[0]), +}; +/* *INDENT-ON* */ + +#endif + +#if 0 + +typedef enum +{ + MY_EVENT_TYPE1, + MY_EVENT_TYPE2, +} my_process_completion_type_t; + +typedef struct +{ + int a; + f64 b; +} my_process_event_data_t; + +static u8 * +format_my_process_event_data (u8 * s, va_list * va) +{ + my_process_event_data_t *d = va_arg (*va, my_process_event_data_t *); + return format (s, "{ a %d b %.6f}", d->a, d->b); +} + +static uword +my_proc (vlib_main_t * vm, vlib_node_runtime_t * rt, vlib_frame_t * f) +{ + vlib_node_t *node; + u32 i; + + node = vlib_get_node (vm, rt->node_index); + + vlib_cli_output (vm, "%v: call frame %p", node->name, f); + + for (i = 0; i < 5; i++) + { + vlib_cli_output (vm, "%v: %d", node->name, i); + vlib_process_suspend (vm, 1e0 /* secs */ ); + } + + vlib_cli_output (vm, "%v: return frame %p", node->name, f); + + if (0) + { + uword n_events_seen, type, *data = 0; + + for (n_events_seen = 0; n_events_seen < 2;) + { + vlib_process_wait_for_event (vm); + type = vlib_process_get_events (vm, &data); + n_events_seen += vec_len (data); + vlib_cli_output (vm, "%U %v: completion #%d type %d data 0x%wx", + format_time_interval, "h:m:s:u", + vlib_time_now (vm), node->name, i, type, data[0]); + _vec_len (data) = 0; + } + + vec_free (data); + } + else + { + uword n_events_seen, i, type; + my_process_event_data_t *data; + for (n_events_seen = 0; n_events_seen < 2;) + { + vlib_process_wait_for_event (vm); + data = vlib_process_get_event_data (vm, &type); + vec_foreach_index (i, data) + { + vlib_cli_output (vm, "%U event type %d data %U", + format_time_interval, "h:m:s:u", + vlib_time_now (vm), type, + format_my_process_event_data, data); + } + n_events_seen += vec_len (data); + vlib_process_put_event_data (vm, data); + } + } + + return i; +} + +/* *INDENT-OFF* */ +VLIB_REGISTER_NODE (my_proc_node,static) = { + .function = my_proc, + .type = VLIB_NODE_TYPE_PROCESS, + .name = "my-proc", +}; +/* *INDENT-ON* */ + +static uword +my_proc_input (vlib_main_t * vm, vlib_node_runtime_t * rt, vlib_frame_t * f) +{ + static int i; + + if (i++ < 2) + { + if (0) + vlib_process_signal_event (vm, my_proc_node.index, + i == 1 ? MY_EVENT_TYPE1 : MY_EVENT_TYPE2, + 0x12340000 + i); + else + { + my_process_event_data_t *d; + f64 dt = 5; + d = vlib_process_signal_event_at_time (vm, + i * dt, + my_proc_node.index, + i == + 1 ? MY_EVENT_TYPE1 : + MY_EVENT_TYPE2, + 1 /* elts */ , + sizeof (d[0])); + d->a = i; + d->b = vlib_time_now (vm); + } + } + else + vlib_node_set_state (vm, rt->node_index, VLIB_NODE_STATE_DISABLED); + + return 0; +} + +/* *INDENT-OFF* */ +VLIB_REGISTER_NODE (my_proc_input_node,static) = { + .function = my_proc_input, + .type = VLIB_NODE_TYPE_INPUT, + .name = "my-proc-input", +}; +/* *INDENT-ON* */ + +static uword +_unformat_farith (unformat_input_t * i, va_list * args) +{ + u32 prec = va_arg (*args, u32); + f64 *result = va_arg (*args, f64 *); + f64 tmp[2]; + + /* Binary operations in from lowest to highest precedence. */ + char *binops[] = { + "+%U", "-%U", "/%U", "*%U", "^%U", + }; + + if (prec <= ARRAY_LEN (binops) - 1 + && unformat_user (i, _unformat_farith, prec + 1, &tmp[0])) + { + int p; + for (p = prec; p < ARRAY_LEN (binops); p++) + { + if (unformat (i, binops[p], _unformat_farith, prec + 0, &tmp[1])) + { + switch (binops[p][0]) + { + case '+': + result[0] = tmp[0] + tmp[1]; + break; + case '-': + result[0] = tmp[0] - tmp[1]; + break; + case '/': + result[0] = tmp[0] / tmp[1]; + break; + case '*': + result[0] = tmp[0] * tmp[1]; + break; + case '^': + result[0] = pow (tmp[0], tmp[1]); + break; + default: + abort (); + } + return 1; + } + } + result[0] = tmp[0]; + return 1; + } + + else if (unformat (i, "-%U", _unformat_farith, prec + 0, &tmp[0])) + { + result[0] = -tmp[0]; + return 1; + } + + else if (unformat (i, "(%U)", _unformat_farith, 0, &tmp[0])) + { + result[0] = tmp[0]; + return 1; + } + + else if (unformat (i, "%f", result)) + return 1; + + else + return 0; +} + +static uword +unformat_farith (unformat_input_t * i, va_list * args) +{ + CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *); + f64 *result = va_arg (*args, f64 *); + return unformat_user (i, _unformat_farith, 0, result); +} + +static uword +unformat_integer (unformat_input_t * i, va_list * args) +{ + CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *); + u32 *data = va_arg (*args, u32 *); + return unformat (i, "%d", data); +} + +static VLIB_CLI_PARSE_RULE (my_parse_rule1) = +{ +.name = "decimal_integer",.short_help = + "a decimal integer",.unformat_function = unformat_integer,.data_size = + sizeof (u32),}; + +static VLIB_CLI_PARSE_RULE (my_parse_rule2) = +{ +.name = "float_expression",.short_help = + "floating point expression",.unformat_function = + unformat_farith,.data_size = sizeof (f64),}; + +static clib_error_t * +bar_command (vlib_main_t * vm, + unformat_input_t * input, vlib_cli_command_t * cmd) +{ + switch (cmd->function_arg) + { + case 2: + { + u32 *d, *e; + d = vlib_cli_get_parse_rule_result (vm, 0); + e = vlib_cli_get_parse_rule_result (vm, 1); + vlib_cli_output (vm, "bar2 %d %d", d[0], e[0]); + break; + } + + case 1: + { + u32 *d = vlib_cli_get_parse_rule_result (vm, 0); + vlib_cli_output (vm, "bar1 %d", d[0]); + break; + } + + case 3: + { + f64 *d = vlib_cli_get_parse_rule_result (vm, 0); + vlib_cli_output (vm, "expr %.6f", d[0]); + } + } + + return 0; +} + +/* *INDENT-OFF* */ +VLIB_CLI_COMMAND (bar_command2, static) = { + .path = "bar %decimal_integer", + .short_help = "bar1 command", + .function = bar_command, + .function_arg = 1, +}; +VLIB_CLI_COMMAND (bar_command1, static) = { + .path = "bar %decimal_integer %decimal_integer", + .short_help = "bar2 command", + .function = bar_command, + .function_arg = 2, +}; +VLIB_CLI_COMMAND (bar_command3, static) = { + .path = "zap %float_expression", + .short_help = "bar3 command", + .function = bar_command, + .function_arg = 3, +}; +/* *INDENT-ON* */ + +#endif + +/* + * fd.io coding-style-patch-verification: ON + * + * Local Variables: + * eval: (c-set-style "gnu") + * End: + */ diff --git a/src/examples/vlib/mc_test.c b/src/examples/vlib/mc_test.c new file mode 100644 index 00000000..e84a713c --- /dev/null +++ b/src/examples/vlib/mc_test.c @@ -0,0 +1,384 @@ +/* + * mc_test.c: test program for vlib mc + * + * Copyright (c) 2010 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include + +typedef struct +{ + u32 min_n_msg_bytes; + u32 max_n_msg_bytes; + u32 tx_serial; + u32 rx_serial; + u32 seed; + u32 verbose; + u32 validate; + u32 window_size; + f64 min_delay, max_delay; + f64 n_packets_to_send; +} mc_test_main_t; + +always_inline u32 +choose_msg_size (mc_test_main_t * tm) +{ + u32 r = tm->min_n_msg_bytes; + if (tm->max_n_msg_bytes > tm->min_n_msg_bytes) + r += + random_u32 (&tm->seed) % (1 + tm->max_n_msg_bytes - + tm->min_n_msg_bytes); + return r; +} + +static mc_test_main_t mc_test_main; + +static void +serialize_test_msg (serialize_main_t * m, va_list * va) +{ + mc_test_main_t *tm = &mc_test_main; + u32 n_bytes = choose_msg_size (tm); + u8 *msg; + int i; + serialize_integer (m, n_bytes, sizeof (n_bytes)); + msg = serialize_get (m, n_bytes); + for (i = 0; i < n_bytes; i++) + msg[i] = i + tm->tx_serial; + tm->tx_serial += n_bytes; +} + +static void +unserialize_test_msg (serialize_main_t * m, va_list * va) +{ + mc_test_main_t *tm = &mc_test_main; + u32 i, n_bytes, dump_msg = tm->verbose; + u8 *p; + unserialize_integer (m, &n_bytes, sizeof (n_bytes)); + p = unserialize_get (m, n_bytes); + if (tm->validate) + for (i = 0; i < n_bytes; i++) + if (p[i] != ((tm->rx_serial + i) & 0xff)) + { + clib_warning ("corrupt msg at offset %d", i); + dump_msg = 1; + break; + } + if (dump_msg) + clib_warning ("got %d bytes, %U", n_bytes, format_hex_bytes, p, n_bytes); + tm->rx_serial += n_bytes; +} + +MC_SERIALIZE_MSG (test_msg, static) = +{ +.name = "test_msg",.serialize = serialize_test_msg,.unserialize = + unserialize_test_msg,}; + +#define SERIALIZE 1 + +#define EVENT_JOIN_STREAM 10 +#define EVENT_SEND_DATA 11 + +static void +test_rx_callback (mc_main_t * mcm, + mc_stream_t * stream, + mc_peer_id_t peer_id, u32 buffer_index) +{ + if (SERIALIZE) + { + return mc_unserialize (mcm, stream, buffer_index); + } + else + { +#if DEBUG > 1 + vlib_main_t *vm = mcm->vlib_main; + vlib_buffer_t *b = vlib_get_buffer (vm, buffer_index); + u8 *dp = vlib_buffer_get_current (b); + + fformat (stdout, "RX from %U %U\n", + stream->transport->format_peer_id, peer_id, + format_hex_bytes, dp, tm->n_msg_bytes); + +#endif + } +} + +static u8 * +test_snapshot_callback (mc_main_t * mcm, + u8 * data_vector, u32 last_global_sequence_processed) +{ + if (SERIALIZE) + { + serialize_main_t m; + + /* Append serialized data to data vector. */ + serialize_open_vector (&m, data_vector); + m.stream.current_buffer_index = vec_len (data_vector); + + return serialize_close_vector (&m); + } + else + return format (data_vector, + "snapshot, last global seq 0x%x", + last_global_sequence_processed); +} + +static void +test_handle_snapshot_callback (mc_main_t * mcm, u8 * data, u32 n_data_bytes) +{ + if (SERIALIZE) + { + serialize_main_t s; + unserialize_open_data (&s, data, n_data_bytes); + } + else + clib_warning ("snapshot `%*s'", n_data_bytes, data); +} + +static mc_socket_main_t mc_socket_main; + +static uword +mc_test_process (vlib_main_t * vm, + vlib_node_runtime_t * node, vlib_frame_t * f) +{ + mc_test_main_t *tm = &mc_test_main; + mc_socket_main_t *msm = &mc_socket_main; + mc_main_t *mcm = &msm->mc_main; + uword event_type, *event_data = 0; + u32 data_serial = 0, stream_index; + f64 delay; + mc_stream_config_t config; + clib_error_t *error; + int i; + char *intfcs[] = { "eth1", "eth0", "ce" }; + + memset (&config, 0, sizeof (config)); + config.name = "test"; + config.window_size = tm->window_size; + config.rx_buffer = test_rx_callback; + config.catchup_snapshot = test_snapshot_callback; + config.catchup = test_handle_snapshot_callback; + stream_index = ~0; + + msm->multicast_tx_ip4_address_host_byte_order = 0xefff0100; + msm->base_multicast_udp_port_host_byte_order = 0xffab; + + error = mc_socket_main_init (&mc_socket_main, intfcs, ARRAY_LEN (intfcs)); + if (error) + { + clib_error_report (error); + exit (1); + } + + mcm->we_can_be_relay_master = 1; + + while (1) + { + vlib_process_wait_for_event (vm); + event_type = vlib_process_get_events (vm, &event_data); + + switch (event_type) + { + case EVENT_JOIN_STREAM: + stream_index = mc_stream_join (mcm, &config); + break; + + case EVENT_SEND_DATA: + { + f64 times[2]; + + if (stream_index == ~0) + stream_index = mc_stream_join (mcm, &config); + + times[0] = vlib_time_now (vm); + for (i = 0; i < event_data[0]; i++) + { + u32 bi; + if (SERIALIZE) + { + mc_serialize_stream (mcm, stream_index, &test_msg, + data_serial); + } + else + { + u8 *mp; + mp = mc_get_vlib_buffer (vm, sizeof (mp[0]), &bi); + mp[0] = data_serial; + mc_stream_send (mcm, stream_index, bi); + } + if (tm->min_delay > 0) + { + delay = + tm->min_delay + + random_f64 (&tm->seed) * (tm->max_delay - + tm->min_delay); + vlib_process_suspend (vm, delay); + } + data_serial++; + } + times[1] = vlib_time_now (vm); + clib_warning ("done sending %d; %.4e per sec", + event_data[0], + (f64) event_data[0] / (times[1] - times[0])); + break; + } + + default: + clib_warning ("bug"); + break; + } + + if (event_data) + _vec_len (event_data) = 0; + } +} + +/* *INDENT-OFF* */ +VLIB_REGISTER_NODE (mc_test_process_node, static) = +{ +.function = mc_test_process,.type = VLIB_NODE_TYPE_PROCESS,.name = + "mc-test-process",}; +/* *INDENT-ON* */ + +static clib_error_t * +mc_test_command (vlib_main_t * vm, + unformat_input_t * input, vlib_cli_command_t * cmd) +{ + f64 npkts = 10; + + if (unformat (input, "join")) + { + vlib_cli_output (vm, "Join stream...\n"); + vlib_process_signal_event (vm, mc_test_process_node.index, + EVENT_JOIN_STREAM, 0); + return 0; + } + else if (unformat (input, "send %f", &npkts) || unformat (input, "send")) + { + vlib_process_signal_event (vm, mc_test_process_node.index, + EVENT_SEND_DATA, (uword) npkts); + vlib_cli_output (vm, "Send %.0f pkts...\n", npkts); + + return 0; + } + else + return unformat_parse_error (input); +} + +/* *INDENT-OFF* */ +VLIB_CLI_COMMAND (test_mc_command, static) = +{ +.path = "test mc",.short_help = "Test mc command",.function = + mc_test_command,}; +/* *INDENT-ON* */ + +static clib_error_t * +mc_show_command (vlib_main_t * vm, + unformat_input_t * input, vlib_cli_command_t * cmd) +{ + mc_main_t *mcm = &mc_socket_main.mc_main; + vlib_cli_output (vm, "%U", format_mc_main, mcm); + return 0; +} + +/* *INDENT-OFF* */ +VLIB_CLI_COMMAND (show_mc_command, static) = +{ +.path = "show mc",.short_help = "Show mc command",.function = + mc_show_command,}; +/* *INDENT-ON* */ + +static clib_error_t * +mc_clear_command (vlib_main_t * vm, + unformat_input_t * input, vlib_cli_command_t * cmd) +{ + mc_main_t *mcm = &mc_socket_main.mc_main; + mc_clear_stream_stats (mcm); + return 0; +} + +/* *INDENT-OFF* */ +VLIB_CLI_COMMAND (clear_mc_command, static) = +{ +.path = "clear mc",.short_help = "Clear mc command",.function = + mc_clear_command,}; +/* *INDENT-ON* */ + +static clib_error_t * +mc_config (vlib_main_t * vm, unformat_input_t * input) +{ + mc_test_main_t *tm = &mc_test_main; + mc_socket_main_t *msm = &mc_socket_main; + clib_error_t *error = 0; + + tm->min_n_msg_bytes = 4; + tm->max_n_msg_bytes = 4; + tm->window_size = 8; + tm->seed = getpid (); + tm->verbose = 0; + tm->validate = 1; + tm->min_delay = 10e-6; + tm->max_delay = 10e-3; + tm->n_packets_to_send = 0; + while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) + { + if (unformat (input, "interface %s", &msm->multicast_interface_name)) + ; + + else if (unformat (input, "n-bytes %d", &tm->max_n_msg_bytes)) + tm->min_n_msg_bytes = tm->max_n_msg_bytes; + else if (unformat (input, "max-n-bytes %d", &tm->max_n_msg_bytes)) + ; + else if (unformat (input, "min-n-bytes %d", &tm->min_n_msg_bytes)) + ; + else if (unformat (input, "seed %d", &tm->seed)) + ; + else if (unformat (input, "window %d", &tm->window_size)) + ; + else if (unformat (input, "verbose")) + tm->verbose = 1; + else if (unformat (input, "no-validate")) + tm->validate = 0; + else if (unformat (input, "min-delay %f", &tm->min_delay)) + ; + else if (unformat (input, "max-delay %f", &tm->max_delay)) + ; + else if (unformat (input, "no-delay")) + tm->min_delay = tm->max_delay = 0; + else if (unformat (input, "n-packets %f", &tm->n_packets_to_send)) + ; + + else + return clib_error_return (0, "unknown input `%U'", + format_unformat_error, input); + } + + if (tm->n_packets_to_send > 0) + vlib_process_signal_event (vm, mc_test_process_node.index, + EVENT_SEND_DATA, + (uword) tm->n_packets_to_send); + + return error; +} + +VLIB_CONFIG_FUNCTION (mc_config, "mc"); + +/* + * fd.io coding-style-patch-verification: ON + * + * Local Variables: + * eval: (c-set-style "gnu") + * End: + */ diff --git a/src/examples/vlib/plex_test.c b/src/examples/vlib/plex_test.c new file mode 100644 index 00000000..ce0c8ef1 --- /dev/null +++ b/src/examples/vlib/plex_test.c @@ -0,0 +1,527 @@ +/* + * Copyright (c) 2015 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include +#include + +static u8 * +format_value_v4_address (u8 * s, va_list * args) +{ + vlib_parse_value_t *v = va_arg (*args, vlib_parse_value_t *); + u32 a = v->value.as_uword; + + s = format (s, "%d.%d.%d.%d", + (a >> 24) & 0xFF, + (a >> 16) & 0xFF, (a >> 8) & 0xFF, (a >> 0) & 0xFF); + + return s; +} + +static vlib_parse_match_t +v4_address_match (vlib_parse_main_t * pm, vlib_parse_type_t * type, + vlib_lex_token_t * t, vlib_parse_value_t * valuep) +{ + u32 digit; + u32 value = 0; + int i; + + if (vec_len (pm->tokens) - (t - pm->tokens) < 7) + return VLIB_PARSE_MATCH_FAIL; + + /* NUMBER DOT NUMBER DOT NUMBER DOT NUMBER */ + + for (i = 0; i < 7; i++) + { + if ((i & 1) == 0) + { + if (t[i].token != VLIB_LEX_number) + return VLIB_PARSE_MATCH_FAIL; + if (t[i].value.as_uword > 0xff) + return VLIB_PARSE_MATCH_FAIL; + digit = t[i].value.as_uword; + value = (value << 8) | digit; + } + else + { + if (t[i].token != VLIB_LEX_dot) + return VLIB_PARSE_MATCH_FAIL; + } + } + /* note: caller advances by 1 */ + pm->current_token_index += 6; + valuep->value.as_uword = value; + return VLIB_PARSE_MATCH_VALUE; +} + +PARSE_TYPE_INIT (v4_address, v4_address_match, 0, format_value_v4_address) + static u8 *format_value_v4_address_and_mask (u8 * s, va_list * args) +{ + vlib_parse_value_t *v = va_arg (*args, vlib_parse_value_t *); + u32 *a = v->value.as_pointer; + + s = format (s, "%d.%d.%d.%d", + (a[0] >> 24) & 0xFF, + (a[0] >> 16) & 0xFF, (a[0] >> 8) & 0xFF, (a[0] >> 0) & 0xFF); + s = format (s, "/%d", a[1]); + + return s; +} + +static vlib_parse_match_t +v4_address_and_mask_match (vlib_parse_main_t * pm, vlib_parse_type_t * type, + vlib_lex_token_t * t, vlib_parse_value_t * valuep) +{ + u32 digit; + u32 address = 0; + u32 *rv = 0; + int i; + + if (vec_len (pm->tokens) - (t - pm->tokens) < 9) + return VLIB_PARSE_MATCH_FAIL; + + /* NUMBER DOT NUMBER DOT NUMBER DOT NUMBER */ + + for (i = 0; i < 7; i++) + { + if ((i & 1) == 0) + { + if (t[i].token != VLIB_LEX_number) + return VLIB_PARSE_MATCH_FAIL; + if (t[i].value.as_uword > 0xff) + return VLIB_PARSE_MATCH_FAIL; + digit = t[i].value.as_uword; + address = (address << 8) | digit; + } + else + { + if (t[i].token != VLIB_LEX_dot) + return VLIB_PARSE_MATCH_FAIL; + } + } + + if (t[7].token != VLIB_LEX_slash || t[8].token != VLIB_LEX_number) + return VLIB_PARSE_MATCH_FAIL; + + vec_add1 (rv, address); + vec_add1 (rv, t[8].value.as_uword); + + /* note: caller advances by 1 */ + pm->current_token_index += 8; + valuep->value.as_pointer = rv; + return VLIB_PARSE_MATCH_VALUE; +} + +void +v4_address_and_mask_cleanup (vlib_parse_value_t * valuep) +{ + u32 *trash = valuep->value.as_pointer; + vec_free (trash); +} + +PARSE_TYPE_INIT (v4_address_and_mask, v4_address_and_mask_match, + v4_address_and_mask_cleanup, + format_value_v4_address_and_mask) + vlib_lex_main_t vlib_lex_main; + + + + vlib_parse_match_t eval_factor0 (vlib_parse_main_t * pm, + vlib_parse_item_t * item, + vlib_parse_value_t * value) +{ + clib_warning ("%U", format_vlib_parse_value, pm); + return VLIB_PARSE_MATCH_RULE; +} + +vlib_parse_match_t +eval_factor1 (vlib_parse_main_t * pm, + vlib_parse_item_t * item, vlib_parse_value_t * value) +{ + clib_warning ("%U", format_vlib_parse_value, pm); + return VLIB_PARSE_MATCH_RULE; +} + +vlib_parse_match_t +eval_factor2 (vlib_parse_main_t * pm, + vlib_parse_item_t * item, vlib_parse_value_t * value) +{ + word a; + int index = vec_len (pm->parse_value) - 1; + + a = pm->parse_value[index].value.as_word; + + pm->parse_value[index].value.as_word = -a; + return VLIB_PARSE_MATCH_RULE; +} + +vlib_parse_match_t +eval_term0 (vlib_parse_main_t * pm, + vlib_parse_item_t * item, vlib_parse_value_t * value) +{ + clib_warning ("%U", format_vlib_parse_value, pm); + return VLIB_PARSE_MATCH_RULE; +} + +vlib_parse_match_t +eval_term1 (vlib_parse_main_t * pm, + vlib_parse_item_t * item, vlib_parse_value_t * value) +{ + uword a, b; + int index = vec_len (pm->parse_value) - 2; + + a = pm->parse_value[index].value.as_uword; + b = pm->parse_value[index + 1].value.as_uword; + + pm->parse_value[index].value.as_uword = a * b; + _vec_len (pm->parse_value) -= 1; + clib_warning ("%U", format_vlib_parse_value, pm); + + return VLIB_PARSE_MATCH_RULE; +} + +vlib_parse_match_t +eval_term2 (vlib_parse_main_t * pm, + vlib_parse_item_t * item, vlib_parse_value_t * value) +{ + uword a, b; + int index = vec_len (pm->parse_value) - 2; + + a = pm->parse_value[index].value.as_uword; + b = pm->parse_value[index + 1].value.as_uword; + + pm->parse_value[index].value.as_uword = a / b; + _vec_len (pm->parse_value) -= 1; + clib_warning ("%U", format_vlib_parse_value, pm); + + return VLIB_PARSE_MATCH_RULE; +} + +vlib_parse_match_t +eval_exp0 (vlib_parse_main_t * pm, + vlib_parse_item_t * item, vlib_parse_value_t * value) +{ + return VLIB_PARSE_MATCH_RULE; +} + +vlib_parse_match_t +eval_exp1 (vlib_parse_main_t * pm, + vlib_parse_item_t * item, vlib_parse_value_t * value) +{ + uword a, b; + int index = vec_len (pm->parse_value) - 2; + + a = pm->parse_value[index].value.as_uword; + b = pm->parse_value[index + 1].value.as_uword; + + pm->parse_value[index].value.as_uword = a + b; + _vec_len (pm->parse_value) -= 1; + clib_warning ("%U", format_vlib_parse_value, pm); + + return VLIB_PARSE_MATCH_RULE; +} + +vlib_parse_match_t +eval_exp2 (vlib_parse_main_t * pm, + vlib_parse_item_t * item, vlib_parse_value_t * value) +{ + uword a, b; + int index = vec_len (pm->parse_value) - 2; + + a = pm->parse_value[index].value.as_uword; + b = pm->parse_value[index + 1].value.as_uword; + + pm->parse_value[index].value.as_uword = a - b; + _vec_len (pm->parse_value) -= 1; + clib_warning ("%U", format_vlib_parse_value, pm); + + return VLIB_PARSE_MATCH_RULE; +} + +vlib_parse_match_t +eval_result (vlib_parse_main_t * pm, + vlib_parse_item_t * item, vlib_parse_value_t * value) +{ + clib_warning ("%U", format_vlib_parse_value, pm); + return VLIB_PARSE_MATCH_DONE; +} + +vlib_parse_match_t +noop_match_rule (vlib_parse_main_t * pm, + vlib_parse_item_t * item, vlib_parse_value_t * value) +{ + clib_warning ("%U", format_vlib_parse_value, pm); + return VLIB_PARSE_MATCH_RULE; +} + +#if 0 +PARSE_INIT (t1, "moo", eval0); +PARSE_INIT (t2, "moo cow mumble", eval1); +PARSE_INIT (t3, "moo cow", eval2); +PARSE_INIT (t4, "moo cow mumble grunch", eval3); +#endif + +#if 0 +PARSE_INIT (r1, "eval ", eval_result); + +PARSE_INIT (r2, " = ", eval_exp0); +PARSE_INIT (r3, " = ", eval_exp1); +PARSE_INIT (r4, " = ", eval_exp2); +PARSE_INIT (r5, " = ", noop_match_rule); +PARSE_TYPE_INIT (exp, rule_match, 0, 0); +PARSE_TYPE_INIT (exp2, rule_match, 0, 0); + +PARSE_INIT (r6, " = ", eval_term0); +PARSE_INIT (r7, " = ", eval_term1); +PARSE_INIT (r8, " = ", eval_term2); +PARSE_INIT (r9, " = ", noop_match_rule); +PARSE_TYPE_INIT (term, rule_match, 0, 0); +PARSE_TYPE_INIT (term2, rule_match, 0, 0); + +PARSE_INIT (r11, " = ", eval_factor1); +PARSE_INIT (r10, " = ", eval_factor0); +PARSE_INIT (r12, " = ", eval_factor2); + +PARSE_TYPE_INIT (factor, rule_match, 0, 0); +#endif + +PARSE_INIT (r1, "eval ", eval_result); + +#if 1 +PARSE_INIT (r2, " = ", eval_exp0); +PARSE_INIT (r3, " = ", eval_exp1); +PARSE_INIT (r4, " = ", eval_exp2); +PARSE_INIT (r5, " = ", noop_match_rule); +PARSE_TYPE_INIT (exp, rule_match, 0, 0); +PARSE_TYPE_INIT (exp2, rule_match, 0, 0); + +PARSE_INIT (r6, " = ", eval_term0); +PARSE_INIT (r7, " = ", eval_term1); +PARSE_INIT (r8, " = ", eval_term2); +PARSE_INIT (r9, " = ", noop_match_rule); +PARSE_TYPE_INIT (term, rule_match, 0, 0); +PARSE_TYPE_INIT (term2, rule_match, 0, 0); + +PARSE_INIT (r11, " = ", eval_factor1); +PARSE_INIT (r10, " = ", eval_factor0); +PARSE_INIT (r12, " = ", eval_factor2); + +PARSE_TYPE_INIT (factor, rule_match, 0, 0); +#endif + +#if 0 +PARSE_TYPE_INIT (exp, rule_match, 0, 0); +PARSE_INIT (r6, " = a b", eval_term0); +PARSE_INIT (r7, " = c d", eval_term1); +PARSE_INIT (r9, " = ", noop_match_rule); +#endif + +#if 0 +#define foreach_rule_evaluator \ +_(0) \ +_(1) \ +_(2) \ +_(3) + +#define _(n) \ +vlib_parse_match_t eval##n (vlib_parse_main_t *pm, \ + vlib_parse_item_t *item, \ + vlib_parse_value_t *value) \ +{ \ + clib_warning ("%U", format_vlib_parse_value, pm); \ + return VLIB_PARSE_MATCH_DONE; \ +} +foreach_rule_evaluator +#undef _ +PARSE_INIT (r1, "eval ", eval_result); + +PARSE_INIT (r2, " = cow", eval0); +PARSE_INIT (r4, " = ", eval1); +PARSE_TYPE_INIT (moo, rule_match, 0, 0); +#endif + + +clib_error_t * +test_init (vlib_main_t * vm) +{ + clib_error_t *error; + + if ((error = vlib_call_init_function (vm, parse_init))) + return error; + + return 0; +} + +VLIB_INIT_FUNCTION (test_init); + +clib_error_t * +vlib_stdlex_init (vlib_main_t * vm) +{ + vlib_lex_main_t *lm = &vlib_lex_main; + u16 top_index; + u16 slash_index, slash_star_index, slash_slash_index, slash_star_star_index; + u16 slash_token; + u16 word_index; + u16 zero_index, octal_index, decimal_index, hex_index, binary_index; + + top_index = vlib_lex_add_table ("top"); + +#define foreach_top_level_single_character_token \ + _('(', lpar) \ + _(')', rpar) \ + _(';', semi) \ + _('[', lbrack) \ + _(']', rbrack) \ + _('{', lcurly) \ + _('}', rcurly) \ + _('+', plus) \ + _('-', minus) \ + _('*', star) \ + _('%', percent) \ + _('@', atsign) \ + _(',', comma) \ + _('.', dot) \ + _('?', qmark) + +#define _(c,t) \ + vlib_lex_set_action_range(top_index,c,c,VLIB_LEX_RETURN,vlib_lex_add_token(lm, #t), top_index); + foreach_top_level_single_character_token; +#undef _ + + /* Numbers */ + zero_index = vlib_lex_add_table ("zero"); + octal_index = vlib_lex_add_table ("octal"); + decimal_index = vlib_lex_add_table ("decimal"); + hex_index = vlib_lex_add_table ("hex"); + binary_index = vlib_lex_add_table ("binary"); + + /* Support 0x 0b 0t and 0123 [octal] */ + vlib_lex_set_action_range (top_index, '0', '0', VLIB_LEX_START_NUMBER, 10, + zero_index); + vlib_lex_set_action_range (top_index, '1', '9', VLIB_LEX_START_NUMBER, 10, + decimal_index); + + vlib_lex_set_action_range (zero_index, 0, 0x7F, VLIB_LEX_RETURN_AND_RESCAN, + VLIB_LEX_number, top_index); + + vlib_lex_set_action_range (zero_index, 'x', 'x', VLIB_LEX_IGNORE, ~0, + hex_index); + vlib_lex_set_action_range (zero_index, 'b', 'b', VLIB_LEX_IGNORE, ~0, + binary_index); + vlib_lex_set_action_range (zero_index, 't', 't', VLIB_LEX_IGNORE, ~0, + decimal_index); + vlib_lex_set_action_range (zero_index, '0', '7', VLIB_LEX_START_NUMBER, 8, + octal_index); + + /* Octal */ + vlib_lex_set_action_range (octal_index, 0, 0x7f, VLIB_LEX_RETURN_AND_RESCAN, + VLIB_LEX_number, top_index); + vlib_lex_set_action_range (octal_index, '0', '7', VLIB_LEX_ADD_TO_NUMBER, 8, + octal_index); + + /* Decimal */ + vlib_lex_set_action_range (decimal_index, 0, 0x7f, + VLIB_LEX_RETURN_AND_RESCAN, VLIB_LEX_number, + top_index); + vlib_lex_set_action_range (decimal_index, '0', '9', VLIB_LEX_ADD_TO_NUMBER, + 10, decimal_index); + + /* Hex */ + vlib_lex_set_action_range (hex_index, 0, 0x7f, VLIB_LEX_RETURN_AND_RESCAN, + VLIB_LEX_number, top_index); + vlib_lex_set_action_range (hex_index, '0', '9', VLIB_LEX_ADD_TO_NUMBER, 16, + hex_index); + vlib_lex_set_action_range (hex_index, 'a', 'f', VLIB_LEX_ADD_TO_NUMBER, 16, + hex_index); + vlib_lex_set_action_range (hex_index, 'A', 'F', VLIB_LEX_ADD_TO_NUMBER, 16, + hex_index); + + /* Binary */ + vlib_lex_set_action_range (binary_index, 0, 0x7f, + VLIB_LEX_RETURN_AND_RESCAN, VLIB_LEX_number, + top_index); + vlib_lex_set_action_range (binary_index, '0', '1', VLIB_LEX_ADD_TO_NUMBER, + 2, binary_index); + + /* c/c++ comment syntax is the worst... */ + + slash_index = vlib_lex_add_table ("slash"); + slash_star_index = vlib_lex_add_table ("slash_star"); + slash_star_star_index = vlib_lex_add_table ("slash_star_star"); + slash_slash_index = vlib_lex_add_table ("slash_slash"); + slash_token = vlib_lex_add_token (lm, "slash"); + + /* Top level: see a slash, ignore, go to slash table */ + vlib_lex_set_action_range (top_index, '/', '/', VLIB_LEX_IGNORE, ~0, + slash_index); + + /* default for slash table: return SLASH, go to top table */ + vlib_lex_set_action_range (slash_index, 1, 0x7F, VLIB_LEX_RETURN_AND_RESCAN, + slash_token, top_index); + /* see slash-slash, go to s-s table */ + vlib_lex_set_action_range (slash_index, '/', '/', VLIB_LEX_IGNORE, ~0, + slash_slash_index); + /* see slash-star, go to s-* table */ + vlib_lex_set_action_range (slash_index, '*', '*', VLIB_LEX_IGNORE, ~0, + slash_star_index); + + /* EOL in s-s table, ignore, go to top table */ + vlib_lex_set_action_range (slash_slash_index, '\n', '\n', VLIB_LEX_IGNORE, + ~0, top_index); + + /* slash-star blah blah star */ + vlib_lex_set_action_range (slash_star_index, '*', '*', VLIB_LEX_IGNORE, ~0, + slash_star_star_index); + + /* slash star blah blah star slash */ + vlib_lex_set_action_range (slash_star_star_index, '/', '/', VLIB_LEX_IGNORE, + ~0, top_index); + + /* LT, =, GT */ + vlib_lex_set_action_range (top_index, '<', '<', VLIB_LEX_RETURN, + VLIB_LEX_lt, top_index); + vlib_lex_set_action_range (top_index, '=', '=', VLIB_LEX_RETURN, + VLIB_LEX_equals, top_index); + vlib_lex_set_action_range (top_index, '>', '>', VLIB_LEX_RETURN, + VLIB_LEX_gt, top_index); + + /* words, key and otherwise */ + word_index = vlib_lex_add_table ("word"); + + vlib_lex_set_action_range (top_index, 'a', 'z', VLIB_LEX_ADD_TO_TOKEN, ~0, + word_index); + vlib_lex_set_action_range (top_index, 'A', 'Z', VLIB_LEX_ADD_TO_TOKEN, ~0, + word_index); + + vlib_lex_set_action_range (word_index, 0, 0x7f, VLIB_LEX_KEYWORD_CHECK, ~0, + top_index); + + vlib_lex_set_action_range (word_index, 'a', 'z', VLIB_LEX_ADD_TO_TOKEN, ~0, + word_index); + vlib_lex_set_action_range (word_index, 'A', 'Z', VLIB_LEX_ADD_TO_TOKEN, ~0, + word_index); + vlib_lex_set_action_range (word_index, '_', '_', VLIB_LEX_ADD_TO_TOKEN, ~0, + word_index); + vlib_lex_set_action_range (word_index, '0', '9', VLIB_LEX_ADD_TO_TOKEN, ~0, + word_index); + + return 0; +} + +/* + * fd.io coding-style-patch-verification: ON + * + * Local Variables: + * eval: (c-set-style "gnu") + * End: + */ diff --git a/src/g2.am b/src/g2.am new file mode 100644 index 00000000..e7965733 --- /dev/null +++ b/src/g2.am @@ -0,0 +1,32 @@ +# Copyright (c) 2016 Cisco and/or its affiliates. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +bin_PROGRAMS += g2 + +g2_SOURCES = \ + tools/g2/clib.c \ + tools/g2/cpel.c \ + tools/g2/cpel.h \ + tools/g2/events.c \ + tools/g2/g2.h \ + tools/g2/main.c \ + tools/g2/menu1.c \ + tools/g2/pointsel.c \ + tools/g2/props.c \ + tools/g2/props.h \ + tools/g2/g2version.c \ + tools/g2/view1.c + +g2_LDADD = $(g2_LIBS) libvppinfra.la -lpthread -lm + +# vi:syntax=automake diff --git a/src/perftool.am b/src/perftool.am new file mode 100644 index 00000000..09f1681a --- /dev/null +++ b/src/perftool.am @@ -0,0 +1,41 @@ +# Copyright (c) 2016 Cisco and/or its affiliates. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +bin_PROGRAMS += c2cpel cpelatency cpeldump cpelinreg cpelstate + +lib_LTLIBRARIES += libcperf.la + +libcperf_la_SOURCES = \ + tools/perftool/delsvec.c \ + tools/perftool/linreg.c \ + tools/perftool/props.c \ + tools/perftool/cpel_util.c + +PERFTOOL_LIBS = libcperf.la libvppinfra.la -lm + +c2cpel_SOURCES = tools/perftool/c2cpel.c +c2cpel_LDADD = $(PERFTOOL_LIBS) + +cpelatency_SOURCES = tools/perftool/cpelatency.c +cpelatency_LDADD = $(PERFTOOL_LIBS) + +cpeldump_SOURCES = tools/perftool/cpeldump.c +cpeldump_LDADD = $(PERFTOOL_LIBS) + +cpelinreg_SOURCES = tools/perftool/cpelinreg.c +cpelinreg_LDADD = $(PERFTOOL_LIBS) + +cpelstate_SOURCES = tools/perftool/cpelstate.c +cpelstate_LDADD = $(PERFTOOL_LIBS) + +# vi:syntax=automake diff --git a/src/plugins/Makefile.am b/src/plugins/Makefile.am new file mode 100644 index 00000000..ffc4b3ab --- /dev/null +++ b/src/plugins/Makefile.am @@ -0,0 +1,60 @@ + +# Copyright (c) +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +AUTOMAKE_OPTIONS = foreign subdir-objects + +AM_CFLAGS = -Wall -I${top_srcdir} -I${top_builddir} +AM_LDFLAGS = -module -shared -avoid-version +SUFFIXES = .api.h .api .api.json +API_FILES = +BUILT_SOURCES = +vppplugins_LTLIBRARIES = +vppapitestplugins_LTLIBRARIES = +noinst_HEADERS = + +vppapitestpluginsdir = ${libdir}/vpp_api_test_plugins +vpppluginsdir = ${libdir}/vpp_plugins + +if ENABLE_FLOWPERPKT_PLUGIN +include flowperpkt.am +endif + +if ENABLE_ILA_PLUGIN +include ila.am +endif + +if ENABLE_SIXRD_PLUGIN +include sixrd.am +endif + +include ../suffix-rules.mk + +# Remove *.la files +install-data-hook: + @-(cd $(vpppluginsdir) && $(RM) $(vppplugins_LTLIBRARIES)) + @-(cd $(vppapitestpluginsdir) && $(RM) $(vppapitestplugins_LTLIBRARIES)) + +############################################################################### +# API +############################################################################### + +apidir = $(prefix)/share/vpp/api/plugins + +api_DATA = \ + $(patsubst %.api,%.api.json,$(API_FILES)) + +BUILT_SOURCES += \ + $(patsubst %.api,%.api.json,$(API_FILES)) \ + $(patsubst %.api,%.api.h,$(API_FILES)) + diff --git a/src/plugins/flowperpkt.am b/src/plugins/flowperpkt.am new file mode 100644 index 00000000..a400603a --- /dev/null +++ b/src/plugins/flowperpkt.am @@ -0,0 +1,38 @@ + +# Copyright (c) +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +vppplugins_LTLIBRARIES += flowperpkt_plugin.la +vppapitestplugins_LTLIBRARIES += flowperpkt_test_plugin.la + +flowperpkt_plugin_la_SOURCES = flowperpkt/flowperpkt.c \ + flowperpkt/l2_node.c \ + flowperpkt/node.c \ + flowperpkt/flowperpkt_plugin.api.h + +BUILT_SOURCES += \ + flowperpkt/flowperpkt.api.h \ + flowperpkt/flowperpkt.api.json + +noinst_HEADERS += \ + flowperpkt/flowperpkt_all_api_h.h \ + flowperpkt/flowperpkt_msg_enum.h \ + flowperpkt/flowperpkt.api.h + +flowperpkt_test_plugin_la_SOURCES = \ + flowperpkt/flowperpkt_test.c \ + flowperpkt/flowperpkt_plugin.api.h + +API_FILES += flowperpkt/flowperpkt.api + +# vi:syntax=automake diff --git a/src/plugins/flowperpkt/flowperpkt.api b/src/plugins/flowperpkt/flowperpkt.api new file mode 100644 index 00000000..fa878f21 --- /dev/null +++ b/src/plugins/flowperpkt/flowperpkt.api @@ -0,0 +1,42 @@ +/* Define a simple enable-disable binary API to control the feature */ + +/** \file + This file defines the vpp control-plane API messages + used to control the flowperpkt plugin +*/ + +/** \brief Enable / disable per-packet IPFIX recording on an interface + @param client_index - opaque cookie to identify the sender + @param context - sender context, to match reply w/ request + @param is_add - add address if non-zero, else delete + @param is_ipv6 - if non-zero the address is ipv6, else ipv4 + @param sw_if_index - index of the interface +*/ +manual_print define flowperpkt_tx_interface_add_del +{ + /* Client identifier, set from api_main.my_client_index */ + u32 client_index; + + /* Arbitrary context, so client can match reply to request */ + u32 context; + + /* Enable / disable the feature */ + u8 is_add; + u8 which; /* 0 = ipv4, 1 = l2, 2 = ipv6 (not yet implemented) */ + + /* Interface handle */ + u32 sw_if_index; +}; + +/** \brief Reply to enable/disable per-packet IPFIX recording messages + @param context - returned sender context, to match reply w/ request + @param retval - return code +*/ +define flowperpkt_tx_interface_add_del_reply +{ + /* From the request */ + u32 context; + + /* Return value, zero means all OK */ + i32 retval; +}; diff --git a/src/plugins/flowperpkt/flowperpkt.c b/src/plugins/flowperpkt/flowperpkt.c new file mode 100644 index 00000000..fb71d5b0 --- /dev/null +++ b/src/plugins/flowperpkt/flowperpkt.c @@ -0,0 +1,671 @@ +/* + * flowperpkt.c - per-packet data capture flow report plugin + * + * Copyright (c) + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @file + * @brief Per-packet IPFIX flow record generator plugin + * + * This file implements vpp plugin registration mechanics, + * debug CLI, and binary API handling. + */ + +#include +#include +#include + +#include +#include +#include + +/* define message IDs */ +#include + +/* define message structures */ +#define vl_typedefs +#include +#undef vl_typedefs + +/* define generated endian-swappers */ +#define vl_endianfun +#include +#undef vl_endianfun + +/* instantiate all the print functions we know about */ +#define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__) +#define vl_printfun +#include +#undef vl_printfun + +flowperpkt_main_t flowperpkt_main; + +/* Get the API version number */ +#define vl_api_version(n,v) static u32 api_version=(v); +#include +#undef vl_api_version + +/* Define the per-interface configurable features */ +/* *INDENT-OFF* */ +VNET_FEATURE_INIT (flow_perpacket_ipv4, static) = +{ + .arc_name = "ip4-output", + .node_name = "flowperpkt-ipv4", + .runs_before = VNET_FEATURES ("interface-output"), +}; + +VNET_FEATURE_INIT (flow_perpacket_l2, static) = +{ + .arc_name = "interface-output", + .node_name = "flowperpkt-l2", + .runs_before = VNET_FEATURES ("interface-tx"), +}; +/* *INDENT-ON* */ + +/* + * A handy macro to set up a message reply. + * Assumes that the following variables are available: + * mp - pointer to request message + * rmp - pointer to reply message type + * rv - return value + */ +#define REPLY_MACRO(t) \ +do { \ + unix_shared_memory_queue_t * q = \ + vl_api_client_index_to_input_queue (mp->client_index); \ + if (!q) \ + return; \ + \ + rmp = vl_msg_api_alloc (sizeof (*rmp)); \ + rmp->_vl_msg_id = ntohs((t)+fm->msg_id_base); \ + rmp->context = mp->context; \ + rmp->retval = ntohl(rv); \ + \ + vl_msg_api_send_shmem (q, (u8 *)&rmp); \ +} while(0); + +/* Macro to finish up custom dump fns */ +#define FINISH \ + vec_add1 (s, 0); \ + vl_print (handle, (char *)s); \ + vec_free (s); \ + return handle; + +#define VALIDATE_SW_IF_INDEX(mp) \ + do { u32 __sw_if_index = ntohl(mp->sw_if_index); \ + vnet_main_t *__vnm = vnet_get_main(); \ + if (pool_is_free_index(__vnm->interface_main.sw_interfaces, \ + __sw_if_index)) { \ + rv = VNET_API_ERROR_INVALID_SW_IF_INDEX; \ + goto bad_sw_if_index; \ + } \ +} while(0); + +#define BAD_SW_IF_INDEX_LABEL \ +do { \ +bad_sw_if_index: \ + ; \ +} while (0); + +/** + * @brief Create an IPFIX template packet rewrite string + * @param frm flow_report_main_t * + * @param fr flow_report_t * + * @param collector_address ip4_address_t * the IPFIX collector address + * @param src_address ip4_address_t * the source address we should use + * @param collector_port u16 the collector port we should use, host byte order + * @returns u8 * vector containing the indicated IPFIX template packet + */ +static inline u8 * +flowperpkt_template_rewrite_inline (flow_report_main_t * frm, + flow_report_t * fr, + ip4_address_t * collector_address, + ip4_address_t * src_address, + u16 collector_port, int variant) +{ + ip4_header_t *ip; + udp_header_t *udp; + ipfix_message_header_t *h; + ipfix_set_header_t *s; + ipfix_template_header_t *t; + ipfix_field_specifier_t *f; + ipfix_field_specifier_t *first_field; + u8 *rewrite = 0; + ip4_ipfix_template_packet_t *tp; + u32 field_count = 0; + flow_report_stream_t *stream; + flowperpkt_main_t *fm = &flowperpkt_main; + + stream = &frm->streams[fr->stream_index]; + + if (variant == FLOW_VARIANT_IPV4) + { + /* + * ip4 Supported Fields: + * + * ingressInterface, TLV type 10, u32 + * egressInterface, TLV type 14, u32 + * sourceIpv4Address, TLV type 8, u32 + * destinationIPv4Address, TLV type 12, u32 + * ipClassOfService, TLV type 5, u8 + * flowStartNanoseconds, TLV type 156, dateTimeNanoseconds (f64) + * Implementation: f64 nanoseconds since VPP started + * warning: wireshark doesn't really understand this TLV + * dataLinkFrameSize, TLV type 312, u16 + * warning: wireshark doesn't understand this TLV at all + */ + + /* Currently 7 fields */ + field_count += 7; + + /* allocate rewrite space */ + vec_validate_aligned + (rewrite, + sizeof (ip4_ipfix_template_packet_t) + + field_count * sizeof (ipfix_field_specifier_t) - 1, + CLIB_CACHE_LINE_BYTES); + } + else if (variant == FLOW_VARIANT_L2) + { + /* + * L2 Supported Fields: + * + * ingressInterface, TLV type 10, u32 + * egressInterface, TLV type 14, u32 + * sourceMacAddress, TLV type 56, u8[6] we hope + * destinationMacAddress, TLV type 57, u8[6] we hope + * ethernetType, TLV type 256, u16 + * flowStartNanoseconds, TLV type 156, dateTimeNanoseconds (f64) + * Implementation: f64 nanoseconds since VPP started + * warning: wireshark doesn't really understand this TLV + * dataLinkFrameSize, TLV type 312, u16 + * warning: wireshark doesn't understand this TLV at all + */ + + /* Currently 7 fields */ + field_count += 7; + + /* allocate rewrite space */ + vec_validate_aligned + (rewrite, + sizeof (ip4_ipfix_template_packet_t) + + field_count * sizeof (ipfix_field_specifier_t) - 1, + CLIB_CACHE_LINE_BYTES); + } + + tp = (ip4_ipfix_template_packet_t *) rewrite; + ip = (ip4_header_t *) & tp->ip4; + udp = (udp_header_t *) (ip + 1); + h = (ipfix_message_header_t *) (udp + 1); + s = (ipfix_set_header_t *) (h + 1); + t = (ipfix_template_header_t *) (s + 1); + first_field = f = (ipfix_field_specifier_t *) (t + 1); + + ip->ip_version_and_header_length = 0x45; + ip->ttl = 254; + ip->protocol = IP_PROTOCOL_UDP; + ip->src_address.as_u32 = src_address->as_u32; + ip->dst_address.as_u32 = collector_address->as_u32; + udp->src_port = clib_host_to_net_u16 (stream->src_port); + udp->dst_port = clib_host_to_net_u16 (collector_port); + udp->length = clib_host_to_net_u16 (vec_len (rewrite) - sizeof (*ip)); + + /* FIXUP: message header export_time */ + /* FIXUP: message header sequence_number */ + h->domain_id = clib_host_to_net_u32 (stream->domain_id); + + /* Add TLVs to the template */ + if (variant == FLOW_VARIANT_IPV4) + { + f->e_id_length = + ipfix_e_id_length (0 /* enterprise */ , ingressInterface, + 4); + f++; + f->e_id_length = + ipfix_e_id_length (0 /* enterprise */ , egressInterface, + 4); + f++; + f->e_id_length = + ipfix_e_id_length (0 /* enterprise */ , sourceIPv4Address, + 4); + f++; + f->e_id_length = + ipfix_e_id_length (0 /* enterprise */ , destinationIPv4Address, 4); + f++; + f->e_id_length = + ipfix_e_id_length (0 /* enterprise */ , ipClassOfService, + 1); + f++; + f->e_id_length = + ipfix_e_id_length (0 /* enterprise */ , flowStartNanoseconds, + 8); + f++; + f->e_id_length = + ipfix_e_id_length (0 /* enterprise */ , dataLinkFrameSize, + 2); + f++; + } + else if (variant == FLOW_VARIANT_L2) + { + f->e_id_length = + ipfix_e_id_length (0 /* enterprise */ , ingressInterface, + 4); + f++; + f->e_id_length = + ipfix_e_id_length (0 /* enterprise */ , egressInterface, + 4); + f++; + f->e_id_length = + ipfix_e_id_length (0 /* enterprise */ , sourceMacAddress, + 6); + f++; + f->e_id_length = + ipfix_e_id_length (0 /* enterprise */ , destinationMacAddress, 6); + f++; + f->e_id_length = ipfix_e_id_length (0 /* enterprise */ , ethernetType, + 2); + f++; + f->e_id_length = + ipfix_e_id_length (0 /* enterprise */ , flowStartNanoseconds, + 8); + f++; + f->e_id_length = + ipfix_e_id_length (0 /* enterprise */ , dataLinkFrameSize, + 2); + f++; + } + + /* Extend in the obvious way, right here... */ + + /* Back to the template packet... */ + ip = (ip4_header_t *) & tp->ip4; + udp = (udp_header_t *) (ip + 1); + + ASSERT (f - first_field); + /* Field count in this template */ + t->id_count = ipfix_id_count (fr->template_id, f - first_field); + + if (variant == FLOW_VARIANT_IPV4) + fm->ipv4_report_id = fr->template_id; + else if (variant == FLOW_VARIANT_L2) + fm->l2_report_id = fr->template_id; + + /* set length in octets */ + s->set_id_length = + ipfix_set_id_length (2 /* set_id */ , (u8 *) f - (u8 *) s); + + /* message length in octets */ + h->version_length = version_length ((u8 *) f - (u8 *) h); + + ip->length = clib_host_to_net_u16 ((u8 *) f - (u8 *) ip); + ip->checksum = ip4_header_checksum (ip); + + return rewrite; +} + +u8 * +flowperpkt_template_rewrite_ipv4 (flow_report_main_t * frm, + flow_report_t * fr, + ip4_address_t * collector_address, + ip4_address_t * src_address, + u16 collector_port) +{ + return flowperpkt_template_rewrite_inline + (frm, fr, collector_address, src_address, collector_port, + FLOW_VARIANT_IPV4); +} + +u8 * +flowperpkt_template_rewrite_l2 (flow_report_main_t * frm, + flow_report_t * fr, + ip4_address_t * collector_address, + ip4_address_t * src_address, + u16 collector_port) +{ + return flowperpkt_template_rewrite_inline + (frm, fr, collector_address, src_address, collector_port, + FLOW_VARIANT_L2); +} + + +/** + * @brief Flush accumulated data + * @param frm flow_report_main_t * + * @param fr flow_report_t * + * @param f vlib_frame_t * + * + * Notes: + * This function must simply return the incoming frame, or no template packets + * will be sent. + */ +vlib_frame_t * +flowperpkt_data_callback_ipv4 (flow_report_main_t * frm, + flow_report_t * fr, + vlib_frame_t * f, u32 * to_next, + u32 node_index) +{ + flowperpkt_flush_callback_ipv4 (); + return f; +} + +vlib_frame_t * +flowperpkt_data_callback_l2 (flow_report_main_t * frm, + flow_report_t * fr, + vlib_frame_t * f, u32 * to_next, u32 node_index) +{ + flowperpkt_flush_callback_l2 (); + return f; +} + +/** + * @brief configure / deconfigure the IPFIX flow-per-packet + * @param fm flowperpkt_main_t * fm + * @param sw_if_index u32 the desired interface + * @param is_add int 1 to enable the feature, 0 to disable it + * @returns 0 if successful, non-zero otherwise + */ + +static int flowperpkt_tx_interface_add_del_feature + (flowperpkt_main_t * fm, u32 sw_if_index, int which, int is_add) +{ + flow_report_main_t *frm = &flow_report_main; + vnet_flow_report_add_del_args_t _a, *a = &_a; + int rv; + + if (which == FLOW_VARIANT_IPV4 && !fm->ipv4_report_created) + { + memset (a, 0, sizeof (*a)); + a->rewrite_callback = flowperpkt_template_rewrite_ipv4; + a->flow_data_callback = flowperpkt_data_callback_ipv4; + a->is_add = 1; + a->domain_id = 1; /*$$$$ config parameter */ + a->src_port = 4739; /*$$$$ config parameter */ + fm->ipv4_report_created = 1; + + rv = vnet_flow_report_add_del (frm, a); + if (rv) + { + clib_warning ("vnet_flow_report_add_del returned %d", rv); + return -1; + } + } + else if (which == FLOW_VARIANT_L2 && !fm->l2_report_created) + { + memset (a, 0, sizeof (*a)); + a->rewrite_callback = flowperpkt_template_rewrite_l2; + a->flow_data_callback = flowperpkt_data_callback_l2; + a->is_add = 1; + a->domain_id = 1; /*$$$$ config parameter */ + a->src_port = 4739; /*$$$$ config parameter */ + fm->l2_report_created = 1; + + rv = vnet_flow_report_add_del (frm, a); + if (rv) + { + clib_warning ("vnet_flow_report_add_del returned %d", rv); + return -1; + } + } + + if (which == FLOW_VARIANT_IPV4) + vnet_feature_enable_disable ("ip4-output", "flowperpkt-ipv4", + sw_if_index, is_add, 0, 0); + else if (which == FLOW_VARIANT_L2) + vnet_feature_enable_disable ("interface-output", "flowperpkt-l2", + sw_if_index, is_add, 0, 0); + + return 0; +} + +/** + * @brief API message handler + * @param mp vl_api_flowperpkt_tx_interface_add_del_t * mp the api message + */ +void vl_api_flowperpkt_tx_interface_add_del_t_handler + (vl_api_flowperpkt_tx_interface_add_del_t * mp) +{ + flowperpkt_main_t *fm = &flowperpkt_main; + vl_api_flowperpkt_tx_interface_add_del_reply_t *rmp; + u32 sw_if_index = ntohl (mp->sw_if_index); + int rv = 0; + + VALIDATE_SW_IF_INDEX (mp); + + if (mp->which != FLOW_VARIANT_IPV4 && mp->which != FLOW_VARIANT_L2) + { + rv = VNET_API_ERROR_UNIMPLEMENTED; + goto out; + } + + rv = flowperpkt_tx_interface_add_del_feature (fm, sw_if_index, mp->which, + mp->is_add); +out: + BAD_SW_IF_INDEX_LABEL; + + REPLY_MACRO (VL_API_FLOWPERPKT_TX_INTERFACE_ADD_DEL_REPLY); +} + +/** + * @brief API message custom-dump function + * @param mp vl_api_flowperpkt_tx_interface_add_del_t * mp the api message + * @param handle void * print function handle + * @returns u8 * output string + */ +static void *vl_api_flowperpkt_tx_interface_add_del_t_print + (vl_api_flowperpkt_tx_interface_add_del_t * mp, void *handle) +{ + u8 *s; + + s = format (0, "SCRIPT: flowperpkt_tx_interface_add_del "); + s = format (s, "sw_if_index %d is_add %d which %d ", + clib_host_to_net_u32 (mp->sw_if_index), + (int) mp->is_add, (int) mp->which); + FINISH; +} + +/* List of message types that this plugin understands */ +#define foreach_flowperpkt_plugin_api_msg \ +_(FLOWPERPKT_TX_INTERFACE_ADD_DEL, flowperpkt_tx_interface_add_del) + +/** + * @brief plugin-api required function + * @param vm vlib_main_t * vlib main data structure pointer + * @param h vlib_plugin_handoff_t * handoff structure + * @param from_early_init int notused + * + * Notes: + * This routine exists to convince the vlib plugin framework that + * we haven't accidentally copied a random .dll into the plugin directory. + * + * Also collects global variable pointers passed from the vpp engine + */ +clib_error_t * +vlib_plugin_register (vlib_main_t * vm, vnet_plugin_handoff_t * h, + int from_early_init) +{ + flowperpkt_main_t *fm = &flowperpkt_main; + clib_error_t *error = 0; + + fm->vlib_main = vm; + fm->vnet_main = h->vnet_main; + + return error; +} + +static clib_error_t * +flowperpkt_tx_interface_add_del_feature_command_fn (vlib_main_t * vm, + unformat_input_t * input, + vlib_cli_command_t * cmd) +{ + flowperpkt_main_t *fm = &flowperpkt_main; + u32 sw_if_index = ~0; + int is_add = 1; + u8 which = FLOW_VARIANT_IPV4; + + int rv; + + while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) + { + if (unformat (input, "disable")) + is_add = 0; + else if (unformat (input, "%U", unformat_vnet_sw_interface, + fm->vnet_main, &sw_if_index)); + else if (unformat (input, "l2")) + which = FLOW_VARIANT_L2; + else + break; + } + + if (sw_if_index == ~0) + return clib_error_return (0, "Please specify an interface..."); + + rv = + flowperpkt_tx_interface_add_del_feature (fm, sw_if_index, which, is_add); + switch (rv) + { + case 0: + break; + + case VNET_API_ERROR_INVALID_SW_IF_INDEX: + return clib_error_return + (0, "Invalid interface, only works on physical ports"); + break; + + case VNET_API_ERROR_UNIMPLEMENTED: + return clib_error_return (0, "ip6 not supported"); + break; + + default: + return clib_error_return (0, "flowperpkt_enable_disable returned %d", + rv); + } + return 0; +} + +/*? + * 'flowperpkt feature add-del' commands to enable/disable + * per-packet IPFIX flow record generation on an interface + * + * @cliexpar + * @parblock + * To enable per-packet IPFIX flow-record generation on an interface: + * @cliexcmd{flowperpkt feature add-del GigabitEthernet2/0/0} + * + * To disable per-packet IPFIX flow-record generation on an interface: + * @cliexcmd{flowperpkt feature add-del GigabitEthernet2/0/0 disable} + * @cliexend + * @endparblock +?*/ +/* *INDENT-OFF* */ +VLIB_CLI_COMMAND (flowperpkt_enable_disable_command, static) = { + .path = "flowperpkt feature add-del", + .short_help = + "flowperpkt feature add-del [disable]", + .function = flowperpkt_tx_interface_add_del_feature_command_fn, +}; +/* *INDENT-ON* */ + +/** + * @brief Set up the API message handling tables + * @param vm vlib_main_t * vlib main data structure pointer + * @returns 0 to indicate all is well + */ +static clib_error_t * +flowperpkt_plugin_api_hookup (vlib_main_t * vm) +{ + flowperpkt_main_t *fm = &flowperpkt_main; +#define _(N,n) \ + vl_msg_api_set_handlers((VL_API_##N + fm->msg_id_base), \ + #n, \ + vl_api_##n##_t_handler, \ + vl_noop_handler, \ + vl_api_##n##_t_endian, \ + vl_api_##n##_t_print, \ + sizeof(vl_api_##n##_t), 1); + foreach_flowperpkt_plugin_api_msg; +#undef _ + + return 0; +} + +#define vl_msg_name_crc_list +#include +#undef vl_msg_name_crc_list + +static void +setup_message_id_table (flowperpkt_main_t * fm, api_main_t * am) +{ +#define _(id,n,crc) \ + vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id + fm->msg_id_base); + foreach_vl_msg_name_crc_flowperpkt; +#undef _ +} + +/** + * @brief Set up the API message handling tables + * @param vm vlib_main_t * vlib main data structure pointer + * @returns 0 to indicate all is well, or a clib_error_t + */ +static clib_error_t * +flowperpkt_init (vlib_main_t * vm) +{ + flowperpkt_main_t *fm = &flowperpkt_main; + vlib_thread_main_t *tm = &vlib_thread_main; + clib_error_t *error = 0; + u32 num_threads; + u8 *name; + + /* Construct the API name */ + name = format (0, "flowperpkt_%08x%c", api_version, 0); + + /* Ask for a correctly-sized block of API message decode slots */ + fm->msg_id_base = vl_msg_api_get_msg_ids + ((char *) name, VL_MSG_FIRST_AVAILABLE); + + /* Hook up message handlers */ + error = flowperpkt_plugin_api_hookup (vm); + + /* Add our API messages to the global name_crc hash table */ + setup_message_id_table (fm, &api_main); + + vec_free (name); + + /* Decide how many worker threads we have */ + num_threads = 1 /* main thread */ + tm->n_eal_threads; + + /* Allocate per worker thread vectors */ + vec_validate (fm->ipv4_buffers_per_worker, num_threads - 1); + vec_validate (fm->l2_buffers_per_worker, num_threads - 1); + vec_validate (fm->ipv4_frames_per_worker, num_threads - 1); + vec_validate (fm->l2_frames_per_worker, num_threads - 1); + vec_validate (fm->ipv4_next_record_offset_per_worker, num_threads - 1); + vec_validate (fm->l2_next_record_offset_per_worker, num_threads - 1); + + /* Set up time reference pair */ + fm->vlib_time_0 = vlib_time_now (vm); + fm->nanosecond_time_0 = unix_time_now_nsec (); + + return error; +} + +VLIB_INIT_FUNCTION (flowperpkt_init); + +/* + * fd.io coding-style-patch-verification: ON + * + * Local Variables: + * eval: (c-set-style "gnu") + * End: + */ diff --git a/src/plugins/flowperpkt/flowperpkt.h b/src/plugins/flowperpkt/flowperpkt.h new file mode 100644 index 00000000..20f6939d --- /dev/null +++ b/src/plugins/flowperpkt/flowperpkt.h @@ -0,0 +1,90 @@ +/* + * flowperpkt.h - skeleton vpp engine plug-in header file + * + * Copyright (c) + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef __included_flowperpkt_h__ +#define __included_flowperpkt_h__ + +#include +#include +#include + +#include +#include +#include +#include + +/** + * @file + * @brief flow-per-packet plugin header file + */ +typedef struct +{ + /** API message ID base */ + u16 msg_id_base; + + /** Have the reports [templates] been created? */ + int ipv4_report_created; + int l2_report_created; + + /** stream/template IDs */ + u16 ipv4_report_id; + u16 l2_report_id; + + /** ipfix buffers under construction, per-worker thread */ + vlib_buffer_t **ipv4_buffers_per_worker; + vlib_buffer_t **l2_buffers_per_worker; + + /** frames containing ipfix buffers, per-worker thread */ + vlib_frame_t **ipv4_frames_per_worker; + vlib_frame_t **l2_frames_per_worker; + + /** next record offset, per worker thread */ + u16 *ipv4_next_record_offset_per_worker; + u16 *l2_next_record_offset_per_worker; + + /** Time reference pair */ + u64 nanosecond_time_0; + f64 vlib_time_0; + + /** convenience vlib_main_t pointer */ + vlib_main_t *vlib_main; + /** convenience vnet_main_t pointer */ + vnet_main_t *vnet_main; +} flowperpkt_main_t; + +typedef enum +{ + FLOW_VARIANT_IPV4, + FLOW_VARIANT_L2, + FLOW_N_VARIANTS, +} flowperpkt_variant_t; + +extern flowperpkt_main_t flowperpkt_main; + +extern vlib_node_registration_t flowperpkt_ipv4_node; + +void flowperpkt_flush_callback_ipv4 (void); +void flowperpkt_flush_callback_l2 (void); + +#endif /* __included_flowperpkt_h__ */ + +/* + * fd.io coding-style-patch-verification: ON + * + * Local Variables: + * eval: (c-set-style "gnu") + * End: + */ diff --git a/src/plugins/flowperpkt/flowperpkt_all_api_h.h b/src/plugins/flowperpkt/flowperpkt_all_api_h.h new file mode 100644 index 00000000..329c375a --- /dev/null +++ b/src/plugins/flowperpkt/flowperpkt_all_api_h.h @@ -0,0 +1,18 @@ +/* + * flowperpkt_all_api_h.h - plug-in api #include file + * + * Copyright (c) + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/* Include the generated file, see BUILT_SOURCES in Makefile.am */ +#include diff --git a/src/plugins/flowperpkt/flowperpkt_msg_enum.h b/src/plugins/flowperpkt/flowperpkt_msg_enum.h new file mode 100644 index 00000000..3177e77a --- /dev/null +++ b/src/plugins/flowperpkt/flowperpkt_msg_enum.h @@ -0,0 +1,31 @@ +/* + * flowperpkt_msg_enum.h - vpp engine plug-in message enumeration + * + * Copyright (c) + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef included_flowperpkt_msg_enum_h +#define included_flowperpkt_msg_enum_h + +#include + +#define vl_msg_id(n,h) n, +typedef enum +{ +#include + /* We'll want to know how many messages IDs we need... */ + VL_MSG_FIRST_AVAILABLE, +} vl_msg_id_t; +#undef vl_msg_id + +#endif /* included_flowperpkt_msg_enum_h */ diff --git a/src/plugins/flowperpkt/flowperpkt_plugin_doc.md b/src/plugins/flowperpkt/flowperpkt_plugin_doc.md new file mode 100644 index 00000000..ed76c45c --- /dev/null +++ b/src/plugins/flowperpkt/flowperpkt_plugin_doc.md @@ -0,0 +1,13 @@ +Per-packet IPFIX flow record plugin {#flowperpkt_plugin_doc} +=================================== + +## Introduction + +This plugin generates one ipfix record entry per packet transmitted +on interfaces which have the feature enabled + +## Sample configuration + +set ipfix exporter collector 192.168.6.2 src 192.168.6.1 template-interval 20 port 4739 path-mtu 1500 + +flowperpkt feature add-del GigabitEthernet2/3/0 diff --git a/src/plugins/flowperpkt/flowperpkt_test.c b/src/plugins/flowperpkt/flowperpkt_test.c new file mode 100644 index 00000000..716818ff --- /dev/null +++ b/src/plugins/flowperpkt/flowperpkt_test.c @@ -0,0 +1,234 @@ +/* + * flowperpkt.c - skeleton vpp-api-test plug-in + * + * Copyright (c) + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include +#include +#include +#include +#include + +/** + * @file vpp_api_test plugin + */ + +uword unformat_sw_if_index (unformat_input_t * input, va_list * args); + +/* Declare message IDs */ +#include + +/* define message structures */ +#define vl_typedefs +#include +#undef vl_typedefs + +/* declare message handlers for each api */ + +#define vl_endianfun /* define message structures */ +#include +#undef vl_endianfun + +/* instantiate all the print functions we know about */ +#define vl_print(handle, ...) +#define vl_printfun +#include +#undef vl_printfun + +/* Get the API version number. */ +#define vl_api_version(n,v) static u32 api_version=(v); +#include +#undef vl_api_version + +typedef struct +{ + /** API message ID base */ + u16 msg_id_base; + /** vat_main_t pointer */ + vat_main_t *vat_main; +} flowperpkt_test_main_t; + +flowperpkt_test_main_t flowperpkt_test_main; + +#define foreach_standard_reply_retval_handler \ +_(flowperpkt_tx_interface_add_del_reply) + +#define _(n) \ + static void vl_api_##n##_t_handler \ + (vl_api_##n##_t * mp) \ + { \ + vat_main_t * vam = flowperpkt_test_main.vat_main; \ + i32 retval = ntohl(mp->retval); \ + if (vam->async_mode) { \ + vam->async_errors += (retval < 0); \ + } else { \ + vam->retval = retval; \ + vam->result_ready = 1; \ + } \ + } +foreach_standard_reply_retval_handler; +#undef _ + +/* + * Table of message reply handlers, must include boilerplate handlers + * we just generated + */ +#define foreach_vpe_api_reply_msg \ +_(FLOWPERPKT_TX_INTERFACE_ADD_DEL_REPLY, \ + flowperpkt_tx_interface_add_del_reply) + + +/* M: construct, but don't yet send a message */ + +#define M(T,t) \ +do { \ + vam->result_ready = 0; \ + mp = vl_msg_api_alloc(sizeof(*mp)); \ + memset (mp, 0, sizeof (*mp)); \ + mp->_vl_msg_id = ntohs (VL_API_##T + sm->msg_id_base); \ + mp->client_index = vam->my_client_index; \ +} while(0); + +#define M2(T,t,n) \ +do { \ + vam->result_ready = 0; \ + mp = vl_msg_api_alloc(sizeof(*mp)+(n)); \ + memset (mp, 0, sizeof (*mp)); \ + mp->_vl_msg_id = ntohs (VL_API_##T + sm->msg_id_base); \ + mp->client_index = vam->my_client_index; \ +} while(0); + +/* S: send a message */ +#define S (vl_msg_api_send_shmem (vam->vl_input_queue, (u8 *)&mp)) + +/* W: wait for results, with timeout */ +#define W \ +do { \ + timeout = vat_time_now (vam) + 1.0; \ + \ + while (vat_time_now (vam) < timeout) { \ + if (vam->result_ready == 1) { \ + return (vam->retval); \ + } \ + } \ + return -99; \ +} while(0); + +static int +api_flowperpkt_tx_interface_add_del (vat_main_t * vam) +{ + flowperpkt_test_main_t *sm = &flowperpkt_test_main; + unformat_input_t *i = vam->input; + f64 timeout; + int enable_disable = 1; + u8 which = 0; /* ipv4 by default */ + u32 sw_if_index = ~0; + vl_api_flowperpkt_tx_interface_add_del_t *mp; + + /* Parse args required to build the message */ + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index)) + ; + else if (unformat (i, "sw_if_index %d", &sw_if_index)) + ; + else if (unformat (i, "disable")) + enable_disable = 0; + else if (unformat (i, "l2")) + which = 1; + else + break; + } + + if (sw_if_index == ~0) + { + errmsg ("missing interface name / explicit sw_if_index number \n"); + return -99; + } + + /* Construct the API message */ + M (FLOWPERPKT_TX_INTERFACE_ADD_DEL, flowperpkt_tx_interface_add_del); + mp->sw_if_index = ntohl (sw_if_index); + mp->is_add = enable_disable; + mp->which = which; + + /* send it... */ + S; + + /* Wait for a reply... */ + W; +} + +/* + * List of messages that the api test plugin sends, + * and that the data plane plugin processes + */ +#define foreach_vpe_api_msg \ +_(flowperpkt_tx_interface_add_del, " [disable]") + +void +vat_api_hookup (vat_main_t * vam) +{ + flowperpkt_test_main_t *sm = &flowperpkt_test_main; + /* Hook up handlers for replies from the data plane plug-in */ +#define _(N,n) \ + vl_msg_api_set_handlers((VL_API_##N + sm->msg_id_base), \ + #n, \ + vl_api_##n##_t_handler, \ + vl_noop_handler, \ + vl_api_##n##_t_endian, \ + vl_api_##n##_t_print, \ + sizeof(vl_api_##n##_t), 1); + foreach_vpe_api_reply_msg; +#undef _ + + /* API messages we can send */ +#define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n); + foreach_vpe_api_msg; +#undef _ + + /* Help strings */ +#define _(n,h) hash_set_mem (vam->help_by_name, #n, h); + foreach_vpe_api_msg; +#undef _ +} + +clib_error_t * +vat_plugin_register (vat_main_t * vam) +{ + flowperpkt_test_main_t *sm = &flowperpkt_test_main; + u8 *name; + + sm->vat_main = vam; + + /* Ask the vpp engine for the first assigned message-id */ + name = format (0, "flowperpkt_%08x%c", api_version, 0); + sm->msg_id_base = vl_client_get_first_plugin_msg_id ((char *) name); + + /* Don't attempt to hook up API messages if the data plane plugin is AWOL */ + if (sm->msg_id_base != (u16) ~ 0) + vat_api_hookup (vam); + + vec_free (name); + + return 0; +} + +/* + * fd.io coding-style-patch-verification: ON + * + * Local Variables: + * eval: (c-set-style "gnu") + * End: + */ diff --git a/src/plugins/flowperpkt/l2_node.c b/src/plugins/flowperpkt/l2_node.c new file mode 100644 index 00000000..1c2f681e --- /dev/null +++ b/src/plugins/flowperpkt/l2_node.c @@ -0,0 +1,561 @@ +/* + * l2_node.c - l2 ipfix-per-packet graph node + * + * Copyright (c) + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include +#include +#include +#include +#include + +/** + * @file l2 flow record generator graph node + */ + +typedef struct +{ + /** interface handle */ + u32 rx_sw_if_index; + u32 tx_sw_if_index; + /** src and dst L2 addresses */ + u8 src_mac[6]; + u8 dst_mac[6]; + /** Ethertype */ + u16 ethertype; + /** packet timestamp */ + u64 timestamp; + /** size of the buffer */ + u16 buffer_size; +} flowperpkt_l2_trace_t; + +/* packet trace format function */ +static u8 * +format_flowperpkt_l2_trace (u8 * s, va_list * args) +{ + CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *); + CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *); + flowperpkt_l2_trace_t *t = va_arg (*args, flowperpkt_l2_trace_t *); + + s = format (s, + "FLOWPERPKT-L2: rx_sw_if_index %d, tx_sw_if_index %d, src %U dst %U ethertype %0x2, timestamp %lld, size %d", + t->rx_sw_if_index, t->tx_sw_if_index, + format_ethernet_address, &t->src_mac, + format_ethernet_address, &t->dst_mac, + t->ethertype, t->timestamp, t->buffer_size); + return s; +} + +vlib_node_registration_t flowperpkt_l2_node; + +/* No counters at the moment */ +#define foreach_flowperpkt_l2_error + +typedef enum +{ +#define _(sym,str) FLOWPERPKT_ERROR_##sym, + foreach_flowperpkt_l2_error +#undef _ + FLOWPERPKT_N_ERROR, +} flowperpkt_l2_error_t; + +static char *flowperpkt_l2_error_strings[] = { +#define _(sym,string) string, + foreach_flowperpkt_l2_error +#undef _ +}; + +typedef enum +{ + FLOWPERPKT_L2_NEXT_DROP, + FLOWPERPKT_L2_NEXT_IP4_LOOKUP, + FLOWPERPKT_L2_N_NEXT, +} flowperpkt_l2_next_t; + +/** + * @brief add an entry to the flow record under construction + * @param vm vlib_main_t * current worker thread main structure pointer + * @param fm flowperpkt_main_t * flow-per-packet main structure pointer + * @param sw_if_index u32 interface handle + * @param tos u8 ToS bits from the packet + * @param timestamp u64 timestamp, nanoseconds since 1/1/70 + * @param length u16 ip length of the packet + * @param do_flush int 1 = flush all cached records, 0 = construct a record + */ + +static inline void +add_to_flow_record_l2 (vlib_main_t * vm, + vlib_node_runtime_t * node, + flowperpkt_main_t * fm, + u32 rx_sw_if_index, u32 tx_sw_if_index, + u8 * src_mac, u8 * dst_mac, + u16 ethertype, u64 timestamp, u16 length, int do_flush) +{ + u32 my_cpu_number = vm->cpu_index; + flow_report_main_t *frm = &flow_report_main; + ip4_header_t *ip; + udp_header_t *udp; + ip4_ipfix_template_packet_t *tp; + ipfix_message_header_t *h; + ipfix_set_header_t *s; + vlib_frame_t *f; + vlib_buffer_t *b0; + u16 offset; + u32 bi0; + vlib_buffer_free_list_t *fl; + + /* Find or allocate a buffer */ + b0 = fm->l2_buffers_per_worker[my_cpu_number]; + + /* Need to allocate a buffer? */ + if (PREDICT_FALSE (b0 == 0)) + { + /* Nothing to flush */ + if (do_flush) + return; + + /* $$$$ drop counter? */ + if (vlib_buffer_alloc (vm, &bi0, 1) != 1) + return; + + /* Initialize the buffer */ + b0 = fm->l2_buffers_per_worker[my_cpu_number] = + vlib_get_buffer (vm, bi0); + fl = + vlib_buffer_get_free_list (vm, VLIB_BUFFER_DEFAULT_FREE_LIST_INDEX); + vlib_buffer_init_for_free_list (b0, fl); + VLIB_BUFFER_TRACE_TRAJECTORY_INIT (b0); + offset = 0; + } + else + { + /* use the current buffer */ + bi0 = vlib_get_buffer_index (vm, b0); + offset = fm->l2_next_record_offset_per_worker[my_cpu_number]; + } + + /* Find or allocate a frame */ + f = fm->l2_frames_per_worker[my_cpu_number]; + if (PREDICT_FALSE (f == 0)) + { + u32 *to_next; + f = vlib_get_frame_to_node (vm, ip4_lookup_node.index); + fm->l2_frames_per_worker[my_cpu_number] = f; + + /* Enqueue the buffer */ + to_next = vlib_frame_vector_args (f); + to_next[0] = bi0; + f->n_vectors = 1; + } + + /* Fresh packet, construct header */ + if (PREDICT_FALSE (offset == 0)) + { + flow_report_stream_t *stream; + + stream = &frm->streams[0]; + + b0->current_data = 0; + b0->current_length = sizeof (*ip) + sizeof (*udp) + sizeof (*h) + + sizeof (*s); + b0->flags |= (VLIB_BUFFER_TOTAL_LENGTH_VALID | VLIB_BUFFER_FLOW_REPORT); + vnet_buffer (b0)->sw_if_index[VLIB_RX] = 0; + vnet_buffer (b0)->sw_if_index[VLIB_TX] = frm->fib_index; + + tp = vlib_buffer_get_current (b0); + ip = (ip4_header_t *) & tp->ip4; + udp = (udp_header_t *) (ip + 1); + h = (ipfix_message_header_t *) (udp + 1); + s = (ipfix_set_header_t *) (h + 1); + + ip->ip_version_and_header_length = 0x45; + ip->ttl = 254; + ip->protocol = IP_PROTOCOL_UDP; + ip->flags_and_fragment_offset = 0; + ip->src_address.as_u32 = frm->src_address.as_u32; + ip->dst_address.as_u32 = frm->ipfix_collector.as_u32; + udp->src_port = clib_host_to_net_u16 (UDP_DST_PORT_ipfix); + udp->dst_port = clib_host_to_net_u16 (UDP_DST_PORT_ipfix); + udp->checksum = 0; + + /* FIXUP: message header export_time */ + h->export_time = (u32) + (((f64) frm->unix_time_0) + + (vlib_time_now (frm->vlib_main) - frm->vlib_time_0)); + h->export_time = clib_host_to_net_u32 (h->export_time); + h->domain_id = clib_host_to_net_u32 (stream->domain_id); + + /* FIXUP: message header sequence_number */ + h->sequence_number = stream->sequence_number++; + h->sequence_number = clib_host_to_net_u32 (h->sequence_number); + + offset = (u32) (((u8 *) (s + 1)) - (u8 *) tp); + } + + /* Add data, unless we're flushing stale data */ + if (PREDICT_TRUE (do_flush == 0)) + { + + /* Add data */ + /* Ingress interface */ + { + u32 ingress_interface = clib_host_to_net_u32 (rx_sw_if_index); + clib_memcpy (b0->data + offset, &ingress_interface, + sizeof (ingress_interface)); + offset += sizeof (ingress_interface); + } + /* Egress interface */ + { + u32 egress_interface = clib_host_to_net_u32 (tx_sw_if_index); + clib_memcpy (b0->data + offset, &egress_interface, + sizeof (egress_interface)); + offset += sizeof (egress_interface); + } + /* src mac address */ + { + clib_memcpy (b0->data + offset, src_mac, 6); + offset += 6; + } + /* dst mac address */ + { + clib_memcpy (b0->data + offset, dst_mac, 6); + offset += 6; + } + + /* ethertype */ + b0->data[offset++] = ethertype >> 8; + b0->data[offset++] = ethertype & 0xFF; + + /* Timestamp */ + clib_memcpy (b0->data + offset, ×tamp, sizeof (f64)); + offset += sizeof (f64); + + /* pkt size */ + { + u16 pkt_size = clib_host_to_net_u16 (length); + clib_memcpy (b0->data + offset, &pkt_size, sizeof (pkt_size)); + offset += sizeof (pkt_size); + } + + b0->current_length += + /* 2*sw_if_index + 2*mac + ethertype + timestamp + length = 32 */ + 2 * sizeof (u32) + 12 + sizeof (u16) + sizeof (f64) + sizeof (u16); + + } + /* Time to flush the buffer? */ + if (PREDICT_FALSE + (do_flush || (offset + 2 * sizeof (u32) + 12 + sizeof (u16) + + +sizeof (f64) + sizeof (u16)) > frm->path_mtu)) + { + tp = vlib_buffer_get_current (b0); + ip = (ip4_header_t *) & tp->ip4; + udp = (udp_header_t *) (ip + 1); + h = (ipfix_message_header_t *) (udp + 1); + s = (ipfix_set_header_t *) (h + 1); + + s->set_id_length = ipfix_set_id_length (fm->l2_report_id, + b0->current_length - + (sizeof (*ip) + sizeof (*udp) + + sizeof (*h))); + h->version_length = version_length (b0->current_length - + (sizeof (*ip) + sizeof (*udp))); + + ip->length = clib_host_to_net_u16 (b0->current_length); + + ip->checksum = ip4_header_checksum (ip); + udp->length = clib_host_to_net_u16 (b0->current_length - sizeof (*ip)); + + if (frm->udp_checksum) + { + /* RFC 7011 section 10.3.2. */ + udp->checksum = ip4_tcp_udp_compute_checksum (vm, b0, ip); + if (udp->checksum == 0) + udp->checksum = 0xffff; + } + + ASSERT (ip->checksum == ip4_header_checksum (ip)); + + if (PREDICT_FALSE (vlib_get_trace_count (vm, node) > 0)) + { + vlib_trace_buffer (vm, node, FLOWPERPKT_L2_NEXT_IP4_LOOKUP, b0, + 0 /* follow chain */ ); + flowperpkt_l2_trace_t *t = + vlib_add_trace (vm, node, b0, sizeof (*t)); + memset (t, 0, sizeof (*t)); + t->rx_sw_if_index = vnet_buffer (b0)->sw_if_index[VLIB_RX]; + t->tx_sw_if_index = vnet_buffer (b0)->sw_if_index[VLIB_TX]; + t->buffer_size = b0->current_length; + } + + vlib_put_frame_to_node (vm, ip4_lookup_node.index, + fm->l2_frames_per_worker[my_cpu_number]); + fm->l2_frames_per_worker[my_cpu_number] = 0; + fm->l2_buffers_per_worker[my_cpu_number] = 0; + offset = 0; + } + + fm->l2_next_record_offset_per_worker[my_cpu_number] = offset; +} + +void +flowperpkt_flush_callback_l2 (void) +{ + vlib_main_t *vm = vlib_get_main (); + flowperpkt_main_t *fm = &flowperpkt_main; + vlib_node_runtime_t *node; + node = vlib_node_get_runtime (vm, flowperpkt_l2_node.index); + + add_to_flow_record_l2 (vm, node, fm, 0 /* rx_sw_if_index */ , + 0 /* tx_sw_if_index */ , + 0 /* src mac */ , + 0 /* dst mac */ , + 0 /* ethertype */ , + 0ULL /* timestamp */ , + 0 /* length */ , + 1 /* do_flush */ ); +} + + +static uword +flowperpkt_l2_node_fn (vlib_main_t * vm, + vlib_node_runtime_t * node, vlib_frame_t * frame) +{ + u32 n_left_from, *from, *to_next; + flowperpkt_l2_next_t next_index; + flowperpkt_main_t *fm = &flowperpkt_main; + u64 now; + + now = (u64) ((vlib_time_now (vm) - fm->vlib_time_0) * 1e9); + now += fm->nanosecond_time_0; + + from = vlib_frame_vector_args (frame); + n_left_from = frame->n_vectors; + next_index = node->cached_next_index; + + while (n_left_from > 0) + { + u32 n_left_to_next; + + vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next); + + while (n_left_from >= 4 && n_left_to_next >= 2) + { + u32 next0 = FLOWPERPKT_L2_NEXT_DROP; + u32 next1 = FLOWPERPKT_L2_NEXT_DROP; + ethernet_header_t *eh0, *eh1; + u16 len0, len1; + u32 bi0, bi1; + vlib_buffer_t *b0, *b1; + + /* Prefetch next iteration. */ + { + vlib_buffer_t *p2, *p3; + + p2 = vlib_get_buffer (vm, from[2]); + p3 = vlib_get_buffer (vm, from[3]); + + vlib_prefetch_buffer_header (p2, LOAD); + vlib_prefetch_buffer_header (p3, LOAD); + + CLIB_PREFETCH (p2->data, CLIB_CACHE_LINE_BYTES, STORE); + CLIB_PREFETCH (p3->data, CLIB_CACHE_LINE_BYTES, STORE); + } + + /* speculatively enqueue b0 and b1 to the current next frame */ + to_next[0] = bi0 = from[0]; + to_next[1] = bi1 = from[1]; + from += 2; + to_next += 2; + n_left_from -= 2; + n_left_to_next -= 2; + + b0 = vlib_get_buffer (vm, bi0); + b1 = vlib_get_buffer (vm, bi1); + + vnet_feature_next (vnet_buffer (b0)->sw_if_index[VLIB_TX], + &next0, b0); + vnet_feature_next (vnet_buffer (b1)->sw_if_index[VLIB_TX], + &next1, b1); + + eh0 = vlib_buffer_get_current (b0); + len0 = vlib_buffer_length_in_chain (vm, b0); + + if (PREDICT_TRUE ((b0->flags & VLIB_BUFFER_FLOW_REPORT) == 0)) + add_to_flow_record_l2 (vm, node, fm, + vnet_buffer (b0)->sw_if_index[VLIB_RX], + vnet_buffer (b0)->sw_if_index[VLIB_TX], + eh0->src_address, + eh0->dst_address, + eh0->type, now, len0, 0 /* flush */ ); + + eh1 = vlib_buffer_get_current (b0); + len1 = vlib_buffer_length_in_chain (vm, b0); + + if (PREDICT_TRUE ((b1->flags & VLIB_BUFFER_FLOW_REPORT) == 0)) + add_to_flow_record_l2 (vm, node, fm, + vnet_buffer (b1)->sw_if_index[VLIB_RX], + vnet_buffer (b1)->sw_if_index[VLIB_TX], + eh1->src_address, + eh1->dst_address, + eh1->type, now, len1, 0 /* flush */ ); + + if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE))) + { + if (b0->flags & VLIB_BUFFER_IS_TRACED) + { + flowperpkt_l2_trace_t *t = + vlib_add_trace (vm, node, b0, sizeof (*t)); + t->rx_sw_if_index = vnet_buffer (b0)->sw_if_index[VLIB_RX]; + t->tx_sw_if_index = vnet_buffer (b0)->sw_if_index[VLIB_TX]; + clib_memcpy (t->src_mac, eh0->src_address, 6); + clib_memcpy (t->dst_mac, eh0->dst_address, 6); + t->ethertype = clib_net_to_host_u16 (eh0->type); + t->timestamp = now; + t->buffer_size = len0; + } + if (b1->flags & VLIB_BUFFER_IS_TRACED) + { + flowperpkt_l2_trace_t *t = + vlib_add_trace (vm, node, b1, sizeof (*t)); + t->rx_sw_if_index = vnet_buffer (b1)->sw_if_index[VLIB_RX]; + t->tx_sw_if_index = vnet_buffer (b1)->sw_if_index[VLIB_TX]; + clib_memcpy (t->src_mac, eh1->src_address, 6); + clib_memcpy (t->dst_mac, eh1->dst_address, 6); + t->ethertype = clib_net_to_host_u16 (eh1->type); + t->timestamp = now; + t->buffer_size = len1; + } + } + + /* verify speculative enqueues, maybe switch current next frame */ + vlib_validate_buffer_enqueue_x2 (vm, node, next_index, + to_next, n_left_to_next, + bi0, bi1, next0, next1); + } + + while (n_left_from > 0 && n_left_to_next > 0) + { + u32 bi0; + vlib_buffer_t *b0; + u32 next0 = FLOWPERPKT_L2_NEXT_DROP; + ethernet_header_t *eh0; + u16 len0; + + /* speculatively enqueue b0 to the current next frame */ + bi0 = from[0]; + to_next[0] = bi0; + from += 1; + to_next += 1; + n_left_from -= 1; + n_left_to_next -= 1; + + b0 = vlib_get_buffer (vm, bi0); + + vnet_feature_next (vnet_buffer (b0)->sw_if_index[VLIB_TX], + &next0, b0); + + eh0 = vlib_buffer_get_current (b0); + len0 = vlib_buffer_length_in_chain (vm, b0); + + if (PREDICT_TRUE ((b0->flags & VLIB_BUFFER_FLOW_REPORT) == 0)) + add_to_flow_record_l2 (vm, node, fm, + vnet_buffer (b0)->sw_if_index[VLIB_RX], + vnet_buffer (b0)->sw_if_index[VLIB_TX], + eh0->src_address, + eh0->dst_address, + eh0->type, now, len0, 0 /* flush */ ); + + if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE) + && (b0->flags & VLIB_BUFFER_IS_TRACED))) + { + flowperpkt_l2_trace_t *t = + vlib_add_trace (vm, node, b0, sizeof (*t)); + t->rx_sw_if_index = vnet_buffer (b0)->sw_if_index[VLIB_RX]; + t->tx_sw_if_index = vnet_buffer (b0)->sw_if_index[VLIB_TX]; + clib_memcpy (t->src_mac, eh0->src_address, 6); + clib_memcpy (t->dst_mac, eh0->dst_address, 6); + t->ethertype = clib_net_to_host_u16 (eh0->type); + t->timestamp = now; + t->buffer_size = len0; + } + + /* verify speculative enqueue, maybe switch current next frame */ + vlib_validate_buffer_enqueue_x1 (vm, node, next_index, + to_next, n_left_to_next, + bi0, next0); + } + + vlib_put_next_frame (vm, node, next_index, n_left_to_next); + } + return frame->n_vectors; +} + +/** + * @brief IPFIX l2 flow-per-packet graph node + * @node flowperpkt-l2 + * + * This is the IPFIX flow-record-per-packet node. + * + * @param vm vlib_main_t corresponding to the current thread. + * @param node vlib_node_runtime_t data for this node. + * @param frame vlib_frame_t whose contents should be dispatched. + * + * @par Graph mechanics: buffer metadata, next index usage + * + * Uses: + * - vnet_buffer(b)->ip.save_rewrite_length + * - tells the node the length of the rewrite which was applied in + * ip4/6_rewrite_inline, allows the code to find the IP header without + * having to parse L2 headers, or make stupid assumptions about their + * length. + * - vnet_buffer(b)->flags & VLIB_BUFFER_FLOW_REPORT + * - Used to suppress flow record generation for flow record packets. + * + * Sets: + * - vnet_buffer(b)->flags & VLIB_BUFFER_FLOW_REPORT + * - To suppress flow record generation for flow record packets + * + * Next Index: + * - Next configured output feature on the interface, usually + * "interface-output." Generated flow records head for ip4-lookup + */ + +/* *INDENT-OFF* */ +VLIB_REGISTER_NODE (flowperpkt_l2_node) = { + .function = flowperpkt_l2_node_fn, + .name = "flowperpkt-l2", + .vector_size = sizeof (u32), + .format_trace = format_flowperpkt_l2_trace, + .type = VLIB_NODE_TYPE_INTERNAL, + + .n_errors = ARRAY_LEN(flowperpkt_l2_error_strings), + .error_strings = flowperpkt_l2_error_strings, + + .n_next_nodes = FLOWPERPKT_L2_N_NEXT, + + /* edit / add dispositions here */ + .next_nodes = { + [FLOWPERPKT_L2_NEXT_DROP] = "error-drop", + [FLOWPERPKT_L2_NEXT_IP4_LOOKUP] = "ip4-lookup", + }, +}; +/* *INDENT-ON* */ + +/* + * fd.io coding-style-patch-verification: ON + * + * Local Variables: + * eval: (c-set-style "gnu") + * End: + */ diff --git a/src/plugins/flowperpkt/node.c b/src/plugins/flowperpkt/node.c new file mode 100644 index 00000000..f77f087d --- /dev/null +++ b/src/plugins/flowperpkt/node.c @@ -0,0 +1,574 @@ +/* + * node.c - ipv4 ipfix-per-packet graph node + * + * Copyright (c) + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include +#include +#include +#include +#include + +/** + * @file ipv4 flow record generator graph node + */ + +typedef struct +{ + /** interface handle */ + u32 rx_sw_if_index; + u32 tx_sw_if_index; + u32 src_address; + u32 dst_address; + /** ToS bits */ + u8 tos; + /** packet timestamp */ + u64 timestamp; + /** size of the buffer */ + u16 buffer_size; +} flowperpkt_ipv4_trace_t; + +/* packet trace format function */ +static u8 * +format_flowperpkt_ipv4_trace (u8 * s, va_list * args) +{ + CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *); + CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *); + flowperpkt_ipv4_trace_t *t = va_arg (*args, flowperpkt_ipv4_trace_t *); + + s = format (s, + "FLOWPERPKT-V4: rx_sw_if_index %d, tx_sw_if_index %d, src %U dst %U tos %0x2, timestamp %lld, size %d", + t->rx_sw_if_index, t->tx_sw_if_index, + format_ip4_address, &t->src_address, + format_ip4_address, &t->dst_address, + t->tos, t->timestamp, t->buffer_size); + return s; +} + +vlib_node_registration_t flowperpkt_ipv4_node; + +/* No counters at the moment */ +#define foreach_flowperpkt_ipv4_error + +typedef enum +{ +#define _(sym,str) FLOWPERPKT_ERROR_##sym, + foreach_flowperpkt_ipv4_error +#undef _ + FLOWPERPKT_N_ERROR, +} flowperpkt_ipv4_error_t; + +static char *flowperpkt_ipv4_error_strings[] = { +#define _(sym,string) string, + foreach_flowperpkt_ipv4_error +#undef _ +}; + +typedef enum +{ + FLOWPERPKT_IPV4_NEXT_DROP, + FLOWPERPKT_IPV4_NEXT_LOOKUP, + FLOWPERPKT_IPV4_N_NEXT, +} flowperpkt_ipv4_next_t; + +/** + * @brief add an entry to the flow record under construction + * @param vm vlib_main_t * current worker thread main structure pointer + * @param fm flowperpkt_main_t * flow-per-packet main structure pointer + * @param sw_if_index u32 interface handle + * @param tos u8 ToS bits from the packet + * @param timestamp u64 timestamp, nanoseconds since 1/1/70 + * @param length u16 ip length of the packet + * @param do_flush int 1 = flush all cached records, 0 = construct a record + */ + +static inline void +add_to_flow_record_ipv4 (vlib_main_t * vm, + vlib_node_runtime_t * node, + flowperpkt_main_t * fm, + u32 rx_sw_if_index, u32 tx_sw_if_index, + u32 src_address, u32 dst_address, + u8 tos, u64 timestamp, u16 length, int do_flush) +{ + u32 my_cpu_number = vm->cpu_index; + flow_report_main_t *frm = &flow_report_main; + ip4_header_t *ip; + udp_header_t *udp; + ip4_ipfix_template_packet_t *tp; + ipfix_message_header_t *h; + ipfix_set_header_t *s; + vlib_frame_t *f; + vlib_buffer_t *b0; + u16 offset; + u32 bi0; + vlib_buffer_free_list_t *fl; + + /* Find or allocate a buffer */ + b0 = fm->ipv4_buffers_per_worker[my_cpu_number]; + + /* Need to allocate a buffer? */ + if (PREDICT_FALSE (b0 == 0)) + { + /* Nothing to flush */ + if (do_flush) + return; + + /* $$$$ drop counter? */ + if (vlib_buffer_alloc (vm, &bi0, 1) != 1) + return; + + /* Initialize the buffer */ + b0 = fm->ipv4_buffers_per_worker[my_cpu_number] = + vlib_get_buffer (vm, bi0); + fl = + vlib_buffer_get_free_list (vm, VLIB_BUFFER_DEFAULT_FREE_LIST_INDEX); + vlib_buffer_init_for_free_list (b0, fl); + VLIB_BUFFER_TRACE_TRAJECTORY_INIT (b0); + offset = 0; + } + else + { + /* use the current buffer */ + bi0 = vlib_get_buffer_index (vm, b0); + offset = fm->ipv4_next_record_offset_per_worker[my_cpu_number]; + } + + /* Find or allocate a frame */ + f = fm->ipv4_frames_per_worker[my_cpu_number]; + if (PREDICT_FALSE (f == 0)) + { + u32 *to_next; + f = vlib_get_frame_to_node (vm, ip4_lookup_node.index); + fm->ipv4_frames_per_worker[my_cpu_number] = f; + + /* Enqueue the buffer */ + to_next = vlib_frame_vector_args (f); + to_next[0] = bi0; + f->n_vectors = 1; + } + + /* Fresh packet, construct header */ + if (PREDICT_FALSE (offset == 0)) + { + flow_report_stream_t *stream; + + stream = &frm->streams[0]; + + b0->current_data = 0; + b0->current_length = sizeof (*ip) + sizeof (*udp) + sizeof (*h) + + sizeof (*s); + b0->flags |= (VLIB_BUFFER_TOTAL_LENGTH_VALID | VLIB_BUFFER_FLOW_REPORT); + vnet_buffer (b0)->sw_if_index[VLIB_RX] = 0; + vnet_buffer (b0)->sw_if_index[VLIB_TX] = frm->fib_index; + + tp = vlib_buffer_get_current (b0); + ip = (ip4_header_t *) & tp->ip4; + udp = (udp_header_t *) (ip + 1); + h = (ipfix_message_header_t *) (udp + 1); + s = (ipfix_set_header_t *) (h + 1); + + ip->ip_version_and_header_length = 0x45; + ip->ttl = 254; + ip->protocol = IP_PROTOCOL_UDP; + ip->flags_and_fragment_offset = 0; + ip->src_address.as_u32 = frm->src_address.as_u32; + ip->dst_address.as_u32 = frm->ipfix_collector.as_u32; + udp->src_port = clib_host_to_net_u16 (UDP_DST_PORT_ipfix); + udp->dst_port = clib_host_to_net_u16 (UDP_DST_PORT_ipfix); + udp->checksum = 0; + + /* FIXUP: message header export_time */ + h->export_time = (u32) + (((f64) frm->unix_time_0) + + (vlib_time_now (frm->vlib_main) - frm->vlib_time_0)); + h->export_time = clib_host_to_net_u32 (h->export_time); + h->domain_id = clib_host_to_net_u32 (stream->domain_id); + + /* FIXUP: message header sequence_number */ + h->sequence_number = stream->sequence_number++; + h->sequence_number = clib_host_to_net_u32 (h->sequence_number); + + offset = (u32) (((u8 *) (s + 1)) - (u8 *) tp); + } + + /* Add data, unless we're flushing stale data */ + if (PREDICT_TRUE (do_flush == 0)) + { + + /* Add data */ + /* Ingress interface */ + { + u32 ingress_interface = clib_host_to_net_u32 (rx_sw_if_index); + clib_memcpy (b0->data + offset, &ingress_interface, + sizeof (ingress_interface)); + offset += sizeof (ingress_interface); + } + /* Egress interface */ + { + u32 egress_interface = clib_host_to_net_u32 (tx_sw_if_index); + clib_memcpy (b0->data + offset, &egress_interface, + sizeof (egress_interface)); + offset += sizeof (egress_interface); + } + /* ip4 src address */ + { + clib_memcpy (b0->data + offset, &src_address, sizeof (src_address)); + offset += sizeof (src_address); + } + /* ip4 dst address */ + { + clib_memcpy (b0->data + offset, &dst_address, sizeof (dst_address)); + offset += sizeof (dst_address); + } + + /* ToS */ + b0->data[offset++] = tos; + + /* Timestamp */ + clib_memcpy (b0->data + offset, ×tamp, sizeof (f64)); + offset += sizeof (f64); + + /* pkt size */ + { + u16 pkt_size = clib_host_to_net_u16 (length); + clib_memcpy (b0->data + offset, &pkt_size, sizeof (pkt_size)); + offset += sizeof (pkt_size); + } + + b0->current_length += + /* sw_if_index + tos + timestamp + length = 15 */ + 4 * sizeof (u32) + sizeof (u8) + sizeof (f64) + sizeof (u16); + + } + /* Time to flush the buffer? */ + if (PREDICT_FALSE + (do_flush || (offset + 4 * sizeof (u32) + sizeof (u8) + + sizeof (f64) + sizeof (u16)) > frm->path_mtu)) + { + tp = vlib_buffer_get_current (b0); + ip = (ip4_header_t *) & tp->ip4; + udp = (udp_header_t *) (ip + 1); + h = (ipfix_message_header_t *) (udp + 1); + s = (ipfix_set_header_t *) (h + 1); + + s->set_id_length = ipfix_set_id_length (fm->ipv4_report_id, + b0->current_length - + (sizeof (*ip) + sizeof (*udp) + + sizeof (*h))); + h->version_length = version_length (b0->current_length - + (sizeof (*ip) + sizeof (*udp))); + + ip->length = clib_host_to_net_u16 (b0->current_length); + + ip->checksum = ip4_header_checksum (ip); + udp->length = clib_host_to_net_u16 (b0->current_length - sizeof (*ip)); + + if (frm->udp_checksum) + { + /* RFC 7011 section 10.3.2. */ + udp->checksum = ip4_tcp_udp_compute_checksum (vm, b0, ip); + if (udp->checksum == 0) + udp->checksum = 0xffff; + } + + ASSERT (ip->checksum == ip4_header_checksum (ip)); + + if (PREDICT_FALSE (vlib_get_trace_count (vm, node) > 0)) + { + vlib_trace_buffer (vm, node, FLOWPERPKT_IPV4_NEXT_LOOKUP, b0, + 0 /* follow chain */ ); + flowperpkt_ipv4_trace_t *t = + vlib_add_trace (vm, node, b0, sizeof (*t)); + t->rx_sw_if_index = vnet_buffer (b0)->sw_if_index[VLIB_RX]; + t->tx_sw_if_index = vnet_buffer (b0)->sw_if_index[VLIB_TX]; + t->src_address = 0; + t->dst_address = 0; + t->tos = 0; + t->timestamp = 0; + t->buffer_size = b0->current_length; + } + + vlib_put_frame_to_node (vm, ip4_lookup_node.index, + fm->ipv4_frames_per_worker[my_cpu_number]); + fm->ipv4_frames_per_worker[my_cpu_number] = 0; + fm->ipv4_buffers_per_worker[my_cpu_number] = 0; + offset = 0; + } + + fm->ipv4_next_record_offset_per_worker[my_cpu_number] = offset; +} + +void +flowperpkt_flush_callback_ipv4 (void) +{ + vlib_main_t *vm = vlib_get_main (); + flowperpkt_main_t *fm = &flowperpkt_main; + vlib_node_runtime_t *node; + node = vlib_node_get_runtime (vm, flowperpkt_ipv4_node.index); + + add_to_flow_record_ipv4 (vm, node, fm, 0 /* rx_sw_if_index */ , + 0 /* tx_sw_if_index */ , + 0 /* src_address */ , + 0 /* dst_address */ , + 0 /* ToS */ , + 0ULL /* timestamp */ , + 0 /* length */ , + 1 /* do_flush */ ); +} + + +static uword +flowperpkt_ipv4_node_fn (vlib_main_t * vm, + vlib_node_runtime_t * node, vlib_frame_t * frame) +{ + u32 n_left_from, *from, *to_next; + flowperpkt_ipv4_next_t next_index; + flowperpkt_main_t *fm = &flowperpkt_main; + u64 now; + + now = (u64) ((vlib_time_now (vm) - fm->vlib_time_0) * 1e9); + now += fm->nanosecond_time_0; + + from = vlib_frame_vector_args (frame); + n_left_from = frame->n_vectors; + next_index = node->cached_next_index; + + while (n_left_from > 0) + { + u32 n_left_to_next; + + vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next); + + while (n_left_from >= 4 && n_left_to_next >= 2) + { + u32 next0 = FLOWPERPKT_IPV4_NEXT_DROP; + u32 next1 = FLOWPERPKT_IPV4_NEXT_DROP; + ip4_header_t *ip0, *ip1; + u16 len0, len1; + u32 bi0, bi1; + vlib_buffer_t *b0, *b1; + + /* Prefetch next iteration. */ + { + vlib_buffer_t *p2, *p3; + + p2 = vlib_get_buffer (vm, from[2]); + p3 = vlib_get_buffer (vm, from[3]); + + vlib_prefetch_buffer_header (p2, LOAD); + vlib_prefetch_buffer_header (p3, LOAD); + + CLIB_PREFETCH (p2->data, CLIB_CACHE_LINE_BYTES, STORE); + CLIB_PREFETCH (p3->data, CLIB_CACHE_LINE_BYTES, STORE); + } + + /* speculatively enqueue b0 and b1 to the current next frame */ + to_next[0] = bi0 = from[0]; + to_next[1] = bi1 = from[1]; + from += 2; + to_next += 2; + n_left_from -= 2; + n_left_to_next -= 2; + + b0 = vlib_get_buffer (vm, bi0); + b1 = vlib_get_buffer (vm, bi1); + + vnet_feature_next (vnet_buffer (b0)->sw_if_index[VLIB_TX], + &next0, b0); + vnet_feature_next (vnet_buffer (b1)->sw_if_index[VLIB_TX], + &next1, b1); + + ip0 = (ip4_header_t *) ((u8 *) vlib_buffer_get_current (b0) + + vnet_buffer (b0)->ip.save_rewrite_length); + + len0 = vlib_buffer_length_in_chain (vm, b0); + + if (PREDICT_TRUE ((b0->flags & VLIB_BUFFER_FLOW_REPORT) == 0)) + add_to_flow_record_ipv4 (vm, node, fm, + vnet_buffer (b0)->sw_if_index[VLIB_RX], + vnet_buffer (b0)->sw_if_index[VLIB_TX], + ip0->src_address.as_u32, + ip0->dst_address.as_u32, + ip0->tos, now, len0, 0 /* flush */ ); + + ip1 = (ip4_header_t *) ((u8 *) vlib_buffer_get_current (b1) + + vnet_buffer (b1)->ip.save_rewrite_length); + len1 = vlib_buffer_length_in_chain (vm, b1); + + if (PREDICT_TRUE ((b1->flags & VLIB_BUFFER_FLOW_REPORT) == 0)) + add_to_flow_record_ipv4 (vm, node, fm, + vnet_buffer (b1)->sw_if_index[VLIB_RX], + vnet_buffer (b1)->sw_if_index[VLIB_TX], + ip1->src_address.as_u32, + ip1->dst_address.as_u32, + ip1->tos, now, len1, 0 /* flush */ ); + + if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE))) + { + if (b0->flags & VLIB_BUFFER_IS_TRACED) + { + flowperpkt_ipv4_trace_t *t = + vlib_add_trace (vm, node, b0, sizeof (*t)); + t->rx_sw_if_index = vnet_buffer (b0)->sw_if_index[VLIB_RX]; + t->tx_sw_if_index = vnet_buffer (b0)->sw_if_index[VLIB_TX]; + t->src_address = ip0->src_address.as_u32; + t->dst_address = ip0->dst_address.as_u32; + t->tos = ip0->tos; + t->timestamp = now; + t->buffer_size = len0; + } + if (b1->flags & VLIB_BUFFER_IS_TRACED) + { + flowperpkt_ipv4_trace_t *t = + vlib_add_trace (vm, node, b1, sizeof (*t)); + t->rx_sw_if_index = vnet_buffer (b1)->sw_if_index[VLIB_RX]; + t->tx_sw_if_index = vnet_buffer (b1)->sw_if_index[VLIB_TX]; + t->src_address = ip1->src_address.as_u32; + t->dst_address = ip1->dst_address.as_u32; + t->tos = ip1->tos; + t->timestamp = now; + t->buffer_size = len1; + } + } + + /* verify speculative enqueues, maybe switch current next frame */ + vlib_validate_buffer_enqueue_x2 (vm, node, next_index, + to_next, n_left_to_next, + bi0, bi1, next0, next1); + } + + while (n_left_from > 0 && n_left_to_next > 0) + { + u32 bi0; + vlib_buffer_t *b0; + u32 next0 = FLOWPERPKT_IPV4_NEXT_DROP; + ip4_header_t *ip0; + u16 len0; + + /* speculatively enqueue b0 to the current next frame */ + bi0 = from[0]; + to_next[0] = bi0; + from += 1; + to_next += 1; + n_left_from -= 1; + n_left_to_next -= 1; + + b0 = vlib_get_buffer (vm, bi0); + + vnet_feature_next (vnet_buffer (b0)->sw_if_index[VLIB_TX], + &next0, b0); + + ip0 = (ip4_header_t *) ((u8 *) vlib_buffer_get_current (b0) + + vnet_buffer (b0)->ip.save_rewrite_length); + /* + * egressInterface, TLV type 14, u32 + * ipClassOfService, TLV type 5, u8 + * flowStartNanoseconds, TLV type 156, dateTimeNanoseconds (f64) + * Implementation: f64 nanoseconds since VPP started + * dataLinkFrameSize, TLV type 312, u16 + */ + len0 = vlib_buffer_length_in_chain (vm, b0); + + if (PREDICT_TRUE ((b0->flags & VLIB_BUFFER_FLOW_REPORT) == 0)) + add_to_flow_record_ipv4 (vm, node, fm, + vnet_buffer (b0)->sw_if_index[VLIB_RX], + vnet_buffer (b0)->sw_if_index[VLIB_TX], + ip0->src_address.as_u32, + ip0->dst_address.as_u32, + ip0->tos, now, len0, 0 /* flush */ ); + + if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE) + && (b0->flags & VLIB_BUFFER_IS_TRACED))) + { + flowperpkt_ipv4_trace_t *t = + vlib_add_trace (vm, node, b0, sizeof (*t)); + t->rx_sw_if_index = vnet_buffer (b0)->sw_if_index[VLIB_RX]; + t->tx_sw_if_index = vnet_buffer (b0)->sw_if_index[VLIB_TX]; + t->src_address = ip0->src_address.as_u32; + t->dst_address = ip0->dst_address.as_u32; + t->tos = ip0->tos; + t->timestamp = now; + t->buffer_size = len0; + } + + /* verify speculative enqueue, maybe switch current next frame */ + vlib_validate_buffer_enqueue_x1 (vm, node, next_index, + to_next, n_left_to_next, + bi0, next0); + } + + vlib_put_next_frame (vm, node, next_index, n_left_to_next); + } + return frame->n_vectors; +} + +/** + * @brief IPFIX ipv4 flow-per-packet graph node + * @node flowperpkt-ipv4 + * + * This is the IPFIX flow-record-per-packet node. + * + * @param vm vlib_main_t corresponding to the current thread. + * @param node vlib_node_runtime_t data for this node. + * @param frame vlib_frame_t whose contents should be dispatched. + * + * @par Graph mechanics: buffer metadata, next index usage + * + * Uses: + * - vnet_buffer(b)->ip.save_rewrite_length + * - tells the node the length of the rewrite which was applied in + * ip4/6_rewrite_inline, allows the code to find the IP header without + * having to parse L2 headers, or make stupid assumptions about their + * length. + * - vnet_buffer(b)->flags & VLIB_BUFFER_FLOW_REPORT + * - Used to suppress flow record generation for flow record packets. + * + * Sets: + * - vnet_buffer(b)->flags & VLIB_BUFFER_FLOW_REPORT + * - To suppress flow record generation for flow record packets + * + * Next Index: + * - Next configured output feature on the interface, usually + * "interface-output." Generated flow records head for ip4-lookup + */ + +/* *INDENT-OFF* */ +VLIB_REGISTER_NODE (flowperpkt_ipv4_node) = { + .function = flowperpkt_ipv4_node_fn, + .name = "flowperpkt-ipv4", + .vector_size = sizeof (u32), + .format_trace = format_flowperpkt_ipv4_trace, + .type = VLIB_NODE_TYPE_INTERNAL, + + .n_errors = ARRAY_LEN(flowperpkt_ipv4_error_strings), + .error_strings = flowperpkt_ipv4_error_strings, + + .n_next_nodes = FLOWPERPKT_IPV4_N_NEXT, + + /* edit / add dispositions here */ + .next_nodes = { + [FLOWPERPKT_IPV4_NEXT_DROP] = "error-drop", + /* Used only to trace ipfix data packets */ + [FLOWPERPKT_IPV4_NEXT_LOOKUP] = "ip4-lookup", + }, +}; +/* *INDENT-ON* */ + +/* + * fd.io coding-style-patch-verification: ON + * + * Local Variables: + * eval: (c-set-style "gnu") + * End: + */ diff --git a/src/plugins/ila.am b/src/plugins/ila.am new file mode 100644 index 00000000..d900f3eb --- /dev/null +++ b/src/plugins/ila.am @@ -0,0 +1,20 @@ +# Copyright (c) 2016 Cisco Systems, Inc. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +vppplugins_LTLIBRARIES += ila_plugin.la + +ila_plugin_la_SOURCES = ila/ila.c + +noinst_HEADERS += ila/ila.h + +# vi:syntax=automake diff --git a/src/plugins/ila/ila.c b/src/plugins/ila/ila.c new file mode 100644 index 00000000..336f4cf5 --- /dev/null +++ b/src/plugins/ila/ila.c @@ -0,0 +1,1070 @@ +/* + * Copyright (c) 2016 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include +#include + +static ila_main_t ila_main; + +#define ILA_TABLE_DEFAULT_HASH_NUM_BUCKETS (64 * 1024) +#define ILA_TABLE_DEFAULT_HASH_MEMORY_SIZE (32<<20) + +#define foreach_ila_error \ + _(NONE, "valid ILA packets") + +typedef enum { +#define _(sym,str) ILA_ERROR_##sym, + foreach_ila_error +#undef _ + ILA_N_ERROR, +} ila_error_t; + +static char *ila_error_strings[] = { +#define _(sym,string) string, + foreach_ila_error +#undef _ +}; + +typedef enum { + ILA_ILA2SIR_NEXT_DROP, + ILA_ILA2SIR_N_NEXT, +} ila_ila2sir_next_t; + +typedef struct { + u32 ila_index; + ip6_address_t initial_dst; + u32 adj_index; +} ila_ila2sir_trace_t; + +static ila_entry_t ila_sir2ila_default_entry = { + .csum_mode = ILA_CSUM_MODE_NO_ACTION, + .type = ILA_TYPE_IID, + .dir = ILA_DIR_ILA2SIR, //Will pass the packet with no +}; + +/** + * @brief Dynamically registered DPO Type for ILA + */ +static dpo_type_t ila_dpo_type; + +/** + * @brief Dynamically registered FIB node type for ILA + */ +static fib_node_type_t ila_fib_node_type; + +u8 * +format_half_ip6_address (u8 * s, va_list * va) +{ + u64 v = clib_net_to_host_u64 (va_arg (*va, u64)); + + return format (s, "%04x:%04x:%04x:%04x", + v >> 48, (v >> 32) & 0xffff, (v >> 16) & 0xffff, v & 0xffff); + +} + +u8 * +format_ila_direction (u8 * s, va_list * args) +{ + ila_direction_t t = va_arg (*args, ila_direction_t); +#define _(i,n,st) \ + if (t == ILA_DIR_##i) \ + return format(s, st); + ila_foreach_direction +#undef _ + return format (s, "invalid_ila_direction"); +} + +static u8 * +format_csum_mode (u8 * s, va_list * va) +{ + ila_csum_mode_t csum_mode = va_arg (*va, ila_csum_mode_t); + char *txt; + + switch (csum_mode) + { +#define _(i,n,st) \ + case ILA_CSUM_MODE_##i: \ + txt = st; \ + break; + ila_csum_foreach_type +#undef _ + default: + txt = "invalid_ila_csum_mode"; + break; + } + return format (s, txt); +} + +u8 * +format_ila_type (u8 * s, va_list * args) +{ + ila_type_t t = va_arg (*args, ila_type_t); +#define _(i,n,st) \ + if (t == ILA_TYPE_##i) \ + return format(s, st); + ila_foreach_type +#undef _ + return format (s, "invalid_ila_type"); +} + +static u8 * +format_ila_entry (u8 * s, va_list * va) +{ + vnet_main_t *vnm = va_arg (*va, vnet_main_t *); + ila_entry_t *e = va_arg (*va, ila_entry_t *); + + if (!e) + { + return format (s, "%-15s%=40s%=40s%+16s%+18s%+11s", "Type", "SIR Address", + "ILA Address", "Checksum Mode", "Direction", "Next DPO"); + } + else if (vnm) + { + if (ip6_address_is_zero(&e->next_hop)) + { + return format (s, "%-15U%=40U%=40U%18U%11U%s", + format_ila_type, e->type, + format_ip6_address, &e->sir_address, + format_ip6_address, &e->ila_address, + format_csum_mode, e->csum_mode, + format_ila_direction, e->dir, + "n/a"); + } + else + { + return format (s, "%-15U%=40U%=40U%18U%11U%U", + format_ila_type, e->type, + format_ip6_address, &e->sir_address, + format_ip6_address, &e->ila_address, + format_csum_mode, e->csum_mode, + format_ila_direction, e->dir, + format_dpo_id, &e->ila_dpo, 0); + } + } + + return NULL; +} + +u8 * +format_ila_ila2sir_trace (u8 * s, va_list * args) +{ + CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *); + CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *); + ila_ila2sir_trace_t *t = va_arg (*args, ila_ila2sir_trace_t *); + return format (s, + "ILA -> SIR adj index: %d entry index: %d initial_dst: %U", + t->adj_index, t->ila_index, format_ip6_address, + &t->initial_dst); +} + +static uword +unformat_ila_direction (unformat_input_t * input, va_list * args) +{ + ila_direction_t *result = va_arg (*args, ila_direction_t *); +#define _(i,n,s) \ + if (unformat(input, s)) \ + { \ + *result = ILA_DIR_##i; \ + return 1;\ + } + + ila_foreach_direction +#undef _ + return 0; +} + +static uword +unformat_ila_type (unformat_input_t * input, va_list * args) +{ + ila_type_t *result = va_arg (*args, ila_type_t *); +#define _(i,n,s) \ + if (unformat(input, s)) \ + { \ + *result = ILA_TYPE_##i; \ + return 1;\ + } + + ila_foreach_type +#undef _ + return 0; +} + +static uword +unformat_ila_csum_mode (unformat_input_t * input, va_list * args) +{ + ila_csum_mode_t *result = va_arg (*args, ila_csum_mode_t *); + if (unformat (input, "none") || unformat (input, "no-action")) + { + *result = ILA_CSUM_MODE_NO_ACTION; + return 1; + } + if (unformat (input, "neutral-map")) + { + *result = ILA_CSUM_MODE_NEUTRAL_MAP; + return 1; + } + if (unformat (input, "adjust-transport")) + { + *result = ILA_CSUM_MODE_ADJUST_TRANSPORT; + return 1; + } + return 0; +} + +static uword +unformat_half_ip6_address (unformat_input_t * input, va_list * args) +{ + u64 *result = va_arg (*args, u64 *); + u32 a[4]; + + if (!unformat (input, "%x:%x:%x:%x", &a[0], &a[1], &a[2], &a[3])) + return 0; + + if (a[0] > 0xFFFF || a[1] > 0xFFFF || a[2] > 0xFFFF || a[3] > 0xFFFF) + return 0; + + *result = clib_host_to_net_u64 ((((u64) a[0]) << 48) | + (((u64) a[1]) << 32) | + (((u64) a[2]) << 16) | (((u64) a[3]))); + + return 1; +} + +static vlib_node_registration_t ila_ila2sir_node; + +static uword +ila_ila2sir (vlib_main_t * vm, + vlib_node_runtime_t * node, vlib_frame_t * frame) +{ + u32 n_left_from, *from, next_index, *to_next, n_left_to_next; + ila_main_t *ilm = &ila_main; + + from = vlib_frame_vector_args (frame); + n_left_from = frame->n_vectors; + next_index = node->cached_next_index; + + while (n_left_from > 0) + { + vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next); + + while (n_left_from >= 4 && n_left_to_next >= 2) + { + u32 pi0, pi1; + vlib_buffer_t *p0, *p1; + ila_entry_t *ie0, *ie1; + ip6_header_t *ip60, *ip61; + ip6_address_t *sir_address0, *sir_address1; + + { + vlib_buffer_t *p2, *p3; + + p2 = vlib_get_buffer (vm, from[2]); + p3 = vlib_get_buffer (vm, from[3]); + + vlib_prefetch_buffer_header (p2, LOAD); + vlib_prefetch_buffer_header (p3, LOAD); + CLIB_PREFETCH (p2->data, sizeof (ip6_header_t), LOAD); + CLIB_PREFETCH (p3->data, sizeof (ip6_header_t), LOAD); + } + + pi0 = to_next[0] = from[0]; + pi1 = to_next[1] = from[1]; + from += 2; + n_left_from -= 2; + to_next += 2; + n_left_to_next -= 2; + + p0 = vlib_get_buffer (vm, pi0); + p1 = vlib_get_buffer (vm, pi1); + ip60 = vlib_buffer_get_current (p0); + ip61 = vlib_buffer_get_current (p1); + sir_address0 = &ip60->dst_address; + sir_address1 = &ip61->dst_address; + ie0 = pool_elt_at_index (ilm->entries, + vnet_buffer (p0)->ip.adj_index[VLIB_TX]); + ie1 = pool_elt_at_index (ilm->entries, + vnet_buffer (p1)->ip.adj_index[VLIB_TX]); + + if (PREDICT_FALSE (p0->flags & VLIB_BUFFER_IS_TRACED)) + { + ila_ila2sir_trace_t *tr = + vlib_add_trace (vm, node, p0, sizeof (*tr)); + tr->ila_index = ie0 - ilm->entries; + tr->initial_dst = ip60->dst_address; + tr->adj_index = vnet_buffer (p0)->ip.adj_index[VLIB_TX]; + } + + if (PREDICT_FALSE (p1->flags & VLIB_BUFFER_IS_TRACED)) + { + ila_ila2sir_trace_t *tr = + vlib_add_trace (vm, node, p1, sizeof (*tr)); + tr->ila_index = ie1 - ilm->entries; + tr->initial_dst = ip61->dst_address; + tr->adj_index = vnet_buffer (p1)->ip.adj_index[VLIB_TX]; + } + + sir_address0 = (ie0->dir != ILA_DIR_SIR2ILA) ? &ie0->sir_address : sir_address0; + sir_address1 = (ie1->dir != ILA_DIR_SIR2ILA) ? &ie1->sir_address : sir_address1; + ip60->dst_address.as_u64[0] = sir_address0->as_u64[0]; + ip60->dst_address.as_u64[1] = sir_address0->as_u64[1]; + ip61->dst_address.as_u64[0] = sir_address1->as_u64[0]; + ip61->dst_address.as_u64[1] = sir_address1->as_u64[1]; + + vnet_buffer (p0)->ip.adj_index[VLIB_TX] = ie0->ila_dpo.dpoi_index; + vnet_buffer (p1)->ip.adj_index[VLIB_TX] = ie1->ila_dpo.dpoi_index; + + vlib_validate_buffer_enqueue_x2 (vm, node, next_index, to_next, + n_left_to_next, pi0, pi1, + ie0->ila_dpo.dpoi_next_node, + ie1->ila_dpo.dpoi_next_node); + } + + /* Single loop */ + while (n_left_from > 0 && n_left_to_next > 0) + { + u32 pi0; + vlib_buffer_t *p0; + ila_entry_t *ie0; + ip6_header_t *ip60; + ip6_address_t *sir_address0; + + pi0 = to_next[0] = from[0]; + from += 1; + n_left_from -= 1; + to_next += 1; + n_left_to_next -= 1; + + p0 = vlib_get_buffer (vm, pi0); + ip60 = vlib_buffer_get_current (p0); + sir_address0 = &ip60->dst_address; + ie0 = pool_elt_at_index (ilm->entries, + vnet_buffer (p0)->ip.adj_index[VLIB_TX]); + + if (PREDICT_FALSE (p0->flags & VLIB_BUFFER_IS_TRACED)) + { + ila_ila2sir_trace_t *tr = + vlib_add_trace (vm, node, p0, sizeof (*tr)); + tr->ila_index = ie0 ? (ie0 - ilm->entries) : ~0; + tr->initial_dst = ip60->dst_address; + tr->adj_index = vnet_buffer (p0)->ip.adj_index[VLIB_TX]; + } + + sir_address0 = (ie0->dir != ILA_DIR_SIR2ILA) ? &ie0->sir_address : sir_address0; + ip60->dst_address.as_u64[0] = sir_address0->as_u64[0]; + ip60->dst_address.as_u64[1] = sir_address0->as_u64[1]; + vnet_buffer (p0)->ip.adj_index[VLIB_TX] = ie0->ila_dpo.dpoi_index; + + vlib_validate_buffer_enqueue_x1 (vm, node, next_index, to_next, + n_left_to_next, pi0, + ie0->ila_dpo.dpoi_next_node); + } + vlib_put_next_frame (vm, node, next_index, n_left_to_next); + } + + return frame->n_vectors; +} + +/** *INDENT-OFF* */ +VLIB_REGISTER_NODE (ila_ila2sir_node, static) = +{ + .function = ila_ila2sir, + .name = "ila-to-sir", + .vector_size = sizeof (u32), + .format_trace = format_ila_ila2sir_trace, + .n_errors = ILA_N_ERROR, + .error_strings = ila_error_strings, + .n_next_nodes = ILA_ILA2SIR_N_NEXT, + .next_nodes = + { + [ILA_ILA2SIR_NEXT_DROP] = "error-drop" + }, +}; +/** *INDENT-ON* */ + +typedef enum +{ + ILA_SIR2ILA_NEXT_DROP, + ILA_SIR2ILA_N_NEXT, +} ila_sir2ila_next_t; + +typedef struct +{ + u32 ila_index; + ip6_address_t initial_dst; +} ila_sir2ila_trace_t; + +u8 * +format_ila_sir2ila_trace (u8 * s, va_list * args) +{ + CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *); + CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *); + ila_sir2ila_trace_t *t = va_arg (*args, ila_sir2ila_trace_t *); + + return format (s, "SIR -> ILA entry index: %d initial_dst: %U", + t->ila_index, format_ip6_address, &t->initial_dst); +} + +static vlib_node_registration_t ila_sir2ila_node; + +static uword +ila_sir2ila (vlib_main_t * vm, + vlib_node_runtime_t * node, vlib_frame_t * frame) +{ + u32 n_left_from, *from, next_index, *to_next, n_left_to_next; + ila_main_t *ilm = &ila_main; + + from = vlib_frame_vector_args (frame); + n_left_from = frame->n_vectors; + next_index = node->cached_next_index; + + while (n_left_from > 0) + { + vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next); + + while (n_left_from >= 4 && n_left_to_next >= 2) + { + u32 pi0, pi1; + vlib_buffer_t *p0, *p1; + ip6_header_t *ip60, *ip61; + u32 next0 = ILA_SIR2ILA_NEXT_DROP; + u32 next1 = ILA_SIR2ILA_NEXT_DROP; + BVT (clib_bihash_kv) kv0, value0; + BVT (clib_bihash_kv) kv1, value1; + ila_entry_t *ie0 = &ila_sir2ila_default_entry; + ila_entry_t *ie1 = &ila_sir2ila_default_entry; + ip6_address_t *ila_address0, *ila_address1; + + { + vlib_buffer_t *p2, *p3; + + p2 = vlib_get_buffer (vm, from[2]); + p3 = vlib_get_buffer (vm, from[3]); + + vlib_prefetch_buffer_header (p2, LOAD); + vlib_prefetch_buffer_header (p3, LOAD); + CLIB_PREFETCH (p2->data, sizeof (ip6_header_t), LOAD); + CLIB_PREFETCH (p3->data, sizeof (ip6_header_t), LOAD); + } + + pi0 = to_next[0] = from[0]; + pi1 = to_next[1] = from[1]; + from += 2; + n_left_from -= 2; + to_next += 2; + n_left_to_next -= 2; + + p0 = vlib_get_buffer (vm, pi0); + p1 = vlib_get_buffer (vm, pi1); + ip60 = vlib_buffer_get_current (p0); + ip61 = vlib_buffer_get_current (p1); + ila_address0 = &ip60->dst_address; + ila_address1 = &ip61->dst_address; + kv0.key[0] = ip60->dst_address.as_u64[0]; + kv0.key[1] = ip60->dst_address.as_u64[1]; + kv0.key[2] = 0; + kv1.key[0] = ip61->dst_address.as_u64[0]; + kv1.key[1] = ip61->dst_address.as_u64[1]; + kv1.key[2] = 0; + + if (PREDICT_TRUE((BV (clib_bihash_search) + (&ilm->id_to_entry_table, &kv0, &value0)) == 0)) { + ie0 = &ilm->entries[value0.value]; + ila_address0 = (ie0->dir != ILA_DIR_ILA2SIR) ? &ie0->ila_address : ila_address0; + } + + if ((BV (clib_bihash_search) + (&ilm->id_to_entry_table, &kv1, &value1)) == 0) { + ie1 = &ilm->entries[value1.value]; + ila_address1 = (ie1->dir != ILA_DIR_ILA2SIR) ? &ie1->ila_address : ila_address1; + } + + if (PREDICT_FALSE (p0->flags & VLIB_BUFFER_IS_TRACED)) + { + ila_sir2ila_trace_t *tr = + vlib_add_trace (vm, node, p0, sizeof (*tr)); + tr->ila_index = + (ie0 != &ila_sir2ila_default_entry) ? (ie0 - ilm->entries) : ~0; + tr->initial_dst = ip60->dst_address; + } + + if (PREDICT_FALSE (p1->flags & VLIB_BUFFER_IS_TRACED)) + { + ila_sir2ila_trace_t *tr = + vlib_add_trace (vm, node, p1, sizeof (*tr)); + tr->ila_index = + (ie1 != &ila_sir2ila_default_entry) ? (ie1 - ilm->entries) : ~0; + tr->initial_dst = ip61->dst_address; + } + + ip60->dst_address.as_u64[0] = ila_address0->as_u64[0]; + ip60->dst_address.as_u64[1] = ila_address0->as_u64[1]; + ip61->dst_address.as_u64[0] = ila_address1->as_u64[0]; + ip61->dst_address.as_u64[1] = ila_address1->as_u64[1]; + + vnet_feature_next (vnet_buffer (p0)->sw_if_index[VLIB_RX], &next0, p0); + vnet_feature_next (vnet_buffer (p1)->sw_if_index[VLIB_RX], &next1, p1); + + vlib_validate_buffer_enqueue_x2 (vm, node, next_index, to_next, + n_left_to_next, pi0, pi1, next0, + next1); + } + + /* Single loop */ + while (n_left_from > 0 && n_left_to_next > 0) + { + u32 pi0; + vlib_buffer_t *p0; + ip6_header_t *ip60; + u32 next0 = ILA_SIR2ILA_NEXT_DROP; + BVT (clib_bihash_kv) kv0, value0; + ila_entry_t *ie0 = &ila_sir2ila_default_entry; + ip6_address_t *ila_address0; + + pi0 = to_next[0] = from[0]; + from += 1; + n_left_from -= 1; + to_next += 1; + n_left_to_next -= 1; + + p0 = vlib_get_buffer (vm, pi0); + ip60 = vlib_buffer_get_current (p0); + ila_address0 = &ip60->dst_address; + + kv0.key[0] = ip60->dst_address.as_u64[0]; + kv0.key[1] = ip60->dst_address.as_u64[1]; + kv0.key[2] = 0; + + if (PREDICT_TRUE((BV (clib_bihash_search) + (&ilm->id_to_entry_table, &kv0, &value0)) == 0)) { + ie0 = &ilm->entries[value0.value]; + ila_address0 = (ie0->dir != ILA_DIR_ILA2SIR) ? &ie0->ila_address : ila_address0; + } + + if (PREDICT_FALSE (p0->flags & VLIB_BUFFER_IS_TRACED)) + { + ila_sir2ila_trace_t *tr = + vlib_add_trace (vm, node, p0, sizeof (*tr)); + tr->ila_index = + (ie0 != &ila_sir2ila_default_entry) ? (ie0 - ilm->entries) : ~0; + tr->initial_dst = ip60->dst_address; + } + + //This operation should do everything for any type (except vnid4 obviously) + ip60->dst_address.as_u64[0] = ila_address0->as_u64[0]; + ip60->dst_address.as_u64[1] = ila_address0->as_u64[1]; + + vnet_feature_next (vnet_buffer (p0)->sw_if_index[VLIB_RX], &next0, p0); + + vlib_validate_buffer_enqueue_x1 (vm, node, next_index, to_next, + n_left_to_next, pi0, next0); + } + vlib_put_next_frame (vm, node, next_index, n_left_to_next); + } + + return frame->n_vectors; +} + +/** *INDENT-OFF* */ +VLIB_REGISTER_NODE (ila_sir2ila_node, static) = +{ + .function = ila_sir2ila,.name = "sir-to-ila", + .vector_size = sizeof (u32), + .format_trace = format_ila_sir2ila_trace, + .n_errors = ILA_N_ERROR, + .error_strings = ila_error_strings, + .n_next_nodes = ILA_SIR2ILA_N_NEXT, + .next_nodes = + { + [ILA_SIR2ILA_NEXT_DROP] = "error-drop" + }, +}; +/** *INDENT-ON* */ + +/** *INDENT-OFF* */ +VNET_FEATURE_INIT (ila_sir2ila, static) = +{ + .arc_name = "ip6-unicast", + .node_name = "sir-to-ila", + .runs_before = VNET_FEATURES ("ip6-lookup"), +}; +/** *INDENT-ON* */ + +static void +ila_entry_stack (ila_entry_t *ie) +{ + /* + * restack on the next-hop's FIB entry + */ + dpo_stack(ila_dpo_type, + DPO_PROTO_IP6, + &ie->ila_dpo, + fib_entry_contribute_ip_forwarding( + ie->next_hop_fib_entry_index)); +} + +int +ila_add_del_entry (ila_add_del_entry_args_t * args) +{ + ila_main_t *ilm = &ila_main; + BVT (clib_bihash_kv) kv, value; + + //Sanity check + if (args->type == ILA_TYPE_IID || args->type == ILA_TYPE_LUID) + { + if ((args->sir_address.as_u8[8] >> 5) != args->type) + { + clib_warning ("Incorrect SIR address (ILA type mismatch %d %d)", + args->sir_address.as_u8[8] >> 1, args->type); + return -1; + } + if (args->sir_address.as_u8[8] & 0x10) + { + clib_warning ("Checksum bit should not be set in SIR address"); + return -1; + } + } + else if (args->type == ILA_TYPE_VNIDM) + { + if (args->sir_address.as_u8[0] != 0xff || + (args->sir_address.as_u8[1] & 0xf0) != 0xf0) + { + clib_warning ("SIR multicast address must start with fff"); + return -1; + } + if (args->sir_address.as_u16[1] || args->sir_address.as_u16[2] || + args->sir_address.as_u16[3] || args->sir_address.as_u16[4] || + args->sir_address.as_u16[5] || (args->sir_address.as_u8[12] & 0xf0)) + { + clib_warning ("SIR multicast address must start with fff"); + return -1; + } + } + + if (!args->is_del) + { + ila_entry_t *e; + pool_get (ilm->entries, e); + e->type = args->type; + e->sir_address = args->sir_address; + e->next_hop = args->next_hop_address; + e->csum_mode = args->csum_mode; + e->dir = args->dir; + + //Construct ILA address + switch (e->type) + { + case ILA_TYPE_IID: + e->ila_address = e->sir_address; + break; + case ILA_TYPE_LUID: + e->ila_address.as_u64[0] = args->locator; + e->ila_address.as_u64[1] = args->sir_address.as_u64[1]; + break; + case ILA_TYPE_VNID6: + e->ila_address.as_u64[0] = args->locator; + e->ila_address.as_u8[8] = (ILA_TYPE_VNID6 << 1); + e->ila_address.as_u32[2] |= args->vnid; + e->ila_address.as_u32[3] = args->sir_address.as_u32[3]; + break; + case ILA_TYPE_VNIDM: + e->ila_address.as_u64[0] = args->locator; + e->ila_address.as_u8[8] = (ILA_TYPE_VNIDM << 1); + e->ila_address.as_u32[2] |= args->vnid; + e->ila_address.as_u32[3] = args->sir_address.as_u32[3]; + e->ila_address.as_u8[12] |= args->sir_address.as_u8[2] << 4; + break; + case ILA_TYPE_VNID4: + clib_warning ("ILA type '%U' is not supported", format_ila_type, + e->type); + return -1; + } + + //Modify ILA checksum if necessary + if (e->csum_mode == ILA_CSUM_MODE_NEUTRAL_MAP) + { + ip_csum_t csum = e->ila_address.as_u16[7]; + int i; + for (i = 0; i < 4; i++) + { + csum = ip_csum_sub_even (csum, e->sir_address.as_u32[i]); + csum = ip_csum_add_even (csum, e->ila_address.as_u32[i]); + } + csum = ip_csum_add_even (csum, clib_host_to_net_u16 (0x1000)); + e->ila_address.as_u16[7] = ip_csum_fold (csum); + e->ila_address.as_u8[8] |= 0x10; + } + + //Create entry with the sir address + kv.key[0] = e->sir_address.as_u64[0]; + kv.key[1] = e->sir_address.as_u64[1]; + kv.key[2] = 0; + kv.value = e - ilm->entries; + BV (clib_bihash_add_del) (&ilm->id_to_entry_table, &kv, + 1 /* is_add */ ); + + if (!ip6_address_is_zero(&e->next_hop)) + { + /* + * become a child of the FIB netry for the next-hop + * so we are informed when its forwarding changes + */ + fib_prefix_t next_hop = { + .fp_addr = { + .ip6 = e->next_hop, + }, + .fp_len = 128, + .fp_proto = FIB_PROTOCOL_IP6, + }; + + e->next_hop_fib_entry_index = + fib_table_entry_special_add(0, + &next_hop, + FIB_SOURCE_RR, + FIB_ENTRY_FLAG_NONE, + ADJ_INDEX_INVALID); + e->next_hop_child_index = + fib_entry_child_add(e->next_hop_fib_entry_index, + ila_fib_node_type, + e - ilm->entries); + + /* + * Create a route that results in the ILA entry + */ + dpo_id_t dpo = DPO_INVALID; + fib_prefix_t pfx = { + .fp_addr = { + .ip6 = e->ila_address, + }, + .fp_len = 128, + .fp_proto = FIB_PROTOCOL_IP6, + }; + + dpo_set(&dpo, ila_dpo_type, DPO_PROTO_IP6, e - ilm->entries); + + fib_table_entry_special_dpo_add(0, + &pfx, + FIB_SOURCE_PLUGIN_HI, + FIB_ENTRY_FLAG_EXCLUSIVE, + &dpo); + dpo_reset(&dpo); + + /* + * finally stack the ILA entry so it will forward to the next-hop + */ + ila_entry_stack (e); + } + } + else + { + ila_entry_t *e; + kv.key[0] = args->sir_address.as_u64[0]; + kv.key[1] = args->sir_address.as_u64[1]; + kv.key[2] = 0; + + if ((BV (clib_bihash_search) (&ilm->id_to_entry_table, &kv, &value) < + 0)) + { + return -1; + } + + e = &ilm->entries[value.value]; + + if (!ip6_address_is_zero(&e->next_hop)) + { + fib_prefix_t pfx = { + .fp_addr = { + .ip6 = e->ila_address, + }, + .fp_len = 128, + .fp_proto = FIB_PROTOCOL_IP6, + }; + + fib_table_entry_special_remove(0, &pfx, FIB_SOURCE_PLUGIN_HI); + /* + * remove this ILA entry as child of the FIB netry for the next-hop + */ + fib_entry_child_remove(e->next_hop_fib_entry_index, + e->next_hop_child_index); + fib_table_entry_delete_index(e->next_hop_fib_entry_index, + FIB_SOURCE_RR); + e->next_hop_fib_entry_index = FIB_NODE_INDEX_INVALID; + } + dpo_reset (&e->ila_dpo); + + BV (clib_bihash_add_del) (&ilm->id_to_entry_table, &kv, + 0 /* is_add */ ); + pool_put (ilm->entries, e); + } + return 0; +} + +int +ila_interface (u32 sw_if_index, u8 disable) +{ + vnet_feature_enable_disable ("ip4-unicast", "sir-to-ila", sw_if_index, + !disable, 0, 0); + return 0; +} + +clib_error_t * +vlib_plugin_register (vlib_main_t * vm, vnet_plugin_handoff_t * h, + int from_early_init) +{ + clib_error_t *error = 0; + + return error; +} + +u8 *format_ila_dpo (u8 * s, va_list * va) +{ + index_t index = va_arg (*va, index_t); + CLIB_UNUSED(u32 indent) = va_arg (*va, u32); + ila_main_t *ilm = &ila_main; + ila_entry_t *ie = pool_elt_at_index (ilm->entries, index); + return format(s, "ILA: idx:%d sir:%U", + index, + format_ip6_address, &ie->sir_address); +} + +/** + * @brief no-op lock function. + * The lifetime of the ILA entry is managed by the control plane + */ +static void +ila_dpo_lock (dpo_id_t *dpo) +{ +} + +/** + * @brief no-op unlock function. + * The lifetime of the ILA entry is managed by the control plane + */ +static void +ila_dpo_unlock (dpo_id_t *dpo) +{ +} + +const static dpo_vft_t ila_vft = { + .dv_lock = ila_dpo_lock, + .dv_unlock = ila_dpo_unlock, + .dv_format = format_ila_dpo, +}; +const static char* const ila_ip6_nodes[] = +{ + "ila-to-sir", + NULL, +}; +const static char* const * const ila_nodes[DPO_PROTO_NUM] = +{ + [DPO_PROTO_IP6] = ila_ip6_nodes, +}; + +static fib_node_t * +ila_fib_node_get_node (fib_node_index_t index) +{ + ila_main_t *ilm = &ila_main; + ila_entry_t *ie = pool_elt_at_index (ilm->entries, index); + + return (&ie->ila_fib_node); +} + +/** + * @brief no-op unlock function. + * The lifetime of the ILA entry is managed by the control plane + */ +static void +ila_fib_node_last_lock_gone (fib_node_t *node) +{ +} + +static ila_entry_t * +ila_entry_from_fib_node (fib_node_t *node) +{ + return ((ila_entry_t*)(((char*)node) - + STRUCT_OFFSET_OF(ila_entry_t, ila_fib_node))); +} + +/** + * @brief + * Callback function invoked when the forwarding changes for the ILA next-hop + */ +static fib_node_back_walk_rc_t +ila_fib_node_back_walk_notify (fib_node_t *node, + fib_node_back_walk_ctx_t *ctx) +{ + ila_entry_stack(ila_entry_from_fib_node(node)); + + return (FIB_NODE_BACK_WALK_CONTINUE); +} + +/* + * ILA's FIB graph node virtual function table + */ +static const fib_node_vft_t ila_fib_node_vft = { + .fnv_get = ila_fib_node_get_node, + .fnv_last_lock = ila_fib_node_last_lock_gone, + .fnv_back_walk = ila_fib_node_back_walk_notify, +}; + +clib_error_t * +ila_init (vlib_main_t * vm) +{ + ila_main_t *ilm = &ila_main; + ilm->entries = NULL; + + ilm->lookup_table_nbuckets = ILA_TABLE_DEFAULT_HASH_NUM_BUCKETS; + ilm->lookup_table_nbuckets = 1 << max_log2 (ilm->lookup_table_nbuckets); + ilm->lookup_table_size = ILA_TABLE_DEFAULT_HASH_MEMORY_SIZE; + + BV (clib_bihash_init) (&ilm->id_to_entry_table, + "ila id to entry index table", + ilm->lookup_table_nbuckets, ilm->lookup_table_size); + + ila_dpo_type = dpo_register_new_type(&ila_vft, ila_nodes); + ila_fib_node_type = fib_node_register_new_type(&ila_fib_node_vft); + + return NULL; +} + +VLIB_INIT_FUNCTION (ila_init); + +static clib_error_t * +ila_entry_command_fn (vlib_main_t * vm, + unformat_input_t * input, vlib_cli_command_t * cmd) +{ + unformat_input_t _line_input, *line_input = &_line_input; + ila_add_del_entry_args_t args = { 0 }; + u8 next_hop_set = 0; + int ret; + + args.type = ILA_TYPE_IID; + args.csum_mode = ILA_CSUM_MODE_NO_ACTION; + args.local_adj_index = ~0; + args.dir = ILA_DIR_BIDIR; + + if (!unformat_user (input, unformat_line_input, line_input)) + return 0; + + while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) + { + if (unformat (line_input, "type %U", unformat_ila_type, &args.type)) + ; + else if (unformat + (line_input, "sir-address %U", unformat_ip6_address, + &args.sir_address)) + ; + else if (unformat + (line_input, "locator %U", unformat_half_ip6_address, + &args.locator)) + ; + else if (unformat + (line_input, "csum-mode %U", unformat_ila_csum_mode, + &args.csum_mode)) + ; + else if (unformat (line_input, "vnid %x", &args.vnid)) + ; + else if (unformat + (line_input, "next-hop %U", unformat_ip6_address, + &args.next_hop_address)) + ; + else if (unformat + (line_input, "direction %U", unformat_ila_direction, &args.dir)) + next_hop_set = 1; + else if (unformat (line_input, "del")) + args.is_del = 1; + else + return clib_error_return (0, "parse error: '%U'", + format_unformat_error, line_input); + } + + unformat_free (line_input); + + if (!next_hop_set) + return clib_error_return (0, "Specified a next hop"); + + if ((ret = ila_add_del_entry (&args))) + return clib_error_return (0, "ila_add_del_entry returned error %d", ret); + + return NULL; +} + +VLIB_CLI_COMMAND (ila_entry_command, static) = +{ + .path = "ila entry", + .short_help = "ila entry [type ] [sir-address
] [locator ] [vnid ]" + " [adj-index ] [next-hop ] [direction (bidir|sir2ila|ila2sir)]" + " [csum-mode (no-action|neutral-map|transport-adjust)] [del]", + .function = ila_entry_command_fn, +}; + +static clib_error_t * +ila_interface_command_fn (vlib_main_t * vm, + unformat_input_t * input, vlib_cli_command_t * cmd) +{ + vnet_main_t *vnm = vnet_get_main (); + u32 sw_if_index = ~0; + u8 disable = 0; + + if (!unformat (input, "%U", unformat_vnet_sw_interface, vnm, &sw_if_index)) + { + return clib_error_return (0, "Invalid interface name"); + } + + if (unformat (input, "disable")) + { + disable = 1; + } + + int ret; + if ((ret = ila_interface (sw_if_index, disable))) + return clib_error_return (0, "ila_interface returned error %d", ret); + + return NULL; +} + +VLIB_CLI_COMMAND (ila_interface_command, static) = +{ + .path = "ila interface", + .short_help = "ila interface [disable]", + .function = ila_interface_command_fn, +}; + +static clib_error_t * +ila_show_entries_command_fn (vlib_main_t * vm, + unformat_input_t * input, + vlib_cli_command_t * cmd) +{ + vnet_main_t *vnm = vnet_get_main (); + ila_main_t *ilm = &ila_main; + ila_entry_t *e; + + vlib_cli_output (vm, " %U\n", format_ila_entry, vnm, NULL); + pool_foreach (e, ilm->entries, + ({ + vlib_cli_output (vm, " %U\n", format_ila_entry, vnm, e); + })); + + return NULL; +} + +VLIB_CLI_COMMAND (ila_show_entries_command, static) = +{ + .path = "show ila entries", + .short_help = "show ila entries", + .function = ila_show_entries_command_fn, +}; diff --git a/src/plugins/ila/ila.h b/src/plugins/ila/ila.h new file mode 100644 index 00000000..26620983 --- /dev/null +++ b/src/plugins/ila/ila.h @@ -0,0 +1,116 @@ +/* + * Copyright (c) 2016 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ILA_H +#define ILA_H + +#include +#include +#include + +#include +#include + +#define ila_foreach_type \ + _(IID, 0, "iid") \ + _(LUID, 1, "luid") \ + _(VNID4, 2, "vnid-ip4") \ + _(VNID6, 3, "vnid-ip6") \ + _(VNIDM, 4, "vnid-multicast") + +typedef enum { +#define _(i,n,s) ILA_TYPE_##i = n, + ila_foreach_type +#undef _ +} ila_type_t; + +#define ila_csum_foreach_type \ +_(NO_ACTION, 0, "no-action") \ +_(NEUTRAL_MAP, 1, "neutral-map") \ +_(ADJUST_TRANSPORT, 2, "adjust-transport") + +typedef enum { +#define _(i,n,s) ILA_CSUM_MODE_##i = n, + ila_csum_foreach_type +#undef _ + ILA_CSUM_N_TYPES +} ila_csum_mode_t; + +#define ila_foreach_direction \ +_(BIDIR, 0, "bidir") \ +_(SIR2ILA, 1, "sir2ila") \ +_(ILA2SIR, 2, "ila2sir") + +typedef enum { +#define _(i,n,s) ILA_DIR_##i = n, + ila_foreach_direction +#undef _ +} ila_direction_t; + +typedef struct { + /** + * Fib Node base class + */ + fib_node_t ila_fib_node; + ila_type_t type; + ip6_address_t sir_address; + ip6_address_t ila_address; + ip6_address_t next_hop; + ila_csum_mode_t csum_mode; + ila_direction_t dir; + + /** + * The FIB entry index for the next-hop + */ + fib_node_index_t next_hop_fib_entry_index; + + /** + * The child index on the FIB entry + */ + u32 next_hop_child_index; + + /** + * The next DPO in the grpah to follow + */ + dpo_id_t ila_dpo; +} ila_entry_t; + +typedef struct { + ila_entry_t *entries; //Pool of ILA entries + + u64 lookup_table_nbuckets; + u64 lookup_table_size; + clib_bihash_24_8_t id_to_entry_table; + + u32 ip6_lookup_next_index; +} ila_main_t; + + +typedef struct { + ila_type_t type; + ip6_address_t sir_address; + ip6_address_t next_hop_address; + u64 locator; + u32 vnid; + u32 local_adj_index; + ila_csum_mode_t csum_mode; + ila_direction_t dir; + u8 is_del; +} ila_add_del_entry_args_t; + +int ila_add_del_entry (ila_add_del_entry_args_t * args); +int ila_interface (u32 sw_if_index, u8 disable); + +#endif //ILA_H diff --git a/src/plugins/sixrd.am b/src/plugins/sixrd.am new file mode 100644 index 00000000..0de45088 --- /dev/null +++ b/src/plugins/sixrd.am @@ -0,0 +1,26 @@ +# Copyright (c) 2015 Cisco and/or its affiliates. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +libsixrd_plugin_la_SOURCES = \ + sixrd/sixrd.c \ + sixrd/sixrd_dpo.c \ + sixrd/ip4_sixrd.c \ + sixrd/ip6_sixrd.c + +noinst_HEADERS += \ + sixrd/sixrd.h \ + sixrd/sixrd_dpo.h + +vppplugins_LTLIBRARIES += libsixrd_plugin.la + +# vi:syntax=automake diff --git a/src/plugins/sixrd/ip4_sixrd.c b/src/plugins/sixrd/ip4_sixrd.c new file mode 100644 index 00000000..2fb8015d --- /dev/null +++ b/src/plugins/sixrd/ip4_sixrd.c @@ -0,0 +1,127 @@ +/*--------------------------------------------------------------------------- + * Copyright (c) 2009-2014 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *--------------------------------------------------------------------------- + */ +#include "sixrd.h" + +static vlib_node_registration_t ip4_sixrd_node; + +typedef enum { + IP4_SIXRD_NEXT_IP6_LOOKUP, + IP4_SIXRD_NEXT_DROP, + IP4_SIXRD_N_NEXT, +} ip4_sixrd_next_t; + +/* + * ip4_sixrd_sec_check + */ +static_always_inline void +ip4_sixrd_sec_check (sixrd_domain_t *d, ip4_address_t sa4, ip6_address_t sa6, u8 *error) +{ + u32 a = sixrd_get_addr(d, sa6.as_u64[0]); + clib_warning("Security check: %U %U", format_ip4_address, &a, format_ip4_address, &sa4); + if (PREDICT_FALSE(sixrd_get_addr(d, sa6.as_u64[0]) != sa4.as_u32)) + *error = SIXRD_ERROR_SEC_CHECK; +} + +/* + * ip4_sixrd + */ +static uword +ip4_sixrd (vlib_main_t *vm, + vlib_node_runtime_t *node, + vlib_frame_t *frame) +{ + u32 n_left_from, *from, next_index, *to_next, n_left_to_next; + vlib_node_runtime_t *error_node = vlib_node_get_runtime(vm, ip4_sixrd_node.index); + u32 decap = 0; + + from = vlib_frame_vector_args(frame); + n_left_from = frame->n_vectors; + next_index = node->cached_next_index; + while (n_left_from > 0) { + vlib_get_next_frame(vm, node, next_index, to_next, n_left_to_next); + + /* Single loop */ + while (n_left_from > 0 && n_left_to_next > 0) { + u32 pi0; + vlib_buffer_t *p0; + u8 error0 = SIXRD_ERROR_NONE; + sixrd_domain_t *d0 = 0; + ip4_header_t *ip40; + ip6_header_t *ip60; + u32 sixrd_domain_index0 = ~0; + u32 next0; + + pi0 = to_next[0] = from[0]; + from += 1; + n_left_from -= 1; + to_next +=1; + n_left_to_next -= 1; + + p0 = vlib_get_buffer(vm, pi0); + ip40 = vlib_buffer_get_current(p0); + + /* Throw away anything that isn't IP in IP. */ + if (PREDICT_TRUE(ip40->protocol == IP_PROTOCOL_IPV6 && clib_net_to_host_u16(ip40->length) >= 60)) { + vlib_buffer_advance(p0, sizeof(ip4_header_t)); + ip60 = vlib_buffer_get_current(p0); + d0 = ip4_sixrd_get_domain(vnet_buffer(p0)->ip.adj_index[VLIB_TX], (ip6_address_t *)&ip60->src_address, + &sixrd_domain_index0, &error0); + } else { + error0 = SIXRD_ERROR_BAD_PROTOCOL; + } + if (d0) { + /* SIXRD inbound security check */ + ip4_sixrd_sec_check(d0, ip40->src_address, ip60->src_address, &error0); + } + + next0 = error0 == SIXRD_ERROR_NONE ? IP4_SIXRD_NEXT_IP6_LOOKUP : IP4_SIXRD_NEXT_DROP; + + if (PREDICT_FALSE(p0->flags & VLIB_BUFFER_IS_TRACED)) { + sixrd_trace_t *tr = vlib_add_trace(vm, node, p0, sizeof(*tr)); + tr->sixrd_domain_index = sixrd_domain_index0; + } + + p0->error = error_node->errors[error0]; + if (PREDICT_TRUE(error0 == SIXRD_ERROR_NONE)) decap++; + vlib_validate_buffer_enqueue_x1(vm, node, next_index, to_next, n_left_to_next, pi0, next0); + + } + vlib_put_next_frame(vm, node, next_index, n_left_to_next); + } + vlib_node_increment_counter(vm, ip4_sixrd_node.index, SIXRD_ERROR_DECAPSULATED, decap); + + return frame->n_vectors; +} + +static char *sixrd_error_strings[] = { +#define _(sym,string) string, + foreach_sixrd_error +#undef _ +}; + +VLIB_REGISTER_NODE(ip4_sixrd_node,static) = { + .function = ip4_sixrd, + .name = "ip4-sixrd", + .vector_size = sizeof(u32), + .format_trace = format_sixrd_trace, + .n_errors = SIXRD_N_ERROR, + .error_strings = sixrd_error_strings, + .n_next_nodes = IP4_SIXRD_N_NEXT, + .next_nodes = { + [IP4_SIXRD_NEXT_IP6_LOOKUP] = "ip6-lookup", + [IP4_SIXRD_NEXT_DROP] = "error-drop", + }, +}; diff --git a/src/plugins/sixrd/ip6_sixrd.c b/src/plugins/sixrd/ip6_sixrd.c new file mode 100644 index 00000000..36f3fab3 --- /dev/null +++ b/src/plugins/sixrd/ip6_sixrd.c @@ -0,0 +1,129 @@ +/*--------------------------------------------------------------------------- + * Copyright (c) 2009-2014 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *--------------------------------------------------------------------------- + */ +/* + * Defines used for testing various optimisation schemes + */ +#define SIXRD_ENCAP_DUAL 0 + +#include "sixrd.h" + +static vlib_node_registration_t ip6_sixrd_node; + +typedef enum { + IP6_SIXRD_NEXT_IP4_LOOKUP, + IP6_SIXRD_NEXT_DROP, + IP6_SIXRD_N_NEXT, +} ip6_sixrd_next_t; + +/* + * ip6_sixrd + */ +static uword +ip6_sixrd (vlib_main_t *vm, + vlib_node_runtime_t *node, + vlib_frame_t *frame) +{ + u32 n_left_from, *from, next_index, *to_next, n_left_to_next; + vlib_node_runtime_t *error_node = vlib_node_get_runtime(vm, ip6_sixrd_node.index); + u32 encap = 0; + from = vlib_frame_vector_args(frame); + n_left_from = frame->n_vectors; + next_index = node->cached_next_index; + + while (n_left_from > 0) { + vlib_get_next_frame(vm, node, next_index, to_next, n_left_to_next); + + while (n_left_from > 0 && n_left_to_next > 0) { + u32 pi0; + vlib_buffer_t *p0; + sixrd_domain_t *d0; + u8 error0 = SIXRD_ERROR_NONE; + ip6_header_t *ip60; + ip4_header_t *ip4h0; + u32 next0 = IP6_SIXRD_NEXT_IP4_LOOKUP; + u32 sixrd_domain_index0 = ~0; + + pi0 = to_next[0] = from[0]; + from += 1; + n_left_from -= 1; + to_next +=1; + n_left_to_next -= 1; + + p0 = vlib_get_buffer(vm, pi0); + ip60 = vlib_buffer_get_current(p0); + // p0->current_length = clib_net_to_host_u16(ip40->length); + d0 = ip6_sixrd_get_domain(vnet_buffer(p0)->ip.adj_index[VLIB_TX], &sixrd_domain_index0); + ASSERT(d0); + + /* SIXRD calc */ + u64 dal60 = clib_net_to_host_u64(ip60->dst_address.as_u64[0]); + u32 da40 = sixrd_get_addr(d0, dal60); + u16 len = clib_net_to_host_u16(ip60->payload_length) + 60; + if (da40 == 0) error0 = SIXRD_ERROR_UNKNOWN; + + /* construct ipv4 header */ + vlib_buffer_advance(p0, - (sizeof(ip4_header_t))); + ip4h0 = vlib_buffer_get_current(p0); + vnet_buffer(p0)->sw_if_index[VLIB_TX] = (u32)~0; + ip4h0->ip_version_and_header_length = 0x45; + ip4h0->tos = 0; + ip4h0->length = clib_host_to_net_u16(len); + ip4h0->fragment_id = 0; + ip4h0->flags_and_fragment_offset = 0; + ip4h0->ttl = 0x40; + ip4h0->protocol = IP_PROTOCOL_IPV6; + ip4h0->src_address = d0->ip4_src; + ip4h0->dst_address.as_u32 = clib_host_to_net_u32(da40); + ip4h0->checksum = ip4_header_checksum(ip4h0); + + next0 = error0 == SIXRD_ERROR_NONE ? IP6_SIXRD_NEXT_IP4_LOOKUP : IP6_SIXRD_NEXT_DROP; + + if (PREDICT_FALSE(p0->flags & VLIB_BUFFER_IS_TRACED)) { + sixrd_trace_t *tr = vlib_add_trace(vm, node, p0, sizeof(*tr)); + tr->sixrd_domain_index = sixrd_domain_index0; + } + + p0->error = error_node->errors[error0]; + if (PREDICT_TRUE(error0 == SIXRD_ERROR_NONE)) encap++; + + vlib_validate_buffer_enqueue_x1(vm, node, next_index, to_next, n_left_to_next, pi0, next0); + } + vlib_put_next_frame(vm, node, next_index, n_left_to_next); + } + vlib_node_increment_counter(vm, ip6_sixrd_node.index, SIXRD_ERROR_ENCAPSULATED, encap); + + return frame->n_vectors; +} + +static char *sixrd_error_strings[] = { +#define _(sym,string) string, + foreach_sixrd_error +#undef _ +}; + +VLIB_REGISTER_NODE(ip6_sixrd_node,static) = { + .function = ip6_sixrd, + .name = "ip6-sixrd", + .vector_size = sizeof(u32), + .format_trace = format_sixrd_trace, + .n_errors = SIXRD_N_ERROR, + .error_strings = sixrd_error_strings, + .n_next_nodes = IP6_SIXRD_N_NEXT, + .next_nodes = { + [IP6_SIXRD_NEXT_IP4_LOOKUP] = "ip4-lookup", + [IP6_SIXRD_NEXT_DROP] = "error-drop", + }, +}; diff --git a/src/plugins/sixrd/sixrd.c b/src/plugins/sixrd/sixrd.c new file mode 100644 index 00000000..66e631a2 --- /dev/null +++ b/src/plugins/sixrd/sixrd.c @@ -0,0 +1,369 @@ +/* + * Copyright (c) 2015 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "sixrd.h" +#include + +#include +#include +#include + +/* + * This code supports the following sixrd modes: + * + * 32 EA bits (Complete IPv4 address is embedded): + * ea_bits_len = 32 + * IPv4 suffix is embedded: + * ea_bits_len = < 32 + * No embedded address bits (1:1 mode): + * ea_bits_len = 0 + */ + +int +sixrd_create_domain (ip6_address_t *ip6_prefix, + u8 ip6_prefix_len, + ip4_address_t *ip4_prefix, + u8 ip4_prefix_len, + ip4_address_t *ip4_src, + u32 *sixrd_domain_index, + u16 mtu) +{ + dpo_id_t dpo_v6 = DPO_INVALID, dpo_v4 = DPO_INVALID; + sixrd_main_t *mm = &sixrd_main; + fib_node_index_t fei; + sixrd_domain_t *d; + + /* Get domain index */ + pool_get_aligned(mm->domains, d, CLIB_CACHE_LINE_BYTES); + memset(d, 0, sizeof (*d)); + *sixrd_domain_index = d - mm->domains; + + /* Init domain struct */ + d->ip4_prefix.as_u32 = ip4_prefix->as_u32; + d->ip4_prefix_len = ip4_prefix_len; + d->ip6_prefix = *ip6_prefix; + d->ip6_prefix_len = ip6_prefix_len; + d->ip4_src = *ip4_src; + d->mtu = mtu; + + if (ip4_prefix_len < 32) + d->shift = 64 - ip6_prefix_len + (32 - ip4_prefix_len); + + /* Create IPv6 route/adjacency */ + fib_prefix_t pfx6 = { + .fp_proto = FIB_PROTOCOL_IP6, + .fp_len = d->ip6_prefix_len, + .fp_addr = { + .ip6 = d->ip6_prefix, + }, + }; + sixrd_dpo_create(DPO_PROTO_IP6, + *sixrd_domain_index, + &dpo_v6); + fib_table_entry_special_dpo_add(0, &pfx6, + FIB_SOURCE_SIXRD, + FIB_ENTRY_FLAG_EXCLUSIVE, + &dpo_v6); + dpo_reset (&dpo_v6); + + /* + * Multiple SIXRD domains may share same source IPv4 TEP + * In this case the route will exist and be SixRD sourced. + * Find the adj (if any) already contributed and modify it + */ + fib_prefix_t pfx4 = { + .fp_proto = FIB_PROTOCOL_IP4, + .fp_len = 32, + .fp_addr = { + .ip4 = d->ip4_src, + }, + }; + fei = fib_table_lookup_exact_match(0, &pfx4); + + if (FIB_NODE_INDEX_INVALID != fei) + { + dpo_id_t dpo = DPO_INVALID; + + if (fib_entry_get_dpo_for_source (fei, FIB_SOURCE_SIXRD, &dpo)) + { + /* + * modify the existing adj to indicate it's shared + * skip to route add. + * It is locked to pair with the unlock below. + */ + const dpo_id_t *sd_dpo; + sixrd_dpo_t *sd; + + ASSERT(DPO_LOAD_BALANCE == dpo.dpoi_type); + + sd_dpo = load_balance_get_bucket(dpo.dpoi_index, 0); + sd = sixrd_dpo_get (sd_dpo->dpoi_index); + + sd->sd_domain = ~0; + dpo_copy (&dpo_v4, sd_dpo); + dpo_reset (&dpo); + + goto route_add; + } + } + /* first time addition of the route */ + sixrd_dpo_create(DPO_PROTO_IP4, + *sixrd_domain_index, + &dpo_v4); + +route_add: + /* + * Create ip4 route. This is a reference counted add. If the prefix + * already exists and is SixRD sourced, it is now SixRD source n+1 times + * and will need to be removed n+1 times. + */ + fib_table_entry_special_dpo_add(0, &pfx4, + FIB_SOURCE_SIXRD, + FIB_ENTRY_FLAG_EXCLUSIVE, + &dpo_v4); + dpo_reset (&dpo_v4); + + return 0; +} + +/* + * sixrd_delete_domain + */ +int +sixrd_delete_domain (u32 sixrd_domain_index) +{ + sixrd_main_t *mm = &sixrd_main; + sixrd_domain_t *d; + + if (pool_is_free_index(mm->domains, sixrd_domain_index)) { + clib_warning("SIXRD domain delete: domain does not exist: %d", + sixrd_domain_index); + return -1; + } + + d = pool_elt_at_index(mm->domains, sixrd_domain_index); + + fib_prefix_t pfx = { + .fp_proto = FIB_PROTOCOL_IP4, + .fp_len = 32, + .fp_addr = { + .ip4 = d->ip4_src, + }, + }; + fib_table_entry_special_remove(0, &pfx, FIB_SOURCE_SIXRD); + + fib_prefix_t pfx6 = { + .fp_proto = FIB_PROTOCOL_IP6, + .fp_len = d->ip6_prefix_len, + .fp_addr = { + .ip6 = d->ip6_prefix, + }, + }; + fib_table_entry_special_remove(0, &pfx6, FIB_SOURCE_SIXRD); + + pool_put(mm->domains, d); + + return 0; +} + +static clib_error_t * +sixrd_add_domain_command_fn (vlib_main_t *vm, + unformat_input_t *input, + vlib_cli_command_t *cmd) +{ + unformat_input_t _line_input, *line_input = &_line_input; + ip4_address_t ip4_prefix; + ip6_address_t ip6_prefix; + ip4_address_t ip4_src; + u32 ip6_prefix_len=0, ip4_prefix_len=0, sixrd_domain_index; + u32 num_m_args = 0; + /* Optional arguments */ + u32 mtu = 0; + + /* Get a line of input. */ + if (!unformat_user(input, unformat_line_input, line_input)) + return 0; + while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) { + if (unformat(line_input, "ip6-pfx %U/%d", unformat_ip6_address, &ip6_prefix, &ip6_prefix_len)) + num_m_args++; + else if (unformat(line_input, "ip4-pfx %U/%d", unformat_ip4_address, &ip4_prefix, &ip4_prefix_len)) + num_m_args++; + else if (unformat(line_input, "ip4-src %U", unformat_ip4_address, &ip4_src)) + num_m_args++; + else if (unformat(line_input, "mtu %d", &mtu)) + num_m_args++; + else + return clib_error_return(0, "unknown input `%U'", + format_unformat_error, input); + } + unformat_free(line_input); + + if (num_m_args < 3) + return clib_error_return(0, "mandatory argument(s) missing"); + + sixrd_create_domain(&ip6_prefix, ip6_prefix_len, &ip4_prefix, ip4_prefix_len, + &ip4_src, &sixrd_domain_index, mtu); + + return 0; +} + +static clib_error_t * +sixrd_del_domain_command_fn (vlib_main_t *vm, + unformat_input_t *input, + vlib_cli_command_t *cmd) +{ + unformat_input_t _line_input, *line_input = &_line_input; + u32 num_m_args = 0; + u32 sixrd_domain_index; + + /* Get a line of input. */ + if (! unformat_user(input, unformat_line_input, line_input)) + return 0; + + while (unformat_check_input(line_input) != UNFORMAT_END_OF_INPUT) { + if (unformat(line_input, "index %d", &sixrd_domain_index)) + num_m_args++; + else + return clib_error_return(0, "unknown input `%U'", + format_unformat_error, input); + } + unformat_free(line_input); + + if (num_m_args != 1) + return clib_error_return(0, "mandatory argument(s) missing"); + + sixrd_delete_domain(sixrd_domain_index); + + return 0; +} + +static u8 * +format_sixrd_domain (u8 *s, va_list *args) +{ + sixrd_domain_t *d = va_arg(*args, sixrd_domain_t *); + sixrd_main_t *mm = &sixrd_main; + + s = format(s, + "[%d] ip6-pfx %U/%d ip4-pfx %U/%d ip4-src %U mtu %d", + d - mm->domains, + format_ip6_address, &d->ip6_prefix, d->ip6_prefix_len, + format_ip4_address, &d->ip4_prefix, d->ip4_prefix_len, + format_ip4_address, &d->ip4_src, d->mtu); + + return s; +} + +static clib_error_t * +show_sixrd_domain_command_fn (vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd) +{ + sixrd_main_t *mm = &sixrd_main; + sixrd_domain_t *d; + + if (pool_elts(mm->domains) == 0) + vlib_cli_output(vm, "No SIXRD domains are configured..."); + + pool_foreach(d, mm->domains, ({vlib_cli_output(vm, "%U", format_sixrd_domain, d);})); + + return 0; + +} + +static clib_error_t * +show_sixrd_stats_command_fn (vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd) +{ + sixrd_main_t *mm = &sixrd_main; + sixrd_domain_t *d; + int domains = 0, domaincount = 0; + if (pool_elts (mm->domains) == 0) + vlib_cli_output (vm, "No SIXRD domains are configured..."); + + pool_foreach(d, mm->domains, ({ + domains += sizeof(*d); + domaincount++; + })); + + vlib_cli_output(vm, "SIXRD domains structure: %d\n", sizeof (sixrd_domain_t)); + vlib_cli_output(vm, "SIXRD domains: %d (%d bytes)\n", domaincount, domains); + + return 0; +} + +/* + * packet trace format function + */ +u8 * +format_sixrd_trace (u8 *s, va_list *args) +{ + CLIB_UNUSED(vlib_main_t *vm) = va_arg (*args, vlib_main_t *); + CLIB_UNUSED(vlib_node_t *node) = va_arg (*args, vlib_node_t *); + sixrd_trace_t *t = va_arg (*args, sixrd_trace_t *); + u32 sixrd_domain_index = t->sixrd_domain_index; + + s = format(s, "SIXRD domain index: %d", sixrd_domain_index); + + return s; +} + +VLIB_CLI_COMMAND(sixrd_add_domain_command, static) = { + .path = "sixrd add domain", + .short_help = + "sixrd add domain ip6-pfx ip4-pfx ip4-src ", + .function = sixrd_add_domain_command_fn, +}; + +VLIB_CLI_COMMAND(sixrd_del_command, static) = { + .path = "sixrd del domain", + .short_help = + "sixrd del domain index ", + .function = sixrd_del_domain_command_fn, +}; + +VLIB_CLI_COMMAND(show_sixrd_domain_command, static) = { + .path = "show sixrd domain", + .function = show_sixrd_domain_command_fn, +}; + +VLIB_CLI_COMMAND(show_sixrd_stats_command, static) = { + .path = "show sixrd stats", + .function = show_sixrd_stats_command_fn, +}; + +/* + * This routine exists to convince the vlib plugin framework that + * we haven't accidentally copied a random .dll into the plugin directory. + * + * Also collects global variable pointers passed from the vpp engine + */ +clib_error_t * +vlib_plugin_register (vlib_main_t * vm, vnet_plugin_handoff_t * h, + int from_early_init) +{ + clib_error_t * error = 0; + sixrd_main_t *mm = &sixrd_main; + + mm->vnet_main = vnet_get_main(); + mm->vlib_main = vm; + + return error; +} + +static clib_error_t * sixrd_init (vlib_main_t * vm) +{ + sixrd_dpo_module_init (); + + return (NULL); +} + +VLIB_INIT_FUNCTION (sixrd_init); diff --git a/src/plugins/sixrd/sixrd.h b/src/plugins/sixrd/sixrd.h new file mode 100644 index 00000000..56714c9e --- /dev/null +++ b/src/plugins/sixrd/sixrd.h @@ -0,0 +1,141 @@ +/*--------------------------------------------------------------------------- + * Copyright (c) 2009-2014 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *--------------------------------------------------------------------------- + */ +#include +#include +#include +#include +#include + +#include "sixrd_dpo.h" + +int sixrd_create_domain(ip6_address_t *ip6_prefix, u8 ip6_prefix_len, + ip4_address_t *ip4_prefix, u8 ip4_prefix_len, + ip4_address_t *ip4_src, u32 *sixrd_domain_index, u16 mtu); +int sixrd_delete_domain(u32 sixrd_domain_index); +u8 *format_sixrd_trace(u8 *s, va_list *args); + +typedef struct { + ip6_address_t ip6_prefix; + ip4_address_t ip4_prefix; + ip4_address_t ip4_src; + u8 ip6_prefix_len; + u8 ip4_prefix_len; + + /* helpers */ + u8 shift; + + u16 mtu; +} sixrd_domain_t; + +typedef struct { + /* pool of SIXRD domains */ + sixrd_domain_t *domains; + + /* convenience */ + vlib_main_t *vlib_main; + vnet_main_t *vnet_main; +} sixrd_main_t; + +#define foreach_sixrd_error \ + /* Must be first. */ \ + _(NONE, "valid SIXRD packets") \ + _(BAD_PROTOCOL, "bad protocol") \ + _(WRONG_ICMP_TYPE, "wrong icmp type") \ + _(SEC_CHECK, "security check failed") \ + _(ICMP, "unable to translate ICMP") \ + _(UNKNOWN, "unknown") \ + _(NO_DOMAIN, "no domain") \ + _(ENCAPSULATED, "encapsulated") \ + _(DECAPSULATED, "decapsulated") \ + _(TRANSLATED_4TO6, "translated 4 to 6") \ + _(TRANSLATED_6TO4, "translated 6 to 4") \ + _(FRAGMENT, "fragment handling error") \ + _(FRAGMENT_QUEUED, "dropped, missing first fragment") \ + _(FRAGMENTED, "packets requiring fragmentation") \ + _(FRAGMENT_PARTS, "fragment parts") \ + _(MALFORMED, "malformed packet") + +typedef enum { +#define _(sym,str) SIXRD_ERROR_##sym, + foreach_sixrd_error +#undef _ + SIXRD_N_ERROR, + } sixrd_error_t; + +typedef struct { + u32 sixrd_domain_index; +} sixrd_trace_t; + +sixrd_main_t sixrd_main; + +/* + * sixrd_get_addr + */ +static_always_inline u32 +sixrd_get_addr (sixrd_domain_t *d, u64 dal) +{ + + /* 1:1 mode */ + if (d->ip4_prefix_len == 32) return (d->ip4_prefix.as_u32); + + /* Grab 32 - ip4_prefix_len bits out of IPv6 address from offset ip6_prefix_len */ + return (d->ip4_prefix.as_u32 | (u32)(dal >> d->shift)); +} + +/* + * Get the SIXRD domain from an IPv6 lookup adjacency. + */ +static_always_inline sixrd_domain_t * +ip6_sixrd_get_domain (u32 sdi, u32 *sixrd_domain_index) +{ + sixrd_main_t *mm = &sixrd_main; + sixrd_dpo_t *sd; + + sd = sixrd_dpo_get(sdi); + + ASSERT(sd); + *sixrd_domain_index = sd->sd_domain; + return pool_elt_at_index(mm->domains, *sixrd_domain_index); +} + +/* + * Get the SIXRD domain from an IPv4 lookup adjacency. + * If the IPv4 address is not shared, no lookup is required. + * The IPv6 address is used otherwise. + */ +static_always_inline sixrd_domain_t * +ip4_sixrd_get_domain (u32 sdi, ip6_address_t *addr, + u32 *sixrd_domain_index, u8 *error) +{ + sixrd_main_t *mm = &sixrd_main; + sixrd_dpo_t *sd; + + sd = sixrd_dpo_get(sdi); + *sixrd_domain_index = sd->sd_domain; + if (*sixrd_domain_index != ~0) + return pool_elt_at_index(mm->domains, *sixrd_domain_index); + + u32 lbi = ip6_fib_table_fwding_lookup(&ip6_main, 0, addr); + const dpo_id_t *dpo = load_balance_get_bucket(lbi, 0); + if (PREDICT_TRUE(dpo->dpoi_type == sixrd_dpo_type)) + { + sd = sixrd_dpo_get(dpo->dpoi_index); + *sixrd_domain_index = sd->sd_domain; + return pool_elt_at_index(mm->domains, *sixrd_domain_index); + } + *error = SIXRD_ERROR_NO_DOMAIN; + return NULL; +} diff --git a/src/plugins/sixrd/sixrd_dpo.c b/src/plugins/sixrd/sixrd_dpo.c new file mode 100644 index 00000000..88a07935 --- /dev/null +++ b/src/plugins/sixrd/sixrd_dpo.c @@ -0,0 +1,132 @@ +/* + * Copyright (c) 2016 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "sixrd_dpo.h" +#include + +/** + * pool of all MPLS Label DPOs + */ +sixrd_dpo_t *sixrd_dpo_pool; + +/** + * The register SIXRD DPO type + */ +dpo_type_t sixrd_dpo_type; + +static sixrd_dpo_t * +sixrd_dpo_alloc (void) +{ + sixrd_dpo_t *sd; + + pool_get_aligned(sixrd_dpo_pool, sd, CLIB_CACHE_LINE_BYTES); + memset(sd, 0, sizeof(*sd)); + + return (sd); +} + +static index_t +sixrd_dpo_get_index (sixrd_dpo_t *sd) +{ + return (sd - sixrd_dpo_pool); +} + +void +sixrd_dpo_create (dpo_proto_t dproto, + u32 domain_index, + dpo_id_t *dpo) +{ + sixrd_dpo_t *sd; + + sd = sixrd_dpo_alloc(); + sd->sd_domain = domain_index; + sd->sd_proto = dproto; + + dpo_set(dpo, + sixrd_dpo_type, + dproto, + sixrd_dpo_get_index(sd)); +} + +u8* +format_sixrd_dpo (u8 *s, va_list *args) +{ + index_t index = va_arg (*args, index_t); + CLIB_UNUSED(u32 indent) = va_arg (*args, u32); + sixrd_dpo_t *sd; + + sd = sixrd_dpo_get(index); + + return (format(s, "sixrd:[%d]:%U domain:%d", + index, + format_dpo_proto, sd->sd_proto, + sd->sd_domain)); +} + + +static void +sixrd_dpo_lock (dpo_id_t *dpo) +{ + sixrd_dpo_t *sd; + + sd = sixrd_dpo_get(dpo->dpoi_index); + + sd->sd_locks++; +} + +static void +sixrd_dpo_unlock (dpo_id_t *dpo) +{ + sixrd_dpo_t *sd; + + sd = sixrd_dpo_get(dpo->dpoi_index); + + sd->sd_locks--; + + if (0 == sd->sd_locks) + { + pool_put(sixrd_dpo_pool, sd); + } +} + +const static dpo_vft_t sd_vft = { + .dv_lock = sixrd_dpo_lock, + .dv_unlock = sixrd_dpo_unlock, + .dv_format = format_sixrd_dpo, +}; + +const static char* const sixrd_ip4_nodes[] = +{ + "ip4-sixrd", + NULL, +}; +const static char* const sixrd_ip6_nodes[] = +{ + "ip6-sixrd", + NULL, +}; + +const static char* const * const sixrd_nodes[DPO_PROTO_NUM] = +{ + [DPO_PROTO_IP4] = sixrd_ip4_nodes, + [DPO_PROTO_IP6] = sixrd_ip6_nodes, + [DPO_PROTO_MPLS] = NULL, +}; + +void +sixrd_dpo_module_init (void) +{ + sixrd_dpo_type = dpo_register_new_type(&sd_vft, sixrd_nodes); +} diff --git a/src/plugins/sixrd/sixrd_dpo.h b/src/plugins/sixrd/sixrd_dpo.h new file mode 100644 index 00000000..17142288 --- /dev/null +++ b/src/plugins/sixrd/sixrd_dpo.h @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2016 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __SIXRD_DPO_H__ +#define __SIXRD_DPO_H__ + +#include +#include + +/** + * A representation of a 6RD DPO + */ +typedef struct sixrd_dpo_t +{ + /** + * The dat-plane protocol + */ + dpo_proto_t sd_proto; + + /** + * the SIXRD domain index + */ + u32 sd_domain; + + /** + * Number of locks/users of the label + */ + u16 sd_locks; +} sixrd_dpo_t; + +extern void sixrd_dpo_create (dpo_proto_t dproto, + u32 domain_index, + dpo_id_t *dpo); + +/* + * Encapsulation violation for fast data-path access + */ +extern sixrd_dpo_t *sixrd_dpo_pool; +extern dpo_type_t sixrd_dpo_type; + +static inline sixrd_dpo_t * +sixrd_dpo_get (index_t index) +{ + return (pool_elt_at_index(sixrd_dpo_pool, index)); +} + +extern void sixrd_dpo_module_init(void); + +#endif diff --git a/src/scripts/vnet/arp4 b/src/scripts/vnet/arp4 new file mode 100644 index 00000000..acb20da3 --- /dev/null +++ b/src/scripts/vnet/arp4 @@ -0,0 +1,21 @@ +packet-generator new { + name x + limit 1 + node ip4-input + size 64-64 + no-recycle + data { + ICMP: 1.0.0.2 -> 2.0.0.2 + ICMP echo_request + incrementing 100 + } +} + +trace add pg-input 100 +loop create +loop create +set int state loop0 up +set int state loop1 up + +set int ip address loop0 1.0.0.1/24 +set int ip address loop1 2.0.0.1/24 diff --git a/src/scripts/vnet/arp4-mpls b/src/scripts/vnet/arp4-mpls new file mode 100644 index 00000000..d3d39f3b --- /dev/null +++ b/src/scripts/vnet/arp4-mpls @@ -0,0 +1,24 @@ +packet-generator new { + name x + limit 1 + node ip4-input + size 64-64 + no-recycle + data { + ICMP: 1.0.0.2 -> 2.2.2.2 + ICMP echo_request + incrementing 100 + } +} + +loop create +loop create +set int state loop0 up +set int state loop1 up + +set int ip address loop0 1.0.0.1/24 +set int ip address loop1 2.0.0.1/24 + +ip route add 2.2.2.2/32 via 2.0.0.2 loop1 out-label 33 + +trace add pg-input 100 diff --git a/src/scripts/vnet/arp6 b/src/scripts/vnet/arp6 new file mode 100644 index 00000000..e6a98935 --- /dev/null +++ b/src/scripts/vnet/arp6 @@ -0,0 +1,21 @@ +packet-generator new { + name x + limit 1 + node ip6-input + size 64-64 + no-recycle + data { + ICMP6: 2000::2 -> 2001::2 + ICMP echo_request + incrementing 100 + } +} + +tr add pg-input 100 +loop create +loop create +set int state loop0 up +set int state loop1 up + +set int ip address loop0 2000::1/64 +set int ip address loop1 2001::1/64 diff --git a/src/scripts/vnet/bvi b/src/scripts/vnet/bvi new file mode 100644 index 00000000..2174da0d --- /dev/null +++ b/src/scripts/vnet/bvi @@ -0,0 +1,76 @@ + + +set int state tuntap-0 down +set int ip address GigabitEthernet2/1/0 1.2.3.4/24 + +set int state GigabitEthernet2/1/0 up +cre sub GigabitEthernet2/1/0 1 dot1q 7 +set int state GigabitEthernet2/1/0.1 up + +set int state GigabitEthernet2/2/0 up +cre sub GigabitEthernet2/2/0 1 dot1q 9 +set int state GigabitEthernet2/2/0.1 up + + +loop create +set int l2 bridge loop0 0 bvi +set int ip table loop0 0 +set int state loop0 up + + +set int l2 bridge GigabitEthernet2/1/0.1 0 +set int l2 bridge GigabitEthernet2/2/0.1 0 + +set int l2 tag-rewrite GigabitEthernet2/1/0.1 pop 1 +set int l2 tag-rewrite GigabitEthernet2/2/0.1 pop 1 + +l2fib add 00:22:44:06:08:0a 0 GigabitEthernet2/1/0.1 static +l2fib add 00:02:04:06:08:0a 0 GigabitEthernet2/2/0.1 static + + +ip route table 0 8.0.0.1/32 via loop0 +set ip arp loop0 8.0.0.1 00:02:04:06:08:0a + + +ip route add 1.2.3.3/32 via GigabitEthernet2/1/0 IP4: 00:15:17:61:73:47 -> 00:15:17:61:73:46 + +cle er +cle int +cle run + +packet-generator new { + name bvi_to_l2 + limit 100 + no-recycle + node ethernet-input + interface GigabitEthernet2/1/0 + data { + IP4: 0050.56b7.7c83 -> 0050.56b7.296d + GRE: 1.2.3.3 -> 8.0.0.1 mpls_unicast + } +} + +packet-generator new { + name l2_to_bvi + limit 50 + no-recycle + node ethernet-input + interface GigabitEthernet2/2/0 + data { + IP4: 0050.56b7.7c83 -> dead.0000.0000 vlan 9 + GRE: 8.0.0.1 -> 1.2.3.3 mpls_unicast + } +} + +packet-generator new { + name l2_to_bvi_via_flood + limit 25 + no-recycle + node ethernet-input + interface GigabitEthernet2/2/0 + data { + IP4: 0050.56b7.7c83 -> ffff.ffff.ffff vlan 9 + GRE: 8.0.0.1 -> 1.2.3.3 mpls_unicast + } +} + diff --git a/src/scripts/vnet/dhcp/dhcpd.conf b/src/scripts/vnet/dhcp/dhcpd.conf new file mode 100644 index 00000000..d4cb3ed7 --- /dev/null +++ b/src/scripts/vnet/dhcp/dhcpd.conf @@ -0,0 +1,8 @@ +# add at the bottom + +subnet 192.168.0.0 netmask 255.255.0.0 { + range 192.168.1.10 192.168.1.254; + option routers 192.168.1.1; + default-lease-time 15; + max-lease-time 15; +} diff --git a/src/scripts/vnet/dhcp/left-ping-target.sh b/src/scripts/vnet/dhcp/left-ping-target.sh new file mode 100644 index 00000000..2edc2a50 --- /dev/null +++ b/src/scripts/vnet/dhcp/left-ping-target.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +# to obtain dhcp address from leftpeer +dhclient -d -v eth1 diff --git a/src/scripts/vnet/dhcp/leftpeer.conf b/src/scripts/vnet/dhcp/leftpeer.conf new file mode 100644 index 00000000..458eecf0 --- /dev/null +++ b/src/scripts/vnet/dhcp/leftpeer.conf @@ -0,0 +1,17 @@ +set int ip table GigabitEthernet2/2/0 12 +set int ip address GigabitEthernet2/2/0 192.168.1.1/24 +set int state GigabitEthernet2/2/0 up + +set int ip table GigabitEthernet2/7/0 11 +set int ip address GigabitEthernet2/7/0 192.168.2.1/24 +set int state GigabitEthernet2/7/0 up + +comment { set dhcp proxy server 1.2.3.4 src-address 1.2.3.5 add-option-82 rx-fib-id 0 server-fib-id 0 } + +comment { set dhcp proxy server 192.168.2.2 src-address 192.168.2.1 add-option-82 rx-fib-id 12 server-fib-id 11 } + +ip route add 0.0.0.0/24 table 11 via local +ip route add 255.255.255.255/24 table 11 via local + +ip route add 0.0.0.0/24 table 12 via local +ip route add 255.255.255.255/24 table 12 via local diff --git a/src/scripts/vnet/icmp b/src/scripts/vnet/icmp new file mode 100644 index 00000000..1e054e2d --- /dev/null +++ b/src/scripts/vnet/icmp @@ -0,0 +1,16 @@ +packet-generator new { + name x + limit 1 + node ip4-input + size 64-64 + no-recycle + data { + ICMP: 1.2.3.4 -> 5.6.7.8 + ICMP echo_request + incrementing 100 + } +} + +tr add pg-input 100 +ip route 5.6.7.8/32 via local +ip route 1.2.3.4/32 via local diff --git a/src/scripts/vnet/icmp6 b/src/scripts/vnet/icmp6 new file mode 100644 index 00000000..2a65acba --- /dev/null +++ b/src/scripts/vnet/icmp6 @@ -0,0 +1,16 @@ +packet-generator new { + name x + limit 1 + node ip6-input + size 64-64 + no-recycle + data { + ICMP6: ::1 -> ::2 + ICMP echo_request + incrementing 100 + } +} + +tr add pg-input 100 +ip route ::1/128 via local +ip route ::2/128 via local diff --git a/src/scripts/vnet/ige b/src/scripts/vnet/ige new file mode 100644 index 00000000..80d045af --- /dev/null +++ b/src/scripts/vnet/ige @@ -0,0 +1,19 @@ +packet-generator new { + name x + limit 1 + node ip4-lookup + size 50-50 + data { + ICMP: 1.0.0.1 -> 1.0.0.3 ttl 1 + incrementing 30 + } +} + +comment { tr add pg-input 100 } +set int ip address GigabitEthernet4/0/0 1.0.0.1/24 +set int ip address GigabitEthernet4/0/1 1.0.0.2/24 +set int state GigabitEthernet4/0/0 up +set int state GigabitEthernet4/0/1 up + +ip route add 1.0.0.3/32 via GigabitEthernet4/0/1 IP4: 00:15:17:61:73:47 -> 00:15:17:61:73:46 +tr add ige-input 10 diff --git a/src/scripts/vnet/ip6 b/src/scripts/vnet/ip6 new file mode 100644 index 00000000..4f9f3ee5 --- /dev/null +++ b/src/scripts/vnet/ip6 @@ -0,0 +1,15 @@ +packet-generator new { + name x + limit 1 + node ethernet-input + size 64-64 + no-recycle + data { + IP6: 1.2.3 -> 4.5.6 + ICMP: ::1 -> ::2 + ICMP echo_request + incrementing 100 + } +} + +tr add pg-input 100 diff --git a/src/scripts/vnet/ip6-hbh b/src/scripts/vnet/ip6-hbh new file mode 100644 index 00000000..0c6de47f --- /dev/null +++ b/src/scripts/vnet/ip6-hbh @@ -0,0 +1,84 @@ +tap connect tap0 +set int state tap-0 up +set int ip address tap-0 1::1/64 +packet-generator new { + name hbh1 + limit 1 + node ip6-input + size 48-48 + no-recycle + data { + IP6_HOP_BY_HOP_OPTIONS: 1::2 -> 1::2 + hex 0x3B00010403040506 + incrementing 100 + } +} +packet-generator new { + name hbh2 + limit 1 + node ip6-input + size 48-48 + no-recycle + data { + IP6_HOP_BY_HOP_OPTIONS: 1::2 -> 1::2 + hex 0x3B00C10403040506 + incrementing 100 + } +} + +packet-generator new { + name hbh3 + limit 1 + node ip6-input + size 48-48 + no-recycle + data { + IP6_HOP_BY_HOP_OPTIONS: 1::2 -> 1::2 + hex 0x3BffC10403040506 + incrementing 100 + } +} + +packet-generator new { + name hbh4 + limit 1 + node ip6-input + size 64-64 + no-recycle + data { + IP6_HOP_BY_HOP_OPTIONS: 1::2 -> 1::2 + hex 0x3BffC10403040506 + incrementing 100 + } +} + +packet-generator new { + name hbh5 + limit 1 + node ip6-input + size 56-56 + no-recycle + data { + IP6_HOP_BY_HOP_OPTIONS: 1::2 -> 1::2 + length 16 + hex 0x3B010104030405060106030405060708 + incrementing 100 + } +} + +packet-generator new { + name hbh6 + limit 1 + node ip6-input + size 56-56 + no-recycle + data { + IP6_HOP_BY_HOP_OPTIONS: 1::2 -> 1::2 + length 16 + hex 0x3a00050200000100 + ICMP echo_request + incrementing 100 + } +} + +tr add pg-input 100 diff --git a/src/scripts/vnet/ixge b/src/scripts/vnet/ixge new file mode 100644 index 00000000..6722b536 --- /dev/null +++ b/src/scripts/vnet/ixge @@ -0,0 +1,15 @@ +packet-generator new { + name x + limit 1 + node ip4-lookup + size 50-50 + data { + ICMP: 1.0.0.1 -> 1.0.0.3 ttl 1 + incrementing 30 + } +} + +comment { tr add pg-input 100 } +set int ip address TenGigabitEthernet5/0/0 33.0.1.1/8 +set int state TenGigabitEthernet5/0/0 up + diff --git a/src/scripts/vnet/l2efpfilter b/src/scripts/vnet/l2efpfilter new file mode 100644 index 00000000..307b4436 --- /dev/null +++ b/src/scripts/vnet/l2efpfilter @@ -0,0 +1,83 @@ + +set int ip address GigabitEthernet2/1/0 1.2.3.4/24 +set int state GigabitEthernet2/1/0 up +set int state tuntap-0 down + + +cre sub GigabitEthernet2/1/0 1 dot1q 1 +cre sub GigabitEthernet2/1/0 2 dot1q 2 +cre sub GigabitEthernet2/1/0 3 dot1q 3 +cre sub GigabitEthernet2/2/0 1 dot1q 1 +cre sub GigabitEthernet2/2/0 100 dot1q 100 + +set int l2 bridge GigabitEthernet2/1/0 0 +set int l2 bridge GigabitEthernet2/1/0.1 0 +set int l2 bridge GigabitEthernet2/1/0.2 0 +set int l2 bridge GigabitEthernet2/1/0.3 0 +set int l2 bridge GigabitEthernet2/2/0 0 +set int l2 bridge GigabitEthernet2/2/0.1 0 +set int l2 bridge GigabitEthernet2/2/0.100 0 + +set int l2 tag-rewrite GigabitEthernet2/2/0.1 push dot1q 50 +set int l2 tag-rewrite GigabitEthernet2/1/0.2 translate 1-1 dot1q 100 +set int l2 tag-rewrite GigabitEthernet2/1/0.3 translate 1-1 dot1q 99 + +set int l2 efp-filter GigabitEthernet2/2/0 +set int l2 efp-filter GigabitEthernet2/2/0.1 +set int l2 efp-filter GigabitEthernet2/2/0.100 + + +l2fib add 00:00:00:00:00:11 0 GigabitEthernet2/2/0.1 static +l2fib add 00:00:00:00:00:22 0 GigabitEthernet2/2/0.100 static + +set int state GigabitEthernet2/1/0 up +set int state GigabitEthernet2/1/0.1 up +set int state GigabitEthernet2/1/0.2 up +set int state GigabitEthernet2/1/0.3 up +set int state GigabitEthernet2/2/0 up +set int state GigabitEthernet2/2/0.1 up +set int state GigabitEthernet2/2/0.100 up + + +trace add pg-input 6 + +clear error +clear run +clear int + +packet-generator new { + name pre_vtr_fail + limit 10 + no-recycle + node ethernet-input + interface GigabitEthernet2/1/0 + data { + IP4: 0050.56b7.7c83 -> 00:00:00:00:00:11 vlan 1 + GRE: 8.0.0.1 -> 1.2.3.3 mpls_unicast + } +} + +packet-generator new { + name post_vtr_pass + limit 20 + no-recycle + node ethernet-input + interface GigabitEthernet2/1/0 + data { + IP4: 0050.56b7.7c83 -> 00:00:00:00:00:22 vlan 2 + GRE: 8.0.0.1 -> 1.2.3.3 mpls_unicast + } +} + +packet-generator new { + name post_vtr_fail + limit 50 + no-recycle + node ethernet-input + interface GigabitEthernet2/1/0 + data { + IP4: 0050.56b7.7c83 -> 00:00:00:00:00:22 vlan 3 + GRE: 8.0.0.1 -> 1.2.3.3 mpls_unicast + } +} + diff --git a/src/scripts/vnet/l2efpfilter_perf b/src/scripts/vnet/l2efpfilter_perf new file mode 100644 index 00000000..b2f4b490 --- /dev/null +++ b/src/scripts/vnet/l2efpfilter_perf @@ -0,0 +1,58 @@ + +set int ip address GigabitEthernet2/1/0 1.2.3.4/24 +set int state GigabitEthernet2/1/0 up +set int state tuntap-0 down + + +cre sub GigabitEthernet2/1/0 1 dot1q 1 +cre sub GigabitEthernet2/1/0 2 dot1q 2 +cre sub GigabitEthernet2/1/0 3 dot1q 3 +cre sub GigabitEthernet2/2/0 1 dot1q 1 +cre sub GigabitEthernet2/2/0 100 dot1q 100 + +set int l2 bridge GigabitEthernet2/1/0 0 +set int l2 bridge GigabitEthernet2/1/0.1 0 +set int l2 bridge GigabitEthernet2/1/0.2 0 +set int l2 bridge GigabitEthernet2/1/0.3 0 +set int l2 bridge GigabitEthernet2/2/0 0 +set int l2 bridge GigabitEthernet2/2/0.1 0 +set int l2 bridge GigabitEthernet2/2/0.100 0 + +set int l2 tag-rewrite GigabitEthernet2/2/0.1 push dot1q 50 +set int l2 tag-rewrite GigabitEthernet2/1/0.2 translate 1-1 dot1q 100 +set int l2 tag-rewrite GigabitEthernet2/1/0.3 translate 1-1 dot1q 99 + +set int l2 efp-filter GigabitEthernet2/2/0 +set int l2 efp-filter GigabitEthernet2/2/0.1 +set int l2 efp-filter GigabitEthernet2/2/0.100 + + +l2fib add 00:00:00:00:00:11 0 GigabitEthernet2/2/0.1 static +l2fib add 00:00:00:00:00:22 0 GigabitEthernet2/2/0.100 static + +set int state GigabitEthernet2/1/0 up +set int state GigabitEthernet2/1/0.1 up +set int state GigabitEthernet2/1/0.2 up +set int state GigabitEthernet2/1/0.3 up +set int state GigabitEthernet2/2/0 up +set int state GigabitEthernet2/2/0.1 up +set int state GigabitEthernet2/2/0.100 up + + +trace add pg-input 6 + +clear error +clear run +clear int + +packet-generator new { + name post_vtr_pass + limit 9111003 + no-recycle + node ethernet-input + interface GigabitEthernet2/1/0 + data { + IP4: 0050.56b7.7c83 -> 00:00:00:00:00:22 vlan 2 + GRE: 8.0.0.1 -> 1.2.3.3 mpls_unicast + } +} diff --git a/src/scripts/vnet/l2fib b/src/scripts/vnet/l2fib new file mode 100644 index 00000000..81ede171 --- /dev/null +++ b/src/scripts/vnet/l2fib @@ -0,0 +1,46 @@ + +set int ip address GigabitEthernet2/1/0 1.2.3.4/24 +set int state GigabitEthernet2/1/0 up + +set int state GigabitEthernet2/2/0 up +cre sub GigabitEthernet2/2/0 1 dot1q 9 +set int state GigabitEthernet2/2/0.1 up +set int state tuntap-0 down + +set int acl input GigabitEthernet2/1/0 +set int acl output GigabitEthernet2/1/0 +set int acl input GigabitEthernet2/2/0.1 +set int acl output GigabitEthernet2/2/0.1 + +set int l2 bridge GigabitEthernet2/1/0 0 +set int l2 bridge GigabitEthernet2/2/0.1 0 + +set int l2 tag-rewrite GigabitEthernet2/1/0 push dot1q 50 +set int l2 tag-rewrite GigabitEthernet2/2/0.1 pop 1 + + +trace add pg-input 6 + +clear error +clear run +clear int + +packet-generator new { + name new_input_if_index_mac_move + limit 4 + no-recycle + node ethernet-input + interface GigabitEthernet2/1/0 + size 98-98 + data { hex 0x00010203040500020406080a080045006402b46b96000100096978676265000500bf436973636f20494f5320536f6674776172652c2040160011000000010101cc000400000000001a00100000000100000000ffffffff } +} + +packet-generator new { + name dmac_hit + limit 7 + no-recycle + node ethernet-input + interface GigabitEthernet2/2/0 + size 98-98 + data { hex 0x00020406080a00224406080a8100000981000011080045006402b46b96000100096978676265000500bf436973636f20494f5320536f6674776172652c2040160011000000010101cc000400000000001a00100000000100000000ffffffff } +} diff --git a/src/scripts/vnet/l2fib_perf b/src/scripts/vnet/l2fib_perf new file mode 100644 index 00000000..638317ff --- /dev/null +++ b/src/scripts/vnet/l2fib_perf @@ -0,0 +1,29 @@ + +set int ip address GigabitEthernet2/1/0 1.2.3.4/24 +set int state GigabitEthernet2/1/0 up + +set int state GigabitEthernet2/2/0 up +cre sub GigabitEthernet2/2/0 1 dot1q 9 +set int state GigabitEthernet2/2/0.1 up +set int state tuntap-0 down + +set int l2 bridge GigabitEthernet2/1/0 0 +set int l2 bridge GigabitEthernet2/2/0.1 0 + +l2fib add 00:22:44:06:08:0a 0 GigabitEthernet2/1/0 static +l2fib add 00:02:04:06:08:0a 0 GigabitEthernet2/2/0.1 static + +cle er +cle int +cle run + +packet-generator new { + name perf + limit 9111003 + no-recycle + node ethernet-input + interface GigabitEthernet2/2/0.1 + size 98-98 + data { hex 0x00224406080a00020406080a81000009080045006402b46b96000100096978676265000500bf436973636f20494f5320536f6674776172652c2040160011000000010101cc000400000000001a00100000000100000000ffffffff } +} + diff --git a/src/scripts/vnet/l2fib_xc b/src/scripts/vnet/l2fib_xc new file mode 100644 index 00000000..35d7342b --- /dev/null +++ b/src/scripts/vnet/l2fib_xc @@ -0,0 +1,31 @@ + +set int ip address GigabitEthernet2/1/0 1.2.3.4/24 +set int state GigabitEthernet2/1/0 up + +set int state GigabitEthernet2/2/0 up +cre sub GigabitEthernet2/2/0 1 dot1q 9 +set int state GigabitEthernet2/2/0.1 up +set int state tuntap-0 down + +set int acl input GigabitEthernet2/1/0 +set int acl output GigabitEthernet2/1/0 +set int acl input GigabitEthernet2/2/0.1 +set int acl output GigabitEthernet2/2/0.1 + +set int l2 xc GigabitEthernet2/1/0 GigabitEthernet2/2/0.1 +set int l2 xc GigabitEthernet2/2/0.1 GigabitEthernet2/1/0 + +clear error +clear run +clear int + +packet-generator new { + name xc + limit 11 + no-recycle + node ethernet-input + interface GigabitEthernet2/1/0 + size 98-98 + data { hex 0x00010203040500020406080a080045006402b46b96000100096978676265000500bf436973636f20494f5320536f6674776172652c2040160011000000010101cc000400000000001a00100000000100000000ffffffff } +} + diff --git a/src/scripts/vnet/l2flood b/src/scripts/vnet/l2flood new file mode 100644 index 00000000..013462ce --- /dev/null +++ b/src/scripts/vnet/l2flood @@ -0,0 +1,42 @@ + +set int ip address GigabitEthernet2/1/0 1.2.3.4/24 +set int state GigabitEthernet2/1/0 up +set int state tuntap-0 down + + +loop create +cre sub loop0 1 dot1q 1 +cre sub loop0 2 dot1q 2 +cre sub loop0 3 dot1q 3 +cre sub GigabitEthernet2/1/0 1 dot1q 1 + + +set int l2 bridge loop0.1 7 +set int l2 bridge loop0.2 7 +set int l2 bridge loop0.3 7 +set int l2 bridge GigabitEthernet2/1/0.1 7 + +loop cre +set int l2 bridge loop1 7 bvi + +set int state GigabitEthernet2/1/0.1 up + +trace add pg-input 6 + +clear error +clear run +clear int + +packet-generator new { + name flood + limit 1 + no-recycle + node ethernet-input + interface GigabitEthernet2/1/0 + data { + IP4: 0050.56b7.7c83 -> ffff.ffff.ffff vlan 1 + GRE: 8.0.0.1 -> 1.2.3.3 mpls_unicast + } + +} + diff --git a/src/scripts/vnet/l2tp b/src/scripts/vnet/l2tp new file mode 100644 index 00000000..337805aa --- /dev/null +++ b/src/scripts/vnet/l2tp @@ -0,0 +1,134 @@ + +set int ip address GigabitEthernet2/1/0 1.2.3.4/24 +set int state GigabitEthernet2/1/0 up +set int state tuntap-0 down + + +cre sub GigabitEthernet2/1/0 1 dot1q 1 +cre sub GigabitEthernet2/1/0 2 dot1q 2 +cre sub GigabitEthernet2/1/0 3 dot1q 3 +cre sub GigabitEthernet2/2/0 1 dot1q 1 +cre sub GigabitEthernet2/2/0 100 dot1q 100 + + +set int l2 tag-rewrite GigabitEthernet2/1/0.1 pop 1 +set int l2 tag-rewrite GigabitEthernet2/1/0.2 pop 1 + + +l2tp session add client 11::1 our 22::2 l2-interface GigabitEthernet2/1/0.1 +l2tp session add client 11::1 our 22::3 l2-interface GigabitEthernet2/1/0.2 local-session-id 2 l2-sublayer-present + +ip route 11::1/128 via GigabitEthernet2/2/0 +set ip6 neighbor GigabitEthernet2/2/0 11::1 00:02:04:06:08:0a + +enable ip6 interface GigabitEthernet2/2/0 + +set int ip6 l2tpv3 GigabitEthernet2/2/0 + +set int state GigabitEthernet2/1/0 up +set int state GigabitEthernet2/1/0.1 up +set int state GigabitEthernet2/1/0.2 up +set int state GigabitEthernet2/1/0.3 up +set int state GigabitEthernet2/2/0 up + + +trace add pg-input 2 + +clear error +clear run +clear int + +packet-generator new { + name decap + limit 10 + size 200-200 + no-recycle + node ethernet-input + interface GigabitEthernet2/2/0 + data { + IP6: 00:50:00:00:00:01 -> 00:50:56:b7:29:7a + L2TP: 11::1 -> 22::2 + L2TP: session_id 1 cookie 0xffffffffffffffff + IP4: 00:55:55:55:00:01 -> 00:dd:dd:dd:00:01 + UDP: 1.2.3.4 -> 5.6.7.8 + incrementing 8 + } +} + +packet-generator new { + name decap_bad_sid + limit 30 + size 200-200 + no-recycle + node ethernet-input + interface GigabitEthernet2/2/0 + data { + IP6: 00:50:00:00:00:01 -> 00:50:56:b7:29:7a + L2TP: 11::1 -> 22::2 + L2TP: session_id 0x999 cookie 0xffffffffffffffff + IP4: 00:55:55:55:00:01 -> 00:dd:dd:dd:00:01 + UDP: 1.2.3.4 -> 5.6.7.8 + incrementing 8 + } +} + +packet-generator new { + name decap_bad_cookie + limit 50 + size 200-200 + no-recycle + node ethernet-input + interface GigabitEthernet2/2/0 + data { + IP6: 00:50:00:00:00:01 -> 00:50:56:b7:29:7a + L2TP: 11::1 -> 22::2 + L2TP: session_id 1 cookie 0x3333ffffffffffff + IP4: 00:55:55:55:00:01 -> 00:dd:dd:dd:00:01 + UDP: 1.2.3.4 -> 5.6.7.8 + incrementing 8 + } +} + +packet-generator new { + name encap + limit 100 + no-recycle + node ethernet-input + interface GigabitEthernet2/1/0 + data { + IP4: 0000.5555.0002 -> 00:00:dd:dd:00:02 vlan 1 + UDP: 1.2.3.4 -> 5.6.7.8 + incrementing 8 + } +} + +packet-generator new { + name decap_sublayer + limit 300 + size 200-200 + no-recycle + node ethernet-input + interface GigabitEthernet2/2/0 + data { + IP6: 00:50:00:00:00:01 -> 00:50:56:b7:29:7a + L2TP: 11::1 -> 22::3 + L2TP: session_id 2 cookie 0xffffffffffffffff l2_sublayer 0 + IP4: 00:55:55:55:00:01 -> 00:dd:dd:dd:00:01 + UDP: 1.2.3.4 -> 5.6.7.8 + incrementing 8 + } +} + +packet-generator new { + name encap_sublayer + limit 700 + no-recycle + node ethernet-input + interface GigabitEthernet2/1/0 + data { + IP4: 0000.5555.0002 -> 00:00:dd:dd:00:02 vlan 2 + UDP: 1.2.3.4 -> 5.6.7.8 + incrementing 8 + } +} + diff --git a/src/scripts/vnet/leftpeer/leftpeer-classify b/src/scripts/vnet/leftpeer/leftpeer-classify new file mode 100755 index 00000000..74285912 --- /dev/null +++ b/src/scripts/vnet/leftpeer/leftpeer-classify @@ -0,0 +1,8 @@ +classify table mask l2 src l3 ip4 src buckets 2 miss-next local + +comment { classify table mask l3 ip4 src buckets 2 miss-next local } +set ip classify intfc GigabitEthernet2/2/0 table-index 0 +set int ip address GigabitEthernet2/2/0 192.168.1.1/24 +set int state GigabitEthernet2/2/0 up + +classify session hit-next local table-index 0 match l2 src 00:50:56:b7:05:bb l3 ip4 src 192.168.1.2 diff --git a/src/scripts/vnet/leftpeer/leftpeer-classify6 b/src/scripts/vnet/leftpeer/leftpeer-classify6 new file mode 100644 index 00000000..6579d50d --- /dev/null +++ b/src/scripts/vnet/leftpeer/leftpeer-classify6 @@ -0,0 +1,5 @@ +classify table mask l3 ip6 src buckets 2 miss-next local +set ip6 classify intfc GigabitEthernet2/2/0 table-index 0 +set int ip address GigabitEthernet2/2/0 db01::1/64 +set int state GigabitEthernet2/2/0 up +classify session hit-next local table-index 0 match l3 ip6 src db01::2 diff --git a/src/scripts/vnet/leftpeer/leftpeer-classifyl2 b/src/scripts/vnet/leftpeer/leftpeer-classifyl2 new file mode 100644 index 00000000..6be4b1e5 --- /dev/null +++ b/src/scripts/vnet/leftpeer/leftpeer-classifyl2 @@ -0,0 +1,8 @@ +set int ip address GigabitEthernet2/2/0 192.168.1.1/24 +set int state GigabitEthernet2/2/0 up + +classify table mask l3 ip4 src buckets 2 l2-miss-next ethernet + +classify session advance 14 l2-hit-next ip4 table-index 0 match l3 ip4 src 192.168.1.2 + +set int l2 class intfc GigabitEthernet2/2/0 ip4-table 0 diff --git a/src/scripts/vnet/leftpeer/leftpeer-dhcp b/src/scripts/vnet/leftpeer/leftpeer-dhcp new file mode 100644 index 00000000..c13a8f3a --- /dev/null +++ b/src/scripts/vnet/leftpeer/leftpeer-dhcp @@ -0,0 +1,23 @@ +loop cre +set int ip table loop0 12 +set int ip address loop0 192.168.1.1/24 +set int state loop0 up + +set int ip table GigabitEthernet2/2/0 12 +comment { set int ip address GigabitEthernet2/2/0 192.168.1.1/24 } +set int unnumbered GigabitEthernet2/2/0 use loop0 +set int state GigabitEthernet2/2/0 up + +set int ip table GigabitEthernet2/7/0 11 +set int ip address GigabitEthernet2/7/0 192.168.2.1/24 +set int state GigabitEthernet2/7/0 up + +uncomment { set dhcp proxy server 1.2.3.4 src-address 1.2.3.5 add-option-82 rx-fib-id 0 server-fib-id 0 } + +uncomment { set dhcp proxy server 192.168.2.2 src-address 192.168.2.1 add-option-82 rx-fib-id 12 server-fib-id 11 } + +ip route add 0.0.0.0/24 table 11 via local +ip route add 255.255.255.255/24 table 11 via local + +ip route add 0.0.0.0/24 table 12 via local +ip route add 255.255.255.255/24 table 12 via local diff --git a/src/scripts/vnet/leftpeer/leftpeer-ioam.conf b/src/scripts/vnet/leftpeer/leftpeer-ioam.conf new file mode 100644 index 00000000..6c1b502c --- /dev/null +++ b/src/scripts/vnet/leftpeer/leftpeer-ioam.conf @@ -0,0 +1,15 @@ +comment { connects to linux ping source eth1 addr db02::2/64 } +set int ip address GigabitEthernet2/2/0 db02::1/64 +set int state GigabitEthernet2/2/0 up + +comment { connects to ioam domain rightpeer eth2 addr db03::3/64 } +set int ip address GigabitEthernet2/3/0 db03::1/64 +set int state GigabitEthernet2/3/0 up + +ioam set rewrite trace-elts 2 pow + +set ip6 neighbor GigabitEthernet2/3/0 db03::3 00:50:56:b7:05:cb + +ip route add db04::0/64 via db03::3 + +ioam set destination db04::0/64 add diff --git a/src/scripts/vnet/leftpeer/leftpeer-l3vxlan.conf b/src/scripts/vnet/leftpeer/leftpeer-l3vxlan.conf new file mode 100644 index 00000000..a75f9b4c --- /dev/null +++ b/src/scripts/vnet/leftpeer/leftpeer-l3vxlan.conf @@ -0,0 +1,12 @@ +comment { tunnel to rightpeer 6.0.3.3 on vlan 101 } + +set int ip address GigabitEthernet2/3/0 6.0.3.1/24 +set int state GigabitEthernet2/3/0 up + +comment { configure lc2 eth1 at e.g. 6.0.2.2/24 } + +set int ip address GigabitEthernet2/2/0 6.0.2.1/24 +set int state GigabitEthernet2/2/0 up + +vxlan tunnel src 6.0.3.1 peer 6.0.3.3 vni 123 adj 6.0.4.4/24 + diff --git a/src/scripts/vnet/leftpeer/leftpeer-lisp.conf b/src/scripts/vnet/leftpeer/leftpeer-lisp.conf new file mode 100644 index 00000000..cb3180b7 --- /dev/null +++ b/src/scripts/vnet/leftpeer/leftpeer-lisp.conf @@ -0,0 +1,18 @@ +comment { vpe_phase2 configuration } + +comment { local client facing interface on vlan 100 } +comment { configure lc2 eth1 at e.g. 6.0.2.2/24 } + +set int ip address GigabitEthernet2/2/0 6.0.2.1/24 +set int state GigabitEthernet2/2/0 up + +comment { tunnel to rightpeer on vlan 101 } +set int ip address GigabitEthernet2/3/0 6.0.3.1/24 +set int state GigabitEthernet2/3/0 up + +lisp gpe tunnel src 6.0.3.1 dst 6.0.3.3 next-ip4 decap-next ip4 iid 1133 +set int ip address lisp_gpe_tunnel0 6.0.4.1/24 +set int state lisp_gpe_tunnel0 up + +lisp gpe tunnel src 6.0.3.3 dst 6.0.3.1 next-ip4 decap-next ip4 iid 3311 +set int stat lisp_gpe_tunnel1 up diff --git a/src/scripts/vnet/leftpeer/leftpeer-mpls.conf b/src/scripts/vnet/leftpeer/leftpeer-mpls.conf new file mode 100644 index 00000000..74bce81b --- /dev/null +++ b/src/scripts/vnet/leftpeer/leftpeer-mpls.conf @@ -0,0 +1,17 @@ +comment { vpe_phase2 configuration } + +comment { local client facing interface on vlan 100 } +comment { configure lc2 eth1 at e.g. 6.0.2.2/24 } + +set int ip table GigabitEthernet2/2/0 1 +set int ip address GigabitEthernet2/2/0 6.0.2.1/24 +set int state GigabitEthernet2/2/0 up + +comment { tunnel to rightpeer on vlan 101 } +set int ip address GigabitEthernet2/3/0 6.0.3.1/24 +set int state GigabitEthernet2/3/0 up + +mpls encap add label 30 fib 1 dest 6.0.3.3 +mpls decap add label 30 fib 1 + +create mpls gre tunnel src 6.0.3.1 dst 6.0.3.3 intfc 6.0.4.1/24 inner-fib-id 1 outer-fib-id 0 diff --git a/src/scripts/vnet/leftpeer/leftpeer-sr.conf b/src/scripts/vnet/leftpeer/leftpeer-sr.conf new file mode 100644 index 00000000..a7b962d3 --- /dev/null +++ b/src/scripts/vnet/leftpeer/leftpeer-sr.conf @@ -0,0 +1,24 @@ +comment { test sr segment chunk-offset on } +test sr hmac validate on + +comment { trunk to rightpeer } +set int ip address GigabitEthernet2/3/0 db03::2/64 +enable ip6 interface GigabitEthernet2/3/0 +set int state GigabitEthernet2/3/0 up + +comment { subscriber linux-ping-source } +set int ip address GigabitEthernet2/2/0 db02::2/64 +enable ip6 interface GigabitEthernet2/2/0 +set int state GigabitEthernet2/2/0 up + +sr hmac id 2 key Gozzer +sr hmac id 3 key Hoser + +sr tunnel src db01::1 dst db04::1/128 next db03::1 next db04::1 tag db02::2 clean key Gozzer InPE 1 + +tap connect srlocal hwaddr random +set int ip6 table tap-0 1 +set int ip address tap-0 db04::99/64 +enable ip6 interface tap-0 +set int state tap-0 up +ip route add table 1 db02::0/64 lookup in table 0 diff --git a/src/scripts/vnet/leftpeer/leftpeer-vxlan.conf b/src/scripts/vnet/leftpeer/leftpeer-vxlan.conf new file mode 100644 index 00000000..d50e8bf4 --- /dev/null +++ b/src/scripts/vnet/leftpeer/leftpeer-vxlan.conf @@ -0,0 +1,17 @@ +comment { tunnel to rightpeer 6.0.3.3 on vlan 101 } + +set int ip address GigabitEthernet2/3/0 6.0.3.1/24 +set int state GigabitEthernet2/3/0 up + +comment { tunnel to thirdpeer 6.0.5.5 on vlan 105 } +set int ip address GigabitEthernet2/7/0 6.0.5.1/24 +set int state GigabitEthernet2/7/0 up + +comment { configure lc2 eth1 at e.g. 6.0.2.2/24 } + +set int ip address GigabitEthernet2/2/0 6.0.2.1/24 +set int state GigabitEthernet2/2/0 up + +vxlan tunnel src 6.0.3.1 peer 6.0.3.3 peer 6.0.3.5 vni 123 +vxlan l2 GigabitEthernet2/2/0 vni 123 + diff --git a/src/scripts/vnet/leftpeer/leftpeer.script b/src/scripts/vnet/leftpeer/leftpeer.script new file mode 100644 index 00000000..f08c8090 --- /dev/null +++ b/src/scripts/vnet/leftpeer/leftpeer.script @@ -0,0 +1,9 @@ +l2tp_set_lookup_key lookup_v6_src + +sw_interface_add_del_address GigabitEthernet2/3/0 db03::2/64 +sw_interface_set_flags GigabitEthernet2/3/0 admin-up + +comment sw_interface_add_del_address GigabitEthernet2/2/0 db02::2/64 +sw_interface_set_flags GigabitEthernet2/2/0 admin-up + +l2tp_session_add_del client_address db03::1 our_address db03::2 GigabitEthernet2/2/0 local_session_id 1 remote_session_id 3 local_cookie 11 remote_cookie 33 diff --git a/src/scripts/vnet/lfib/ip4-to-mpls b/src/scripts/vnet/lfib/ip4-to-mpls new file mode 100644 index 00000000..85753797 --- /dev/null +++ b/src/scripts/vnet/lfib/ip4-to-mpls @@ -0,0 +1,26 @@ +packet-generator new { + name x + limit 1 + node ip4-input + size 64-64 + no-recycle + data { + ICMP: 1.0.0.2 -> 2.2.2.2 + ICMP echo_request + incrementing 100 + } +} + +loop create +loop create +set int state loop0 up +set int state loop1 up + +set int ip address loop0 1.0.0.1/24 +set int ip address loop1 2.0.0.1/24 + +set ip arp static loop1 2.0.0.2 dead.beef.babe +set int mpls loop1 enable +ip route add 2.2.2.2/32 via 2.0.0.2 loop1 out-label 33 + +trace add pg-input 100 diff --git a/src/scripts/vnet/lfib/mpls-pop-to-mpls b/src/scripts/vnet/lfib/mpls-pop-to-mpls new file mode 100644 index 00000000..2818ac13 --- /dev/null +++ b/src/scripts/vnet/lfib/mpls-pop-to-mpls @@ -0,0 +1,28 @@ +packet-generator new { + name x + limit 1 + node mpls-input + size 72-72 + no-recycle + data { + hex 0x0001e0ff0001f1ff4500004000000000400177ba010000020202020208007a6e000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f2021222324252627 + } +} + +loop create +loop create +set int state loop0 up +set int state loop1 up + +set int ip address loop0 1.0.0.1/24 +set int ip address loop1 2.0.0.1/24 + +set ip arp static loop1 2.0.0.2 dead.beef.babe +set int mpls loop1 enable + +ip route add 2.2.2.2/32 via 2.0.0.2 loop1 out-label 33 + +mpls local-label add 30 non-eos mpls-lookup-in-table 0 +mpls local-label add 31 2.2.2.2/32 + +trace add pg-input 100 diff --git a/src/scripts/vnet/lfib/mpls-to-ip4 b/src/scripts/vnet/lfib/mpls-to-ip4 new file mode 100644 index 00000000..24e235e0 --- /dev/null +++ b/src/scripts/vnet/lfib/mpls-to-ip4 @@ -0,0 +1,27 @@ +packet-generator new { + name x + limit 1 + node mpls-input + size 68-68 + no-recycle + data { + hex 0x0001e1ff4500004000000000400177ba010000020202020208007a6e000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f2021222324252627 + } +} + +loop create +loop create +set int state loop0 up +set int state loop1 up + +set int ip address loop0 1.0.0.1/24 +set int ip address loop1 2.0.0.1/24 + +set ip arp static loop1 2.0.0.2 dead.beef.babe +set int mpls loop1 enable + +ip route add 2.2.2.2/32 via 2.0.0.2 loop1 out-label 33 + +mpls local-label add 30 eos ip4-lookup-in-table 0 + +trace add pg-input 100 diff --git a/src/scripts/vnet/lfib/mpls-to-mpls b/src/scripts/vnet/lfib/mpls-to-mpls new file mode 100644 index 00000000..497dbab3 --- /dev/null +++ b/src/scripts/vnet/lfib/mpls-to-mpls @@ -0,0 +1,26 @@ +packet-generator new { + name x + limit 1 + node mpls-input + size 68-68 + no-recycle + data { + hex 0x0001e1ff4500004000000000400177ba010000020200000208007a6e000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f2021222324252627 + } +} + +loop create +loop create +set int state loop0 up +set int state loop1 up + +set int ip address loop0 1.0.0.1/24 +set int ip address loop1 2.0.0.1/24 + +set ip arp static loop1 2.0.0.2 dead.beef.babe +set int mpls loop1 enable + +ip route add 2.2.2.2/32 via 2.0.0.2 loop1 out-label 33 +mpls local-label add 30 2.2.2.2/32 + +trace add pg-input 100 diff --git a/src/scripts/vnet/mpls-o-ethernet/leftpeer.conf b/src/scripts/vnet/mpls-o-ethernet/leftpeer.conf new file mode 100644 index 00000000..dd37b942 --- /dev/null +++ b/src/scripts/vnet/mpls-o-ethernet/leftpeer.conf @@ -0,0 +1,17 @@ +comment { vpe_phase2 configuration } + +comment { local client facing interface } +comment { configure lc2 eth1 at e.g. 6.0.2.2/24 } + +set int ip table GigabitEthernet2/2/0 1 +set int ip address GigabitEthernet2/2/0 6.0.2.1/24 +set int state GigabitEthernet2/2/0 up + +comment { tunnel to rightpeer } +set int ip address GigabitEthernet2/3/0 6.0.3.1/24 +set int state GigabitEthernet2/3/0 up + +mpls encap add label 30 fib 1 dest 6.0.4.1 +mpls decap add label 30 fib 1 + +create mpls ethernet tunnel dst 00:50:56:b7:05:cb adj 6.0.4.1/24 tx-intfc GigabitEthernet2/3/0 fib-id 1 diff --git a/src/scripts/vnet/mpls-o-ethernet/pg b/src/scripts/vnet/mpls-o-ethernet/pg new file mode 100644 index 00000000..ba5397f7 --- /dev/null +++ b/src/scripts/vnet/mpls-o-ethernet/pg @@ -0,0 +1,10 @@ +packet-generator new { + name x + limit 1 + node mpls-ethernet-input + size 68-68 + no-recycle + data { + hex 0x0001e1ff4500004000000000400177ba010000020200000208007a6e000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f2021222324252627 + } +} \ No newline at end of file diff --git a/src/scripts/vnet/mpls-o-ethernet/rightpeer.conf b/src/scripts/vnet/mpls-o-ethernet/rightpeer.conf new file mode 100644 index 00000000..7709ce4d --- /dev/null +++ b/src/scripts/vnet/mpls-o-ethernet/rightpeer.conf @@ -0,0 +1,15 @@ +comment { local client facing interface } +comment { configure lc4 eth1 at e.g. 6.0.4.4/24 } + +set int ip table GigabitEthernet2/4/0 1 +set int ip address GigabitEthernet2/4/0 6.0.4.1/24 +set int state GigabitEthernet2/4/0 up + +comment { tunnel to leftpeer } +set int ip address GigabitEthernet2/3/0 6.0.3.3/24 +set int state GigabitEthernet2/3/0 up + +mpls encap add label 30 fib 1 dest 6.0.2.1 +mpls decap add label 30 fib 1 + +create mpls ethernet tunnel dst 00:50:56:b7:05:bf adj 6.0.2.1/24 tx-intfc GigabitEthernet2/3/0 fib-id 1 diff --git a/src/scripts/vnet/mpls-o-ethernet/single.conf b/src/scripts/vnet/mpls-o-ethernet/single.conf new file mode 100644 index 00000000..2a25d355 --- /dev/null +++ b/src/scripts/vnet/mpls-o-ethernet/single.conf @@ -0,0 +1,17 @@ +comment { single node configuration } + +loop create +loop create +set int state loop0 up +set int state loop1 up + +set int ip address loop0 1.0.0.1/24 +set int ip address loop1 2.0.0.1/24 + + +ip route add 2.2.2.2/32 via 2.0.0.2 loop1 + +mpls encap add label 30 fib 0 dest 2.2.2.2 +mpls decap add label 30 fib 0 + +create mpls ethernet tunnel dst 00:50:56:b7:05:cb adj 2.2.2.2/32 tx-intfc loop1 fib-id 0 diff --git a/src/scripts/vnet/mpls-o-gre/dhcpd.conf b/src/scripts/vnet/mpls-o-gre/dhcpd.conf new file mode 100644 index 00000000..f0f659cd --- /dev/null +++ b/src/scripts/vnet/mpls-o-gre/dhcpd.conf @@ -0,0 +1,116 @@ +# +# Sample configuration file for ISC dhcpd for Debian +# +# Attention: If /etc/ltsp/dhcpd.conf exists, that will be used as +# configuration file instead of this file. +# +# + +# The ddns-updates-style parameter controls whether or not the server will +# attempt to do a DNS update when a lease is confirmed. We default to the +# behavior of the version 2 packages ('none', since DHCP v2 didn't +# have support for DDNS.) +ddns-update-style none; + +# option definitions common to all supported networks... +option domain-name "example.org"; +option domain-name-servers ns1.example.org, ns2.example.org; + +default-lease-time 600; +max-lease-time 7200; + +# If this DHCP server is the official DHCP server for the local +# network, the authoritative directive should be uncommented. +#authoritative; + +# Use this to send dhcp log messages to a different log file (you also +# have to hack syslog.conf to complete the redirection). +log-facility local7; + +# No service will be given on this subnet, but declaring it helps the +# DHCP server to understand the network topology. + +#subnet 10.152.187.0 netmask 255.255.255.0 { +#} + +# This is a very basic subnet declaration. + +#subnet 10.254.239.0 netmask 255.255.255.224 { +# range 10.254.239.10 10.254.239.20; +# option routers rtr-239-0-1.example.org, rtr-239-0-2.example.org; +#} + +# This declaration allows BOOTP clients to get dynamic addresses, +# which we don't really recommend. + +#subnet 10.254.239.32 netmask 255.255.255.224 { +# range dynamic-bootp 10.254.239.40 10.254.239.60; +# option broadcast-address 10.254.239.31; +# option routers rtr-239-32-1.example.org; +#} + +# A slightly different configuration for an internal subnet. +#subnet 10.5.5.0 netmask 255.255.255.224 { +# range 10.5.5.26 10.5.5.30; +# option domain-name-servers ns1.internal.example.org; +# option domain-name "internal.example.org"; +# option routers 10.5.5.1; +# option broadcast-address 10.5.5.31; +# default-lease-time 600; +# max-lease-time 7200; +#} + +# Hosts which require special configuration options can be listed in +# host statements. If no address is specified, the address will be +# allocated dynamically (if possible), but the host-specific information +# will still come from the host declaration. + +#host passacaglia { +# hardware ethernet 0:0:c0:5d:bd:95; +# filename "vmunix.passacaglia"; +# server-name "toccata.fugue.com"; +#} + +# Fixed IP addresses can also be specified for hosts. These addresses +# should not also be listed as being available for dynamic assignment. +# Hosts for which fixed IP addresses have been specified can boot using +# BOOTP or DHCP. Hosts for which no fixed address is specified can only +# be booted with DHCP, unless there is an address range on the subnet +# to which a BOOTP client is connected which has the dynamic-bootp flag +# set. +#host fantasia { +# hardware ethernet 08:00:07:26:c0:a5; +# fixed-address fantasia.fugue.com; +#} + +# You can declare a class of clients and then do address allocation +# based on that. The example below shows a case where all clients +# in a certain class get addresses on the 10.17.224/24 subnet, and all +# other clients get addresses on the 10.0.29/24 subnet. + +#class "foo" { +# match if substring (option vendor-class-identifier, 0, 4) = "SUNW"; +#} + +#shared-network 224-29 { +# subnet 10.17.224.0 netmask 255.255.255.0 { +# option routers rtr-224.example.org; +# } +# subnet 10.0.29.0 netmask 255.255.255.0 { +# option routers rtr-29.example.org; +# } +# pool { +# allow members of "foo"; +# range 10.17.224.10 10.17.224.250; +# } +# pool { +# deny members of "foo"; +# range 10.0.29.10 10.0.29.230; +# } +#} +subnet 6.0.0.0 netmask 255.255.0.0 { + range 6.0.2.2 6.0.2.5; + option routers 6.0.2.1; + default-lease-time 15; + max-lease-time 15; +} diff --git a/src/scripts/vnet/mpls-o-gre/leftpeer.conf b/src/scripts/vnet/mpls-o-gre/leftpeer.conf new file mode 100644 index 00000000..149c70c0 --- /dev/null +++ b/src/scripts/vnet/mpls-o-gre/leftpeer.conf @@ -0,0 +1,14 @@ +comment { left linux ping target configure at e.g. 6.0.2.2/24 } + +set int ip table GigabitEthernet2/2/0 1 +set int ip address GigabitEthernet2/2/0 6.0.2.1/24 +set int state GigabitEthernet2/2/0 up + +comment { tunnel to rightpeer } +set int ip address GigabitEthernet2/3/0 6.0.3.1/24 +set int state GigabitEthernet2/3/0 up + +mpls encap add label 30 fib 1 dest 6.0.3.3 +mpls decap add label 30 fib 1 + +create mpls gre tunnel src 6.0.3.1 dst 6.0.3.3 intfc 6.0.4.1/24 inner-fib-id 1 outer-fib-id 0 diff --git a/src/scripts/vnet/mpls-o-gre/rightpeer.conf b/src/scripts/vnet/mpls-o-gre/rightpeer.conf new file mode 100644 index 00000000..b5bb597d --- /dev/null +++ b/src/scripts/vnet/mpls-o-gre/rightpeer.conf @@ -0,0 +1,14 @@ +comment { right linux ping target configure e.g. 6.0.4.4/24 } + +set int ip table GigabitEthernet2/4/0 1 +set int ip address GigabitEthernet2/4/0 6.0.4.1/24 +set int state GigabitEthernet2/4/0 up + +comment { tunnel to leftpeer } +set int ip address GigabitEthernet2/3/0 6.0.3.3/24 +set int state GigabitEthernet2/3/0 up + +mpls encap add label 30 fib 1 dest 6.0.3.1 +mpls decap add label 30 fib 1 + +create mpls gre tunnel src 6.0.3.3 dst 6.0.3.1 intfc 6.0.2.1/24 inner-fib-id 1 outer-fib-id 0 diff --git a/src/scripts/vnet/mpls-tunnel b/src/scripts/vnet/mpls-tunnel new file mode 100644 index 00000000..d04b2970 --- /dev/null +++ b/src/scripts/vnet/mpls-tunnel @@ -0,0 +1,87 @@ +packet-generator new { + name x0 + limit 1 + node ip4-input + size 64-64 + no-recycle + data { + ICMP: 1.0.0.2 -> 2.0.0.2 + ICMP echo_request + incrementing 100 + } +} +packet-generator new { + name x1 + limit 1 + node ip4-input + size 64-64 + no-recycle + data { + ICMP: 1.0.0.2 -> 2.0.1.2 + ICMP echo_request + incrementing 100 + } +} +packet-generator new { + name x2 + limit 1 + node ip4-input + size 64-64 + no-recycle + data { + ICMP: 1.0.0.2 -> 2.0.2.2 + ICMP echo_request + incrementing 100 + } +} +packet-generator new { + name x3 + limit 1 + node ip4-input + size 64-64 + no-recycle + data { + ICMP: 1.0.0.2 -> 2.0.3.2 + ICMP echo_request + incrementing 100 + } +} + + + +trace add pg-input 100 + +loop create +set int state loop0 up + +set int ip address loop0 10.0.0.1/24 +set ip arp loop0 10.0.0.2 00:00:11:aa:bb:cc + +mpls tunnel add via 10.0.0.2 loop0 out-label 33 out-label 34 out-label 35 out-label 36 +set int state mpls-tunnel0 up +set int ip addr mpls-tunnel0 192.168.0.1/32 +ip route add 2.0.0.2/32 via 192.168.0.2 mpls-tunnel0 + + +mpls tunnel add via 10.0.0.2 out-label 33 +set int state mpls-tunnel1 up +set int ip addr mpls-tunnel1 192.168.1.1/32 +ip route add 2.0.1.2/32 via 192.168.1.2 mpls-tunnel1 out-label 99 + +mpls tunnel add via 10.0.0.2 loop0 out-label 3 +set int state mpls-tunnel2 up +set int ip addr mpls-tunnel2 192.168.2.1/32 +ip route add 2.0.2.2/32 via 192.168.2.2 mpls-tunnel2 + + +mpls tunnel add l2-only via 10.0.0.2 loop0 out-label 234 out-label 0 +set int state mpls-tunnel3 up +set int l2 bridge mpls-tunnel3 1 + +loop create +set int ip addr loop1 6.0.1.44/24 +set int l2 bridge loop1 1 bvi +set int l2 learn loop1 disable +set int state loop1 up + +ip route add 2.0.3.2/32 via 6.0.1.45 loop1 diff --git a/src/scripts/vnet/pcap b/src/scripts/vnet/pcap new file mode 100644 index 00000000..692e5f27 --- /dev/null +++ b/src/scripts/vnet/pcap @@ -0,0 +1,18 @@ +packet-generator new { + name x + limit 1 + node ethernet-input + no-recycle + pcap /home/eliot/pcap-data/ISIS_level1_adjacency.cap +} + +packet-generator new { + name y + limit 1 + node hdlc-input + no-recycle + pcap /home/eliot/pcap-data/ISIS_p2p_adjacency.cap +} + +tr add pg-input 10 + diff --git a/src/scripts/vnet/probe4 b/src/scripts/vnet/probe4 new file mode 100644 index 00000000..b530e0db --- /dev/null +++ b/src/scripts/vnet/probe4 @@ -0,0 +1,11 @@ +ethernet create-interfaces +set int state fake-eth0 up +set int ip address fake-eth0 1.0.0.1/24 +comment { error } +comment { ip probe fake-eth0 1.0.0.1 } +comment { ip probe fake-eth0 1.2.3.4 } +comment { error } +comment { ip probe fake-eth0 1.0.0.2 } + + + diff --git a/src/scripts/vnet/probe6 b/src/scripts/vnet/probe6 new file mode 100644 index 00000000..a5490c90 --- /dev/null +++ b/src/scripts/vnet/probe6 @@ -0,0 +1,7 @@ +ethernet create-interfaces +set int state fake-eth0 up +set int ip address fake-eth0 2000::1/64 +comment { ip probe fake-eth0 2000::1 } + + + diff --git a/src/scripts/vnet/rewrite b/src/scripts/vnet/rewrite new file mode 100644 index 00000000..d41b9dbf --- /dev/null +++ b/src/scripts/vnet/rewrite @@ -0,0 +1,62 @@ + + +comment { test ipv4 port/vlan/qinq rewrites by generating arps } + +set int state tuntap-0 down + +set int ip address GigabitEthernet2/2/0 1.2.5.4/24 + +cre sub GigabitEthernet2/2/0 1 dot1q 6 exact-match +set int ip address GigabitEthernet2/2/0.1 1.2.6.4/24 + +cre sub GigabitEthernet2/2/0 2 dot1ad 7 inner-dot1q 8 exact-match +set int ip address GigabitEthernet2/2/0.2 1.2.7.4/24 + +set int state GigabitEthernet2/1/0 up +set int state GigabitEthernet2/2/0 up +set int state GigabitEthernet2/2/0.1 up +set int state GigabitEthernet2/2/0.2 up + +trace add pg-input 2 + +cle er +cle int +cle run + +packet-generator new { + name toport + limit 2 + no-recycle + node ethernet-input + interface GigabitEthernet2/1/0 + data { + IP4: 0050.56b7.7c83 -> 0050.56b7.296d + GRE: 8.0.0.1 -> 1.2.5.6 mpls_unicast + } +} + +packet-generator new { + name tovlan + limit 2 + no-recycle + node ethernet-input + interface GigabitEthernet2/1/0 + data { + IP4: 0050.56b7.7c83 -> 0050.56b7.296d + GRE: 8.0.0.1 -> 1.2.6.6 mpls_unicast + } +} + +packet-generator new { + name toqinq + limit 2 + no-recycle + node ethernet-input + interface GigabitEthernet2/1/0 + data { + IP4: 0050.56b7.7c83 -> 0050.56b7.296d + GRE: 8.0.0.1 -> 1.2.7.6 mpls_unicast + } +} + + diff --git a/src/scripts/vnet/rightpeer/rightpeer-ioam.conf b/src/scripts/vnet/rightpeer/rightpeer-ioam.conf new file mode 100644 index 00000000..3e9a8d34 --- /dev/null +++ b/src/scripts/vnet/rightpeer/rightpeer-ioam.conf @@ -0,0 +1,14 @@ +comment { connects to right ping target eth3 addr db04::4/64 } +set int ip address GigabitEthernet2/4/0 db04::1/64 +set int state GigabitEthernet2/4/0 up + +comment { connects to ioam domain leftpeer addr db03::1/64 } +set int ip address GigabitEthernet2/3/0 db03::3/64 +set int state GigabitEthernet2/3/0 up + +set ip6 neighbor GigabitEthernet2/3/0 db03::1 00:50:56:b7:05:bf +set ip6 neighbor GigabitEthernet2/4/0 db04::4 00:50:56:b7:05:d2 + +ip route add db02::0/64 via db03::1 + +ioam set destination db04::4/128 pop diff --git a/src/scripts/vnet/rightpeer/rightpeer-l3vxlan.conf b/src/scripts/vnet/rightpeer/rightpeer-l3vxlan.conf new file mode 100644 index 00000000..abba1ab0 --- /dev/null +++ b/src/scripts/vnet/rightpeer/rightpeer-l3vxlan.conf @@ -0,0 +1,9 @@ +set int ip address GigabitEthernet2/4/0 6.0.4.1/24 +set int state GigabitEthernet2/4/0 up + +comment { tunnel to leftpeer on vlan 101 } +set int ip address GigabitEthernet2/3/0 6.0.3.3/24 +set int state GigabitEthernet2/3/0 up + +vxlan tunnel src 6.0.3.3 peer 6.0.3.1 vni 123 adj 6.0.2.0/24 + diff --git a/src/scripts/vnet/rightpeer/rightpeer-lisp.conf b/src/scripts/vnet/rightpeer/rightpeer-lisp.conf new file mode 100644 index 00000000..961204a3 --- /dev/null +++ b/src/scripts/vnet/rightpeer/rightpeer-lisp.conf @@ -0,0 +1,16 @@ +comment { local client facing interface } +comment { configure lc4 eth1 at e.g. 6.0.4.4/24 } + +set int ip address GigabitEthernet2/4/0 6.0.4.1/24 +set int state GigabitEthernet2/4/0 up + +comment { tunnel to leftpeer } +set int ip address GigabitEthernet2/3/0 6.0.3.3/24 +set int state GigabitEthernet2/3/0 up + +lisp gpe tunnel src 6.0.3.3 dst 6.0.3.1 next-ip4 decap-next ip4 iid 3311 +set int ip address lisp_gpe_tunnel0 6.0.2.3/24 +set int state lisp_gpe_tunnel0 up + +lisp gpe tunnel src 6.0.3.1 dst 6.0.3.3 next-ip4 decap-next ip4 iid 1133 +set int state lisp_gpe_tunnel1 up diff --git a/src/scripts/vnet/rightpeer/rightpeer-mpls-l2.conf b/src/scripts/vnet/rightpeer/rightpeer-mpls-l2.conf new file mode 100644 index 00000000..0ce38583 --- /dev/null +++ b/src/scripts/vnet/rightpeer/rightpeer-mpls-l2.conf @@ -0,0 +1,24 @@ +comment { vpe_phase1d configuration } + +comment { local client facing interface } +comment { configure lc4 eth1 at e.g. 6.0.4.4/24 } + +set int ip table GigabitEthernet2/4/0 1 +set int ip address GigabitEthernet2/4/0 6.0.4.1/24 +set int state GigabitEthernet2/4/0 up + +comment { tunnel to leftpeer } +set int ip address GigabitEthernet2/3/0 6.0.3.3/24 +set int state GigabitEthernet2/3/0 up + +mpls encap add label 30 fib 1 dest 6.0.3.1 +mpls decap add label 30 next output GigabitEthernet2/4/0 + +comment { create mpls gre tunnel src 6.0.3.3 dst 6.0.3.1 intfc 6.0.2.1/24 inner-fib-id 1 outer-fib-id 0 l2-only } + +comment {set int l2 xconnect GigabitEthernet2/4/0 mpls-gre0 } + +uncomment { create mpls ethernet tunnel dst 00:50:56:b7:05:bf adj 6.0.3.1/8 l2-only tx-intfc GigabitEthernet2/3/0 fib-id 1 } + +uncomment { set int l2 xconnect GigabitEthernet2/4/0 mpls-eth0 } + diff --git a/src/scripts/vnet/rightpeer/rightpeer-mpls.conf b/src/scripts/vnet/rightpeer/rightpeer-mpls.conf new file mode 100644 index 00000000..fc97ba16 --- /dev/null +++ b/src/scripts/vnet/rightpeer/rightpeer-mpls.conf @@ -0,0 +1,17 @@ +comment { vpe_phase1d configuration } + +comment { local client facing interface } +comment { configure lc4 eth1 at e.g. 6.0.4.4/24 } + +set int ip table GigabitEthernet2/4/0 1 +set int ip address GigabitEthernet2/4/0 6.0.4.1/24 +set int state GigabitEthernet2/4/0 up + +comment { tunnel to leftpeer } +set int ip address GigabitEthernet2/3/0 6.0.3.3/24 +set int state GigabitEthernet2/3/0 up + +mpls encap add label 30 fib 1 dest 6.0.3.1 +mpls decap add label 30 fib 1 + +create mpls gre tunnel src 6.0.3.3 dst 6.0.3.1 intfc 6.0.2.1/24 inner-fib-id 1 outer-fib-id 0 diff --git a/src/scripts/vnet/rightpeer/rightpeer-sr.conf b/src/scripts/vnet/rightpeer/rightpeer-sr.conf new file mode 100644 index 00000000..0b2a98bb --- /dev/null +++ b/src/scripts/vnet/rightpeer/rightpeer-sr.conf @@ -0,0 +1,28 @@ +comment { test sr segment chunk-offset on } +test sr hmac validate on + +comment { trunk to leftpeer } +set int ip address GigabitEthernet2/3/0 db03::1/64 +enable ip6 interface GigabitEthernet2/3/0 +set int state GigabitEthernet2/3/0 up + +comment { subscriber right peer target } +set int ip address GigabitEthernet2/4/0 db04::2/64 + +comment { next address to fake out ND on shared LAN segment } +comment { set int ip address GigabitEthernet2/4/0 db02::13/64 } + +enable ip6 interface GigabitEthernet2/4/0 +set int state GigabitEthernet2/4/0 up + +sr hmac id 2 key Gozzer +sr hmac id 3 key Hoser + +sr tunnel src db04::1 dst db02::1/128 next db03::2 next db02::1 tag db04::2 clean key Hoser + +tap connect srlocal hwaddr random +set int ip6 table tap-0 1 +set int ip address tap-0 db04::99/64 +enable ip6 interface tap-0 +set int state tap-0 up +ip route add table 1 db02::0/64 lookup in table 0 diff --git a/src/scripts/vnet/rightpeer/rightpeer-vxlan.conf b/src/scripts/vnet/rightpeer/rightpeer-vxlan.conf new file mode 100644 index 00000000..bd4c427e --- /dev/null +++ b/src/scripts/vnet/rightpeer/rightpeer-vxlan.conf @@ -0,0 +1,16 @@ + +comment { local client facing interface } + +comment { configure client lc4 eth1 } +set int state GigabitEthernet2/4/0 up + +comment { tunnel to leftpeer } +set int ip address GigabitEthernet2/3/0 6.0.3.3/24 +set int state GigabitEthernet2/3/0 up + +comment { tunnel to extra ping target } +set int ip address GigabitEthernet2/7/0 6.0.5.3/24 +set int state GigabitEthernet2/3/0 up + +vxlan tunnel src 6.0.3.3 peer 6.0.3.1 peer 6.0.3.5 vni 123 +vxlan l2 GigabitEthernet2/4/0 vni 123 diff --git a/src/scripts/vnet/rightpeer/rightpeer.script b/src/scripts/vnet/rightpeer/rightpeer.script new file mode 100644 index 00000000..153988ce --- /dev/null +++ b/src/scripts/vnet/rightpeer/rightpeer.script @@ -0,0 +1,9 @@ +l2tp_set_lookup_key lookup_v6_src + +sw_interface_add_del_address GigabitEthernet2/3/0 db03::1/64 +sw_interface_set_flags GigabitEthernet2/3/0 admin-up + +comment sw_interface_add_del_address GigabitEthernet2/4/0 db02::2/64 +sw_interface_set_flags GigabitEthernet2/4/0 admin-up + +l2tp_session_add_del client_address db03::2 our_address db03::1 GigabitEthernet2/4/0 local_session_id 3 remote_session_id 1 local_cookie 33 remote_cookie 11 diff --git a/src/scripts/vnet/rpf b/src/scripts/vnet/rpf new file mode 100644 index 00000000..571c6b79 --- /dev/null +++ b/src/scripts/vnet/rpf @@ -0,0 +1,18 @@ +packet-generator new { + name x + limit 1 + node ip4-input + size 64-64 + no-recycle + data { + ICMP: 1.2.3.4 -> 5.6.7.8 + ICMP echo_request + incrementing 100 + } +} + +tr add pg-input 100 +set interface ip source-check pg/stream-0 +ip route 1.2.3.4/32 via pg/stream-0 0x01020304 +ip route 5.6.7.8/32 via drop + diff --git a/src/scripts/vnet/rtt-test b/src/scripts/vnet/rtt-test new file mode 100644 index 00000000..5501b99d --- /dev/null +++ b/src/scripts/vnet/rtt-test @@ -0,0 +1,31 @@ +set int state TenGigabitEthernet4/0/0 up +set int state TenGigabitEthernet5/0/0 up + +set int ip address TenGigabitEthernet4/0/0 1.0.0.1/24 +set int ip address TenGigabitEthernet5/0/0 2.0.0.1/24 + +ip route table 0 1.0.0.2/32 via TenGigabitEthernet4/0/0 IP4: 00:1b:21:74:5b:04 -> 00:1b:21:79:8e:bc +ip route table 0 2.0.0.2/32 via TenGigabitEthernet5/0/0 IP4: 00:1b:21:79:8e:bc -> 00:1b:21:74:5b:04 +ip route table 1 2.0.0.2/32 via local +ip route table 1 1.0.0.2/32 via local + +set int ip table TenGigabitEthernet5/0/0 1 +set int ip table TenGigabitEthernet4/0/0 1 + +comment { trace add rtt-test-tx 100 } +comment { trace add ixge-input 100 } +comment { te rtt { 1.0.0.2 -> 2.0.0.2 count 1e4 rate 1e9 size 100 histogram-time 1e-5 } } + +packet-generator new { + name x + limit 1 + node ip4-input + size 170-170 + data { + ICMP: 1.0.0.2 -> 2.0.0.2 + ICMP echo_request + incrementing 100 + } +} + + diff --git a/src/scripts/vnet/snat b/src/scripts/vnet/snat new file mode 100644 index 00000000..87fd699e --- /dev/null +++ b/src/scripts/vnet/snat @@ -0,0 +1,34 @@ +packet-generator new { + name f1 + limit 1000000 + node ip4-input + size 64-64 + no-recycle + worker 0 + data { + UDP: 10.0.0.3 -> 172.16.1.2 + UDP: 3000 -> 3001 + length 128 checksum 0 incrementing 1 + } +} + + +packet-generator new { + name f2 + limit 1000000 + node ip4-input + size 64-64 + no-recycle + worker 1 + data { + UDP: 10.0.0.3 -> 172.16.1.2 + UDP: 3005 -> 3006 + length 128 checksum 0 incrementing 1 + } +} + +snat add address 172.16.1.3 +ip route 172.16.1.2/32 via drop +set int ip address pg0 10.0.0.1/24 +set int snat in pg0 +trace add pg-input 10 diff --git a/src/scripts/vnet/snat_static b/src/scripts/vnet/snat_static new file mode 100644 index 00000000..8fe48bff --- /dev/null +++ b/src/scripts/vnet/snat_static @@ -0,0 +1,44 @@ +create packet-generator interface pg0 +create packet-generator interface pg1 + +packet-generator new { + name f1 + limit 1000000 + node ip4-input + size 64-64 + no-recycle + worker 0 + interface pg0 + data { + UDP: 10.0.0.3 -> 172.16.1.2 + UDP: 3000 -> 3001 + length 128 checksum 0 incrementing 1 + } +} + + +packet-generator new { + name f2 + limit 1000000 + node ip4-input + size 64-64 + no-recycle + worker 1 + interface pg1 + data { + UDP: 172.16.1.2 -> 172.16.1.3 + UDP: 3001 -> 3000 + length 128 checksum 0 incrementing 1 + } +} + +snat add address 172.16.1.3 +snat add static mapping local 10.0.0.3 external 172.16.1.3 +set int ip address pg0 10.0.0.1/24 +set int ip address pg1 172.16.1.1/24 +set int state pg0 up +set int state pg1 up +set ip arp static pg0 10.0.0.3 abcd.abcd.abcd +set ip arp static pg1 172.16.1.2 cdef.abcd.abcd +set int snat in pg0 out pg1 +trace add pg-input 10 diff --git a/src/scripts/vnet/snat_static_with_port b/src/scripts/vnet/snat_static_with_port new file mode 100644 index 00000000..f646145a --- /dev/null +++ b/src/scripts/vnet/snat_static_with_port @@ -0,0 +1,44 @@ +create packet-generator interface pg0 +create packet-generator interface pg1 + +packet-generator new { + name f1 + limit 1000000 + node ip4-input + size 64-64 + no-recycle + worker 0 + interface pg0 + data { + UDP: 10.0.0.3 -> 172.16.1.2 + UDP: 3000 -> 3001 + length 128 checksum 0 incrementing 1 + } +} + + +packet-generator new { + name f2 + limit 1000000 + node ip4-input + size 64-64 + no-recycle + worker 1 + interface pg1 + data { + UDP: 172.16.1.2 -> 172.16.1.3 + UDP: 3001 -> 3000 + length 128 checksum 0 incrementing 1 + } +} + +snat add address 172.16.1.3 +snat add static mapping local 10.0.0.3 3000 external 172.16.1.3 3000 +set int ip address pg0 10.0.0.1/24 +set int ip address pg1 172.16.1.1/24 +set int state pg0 up +set int state pg1 up +set ip arp static pg0 10.0.0.3 abcd.abcd.abcd +set ip arp static pg1 172.16.1.2 cdef.abcd.abcd +set int snat in pg0 out pg1 +trace add pg-input 10 diff --git a/src/scripts/vnet/source_and_port_range_check b/src/scripts/vnet/source_and_port_range_check new file mode 100644 index 00000000..dce227b4 --- /dev/null +++ b/src/scripts/vnet/source_and_port_range_check @@ -0,0 +1,63 @@ + +create loop int + +set int state loop0 up +set int ip addr loop0 10.10.10.10/32 + +packet-generator new { + name deny-from-default-route + limit 1 + node ip4-input + size 64-64 + no-recycle + data { + UDP: 1.2.3.4 -> 5.6.7.8 + UDP: 3000 -> 3001 + length 128 checksum 0 incrementing 1 + } +} + +packet-generator new { + name allow + limit 1 + node ip4-input + size 64-64 + no-recycle + data { + UDP: 1.1.1.1 -> 5.6.7.8 + UDP: 3000 -> 3001 + length 128 checksum 0 incrementing 1 + } +} + +packet-generator new { + name deny-from-port-range + limit 1 + node ip4-input + size 64-64 + no-recycle + data { + UDP: 1.1.1.1 -> 5.6.7.8 + UDP: 6000 -> 6001 + length 128 checksum 0 incrementing 1 + } +} + +set ip source-and-port-range-check 1.1.1.0/24 range 2000 - 3000 vrf 99 + +set interface ip source-and-port-range-check pg0 udp-out-vrf 99 + + show ip source-and-port-range-check vrf 99 1.1.1.1 + +set ip source-and-port-range-check 1.1.1.0/24 range 4000 - 5000 vrf 99 + +set ip source-and-port-range-check 1.1.2.0/24 range 4000 - 5000 vrf 99 + +show ip source-and-port-range-check vrf 99 1.1.1.1 +show ip source-and-port-range-check vrf 99 1.1.2.1 + +set ip source-and-port-range-check 1.1.2.0/24 range 4000 - 5000 vrf 99 del + +show ip source-and-port-range-check vrf 99 1.1.2.1 + +tr add pg-input 100 diff --git a/src/scripts/vnet/speed b/src/scripts/vnet/speed new file mode 100644 index 00000000..d60d671f --- /dev/null +++ b/src/scripts/vnet/speed @@ -0,0 +1,14 @@ +packet-generator new { + name x + limit 1 + node ip4-input + size 50-50 + data { + ICMP: 1.2.3.4 -> 5.6.7.8 + ICMP echo_request + incrementing 100 + } +} + +tr add pg-input 100 +ip route 5.6.7.8/32 via pg/stream-0 000102030405060708090a0b0c0d diff --git a/src/scripts/vnet/sr/left-linux-ping.sh b/src/scripts/vnet/sr/left-linux-ping.sh new file mode 100755 index 00000000..55b83506 --- /dev/null +++ b/src/scripts/vnet/sr/left-linux-ping.sh @@ -0,0 +1,3 @@ +#!/bin/bash +ifconfig eth2 inet6 add db02::1/64 +route -A inet6 add db04::1/128 gw db02::2 diff --git a/src/scripts/vnet/sr/leftpeer.conf b/src/scripts/vnet/sr/leftpeer.conf new file mode 100644 index 00000000..9591d968 --- /dev/null +++ b/src/scripts/vnet/sr/leftpeer.conf @@ -0,0 +1,27 @@ +comment { test sr segment chunk-offset on } +test sr hmac validate on + +comment { trunk to rightpeer } +set int ip address GigabitEthernet2/3/0 db03::2/64 +enable ip6 interface GigabitEthernet2/3/0 +set int state GigabitEthernet2/3/0 up + +comment { subscriber left-linux-ping } +set int ip address GigabitEthernet2/2/0 db02::2/64 +enable ip6 interface GigabitEthernet2/2/0 +set int state GigabitEthernet2/2/0 up + +sr hmac id 2 key Gozzer +sr hmac id 3 key Hoser + +sr tunnel src db01::1 dst db04::1/128 next db03::1 next db04::1 tag db02::2 clean key Gozzer InPE 1 + +comment { sr unaware service chaining to db03::5 } +comment { sr tunnel src db01::1 dst db04::1/128 next db03::1 next db03::5 next db04::1 tag db02::2 clean key Gozzer InPE 1 } + +comment { tap connect srlocal hwaddr random } +comment { set int ip6 table tap-0 1 } +comment { set int ip address tap-0 db04::99/64 } +comment { enable ip6 interface tap-0 } +comment { set int state tap-0 up } +comment { ip route add table 1 db02::0/64 lookup in table 0 } diff --git a/src/scripts/vnet/sr/right-linux-ping.sh b/src/scripts/vnet/sr/right-linux-ping.sh new file mode 100755 index 00000000..029368db --- /dev/null +++ b/src/scripts/vnet/sr/right-linux-ping.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +ifconfig eth1 inet6 add db04::1/64 +route -A inet6 add db02::1/128 gw db04::2 diff --git a/src/scripts/vnet/sr/rightpeer.conf b/src/scripts/vnet/sr/rightpeer.conf new file mode 100644 index 00000000..6da7a7af --- /dev/null +++ b/src/scripts/vnet/sr/rightpeer.conf @@ -0,0 +1,22 @@ +comment { trunk to leftpeer } +set int ip address GigabitEthernet2/0/0 db03::1/64 +enable ip6 interface GigabitEthernet2/0/0 +set int state GigabitEthernet2/0/0 up + +comment { subscriber right-linux-ping } +set int ip address GigabitEthernet2/2/0 db04::2/64 + +comment { next address to fake out ND on shared LAN segment } +set int ip address GigabitEthernet2/2/0 db02::13/64 + +enable ip6 interface GigabitEthernet2/2/0 +set int state GigabitEthernet2/2/0 up + +sr tunnel src db04::1 dst db02::1/128 next db03::2 next db02::1 tag db04::2 clean + +tap connect srlocal hwaddr random +set int ip6 table tap-0 1 +set int ip address tap-0 db04::99/64 +enable ip6 interface tap-0 +set int state tap-0 up +ip route add table 1 db02::0/64 lookup in table 0 diff --git a/src/scripts/vnet/sr/srlocal.sh b/src/scripts/vnet/sr/srlocal.sh new file mode 100755 index 00000000..2f568408 --- /dev/null +++ b/src/scripts/vnet/sr/srlocal.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +ifconfig srlocal inet6 add db04::1/64 +route -6 add db02::0/64 gw db04::99 diff --git a/src/scripts/vnet/srp b/src/scripts/vnet/srp new file mode 100644 index 00000000..7cc37011 --- /dev/null +++ b/src/scripts/vnet/srp @@ -0,0 +1,27 @@ +srp create-interfaces +srp create-interfaces +set int hw-class fake-srp0 srp +set int hw-class fake-srp1 srp + +packet-generator new { + name x + limit 1 + node ip4-input + size 64-64 + no-recycle + data { + ICMP: 1.0.0.2 -> 2.0.0.2 + ICMP echo_request + incrementing 100 + } +} + +tr add pg-input 100 +set int state fake-srp0 up +set int state fake-srp1 up + +set int ip address fake-srp0 1.0.0.1/24 +set int ip address fake-srp1 2.0.0.1/24 + + + diff --git a/src/scripts/vnet/tcp b/src/scripts/vnet/tcp new file mode 100644 index 00000000..a2ee8b2d --- /dev/null +++ b/src/scripts/vnet/tcp @@ -0,0 +1,16 @@ +packet-generator new { + name x + limit 1 + node ip4-input + size 64-64 + no-recycle + data { + TCP: 1.2.3.4 -> 5.6.7.8 + TCP: 1234 -> 5678 + incrementing 100 + } +} + +tr add pg-input 100 +ip route 5.6.7.8/32 via local +ip route 1.2.3.4/32 via local diff --git a/src/scripts/vnet/tcp-test b/src/scripts/vnet/tcp-test new file mode 100644 index 00000000..52bfbcdd --- /dev/null +++ b/src/scripts/vnet/tcp-test @@ -0,0 +1,6 @@ +int create-ethernet +set int ip address fake-eth0 1.2.3.4/24 +set int state fake-eth0 up +ip route 1.2.3.5/32 via local +trace add tuntap-rx 100 + diff --git a/src/scripts/vnet/tf-ucs-1 b/src/scripts/vnet/tf-ucs-1 new file mode 100644 index 00000000..efa5f2dc --- /dev/null +++ b/src/scripts/vnet/tf-ucs-1 @@ -0,0 +1,16 @@ +comment { connected to Ixia port 1} +set int ip address TenGigabitEthernet4/0/0 1.0.0.2/8 + +set int state TenGigabitEthernet4/0/0 up + +comment { connected to Ixia port 2} +set int ip address TenGigabitEthernet4/0/1 2.0.0.2/8 +set int state TenGigabitEthernet4/0/1 up + +comment { connected to Ixia port 3} +set int ip address TenGigabitEthernet6/0/0 3.0.0.2/8 +set int state TenGigabitEthernet6/0/0 up + +comment { connected to Ixia port 4} +set int ip address TenGigabitEthernet6/0/1 4.0.0.2/8 +set int state TenGigabitEthernet6/0/1 up diff --git a/src/scripts/vnet/urpf b/src/scripts/vnet/urpf new file mode 100644 index 00000000..a4d87527 --- /dev/null +++ b/src/scripts/vnet/urpf @@ -0,0 +1,86 @@ + +create loop int + +set int state loop0 up +set int ip addr loop0 10.10.10.10/24 + +packet-generator new { + name transit-deny + limit 1 + node ip4-input + size 64-64 + no-recycle + data { + UDP: 1.2.3.4 -> 2.2.2.2 + UDP: 3000 -> 3001 + length 128 checksum 0 incrementing 1 + } +} + +packet-generator new { + name transit-allow + limit 1 + node ip4-input + size 64-64 + no-recycle + data { + UDP: 1.1.1.1 -> 2.2.2.2 + UDP: 3000 -> 3001 + length 128 checksum 0 incrementing 1 + } +} + +packet-generator new { + name transit-allow-from-excemption + limit 1 + node ip4-input + size 64-64 + no-recycle + data { + UDP: 11.11.12.13 -> 2.2.2.2 + UDP: 6000 -> 6001 + length 128 checksum 0 incrementing 1 + } +} + +packet-generator new { + name for-us-allow-from-excemption + limit 1 + node ip4-input + size 64-64 + no-recycle + data { + UDP: 11.11.12.13 -> 10.10.10.10 + UDP: 6000 -> 6001 + length 128 checksum 0 incrementing 1 + } +} + +packet-generator new { + name for-us-allow + limit 1 + node ip4-input + size 64-64 + no-recycle + data { + UDP: 1.1.1.1 -> 10.10.10.10 + UDP: 3000 -> 3001 + length 128 checksum 0 incrementing 1 + } +} + +tr add pg-input 100 + +set int ip addr pg0 10.10.11.10/24 + +set interface ip source-check pg0 strict + +ip route add 1.1.1.1/32 via 10.10.11.11 pg0 +ip route add 2.2.2.2/32 via 10.10.10.11 loop0 + +ip urpf-accept 11.11.0.0/16 + +#set interface ip source-check pg0 strict del +#set interface ip source-check pg0 loose + +#ip urpf-accept del 11.11.0.0/16 diff --git a/src/scripts/vnet/virl/ip6sr.virl b/src/scripts/vnet/virl/ip6sr.virl new file mode 100644 index 00000000..5d4d1a0a --- /dev/null +++ b/src/scripts/vnet/virl/ip6sr.virl @@ -0,0 +1,874 @@ + + + + flat + dual_stack + false + + + + ! +! Last configuration change at 16:41:18 UTC Fri Mar 27 2015 +! +version 15.4 +service timestamps debug datetime msec +service timestamps log datetime msec +no service password-encryption +! +hostname iosv-1 +! +boot-start-marker +boot-end-marker +! +! +enable password cisco +! +no aaa new-model +! +! +! +mmi polling-interval 60 +no mmi auto-configure +no mmi pvc +mmi snmp-timeout 180 +! +! +! +! +! +! +! +! +! +! +! +! +! +no ip domain lookup +ip cef +ipv6 unicast-routing +ipv6 cef +! +multilink bundle-name authenticated +! +! +cts logging verbose +! +! +! +redundancy +! +! +! +! +! +! +! +! +! +! +! +! +! +! +! +interface Loopback0 + description Loopback + ip address 192.168.0.2 255.255.255.255 + ipv6 address ::B:1:0:0:2/128 +! +interface GigabitEthernet0/0 + description OOB Management + ip address 172.16.1.193 255.255.255.0 + duplex auto + speed auto + media-type rj45 +! +interface GigabitEthernet0/1 + description to vpp-1 + ip address 10.0.0.5 255.255.255.252 + duplex auto + speed auto + media-type rj45 + ipv6 address ::A:1:1:0:6/126 +! +ip forward-protocol nd +! +! +no ip http server +no ip http secure-server +! +! route to iosv-2 +ipv6 route ::A:1:1:0:16/128 ::A:1:1:0:7 +! route to iosv-4 +ipv6 route ::A:1:1:0:22/128 ::A:1:1:0:7 +! +! +! +control-plane +! +banner exec ` +************************************************************************** +* IOSv is strictly limited to use for evaluation, demonstration and IOS * +* education. IOSv is provided as-is and is not supported by Cisco's * +* Technical Advisory Center. Any use or disclosure, in whole or in part, * +* of the IOSv Software or Documentation to any third party for any * +* purposes is expressly prohibited except as otherwise authorized by * +* Cisco in writing. * +**************************************************************************` +banner incoming ` +************************************************************************** +* IOSv is strictly limited to use for evaluation, demonstration and IOS * +* education. IOSv is provided as-is and is not supported by Cisco's * +* Technical Advisory Center. Any use or disclosure, in whole or in part, * +* of the IOSv Software or Documentation to any third party for any * +* purposes is expressly prohibited except as otherwise authorized by * +* Cisco in writing. * +**************************************************************************` +banner login ` +************************************************************************** +* IOSv is strictly limited to use for evaluation, demonstration and IOS * +* education. IOSv is provided as-is and is not supported by Cisco's * +* Technical Advisory Center. Any use or disclosure, in whole or in part, * +* of the IOSv Software or Documentation to any third party for any * +* purposes is expressly prohibited except as otherwise authorized by * +* Cisco in writing. * +**************************************************************************` +! +line con 0 + password cisco +line aux 0 +line vty 0 4 + exec-timeout 720 0 + password cisco + login + transport input telnet ssh +! +no scheduler allocate +! +end + + + + + + + ! +! Last configuration change at 16:41:10 UTC Fri Mar 27 2015 +! +version 15.4 +service timestamps debug datetime msec +service timestamps log datetime msec +no service password-encryption +! +hostname iosv-2 +! +boot-start-marker +boot-end-marker +! +! +enable password cisco +! +no aaa new-model +! +! +! +mmi polling-interval 60 +no mmi auto-configure +no mmi pvc +mmi snmp-timeout 180 +! +! +! +! +! +! +! +! +! +! +! +! +! +no ip domain lookup +ip cef +ipv6 unicast-routing +ipv6 cef +! +multilink bundle-name authenticated +! +! +cts logging verbose +! +! +! +redundancy +! +! +! +! +! +! +! +! +! +! +! +! +! +! +! +interface Loopback0 + description Loopback + ip address 192.168.0.3 255.255.255.255 + ipv6 address ::B:1:0:0:3/128 +! +interface GigabitEthernet0/0 + description OOB Management + ip address 172.16.1.191 255.255.255.0 + duplex auto + speed auto + media-type rj45 +! +interface GigabitEthernet0/1 + description to vpp-2 + ip address 10.0.0.21 255.255.255.252 + duplex auto + speed auto + media-type rj45 + ipv6 address ::A:1:1:0:16/126 +! +ip forward-protocol nd +! +! +no ip http server +no ip http secure-server +! +ipv6 route ::A:1:1:0:6/128 ::A:1:1:0:17 +! +! +! +control-plane +! +banner exec ` +************************************************************************** +* IOSv is strictly limited to use for evaluation, demonstration and IOS * +* education. IOSv is provided as-is and is not supported by Cisco's * +* Technical Advisory Center. Any use or disclosure, in whole or in part, * +* of the IOSv Software or Documentation to any third party for any * +* purposes is expressly prohibited except as otherwise authorized by * +* Cisco in writing. * +**************************************************************************` +banner incoming ` +************************************************************************** +* IOSv is strictly limited to use for evaluation, demonstration and IOS * +* education. IOSv is provided as-is and is not supported by Cisco's * +* Technical Advisory Center. Any use or disclosure, in whole or in part, * +* of the IOSv Software or Documentation to any third party for any * +* purposes is expressly prohibited except as otherwise authorized by * +* Cisco in writing. * +**************************************************************************` +banner login ` +************************************************************************** +* IOSv is strictly limited to use for evaluation, demonstration and IOS * +* education. IOSv is provided as-is and is not supported by Cisco's * +* Technical Advisory Center. Any use or disclosure, in whole or in part, * +* of the IOSv Software or Documentation to any third party for any * +* purposes is expressly prohibited except as otherwise authorized by * +* Cisco in writing. * +**************************************************************************` +! +line con 0 + password cisco +line aux 0 +line vty 0 4 + exec-timeout 720 0 + password cisco + login + transport input telnet ssh +! +no scheduler allocate +! +end + + + + + + + ! +! Last configuration change at 16:27:43 UTC Fri Mar 27 2015 +! +version 15.4 +service timestamps debug datetime msec +service timestamps log datetime msec +no service password-encryption +! +hostname iosv-3 +! +boot-start-marker +boot-end-marker +! +! +enable password cisco +! +no aaa new-model +! +! +! +mmi polling-interval 60 +no mmi auto-configure +no mmi pvc +mmi snmp-timeout 180 +! +! +! +! +! +! +! +! +! +! +! +! +! +no ip domain lookup +ip cef +ipv6 unicast-routing +ipv6 cef +! +multilink bundle-name authenticated +! +! +cts logging verbose +! +! +! +redundancy +! +! +! +! +! +! +! +! +! +! +! +! +! +! +! +interface Loopback0 + description Loopback + ip address 192.168.0.6 255.255.255.255 + ipv6 address ::B:1:0:0:4/128 +! +interface GigabitEthernet0/0 + description OOB Management + ip address 172.16.1.192 255.255.255.0 + duplex auto + speed auto + media-type rj45 +! +interface GigabitEthernet0/1 + description to vpp-1 + ip address 10.0.0.9 255.255.255.252 + duplex auto + speed auto + media-type rj45 + ipv6 address ::A:1:1:0:A/126 +! +ip forward-protocol nd +! +! +no ip http server +no ip http secure-server +! +! +! +! +control-plane +! +banner exec ` +************************************************************************** +* IOSv is strictly limited to use for evaluation, demonstration and IOS * +* education. IOSv is provided as-is and is not supported by Cisco's * +* Technical Advisory Center. Any use or disclosure, in whole or in part, * +* of the IOSv Software or Documentation to any third party for any * +* purposes is expressly prohibited except as otherwise authorized by * +* Cisco in writing. * +**************************************************************************` +banner incoming ` +************************************************************************** +* IOSv is strictly limited to use for evaluation, demonstration and IOS * +* education. IOSv is provided as-is and is not supported by Cisco's * +* Technical Advisory Center. Any use or disclosure, in whole or in part, * +* of the IOSv Software or Documentation to any third party for any * +* purposes is expressly prohibited except as otherwise authorized by * +* Cisco in writing. * +**************************************************************************` +banner login ` +************************************************************************** +* IOSv is strictly limited to use for evaluation, demonstration and IOS * +* education. IOSv is provided as-is and is not supported by Cisco's * +* Technical Advisory Center. Any use or disclosure, in whole or in part, * +* of the IOSv Software or Documentation to any third party for any * +* purposes is expressly prohibited except as otherwise authorized by * +* Cisco in writing. * +**************************************************************************` +! +line con 0 + password cisco +line aux 0 +line vty 0 4 + exec-timeout 720 0 + password cisco + login + transport input telnet ssh +! +no scheduler allocate +! +end + + + + + + + ! +! Last configuration change at 16:27:43 UTC Fri Mar 27 2015 +! +version 15.4 +service timestamps debug datetime msec +service timestamps log datetime msec +no service password-encryption +! +hostname iosv-4 +! +boot-start-marker +boot-end-marker +! +! +enable password cisco +! +no aaa new-model +! +! +! +mmi polling-interval 60 +no mmi auto-configure +no mmi pvc +mmi snmp-timeout 180 +! +! +! +! +! +! +! +! +! +! +! +! +! +no ip domain lookup +ip cef +ipv6 unicast-routing +ipv6 cef +! +multilink bundle-name authenticated +! +! +cts logging verbose +! +! +! +redundancy +! +! +! +! +! +! +! +! +! +! +! +! +! +! +! +interface Loopback0 + description Loopback + ip address 192.168.0.8 255.255.255.255 + ipv6 address ::B:1:0:0:5/128 +! +interface GigabitEthernet0/0 + description OOB Management + ip address 172.16.1.194 255.255.255.0 + duplex auto + speed auto + media-type rj45 +! +interface GigabitEthernet0/1 + description to vpp-2 + ip address 10.0.0.33 255.255.255.252 + duplex auto + speed auto + media-type rj45 + ipv6 address ::A:1:1:0:22/126 +! +! Route to iosv-1 +ipv6 route ::A:1:1:0:6/128 ::A:1:1:0:23 +ip forward-protocol nd +! +! +no ip http server +no ip http secure-server +! +! +! +! +control-plane +! +banner exec ` +************************************************************************** +* IOSv is strictly limited to use for evaluation, demonstration and IOS * +* education. IOSv is provided as-is and is not supported by Cisco's * +* Technical Advisory Center. Any use or disclosure, in whole or in part, * +* of the IOSv Software or Documentation to any third party for any * +* purposes is expressly prohibited except as otherwise authorized by * +* Cisco in writing. * +**************************************************************************` +banner incoming ` +************************************************************************** +* IOSv is strictly limited to use for evaluation, demonstration and IOS * +* education. IOSv is provided as-is and is not supported by Cisco's * +* Technical Advisory Center. Any use or disclosure, in whole or in part, * +* of the IOSv Software or Documentation to any third party for any * +* purposes is expressly prohibited except as otherwise authorized by * +* Cisco in writing. * +**************************************************************************` +banner login ` +************************************************************************** +* IOSv is strictly limited to use for evaluation, demonstration and IOS * +* education. IOSv is provided as-is and is not supported by Cisco's * +* Technical Advisory Center. Any use or disclosure, in whole or in part, * +* of the IOSv Software or Documentation to any third party for any * +* purposes is expressly prohibited except as otherwise authorized by * +* Cisco in writing. * +**************************************************************************` +! +line con 0 + password cisco +line aux 0 +line vty 0 4 + exec-timeout 720 0 + password cisco + login + transport input telnet ssh +! +no scheduler allocate +! +end + + + + + + + #cloud-config +bootcmd: +- ln -s -t /etc/rc.d /etc/rc.local +hostname: vpp-1 +manage_etc_hosts: true +runcmd: +- start ttyS0 +- systemctl start getty@ttyS0.service +- systemctl start rc-local +- sed -i '/^\s*PasswordAuthentication\s\+no/d' /etc/ssh/sshd_config +- echo "UseDNS no" >> /etc/ssh/sshd_config +- service ssh restart +- service sshd restart +- sed -i 's/no-pci//' /cisco/etc/qn.conf +- sed -i 's/1024/1024 decimal-interface-names/g' /cisco/etc/qn.conf +users: +- default +- gecos: User configured by VIRL Configuration Engine 0.15.3 + lock-passwd: false + name: cisco + plain-text-passwd: cisco + shell: /bin/bash + ssh-authorized-keys: + - VIRL-USER-SSH-PUBLIC-KEY + sudo: ALL=(ALL) ALL +write_files: +- path: /etc/init/ttyS0.conf + owner: root:root + content: | + # ttyS0 - getty + # This service maintains a getty on ttyS0 from the point the system is + # started until it is shut down again. + start on stopped rc or RUNLEVEL=[12345] + stop on runlevel [!12345] + respawn + exec /sbin/getty -L 115200 ttyS0 vt102 + permissions: '0644' +- path: /etc/systemd/system/dhclient@.service + content: | + [Unit] + Description=Run dhclient on %i interface + After=network.target + [Service] + Type=oneshot + ExecStart=/sbin/dhclient %i -pf /var/run/dhclient.%i.pid -lf /var/lib/dhclient/dhclient.%i.lease + RemainAfterExit=yes + owner: root:root + permissions: '0644' +- path: /cisco/etc/vpp-server.conf + owner: root:root + permissions: '0644' + content: |- + set interface ip address GigabitEthernet0/4/0 10.0.0.6/30 + set interface ip address GigabitEthernet0/4/0 ::a:1:1:0:7/126 + set interface state GigabitEthernet0/4/0 up + set interface ip address GigabitEthernet0/5/0 10.0.0.10/30 + set interface ip address GigabitEthernet0/5/0 ::a:1:1:0:b/126 + set interface state GigabitEthernet0/5/0 up + set interface ip address GigabitEthernet0/6/0 10.0.0.13/30 + set interface ip address GigabitEthernet0/6/0 ::a:1:1:0:e/126 + set interface state GigabitEthernet0/6/0 up + set interface ip address GigabitEthernet0/7/0 10.0.0.17/30 + set interface ip address GigabitEthernet0/7/0 ::a:1:1:0:12/126 + set interface state GigabitEthernet0/7/0 up + sr tunnel src 0::a:1:1:0:6 dst 0::a:1:1:0:16/128 next 0::a:1:1:0:f next 0::a:1:1:0:1a next 0::a:1:1:0:16 tag 0::a:1:1:0:7 InPE 1 clean + sr tunnel src 0::a:1:1:0:6 dst 0::a:1:1:0:22/128 next 0::a:1:1:0:f next 0::a:1:1:0:1a next 0::a:1:1:0:22 tag 0::a:1:1:0:7 InPE 1 clean + + + + + + + + + + #cloud-config +bootcmd: +- ln -s -t /etc/rc.d /etc/rc.local +hostname: vpp-2 +manage_etc_hosts: true +runcmd: +- start ttyS0 +- systemctl start getty@ttyS0.service +- systemctl start rc-local +- sed -i '/^\s*PasswordAuthentication\s\+no/d' /etc/ssh/sshd_config +- echo "UseDNS no" >> /etc/ssh/sshd_config +- service ssh restart +- service sshd restart +- sed -i 's/no-pci//' /cisco/etc/qn.conf +- sed -i 's/1024/1024 decimal-interface-names/g' /cisco/etc/qn.conf +users: +- default +- gecos: User configured by VIRL Configuration Engine 0.15.3 + lock-passwd: false + name: cisco + plain-text-passwd: cisco + shell: /bin/bash + ssh-authorized-keys: + - VIRL-USER-SSH-PUBLIC-KEY + sudo: ALL=(ALL) ALL +write_files: +- path: /etc/init/ttyS0.conf + owner: root:root + content: | + # ttyS0 - getty + # This service maintains a getty on ttyS0 from the point the system is + # started until it is shut down again. + start on stopped rc or RUNLEVEL=[12345] + stop on runlevel [!12345] + respawn + exec /sbin/getty -L 115200 ttyS0 vt102 + permissions: '0644' +- path: /etc/systemd/system/dhclient@.service + content: | + [Unit] + Description=Run dhclient on %i interface + After=network.target + [Service] + Type=oneshot + ExecStart=/sbin/dhclient %i -pf /var/run/dhclient.%i.pid -lf /var/lib/dhclient/dhclient.%i.lease + RemainAfterExit=yes + owner: root:root + permissions: '0644' +- path: /cisco/etc/vpp-server.conf + owner: root:root + permissions: '0644' + content: |- + set interface ip address GigabitEthernet0/4/0 10.0.0.25/30 + set interface ip address GigabitEthernet0/4/0 ::a:1:1:0:1a/126 + set interface state GigabitEthernet0/4/0 up + set interface ip address GigabitEthernet0/5/0 10.0.0.29/30 + set interface ip address GigabitEthernet0/5/0 ::a:1:1:0:1e/126 + set interface state GigabitEthernet0/5/0 up + set interface ip address GigabitEthernet0/6/0 10.0.0.22/30 + set interface ip address GigabitEthernet0/6/0 ::a:1:1:0:17/126 + set interface state GigabitEthernet0/6/0 up + set interface ip address GigabitEthernet0/7/0 10.0.0.34/30 + set interface ip address GigabitEthernet0/7/0 ::a:1:1:0:23/126 + set interface state GigabitEthernet0/7/0 up + sr tunnel src 0::a:1:1:0:16 dst 0::a:1:1:0:6/128 next 0::a:1:1:0:1b next 0::a:1:1:0:e next 0::a:1:1:0:6 tag 0::a:1:1:0:17 InPE 1 clean + + + + + + + + + + #cloud-config +bootcmd: +- ln -s -t /etc/rc.d /etc/rc.local +hostname: vpp-3 +manage_etc_hosts: true +runcmd: +- start ttyS0 +- systemctl start getty@ttyS0.service +- systemctl start rc-local +- sed -i '/^\s*PasswordAuthentication\s\+no/d' /etc/ssh/sshd_config +- echo "UseDNS no" >> /etc/ssh/sshd_config +- service ssh restart +- service sshd restart +- sed -i 's/no-pci//' /cisco/etc/qn.conf +- sed -i 's/1024/1024 decimal-interface-names/g' /cisco/etc/qn.conf +users: +- default +- gecos: User configured by VIRL Configuration Engine 0.15.3 + lock-passwd: false + name: cisco + plain-text-passwd: cisco + shell: /bin/bash + ssh-authorized-keys: + - VIRL-USER-SSH-PUBLIC-KEY + sudo: ALL=(ALL) ALL +write_files: +- path: /etc/init/ttyS0.conf + owner: root:root + content: | + # ttyS0 - getty + # This service maintains a getty on ttyS0 from the point the system is + # started until it is shut down again. + start on stopped rc or RUNLEVEL=[12345] + stop on runlevel [!12345] + respawn + exec /sbin/getty -L 115200 ttyS0 vt102 + permissions: '0644' +- path: /etc/systemd/system/dhclient@.service + content: | + [Unit] + Description=Run dhclient on %i interface + After=network.target + [Service] + Type=oneshot + ExecStart=/sbin/dhclient %i -pf /var/run/dhclient.%i.pid -lf /var/lib/dhclient/dhclient.%i.lease + RemainAfterExit=yes + owner: root:root + permissions: '0644' +- path: /cisco/etc/vpp-server.conf + owner: root:root + permissions: '0644' + content: |- + set interface ip address GigabitEthernet0/4/0 10.0.0.14/30 + set interface ip address GigabitEthernet0/4/0 ::a:1:1:0:f/126 + set interface state GigabitEthernet0/4/0 up + set interface ip address GigabitEthernet0/5/0 10.0.0.26/30 + set interface ip address GigabitEthernet0/5/0 ::a:1:1:0:1b/126 + set interface state GigabitEthernet0/5/0 up + comment { fix src rpf drop screws} + ip route add ::a:1:1:0:6/128 via drop + ip route add ::a:1:1:0:16/128 via drop + ip route add ::a:1:1:0:22/128 via drop + + + + + + + + #cloud-config +bootcmd: +- ln -s -t /etc/rc.d /etc/rc.local +hostname: vpp-4 +manage_etc_hosts: true +runcmd: +- start ttyS0 +- systemctl start getty@ttyS0.service +- systemctl start rc-local +- sed -i '/^\s*PasswordAuthentication\s\+no/d' /etc/ssh/sshd_config +- echo "UseDNS no" >> /etc/ssh/sshd_config +- service ssh restart +- service sshd restart +- sed -i 's/no-pci//' /cisco/etc/qn.conf +- sed -i 's/1024/1024 decimal-interface-names/g' /cisco/etc/qn.conf +users: +- default +- gecos: User configured by VIRL Configuration Engine 0.15.3 + lock-passwd: false + name: cisco + plain-text-passwd: cisco + shell: /bin/bash + ssh-authorized-keys: + - VIRL-USER-SSH-PUBLIC-KEY + sudo: ALL=(ALL) ALL +write_files: +- path: /etc/init/ttyS0.conf + owner: root:root + content: | + # ttyS0 - getty + # This service maintains a getty on ttyS0 from the point the system is + # started until it is shut down again. + start on stopped rc or RUNLEVEL=[12345] + stop on runlevel [!12345] + respawn + exec /sbin/getty -L 115200 ttyS0 vt102 + permissions: '0644' +- path: /etc/systemd/system/dhclient@.service + content: | + [Unit] + Description=Run dhclient on %i interface + After=network.target + [Service] + Type=oneshot + ExecStart=/sbin/dhclient %i -pf /var/run/dhclient.%i.pid -lf /var/lib/dhclient/dhclient.%i.lease + RemainAfterExit=yes + owner: root:root + permissions: '0644' +- path: /cisco/etc/vpp-server.conf + owner: root:root + permissions: '0644' + content: |- + set interface ip address GigabitEthernet0/4/0 10.0.0.18/30 + set interface ip address GigabitEthernet0/4/0 ::a:1:1:0:13/126 + set interface state GigabitEthernet0/4/0 up + set interface ip address GigabitEthernet0/5/0 10.0.0.30/30 + set interface ip address GigabitEthernet0/5/0 ::a:1:1:0:1f/126 + set interface state GigabitEthernet0/5/0 up + + + + + + + + + + + + + + diff --git a/src/scripts/vnet/virl/ip6sr_notes.txt b/src/scripts/vnet/virl/ip6sr_notes.txt new file mode 100644 index 00000000..5febf2c6 --- /dev/null +++ b/src/scripts/vnet/virl/ip6sr_notes.txt @@ -0,0 +1,38 @@ +vpp-1, tunnel 1: iosv-1 vpp-1 vpp-3 vpp-2 iosv-2 + +iosv-1 +::a:1:1:0:6 + +to iosv2 +ipv6 route ::a:1:1:0:16/128 ::a:1:1:0:7 +to iosv4 +ipv6 route ::a:1:1:0:22/128 ::a:1:1:0:7 + +vpp-1 + +::a:1:1:0:7 +... +::a:1:1:0:e + +sr tunnel src 0::a:1:1:0:6 dst 0::a:1:1:0:16/128 next 0::a:1:1:0:f next 0::a:1:1:0:1a next 0::a:1:1:0:16 tag 0::a:1:1:0:7 InPE 1 clean + +vpp-3 +::a:1:1:0:f +.. +::a:1:1:0:1b + +comment {fix src rpf screws} +ip route add ::a:1:1:0:6/128 via drop +ip route add ::a:1:1:0:16/128 via drop +ip route add ::a:1:1:0:22/128 via drop +vpp-2 +::a:1:1:0:1a +.. +::a:1:1:0:17 + +sr tunnel src 0::a:1:1:0:16 dst 0::a:1:1:0:6/128 next 0::a:1:1:0:1b next 0::a:1:1:0:e next 0::a:1:1:0:6 tag 0::a:1:1:0:17 InPE 1 clean + +iosv-2 +::a:1:1:0:16 + +ipv6 route ::a:1:1:0:6/128 ::a:1:1:0:17 diff --git a/src/scripts/vnet/virl/mplsogre.virl b/src/scripts/vnet/virl/mplsogre.virl new file mode 100644 index 00000000..33dd0329 --- /dev/null +++ b/src/scripts/vnet/virl/mplsogre.virl @@ -0,0 +1,319 @@ + + + + flat + + + + #cloud-config +bootcmd: +- ln -s -t /etc/rc.d /etc/rc.local +hostname: vpp-1 +manage_etc_hosts: true +runcmd: +- start ttyS0 +- systemctl start getty@ttyS0.service +- systemctl start rc-local +- sed -i '/^\s*PasswordAuthentication\s\+no/d' /etc/ssh/sshd_config +- echo "UseDNS no" >> /etc/ssh/sshd_config +- service ssh restart +- service sshd restart +- sed -i 's/no-pci//' /cisco/etc/qn.conf +- sed -i 's/1024/1024 decimal-interface-names/g' /cisco/etc/qn.conf +users: +- default +- gecos: User configured by VIRL Configuration Engine 0.15.3 + lock-passwd: false + name: cisco + plain-text-passwd: cisco + shell: /bin/bash + ssh-authorized-keys: + - VIRL-USER-SSH-PUBLIC-KEY + sudo: ALL=(ALL) ALL +write_files: +- path: /etc/init/ttyS0.conf + owner: root:root + content: | + # ttyS0 - getty + # This service maintains a getty on ttyS0 from the point the system is + # started until it is shut down again. + start on stopped rc or RUNLEVEL=[12345] + stop on runlevel [!12345] + respawn + exec /sbin/getty -L 115200 ttyS0 vt102 + permissions: '0644' +- path: /etc/systemd/system/dhclient@.service + content: | + [Unit] + Description=Run dhclient on %i interface + After=network.target + [Service] + Type=oneshot + ExecStart=/sbin/dhclient %i -pf /var/run/dhclient.%i.pid -lf /var/lib/dhclient/dhclient.%i.lease + RemainAfterExit=yes + owner: root:root + permissions: '0644' +- path: /cisco/etc/vpp-server.conf + owner: root:root + permissions: '0644' + content: |- + set interface ip address GigabitEthernet0/4/0 10.0.0.6/30 + set interface state GigabitEthernet0/4/0 up + set interface ip address GigabitEthernet0/5/0 10.0.0.9/30 + set interface state GigabitEthernet0/5/0 up + mpls encap add label 30 fib 0 dest 10.0.0.10 + mpls decap add label 30 fib 0 + create mpls gre tunnel src 10.0.0.9 dst 10.0.0.10 intfc 10.0.0.13/30 inner-fib-id 0 outer-fib-id 0 + + + + + + + + #cloud-config +bootcmd: +- ln -s -t /etc/rc.d /etc/rc.local +hostname: vpp-2 +manage_etc_hosts: true +runcmd: +- start ttyS0 +- systemctl start getty@ttyS0.service +- systemctl start rc-local +- sed -i '/^\s*PasswordAuthentication\s\+no/d' /etc/ssh/sshd_config +- echo "UseDNS no" >> /etc/ssh/sshd_config +- service ssh restart +- service sshd restart +- sed -i 's/no-pci//' /cisco/etc/qn.conf +- sed -i 's/1024/1024 decimal-interface-names/g' /cisco/etc/qn.conf +users: +- default +- gecos: User configured by VIRL Configuration Engine 0.15.3 + lock-passwd: false + name: cisco + plain-text-passwd: cisco + shell: /bin/bash + ssh-authorized-keys: + - VIRL-USER-SSH-PUBLIC-KEY + sudo: ALL=(ALL) ALL +write_files: +- path: /etc/init/ttyS0.conf + owner: root:root + content: | + # ttyS0 - getty + # This service maintains a getty on ttyS0 from the point the system is + # started until it is shut down again. + start on stopped rc or RUNLEVEL=[12345] + stop on runlevel [!12345] + respawn + exec /sbin/getty -L 115200 ttyS0 vt102 + permissions: '0644' +- path: /etc/systemd/system/dhclient@.service + content: | + [Unit] + Description=Run dhclient on %i interface + After=network.target + [Service] + Type=oneshot + ExecStart=/sbin/dhclient %i -pf /var/run/dhclient.%i.pid -lf /var/lib/dhclient/dhclient.%i.lease + RemainAfterExit=yes + owner: root:root + permissions: '0644' +- path: /cisco/etc/vpp-server.conf + owner: root:root + permissions: '0644' + content: |- + set interface ip address GigabitEthernet0/4/0 10.0.0.10/30 + set interface state GigabitEthernet0/4/0 up + set interface ip address GigabitEthernet0/5/0 10.0.0.14/30 + set interface state GigabitEthernet0/5/0 up + mpls encap add label 30 fib 0 dest 10.0.0.9 + mpls decap add label 30 fib 0 + create mpls gre tunnel src 10.0.0.10 dst 10.0.0.9 intfc 10.0.0.5/30 inner-fib-id 0 outer-fib-id 0 + + + + + + + + ! IOS Config generated on 2015-03-03 17:26 +! by autonetkit_0.15.0 +! +hostname iosv-1 +boot-start-marker +boot-end-marker +! +no aaa new-model +! +! +ip cef +ipv6 unicast-routing +ipv6 cef +! +! +service timestamps debug datetime msec +service timestamps log datetime msec +no service password-encryption +no service config +enable password cisco +ip classless +ip subnet-zero +no ip domain lookup +line vty 0 4 + transport input ssh telnet + exec-timeout 720 0 + password cisco + login +line con 0 + password cisco +! +! +interface Loopback0 + description Loopback + ip address 192.168.0.1 255.255.255.255 +! +interface GigabitEthernet0/0 + description OOB Management + ! Configured on launch + no ip address + duplex auto + speed auto + no shutdown +! +interface GigabitEthernet0/1 + description to vpp-1 + ip address 10.0.0.5 255.255.255.252 + ip ospf cost 1 + duplex auto + speed auto + no shutdown +! +! +! +router ospf 1 + network 192.168.0.1 0.0.0.0 area 0 + log-adjacency-changes + passive-interface Loopback0 + network 10.0.0.4 0.0.0.3 area 0 +! +! +router bgp 1 + bgp router-id 192.168.0.1 + no synchronization +! ibgp + ! ibgp peers + ! + neighbor 192.168.0.4 remote-as 1 + neighbor 192.168.0.4 description iBGP peer iosv-2 + neighbor 192.168.0.4 update-source Loopback0 +! +! + ! + address-family ipv4 + network 192.168.0.1 mask 255.255.255.255 + neighbor 192.168.0.4 activate + exit-address-family +! +! +! +ip route 10.0.0.13 255.255.255.255 10.0.0.6 +end + + + + + + + + ! IOS Config generated on 2015-03-03 17:26 +! by autonetkit_0.15.0 +! +hostname iosv-2 +boot-start-marker +boot-end-marker +! +no aaa new-model +! +! +ip cef +ipv6 unicast-routing +ipv6 cef +! +! +service timestamps debug datetime msec +service timestamps log datetime msec +no service password-encryption +no service config +enable password cisco +ip classless +ip subnet-zero +no ip domain lookup +line vty 0 4 + transport input ssh telnet + exec-timeout 720 0 + password cisco + login +line con 0 + password cisco +! +! +interface Loopback0 + description Loopback + ip address 192.168.0.4 255.255.255.255 +! +interface GigabitEthernet0/0 + description OOB Management + ! Configured on launch + no ip address + duplex auto + speed auto + no shutdown +! +interface GigabitEthernet0/1 + description to vpp-2 + ip address 10.0.0.13 255.255.255.252 + ip ospf cost 1 + duplex auto + speed auto + no shutdown +! +! +! +router ospf 1 + network 192.168.0.4 0.0.0.0 area 0 + log-adjacency-changes + passive-interface Loopback0 + network 10.0.0.12 0.0.0.3 area 0 +! +! +router bgp 1 + bgp router-id 192.168.0.4 + no synchronization +! ibgp + ! ibgp peers + ! + neighbor 192.168.0.1 remote-as 1 + neighbor 192.168.0.1 description iBGP peer iosv-1 + neighbor 192.168.0.1 update-source Loopback0 +! +! + ! + address-family ipv4 + network 192.168.0.4 mask 255.255.255.255 + neighbor 192.168.0.1 activate + exit-address-family +! +! +ip route 10.0.0.5 255.255.255.255 10.0.0.14 +! +end + + + + + + + + + diff --git a/src/scripts/vnet/virl/simple.virl b/src/scripts/vnet/virl/simple.virl new file mode 100644 index 00000000..6033c42c --- /dev/null +++ b/src/scripts/vnet/virl/simple.virl @@ -0,0 +1,389 @@ + + + + flat + + + + ! +! Last configuration change at 14:27:32 UTC Fri Mar 27 2015 +! +version 15.4 +service timestamps debug datetime msec +service timestamps log datetime msec +no service password-encryption +! +hostname iosv-1 +! +boot-start-marker +boot-end-marker +! +! +enable password cisco +! +no aaa new-model +! +! +! +mmi polling-interval 60 +no mmi auto-configure +no mmi pvc +mmi snmp-timeout 180 +! +! +! +! +! +! +! +! +! +! +! +! +! +no ip domain lookup +ip cef +ipv6 unicast-routing +ipv6 cef +! +multilink bundle-name authenticated +! +! +cts logging verbose +! +! +! +redundancy +! +! +! +! +! +! +! +! +! +! +! +! +! +! +! +interface Loopback0 + description Loopback + ip address 192.168.0.2 255.255.255.255 +! +interface GigabitEthernet0/0 + description OOB Management + ip address 172.16.1.167 255.255.255.0 + duplex auto + speed auto + media-type rj45 +! +interface GigabitEthernet0/1 + description to vpp-1 + ip address 10.0.0.5 255.255.255.252 + ip ospf cost 1 + duplex auto + speed auto + media-type rj45 +! +router ospf 1 + passive-interface Loopback0 + network 10.0.0.4 0.0.0.3 area 0 + network 192.168.0.2 0.0.0.0 area 0 +! +router bgp 1 + bgp router-id 192.168.0.2 + bgp log-neighbor-changes + neighbor 192.168.0.3 remote-as 1 + neighbor 192.168.0.3 description iBGP peer iosv-2 + neighbor 192.168.0.3 update-source Loopback0 + ! + address-family ipv4 + network 192.168.0.2 mask 255.255.255.255 + neighbor 192.168.0.3 activate + exit-address-family +! +ip forward-protocol nd +! +! +no ip http server +no ip http secure-server +ip route 10.0.0.9 255.255.255.255 10.0.0.6 +! +! +! +! +control-plane +! +banner exec ` +************************************************************************** +* IOSv is strictly limited to use for evaluation, demonstration and IOS * +* education. IOSv is provided as-is and is not supported by Cisco's * +* Technical Advisory Center. Any use or disclosure, in whole or in part, * +* of the IOSv Software or Documentation to any third party for any * +* purposes is expressly prohibited except as otherwise authorized by * +* Cisco in writing. * +**************************************************************************` +banner incoming ` +************************************************************************** +* IOSv is strictly limited to use for evaluation, demonstration and IOS * +* education. IOSv is provided as-is and is not supported by Cisco's * +* Technical Advisory Center. Any use or disclosure, in whole or in part, * +* of the IOSv Software or Documentation to any third party for any * +* purposes is expressly prohibited except as otherwise authorized by * +* Cisco in writing. * +**************************************************************************` +banner login ` +************************************************************************** +* IOSv is strictly limited to use for evaluation, demonstration and IOS * +* education. IOSv is provided as-is and is not supported by Cisco's * +* Technical Advisory Center. Any use or disclosure, in whole or in part, * +* of the IOSv Software or Documentation to any third party for any * +* purposes is expressly prohibited except as otherwise authorized by * +* Cisco in writing. * +**************************************************************************` +! +line con 0 + password cisco +line aux 0 +line vty 0 4 + exec-timeout 720 0 + password cisco + login + transport input telnet ssh +! +no scheduler allocate +! +end + + + + + + + ! +! Last configuration change at 14:26:58 UTC Fri Mar 27 2015 +! +version 15.4 +service timestamps debug datetime msec +service timestamps log datetime msec +no service password-encryption +! +hostname iosv-2 +! +boot-start-marker +boot-end-marker +! +! +enable password cisco +! +no aaa new-model +! +! +! +mmi polling-interval 60 +no mmi auto-configure +no mmi pvc +mmi snmp-timeout 180 +! +! +! +! +! +! +! +! +! +! +! +! +! +no ip domain lookup +ip cef +ipv6 unicast-routing +ipv6 cef +! +multilink bundle-name authenticated +! +! +cts logging verbose +! +! +! +redundancy +! +! +! +! +! +! +! +! +! +! +! +! +! +! +! +interface Loopback0 + description Loopback + ip address 192.168.0.3 255.255.255.255 +! +interface GigabitEthernet0/0 + description OOB Management + ip address 172.16.1.164 255.255.255.0 + duplex auto + speed auto + media-type rj45 +! +interface GigabitEthernet0/1 + description to vpp-1 + ip address 10.0.0.9 255.255.255.252 + ip ospf cost 1 + duplex auto + speed auto + media-type rj45 +! +router ospf 1 + passive-interface Loopback0 + network 10.0.0.8 0.0.0.3 area 0 + network 192.168.0.3 0.0.0.0 area 0 +! +router bgp 1 + bgp router-id 192.168.0.3 + bgp log-neighbor-changes + neighbor 192.168.0.2 remote-as 1 + neighbor 192.168.0.2 description iBGP peer iosv-1 + neighbor 192.168.0.2 update-source Loopback0 + ! + address-family ipv4 + network 192.168.0.3 mask 255.255.255.255 + neighbor 192.168.0.2 activate + exit-address-family +! +ip forward-protocol nd +! +! +no ip http server +no ip http secure-server +ip route 10.0.0.5 255.255.255.255 10.0.0.10 +! +! +! +! +control-plane +! +banner exec ` +************************************************************************** +* IOSv is strictly limited to use for evaluation, demonstration and IOS * +* education. IOSv is provided as-is and is not supported by Cisco's * +* Technical Advisory Center. Any use or disclosure, in whole or in part, * +* of the IOSv Software or Documentation to any third party for any * +* purposes is expressly prohibited except as otherwise authorized by * +* Cisco in writing. * +**************************************************************************` +banner incoming ` +************************************************************************** +* IOSv is strictly limited to use for evaluation, demonstration and IOS * +* education. IOSv is provided as-is and is not supported by Cisco's * +* Technical Advisory Center. Any use or disclosure, in whole or in part, * +* of the IOSv Software or Documentation to any third party for any * +* purposes is expressly prohibited except as otherwise authorized by * +* Cisco in writing. * +**************************************************************************` +banner login ` +************************************************************************** +* IOSv is strictly limited to use for evaluation, demonstration and IOS * +* education. IOSv is provided as-is and is not supported by Cisco's * +* Technical Advisory Center. Any use or disclosure, in whole or in part, * +* of the IOSv Software or Documentation to any third party for any * +* purposes is expressly prohibited except as otherwise authorized by * +* Cisco in writing. * +**************************************************************************` +! +line con 0 + password cisco +line aux 0 +line vty 0 4 + exec-timeout 720 0 + password cisco + login + transport input telnet ssh +! +no scheduler allocate +! +end + + + + + + + #cloud-config +bootcmd: +- ln -s -t /etc/rc.d /etc/rc.local +hostname: vpp-1 +manage_etc_hosts: true +runcmd: +- start ttyS0 +- systemctl start getty@ttyS0.service +- systemctl start rc-local +- sed -i '/^\s*PasswordAuthentication\s\+no/d' /etc/ssh/sshd_config +- echo "UseDNS no" >> /etc/ssh/sshd_config +- service ssh restart +- service sshd restart +- sed -i 's/no-pci//' /cisco/etc/qn.conf +- sed -i 's/1024/1024 decimal-interface-names/g' /cisco/etc/qn.conf +users: +- default +- gecos: User configured by VIRL Configuration Engine 0.15.3 + lock-passwd: false + name: cisco + plain-text-passwd: cisco + shell: /bin/bash + ssh-authorized-keys: + - VIRL-USER-SSH-PUBLIC-KEY + sudo: ALL=(ALL) ALL +write_files: +- path: /etc/init/ttyS0.conf + owner: root:root + content: | + # ttyS0 - getty + # This service maintains a getty on ttyS0 from the point the system is + # started until it is shut down again. + start on stopped rc or RUNLEVEL=[12345] + stop on runlevel [!12345] + respawn + exec /sbin/getty -L 115200 ttyS0 vt102 + permissions: '0644' +- path: /etc/systemd/system/dhclient@.service + content: | + [Unit] + Description=Run dhclient on %i interface + After=network.target + [Service] + Type=oneshot + ExecStart=/sbin/dhclient %i -pf /var/run/dhclient.%i.pid -lf /var/lib/dhclient/dhclient.%i.lease + RemainAfterExit=yes + owner: root:root + permissions: '0644' +- path: /cisco/etc/vpp-server.conf + owner: root:root + permissions: '0644' + content: |- + set interface ip address GigabitEthernet0/4/0 10.0.0.6/30 + set interface state GigabitEthernet0/4/0 up + set interface ip address GigabitEthernet0/5/0 10.0.0.10/30 + set interface state GigabitEthernet0/5/0 up + + + + + + + + diff --git a/src/scripts/vnet/vlan b/src/scripts/vnet/vlan new file mode 100644 index 00000000..076080a6 --- /dev/null +++ b/src/scripts/vnet/vlan @@ -0,0 +1,23 @@ +int create-ethernet +int create-sub fake-eth0 1 +set int state fake-eth0 up +set int state fake-eth0.1 up + +packet-generator new { + name x + limit 1 + node ethernet-input + interface fake-eth0 + size 64-64 + no-recycle + data { + IP4: 1.2.3 -> 4.5.6 vlan 1 + ICMP: 1.2.3.4 -> 5.6.7.8 + ICMP echo_request + incrementing 100 + } +} + +tr add pg-input 100 +ip route 5.6.7.8/32 via local +ip route 1.2.3.4/32 via local diff --git a/src/scripts/vppctl b/src/scripts/vppctl new file mode 100755 index 00000000..4fdf03c7 --- /dev/null +++ b/src/scripts/vppctl @@ -0,0 +1,121 @@ +#! /usr/bin/python +''' +Copyright 2016 Intel Corporation + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +''' + +from cmd import Cmd +import os +import subprocess +import re +import sys +try: + import readline +except ImportError: + readline = None + +persishist = os.path.expanduser('~/.vpphistory') +persishist_size = 1000 +if not persishist: + os.mknod(persishist, stat.S_IFREG) + +class Vppctl(Cmd): + + def historyWrite(self): + if readline: + readline.set_history_length(persishist_size) + readline.write_history_file(persishist) + + def runVat(self, line): + input_prefix = "exec " + input_command = input_prefix + line + line_remove = '^load_one_plugin:' + s = '\n' + command = ['vpp_api_test'] + + if os.geteuid() != 0: + command = ['sudo', 'vpp_api_test'] + + vpp_process = subprocess.Popen(command, + stderr=subprocess.PIPE, + stdin=subprocess.PIPE, + stdout=subprocess.PIPE) + stdout_value = vpp_process.communicate(input_command)[0] + + buffer_stdout = stdout_value.splitlines() + + buffer_stdout[:] = [b for b in buffer_stdout + if line_remove not in b] + + for i, num in enumerate(buffer_stdout): + buffer_stdout[i] = num.replace('vat# ','') + + stdout_value = s.join(buffer_stdout) + print stdout_value + + def do_help(self, line): + self.runVat("help") + + def default(self, line): + self.runVat(line) + + def do_exit(self, line): + self.historyWrite() + raise SystemExit + + def emptyline(self): + pass + + def do_EOF(self,line): + self.historyWrite() + sys.stdout.write('\n') + raise SystemExit + + def preloop(self): + if readline and os.path.exists(persishist): + readline.read_history_file(persishist) + + def postcmd(self, stop, line): + self.historyWrite() + +if __name__ == '__main__': + command_args = sys.argv + + + if not len(command_args) > 1: + prompt = Vppctl() + red_set = '\033[31m' + norm_set = '\033[0m' + if sys.stdout.isatty(): + prompt.prompt = 'vpp# ' + try: + prompt.cmdloop(red_set + " _______ _ " + norm_set + " _ _____ ___ \n" + + red_set + " __/ __/ _ \ (_)__ " + norm_set + " | | / / _ \/ _ \\\n" + + red_set + " _/ _// // / / / _ \\" + norm_set + " | |/ / ___/ ___/\n" + + red_set + " /_/ /____(_)_/\___/ " + norm_set + "|___/_/ /_/ \n") + except KeyboardInterrupt: + sys.stdout.write('\n') + else: + try: + prompt.cmdloop() + except KeyboardInterrupt: + sys.stdout.write('\n') + else: + del command_args[0] + stdout_value = " ".join(command_args) + VatAddress = Vppctl() + VatAddress.runVat(stdout_value) + + + diff --git a/src/suffix-rules.mk b/src/suffix-rules.mk new file mode 100644 index 00000000..e3eeb922 --- /dev/null +++ b/src/suffix-rules.mk @@ -0,0 +1,27 @@ +# Copyright (c) 2016 Cisco and/or its affiliates. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Shared suffix rules +# Please do not set "SUFFIXES = .api.h .api" here + +%.api.h: %.api + @echo " APIGEN " $@ ; \ + mkdir -p `dirname $@` ; \ + $(CC) $(CPPFLAGS) -E -P -C -x c $^ \ + | vppapigen --input - --output $@ --show-name $@ + +%.api.json: %.api + @echo " JSON APIGEN " $@ ; \ + mkdir -p `dirname $@` ; \ + $(CC) $(CPPFLAGS) -E -P -C -x c $^ \ + | vppapigen --input - --json $@ diff --git a/src/svm.am b/src/svm.am new file mode 100644 index 00000000..d91eaa27 --- /dev/null +++ b/src/svm.am @@ -0,0 +1,31 @@ +# Copyright (c) 2015 Cisco and/or its affiliates. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +bin_PROGRAMS += svmtool svmdbtool + +nobase_include_HEADERS += svm/svm.h svm/ssvm.h svm/svmdb.h + +libsvmdir = ${libdir} +libsvm_LTLIBRARIES = libsvm.la libsvmdb.la + +libsvm_la_SOURCES = svm/svm.c svm/ssvm.c + +svmtool_SOURCES = svm/svmtool.c +svmtool_LDADD = libsvm.la libvppinfra.la -lpthread -lrt + +libsvmdb_la_SOURCES = svm/svmdb.c + +svmdbtool_SOURCES = svm/svmdbtool.c +svmdbtool_LDADD = libsvmdb.la libsvm.la libvppinfra.la -lpthread -lrt + +# vi:syntax=automake diff --git a/src/svm/dir.dox b/src/svm/dir.dox new file mode 100644 index 00000000..83246979 --- /dev/null +++ b/src/svm/dir.dox @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2016 Cisco and/or its affiliates. + * Copyright (c) 2016 Comcast Cable Communications Management, LLC. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/* Doxygen directory documentation */ +/** +@dir +@brief Shared virtual memory allocation library. +*/ diff --git a/src/svm/persist.c b/src/svm/persist.c new file mode 100644 index 00000000..023c596b --- /dev/null +++ b/src/svm/persist.c @@ -0,0 +1,258 @@ +/* + *------------------------------------------------------------------ + * persist.c - persistent data structure storage test / demo code + * + * Copyright (c) 2013 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------ + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +typedef struct +{ + svmdb_client_t *c; +} persist_main_t; + +persist_main_t persist_main; + +typedef struct +{ + u8 *string1; + u8 *string2; +} demo_struct2_t; + +typedef struct +{ + demo_struct2_t *demo2; + u8 *name; +} demo_struct1_t; + +/* + * Data structures in persistent shared memory, all the time + */ +clib_error_t * +persist_malloc (persist_main_t * pm) +{ + demo_struct2_t *demo2; + demo_struct1_t *demo1; + time_t starttime = time (0); + char *datestring = ctime (&starttime); + void *oldheap; + + /* Get back the root pointer */ + demo1 = svmdb_local_get_variable_reference + (pm->c, SVMDB_NAMESPACE_VEC, "demo1_location"); + + /* It doesnt exist create our data structures */ + if (demo1 == 0) + { + /* If you want MP / thread safety, lock the region... */ + pthread_mutex_lock (&pm->c->db_rp->mutex); + + /* Switch to the shared memory region heap */ + oldheap = svm_push_data_heap (pm->c->db_rp); + + /* Allocate the top-level structure as a single element vector */ + vec_validate (demo1, 0); + + /* Allocate the next-level structure as a plain old memory obj */ + demo2 = clib_mem_alloc (sizeof (*demo2)); + + demo1->demo2 = demo2; + demo1->name = format (0, "My name is Ishmael%c", 0); + demo2->string1 = format (0, "Here is string1%c", 0); + demo2->string2 = format (0, "Born at %s%c", datestring, 0); + + /* Back to the process-private heap */ + svm_pop_heap (oldheap); + pthread_mutex_unlock (&pm->c->db_rp->mutex); + + /* + * Set the root pointer. Note: this guy switches heaps, locks, etc. + * We allocated demo1 as a vector to make this "just work..." + */ + svmdb_local_set_vec_variable (pm->c, "demo1_location", + demo1, sizeof (demo1)); + + } + else + { + /* retrieve and print data from shared memory */ + demo2 = demo1->demo2; + fformat (stdout, "name: %s\n", demo1->name); + fformat (stdout, "demo2 location: %llx\n", demo2); + fformat (stdout, "string1: %s\n", demo2->string1); + fformat (stdout, "string2: %s\n", demo2->string2); + } + return 0; +} + +void +unserialize_demo1 (serialize_main_t * sm, va_list * args) +{ + demo_struct1_t **result = va_arg (*args, demo_struct1_t **); + demo_struct1_t *demo1; + demo_struct2_t *demo2; + + /* Allocate data structures in process private memory */ + demo1 = clib_mem_alloc (sizeof (*demo1)); + demo2 = clib_mem_alloc (sizeof (*demo2)); + demo1->demo2 = demo2; + + /* retrieve data from shared memory checkpoint */ + unserialize_cstring (sm, (char **) &demo1->name); + unserialize_cstring (sm, (char **) &demo2->string1); + unserialize_cstring (sm, (char **) &demo2->string2); + *result = demo1; +} + +void +serialize_demo1 (serialize_main_t * sm, va_list * args) +{ + demo_struct1_t *demo1 = va_arg (*args, demo_struct1_t *); + demo_struct2_t *demo2 = demo1->demo2; + + serialize_cstring (sm, (char *) demo1->name); + serialize_cstring (sm, (char *) demo2->string1); + serialize_cstring (sm, (char *) demo2->string2); +} + +/* Serialize / unserialize variant */ +clib_error_t * +persist_serialize (persist_main_t * pm) +{ + u8 *checkpoint; + serialize_main_t sm; + + demo_struct2_t *demo2; + demo_struct1_t *demo1; + time_t starttime = time (0); + char *datestring = ctime (&starttime); + + /* Get back the root pointer */ + checkpoint = svmdb_local_get_vec_variable (pm->c, "demo1_checkpoint", + sizeof (u8)); + + /* It doesnt exist create our data structures */ + if (checkpoint == 0) + { + /* Allocate data structures in process-private memory */ + demo1 = clib_mem_alloc (sizeof (*demo2)); + vec_validate (demo1, 0); + demo2 = clib_mem_alloc (sizeof (*demo2)); + + demo1->demo2 = demo2; + demo1->name = format (0, "My name is Ishmael%c", 0); + demo2->string1 = format (0, "Here is string1%c", 0); + demo2->string2 = format (0, "Born at %s%c", datestring, 0); + + /* Create checkpoint */ + serialize_open_vector (&sm, checkpoint); + serialize (&sm, serialize_demo1, demo1); + checkpoint = serialize_close_vector (&sm); + + /* Copy checkpoint into shared memory */ + svmdb_local_set_vec_variable (pm->c, "demo1_checkpoint", + checkpoint, sizeof (u8)); + /* Toss the process-private-memory original.. */ + vec_free (checkpoint); + } + else + { + /* Open the checkpoint */ + unserialize_open_data (&sm, checkpoint, vec_len (checkpoint)); + unserialize (&sm, unserialize_demo1, &demo1); + + /* Toss the process-private-memory checkpoint copy */ + vec_free (checkpoint); + + /* Off we go... */ + demo2 = demo1->demo2; + fformat (stdout, "name: %s\n", demo1->name); + fformat (stdout, "demo2 location: %llx\n", demo2); + fformat (stdout, "string1: %s\n", demo2->string1); + fformat (stdout, "string2: %s\n", demo2->string2); + } + return 0; +} + + +int +main (int argc, char **argv) +{ + unformat_input_t _input, *input = &_input; + persist_main_t *pm = &persist_main; + clib_error_t *error = 0; + + /* Make a 4mb database arena, chroot so it's truly private */ + pm->c = svmdb_map_chroot_size ("/ptest", 4 << 20); + + ASSERT (pm->c); + + unformat_init_command_line (input, argv); + + while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) + { + if (unformat (input, "malloc")) + error = persist_malloc (pm); + else if (unformat (input, "serialize")) + error = persist_serialize (pm); + else + { + error = clib_error_return (0, "Unknown flavor '%U'", + format_unformat_error, input); + break; + } + } + + svmdb_unmap (pm->c); + + if (error) + { + clib_error_report (error); + exit (1); + } + return 0; +} + +/* + * fd.io coding-style-patch-verification: ON + * + * Local Variables: + * eval: (c-set-style "gnu") + * End: + */ diff --git a/src/svm/ssvm.c b/src/svm/ssvm.c new file mode 100644 index 00000000..6f409eb6 --- /dev/null +++ b/src/svm/ssvm.c @@ -0,0 +1,178 @@ +/* + * Copyright (c) 2015 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "ssvm.h" + +int +ssvm_master_init (ssvm_private_t * ssvm, u32 master_index) +{ + int ssvm_fd; + u8 *ssvm_filename; + u8 junk = 0; + int flags; + ssvm_shared_header_t *sh; + u64 ticks = clib_cpu_time_now (); + u64 randomize_baseva; + void *oldheap; + + if (ssvm->ssvm_size == 0) + return SSVM_API_ERROR_NO_SIZE; + + ssvm_filename = format (0, "/dev/shm/%s%c", ssvm->name, 0); + + unlink ((char *) ssvm_filename); + + vec_free (ssvm_filename); + + ssvm_fd = shm_open ((char *) ssvm->name, O_RDWR | O_CREAT | O_EXCL, 0777); + + if (ssvm_fd < 0) + { + clib_unix_warning ("create segment '%s'", ssvm->name); + return SSVM_API_ERROR_CREATE_FAILURE; + } + + if (lseek (ssvm_fd, ssvm->ssvm_size, SEEK_SET) < 0) + { + clib_unix_warning ("lseek"); + close (ssvm_fd); + return SSVM_API_ERROR_SET_SIZE; + } + + if (write (ssvm_fd, &junk, 1) != 1) + { + clib_unix_warning ("set ssvm size"); + close (ssvm_fd); + return SSVM_API_ERROR_SET_SIZE; + } + + flags = MAP_SHARED; + if (ssvm->requested_va) + flags |= MAP_FIXED; + + randomize_baseva = (ticks & 15) * MMAP_PAGESIZE; + + if (ssvm->requested_va) + ssvm->requested_va += randomize_baseva; + + sh = ssvm->sh = + (ssvm_shared_header_t *) mmap ((void *) ssvm->requested_va, + ssvm->ssvm_size, PROT_READ | PROT_WRITE, + flags, ssvm_fd, 0); + + if (ssvm->sh == MAP_FAILED) + { + clib_unix_warning ("mmap"); + close (ssvm_fd); + return SSVM_API_ERROR_MMAP; + } + + close (ssvm_fd); + + ssvm->my_pid = getpid (); + sh->master_pid = ssvm->my_pid; + sh->ssvm_size = ssvm->ssvm_size; + sh->heap = mheap_alloc_with_flags + (((u8 *) sh) + MMAP_PAGESIZE, ssvm->ssvm_size - MMAP_PAGESIZE, + MHEAP_FLAG_DISABLE_VM | MHEAP_FLAG_THREAD_SAFE); + + sh->ssvm_va = pointer_to_uword (sh); + sh->master_index = master_index; + + oldheap = ssvm_push_heap (sh); + sh->name = format (0, "%s%c", ssvm->name, 0); + ssvm_pop_heap (oldheap); + + ssvm->i_am_master = 1; + + /* The application has to set set sh->ready... */ + return 0; +} + +int +ssvm_slave_init (ssvm_private_t * ssvm, int timeout_in_seconds) +{ + struct stat stat; + int ssvm_fd = -1; + ssvm_shared_header_t *sh; + + ssvm->i_am_master = 0; + + while (timeout_in_seconds-- > 0) + { + if (ssvm_fd < 0) + ssvm_fd = shm_open ((char *) ssvm->name, O_RDWR, 0777); + if (ssvm_fd < 0) + { + sleep (1); + continue; + } + if (fstat (ssvm_fd, &stat) < 0) + { + sleep (1); + continue; + } + + if (stat.st_size > 0) + goto map_it; + } + clib_warning ("slave timeout"); + return SSVM_API_ERROR_SLAVE_TIMEOUT; + +map_it: + sh = (void *) mmap (0, MMAP_PAGESIZE, PROT_READ | PROT_WRITE, MAP_SHARED, + ssvm_fd, 0); + if (sh == MAP_FAILED) + { + clib_unix_warning ("slave research mmap"); + close (ssvm_fd); + return SSVM_API_ERROR_MMAP; + } + + while (timeout_in_seconds-- > 0) + { + if (sh->ready) + goto re_map_it; + } + close (ssvm_fd); + munmap (sh, MMAP_PAGESIZE); + clib_warning ("slave timeout 2"); + return SSVM_API_ERROR_SLAVE_TIMEOUT; + +re_map_it: + ssvm->requested_va = (u64) sh->ssvm_va; + ssvm->ssvm_size = sh->ssvm_size; + munmap (sh, MMAP_PAGESIZE); + + sh = ssvm->sh = (void *) mmap ((void *) ssvm->requested_va, ssvm->ssvm_size, + PROT_READ | PROT_WRITE, + MAP_SHARED | MAP_FIXED, ssvm_fd, 0); + + if (sh == MAP_FAILED) + { + clib_unix_warning ("slave final mmap"); + close (ssvm_fd); + return SSVM_API_ERROR_MMAP; + } + sh->slave_pid = getpid (); + return 0; +} + +/* + * fd.io coding-style-patch-verification: ON + * + * Local Variables: + * eval: (c-set-style "gnu") + * End: + */ diff --git a/src/svm/ssvm.h b/src/svm/ssvm.h new file mode 100644 index 00000000..9e61b9a0 --- /dev/null +++ b/src/svm/ssvm.h @@ -0,0 +1,155 @@ +/* + * Copyright (c) 2015 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef __included_ssvm_h__ +#define __included_ssvm_h__ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define MMAP_PAGESIZE (4<<10) +#define SSVM_N_OPAQUE 7 + +typedef struct +{ + /* Spin-lock */ + volatile u32 lock; + volatile u32 owner_pid; + int recursion_count; + u32 tag; /* for debugging */ + + /* The allocation arena */ + void *heap; + + /* Segment must be mapped at this address, or no supper */ + u64 ssvm_va; + /* The actual mmap size */ + u64 ssvm_size; + u32 master_pid; + u32 slave_pid; + u8 *name; + void *opaque[SSVM_N_OPAQUE]; + + /* Set when the master application thinks it's time to make the donuts */ + volatile u32 ready; + + /* Needed to make unique MAC addresses, etc. */ + u32 master_index; +} ssvm_shared_header_t; + +typedef struct +{ + ssvm_shared_header_t *sh; + u64 ssvm_size; + u32 my_pid; + u32 vlib_hw_if_index; + u8 *name; + uword requested_va; + int i_am_master; + u32 per_interface_next_index; + u32 *rx_queue; +} ssvm_private_t; + +always_inline void +ssvm_lock (ssvm_shared_header_t * h, u32 my_pid, u32 tag) +{ + if (h->owner_pid == my_pid) + { + h->recursion_count++; + return; + } + + while (__sync_lock_test_and_set (&h->lock, 1)) + ; + + h->owner_pid = my_pid; + h->recursion_count = 1; + h->tag = tag; +} + +always_inline void +ssvm_unlock (ssvm_shared_header_t * h) +{ + if (--h->recursion_count == 0) + { + h->owner_pid = 0; + h->tag = 0; + CLIB_MEMORY_BARRIER (); + h->lock = 0; + } +} + +static inline void * +ssvm_push_heap (ssvm_shared_header_t * sh) +{ + u8 *oldheap; + oldheap = clib_mem_set_heap (sh->heap); + return ((void *) oldheap); +} + +static inline void +ssvm_pop_heap (void *oldheap) +{ + clib_mem_set_heap (oldheap); +} + +#define foreach_ssvm_api_error \ +_(NO_NAME, "No shared segment name", -10) \ +_(NO_SIZE, "Size not set (master)", -11) \ +_(CREATE_FAILURE, "Create failed", -12) \ +_(SET_SIZE, "Set size failed", -13) \ +_(MMAP, "mmap failed", -14) \ +_(SLAVE_TIMEOUT, "Slave map timeout", -15) + +typedef enum +{ +#define _(n,s,c) SSVM_API_ERROR_##n = c, + foreach_ssvm_api_error +#undef _ +} ssvm_api_error_enum_t; + +#define SSVM_API_ERROR_NO_NAME (-10) + +int ssvm_master_init (ssvm_private_t * ssvm, u32 master_index); +int ssvm_slave_init (ssvm_private_t * ssvm, int timeout_in_seconds); + +#endif /* __included_ssvm_h__ */ + +/* + * fd.io coding-style-patch-verification: ON + * + * Local Variables: + * eval: (c-set-style "gnu") + * End: + */ diff --git a/src/svm/svm.c b/src/svm/svm.c new file mode 100644 index 00000000..e4ca98e1 --- /dev/null +++ b/src/svm/svm.c @@ -0,0 +1,1237 @@ +/* + *------------------------------------------------------------------ + * svm.c - shared VM allocation, mmap(...MAP_FIXED...) + * library + * + * Copyright (c) 2009 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------ + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "svm.h" + +static svm_region_t *root_rp; +static int root_rp_refcount; + +#define MAXLOCK 2 +static pthread_mutex_t *mutexes_held[MAXLOCK]; +static int nheld; + +svm_region_t * +svm_get_root_rp (void) +{ + return root_rp; +} + +#define MUTEX_DEBUG + +static void +region_lock (svm_region_t * rp, int tag) +{ + pthread_mutex_lock (&rp->mutex); +#ifdef MUTEX_DEBUG + rp->mutex_owner_pid = getpid (); + rp->mutex_owner_tag = tag; +#endif + ASSERT (nheld < MAXLOCK); + /* + * Keep score of held mutexes so we can try to exit + * cleanly if the world comes to an end at the worst possible + * moment + */ + mutexes_held[nheld++] = &rp->mutex; +} + +static void +region_unlock (svm_region_t * rp) +{ + int i, j; +#ifdef MUTEX_DEBUG + rp->mutex_owner_pid = 0; + rp->mutex_owner_tag = 0; +#endif + + for (i = nheld - 1; i >= 0; i--) + { + if (mutexes_held[i] == &rp->mutex) + { + for (j = i; j < MAXLOCK - 1; j++) + mutexes_held[j] = mutexes_held[j + 1]; + nheld--; + goto found; + } + } + ASSERT (0); + +found: + CLIB_MEMORY_BARRIER (); + pthread_mutex_unlock (&rp->mutex); +} + + +static u8 * +format_svm_flags (u8 * s, va_list * args) +{ + uword f = va_arg (*args, uword); + + if (f & SVM_FLAGS_MHEAP) + s = format (s, "MHEAP "); + if (f & SVM_FLAGS_FILE) + s = format (s, "FILE "); + if (f & SVM_FLAGS_NODATA) + s = format (s, "NODATA "); + if (f & SVM_FLAGS_NEED_DATA_INIT) + s = format (s, "INIT "); + + return (s); +} + +static u8 * +format_svm_size (u8 * s, va_list * args) +{ + uword size = va_arg (*args, uword); + + if (size >= (1 << 20)) + { + s = format (s, "(%d mb)", size >> 20); + } + else if (size >= (1 << 10)) + { + s = format (s, "(%d kb)", size >> 10); + } + else + { + s = format (s, "(%d bytes)", size); + } + return (s); +} + +u8 * +format_svm_region (u8 * s, va_list * args) +{ + svm_region_t *rp = va_arg (*args, svm_region_t *); + int verbose = va_arg (*args, int); + int i; + uword lo, hi; + + s = format (s, "%s: base va 0x%x size 0x%x %U\n", + rp->region_name, rp->virtual_base, + rp->virtual_size, format_svm_size, rp->virtual_size); + s = format (s, " user_ctx 0x%x, bitmap_size %d\n", + rp->user_ctx, rp->bitmap_size); + + if (verbose) + { + s = format (s, " flags: 0x%x %U\n", rp->flags, + format_svm_flags, rp->flags); + s = format (s, + " region_heap 0x%x data_base 0x%x data_heap 0x%x\n", + rp->region_heap, rp->data_base, rp->data_heap); + } + + s = format (s, " %d clients, pids: ", vec_len (rp->client_pids)); + + for (i = 0; i < vec_len (rp->client_pids); i++) + s = format (s, "%d ", rp->client_pids[i]); + + s = format (s, "\n"); + + if (verbose) + { + lo = hi = ~0; + + s = format (s, " VM in use: "); + + for (i = 0; i < rp->bitmap_size; i++) + { + if (clib_bitmap_get_no_check (rp->bitmap, i) != 0) + { + if (lo == ~0) + { + hi = lo = rp->virtual_base + i * MMAP_PAGESIZE; + } + else + { + hi = rp->virtual_base + i * MMAP_PAGESIZE; + } + } + else + { + if (lo != ~0) + { + hi = rp->virtual_base + i * MMAP_PAGESIZE - 1; + s = format (s, " 0x%x - 0x%x (%dk)\n", lo, hi, + (hi - lo) >> 10); + lo = hi = ~0; + } + } + } + s = format (s, " rgn heap stats: %U", format_mheap, + rp->region_heap, 0); + if ((rp->flags & SVM_FLAGS_MHEAP) && rp->data_heap) + { + s = format (s, "\n data heap stats: %U", format_mheap, + rp->data_heap, 1); + } + s = format (s, "\n"); + } + + return (s); +} + +/* + * rnd_pagesize + * Round to a pagesize multiple, presumably 4k works + */ +static u64 +rnd_pagesize (u64 size) +{ + u64 rv; + + rv = (size + (MMAP_PAGESIZE - 1)) & ~(MMAP_PAGESIZE - 1); + return (rv); +} + +/* + * svm_data_region_setup + */ +static int +svm_data_region_create (svm_map_region_args_t * a, svm_region_t * rp) +{ + int fd; + u8 junk = 0; + uword map_size; + + map_size = rp->virtual_size - (MMAP_PAGESIZE + + (a->pvt_heap_size ? a->pvt_heap_size : + SVM_PVT_MHEAP_SIZE)); + + if (a->flags & SVM_FLAGS_FILE) + { + struct stat statb; + + fd = open (a->backing_file, O_RDWR | O_CREAT, 0777); + + if (fd < 0) + { + clib_unix_warning ("open"); + return -1; + } + + if (fstat (fd, &statb) < 0) + { + clib_unix_warning ("fstat"); + close (fd); + return -2; + } + + if (statb.st_mode & S_IFREG) + { + if (statb.st_size == 0) + { + if (lseek (fd, map_size, SEEK_SET) == (off_t) - 1) + { + clib_unix_warning ("seek region size"); + close (fd); + return -3; + } + if (write (fd, &junk, 1) != 1) + { + clib_unix_warning ("set region size"); + close (fd); + return -3; + } + } + else + { + map_size = rnd_pagesize (statb.st_size); + } + } + else + { + map_size = a->backing_mmap_size; + } + + ASSERT (map_size <= rp->virtual_size - + (MMAP_PAGESIZE + SVM_PVT_MHEAP_SIZE)); + + if (mmap (rp->data_base, map_size, PROT_READ | PROT_WRITE, + MAP_SHARED | MAP_FIXED, fd, 0) == MAP_FAILED) + { + clib_unix_warning ("mmap"); + close (fd); + return -3; + } + close (fd); + rp->backing_file = (char *) format (0, "%s\0", a->backing_file); + rp->flags |= SVM_FLAGS_FILE; + } + + if (a->flags & SVM_FLAGS_MHEAP) + { + rp->data_heap = + mheap_alloc_with_flags ((void *) (rp->data_base), map_size, + MHEAP_FLAG_DISABLE_VM); + rp->flags |= SVM_FLAGS_MHEAP; + } + return 0; +} + +static int +svm_data_region_map (svm_map_region_args_t * a, svm_region_t * rp) +{ + int fd; + u8 junk = 0; + uword map_size; + struct stat statb; + + map_size = rp->virtual_size - + (MMAP_PAGESIZE + + (a->pvt_heap_size ? a->pvt_heap_size : SVM_PVT_MHEAP_SIZE)); + + if (a->flags & SVM_FLAGS_FILE) + { + + fd = open (a->backing_file, O_RDWR, 0777); + + if (fd < 0) + { + clib_unix_warning ("open"); + return -1; + } + + if (fstat (fd, &statb) < 0) + { + clib_unix_warning ("fstat"); + close (fd); + return -2; + } + + if (statb.st_mode & S_IFREG) + { + if (statb.st_size == 0) + { + if (lseek (fd, map_size, SEEK_SET) == (off_t) - 1) + { + clib_unix_warning ("seek region size"); + close (fd); + return -3; + } + if (write (fd, &junk, 1) != 1) + { + clib_unix_warning ("set region size"); + close (fd); + return -3; + } + } + else + { + map_size = rnd_pagesize (statb.st_size); + } + } + else + { + map_size = a->backing_mmap_size; + } + + ASSERT (map_size <= rp->virtual_size + - (MMAP_PAGESIZE + + + (a->pvt_heap_size ? a->pvt_heap_size : SVM_PVT_MHEAP_SIZE))); + + if (mmap (rp->data_base, map_size, PROT_READ | PROT_WRITE, + MAP_SHARED | MAP_FIXED, fd, 0) == MAP_FAILED) + { + clib_unix_warning ("mmap"); + close (fd); + return -3; + } + close (fd); + } + return 0; +} + +u8 * +shm_name_from_svm_map_region_args (svm_map_region_args_t * a) +{ + u8 *path; + u8 *shm_name; + u8 *split_point; + u8 *mkdir_arg = 0; + int root_path_offset = 0; + int name_offset = 0; + + if (a->root_path) + { + /* Tolerate present or absent slashes */ + if (a->root_path[0] == '/') + root_path_offset++; + + /* create the root_path under /dev/shm + iterate through path creating directories */ + + path = format (0, "/dev/shm/%s%c", &a->root_path[root_path_offset], 0); + split_point = path + 1; + vec_add1 (mkdir_arg, '-'); + + while (*split_point) + { + while (*split_point && *split_point != '/') + { + vec_add1 (mkdir_arg, *split_point); + split_point++; + } + vec_add1 (mkdir_arg, 0); + + /* ready to descend another level */ + mkdir_arg[vec_len (mkdir_arg) - 1] = '-'; + split_point++; + } + vec_free (mkdir_arg); + vec_free (path); + + if (a->name[0] == '/') + name_offset = 1; + + shm_name = format (0, "/%s-%s%c", a->root_path, + &a->name[name_offset], 0); + } + else + shm_name = format (0, "%s%c", a->name, 0); + return (shm_name); +} + +/* + * svm_map_region + */ +void * +svm_map_region (svm_map_region_args_t * a) +{ + int svm_fd; + svm_region_t *rp; + pthread_mutexattr_t attr; + pthread_condattr_t cattr; + int deadman = 0; + u8 junk = 0; + void *oldheap; + int overhead_space; + int rv; + uword data_base; + int nbits, words, bit; + int pid_holding_region_lock; + u8 *shm_name; + int dead_region_recovery = 0; + int time_left; + struct stat stat; + struct timespec ts, tsrem; + + if (CLIB_DEBUG > 1) + clib_warning ("[%d] map region %s", getpid (), a->name); + + ASSERT ((a->size & ~(MMAP_PAGESIZE - 1)) == a->size); + ASSERT (a->name); + + shm_name = shm_name_from_svm_map_region_args (a); + + svm_fd = shm_open ((char *) shm_name, O_RDWR | O_CREAT | O_EXCL, 0777); + + if (svm_fd >= 0) + { + if (fchmod (svm_fd, 0770) < 0) + clib_unix_warning ("segment chmod"); + /* This turns out to fail harmlessly if the client starts first */ + if (fchown (svm_fd, a->uid, a->gid) < 0) + clib_unix_warning ("segment chown [ok if client starts first]"); + + vec_free (shm_name); + + if (lseek (svm_fd, a->size, SEEK_SET) == (off_t) - 1) + { + clib_warning ("seek region size"); + close (svm_fd); + return (0); + } + if (write (svm_fd, &junk, 1) != 1) + { + clib_warning ("set region size"); + close (svm_fd); + return (0); + } + + rp = mmap ((void *) a->baseva, a->size, + PROT_READ | PROT_WRITE, MAP_SHARED | MAP_FIXED, svm_fd, 0); + + if (rp == (svm_region_t *) MAP_FAILED) + { + clib_unix_warning ("mmap create"); + close (svm_fd); + return (0); + } + close (svm_fd); + memset (rp, 0, sizeof (*rp)); + + if (pthread_mutexattr_init (&attr)) + clib_unix_warning ("mutexattr_init"); + + if (pthread_mutexattr_setpshared (&attr, PTHREAD_PROCESS_SHARED)) + clib_unix_warning ("mutexattr_setpshared"); + + if (pthread_mutex_init (&rp->mutex, &attr)) + clib_unix_warning ("mutex_init"); + + if (pthread_mutexattr_destroy (&attr)) + clib_unix_warning ("mutexattr_destroy"); + + if (pthread_condattr_init (&cattr)) + clib_unix_warning ("condattr_init"); + + if (pthread_condattr_setpshared (&cattr, PTHREAD_PROCESS_SHARED)) + clib_unix_warning ("condattr_setpshared"); + + if (pthread_cond_init (&rp->condvar, &cattr)) + clib_unix_warning ("cond_init"); + + if (pthread_condattr_destroy (&cattr)) + clib_unix_warning ("condattr_destroy"); + + region_lock (rp, 1); + + rp->virtual_base = a->baseva; + rp->virtual_size = a->size; + + rp->region_heap = + mheap_alloc_with_flags ((void *) (a->baseva + MMAP_PAGESIZE), + (a->pvt_heap_size != 0) ? + a->pvt_heap_size : SVM_PVT_MHEAP_SIZE, + MHEAP_FLAG_DISABLE_VM); + oldheap = svm_push_pvt_heap (rp); + + rp->region_name = (char *) format (0, "%s%c", a->name, 0); + vec_add1 (rp->client_pids, getpid ()); + + nbits = rp->virtual_size / MMAP_PAGESIZE; + + ASSERT (nbits > 0); + rp->bitmap_size = nbits; + words = (nbits + BITS (uword) - 1) / BITS (uword); + vec_validate (rp->bitmap, words - 1); + + overhead_space = MMAP_PAGESIZE /* header */ + + ((a->pvt_heap_size != 0) ? a->pvt_heap_size : SVM_PVT_MHEAP_SIZE); + + bit = 0; + data_base = (uword) rp->virtual_base; + + if (a->flags & SVM_FLAGS_NODATA) + rp->flags |= SVM_FLAGS_NEED_DATA_INIT; + + do + { + clib_bitmap_set_no_check (rp->bitmap, bit, 1); + bit++; + overhead_space -= MMAP_PAGESIZE; + data_base += MMAP_PAGESIZE; + } + while (overhead_space > 0); + + rp->data_base = (void *) data_base; + + /* + * Note: although the POSIX spec guarantees that only one + * process enters this block, we have to play games + * to hold off clients until e.g. the mutex is ready + */ + rp->version = SVM_VERSION; + + /* setup the data portion of the region */ + + rv = svm_data_region_create (a, rp); + if (rv) + { + clib_warning ("data_region_create: %d", rv); + } + + region_unlock (rp); + + svm_pop_heap (oldheap); + + return ((void *) rp); + } + else + { + svm_fd = shm_open ((char *) shm_name, O_RDWR, 0777); + + vec_free (shm_name); + + if (svm_fd < 0) + { + perror ("svm_region_map(mmap open)"); + return (0); + } + + time_left = 20; + while (1) + { + if (0 != fstat (svm_fd, &stat)) + { + clib_warning ("fstat failed: %d", errno); + close (svm_fd); + return (0); + } + if (stat.st_size > 0) + { + break; + } + if (0 == time_left) + { + clib_warning ("waiting for resize of shm file timed out"); + close (svm_fd); + return (0); + } + ts.tv_sec = 0; + ts.tv_nsec = 100000000; + while (nanosleep (&ts, &tsrem) < 0) + ts = tsrem; + time_left--; + } + + rp = mmap (0, MMAP_PAGESIZE, + PROT_READ | PROT_WRITE, MAP_SHARED, svm_fd, 0); + + if (rp == (svm_region_t *) MAP_FAILED) + { + close (svm_fd); + clib_warning ("mmap"); + return (0); + } + /* + * We lost the footrace to create this region; make sure + * the winner has crossed the finish line. + */ + while (rp->version == 0 && deadman++ < 5) + { + sleep (1); + } + + /* + * -ed? + */ + if (rp->version == 0) + { + clib_warning ("rp->version %d not %d", rp->version, SVM_VERSION); + close (svm_fd); + munmap (rp, a->size); + return (0); + } + /* Remap now that the region has been placed */ + a->baseva = rp->virtual_base; + a->size = rp->virtual_size; + munmap (rp, MMAP_PAGESIZE); + + rp = (void *) mmap ((void *) a->baseva, a->size, + PROT_READ | PROT_WRITE, + MAP_SHARED | MAP_FIXED, svm_fd, 0); + if ((uword) rp == (uword) MAP_FAILED) + { + clib_unix_warning ("mmap"); + close (svm_fd); + return (0); + } + + if ((uword) rp != rp->virtual_base) + { + clib_warning ("mmap botch"); + } + + /* + * Try to fix the region mutex if it is held by + * a dead process + */ + pid_holding_region_lock = rp->mutex_owner_pid; + if (pid_holding_region_lock && kill (pid_holding_region_lock, 0) < 0) + { + clib_warning + ("region %s mutex held by dead pid %d, tag %d, force unlock", + rp->region_name, pid_holding_region_lock, rp->mutex_owner_tag); + /* owner pid is nonexistent */ + rp->mutex.__data.__owner = 0; + rp->mutex.__data.__lock = 0; + dead_region_recovery = 1; + } + + if (dead_region_recovery) + clib_warning ("recovery: attempt to re-lock region"); + + region_lock (rp, 2); + oldheap = svm_push_pvt_heap (rp); + vec_add1 (rp->client_pids, getpid ()); + + if (dead_region_recovery) + clib_warning ("recovery: attempt svm_data_region_map"); + + rv = svm_data_region_map (a, rp); + if (rv) + { + clib_warning ("data_region_map: %d", rv); + } + + if (dead_region_recovery) + clib_warning ("unlock and continue"); + + region_unlock (rp); + + svm_pop_heap (oldheap); + + return ((void *) rp); + + } + return 0; /* NOTREACHED */ +} + +static void +svm_mutex_cleanup (void) +{ + int i; + for (i = 0; i < nheld; i++) + { + pthread_mutex_unlock (mutexes_held[i]); + } +} + +static void +svm_region_init_internal (svm_map_region_args_t * a) +{ + svm_region_t *rp; + u64 ticks = clib_cpu_time_now (); + uword randomize_baseva; + + /* guard against klutz calls */ + if (root_rp) + return; + + root_rp_refcount++; + + atexit (svm_mutex_cleanup); + + /* Randomize the shared-VM base at init time */ + if (MMAP_PAGESIZE <= (4 << 10)) + randomize_baseva = (ticks & 15) * MMAP_PAGESIZE; + else + randomize_baseva = (ticks & 3) * MMAP_PAGESIZE; + + a->baseva += randomize_baseva; + + rp = svm_map_region (a); + ASSERT (rp); + + region_lock (rp, 3); + + /* Set up the main region data structures */ + if (rp->flags & SVM_FLAGS_NEED_DATA_INIT) + { + svm_main_region_t *mp = 0; + void *oldheap; + + rp->flags &= ~(SVM_FLAGS_NEED_DATA_INIT); + + oldheap = svm_push_pvt_heap (rp); + vec_validate (mp, 0); + mp->name_hash = hash_create_string (0, sizeof (uword)); + mp->root_path = a->root_path ? format (0, "%s%c", a->root_path, 0) : 0; + rp->data_base = mp; + svm_pop_heap (oldheap); + } + region_unlock (rp); + root_rp = rp; +} + +void +svm_region_init (void) +{ + svm_map_region_args_t _a, *a = &_a; + + memset (a, 0, sizeof (*a)); + a->root_path = 0; + a->name = SVM_GLOBAL_REGION_NAME; + a->baseva = SVM_GLOBAL_REGION_BASEVA; + a->size = SVM_GLOBAL_REGION_SIZE; + a->flags = SVM_FLAGS_NODATA; + a->uid = 0; + a->gid = 0; + + svm_region_init_internal (a); +} + +void +svm_region_init_chroot (char *root_path) +{ + svm_map_region_args_t _a, *a = &_a; + + memset (a, 0, sizeof (*a)); + a->root_path = root_path; + a->name = SVM_GLOBAL_REGION_NAME; + a->baseva = SVM_GLOBAL_REGION_BASEVA; + a->size = SVM_GLOBAL_REGION_SIZE; + a->flags = SVM_FLAGS_NODATA; + a->uid = 0; + a->gid = 0; + + svm_region_init_internal (a); +} + +void +svm_region_init_chroot_uid_gid (char *root_path, int uid, int gid) +{ + svm_map_region_args_t _a, *a = &_a; + + memset (a, 0, sizeof (*a)); + a->root_path = root_path; + a->name = SVM_GLOBAL_REGION_NAME; + a->baseva = SVM_GLOBAL_REGION_BASEVA; + a->size = SVM_GLOBAL_REGION_SIZE; + a->flags = SVM_FLAGS_NODATA; + a->uid = uid; + a->gid = gid; + + svm_region_init_internal (a); +} + +void +svm_region_init_args (svm_map_region_args_t * a) +{ + svm_region_init_internal (a); +} + +void * +svm_region_find_or_create (svm_map_region_args_t * a) +{ + svm_main_region_t *mp; + svm_region_t *rp; + uword need_nbits; + int index, i; + void *oldheap; + uword *p; + u8 *name; + svm_subregion_t *subp; + + ASSERT (root_rp); + + a->size += MMAP_PAGESIZE + + ((a->pvt_heap_size != 0) ? a->pvt_heap_size : SVM_PVT_MHEAP_SIZE); + a->size = rnd_pagesize (a->size); + + region_lock (root_rp, 4); + oldheap = svm_push_pvt_heap (root_rp); + mp = root_rp->data_base; + + ASSERT (mp); + + /* Map the named region from the correct chroot environment */ + a->root_path = (char *) mp->root_path; + + /* + * See if this region is already known. If it is, we're + * almost done... + */ + p = hash_get_mem (mp->name_hash, a->name); + + if (p) + { + rp = svm_map_region (a); + region_unlock (root_rp); + svm_pop_heap (oldheap); + return rp; + } + + /* Create the region. */ + ASSERT ((a->size & ~(MMAP_PAGESIZE - 1)) == a->size); + + need_nbits = a->size / MMAP_PAGESIZE; + + index = 1; /* $$$ fixme, figure out how many bit to really skip */ + + /* + * Scan the virtual space allocation bitmap, looking for a large + * enough chunk + */ + do + { + if (clib_bitmap_get_no_check (root_rp->bitmap, index) == 0) + { + for (i = 0; i < (need_nbits - 1); i++) + { + if (clib_bitmap_get_no_check (root_rp->bitmap, index + i) == 1) + { + index = index + i; + goto next; + } + } + break; + } + index++; + next:; + } + while (index < root_rp->bitmap_size); + + /* Completely out of VM? */ + if (index >= root_rp->bitmap_size) + { + clib_warning ("region %s: not enough VM to allocate 0x%llx (%lld)", + root_rp->region_name, a->size, a->size); + svm_pop_heap (oldheap); + region_unlock (root_rp); + return 0; + } + + /* + * Mark virtual space allocated + */ +#if CLIB_DEBUG > 1 + clib_warning ("set %d bits at index %d", need_nbits, index); +#endif + + for (i = 0; i < need_nbits; i++) + { + clib_bitmap_set_no_check (root_rp->bitmap, index + i, 1); + } + + /* Place this region where it goes... */ + a->baseva = root_rp->virtual_base + index * MMAP_PAGESIZE; + + rp = svm_map_region (a); + + pool_get (mp->subregions, subp); + name = format (0, "%s%c", a->name, 0); + subp->subregion_name = name; + + hash_set_mem (mp->name_hash, name, subp - mp->subregions); + + svm_pop_heap (oldheap); + + region_unlock (root_rp); + + return (rp); +} + +/* + * svm_region_unmap + * + * Let go of the indicated region. If the calling process + * is the last customer, throw it away completely. + * The root region mutex guarantees atomicity with respect to + * a new region client showing up at the wrong moment. + */ +void +svm_region_unmap (void *rp_arg) +{ + int i, mypid = getpid (); + int nclients_left; + void *oldheap; + uword virtual_base, virtual_size; + svm_region_t *rp = rp_arg; + char *name; + + /* + * If we take a signal while holding one or more shared-memory + * mutexes, we may end up back here from an otherwise + * benign exit handler. Bail out to avoid a recursive + * mutex screw-up. + */ + if (nheld) + return; + + ASSERT (rp); + ASSERT (root_rp); + + if (CLIB_DEBUG > 1) + clib_warning ("[%d] unmap region %s", getpid (), rp->region_name); + + region_lock (root_rp, 5); + region_lock (rp, 6); + + oldheap = svm_push_pvt_heap (rp); /* nb vec_delete() in the loop */ + + /* Remove the caller from the list of mappers */ + for (i = 0; i < vec_len (rp->client_pids); i++) + { + if (rp->client_pids[i] == mypid) + { + vec_delete (rp->client_pids, 1, i); + goto found; + } + } + clib_warning ("pid %d AWOL", mypid); + +found: + + svm_pop_heap (oldheap); + + nclients_left = vec_len (rp->client_pids); + virtual_base = rp->virtual_base; + virtual_size = rp->virtual_size; + + if (nclients_left == 0) + { + int index, nbits, i; + svm_main_region_t *mp; + uword *p; + svm_subregion_t *subp; + + /* Kill the region, last guy on his way out */ + + oldheap = svm_push_pvt_heap (root_rp); + name = vec_dup (rp->region_name); + + virtual_base = rp->virtual_base; + virtual_size = rp->virtual_size; + + /* Figure out which bits to clear in the root region bitmap */ + index = (virtual_base - root_rp->virtual_base) / MMAP_PAGESIZE; + + nbits = (virtual_size + MMAP_PAGESIZE - 1) / MMAP_PAGESIZE; + +#if CLIB_DEBUG > 1 + clib_warning ("clear %d bits at index %d", nbits, index); +#endif + /* Give back the allocated VM */ + for (i = 0; i < nbits; i++) + { + clib_bitmap_set_no_check (root_rp->bitmap, index + i, 0); + } + + mp = root_rp->data_base; + + p = hash_get_mem (mp->name_hash, name); + + /* Better never happen ... */ + if (p == NULL) + { + region_unlock (rp); + region_unlock (root_rp); + svm_pop_heap (oldheap); + clib_warning ("Region name '%s' not found?", name); + return; + } + + /* Remove from the root region subregion pool */ + subp = mp->subregions + p[0]; + pool_put (mp->subregions, subp); + + hash_unset_mem (mp->name_hash, name); + + vec_free (name); + + region_unlock (rp); + shm_unlink (rp->region_name); + munmap ((void *) virtual_base, virtual_size); + region_unlock (root_rp); + svm_pop_heap (oldheap); + return; + } + + region_unlock (rp); + region_unlock (root_rp); + + munmap ((void *) virtual_base, virtual_size); +} + +/* + * svm_region_exit + * There is no clean way to unlink the + * root region when all clients go away, + * so remove the pid entry and call it a day. + */ +void +svm_region_exit () +{ + void *oldheap; + int i, mypid = getpid (); + uword virtual_base, virtual_size; + + /* It felt so nice we did it twice... */ + if (root_rp == 0) + return; + + if (--root_rp_refcount > 0) + return; + + /* + * If we take a signal while holding one or more shared-memory + * mutexes, we may end up back here from an otherwise + * benign exit handler. Bail out to avoid a recursive + * mutex screw-up. + */ + if (nheld) + return; + + region_lock (root_rp, 7); + oldheap = svm_push_pvt_heap (root_rp); + + virtual_base = root_rp->virtual_base; + virtual_size = root_rp->virtual_size; + + for (i = 0; i < vec_len (root_rp->client_pids); i++) + { + if (root_rp->client_pids[i] == mypid) + { + vec_delete (root_rp->client_pids, 1, i); + goto found; + } + } + clib_warning ("pid %d AWOL", mypid); + +found: + + region_unlock (root_rp); + svm_pop_heap (oldheap); + + root_rp = 0; + munmap ((void *) virtual_base, virtual_size); +} + +void +svm_client_scan_this_region_nolock (svm_region_t * rp) +{ + int j; + int mypid = getpid (); + void *oldheap; + + for (j = 0; j < vec_len (rp->client_pids); j++) + { + if (mypid == rp->client_pids[j]) + continue; + if (rp->client_pids[j] && (kill (rp->client_pids[j], 0) < 0)) + { + clib_warning ("%s: cleanup ghost pid %d", + rp->region_name, rp->client_pids[j]); + /* nb: client vec in rp->region_heap */ + oldheap = svm_push_pvt_heap (rp); + vec_delete (rp->client_pids, 1, j); + j--; + svm_pop_heap (oldheap); + } + } +} + + +/* + * Scan svm regions for dead clients + */ +void +svm_client_scan (char *root_path) +{ + int i, j; + svm_main_region_t *mp; + svm_map_region_args_t *a = 0; + svm_region_t *root_rp; + svm_region_t *rp; + svm_subregion_t *subp; + u8 *name = 0; + u8 **svm_names = 0; + void *oldheap; + int mypid = getpid (); + + vec_validate (a, 0); + + svm_region_init_chroot (root_path); + + root_rp = svm_get_root_rp (); + + pthread_mutex_lock (&root_rp->mutex); + + mp = root_rp->data_base; + + for (j = 0; j < vec_len (root_rp->client_pids); j++) + { + if (mypid == root_rp->client_pids[j]) + continue; + if (root_rp->client_pids[j] && (kill (root_rp->client_pids[j], 0) < 0)) + { + clib_warning ("%s: cleanup ghost pid %d", + root_rp->region_name, root_rp->client_pids[j]); + /* nb: client vec in root_rp->region_heap */ + oldheap = svm_push_pvt_heap (root_rp); + vec_delete (root_rp->client_pids, 1, j); + j--; + svm_pop_heap (oldheap); + } + } + + /* + * Snapshoot names, can't hold root rp mutex across + * find_or_create. + */ + /* *INDENT-OFF* */ + pool_foreach (subp, mp->subregions, ({ + name = vec_dup (subp->subregion_name); + vec_add1(svm_names, name); + })); + /* *INDENT-ON* */ + + pthread_mutex_unlock (&root_rp->mutex); + + for (i = 0; i < vec_len (svm_names); i++) + { + vec_validate (a, 0); + a->root_path = root_path; + a->name = (char *) svm_names[i]; + rp = svm_region_find_or_create (a); + if (rp) + { + pthread_mutex_lock (&rp->mutex); + + svm_client_scan_this_region_nolock (rp); + + pthread_mutex_unlock (&rp->mutex); + svm_region_unmap (rp); + vec_free (svm_names[i]); + } + vec_free (a); + } + vec_free (svm_names); + + svm_region_exit (); + + vec_free (a); +} + +/* + * fd.io coding-style-patch-verification: ON + * + * Local Variables: + * eval: (c-set-style "gnu") + * End: + */ diff --git a/src/svm/svm.h b/src/svm/svm.h new file mode 100644 index 00000000..0b87dbcb --- /dev/null +++ b/src/svm/svm.h @@ -0,0 +1,207 @@ +/* + *------------------------------------------------------------------ + * svm.h - shared VM allocation, mmap(...MAP_FIXED...) + * brain police + * + * Copyright (c) 2009 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------ + */ + +#ifndef __included_svm_h__ +#define __included_svm_h__ + +#include +#include +#include + +#define MMAP_PAGESIZE (clib_mem_get_page_size()) + +#define SVM_VERSION ((1<<16) | 1) /* set to declare region ready. */ + +#define SVM_FLAGS_MHEAP (1<<0) /* region contains an mheap */ +#define SVM_FLAGS_FILE (1<<1) /* region backed by one or more files */ +#define SVM_FLAGS_NODATA (1<<2) /* region will be further subdivided */ +#define SVM_FLAGS_NEED_DATA_INIT (1<<3) + +#define SVM_PVT_MHEAP_SIZE (128<<10) /* region's private mheap (128k) */ + +typedef struct svm_region_ +{ + volatile uword version; + pthread_mutex_t mutex; + pthread_cond_t condvar; + int mutex_owner_pid; /* in case of trouble */ + int mutex_owner_tag; + uword flags; + uword virtual_base; /* base of the region object */ + uword virtual_size; + void *region_heap; + void *data_base; /* data portion base address */ + void *data_heap; /* data heap, if any */ + volatile void *user_ctx; /* user context pointer */ + /* stuff allocated in the region's heap */ + uword bitmap_size; /* nbits in virtual alloc bitmap */ + uword *bitmap; /* the bitmap */ + char *region_name; + char *backing_file; + char **filenames; + uword *client_pids; + /* pad */ + + /* next page: + * (64K) clib heap for the region itself + * + * data_base -> whatever is in this region + */ + +} svm_region_t; + +typedef struct svm_map_region_args_ +{ + char *root_path; /* NULL means use the truly global arena */ + char *name; + u64 baseva; + u64 size; + u64 pvt_heap_size; + uword flags; + char *backing_file; + uword backing_mmap_size; + /* uid, gid to own the svm region(s) */ + int uid; + int gid; +} svm_map_region_args_t; + + +/* + * Memory shared across all router instances. Packet buffers, etc + * Base should be "out of the way," and size should be big enough to + * cover everything we plan to put here. + */ +#define SVM_GLOBAL_REGION_BASEVA 0x30000000 +#define SVM_GLOBAL_REGION_SIZE (64<<20) +#define SVM_GLOBAL_REGION_NAME "/global_vm" + +/* + * Memory shared across individual router instances. + */ +#define SVM_OVERLAY_REGION_BASEVA \ + (SVM_GLOBAL_REGION_BASEVA + SVM_GLOBAL_REGION_SIZE) +#define SVM_OVERLAY_REGION_SIZE (1<<20) +#define SVM_OVERLAY_REGION_BASENAME "/overlay_vm" + +typedef struct +{ + u8 *subregion_name; +} svm_subregion_t; + +typedef struct +{ + svm_subregion_t *subregions; /* subregion pool */ + uword *name_hash; + u8 *root_path; +} svm_main_region_t; + + +void *svm_region_find_or_create (svm_map_region_args_t * a); +void svm_region_init (void); +void svm_region_init_chroot (char *root_path); +void svm_region_init_chroot_uid_gid (char *root_path, int uid, int gid); +void svm_region_init_args (svm_map_region_args_t * a); +void svm_region_exit (void); +void svm_region_unmap (void *rp_arg); +void svm_client_scan (char *root_path); +void svm_client_scan_this_region_nolock (svm_region_t * rp); +u8 *shm_name_from_svm_map_region_args (svm_map_region_args_t * a); + +static inline void * +svm_mem_alloc (svm_region_t * rp, uword size) +{ + u8 *oldheap; + ASSERT (rp->flags & SVM_FLAGS_MHEAP); + u8 *rv; + + pthread_mutex_lock (&rp->mutex); + oldheap = clib_mem_set_heap (rp->data_heap); + rv = clib_mem_alloc (size); + clib_mem_set_heap (oldheap); + pthread_mutex_unlock (&rp->mutex); + return (rv); +} + +static inline void * +svm_mem_alloc_aligned_at_offset (svm_region_t * rp, + uword size, uword align, uword offset) +{ + u8 *oldheap; + ASSERT (rp->flags & SVM_FLAGS_MHEAP); + u8 *rv; + + pthread_mutex_lock (&rp->mutex); + oldheap = clib_mem_set_heap (rp->data_heap); + rv = clib_mem_alloc_aligned_at_offset (size, align, offset, + 1 /* yes, call os_out_of_memory */ ); + clib_mem_set_heap (oldheap); + pthread_mutex_unlock (&rp->mutex); + return (rv); +} + +static inline void +svm_mem_free (svm_region_t * rp, void *ptr) +{ + u8 *oldheap; + ASSERT (rp->flags & SVM_FLAGS_MHEAP); + + pthread_mutex_lock (&rp->mutex); + oldheap = clib_mem_set_heap (rp->data_heap); + clib_mem_free (ptr); + clib_mem_set_heap (oldheap); + pthread_mutex_unlock (&rp->mutex); + +} + +static inline void * +svm_push_pvt_heap (svm_region_t * rp) +{ + u8 *oldheap; + oldheap = clib_mem_set_heap (rp->region_heap); + return ((void *) oldheap); +} + +static inline void * +svm_push_data_heap (svm_region_t * rp) +{ + u8 *oldheap; + oldheap = clib_mem_set_heap (rp->data_heap); + return ((void *) oldheap); +} + +static inline void +svm_pop_heap (void *oldheap) +{ + clib_mem_set_heap (oldheap); +} + +u8 *format_svm_region (u8 * s, va_list * args); + +svm_region_t *svm_get_root_rp (void); + +#endif /* __included_svm_h__ */ + +/* + * fd.io coding-style-patch-verification: ON + * + * Local Variables: + * eval: (c-set-style "gnu") + * End: + */ diff --git a/src/svm/svm_test.c b/src/svm/svm_test.c new file mode 100644 index 00000000..ab0b9e24 --- /dev/null +++ b/src/svm/svm_test.c @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2015 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/* + *------------------------------------------------------------------ + * svm_test.c -- brain police + *------------------------------------------------------------------ + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "svm.h" + + +int +main (int argc, char **argv) +{ + svm_region_t *root_rp, *rp; + svm_map_region_args_t *a = 0; + + vec_validate (a, 0); + + root_rp = svm_region_init (); + + ASSERT (root_rp); + + a->name = "/qvnet"; + a->size = (4 << 10); + + rp = svm_region_find_or_create (root_rp, a); + + ASSERT (rp); + + *((u32 *) rp->data_base) = 0xdeadbeef; + svm_region_unmap (root_rp, rp); + + fformat (stdout, "exiting...\n"); + + exit (0); +} + +/* + * fd.io coding-style-patch-verification: ON + * + * Local Variables: + * eval: (c-set-style "gnu") + * End: + */ diff --git a/src/svm/svmdb.c b/src/svm/svmdb.c new file mode 100644 index 00000000..03dfe7c3 --- /dev/null +++ b/src/svm/svmdb.c @@ -0,0 +1,671 @@ +/* + *------------------------------------------------------------------ + * svmdb.c -- simple shared memory database + * + * Copyright (c) 2009 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------ + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "svmdb.h" + +static void local_set_variable_nolock (svmdb_client_t * client, + svmdb_namespace_t namespace, + u8 * var, u8 * val, u32 elsize); + +always_inline void +region_lock (svm_region_t * rp, int tag) +{ + pthread_mutex_lock (&rp->mutex); +#ifdef MUTEX_DEBUG + rp->mutex_owner_pid = getpid (); + rp->mutex_owner_tag = tag; +#endif +} + +always_inline void +region_unlock (svm_region_t * rp) +{ +#ifdef MUTEX_DEBUG + rp->mutex_owner_pid = 0; + rp->mutex_owner_tag = 0; +#endif + pthread_mutex_unlock (&rp->mutex); +} + +svmdb_client_t * +svmdb_map (svmdb_map_args_t * dba) +{ + svmdb_client_t *client = 0; + svm_map_region_args_t *a = 0; + svm_region_t *db_rp; + void *oldheap; + svmdb_shm_hdr_t *hp = 0; + + vec_validate (client, 0); + vec_validate (a, 0); + + svm_region_init_chroot_uid_gid (dba->root_path, dba->uid, dba->gid); + + a->root_path = dba->root_path; + a->name = "/db"; + a->size = dba->size ? dba->size : SVMDB_DEFAULT_SIZE; + a->flags = SVM_FLAGS_MHEAP; + a->uid = dba->uid; + a->gid = dba->gid; + + db_rp = client->db_rp = svm_region_find_or_create (a); + + ASSERT (db_rp); + + vec_free (a); + + region_lock (client->db_rp, 10); + /* Has someone else set up the shared-memory variable table? */ + if (db_rp->user_ctx) + { + client->shm = (void *) db_rp->user_ctx; + client->pid = getpid (); + region_unlock (client->db_rp); + ASSERT (client->shm->version == SVMDB_SHM_VERSION); + return (client); + } + /* Nope, it's our problem... */ + + /* Add a bogus client (pid=0) so the svm won't be deallocated */ + oldheap = svm_push_pvt_heap (db_rp); + vec_add1 (client->db_rp->client_pids, 0); + svm_pop_heap (oldheap); + + oldheap = svm_push_data_heap (db_rp); + + vec_validate (hp, 0); + hp->version = SVMDB_SHM_VERSION; + hp->namespaces[SVMDB_NAMESPACE_STRING] + = hash_create_string (0, sizeof (uword)); + hp->namespaces[SVMDB_NAMESPACE_VEC] + = hash_create_string (0, sizeof (uword)); + + db_rp->user_ctx = hp; + client->shm = hp; + + svm_pop_heap (oldheap); + region_unlock (client->db_rp); + client->pid = getpid (); + + return (client); +} + +void +svmdb_unmap (svmdb_client_t * client) +{ + ASSERT (client); + + if (!svm_get_root_rp ()) + return; + + svm_region_unmap ((void *) client->db_rp); + svm_region_exit (); + vec_free (client); +} + +static void +notify_value (svmdb_value_t * v, svmdb_action_t a) +{ + int i; + int rv; + union sigval sv; + u32 value; + u32 *dead_registrations = 0; + + svmdb_notify_t *np; + + for (i = 0; i < vec_len (v->notifications); i++) + { + np = vec_elt_at_index (v->notifications, i); + if (np->action == a) + { + value = (np->action << 28) | (np->opaque); + sv.sival_ptr = (void *) (uword) value; + do + { + rv = 0; + if (sigqueue (np->pid, np->signum, sv) == 0) + break; + rv = errno; + } + while (rv == EAGAIN); + if (rv == 0) + continue; + vec_add1 (dead_registrations, i); + } + } + + for (i = 0; i < vec_len (dead_registrations); i++) + { + np = vec_elt_at_index (v->notifications, dead_registrations[i]); + clib_warning ("dead reg pid %d sig %d action %d opaque %x", + np->pid, np->signum, np->action, np->opaque); + vec_delete (v->notifications, 1, dead_registrations[i]); + } + vec_free (dead_registrations); +} + +int +svmdb_local_add_del_notification (svmdb_client_t * client, + svmdb_notification_args_t * a) +{ + uword *h; + void *oldheap; + hash_pair_t *hp; + svmdb_shm_hdr_t *shm; + u8 *dummy_value = 0; + svmdb_value_t *value; + svmdb_notify_t *np; + int i; + int rv = 0; + + ASSERT (a->elsize); + + region_lock (client->db_rp, 18); + shm = client->shm; + oldheap = svm_push_data_heap (client->db_rp); + + h = shm->namespaces[a->nspace]; + + hp = hash_get_pair_mem (h, a->var); + if (hp == 0) + { + local_set_variable_nolock (client, a->nspace, (u8 *) a->var, + dummy_value, a->elsize); + /* might have moved */ + h = shm->namespaces[a->nspace]; + hp = hash_get_pair_mem (h, a->var); + ASSERT (hp); + } + + value = pool_elt_at_index (shm->values, hp->value[0]); + + for (i = 0; i < vec_len (value->notifications); i++) + { + np = vec_elt_at_index (value->notifications, i); + if ((np->pid == client->pid) + && (np->signum == a->signum) + && (np->action == a->action) && (np->opaque == a->opaque)) + { + if (a->add_del == 0 /* delete */ ) + { + vec_delete (value->notifications, 1, i); + goto out; + } + else + { /* add */ + clib_warning + ("%s: ignore dup reg pid %d signum %d action %d opaque %x", + a->var, client->pid, a->signum, a->action, a->opaque); + rv = -2; + goto out; + } + } + } + if (a->add_del == 0) + { + rv = -3; + goto out; + } + + vec_add2 (value->notifications, np, 1); + np->pid = client->pid; + np->signum = a->signum; + np->action = a->action; + np->opaque = a->opaque; + +out: + svm_pop_heap (oldheap); + region_unlock (client->db_rp); + return rv; +} + + +static void +local_unset_variable_nolock (svmdb_client_t * client, + svmdb_namespace_t namespace, char *var) +{ + uword *h; + svmdb_value_t *oldvalue; + hash_pair_t *hp; + + h = client->shm->namespaces[namespace]; + hp = hash_get_pair_mem (h, var); + if (hp) + { + oldvalue = pool_elt_at_index (client->shm->values, hp->value[0]); + if (vec_len (oldvalue->notifications)) + notify_value (oldvalue, SVMDB_ACTION_UNSET); + /* zero length value means unset */ + _vec_len (oldvalue->value) = 0; + } + client->shm->namespaces[namespace] = h; +} + +void +svmdb_local_unset_string_variable (svmdb_client_t * client, char *var) +{ + void *oldheap; + + region_lock (client->db_rp, 11); + oldheap = svm_push_data_heap (client->db_rp); + local_unset_variable_nolock (client, SVMDB_NAMESPACE_STRING, var); + svm_pop_heap (oldheap); + region_unlock (client->db_rp); +} + +static void +local_set_variable_nolock (svmdb_client_t * client, + svmdb_namespace_t namespace, + u8 * var, u8 * val, u32 elsize) +{ + uword *h; + hash_pair_t *hp; + u8 *name; + svmdb_shm_hdr_t *shm; + + shm = client->shm; + h = shm->namespaces[namespace]; + hp = hash_get_pair_mem (h, var); + if (hp) + { + svmdb_value_t *oldvalue; + oldvalue = pool_elt_at_index (client->shm->values, hp->value[0]); + vec_alloc (oldvalue->value, vec_len (val) * elsize); + clib_memcpy (oldvalue->value, val, vec_len (val) * elsize); + _vec_len (oldvalue->value) = vec_len (val); + notify_value (oldvalue, SVMDB_ACTION_SET); + } + else + { + svmdb_value_t *newvalue; + pool_get (shm->values, newvalue); + memset (newvalue, 0, sizeof (*newvalue)); + newvalue->elsize = elsize; + vec_alloc (newvalue->value, vec_len (val) * elsize); + clib_memcpy (newvalue->value, val, vec_len (val) * elsize); + _vec_len (newvalue->value) = vec_len (val); + name = format (0, "%s%c", var, 0); + hash_set_mem (h, name, newvalue - shm->values); + } + shm->namespaces[namespace] = h; +} + +void +svmdb_local_set_string_variable (svmdb_client_t * client, + char *var, char *val) +{ + void *oldheap; + + region_lock (client->db_rp, 12); + oldheap = svm_push_data_heap (client->db_rp); + + local_unset_variable_nolock (client, SVMDB_NAMESPACE_STRING, var); + + local_set_variable_nolock (client, SVMDB_NAMESPACE_STRING, + (u8 *) var, (u8 *) val, 1 /* elsize */ ); + svm_pop_heap (oldheap); + region_unlock (client->db_rp); +} + +static u8 * +local_get_variable_nolock (svmdb_client_t * client, + svmdb_namespace_t namespace, u8 * var) +{ + uword *h; + uword *p; + svmdb_shm_hdr_t *shm; + svmdb_value_t *oldvalue; + + shm = client->shm; + h = shm->namespaces[namespace]; + p = hash_get_mem (h, var); + if (p) + { + oldvalue = pool_elt_at_index (shm->values, p[0]); + notify_value (oldvalue, SVMDB_ACTION_GET); + return (oldvalue->value); + } + return 0; +} + +void * +svmdb_local_get_variable_reference (svmdb_client_t * client, + svmdb_namespace_t namespace, char *var) +{ + u8 *rv; + + region_lock (client->db_rp, 19); + rv = local_get_variable_nolock (client, namespace, (u8 *) var); + region_unlock (client->db_rp); + return (void *) rv; +} + +char * +svmdb_local_get_string_variable (svmdb_client_t * client, char *var) +{ + u8 *rv = 0; + + region_lock (client->db_rp, 13); + rv = local_get_variable_nolock (client, SVMDB_NAMESPACE_STRING, (u8 *) var); + + if (rv && vec_len (rv)) + { + rv = format (0, "%s", rv); + vec_add1 (rv, 0); + } + region_unlock (client->db_rp); + return ((char *) rv); +} + +void +svmdb_local_dump_strings (svmdb_client_t * client) +{ + uword *h; + u8 *key; + u32 value; + svmdb_shm_hdr_t *shm = client->shm; + + region_lock (client->db_rp, 14); + + h = client->shm->namespaces[SVMDB_NAMESPACE_STRING]; + + /* *INDENT-OFF* */ + hash_foreach_mem(key, value, h, + ({ + svmdb_value_t *v = pool_elt_at_index (shm->values, value); + + fformat(stdout, "%s: %s\n", key, + vec_len(v->value) ? v->value : (u8 *)"(nil)"); + })); + /* *INDENT-ON* */ + region_unlock (client->db_rp); +} + +int +svmdb_local_serialize_strings (svmdb_client_t * client, char *filename) +{ + uword *h; + u8 *key; + u32 value; + svmdb_shm_hdr_t *shm = client->shm; + serialize_main_t _sm, *sm = &_sm; + clib_error_t *error = 0; + u8 *sanitized_name = 0; + int fd = 0; + + if (strstr (filename, "..") || index (filename, '/')) + { + error = clib_error_return (0, "Illegal characters in filename '%s'", + filename); + goto out; + } + + sanitized_name = format (0, "/tmp/%s%c", filename, 0); + + fd = creat ((char *) sanitized_name, 0644); + + if (fd < 0) + { + error = clib_error_return_unix (0, "Create '%s'", sanitized_name); + goto out; + } + + serialize_open_unix_file_descriptor (sm, fd); + + region_lock (client->db_rp, 20); + + h = client->shm->namespaces[SVMDB_NAMESPACE_STRING]; + + serialize_likely_small_unsigned_integer (sm, hash_elts (h)); + + /* *INDENT-OFF* */ + hash_foreach_mem(key, value, h, + ({ + svmdb_value_t *v = pool_elt_at_index (shm->values, value); + + /* Omit names with nil values */ + if (vec_len(v->value)) + { + serialize_cstring (sm, (char *)key); + serialize_cstring (sm, (char *)v->value); + } + })); + /* *INDENT-ON* */ + region_unlock (client->db_rp); + + serialize_close (sm); + +out: + if (fd > 0 && close (fd) < 0) + error = clib_error_return_unix (0, "close fd %d", fd); + + if (error) + { + clib_error_report (error); + return -1; + } + return 0; +} + +int +svmdb_local_unserialize_strings (svmdb_client_t * client, char *filename) +{ + serialize_main_t _sm, *sm = &_sm; + void *oldheap; + clib_error_t *error = 0; + u8 *key, *value; + int fd = 0; + u32 nelts; + int i; + + fd = open (filename, O_RDONLY); + + if (fd < 0) + { + error = clib_error_return_unix (0, "Failed to open '%s'", filename); + goto out; + } + + unserialize_open_unix_file_descriptor (sm, fd); + + region_lock (client->db_rp, 21); + oldheap = svm_push_data_heap (client->db_rp); + + nelts = unserialize_likely_small_unsigned_integer (sm); + + for (i = 0; i < nelts; i++) + { + unserialize_cstring (sm, (char **) &key); + unserialize_cstring (sm, (char **) &value); + local_set_variable_nolock (client, SVMDB_NAMESPACE_STRING, + key, value, 1 /* elsize */ ); + vec_free (key); + vec_free (value); + } + svm_pop_heap (oldheap); + region_unlock (client->db_rp); + + serialize_close (sm); + +out: + if (fd > 0 && close (fd) < 0) + error = clib_error_return_unix (0, "close fd %d", fd); + + if (error) + { + clib_error_report (error); + return -1; + } + return 0; +} + +void +svmdb_local_unset_vec_variable (svmdb_client_t * client, char *var) +{ + void *oldheap; + + region_lock (client->db_rp, 15); + oldheap = svm_push_data_heap (client->db_rp); + local_unset_variable_nolock (client, SVMDB_NAMESPACE_VEC, var); + svm_pop_heap (oldheap); + region_unlock (client->db_rp); +} + +void +svmdb_local_set_vec_variable (svmdb_client_t * client, + char *var, void *val_arg, u32 elsize) +{ + u8 *val = (u8 *) val_arg; + void *oldheap; + + region_lock (client->db_rp, 16); + oldheap = svm_push_data_heap (client->db_rp); + + local_unset_variable_nolock (client, SVMDB_NAMESPACE_VEC, var); + local_set_variable_nolock (client, SVMDB_NAMESPACE_VEC, (u8 *) var, + val, elsize); + + svm_pop_heap (oldheap); + region_unlock (client->db_rp); +} + +void * +svmdb_local_get_vec_variable (svmdb_client_t * client, char *var, u32 elsize) +{ + u8 *rv = 0; + u8 *copy = 0; + + region_lock (client->db_rp, 17); + + rv = local_get_variable_nolock (client, SVMDB_NAMESPACE_VEC, (u8 *) var); + + if (rv && vec_len (rv)) + { + /* Make a copy in process-local memory */ + vec_alloc (copy, vec_len (rv) * elsize); + clib_memcpy (copy, rv, vec_len (rv) * elsize); + _vec_len (copy) = vec_len (rv); + region_unlock (client->db_rp); + return (copy); + } + region_unlock (client->db_rp); + return (0); +} + +void +svmdb_local_dump_vecs (svmdb_client_t * client) +{ + uword *h; + u8 *key; + u32 value; + svmdb_shm_hdr_t *shm; + + region_lock (client->db_rp, 17); + shm = client->shm; + + h = client->shm->namespaces[SVMDB_NAMESPACE_VEC]; + + /* *INDENT-OFF* */ + hash_foreach_mem(key, value, h, + ({ + svmdb_value_t *v = pool_elt_at_index (shm->values, value); + (void) fformat(stdout, "%s:\n %U (%.2f)\n", key, + format_hex_bytes, v->value, + vec_len(v->value)*v->elsize, ((f64 *)(v->value))[0]); + })); + /* *INDENT-ON* */ + + region_unlock (client->db_rp); +} + +void * +svmdb_local_find_or_add_vec_variable (svmdb_client_t * client, + char *var, u32 nbytes) +{ + void *oldheap; + u8 *rv = 0; + + region_lock (client->db_rp, 18); + oldheap = svm_push_data_heap (client->db_rp); + + rv = local_get_variable_nolock (client, SVMDB_NAMESPACE_VEC, (u8 *) var); + + if (rv) + { + goto out; + } + else + { + uword *h; + u8 *name; + svmdb_shm_hdr_t *shm; + svmdb_value_t *newvalue; + + shm = client->shm; + h = shm->namespaces[SVMDB_NAMESPACE_VEC]; + + pool_get (shm->values, newvalue); + memset (newvalue, 0, sizeof (*newvalue)); + newvalue->elsize = 1; + vec_alloc (newvalue->value, nbytes); + _vec_len (newvalue->value) = nbytes; + name = format (0, "%s%c", var, 0); + hash_set_mem (h, name, newvalue - shm->values); + shm->namespaces[SVMDB_NAMESPACE_VEC] = h; + rv = newvalue->value; + } + +out: + svm_pop_heap (oldheap); + region_unlock (client->db_rp); + return (rv); +} + +/* + * fd.io coding-style-patch-verification: ON + * + * Local Variables: + * eval: (c-set-style "gnu") + * End: + */ diff --git a/src/svm/svmdb.h b/src/svm/svmdb.h new file mode 100644 index 00000000..e02628a0 --- /dev/null +++ b/src/svm/svmdb.h @@ -0,0 +1,135 @@ +/* + *------------------------------------------------------------------ + * svmdb.h - shared VM database + * + * Copyright (c) 2009 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------ + */ + +#ifndef __included_svmdb_h__ +#define __included_svmdb_h__ + +#include "svm.h" + +typedef enum +{ + SVMDB_ACTION_ILLEGAL = 0, + SVMDB_ACTION_GET, /* not clear why anyone would care */ + SVMDB_ACTION_SET, + SVMDB_ACTION_UNSET, +} svmdb_action_t; + +typedef struct +{ + int pid; + int signum; + u32 action:4; + u32 opaque:28; +} svmdb_notify_t; + +typedef struct +{ + u8 *value; + svmdb_notify_t *notifications; + u32 elsize; +} svmdb_value_t; + +typedef enum +{ + SVMDB_NAMESPACE_STRING = 0, + SVMDB_NAMESPACE_VEC, + SVMDB_N_NAMESPACES, +} svmdb_namespace_t; + +typedef struct +{ + uword version; + /* pool of values */ + svmdb_value_t *values; + uword *namespaces[SVMDB_N_NAMESPACES]; +} svmdb_shm_hdr_t; + +#define SVMDB_SHM_VERSION 2 + +typedef struct +{ + int flags; + int pid; + svm_region_t *db_rp; + svmdb_shm_hdr_t *shm; +} svmdb_client_t; + +typedef struct +{ + int add_del; + svmdb_namespace_t nspace; + char *var; + u32 elsize; + int signum; + u32 action:4; + u32 opaque:28; +} svmdb_notification_args_t; + +typedef struct +{ + char *root_path; + uword size; + u32 uid; + u32 gid; +} svmdb_map_args_t; + +/* + * Must be a reasonable number, several mb smaller than + * SVM_GLOBAL_REGION_SIZE, or no donut for you... + */ +#define SVMDB_DEFAULT_SIZE (4<<20) + +svmdb_client_t *svmdb_map (svmdb_map_args_t *); + +void svmdb_unmap (svmdb_client_t * client); +void svmdb_local_unset_string_variable (svmdb_client_t * client, char *var); +void svmdb_local_set_string_variable (svmdb_client_t * client, + char *var, char *val); +char *svmdb_local_get_string_variable (svmdb_client_t * client, char *var); +void *svmdb_local_get_variable_reference (svmdb_client_t * client, + svmdb_namespace_t ns, char *var); + +void svmdb_local_dump_strings (svmdb_client_t * client); + +void svmdb_local_unset_vec_variable (svmdb_client_t * client, char *var); +void svmdb_local_set_vec_variable (svmdb_client_t * client, + char *var, void *val, u32 elsize); +void *svmdb_local_get_vec_variable (svmdb_client_t * client, char *var, + u32 elsize); +void svmdb_local_dump_vecs (svmdb_client_t * client); + +int svmdb_local_add_del_notification (svmdb_client_t * client, + svmdb_notification_args_t * args); + +void *svmdb_local_find_or_add_vec_variable (svmdb_client_t * client, + char *var, u32 nbytes); + +int svmdb_local_serialize_strings (svmdb_client_t * client, char *filename); +int svmdb_local_unserialize_strings (svmdb_client_t * client, char *filename); + + +#endif /* __included_svmdb_h__ */ + +/* + * fd.io coding-style-patch-verification: ON + * + * Local Variables: + * eval: (c-set-style "gnu") + * End: + */ diff --git a/src/svm/svmdbtool.c b/src/svm/svmdbtool.c new file mode 100644 index 00000000..a0af15fc --- /dev/null +++ b/src/svm/svmdbtool.c @@ -0,0 +1,537 @@ +/* + * Copyright (c) 2015 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "svmdb.h" + +typedef struct +{ + svmdb_map_args_t map_args; + int uid, gid; + uword size; +} svmdbtool_main_t; + +svmdbtool_main_t svmdbtool_main; + +static inline svmdb_map_args_t * +map_arg_setup (char *chroot_path) +{ + svmdbtool_main_t *sm = &svmdbtool_main; + svmdb_map_args_t *ma = &sm->map_args; + + memset (ma, 0, sizeof (*ma)); + ma->root_path = chroot_path; + ma->size = sm->size; + ma->uid = sm->uid; + ma->gid = sm->gid; + return ma; +} + +static void +get_string (char *chroot_path, u8 * vbl) +{ + svmdb_client_t *c; + char *rv; + svmdb_map_args_t *ma; + + ma = map_arg_setup (chroot_path); + + c = svmdb_map (ma); + + rv = svmdb_local_get_string_variable (c, (char *) vbl); + + fformat (stdout, "%s\n", rv ? rv : "UNSET"); + vec_free (rv); + svmdb_unmap (c); +} + +static void +set_string (char *chroot_path, u8 * vbl, u8 * value) +{ + svmdb_client_t *c; + svmdb_map_args_t *ma; + + ma = map_arg_setup (chroot_path); + + c = svmdb_map (ma); + svmdb_local_set_string_variable (c, (char *) vbl, (char *) value); + svmdb_unmap (c); +} + +static void +unset_string (char *chroot_path, u8 * vbl) +{ + svmdb_client_t *c; + svmdb_map_args_t *ma; + + ma = map_arg_setup (chroot_path); + + c = svmdb_map (ma); + svmdb_local_unset_string_variable (c, (char *) vbl); + svmdb_unmap (c); +} + +static void +dump_strings (char *chroot_path) +{ + svmdb_client_t *c; + svmdb_map_args_t *ma; + + ma = map_arg_setup (chroot_path); + + c = svmdb_map (ma); + svmdb_local_dump_strings (c); + svmdb_unmap (c); +} + +static void +serialize_strings (char *chroot_path, char *filename) +{ + svmdb_client_t *c; + svmdb_map_args_t *ma; + + ma = map_arg_setup (chroot_path); + + c = svmdb_map (ma); + (void) svmdb_local_serialize_strings (c, filename); + svmdb_unmap (c); +} + +static void +unserialize_strings (char *chroot_path, char *filename) +{ + svmdb_client_t *c; + svmdb_map_args_t *ma; + + ma = map_arg_setup (chroot_path); + + c = svmdb_map (ma); + (void) svmdb_local_unserialize_strings (c, filename); + svmdb_unmap (c); +} + +static void +test_vlib_vec_rate (char *chroot_path, f64 vr) +{ + svmdb_client_t *c; + f64 *tv = 0; + svmdb_map_args_t *ma; + + ma = map_arg_setup (chroot_path); + + c = svmdb_map (ma); + + vec_add1 (tv, vr); + + svmdb_local_set_vec_variable (c, "vlib_vector_rate", (char *) tv, + sizeof (*tv)); + svmdb_unmap (c); + + vec_free (tv); +} + + + +static void +test_vec (char *chroot_path, u8 * vbl) +{ + svmdb_client_t *c; + u64 *tv = 0; + int i; + svmdb_map_args_t *ma; + + ma = map_arg_setup (chroot_path); + + c = svmdb_map (ma); + + /* my amp goes to 11 */ + for (i = 0; i < 11; i++) + { + vec_add1 (tv, i); + } + + svmdb_local_set_vec_variable (c, (char *) vbl, (char *) tv, sizeof (tv[0])); + svmdb_unmap (c); + + vec_free (tv); +} + +static void +fake_install (char *chroot_path, u8 * add_value) +{ + svmdb_client_t *c; + u8 *v = 0; + u8 **values = 0; + u8 *oldvalue; + u8 *value; + int nitems = 0, i; + serialize_main_t m; + svmdb_map_args_t *ma; + + ma = map_arg_setup (chroot_path); + + c = svmdb_map (ma); + + oldvalue = svmdb_local_get_vec_variable (c, "installed_sw", 1); + if (oldvalue) + { + unserialize_open_data (&m, oldvalue, vec_len (oldvalue)); + nitems = unserialize_likely_small_unsigned_integer (&m); + for (i = 0; i < nitems; i++) + { + unserialize_cstring (&m, (char **) &value); + vec_add1 (values, value); + } + vec_free (v); + } + nitems++; + value = format (0, "%s%c", add_value, 0); + + vec_add1 (values, value); + + fformat (stdout, "Resulting installed_sw vector:\n"); + + serialize_open_vector (&m, v); + serialize_likely_small_unsigned_integer (&m, vec_len (values)); + for (i = 0; i < vec_len (values); i++) + { + fformat (stdout, "%s\n", values[i]); + serialize_cstring (&m, (char *) values[i]); + } + + v = serialize_close_vector (&m); + + svmdb_local_set_vec_variable (c, "installed_sw", v, sizeof (v[0])); + svmdb_unmap (c); + + for (i = 0; i < vec_len (values); i++) + vec_free (values[i]); + vec_free (values); +} + +static void +sigaction_handler (int signum, siginfo_t * i, void *notused) +{ + u32 action, opaque; + + action = (u32) (uword) i->si_ptr; + action >>= 28; + opaque = (u32) (uword) i->si_ptr; + opaque &= ~(0xF0000000); + + clib_warning ("signal %d, action %d, opaque %x", signum, action, opaque); +} + +static void +test_reg (char *chroot_path, u8 * vbl) +{ + svmdb_client_t *c; + svmdb_notification_args_t args; + svmdb_notification_args_t *a = &args; + struct sigaction sa; + svmdb_map_args_t *ma; + + ma = map_arg_setup (chroot_path); + + memset (&sa, 0, sizeof (sa)); + sa.sa_sigaction = sigaction_handler; + sa.sa_flags = SA_SIGINFO; + if (sigaction (SIGUSR2, &sa, 0) < 0) + { + clib_unix_warning ("sigaction"); + return; + } + + memset (a, 0, sizeof (*a)); + + c = svmdb_map (ma); + + a->add_del = 1 /* add */ ; + a->nspace = SVMDB_NAMESPACE_STRING; + a->var = (char *) vbl; + a->elsize = 1; + a->signum = SIGUSR2; + a->action = SVMDB_ACTION_GET; + a->opaque = 0x0eadbeef; + + svmdb_local_add_del_notification (c, a); + + (void) svmdb_local_get_string_variable (c, (char *) vbl); + + a->add_del = 0; /* del */ + svmdb_local_add_del_notification (c, a); + + + + svmdb_unmap (c); +} + +static void +unset_vec (char *chroot_path, u8 * vbl) +{ + svmdb_client_t *c; + svmdb_map_args_t *ma; + + ma = map_arg_setup (chroot_path); + + c = svmdb_map (ma); + + svmdb_local_unset_vec_variable (c, (char *) vbl); + svmdb_unmap (c); +} + +static void +dump_vecs (char *chroot_path) +{ + svmdb_client_t *c; + svmdb_map_args_t *ma; + + ma = map_arg_setup (chroot_path); + + c = svmdb_map (ma); + + svmdb_local_dump_vecs (c); + svmdb_unmap (c); +} + +static void +crash_test (char *chroot_path) +{ + svmdb_client_t *c; + svmdb_map_args_t *ma; + + ma = map_arg_setup (chroot_path); + + c = svmdb_map (ma); + + clib_warning ("Grab region mutex and crash deliberately!"); + c->db_rp->mutex_owner_pid = getpid (); + c->db_rp->mutex_owner_tag = -13; + pthread_mutex_lock (&c->db_rp->mutex); + + abort (); +} + +static void +map_with_size (char *chroot_path, uword size) +{ + svmdb_client_t *c; + svmdb_map_args_t *ma; + + svmdbtool_main.size = size; + ma = map_arg_setup (chroot_path); + + c = svmdb_map (ma); + + svmdb_unmap (c); +} + +int +main (int argc, char **argv) +{ + unformat_input_t input; + int parsed = 0; + u8 *vbl = 0, *value = 0; + char *chroot_path = 0; + u8 *chroot_path_u8; + u8 *filename; + uword size; + f64 vr; + int uid, gid, rv; + struct passwd _pw, *pw; + struct group _grp, *grp; + char *s, buf[128]; + + svmdbtool_main.uid = geteuid (); + svmdbtool_main.gid = getegid (); + + unformat_init_command_line (&input, argv); + + while (unformat_check_input (&input) != UNFORMAT_END_OF_INPUT) + { + if (unformat (&input, "get-string %s", &vbl)) + { + get_string (chroot_path, vbl); + vec_free (vbl); + parsed++; + } + else if (unformat (&input, "set-string %s %s", &vbl, &value)) + { + set_string (chroot_path, vbl, value); + vec_free (vbl); + vec_free (value); + parsed++; + } + else if (unformat (&input, "unset-string %s", &vbl)) + { + unset_string (chroot_path, vbl); + vec_free (vbl); + parsed++; + } + else if (unformat (&input, "dump-strings")) + { + dump_strings (chroot_path); + parsed++; + } + else if (unformat (&input, "unset-vec %s", &vbl)) + { + unset_vec (chroot_path, vbl); + vec_free (vbl); + parsed++; + } + else if (unformat (&input, "dump-vecs")) + { + dump_vecs (chroot_path); + parsed++; + } + else if (unformat (&input, "test-vec %s", &vbl)) + { + test_vec (chroot_path, vbl); + // vec_free(vbl); + parsed++; + } + else if (unformat (&input, "vlib-vec-rate %f", &vr)) + { + test_vlib_vec_rate (chroot_path, vr); + parsed++; + } + else if (unformat (&input, "test-reg %s", &vbl)) + { + test_reg (chroot_path, vbl); + parsed++; + } + else if (unformat (&input, "crash-test")) + { + crash_test (chroot_path); + } + else if (unformat (&input, "chroot %s", &chroot_path_u8)) + { + chroot_path = (char *) chroot_path_u8; + } + else if (unformat (&input, "fake-install %s", &value)) + { + fake_install (chroot_path, value); + parsed++; + } + else if (unformat (&input, "size %d", &size)) + { + map_with_size (chroot_path, size); + parsed++; + } + else if (unformat (&input, "uid %d", &uid)) + svmdbtool_main.uid = uid; + else if (unformat (&input, "gid %d", &gid)) + svmdbtool_main.gid = gid; + else if (unformat (&input, "uid %s", &s)) + { + /* lookup the username */ + pw = NULL; + rv = getpwnam_r (s, &_pw, buf, sizeof (buf), &pw); + if (rv < 0) + { + fformat (stderr, "cannot fetch username %s", s); + exit (1); + } + if (pw == NULL) + { + fformat (stderr, "username %s does not exist", s); + exit (1); + } + vec_free (s); + svmdbtool_main.uid = pw->pw_uid; + } + else if (unformat (&input, "gid %s", &s)) + { + /* lookup the group name */ + grp = NULL; + rv = getgrnam_r (s, &_grp, buf, sizeof (buf), &grp); + if (rv != 0) + { + fformat (stderr, "cannot fetch group %s", s); + exit (1); + } + if (grp == NULL) + { + fformat (stderr, "group %s does not exist", s); + exit (1); + } + vec_free (s); + svmdbtool_main.gid = grp->gr_gid; + } + else if (unformat (&input, "serialize-strings %s", &filename)) + { + vec_add1 (filename, 0); + serialize_strings (chroot_path, (char *) filename); + parsed++; + } + else if (unformat (&input, "unserialize-strings %s", &filename)) + { + vec_add1 (filename, 0); + unserialize_strings (chroot_path, (char *) filename); + parsed++; + } + else + { + break; + } + } + + unformat_free (&input); + + if (!parsed) + { + fformat (stdout, "%s: get-string | set-string \n", + argv[0]); + fformat (stdout, " unset-string | dump-strings\n"); + fformat (stdout, " test-vec |\n"); + fformat (stdout, " unset-vec | dump-vecs\n"); + fformat (stdout, " chroot [uid ]\n"); + fformat (stdout, " [gid ]\n"); + } + + exit (0); +} + +/* + * fd.io coding-style-patch-verification: ON + * + * Local Variables: + * eval: (c-set-style "gnu") + * End: + */ diff --git a/src/svm/svmtool.c b/src/svm/svmtool.c new file mode 100644 index 00000000..b3195514 --- /dev/null +++ b/src/svm/svmtool.c @@ -0,0 +1,528 @@ +/* + *------------------------------------------------------------------ + * svmtool.c + * + * Copyright (c) 2009 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------ + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "svm.h" + + + +/* + * format_all_svm_regions + * Maps / unmaps regions. Do NOT call from client code! + */ +u8 * +format_all_svm_regions (u8 * s, va_list * args) +{ + int verbose = va_arg (*args, int); + svm_region_t *root_rp = svm_get_root_rp (); + svm_main_region_t *mp; + svm_subregion_t *subp; + svm_region_t *rp; + svm_map_region_args_t *a = 0; + u8 **svm_names = 0; + u8 *name = 0; + int i; + + ASSERT (root_rp); + + pthread_mutex_lock (&root_rp->mutex); + + s = format (s, "%U", format_svm_region, root_rp, verbose); + + mp = root_rp->data_base; + + /* + * Snapshoot names, can't hold root rp mutex across + * find_or_create. + */ + /* *INDENT-OFF* */ + pool_foreach (subp, mp->subregions, ({ + name = vec_dup (subp->subregion_name); + vec_add1(svm_names, name); + })); + /* *INDENT-ON* */ + + pthread_mutex_unlock (&root_rp->mutex); + + for (i = 0; i < vec_len (svm_names); i++) + { + vec_validate (a, 0); + a->name = (char *) svm_names[i]; + rp = svm_region_find_or_create (a); + if (rp) + { + pthread_mutex_lock (&rp->mutex); + s = format (s, "%U", format_svm_region, rp, verbose); + pthread_mutex_unlock (&rp->mutex); + svm_region_unmap (rp); + vec_free (svm_names[i]); + } + vec_free (a); + } + vec_free (svm_names); + return (s); +} + +void +show (char *chroot_path, int verbose) +{ + svm_map_region_args_t *a = 0; + + vec_validate (a, 0); + + svm_region_init_chroot (chroot_path); + + fformat (stdout, "My pid is %d\n", getpid ()); + + fformat (stdout, "%U", format_all_svm_regions, verbose); + + svm_region_exit (); + + vec_free (a); +} + + +static void * +svm_map_region_nolock (svm_map_region_args_t * a) +{ + int svm_fd; + svm_region_t *rp; + int deadman = 0; + u8 *shm_name; + + ASSERT ((a->size & ~(MMAP_PAGESIZE - 1)) == a->size); + + shm_name = shm_name_from_svm_map_region_args (a); + + svm_fd = shm_open ((char *) shm_name, O_RDWR, 0777); + + if (svm_fd < 0) + { + perror ("svm_region_map(mmap open)"); + return (0); + } + vec_free (shm_name); + + rp = mmap (0, MMAP_PAGESIZE, PROT_READ | PROT_WRITE, MAP_SHARED, svm_fd, 0); + + if (rp == (svm_region_t *) MAP_FAILED) + { + close (svm_fd); + clib_warning ("mmap"); + return (0); + } + /* + * We lost the footrace to create this region; make sure + * the winner has crossed the finish line. + */ + while (rp->version == 0 && deadman++ < 5) + { + sleep (1); + } + + /* + * -ed? + */ + if (rp->version == 0) + { + clib_warning ("rp->version %d not %d", rp->version, SVM_VERSION); + munmap (rp, MMAP_PAGESIZE); + return (0); + } + /* Remap now that the region has been placed */ + a->baseva = rp->virtual_base; + a->size = rp->virtual_size; + munmap (rp, MMAP_PAGESIZE); + + rp = (void *) mmap ((void *) a->baseva, a->size, + PROT_READ | PROT_WRITE, + MAP_SHARED | MAP_FIXED, svm_fd, 0); + if ((uword) rp == (uword) MAP_FAILED) + { + clib_unix_warning ("mmap"); + return (0); + } + + if ((uword) rp != rp->virtual_base) + { + clib_warning ("mmap botch"); + } + + if (pthread_mutex_trylock (&rp->mutex)) + { + clib_warning ("rp->mutex LOCKED by pid %d, tag %d, cleared...", + rp->mutex_owner_pid, rp->mutex_owner_tag); + memset (&rp->mutex, 0, sizeof (rp->mutex)); + + } + else + { + clib_warning ("mutex OK...\n"); + pthread_mutex_unlock (&rp->mutex); + } + + return ((void *) rp); +} + +/* + * rnd_pagesize + * Round to a pagesize multiple, presumably 4k works + */ +static u64 +rnd_pagesize (u64 size) +{ + u64 rv; + + rv = (size + (MMAP_PAGESIZE - 1)) & ~(MMAP_PAGESIZE - 1); + return (rv); +} + +#define MUTEX_DEBUG + +always_inline void +region_lock (svm_region_t * rp, int tag) +{ + pthread_mutex_lock (&rp->mutex); +#ifdef MUTEX_DEBUG + rp->mutex_owner_pid = getpid (); + rp->mutex_owner_tag = tag; +#endif +} + +always_inline void +region_unlock (svm_region_t * rp) +{ +#ifdef MUTEX_DEBUG + rp->mutex_owner_pid = 0; + rp->mutex_owner_tag = 0; +#endif + pthread_mutex_unlock (&rp->mutex); +} + + +static void * +svm_existing_region_map_nolock (void *root_arg, svm_map_region_args_t * a) +{ + svm_region_t *root_rp = root_arg; + svm_main_region_t *mp; + svm_region_t *rp; + void *oldheap; + uword *p; + + a->size += MMAP_PAGESIZE + + (a->pvt_heap_size ? a->pvt_heap_size : SVM_PVT_MHEAP_SIZE); + a->size = rnd_pagesize (a->size); + + region_lock (root_rp, 4); + oldheap = svm_push_pvt_heap (root_rp); + mp = root_rp->data_base; + + ASSERT (mp); + + p = hash_get_mem (mp->name_hash, a->name); + + if (p) + { + rp = svm_map_region_nolock (a); + region_unlock (root_rp); + svm_pop_heap (oldheap); + return rp; + } + return 0; + +} + +static void +trace (char *chroot_path, char *name, int enable_disable) +{ + svm_map_region_args_t *a = 0; + svm_region_t *db_rp; + void *oldheap; + + vec_validate (a, 0); + + svm_region_init_chroot (chroot_path); + + a->name = name; + a->size = 1 << 20; + a->flags = SVM_FLAGS_MHEAP; + + db_rp = svm_region_find_or_create (a); + + ASSERT (db_rp); + + region_lock (db_rp, 20); + + oldheap = svm_push_data_heap (db_rp); + + mheap_trace (db_rp->data_heap, enable_disable); + + svm_pop_heap (oldheap); + region_unlock (db_rp); + + svm_region_unmap ((void *) db_rp); + svm_region_exit (); + vec_free (a); +} + + + +static void +subregion_repair (char *chroot_path) +{ + int i; + svm_main_region_t *mp; + svm_map_region_args_t a; + svm_region_t *root_rp; + svm_region_t *rp; + svm_subregion_t *subp; + u8 *name = 0; + u8 **svm_names = 0; + + svm_region_init_chroot (chroot_path); + root_rp = svm_get_root_rp (); + + pthread_mutex_lock (&root_rp->mutex); + + mp = root_rp->data_base; + + /* + * Snapshoot names, can't hold root rp mutex across + * find_or_create. + */ + /* *INDENT-OFF* */ + pool_foreach (subp, mp->subregions, ({ + name = vec_dup (subp->subregion_name); + vec_add1(svm_names, name); + })); + /* *INDENT-ON* */ + + pthread_mutex_unlock (&root_rp->mutex); + + for (i = 0; i < vec_len (svm_names); i++) + { + memset (&a, 0, sizeof (a)); + a.root_path = chroot_path; + a.name = (char *) svm_names[i]; + fformat (stdout, "Checking %s region...\n", a.name); + rp = svm_existing_region_map_nolock (root_rp, &a); + if (rp) + { + svm_region_unmap (rp); + vec_free (svm_names[i]); + } + } + vec_free (svm_names); +} + +void +repair (char *chroot_path, int crash_root_region) +{ + svm_region_t *root_rp = 0; + svm_map_region_args_t *a = 0; + void *svm_map_region (svm_map_region_args_t * a); + int svm_fd; + u8 *shm_name; + + fformat (stdout, "our pid: %d\n", getpid ()); + + vec_validate (a, 0); + + a->root_path = chroot_path; + a->name = SVM_GLOBAL_REGION_NAME; + a->baseva = SVM_GLOBAL_REGION_BASEVA; + a->size = SVM_GLOBAL_REGION_SIZE; + a->flags = SVM_FLAGS_NODATA; + + shm_name = shm_name_from_svm_map_region_args (a); + + svm_fd = shm_open ((char *) shm_name, O_RDWR, 0777); + + if (svm_fd < 0) + { + perror ("svm_region_map(mmap open)"); + goto out; + } + + vec_free (shm_name); + + root_rp = mmap (0, MMAP_PAGESIZE, + PROT_READ | PROT_WRITE, MAP_SHARED, svm_fd, 0); + + if (root_rp == (svm_region_t *) MAP_FAILED) + { + close (svm_fd); + clib_warning ("mmap"); + goto out; + } + + /* Remap now that the region has been placed */ + clib_warning ("remap to 0x%x", root_rp->virtual_base); + + a->baseva = root_rp->virtual_base; + a->size = root_rp->virtual_size; + munmap (root_rp, MMAP_PAGESIZE); + + root_rp = (void *) mmap ((void *) a->baseva, a->size, + PROT_READ | PROT_WRITE, + MAP_SHARED | MAP_FIXED, svm_fd, 0); + if ((uword) root_rp == (uword) MAP_FAILED) + { + clib_unix_warning ("mmap"); + goto out; + } + + close (svm_fd); + + if ((uword) root_rp != root_rp->virtual_base) + { + clib_warning ("mmap botch"); + goto out; + } + + if (pthread_mutex_trylock (&root_rp->mutex)) + { + clib_warning ("root_rp->mutex LOCKED by pid %d, tag %d, cleared...", + root_rp->mutex_owner_pid, root_rp->mutex_owner_tag); + memset (&root_rp->mutex, 0, sizeof (root_rp->mutex)); + goto out; + } + else + { + clib_warning ("root_rp->mutex OK...\n"); + pthread_mutex_unlock (&root_rp->mutex); + } + +out: + vec_free (a); + /* + * Now that the root region is known to be OK, + * fix broken subregions + */ + subregion_repair (chroot_path); + + if (crash_root_region) + { + clib_warning ("Leaving root region locked on purpose..."); + pthread_mutex_lock (&root_rp->mutex); + root_rp->mutex_owner_pid = getpid (); + root_rp->mutex_owner_tag = 99; + } + svm_region_exit (); +} + +int +main (int argc, char **argv) +{ + unformat_input_t input; + int parsed = 0; + char *name; + char *chroot_path = 0; + u8 *chroot_u8; + + unformat_init_command_line (&input, argv); + + while (unformat_check_input (&input) != UNFORMAT_END_OF_INPUT) + { + if (unformat (&input, "show-verbose")) + { + show (chroot_path, 1); + parsed++; + } + else if (unformat (&input, "show")) + { + show (chroot_path, 0); + parsed++; + } + else if (unformat (&input, "client-scan")) + { + svm_client_scan (chroot_path); + parsed++; + } + else if (unformat (&input, "repair")) + { + repair (chroot_path, 0 /* fix it */ ); + parsed++; + } + else if (unformat (&input, "crash")) + { + repair (chroot_path, 1 /* crash it */ ); + parsed++; + } + else if (unformat (&input, "trace-on %s", &name)) + { + trace (chroot_path, name, 1); + parsed++; + } + else if (unformat (&input, "trace-off %s", &name)) + { + trace (chroot_path, name, 0); + parsed++; + } + else if (unformat (&input, "chroot %s", &chroot_u8)) + { + chroot_path = (char *) chroot_u8; + } + else + { + break; + } + } + + unformat_free (&input); + + if (!parsed) + { + fformat (stdout, + "%s: show | show-verbose | client-scan | trace-on \n", + argv[0]); + fformat (stdout, " trace-off \n"); + } + exit (0); +} + +/* + * fd.io coding-style-patch-verification: ON + * + * Local Variables: + * eval: (c-set-style "gnu") + * End: + */ diff --git a/src/tests/vnet/README b/src/tests/vnet/README new file mode 100644 index 00000000..10579e50 --- /dev/null +++ b/src/tests/vnet/README @@ -0,0 +1,10 @@ +Unit test infrastructure for vnet + +To run unit tests do the following: + + 1. build vpp with 'vpp_enable_tests = yes' in build-data/platforms/vpp.mk + + 2. go to build-root/build-$tag-$arch/vnet + + 3. run + $ make check diff --git a/src/tests/vnet/lisp-cp/test_cp_serdes.c b/src/tests/vnet/lisp-cp/test_cp_serdes.c new file mode 100644 index 00000000..9d51dc8f --- /dev/null +++ b/src/tests/vnet/lisp-cp/test_cp_serdes.c @@ -0,0 +1,639 @@ +/* + * Copyright (c) 2016 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include +#include +#include +#include + +/* FIXME */ +#include +vpe_api_main_t vpe_api_main; + +#define _assert(e) \ + error = CLIB_ERROR_ASSERT (e); \ + if (error) \ + goto done; + +static void print_chunk(u8 * b, int * offset, int c, char * des) +{ + int i, n = offset[0] + c;; + for (i = offset[0]; i < n; i++) + { + printf("0x%02x, ", b[i]); + } + printf(" // %s\n", des); + *offset += c; +} + +void print_map_request(map_request_hdr_t * h) +{ +#define pchunk(_count, _desc) \ + print_chunk((u8 *)h, &offset, _count, _desc) + + int offset = 0; + + pchunk(4, "data"); + pchunk(8, "Nonce"); + pchunk(2, "Source-EID-AFI"); + pchunk(4, "Source EID Address"); + pchunk(2, "ITR-RLOC-AFI 1"); + pchunk(4, "ITR-RLOC Address 1"); + pchunk(2, "ITR-RLOC-AFI 2"); + pchunk(16, "ITR-RLOC Address 2"); + pchunk(1, "REC: reserved"); + pchunk(1, "REC: EID mask-len"); + pchunk(2, "REC: EID-prefix-AFI"); + pchunk(4, "REC: EID-prefix"); + printf("\n"); +} + +static clib_error_t * test_lisp_msg_push_ecm () +{ + vlib_main_t * vm = vlib_get_main (); + clib_error_t * error = 0; + gid_address_t la, ra; + vlib_buffer_t * b = 0; + u32 buff_len = 900; + int lp = 0x15, rp = 0x14; + + b = clib_mem_alloc (buff_len); + memset((u8 *)b, 0, buff_len); + b->current_length = buff_len; + b->current_data = sizeof(udp_header_t) + sizeof(ip4_header_t) + + sizeof(ecm_hdr_t) + 1; + + la.type = GID_ADDR_IP_PREFIX; + la.ippref.addr.ip.v4.as_u32 = 0xa1b2c3d4; + la.ippref.addr.version = IP4; + + ra.type = GID_ADDR_IP_PREFIX; + ra.ippref.addr.ip.v4.as_u32 = 0x90817263; + ra.ippref.addr.version = IP4; + + ecm_hdr_t * lh = lisp_msg_push_ecm (vm, b, lp, rp, &la, &ra); + + u8 expected_ecm_hdr[] = { + 0x80, 0x00, 0x00, 0x00 + }; + _assert(0 == memcmp(expected_ecm_hdr, lh, sizeof(expected_ecm_hdr))); + + ip4_header_t * ih = (ip4_header_t *) (lh + 1); + /* clear ip checksum */ + memset((u8 *)ih + 10, 0, 2); + + u8 expected_ip4_hdr[] = { + 0x45, /* version; IHL */ + 0x00, /* services */ + 0x03, 0xa0, /* total length */ + 0x00, 0x00, /* identification */ + 0x40, 0x00, /* flags; fragment offset*/ + 0xff, /* TTL */ + 0x11, /* protocol */ + 0x00, 0x00, /* header checksum */ + 0xd4, 0xc3, 0xb2, 0xa1, /* src IP */ + 0x63, 0x72, 0x81, 0x90, /* dst IP */ + }; + _assert(0 == memcmp(ih, expected_ip4_hdr, sizeof(expected_ip4_hdr))); + + udp_header_t * uh = (udp_header_t *) (ih + 1); + /* clear udp checksum */ + memset((u8 *)uh + 6, 0, 2); + + u8 expected_udp_hdr[] = { + 0x00, 0x15, /* src port */ + 0x00, 0x14, /* dst port */ + 0x03, 0x8c, /* length */ + 0x00, 0x00, /* checksum */ + }; + _assert(0 == memcmp(uh, expected_udp_hdr, sizeof(expected_udp_hdr))); + +done: + clib_mem_free (b); + return error; +} + +static clib_error_t * test_lisp_msg_parse_mapping_record () +{ + clib_error_t * error = 0; + locator_t probed; + locator_t * locs = 0; + vlib_buffer_t * b = 0; + gid_address_t eid; + u32 buff_len = 500; + + b = clib_mem_alloc (buff_len); + memset((u8 *)b, 0, buff_len); + + u8 map_reply_records[] = { + /* 1. record */ + 0x01, 0x02, 0x03, 0x04, /* record TTL */ + 0x01, /* locator count */ + 0x00, 0x00, 0x00, /* eid-mask-len; ... */ + 0x00, 0x00, /* reserved; map-version num */ + 0x00, 0x01, /* EID-Prefix-AFI */ + 0x33, 0x44, 0x55, 0x66, /* eid-prefix */ + /* loc */ + 0x0a, /* prority */ + 0x0b, /* weight */ + 0x0c, /* m-prority */ + 0x0d, /* m-weight */ + 0x00, 0x00, /* unused flags */ + 0x00, 0x01, /* Loc-AFI */ + 0xaa, 0xbb, 0xcc, 0xdd, /* Loator */ + }; + b->current_length = buff_len; + clib_memcpy(b->data, map_reply_records, sizeof(map_reply_records)); + + lisp_msg_parse_mapping_record (b, &eid, &locs, &probed); + _assert(vec_len (locs) == 1); + _assert(eid.ippref.addr.ip.v4.as_u32 == 0x66554433); + _assert(locs[0].local == 0); + _assert(locs[0].address.ippref.addr.ip.v4.as_u32 == 0xddccbbaa); + _assert(locs[0].address.type == GID_ADDR_IP_PREFIX); + _assert(locs[0].priority == 0xa); + _assert(locs[0].weight == 0xb); + _assert(locs[0].mpriority == 0xc); + _assert(locs[0].mweight == 0xd); + +done: + clib_mem_free (b); + if (locs) + vec_free (locs); + return error; +} + +static map_request_hdr_t * +build_map_request (lisp_cp_main_t * lcm, vlib_buffer_t * b, + gid_address_t * rlocs) +{ + gid_address_t _seid, * seid = &_seid; + gid_address_t _deid, * deid = &_deid; + u8 is_smr_invoked = 1; + u8 rloc_probe_set = 0; + u64 nonce = 0; + map_request_hdr_t * h = 0; + memset (deid, 0, sizeof (deid[0])); + memset (seid, 0, sizeof (seid[0])); + + gid_address_type (seid) = GID_ADDR_IP_PREFIX; + ip_address_t * ip_addr = &gid_address_ip (seid); + ip_addr_v4 (ip_addr).as_u32 = 0x12345678; + seid->ippref.addr.version = IP4; + + gid_address_type (deid) = GID_ADDR_IP_PREFIX; + ip_address_t * ip_addr2 = &gid_address_ip (deid); + ip_addr_v4 (ip_addr2).as_u32 = 0x9abcdef0; + deid->ippref.addr.version = IP4; + gid_address_ippref_len (deid) = 24; + + h = lisp_msg_put_mreq (lcm, b, seid, deid, rlocs, + is_smr_invoked, rloc_probe_set, &nonce); + vec_free(rlocs); + return h; +} + +static void +generate_rlocs (gid_address_t **rlocs, u32 * count) +{ + gid_address_t gid_addr_data, * gid_addr = &gid_addr_data; + memset (gid_addr, 0, sizeof (gid_addr[0])); + ip_address_t * addr = &gid_address_ip (gid_addr); + + gid_address_type (gid_addr) = GID_ADDR_IP_PREFIX; + + ip_addr_version (addr) = IP4; + ip_addr_v4 (addr).data_u32 = 0x10203040; + vec_add1 (rlocs[0], gid_addr[0]); + + ip_addr_v6 (addr).as_u32[0] = 0xffeeddcc; + ip_addr_v6 (addr).as_u32[1] = 0xbbaa9988; + ip_addr_v6 (addr).as_u32[2] = 0x77665544; + ip_addr_v6 (addr).as_u32[3] = 0x33221100; + ip_addr_version (addr) = IP6; + vec_add1 (rlocs[0], gid_addr[0]); +} + +static clib_error_t * test_lisp_msg_parse () +{ + gid_address_t eid; + lisp_cp_main_t * lcm = vnet_lisp_cp_get_main(); + map_request_hdr_t *h; + gid_address_t gid; + clib_error_t * error = 0; + vlib_buffer_t * b; + gid_address_t * rlocs_decode = 0, * rlocs = 0; + u32 rloc_count_parse = 0; + + u8 * data = clib_mem_alloc(500); + memset(data, 0, 500); + b = (vlib_buffer_t *) data; + + generate_rlocs (&rlocs_decode, &rloc_count_parse); + h = build_map_request (lcm, b, rlocs_decode); + + vlib_buffer_pull(b, sizeof(*h)); + u32 len = lisp_msg_parse_addr(b, &gid); + _assert (len == 2 + 4 + /* Source-EID-AFI field lenght + IPv4 address length */); + _assert (gid.ippref.addr.ip.v4.as_u32 == 0x12345678); + _assert (gid.ippref.addr.version == IP4); + + u8 rloc_count = MREQ_ITR_RLOC_COUNT(h) + 1; + lisp_msg_parse_itr_rlocs (b, &rlocs, rloc_count); + + _assert (vec_len (rlocs) == 2); + _assert (rlocs[0].ippref.addr.ip.v4.as_u32 == 0x10203040); + _assert (rlocs[0].ippref.addr.version == IP4); + + _assert (rlocs[1].ippref.addr.ip.v6.as_u32[0] == 0xffeeddcc); + _assert (rlocs[1].ippref.addr.ip.v6.as_u32[1] == 0xbbaa9988); + _assert (rlocs[1].ippref.addr.ip.v6.as_u32[2] == 0x77665544); + _assert (rlocs[1].ippref.addr.ip.v6.as_u32[3] == 0x33221100); + _assert (rlocs[1].ippref.addr.version == IP6); + + lisp_msg_parse_eid_rec (b, &eid); + _assert (eid.ippref.addr.ip.v4.as_u32 == 0x9abcdef0); + _assert (eid.ippref.addr.version == IP4); + _assert (eid.ippref.len == 24); + +done: + clib_mem_free (data); + if (rlocs) + vec_free (rlocs); + return error; +} + +static clib_error_t * test_lisp_msg_put_mreq_with_lcaf () +{ + lisp_cp_main_t * lcm = vnet_lisp_cp_get_main (); + clib_error_t * error = 0; + map_request_hdr_t *h = 0; + gid_address_t * rlocs = 0; + + ip_prefix_t ippref; + ip_prefix_version (&ippref) = IP4; + ip4_address_t * ip = &ip_prefix_v4 (&ippref); + ip->as_u32 = 0x11223344; + + gid_address_t g = + { + .type = GID_ADDR_IP_PREFIX, + .ippref = ippref, + .vni = 0x90919293, + .vni_mask = 0x17 + }; + vec_add1 (rlocs, g); + + u8 * data = clib_mem_alloc (500); + memset (data, 0, 500); + + h = build_map_request (lcm, (vlib_buffer_t *) data, rlocs); + + /* clear Nonce to simplify comparison */ + memset ((u8 *)h + 4, 0, 8); + + u8 expected_data[] = + { + 0x10, 0x40, 0x00, 0x01, /* type; flags; IRC; REC count */ + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, /* nonce */ + 0x00, 0x01, /* Source-EID-AFI */ + 0x78, 0x56, 0x34, 0x12, /* Source EID Address */ + + /* RLOCs */ + 0x40, 0x03, /* AFI = LCAF*/ + /* LCAF header*/ + 0x00, 0x00, /* reserved1, flags */ + 0x02, /* type = Instance ID */ + 0x17, /* IID mask-len */ + 0x00, 0x0a, /* lenght */ + 0x90, 0x91, 0x92, 0x93, /* IID / VNI */ + + 0x00, 0x01, /* AFI = ipv4 */ + 0x44, 0x33, 0x22, 0x11, /* ITR-RLOC Address 1 */ + + /* record */ + 0x00, /* reserved */ + 0x18, /* EID mask-len */ + 0x00, 0x01, /* EID-prefix-AFI */ + 0xf0, 0xde, 0xbc, 0x9a, /* EID-prefix */ + }; + + _assert (0 == memcmp (expected_data, (u8 *) h, sizeof (expected_data))); +done: + clib_mem_free (data); + return error; +} + +static clib_error_t * test_lisp_msg_put_mreq () +{ + lisp_cp_main_t * lcm = vnet_lisp_cp_get_main(); + clib_error_t * error = 0; + map_request_hdr_t *h; + gid_address_t * rlocs = 0; + u32 rloc_count = 0; + + u8 * data = clib_mem_alloc(500); + memset(data, 0, 500); + + generate_rlocs (&rlocs, &rloc_count); + h = build_map_request (lcm, (vlib_buffer_t *) data, rlocs); + + /* clear Nonce to simplify comparison */ + memset((u8 *)h + 4, 0, 8); + + print_map_request(h); + + u8 expected_data[50] = { + 0x10, 0x40, 0x01, 0x01, /* type; flags; IRC; REC count */ + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, /* nonce */ + 0x00, 0x01, /* Source-EID-AFI */ + 0x78, 0x56, 0x34, 0x12, /* Source EID Address */ + + /* RLOCs */ + 0x00, 0x01, /* ITR-RLOC-AFI 1 */ + 0x40, 0x30, 0x20, 0x10, /* ITR-RLOC Address 1 */ + 0x00, 0x02, /* ITR-RLOC-AFI 2 */ + 0xcc, 0xdd, 0xee, 0xff, + 0x88, 0x99, 0xaa, 0xbb, + 0x44, 0x55, 0x66, 0x77, + 0x00, 0x11, 0x22, 0x33, /* ITR-RLOC Address 2 */ + + /* record */ + 0x00, /* reserved */ + 0x18, /* EID mask-len */ + 0x00, 0x01, /* EID-prefix-AFI */ + 0xf0, 0xde, 0xbc, 0x9a, /* EID-prefix */ + }; + _assert (0 == memcmp (expected_data, (u8 *) h, sizeof (expected_data))); + +done: + clib_mem_free (data); + return error; +} + +/* generate a vector of eid records */ +static mapping_t * +build_test_map_records () +{ + mapping_t * records = 0; + + mapping_t r = { + .ttl = 0x44332211, + .eid = { + .type = GID_ADDR_MAC, + .mac = {1, 2, 3, 4, 5, 6}, + .vni = 0x0 + } + }; + + locator_t loc = { + .weight = 1, + .priority = 2, + .local = 1, + .address = { + .type = GID_ADDR_IP_PREFIX, + .ippref = { + .addr = { + .ip.v4.as_u32 = 0x99887766, + .version = IP4 + } + } + } + }; + vec_add1 (r.locators, loc); + vec_add1 (records, r); + + return records; +} + +static void +free_test_map_records (mapping_t * maps) +{ + mapping_t * map; + vec_foreach (map, maps) + { + vec_free (map->locators); + } + vec_free (maps); +} + +static clib_error_t * +test_lisp_map_register () +{ + vlib_buffer_t *b; + clib_error_t * error = 0; + u64 nonce; + u32 msg_len = 0; + mapping_t * records = build_test_map_records (); + + u8 * data = clib_mem_alloc(500); + memset(data, 0, 500); + b = (vlib_buffer_t *) data; + + lisp_msg_put_map_register (b, records, 1 /* want map notify */, + 20 /* length of HMAC_SHA_1_96 */, + &nonce, &msg_len); + free_test_map_records (records); + + /* clear Nonce to simplify comparison */ + memset((u8 *)b->data + 4, 0, 8); + + /* clear authentication data */ + memset ((u8 *)b->data + 16, 0, 20); + + u8 expected_data[] = { + 0x30, 0x00, 0x01, 0x01, /* type; rsvd; want notify; REC count */ + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, /* nonce */ + 0x00, 0x00, 0x00, 0x00, /* key id, auth data length: + both are zeroes because those are set in another + function (see auth_data_len_by_key_id())*/ + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, /* auth data */ + + /* first record */ + 0x44, 0x33, 0x22, 0x11, /* ttl */ + 0x01, 0x00, 0x00, 0x00, /* loc count, eid len, ACT, A */ + 0x00, 0x00, 0x40, 0x05, /* rsvd, map ver num, AFI = MAC */ + 0x01, 0x02, 0x03, 0x04, + 0x05, 0x06, /* MAC EID */ + + /* locator 1 */ + 0x02, 0x01, 0x00, 0x00, /* prio, weight, mprio, mweight */ + 0x00, 0x04, 0x00, 0x01, /* flags, AFI = ipv4 */ + 0x66, 0x77, 0x88, 0x99, /* ipv4 locator address */ + }; + _assert (0 == memcmp (expected_data, b->data, sizeof (expected_data))); +done: + clib_mem_free (data); + return error; +} + +static clib_error_t * +test_lisp_parse_lcaf () +{ + int i; + clib_error_t * error = 0; + gid_address_t eid; + locator_t * locs = 0; + locator_t probed; + vlib_buffer_t * b = 0; + u32 buff_len = 500; + + b = clib_mem_alloc (buff_len); + memset ((u8 *)b, 0, buff_len); + + u8 map_reply_records[] = + { + /* 1. record */ + 0x01, 0x02, 0x03, 0x04, /* record TTL */ + 0x03, /* locator count */ + 0x00, 0x00, 0x00, /* eid-mask-len; ... */ + 0x00, 0x00, /* reserved; map-version num */ + 0x00, 0x01, /* EID-Prefix-AFI */ + 0x33, 0x44, 0x55, 0x66, /* eid-prefix */ + + /* 1st locator */ + 0x0a, /* prority */ + 0x0b, /* weight */ + 0x0c, /* m-prority */ + 0x0d, /* m-weight */ + 0x00, 0x00, /* unused flags */ + 0x40, 0x03, /* Loc-AFI = LCAF*/ + + /* LCAF header*/ + 0x00, 0x00, /* reserved1, flags */ + 0x02, /* type = Instance ID */ + 0x18, /* IID mask-len */ + 0x00, 0x0a, /* lenght */ + /* LCAF Instance ID */ + 0x00, 0x00, 0x00, 0x09, /* iid */ + 0x00, 0x01, /* AFI = ipv4 */ + 0x10, 0xbb, 0xcc, 0xdd, /* ipv4 loator address */ + + /* 2nd locator */ + 0x07, /* prority */ + 0x06, /* weight */ + 0x05, /* m-prority */ + 0x04, /* m-weight */ + 0x00, 0x00, /* unused flags */ + 0x40, 0x03, /* Loc-AFI = LCAF*/ + + /* LCAF header*/ + 0x00, 0x00, /* reserved1, flags */ + 0x02, /* type = Instance ID */ + 0x18, /* IID mask-len */ + 0x00, 0x16, /* iid length + next AFI lenght */ + /* LCAF Instance ID */ + 0x22, 0x44, 0x66, 0x88, /* iid */ + 0x00, 0x02, /* AFI = ipv6 */ + 0xcc, 0xdd, 0xee, 0xff, + 0x88, 0x99, 0xaa, 0xbb, + 0x44, 0x55, 0x66, 0x77, + 0x00, 0x11, 0x22, 0x33, /* ipv6 locator address */ + + /* 3rd locator */ + 0x0a, /* prority */ + 0x0b, /* weight */ + 0x0c, /* m-prority */ + 0x0d, /* m-weight */ + 0x00, 0x00, /* unused flags */ + 0x00, 0x01, /* Loc-AFI */ + 0xaa, 0xbb, 0xcc, 0xdd, /* Loator */ + }; + + b->current_length = buff_len; + memcpy (b->data, map_reply_records, sizeof (map_reply_records)); + + lisp_msg_parse_mapping_record (b, &eid, &locs, &probed); + _assert (vec_len (locs) == 3); + _assert (eid.ippref.addr.ip.v4.as_u32 == 0x66554433); + + /* check 1st locator - an LCAF with ipv4 */ + _assert (locs[0].local == 0); + _assert (locs[0].priority == 0xa); + _assert (locs[0].weight == 0xb); + _assert (locs[0].mpriority == 0xc); + _assert (locs[0].mweight == 0xd); + + _assert (gid_address_type (&locs[0].address) == GID_ADDR_IP_PREFIX); + _assert (gid_address_vni (&locs[0].address) == 0x09); + ip_prefix_t * ip_pref = &gid_address_ippref (&locs[0].address); + _assert (IP4 == ip_prefix_version (ip_pref)); + + /* 2nd locator - LCAF entry with ipv6 address */ + _assert (locs[1].local == 0); + _assert (locs[1].priority == 0x7); + _assert (locs[1].weight == 0x6); + _assert (locs[1].mpriority == 0x5); + _assert (locs[1].mweight == 0x4); + + _assert (gid_address_type (&locs[1].address) == GID_ADDR_IP_PREFIX); + _assert (0x22446688 == gid_address_vni (&locs[1].address)); + ip_pref = &gid_address_ippref (&locs[1].address); + _assert (IP6 == ip_prefix_version (ip_pref)); + + /* 3rd locator - simple ipv4 address */ + _assert (gid_address_type (&locs[2].address) == GID_ADDR_IP_PREFIX); +done: + clib_mem_free (b); + + for (i = 0; i < 3; i++) + locator_free (&locs[i]); + vec_free (locs); + return error; +} + +#define foreach_test_case \ + _(lisp_msg_put_mreq) \ + _(lisp_msg_put_mreq_with_lcaf) \ + _(lisp_msg_push_ecm) \ + _(lisp_msg_parse) \ + _(lisp_msg_parse_mapping_record) \ + _(lisp_parse_lcaf) \ + _(lisp_map_register) + +int run_tests (void) +{ + clib_error_t * error; + +#define _(_test_name) \ + error = test_ ## _test_name (); \ + if (error) \ + { \ + clib_error_report (error); \ + return 0; \ + } + + foreach_test_case +#undef _ + + return 0; +} + +int main() +{ + return run_tests (); +} +#undef _assert diff --git a/src/tests/vnet/lisp-cp/test_lisp_types.c b/src/tests/vnet/lisp-cp/test_lisp_types.c new file mode 100644 index 00000000..5d910f66 --- /dev/null +++ b/src/tests/vnet/lisp-cp/test_lisp_types.c @@ -0,0 +1,565 @@ +/* + * Copyright (c) 2016 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include + +/* FIXME */ +#include +vpe_api_main_t vpe_api_main; + +#define _assert(e) \ + error = CLIB_ERROR_ASSERT (e); \ + if (error) \ + goto done; + +static clib_error_t * test_locator_type (void) +{ + clib_error_t * error = 0; + gid_address_t _gid_addr, * gid = &_gid_addr; + ip_prefix_t * ippref; + gid_address_type (gid) = GID_ADDR_IP_PREFIX; + gid_address_ippref_len (gid) = 24; + ippref = &gid_address_ippref (gid); + ip_prefix_version (ippref) = IP4; + ip_prefix_len (ippref) = 0; + ip4_address_t * ip4 = &ip_prefix_v4 (ippref); + ip4->as_u32 = 0x20304050; + + /* local locator */ + locator_t loc1, loc2 = { + .local = 1, + .state = 2, + .sw_if_index = 8, + .priority = 3, + .weight = 100, + .mpriority = 4, + .mweight = 101 + }; + locator_copy (&loc1, &loc2); + _assert (0 == locator_cmp (&loc1, &loc2)); + + /* remote locator */ + loc2.local = 0; + + ip_prefix_t nested_ippref; + ip_prefix_version (&nested_ippref) = IP4; + ip_prefix_len (&nested_ippref) = 0; + ip4 = &ip_prefix_v4 (&nested_ippref); + ip4->as_u32 = 0x33882299; + gid_address_t nested_gid = + { + .type = GID_ADDR_IP_PREFIX, + .ippref = nested_ippref + }; + + lcaf_t lcaf = + { + .type = LCAF_INSTANCE_ID, + .uni = + { + .vni_mask_len = 5, + .vni = 0xa1b2c3d4, + .gid_addr = &nested_gid + } + }; + gid_address_type (gid) = GID_ADDR_LCAF; + gid_address_lcaf (gid) = lcaf; + + loc2.address = gid[0]; + locator_copy(&loc1, &loc2); + + _assert (0 == locator_cmp (&loc1, &loc2)); + +done: + locator_free (&loc1); + return error; +} + +static clib_error_t * test_gid_parse_ip_pref () +{ + clib_error_t * error = 0; + gid_address_t _gid_addr, * gid_addr = &_gid_addr; + gid_address_t _gid_addr_copy, * gid_addr_copy = &_gid_addr_copy; + u8 data[] = + { + 0x00, 0x01, /* AFI = IPv4 */ + 0x10, 0xbb, 0xcc, 0xdd, /* ipv4 address */ + }; + + u32 len = gid_address_parse (data, gid_addr); + _assert (6 == len); + gid_address_copy (gid_addr_copy, gid_addr); + _assert (0 == gid_address_cmp (gid_addr_copy, gid_addr)); +done: + return error; +} + +static clib_error_t * test_gid_parse_mac () +{ + clib_error_t * error = 0; + gid_address_t _gid, * gid = &_gid; + gid_address_t _gid_copy, * gid_copy = &_gid_copy; + + u8 data[] = + { + 0x40, 0x05, /* AFI = MAC address */ + 0x10, 0xbb, 0xcc, 0xdd, /* MAC */ + 0x77, 0x99, + }; + + u32 len = gid_address_parse (data, gid); + _assert (8 == len); + _assert (GID_ADDR_MAC == gid_address_type (gid)); + gid_address_copy (gid_copy, gid); + _assert (0 == gid_address_cmp (gid_copy, gid)); +done: + return error; +} + +static clib_error_t * test_gid_parse_lcaf () +{ + clib_error_t * error = 0; + gid_address_t _gid_addr, * gid_addr = &_gid_addr; + gid_address_t _gid_addr_copy, * gid_addr_copy = &_gid_addr_copy; + + memset (gid_addr, 0, sizeof (gid_addr[0])); + memset (gid_addr_copy, 0, sizeof (gid_addr_copy[0])); + + u8 data[] = + { + 0x40, 0x03, /* AFI = LCAF*/ + + /* LCAF header*/ + 0x00, 0x00, /* reserved1, flags */ + 0x02, /* type = Instance ID */ + 0x18, /* IID mask-len */ + 0x00, 0x0a, /* iid length + next AFI lenght */ + /* LCAF Instance ID */ + 0x00, 0x00, 0x00, 0x09, /* iid */ + 0x00, 0x01, /* AFI = ipv4 */ + 0x10, 0xbb, 0xcc, 0xdd, /* ipv4 address */ + }; + u32 len = gid_address_parse (data, gid_addr); + _assert (18 == len); + gid_address_copy (gid_addr_copy, gid_addr); + _assert (0 == gid_address_cmp (gid_addr_copy, gid_addr)); + _assert (GID_ADDR_IP_PREFIX == gid_address_type (gid_addr)); + _assert (9 == gid_address_vni (gid_addr)); + _assert (0x18 == gid_address_vni_mask (gid_addr)); + _assert (0xddccbb10 == gid_addr->ippref.addr.ip.v4.as_u32); + +done: + gid_address_free (gid_addr); + gid_address_free (gid_addr_copy); + return error; +} + +/* recursive LCAFs are not supported */ +#if 0 +static clib_error_t * test_gid_parse_lcaf_complex () +{ + clib_error_t * error = 0; + gid_address_t _gid_addr, * gid_addr = &_gid_addr; + gid_address_t _gid_addr_copy, * gid_addr_copy = &_gid_addr_copy; + + memset (gid_addr, 0, sizeof (gid_addr[0])); + memset (gid_addr_copy, 0, sizeof (gid_addr_copy[0])); + + u8 data[] = + { + 0x40, 0x03, /* AFI = LCAF*/ + + /* LCAF header*/ + 0x00, 0x00, /* reserved1, flags */ + 0x02, /* type = Instance ID */ + 0x18, /* IID mask-len */ + 0x00, 0x0a, /* iid length + next AFI lenght */ + /* LCAF Instance ID */ + 0x00, 0x00, 0x00, 0x0b, /* iid */ + + 0x40, 0x03, /* AFI = LCAF*/ + /* LCAF header*/ + 0x00, 0x00, /* reserved1, flags */ + 0x02, /* type = Instance ID */ + 0x17, /* IID mask-len */ + 0x00, 0x0a, /* iid length + next AFI lenght */ + /* LCAF Instance ID */ + 0x00, 0x00, 0x00, 0x0c, /* iid */ + + 0x40, 0x03, /* AFI = LCAF*/ + /* LCAF header*/ + 0x00, 0x00, /* reserved1, flags */ + 0x02, /* type = Instance ID */ + 0x16, /* IID mask-len */ + 0x00, 0x16, /* iid length + next AFI lenght */ + /* LCAF Instance ID */ + 0x00, 0x00, 0x00, 0x0d, /* iid */ + + 0x00, 0x02, /* AFI = IPv6 */ + + 0x10, 0xbb, 0xcc, 0xdd, + 0x10, 0xbb, 0xcc, 0xdd, + 0x10, 0xbb, 0xcc, 0xdd, + 0x10, 0xbb, 0xcc, 0xdd, /* ipv6 address */ + }; + u32 len = gid_address_parse (data, gid_addr); + _assert (54 == len); + _assert (gid_addr->type == GID_ADDR_LCAF); + gid_address_copy (gid_addr_copy, gid_addr); + _assert (0 == gid_address_cmp (gid_addr_copy, gid_addr)); + _assert (gid_addr_copy->type == GID_ADDR_LCAF); + + lcaf_t * lcaf = &gid_address_lcaf (gid_addr_copy); + _assert (lcaf->type == LCAF_INSTANCE_ID); + vni_t * v = (vni_t *) lcaf; + _assert (v->vni == 0x0b); + _assert (v->vni_mask_len == 0x18); + + gid_address_t * tmp = vni_gid (v); + _assert (gid_address_type (tmp) == GID_ADDR_LCAF); + lcaf = &gid_address_lcaf (tmp); + _assert (lcaf->type == LCAF_INSTANCE_ID); + + v = (vni_t *) lcaf; + _assert (v->vni == 0x0c); + _assert (v->vni_mask_len == 0x17); + + tmp = vni_gid (v); + _assert (gid_address_type (tmp) == GID_ADDR_LCAF); + lcaf = &gid_address_lcaf (tmp); + + _assert (lcaf->type == LCAF_INSTANCE_ID); + v = (vni_t *) lcaf; + _assert (v->vni == 0x0d); + _assert (v->vni_mask_len == 0x16); + + tmp = vni_gid (v); + _assert (gid_address_type (tmp) == GID_ADDR_IP_PREFIX); + + ip_prefix_t * ip_pref = &gid_address_ippref (tmp); + ip6_address_t * ip6 = &ip_prefix_v6 (ip_pref); + _assert (ip6->as_u32[0] == 0xddccbb10); + _assert (ip6->as_u32[1] == 0xddccbb10); + _assert (ip6->as_u32[2] == 0xddccbb10); + _assert (ip6->as_u32[3] == 0xddccbb10); + _assert (ip_prefix_version (ip_pref) == IP6); + +done: + gid_address_free (gid_addr); + gid_address_free (gid_addr_copy); + return error; +} +#endif + +#if 0 /* uncomment this once VNI is supported */ +static clib_error_t * test_write_mac_in_lcaf (void) +{ + clib_error_t * error = 0; + + u8 * b = clib_mem_alloc(500); + memset(b, 0, 500); + + gid_address_t g = + { + .mac = {0x1, 0x2, 0x3, 0x4, 0x5, 0x6}, + .vni = 0x30, + .vni_mask = 0x10, + .type = GID_ADDR_MAC, + }; + + u16 len = gid_address_put (b, &g); + _assert (8 == len); + + u8 expected[] = + { + 0x40, 0x03, /* AFI = LCAF */ + 0x00, /* reserved1 */ + 0x00, /* flags */ + 0x02, /* LCAF type = Instance ID */ + 0x20, /* IID/VNI mask len */ + 0x00, 0x0a, /* length */ + 0x01, 0x02, 0x03, 0x04, /* Instance ID / VNI */ + + 0x00, 0x06, /* AFI = MAC */ + 0x01, 0x02, 0x03, 0x04, + 0x05, 0x06 /* MAC */ + } + _assert (0 == memcmp (expected, b, len)); +done: + clib_mem_free (b); + return error; +} +#endif + +static clib_error_t * test_mac_address_write (void) +{ + clib_error_t * error = 0; + + u8 * b = clib_mem_alloc(500); + memset(b, 0, 500); + + gid_address_t g = + { + .mac = {0x1, 0x2, 0x3, 0x4, 0x5, 0x6}, + .type = GID_ADDR_MAC, + }; + + u16 len = gid_address_put (b, &g); + _assert (8 == len); + + u8 expected[] = + { + 0x40, 0x05, /* AFI = MAC */ + 0x01, 0x02, 0x03, 0x04, + 0x05, 0x06 /* MAC */ + }; + _assert (0 == memcmp (expected, b, len)); +done: + clib_mem_free (b); + return error; +} + +static clib_error_t * +test_src_dst_with_vni_serdes (void) +{ + clib_error_t * error = 0; + u8 * b = clib_mem_alloc (500); + memset (b, 0, 500); + + fid_address_t src = + { + .type = FID_ADDR_IP_PREF, + .ippref = + { + .len = 24, + .addr = + { + .version = IP4, + .ip.v4.data = { 0x1, 0x2, 0x3, 0x0 } + } + } + }; + + fid_address_t dst = + { + .type = FID_ADDR_IP_PREF, + .ippref = + { + .len = 16, + .addr = + { + .version = IP4, + .ip.v4.data = { 0x9, 0x8, 0x0, 0x0 } + } + } + }; + + source_dest_t sd = + { + .src = src, + .dst = dst + }; + + gid_address_t g = + { + .sd = sd, + .type = GID_ADDR_SRC_DST, + .vni = 0x12345678, + .vni_mask = 0x9 + }; + + u16 size_to_put = gid_address_size_to_put(&g); + _assert (36 == size_to_put); + _assert (0 == gid_address_len(&g)); + + u16 write_len = gid_address_put (b, &g); + printf("sizetoput %d; writelen %d\n", size_to_put, write_len); + _assert (size_to_put == write_len); + + u8 expected_data[] = + { + 0x40, 0x03, 0x00, 0x00, /* AFI = LCAF, reserved1, flags */ + 0x02, 0x09, 0x00, 0x1c, /* LCAF type = IID, IID mask-len, length */ + 0x12, 0x34, 0x56, 0x78, /* reserved; source-ML, Dest-ML */ + + 0x40, 0x03, 0x00, 0x00, /* AFI = LCAF, reserved1, flags */ + 0x0c, 0x00, 0x00, 0x10, /* LCAF type = source/dest key, rsvd, length */ + 0x00, 0x00, 0x18, 0x10, /* reserved; source-ML, Dest-ML */ + + 0x00, 0x01, /* AFI = ip4 */ + 0x01, 0x02, 0x03, 0x00, /* source */ + + 0x00, 0x01, /* AFI = ip4 */ + 0x09, 0x08, 0x00, 0x00, /* destination */ + }; + _assert (0 == memcmp (expected_data, b, sizeof (expected_data))); + + gid_address_t p; + memset (&p, 0, sizeof (p)); + _assert (write_len == gid_address_parse (b, &p)); + _assert (0 == gid_address_cmp (&g, &p)); +done: + clib_mem_free (b); + return error; +} + +static clib_error_t * +test_src_dst_serdes (void) +{ + clib_error_t * error = 0; + + u8 * b = clib_mem_alloc (500); + memset (b, 0, 500); + + fid_address_t src = + { + .type = FID_ADDR_MAC, + .mac = { 0x11, 0x22, 0x33, 0x44, 0x55, 0x66 } + }; + + fid_address_t dst = + { + .type = FID_ADDR_MAC, + .mac = { 0x10, 0x21, 0x32, 0x43, 0x54, 0x65 } + }; + + source_dest_t sd = + { + .src = src, + .dst = dst + }; + + gid_address_t g = + { + .sd = sd, + .type = GID_ADDR_SRC_DST, + .vni = 0x0, + .vni_mask = 0x0 + }; + + u16 size_to_put = gid_address_size_to_put(&g); + _assert (28 == size_to_put); + _assert (0 == gid_address_len(&g)); + + u16 write_len = gid_address_put (b, &g); + _assert (size_to_put == write_len); + + u8 expected_data[] = + { + 0x40, 0x03, 0x00, 0x00, /* AFI = LCAF, reserved1, flags */ + 0x0c, 0x00, 0x00, 0x14, /* LCAF type = source/dest key, rsvd, length */ + 0x00, 0x00, 0x00, 0x00, /* reserved; source-ML, Dest-ML */ + + 0x40, 0x05, /* AFI = MAC */ + 0x11, 0x22, 0x33, 0x44, + 0x55, 0x66, /* source */ + + 0x40, 0x05, /* AFI = MAC */ + 0x10, 0x21, 0x32, 0x43, + 0x54, 0x65, /* destination */ + }; + _assert (0 == memcmp (expected_data, b, sizeof (expected_data))); + + gid_address_t p; + memset (&p, 0, sizeof (p)); + _assert (write_len == gid_address_parse (b, &p)); + _assert (0 == gid_address_cmp (&g, &p)); +done: + clib_mem_free (b); + return error; +} + +static clib_error_t * test_gid_address_write (void) +{ + clib_error_t * error = 0; + ip_prefix_t ippref_data, * ippref = &ippref_data; + + u8 * b = clib_mem_alloc(500); + memset(b, 0, 500); + + ip_prefix_version (ippref) = IP4; + ip_prefix_len (ippref) = 9; + ip4_address_t * ip4 = &ip_prefix_v4 (ippref); + ip4->as_u32 = 0xaabbccdd; + + gid_address_t g = + { + .ippref = ippref[0], + .type = GID_ADDR_IP_PREFIX, + .vni = 0x01020304, + .vni_mask = 0x18 + }; + + _assert (18 == gid_address_size_to_put (&g)); + _assert (gid_address_len (&g) == 9); + + u16 write_len = gid_address_put (b, &g); + _assert (18 == write_len); + + u8 expected_gid_data[] = + { + 0x40, 0x03, /* AFI = LCAF */ + 0x00, /* reserved1 */ + 0x00, /* flags */ + 0x02, /* LCAF type = Instance ID */ + 0x18, /* IID/VNI mask len */ + 0x00, 0x0a, /* length */ + 0x01, 0x02, 0x03, 0x04, /* Instance ID / VNI */ + + 0x00, 0x01, /* AFI = IPv4 */ + 0xdd, 0xcc, 0xbb, 0xaa, /* ipv4 addr */ + }; + _assert (0 == memcmp (expected_gid_data, b, sizeof (expected_gid_data))); +done: + clib_mem_free (b); + return error; +} + +#define foreach_test_case \ + _(locator_type) \ + _(gid_parse_ip_pref) \ + _(gid_parse_mac) \ + _(gid_parse_lcaf) \ + _(mac_address_write) \ + _(gid_address_write) \ + _(src_dst_serdes) \ + _(src_dst_with_vni_serdes) + +int run_tests (void) +{ + clib_error_t * error; + +#define _(_test_name) \ + error = test_ ## _test_name (); \ + if (error) \ + { \ + clib_error_report (error); \ + return 0; \ + } + + foreach_test_case +#undef _ + + return 0; +} + +int main() +{ + return run_tests (); +} + diff --git a/src/tests/vnet/lisp-gpe/test.c b/src/tests/vnet/lisp-gpe/test.c new file mode 100644 index 00000000..dde633ae --- /dev/null +++ b/src/tests/vnet/lisp-gpe/test.c @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2016 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +int main(int argc, char **argv) { + return 0; +} diff --git a/src/tools/elftool/dir.dox b/src/tools/elftool/dir.dox new file mode 100644 index 00000000..40426e04 --- /dev/null +++ b/src/tools/elftool/dir.dox @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2016 Cisco and/or its affiliates. + * Copyright (c) 2016 Comcast Cable Communications Management, LLC. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** @dir + * @brief VPP instrastructure tools. + */ diff --git a/src/tools/elftool/elftool.c b/src/tools/elftool/elftool.c new file mode 100644 index 00000000..d9d3704b --- /dev/null +++ b/src/tools/elftool/elftool.c @@ -0,0 +1,464 @@ +/* + * Copyright (c) 2015 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/* + Copyright (c) 2008 Eliot Dresselhaus + + 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 AUTHORS OR COPYRIGHT HOLDERS BE + LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#include + +#include +#include +#include + +#ifndef CLIB_UNIX +#error "unix only" +#endif + +typedef struct { + elf_main_t elf_main; + char * input_file; + char * output_file; + char * set_interpreter; + char * set_rpath; + int unset_rpath; + int verbose; + int quiet; + int allow_elf_shared; + /* for use in the optimized / simplified case */ + u64 file_size; + u64 interpreter_offset; + u64 rpath_offset; +} elf_tool_main_t; + +static clib_error_t * elf_set_interpreter (elf_main_t * em, + elf_tool_main_t * tm) +{ + elf_segment_t * g; + elf_section_t * s; + clib_error_t * error; + char * interp = tm->set_interpreter; + + switch (em->first_header.file_type) + { + case ELF_EXEC: + break; + + case ELF_SHARED: + if (tm->allow_elf_shared) + break; + /* Note flowthrough */ + default: + return clib_error_return (0, "unacceptable file_type"); + } + + vec_foreach (g, em->segments) + { + if (g->header.type == ELF_SEGMENT_INTERP) + break; + } + + if (g >= vec_end (em->segments)) + return clib_error_return (0, "interpreter not found"); + + if (g->header.memory_size < 1 + strlen (interp)) + return clib_error_return (0, "given interpreter does not fit; must be less than %d bytes (`%s' given)", + g->header.memory_size, interp); + + error = elf_get_section_by_start_address (em, g->header.virtual_address, &s); + if (error) + return error; + + /* Put in new null terminated string. */ + memset (s->contents, 0, vec_len (s->contents)); + clib_memcpy (s->contents, interp, strlen (interp)); + + return 0; +} + +static void +delete_rpath_for_section (elf_main_t * em, elf_section_t * s) +{ + elf64_dynamic_entry_t * e; + elf64_dynamic_entry_t * new_es = 0; + + vec_foreach (e, em->dynamic_entries) + { + switch (e->type) + { + case ELF_DYNAMIC_ENTRY_RPATH: + case ELF_DYNAMIC_ENTRY_RUN_PATH: + break; + + default: + vec_add1 (new_es, e[0]); + break; + } + } + + /* Pad so as to keep section size constant. */ + { + elf64_dynamic_entry_t e_end; + e_end.type = ELF_DYNAMIC_ENTRY_END; + e_end.data = 0; + while (vec_len (new_es) < vec_len (em->dynamic_entries)) + vec_add1 (new_es, e_end); + } + + vec_free (em->dynamic_entries); + em->dynamic_entries = new_es; + + elf_set_dynamic_entries (em); +} + +static void delete_rpath (elf_main_t * em) +{ + elf_section_t * s; + + vec_foreach (s, em->sections) + { + switch (s->header.type) + { + case ELF_SECTION_DYNAMIC: + delete_rpath_for_section (em, s); + break; + + default: + break; + } + } +} + +static clib_error_t * +set_rpath_for_section (elf_main_t * em, elf_section_t * s, char * new_rpath) +{ + elf64_dynamic_entry_t * e; + char * old_rpath; + int old_len, new_len = strlen (new_rpath); + u8 * new_string_table = vec_dup (em->dynamic_string_table); + + vec_foreach (e, em->dynamic_entries) + { + switch (e->type) + { + case ELF_DYNAMIC_ENTRY_RPATH: + case ELF_DYNAMIC_ENTRY_RUN_PATH: + old_rpath = (char *) new_string_table + e->data; + old_len = strlen (old_rpath); + if (old_len < new_len) + return clib_error_return (0, "rpath of `%s' does not fit (old rpath `%s')", + new_rpath, old_rpath); + strcpy (old_rpath, new_rpath); + break; + + default: + break; + } + } + + elf_set_section_contents (em, em->dynamic_string_table_section_index, + new_string_table, + vec_bytes (new_string_table)); + + return 0; +} + +static clib_error_t * +set_rpath (elf_main_t * em, char * rpath) +{ + clib_error_t * error = 0; + elf_section_t * s; + + vec_foreach (s, em->sections) + { + switch (s->header.type) + { + case ELF_SECTION_DYNAMIC: + error = set_rpath_for_section (em, s, rpath); + if (error) + return error; + break; + + default: + break; + } + } + + return error; +} + +static clib_error_t * +set_interpreter_rpath (elf_tool_main_t * tm) +{ + int ifd = -1, ofd = -1; + struct stat fd_stat; + u8 *idp = 0; /* warning be gone */ + u64 mmap_length = 0, i; + u32 run_length; + u8 in_run; + u64 offset0 = 0, offset1 = 0; + clib_error_t * error = 0; + int fix_in_place = 0; + + if (!strcmp (tm->input_file, tm->output_file)) + fix_in_place = 1; + + ifd = open (tm->input_file, O_RDWR); + if (ifd < 0) + { + error = clib_error_return_unix (0, "open `%s'", tm->input_file); + goto done; + } + + if (fstat (ifd, &fd_stat) < 0) + { + error = clib_error_return_unix (0, "fstat `%s'", tm->input_file); + goto done; + } + + if (!(fd_stat.st_mode & S_IFREG)) + { + error = clib_error_return (0, "%s is not a regular file", tm->input_file); + goto done; + } + + mmap_length = fd_stat.st_size; + if (mmap_length < 4) + { + error = clib_error_return (0, "%s too short", tm->input_file); + goto done; + } + + /* COW-mapping, since we intend to write the fixups */ + if (fix_in_place) + idp = mmap (0, mmap_length, PROT_READ | PROT_WRITE, MAP_SHARED, + ifd, /* offset */ 0); + else + idp = mmap (0, mmap_length, PROT_READ | PROT_WRITE, MAP_PRIVATE, + ifd, /* offset */ 0); + if (~pointer_to_uword (idp) == 0) + { + mmap_length = 0; + error = clib_error_return_unix (0, "mmap `%s'", tm->input_file); + goto done; + } + + if (idp[0] != 0x7f || idp[1] != 'E' || idp[2] != 'L' || idp[3] != 'F') + { + error = clib_error_return (0, "not an ELF file '%s'", tm->input_file); + goto done; + } + + in_run = 0; + run_length = 0; + + for (i = 0; i < mmap_length; i++) + { + if (idp[i] == '/') + { + if (in_run) + run_length++; + else + { + in_run = 1; + run_length = 1; + } + } + else + { + if (in_run && run_length >= 16) + { + if (offset0 == 0) + offset0 = (i - run_length); + else if (offset1 == 0) + { + offset1 = (i - run_length); + goto found_both; + } + } + in_run = 0; + run_length = 0; + } + } + + if (offset0 == 0) + { + error = clib_error_return (0, "no fixup markers in %s", + tm->input_file); + goto done; + } + + found_both: + if (0) + clib_warning ("offset0 %lld (0x%llx), offset1 %lld (0x%llx)", + offset0, offset0, offset1, offset1); + + /* Executable file case */ + if (offset0 && offset1) + { + tm->interpreter_offset = offset0; + tm->rpath_offset = offset1; + } + else /* shared library case */ + { + tm->interpreter_offset = 0; + tm->rpath_offset = offset0; + } + + if (tm->interpreter_offset) + clib_memcpy (&idp[tm->interpreter_offset], tm->set_interpreter, + strlen (tm->set_interpreter)+1); + + if (tm->rpath_offset) + clib_memcpy (&idp[tm->rpath_offset], tm->set_rpath, + strlen (tm->set_rpath)+1); + + /* Write the output file... */ + if (fix_in_place == 0) + { + ofd = open (tm->output_file, O_RDWR | O_CREAT | O_TRUNC, 0644); + if (ofd < 0) + { + error = clib_error_return_unix (0, "create `%s'", tm->output_file); + goto done; + } + + if (write (ofd, idp, mmap_length) != mmap_length) + error = clib_error_return_unix (0, "write `%s'", tm->output_file); + } + + done: + if (mmap_length > 0 && idp) + munmap (idp, mmap_length); + if (ifd >= 0) + close (ifd); + if (ofd >= 0) + close (ofd); + return error; +} + + +int main (int argc, char * argv[]) +{ + elf_tool_main_t _tm, * tm = &_tm; + elf_main_t * em = &tm->elf_main; + unformat_input_t i; + clib_error_t * error = 0; + + memset (tm, 0, sizeof (tm[0])); + unformat_init_command_line (&i, argv); + + while (unformat_check_input (&i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (&i, "in %s", &tm->input_file)) + ; + else if (unformat (&i, "out %s", &tm->output_file)) + ; + else if (unformat (&i, "set-interpreter %s", &tm->set_interpreter)) + ; + else if (unformat (&i, "set-rpath %s", &tm->set_rpath)) + ; + else if (unformat (&i, "unset-rpath")) + tm->unset_rpath = 1; + else if (unformat (&i, "verbose")) + tm->verbose = ~0; + else if (unformat (&i, "verbose-symbols")) + tm->verbose |= FORMAT_ELF_MAIN_SYMBOLS; + else if (unformat (&i, "verbose-relocations")) + tm->verbose |= FORMAT_ELF_MAIN_RELOCATIONS; + else if (unformat (&i, "verbose-dynamic")) + tm->verbose |= FORMAT_ELF_MAIN_DYNAMIC; + else if (unformat (&i, "quiet")) + tm->quiet = 1; + else if (unformat (&i, "allow-elf-shared")) + tm->allow_elf_shared = 1; + else + { + error = unformat_parse_error (&i); + goto done; + } + } + + if (! tm->input_file) + { + error = clib_error_return (0, "no input file"); + goto done; + } + + /* Do the typical case a stone-simple way... */ + if (tm->quiet && tm->set_interpreter && tm->set_rpath && tm->output_file) + { + error = set_interpreter_rpath (tm); + goto done; + } + + error = elf_read_file (em, tm->input_file); + + if (error) + goto done; + + if (tm->verbose) + fformat (stdout, "%U", format_elf_main, em, tm->verbose); + + if (tm->set_interpreter) + { + error = elf_set_interpreter (em, tm); + if (error) + goto done; + } + + if (tm->set_rpath) + { + error = set_rpath (em, tm->set_rpath); + if (error) + goto done; + } + + if (tm->unset_rpath) + delete_rpath (em); + + if (tm->output_file) + error = elf_write_file (em, tm->output_file); + + elf_main_free (em); + + done: + if (error) + { + if (tm->quiet == 0) + clib_error_report (error); + return 1; + } + else + return 0; +} diff --git a/src/tools/g2/clib.c b/src/tools/g2/clib.c new file mode 100644 index 00000000..6454c84d --- /dev/null +++ b/src/tools/g2/clib.c @@ -0,0 +1,154 @@ +/* + *------------------------------------------------------------------ + * Copyright (c) 2009-2016 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "cpel.h" +#include "g2.h" + +int widest_track_format; + +typedef struct bound_track_ { + u32 track; + u8 *track_str; +} bound_track_t; + +bound_track_t *bound_tracks; + +uword *the_evtdef_hash; /* (event-id, event-definition) hash */ +uword *the_trackdef_hash; /* (track-id, track-definition) hash */ + +elog_main_t elog_main; + +void *get_clib_event (unsigned int datum) +{ + elog_event_t *ep = vec_elt_at_index (elog_main.events, datum); + return (void *)ep; +} + +/* + * read_clib_file + */ +int read_clib_file(char *clib_file) +{ + static FILE *ofp; + clib_error_t *error = 0; + int i; + elog_main_t *em = &elog_main; + double starttime, delta; + + vec_free(em->events); + vec_free(em->event_types); + if (the_trackdef_hash) + hash_free(the_trackdef_hash); + + the_trackdef_hash = hash_create (0, sizeof (uword)); + + error = elog_read_file (&elog_main, clib_file); + + if (error) { + fformat(stderr, "%U", format_clib_error, error); + return (1); + } + + if (ofp == NULL) { + ofp = fdopen(2, "w"); + if (ofp == NULL) { + fprintf(stderr, "Couldn't fdopen(2)?\n"); + exit(1); + } + } + + em = &elog_main; + + for (i = 0; i < vec_len (em->tracks); i++) { + u32 track_code; + bound_track_t * btp; + elog_track_t * t; + uword * p; + int track_strlen; + + t = &em->tracks[i]; + track_code = i; + p = hash_get(the_trackdef_hash, track_code); + if (p) { + fprintf(ofp, "track %d redefined, retain first definition\n", + track_code); + continue; + } + vec_add2(bound_tracks, btp, 1); + btp->track = track_code; + btp->track_str = (u8 *) t->name; + hash_set(the_trackdef_hash, track_code, btp - bound_tracks); + + track_strlen = strlen((char *)btp->track_str); + if (track_strlen > widest_track_format) + widest_track_format = track_strlen; + } + + initialize_events(); + + for (i = 0; i < vec_len (em->event_types); i++) { + elog_event_type_t *ep; + u8 *tmp; + + ep = vec_elt_at_index(em->event_types, i); + tmp = (u8 *) vec_dup(ep->format); + vec_add1(tmp,0); + add_event_from_clib_file (ep->type_index_plus_one, (char *) tmp, i); + vec_free(tmp); + } + + finalize_events(); + + em->events = elog_get_events (em); + + cpel_event_init(vec_len(em->events)); + + starttime = em->events[0].time; + + for (i = 0; i < vec_len (em->events); i++) { + elog_event_t *ep; + + ep = vec_elt_at_index(em->events, i); + + delta = ep->time - starttime; + + add_clib_event (delta, ep->track, ep->type + 1, i); + } + + cpel_event_finalize(); + + set_pid_ax_width(8*widest_track_format); + + return(0); +} diff --git a/src/tools/g2/configure.ac b/src/tools/g2/configure.ac new file mode 100644 index 00000000..c8af7747 --- /dev/null +++ b/src/tools/g2/configure.ac @@ -0,0 +1,12 @@ +AC_INIT(g2, 3.0) +AM_INIT_AUTOMAKE +AM_SILENT_RULES([yes]) + +AC_CHECK_LIB([vppinfra], [clib_mem_get_page_size],, + AC_MSG_ERROR([Please install the vpp-lib package])) +AC_CHECK_HEADER([vppinfra/clib.h],, + AC_MSG_ERROR([Please install the vpp-dev package])) + +PKG_CHECK_MODULES(g2, gtk+-2.0) + +AC_OUTPUT([Makefile]) diff --git a/src/tools/g2/cpel.c b/src/tools/g2/cpel.c new file mode 100644 index 00000000..8bcc91e6 --- /dev/null +++ b/src/tools/g2/cpel.c @@ -0,0 +1,470 @@ +/* + *------------------------------------------------------------------ + * Copyright (c) 2005-2016 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "cpel.h" +#include "g2.h" + +typedef struct bound_event_ { + u32 event_code; + u8 *event_str; + u8 *datum_str; +} bound_event_t; + +bound_event_t *bound_events; + +int widest_track_format=8; + +typedef struct bound_track_ { + u32 track; + u8 *track_str; +} bound_track_t; + +bound_track_t *bound_tracks; + +uword *the_strtab_hash; /* (name, base-VA) hash of all string tables */ +uword *the_evtdef_hash; /* (event-id, event-definition) hash */ +uword *the_trackdef_hash; /* (track-id, track-definition) hash */ +u8 *event_strtab; /* event string-table */ + +void fatal(char *s) +{ + fprintf(stderr, "%s", s); + exit(1); +} + +typedef enum { + PASS1=1, + PASS2=2, +} pass_t; + +typedef struct { + int (*pass1)(cpel_section_header_t *, int, FILE *); + int (*pass2)(cpel_section_header_t *, int, FILE *); +} section_processor_t; + +int bad_section(cpel_section_header_t *sh, int verbose, FILE *ofp) +{ + fprintf(ofp, "Bad (type 0) section, skipped...\n"); + return(0); +} + +int noop_pass(cpel_section_header_t *sh, int verbose, FILE *ofp) +{ + return(0); +} + +int strtab_pass1(cpel_section_header_t *sh, int verbose, FILE *ofp) +{ + uword *p; + u8 *strtab_data_area = (u8 *)(sh+1); + + /* Multiple string tables with the same name are Bad... */ + p = hash_get_mem(the_strtab_hash, strtab_data_area); + if (p) { + fprintf(ofp, "Duplicate string table name %s", strtab_data_area); + } + /* + * Looks funny, but we really do want key = first string in the + * table, value = address(first string in the table) + */ + hash_set_mem(the_strtab_hash, strtab_data_area, strtab_data_area); + if (verbose) { + fprintf(ofp, "String Table %s\n", strtab_data_area); + } + return(0); +} + +int evtdef_pass1(cpel_section_header_t *sh, int verbose, FILE *ofp) +{ + int i, nevents; + event_definition_section_header_t *edh; + event_definition_t *ep; + u8 *this_strtab; + u32 event_code; + uword *p; + bound_event_t *bp; + + edh = (event_definition_section_header_t *)(sh+1); + nevents = ntohl(edh->number_of_event_definitions); + + if (verbose) { + fprintf(ofp, "Event Definition Section: %d definitions\n", + nevents); + } + + p = hash_get_mem(the_strtab_hash, edh->string_table_name); + if (!p) { + fprintf(ofp, "Fatal: couldn't find string table\n"); + return(1); + } + this_strtab = (u8 *)p[0]; + + initialize_events(); + + ep = (event_definition_t *)(edh+1); + + for (i = 0; i < nevents; i++) { + event_code = ntohl(ep->event); + p = hash_get(the_evtdef_hash, event_code); + if (p) { + fprintf(ofp, "Event %d redefined, retain first definition\n", + event_code); + continue; + } + vec_add2(bound_events, bp, 1); + bp->event_code = event_code; + bp->event_str = this_strtab + ntohl(ep->event_format); + bp->datum_str = this_strtab + ntohl(ep->datum_format); + hash_set(the_evtdef_hash, event_code, bp - bound_events); + + add_event_from_cpel_file(event_code, (char *) bp->event_str, + (char *)bp->datum_str); + + ep++; + } + + finalize_events(); + return (0); +} + +int trackdef_pass1(cpel_section_header_t *sh, int verbose, FILE *ofp) +{ + int i, nevents; + track_definition_section_header_t *tdh; + track_definition_t *tp; + u8 *this_strtab; + u32 track_code; + uword *p; + bound_track_t *btp; + int track_strlen; + + tdh = (track_definition_section_header_t *)(sh+1); + nevents = ntohl(tdh->number_of_track_definitions); + + if (verbose) { + fprintf(ofp, "Track Definition Section: %d definitions\n", + nevents); + } + + p = hash_get_mem(the_strtab_hash, tdh->string_table_name); + if (!p) { + fprintf(ofp, "Fatal: couldn't find string table\n"); + return(1); + } + this_strtab = (u8 *)p[0]; + + tp = (track_definition_t *)(tdh+1); + + for (i = 0; i < nevents; i++) { + track_code = ntohl(tp->track); + p = hash_get(the_trackdef_hash, track_code); + if (p) { + fprintf(ofp, "track %d redefined, retain first definition\n", + track_code); + continue; + } + vec_add2(bound_tracks, btp, 1); + btp->track = track_code; + btp->track_str = this_strtab + ntohl(tp->track_format); + hash_set(the_trackdef_hash, track_code, btp - bound_tracks); + + track_strlen = strlen((char *)btp->track_str); + if (track_strlen > widest_track_format) + widest_track_format = track_strlen; + tp++; + } + return (0); +} + +int unsupported_pass (cpel_section_header_t *sh, int verbose, FILE *ofp) +{ + if (verbose) { + fprintf(ofp, "Unsupported type %d section\n", + ntohl(sh->section_type)); + } + return(0); +} + +int event_pass2(cpel_section_header_t *sh, int verbose, FILE *ofp) +{ + event_section_header_t *eh; + u32 event_code, track_code, datum; + u64 starttime = ~0ULL; + int nevents; + int i; + event_entry_t *ep; + u64 now; + u64 delta; + u32 time0, time1; + double d; + uword *p; + + eh = (event_section_header_t *)(sh+1); + nevents = ntohl(eh->number_of_events); + ticks_per_ns = ntohl(eh->clock_ticks_per_second)/1e9; + ep = (event_entry_t *)(eh+1); + + p = hash_get_mem(the_strtab_hash, eh->string_table_name); + if (!p) { + fprintf(ofp, "Fatal: couldn't find string table\n"); + return(1); + } + event_strtab = (u8 *)p[0]; + + cpel_event_init(nevents); + + for (i = 0; i < nevents; i++) { + time0 = ntohl (ep->time[0]); + time1 = ntohl (ep->time[1]); + + now = (((u64) time0)<<32) | time1; + + /* Convert from bus ticks to usec */ + d = now; + d /= ticks_per_ns; + + now = d; + + if (starttime == ~0ULL) + starttime = now; + + delta = now - starttime; + + /* Delta = time since first event, in usec */ + event_code = ntohl(ep->event_code); + track_code = ntohl(ep->track); + datum = ntohl(ep->event_datum); + + add_cpel_event(delta, track_code, event_code, datum); + + ep++; + } + cpel_event_finalize(); + return(0); +} + +char *strtab_ref(unsigned long datum) +{ + return ((char *)(event_strtab + datum)); +} + +/* + * Note: If necessary, add passes / columns to this table to + * handle section order dependencies. + */ + +section_processor_t processors[CPEL_NUM_SECTION_TYPES+1] = +{ + {bad_section, noop_pass}, /* type 0 -- f**ked */ + {strtab_pass1, noop_pass}, /* type 1 -- STRTAB */ + {unsupported_pass, noop_pass}, /* type 2 -- SYMTAB */ + {evtdef_pass1, noop_pass}, /* type 3 -- EVTDEF */ + {trackdef_pass1, noop_pass}, /* type 4 -- TRACKDEF */ + {noop_pass, event_pass2}, /* type 5 -- EVENTS */ +}; + + +int process_section(cpel_section_header_t *sh, int verbose, FILE *ofp, + pass_t pass) +{ + u32 type; + type = ntohl(sh->section_type); + int rv; + int (*fp)(cpel_section_header_t *, int, FILE *); + + if (type > CPEL_NUM_SECTION_TYPES) { + fprintf(stderr, "Unknown section type %d\n", type); + return(1); + } + switch(pass) { + case PASS1: + fp = processors[type].pass1; + break; + + case PASS2: + fp = processors[type].pass2; + break; + + default: + fprintf(stderr, "Unknown pass %d\n", pass); + return(1); + } + + rv = (*fp)(sh, verbose, ofp); + + return(rv); +} + +int cpel_dump_file_header(cpel_file_header_t *fh, int verbose, FILE *ofp) +{ + time_t file_time; + + if (verbose) { + fprintf(ofp, "CPEL file: %s-endian, version %d\n", + ((fh->endian_version & CPEL_FILE_LITTLE_ENDIAN) ? + "little" : "big"), + fh->endian_version & CPEL_FILE_VERSION_MASK); + + file_time = ntohl(fh->file_date); + + fprintf(ofp, "File created %s", ctime(&file_time)); + } + + return(0); +} + + +int cpel_process(u8 *cpel, int verbose, FILE *ofp) +{ + cpel_file_header_t *fh; + cpel_section_header_t *sh; + u16 nsections; + u32 section_size; + int i; + + /* First, the file header */ + fh = (cpel_file_header_t *)cpel; + if (fh->endian_version != CPEL_FILE_VERSION) { + if (fh->endian_version & CPEL_FILE_LITTLE_ENDIAN) { + fprintf(stderr, "Little endian data format not supported\n"); + return(1); + } + fprintf(stderr, "Unsupported file version 0x%x\n", + fh->endian_version); + return(1); + } + cpel_dump_file_header(fh, verbose, ofp); + nsections = ntohs(fh->nsections); + + /* + * Take two passes through the file. PASS1 builds + * data structures, PASS2 actually dumps the file. + * Just in case the sections are in an unobvious order. + */ + sh = (cpel_section_header_t *)(fh+1); + for (i = 0; i < nsections; i++) { + section_size = ntohl(sh->data_length); + + if(verbose) { + fprintf(ofp, "Section type %d, size %d\n", ntohl(sh->section_type), + section_size); + } + + if(process_section(sh, verbose, ofp, PASS1)) + return(1); + + sh++; + sh = (cpel_section_header_t *)(((u8 *)sh)+section_size); + } + + sh = (cpel_section_header_t *)(fh+1); + for (i = 0; i < nsections; i++) { + if(process_section(sh, verbose, ofp, PASS2)) + return(1); + section_size = ntohl(sh->data_length); + sh++; + sh = (cpel_section_header_t *)(((u8 *)sh)+section_size); + } + + + return(0); +} + +/* + * read_cpel_file + */ +int read_cpel_file(char *cpel_file) +{ + int verbose = 0; + int rv; + static u8 *cpel; + static unsigned long size; + static FILE *ofp; + + if (cpel) { + unmapfile((char *)cpel, size); + hash_free(the_strtab_hash); + the_strtab_hash = 0; + hash_free(the_evtdef_hash); + the_evtdef_hash = 0; + hash_free(the_trackdef_hash); + the_trackdef_hash = 0; + } + + cpel = (u8 *)mapfile((char *)cpel_file, &size); + if (cpel == 0) { + fprintf(stderr, "Couldn't map %s...\n", cpel_file); + exit(1); + } + + if (ofp == NULL) { + ofp = fdopen(2, "w"); + if (ofp == NULL) { + fprintf(stderr, "Couldn't fdopen(2)?\n"); + exit(1); + } + } + + the_strtab_hash = hash_create_string (0, sizeof (uword)); + the_evtdef_hash = hash_create (0, sizeof (uword)); + the_trackdef_hash = hash_create (0, sizeof (uword)); + + rv = cpel_process(cpel, verbose, ofp); + + set_pid_ax_width(8*widest_track_format); + + return(rv); +} + +static bound_track_t generic_hex_track = {0, (u8 *) "0x%08x"}; +static bound_track_t generic_decimal_track = {0, (u8 *) "%8ld"}; + +/* + * get_track_label + */ +char *get_track_label(unsigned long track) +{ + uword *p; + bound_track_t *tp; + + p = hash_get(the_trackdef_hash, track); + if (p) { + tp = &bound_tracks[p[0]]; + } else { + if (track > 65535) + tp = &generic_hex_track; + else + tp = &generic_decimal_track; + } + return((char *)tp->track_str); +} diff --git a/src/tools/g2/cpel.h b/src/tools/g2/cpel.h new file mode 100644 index 00000000..73e4aea5 --- /dev/null +++ b/src/tools/g2/cpel.h @@ -0,0 +1,83 @@ +/* + *------------------------------------------------------------------ + * Copyright (c) 2005-2016 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _CPEL_H_ +#define _CPEL_H_ 1 + +typedef struct cpel_file_header_ { + unsigned char endian_version; + unsigned char pad; + unsigned short nsections; + unsigned file_date; +} cpel_file_header_t; + +#define CPEL_FILE_LITTLE_ENDIAN 0x80 +#define CPEL_FILE_VERSION 0x01 +#define CPEL_FILE_VERSION_MASK 0x7F + +typedef struct cpel_section_header_ { + unsigned int section_type; + unsigned int data_length; /* does NOT include type and itself */ +} cpel_section_header_t; + +#define CPEL_SECTION_STRTAB 1 +/* string at offset 0 is the name of the table */ + +#define CPEL_SECTION_SYMTAB 2 +#define CPEL_SECTION_EVTDEF 3 + +typedef struct event_definition_section_header_ { + char string_table_name[64]; + unsigned int number_of_event_definitions; +} event_definition_section_header_t; + +typedef struct event_definition_ { + unsigned int event; + unsigned int event_format; + unsigned int datum_format; +} event_definition_t; + +#define CPEL_SECTION_TRACKDEF 4 + +typedef struct track_definition_section_header_ { + char string_table_name[64]; + unsigned int number_of_track_definitions; +} track_definition_section_header_t; + +typedef struct track_definition_ { + unsigned int track; + unsigned int track_format; +} track_definition_t; + +#define CPEL_SECTION_EVENT 5 + +typedef struct event_section_header_ { + char string_table_name[64]; + unsigned int number_of_events; + unsigned int clock_ticks_per_second; +} event_section_header_t; + +typedef struct event_entry_ { + unsigned int time[2]; + unsigned int track; + unsigned int event_code; + unsigned int event_datum; +} event_entry_t; + +#define CPEL_NUM_SECTION_TYPES 5 + +#endif /* _CPEL_H_ */ + diff --git a/src/tools/g2/events.c b/src/tools/g2/events.c new file mode 100644 index 00000000..d4333bb0 --- /dev/null +++ b/src/tools/g2/events.c @@ -0,0 +1,475 @@ +/* + *------------------------------------------------------------------ + * Copyright (c) 2005-2016 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include "g2.h" +#include +#include +#include +#include + +/* + * globals + */ +boolean g_little_endian; +event_t *g_events; +ulong g_nevents; +pid_sort_t *g_pids; +pid_sort_t *g_original_pids; +int g_npids; +pid_data_t *g_pid_data_list; + +/* + * locals + */ +pid_data_t **s_pidhash; + +/* + * config parameters + */ + +double ticks_per_ns=1000.0; +boolean ticks_per_ns_set; + +/**************************************************************************** +* event_init +****************************************************************************/ + +void event_init(void) +{ + ulong endian; + char *ep; + char *askstr; + int tmp; + + ep = (char *)&endian; + endian = 0x12345678; + if (*ep != 0x12) + g_little_endian = TRUE; + else + g_little_endian = FALSE; + + askstr = getprop("dont_ask_ticks_per_ns_initially"); + + if (askstr && (*askstr == 't' || *askstr == 'T')) { + tmp = atol(getprop_default("ticks_per_ns", 0)); + if (tmp > 0) { + ticks_per_ns = tmp; + ticks_per_ns_set = TRUE; + } + } +} + +/**************************************************************************** +* find_or_add_pid +****************************************************************************/ + +pid_data_t *find_or_add_pid (ulong pid) +{ + pid_data_t *pp; + ulong bucket; + + bucket = pid % PIDHASH_NBUCKETS; + + pp = s_pidhash[bucket]; + + if (pp == 0) { + pp = g_malloc0(sizeof(pid_data_t)); + pp->pid_value = pid; + s_pidhash[bucket] = pp; + g_npids++; + return(pp); + } + while (pp) { + if (pp->pid_value == pid) + return(pp); + pp = pp->next; + } + + pp = g_malloc0(sizeof(pid_data_t)); + pp->pid_value = pid; + pp->next = s_pidhash[bucket]; + s_pidhash[bucket] = pp; + g_npids++; + return(pp); +} + +/**************************************************************************** +* pid_cmp +****************************************************************************/ + +int pid_cmp(const void *a1, const void *a2) +{ + pid_sort_t *p1 = (pid_sort_t *)a1; + pid_sort_t *p2 = (pid_sort_t *)a2; + + if (p1->pid_value < p2->pid_value) + return(-1); + else if (p1->pid_value == p2->pid_value) + return(0); + else + return(1); +} + +/**************************************************************************** +* make_sorted_pid_vector +****************************************************************************/ + +static void make_sorted_pid_vector(void) +{ + pid_data_t *pp; + pid_data_t **p_previous; + pid_sort_t *psp; + int i; + + psp = g_pids = g_malloc(sizeof(pid_sort_t)*g_npids); + + for (i = 0; i < PIDHASH_NBUCKETS; i++) { + pp = s_pidhash[i]; + while(pp) { + psp->pid = pp; + psp->pid_value = pp->pid_value; + psp++; + pp = pp->next; + } + } + + qsort(&g_pids[0], g_npids, sizeof(pid_sort_t), pid_cmp); + + /* put the sort order into the pid objects */ + psp = g_pids; + + /* + * This is rather gross. + * + * We happen to know that whenever this function is called, the hash table + * structure itself is immediately torn down. So the "next" pointers in the + * pid_data_t elements are about to become useless. + * + * So we re-use them, to link all the pid_data_t elements together into a + * single unified linked list, with g_pid_data_list pointing to the head. + * This means we can walk all the pid_data_t objects if we really want to. + * Reading snapshots from disk is one example. + * + * Alternatively we could just leave the hash table in place; this is + * far nicer, but as it happens, trading O(n) lookups for O(1) lookups + * isn't actually a problem for the restricted post-tear-down usage. So for + * now we take the memory savings and swap our hash table for a list. + */ + p_previous = &g_pid_data_list; + for (i = 0; i < g_npids; i++) { + pp = psp->pid; + pp->pid_index = i; + *p_previous = pp; + p_previous = &pp->next; + psp++; + } + *p_previous = NULL; + + /* + * Squirrel away original (sorted) vector, so we can + * toggle between "chase" mode, snapshots, and the original + * display method on short notice + */ + g_original_pids = g_malloc(sizeof(pid_sort_t)*g_npids); + memcpy (g_original_pids, g_pids, sizeof(pid_sort_t)*g_npids); +} + +/**************************************************************************** +* read_events +****************************************************************************/ + +void read_events(char *filename) +{ + ulong *ulp; + ulong size; + event_t *ep; + raw_event_t *rep; + ulonglong start_time=0ULL; + ulonglong low_time; + boolean once=TRUE; + int i; + char tmpbuf [128]; + + ulp = (ulong *)mapfile(filename, &size); + + if (ulp == NULL) { + sprintf(tmpbuf, "Couldn't open %s\n", filename); + infobox("Read Event Log Failure", tmpbuf); + return; + } + + g_nevents = ntohl(*ulp); + + if (size != (g_nevents*sizeof(raw_event_t) + sizeof(g_nevents))) { + sprintf(tmpbuf, "%s was damaged, or isn't an event log.\n", filename); + infobox("Bad Input File", tmpbuf); + g_nevents = 0; + unmapfile((char *)ulp, size); + return; + } + + rep = (raw_event_t *)(ulp+1); + + if (g_events) + g_free(g_events); + + g_events = (event_t *)g_malloc(g_nevents * sizeof(event_t)); + ep = g_events; + + while (g_npids > 0) { + g_free((g_pids + g_npids-1)->pid); + g_npids--; + } + if (g_pids) { + g_free(g_pids); + g_free(g_original_pids); + g_pids = 0; + g_original_pids = 0; + } + + s_pidhash = (pid_data_t **)g_malloc0( + PIDHASH_NBUCKETS*sizeof(pid_data_t *)); + + /* $$$ add a SEGV handler... */ + for (i = 0; i < g_nevents; i++) { + if (once) { + once = FALSE; + start_time = ((ulonglong)ntohl(rep->time[0])); + start_time <<= 32; + low_time = ntohl(rep->time[1]); + low_time &= 0xFFFFFFFF; + start_time |= low_time; + ep->time = 0LL; + } else { + ep->time = ((ulonglong)ntohl(rep->time[0])); + ep->time <<= 32; + low_time = ntohl(rep->time[1]); + low_time &= 0xFFFFFFFF; + ep->time |= low_time; + ep->time -= start_time; + ep->time /= ticks_per_ns; + } + ep->code = ntohl(rep->code); + ep->pid = find_or_add_pid(ntohl(rep->pid)); + ep->datum = ntohl(rep->datum); + ep->flags = 0; + ep++; + rep++; + } + + unmapfile((char *)ulp, size); + + make_sorted_pid_vector(); + g_free(s_pidhash); + s_pidhash = 0; + + /* Give the view-1 world a chance to reset a few things... */ + view1_read_events_callback(); +} + +static event_t *add_ep; + +/**************************************************************************** +* cpel_event_init +****************************************************************************/ +void cpel_event_init (ulong nevents) +{ + g_nevents = nevents; + if (g_events) + g_free(g_events); + add_ep = g_events = (event_t *)g_malloc(g_nevents * sizeof(event_t)); + while (g_npids > 0) { + g_free((g_pids + g_npids-1)->pid); + g_npids--; + } + if (g_pids) { + g_free(g_pids); + g_free(g_original_pids); + g_pids = 0; + g_original_pids = 0; + } + s_pidhash = (pid_data_t **)g_malloc0( + PIDHASH_NBUCKETS*sizeof(pid_data_t *)); +} + +/**************************************************************************** +* add_cpel_event +****************************************************************************/ + +void add_cpel_event(ulonglong delta, ulong track, ulong event, ulong datum) +{ + event_t *ep; + + ep = add_ep++; + ep->time = delta; + ep->pid = find_or_add_pid(track); + ep->code = event; + ep->datum = datum; + ep->flags = 0; +} + +/**************************************************************************** +* add_clib_event +****************************************************************************/ + +void add_clib_event(double delta, unsigned short track, + unsigned short event, unsigned int index) +{ + event_t *ep; + + ep = add_ep++; + ep->time = (ulonglong) (delta * 1e9); /* time in intger nanoseconds */ + ep->pid = find_or_add_pid(track); + ep->code = event; + ep->datum = index; + ep->flags = EVENT_FLAG_CLIB; +} + +/**************************************************************************** +* cpel_event_finalize +****************************************************************************/ + +void cpel_event_finalize(void) +{ + make_sorted_pid_vector(); + g_free(s_pidhash); + s_pidhash = 0; + + /* Give the view-1 world a chance to reset a few things... */ + view1_read_events_callback(); +} + +/**************************************************************************** +* mapfile +****************************************************************************/ + +char *mapfile (char *file, ulong *sizep) +{ + struct stat statb; + char *rv; + int maphfile; + size_t mapfsize; + + maphfile = open (file, O_RDONLY); + + if (maphfile < 0) + return (NULL); + + if (fstat (maphfile, &statb) < 0) { + return (NULL); + } + + /* Don't try to mmap directories, FIFOs, semaphores, etc. */ + if (! (statb.st_mode & S_IFREG)) { + return (NULL); + } + + mapfsize = statb.st_size; + + if (mapfsize < 3) { + close (maphfile); + return (NULL); + } + + rv = mmap (0, mapfsize, PROT_READ, MAP_SHARED, maphfile, 0); + + if (rv == 0) { + g_error ("%s mapping problem, I quit...\n", file); + } + + close (maphfile); + + if (madvise (rv, mapfsize, MADV_SEQUENTIAL) < 0) { + return (rv); + } + + if (sizep) { + *sizep = mapfsize; + } + return (rv); +} + +/**************************************************************************** +* unmapfile +****************************************************************************/ + +boolean unmapfile (char *addr, ulong size) +{ + if (munmap (addr, size) < 0) { + g_warning("Unmap error, addr 0x%lx size 0x%x\n", + (unsigned long) addr, (unsigned int)size); + return(FALSE); + } + return(TRUE); +} + +/**************************************************************************** +* find_event_index +* Binary search for first event whose time is >= t +****************************************************************************/ + +int find_event_index (ulonglong t) +{ + int index, bottom, top; + event_t *ep; + + bottom = g_nevents-1; + top = 0; + + while (1) { + index = (bottom + top) / 2; + + ep = (g_events + index); + + if (ep->time == t) + return(index); + + if (top >= bottom) { + while (index > 0 && ep->time > t) { + ep--; + index--; + } + while (index < g_nevents && ep->time < t) { + ep++; + index++; + } + return(index); + } + + if (ep->time < t) + top = index + 1; + else + bottom = index - 1; + } +} + +/**************************************************************************** +* events_about +****************************************************************************/ + +void events_about (char *tmpbuf) +{ + sprintf(tmpbuf+strlen(tmpbuf), "%d total events, %.3f ticks per us\n", + (int)g_nevents, ticks_per_ns); +} diff --git a/src/tools/g2/g2.h b/src/tools/g2/g2.h new file mode 100644 index 00000000..1ab42191 --- /dev/null +++ b/src/tools/g2/g2.h @@ -0,0 +1,195 @@ +/* + *------------------------------------------------------------------ + * Copyright (c) 2005-2016 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * typedefs and so forth + */ +#include +#include +#include +#include "props.h" + +typedef char boolean; +typedef unsigned long long ulonglong; + +/* + * main.c + */ + +GtkWidget *g_mainwindow; +GtkWidget *g_mainvbox; +GtkWidget *g_mainhbox; + +/* + * pointsel.c + */ +void point_selector_init(void); +boolean read_event_definitions (char *filename); +char *sxerox(char *); +void pointsel_about(char *); +void pointsel_next_snapshot(void); +void initialize_events(void); +void finalize_events(void); + +#define NEVENTS 100000 + +typedef struct event_def_ { + ulong event; + char *name; + char *format; + boolean selected; + boolean is_clib; + char pad[2]; +} event_def_t; + +event_def_t *find_event_definition (ulong code); + +event_def_t g_eventdefs[NEVENTS]; + +/* + * config params + */ +int c_maxpointsel; /* max # points shown in selector dlg */ +gint c_view1_draw_width; +gint c_view1_draw_height; + +/* + * menu1.c + */ + +void menu1_init(void); +void modal_dialog (char *label_text, char *retry_text, char *default_value, + boolean (*cb)(char *)); +void infobox(char *label_text, char *text); +/* + * view1.c + */ +GdkFont *g_font; +GdkColor fg_black, bg_white; +void view1_init(void); +void view1_display(void); +void view1_read_events_callback(void); +void view1_display_when_idle(void); +void view1_print_callback(GtkToggleButton *item, gpointer data); +void view1_about(char *); +void set_pid_ax_width(int width); +void set_window_title(const char *filename); + +enum view1_tbox_fn { + TBOX_DRAW_BOXED = 1, /* note: order counts */ + TBOX_DRAW_EVENT, + TBOX_DRAW_PLAIN, + TBOX_PRINT_BOXED, + TBOX_PRINT_EVENT, + TBOX_PRINT_PLAIN, /* end restriction */ + TBOX_GETRECT_BOXED, + TBOX_GETRECT_EVENT, + TBOX_GETRECT_PLAIN, +}; + +enum view1_line_fn { + LINE_DRAW_BLACK = 1, + LINE_DRAW_WHITE, + LINE_PRINT, +}; + +GdkRectangle *tbox (char *s, int x, int y, enum view1_tbox_fn function); +void line (int x1, int y1, int x2, int y2, enum view1_line_fn function); +gint view1_handle_key_press_event (GtkWidget *widget, GdkEventKey *event); + +/* + * events.c + */ + +void events_about (char *); + +typedef struct raw_event { + unsigned long time[2]; + unsigned long pid; + unsigned long code; + unsigned long datum; +} raw_event_t; + +void event_init(void); +char *mapfile (char *file, ulong *sizep); +boolean unmapfile (char *addr, ulong size); +void read_events (char *); +int find_event_index (ulonglong t); +int read_cpel_file(char *file); +int read_clib_file(char *file); +void cpel_event_init(ulong); +void add_event_from_cpel_file(ulong, char * , char *); +void add_event_from_clib_file(unsigned int event, char *name, + unsigned int vec_index); +void add_cpel_event(ulonglong delta, ulong, ulong, ulong); +void add_clib_event(double delta, unsigned short track, + unsigned short event, unsigned int index); +void cpel_event_finalize(void); +void *get_clib_event (unsigned int datum); + +typedef struct pid_data { + struct pid_data *next; + ulong pid_value; /* The actual pid value */ + ulong pid_index; /* Index in pid sort order */ +} pid_data_t; + +#define EVENT_FLAG_SELECT 0x00000001 /* This event is selected */ +#define EVENT_FLAG_SEARCHRSLT 0x00000002 /* This event is the search rslt */ +#define EVENT_FLAG_CLIB 0x00000004 /* clib event */ + +typedef struct pid_sort { + struct pid_data *pid; + ulong pid_value; + /* + * This is a bit of a hack, since this is used only by the view: + */ + unsigned color_index; +} pid_sort_t; + +typedef struct event { + ulonglong time; + ulong code; + pid_data_t *pid; + ulong datum; + ulong flags; +} event_t; + + +boolean g_little_endian; +event_t *g_events; +ulong g_nevents; +pid_sort_t *g_pids; +pid_sort_t *g_original_pids; +int g_npids; +pid_data_t *g_pid_data_list; + +#define PIDHASH_NBUCKETS 20021 /* Should be prime */ + +boolean ticks_per_ns_set; +double ticks_per_ns; + +/* + * version.c + */ +const char *version_string; +const char *minor_v_string; + +/* + * cpel.c + */ +char *get_track_label(unsigned long); +int widest_track_format; +char *strtab_ref(unsigned long); diff --git a/src/tools/g2/g2version.c b/src/tools/g2/g2version.c new file mode 100644 index 00000000..4b6f9313 --- /dev/null +++ b/src/tools/g2/g2version.c @@ -0,0 +1,19 @@ +/* + *------------------------------------------------------------------ + * Copyright (c) 2005-2016 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +const char *version_string = "G2 (x86_64 GNU/Linux) major version 3.0"; +const char *minor_v_string = + "Built Wed Feb 3 10:58:12 EST 2016"; diff --git a/src/tools/g2/main.c b/src/tools/g2/main.c new file mode 100644 index 00000000..a782e17f --- /dev/null +++ b/src/tools/g2/main.c @@ -0,0 +1,196 @@ +/* + *------------------------------------------------------------------ + * Copyright (c) 2005-2016 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "g2.h" +#include "props.h" +#include +#include +#include +#include +#include + +/* + * globals + */ + +GtkWidget *g_mainwindow; /* The main window */ + +/* Graphical object heirarchy + * + * [main window] + * [main vbox] + * [main (e.g. file) menubar] + * [view hbox] + * [view bottom menu] + */ + +GtkWidget *g_mainvbox; +GtkWidget *g_mainhbox; + +gint delete_event(GtkWidget *widget, GdkEvent *event, gpointer data) +{ + /* Allow window to be destroyed */ + return(FALSE); +} + +void destroy(GtkWidget *widget, gpointer data) +{ + gtk_main_quit(); +} + +int main (int argc, char **argv) +{ + char tmpbuf [128]; + struct passwd *pw; + char *event_file = 0; + char *cpel_file = 0; + char *clib_file =0; + char *title = "none"; + int curarg=1; + char *homedir; + + gtk_init(&argc, &argv); + + homedir = getenv ("HOME"); + tmpbuf[0] = 0; + + if (homedir) { + sprintf(tmpbuf, "%s/.g2", homedir); + } else { + pw = getpwuid(geteuid()); + if (pw) { + sprintf(tmpbuf, "%s/.g2", pw->pw_dir); + } + } + if (tmpbuf[0]) + readprops(tmpbuf); + + g_mainwindow = gtk_window_new (GTK_WINDOW_TOPLEVEL); + + gtk_signal_connect (GTK_OBJECT(g_mainwindow), "delete_event", + GTK_SIGNAL_FUNC (delete_event), NULL); + + gtk_signal_connect (GTK_OBJECT(g_mainwindow), "destroy", + GTK_SIGNAL_FUNC (destroy), NULL); + + gtk_container_set_border_width(GTK_CONTAINER(g_mainwindow), 5); + + g_mainvbox = gtk_vbox_new(FALSE, 0); + g_mainhbox = gtk_hbox_new(FALSE, 0); + + /* + * init routines + */ + + menu1_init(); + point_selector_init(); + view1_init(); + event_init(); + + /* + * Now that we're ready to rock 'n roll, see if we've been asked to + * press a few buttons... + */ + + while (curarg < argc) { + if (!strncmp(argv[curarg], "--cpel-input", 4)) { + curarg++; + if (curarg < argc) { + cpel_file = argv[curarg]; + curarg++; + break; + } + g_error("Missing filename after --cpel-input"); + } + if (!strncmp(argv[curarg], "--clib-input", 4)) { + curarg++; + if (curarg < argc) { + clib_file = argv[curarg]; + curarg++; + break; + } + g_error("Missing filename after --cpel-input"); + } + + if (!strncmp(argv[curarg], "--pointdefs", 3)) { + curarg++; + if (curarg < argc) { + read_event_definitions(argv[curarg]); + curarg++; + continue; + } + g_error ("Missing filename after --pointdefs\n"); + } + if (!strncmp(argv[curarg], "--event-log", 3)) { + curarg++; + if (curarg < argc) { + event_file = argv[curarg]; + curarg++; + continue; + } + g_error ("Missing filename after --event-log\n"); + } + + if (!strncmp(argv[curarg], "--ticks-per-us", 3)) { + curarg++; + if (curarg < argc) { + ticks_per_ns = 0.0; + ticks_per_ns = atof(argv[curarg]); + if (ticks_per_ns == 0.0) { + g_error("ticks-per-ns (%s) didn't convert properly\n", + argv[curarg]); + } + ticks_per_ns_set = TRUE; + curarg++; + continue; + } + g_error ("Missing filename after --event-log\n"); + } + + fprintf(stderr, + "g2 [--pointdefs ] [--event-log ]\n"); + fprintf(stderr, " [--ticks-per-us ]\n"); + fprintf(stderr, + " [--cpel-input ] [--clib-input \n"); + fprintf(stderr, + "%s\n%s\n", version_string, minor_v_string); + exit(0); + } + + if (clib_file) { + read_clib_file (clib_file); + title = clib_file; + } else if (cpel_file) { + read_cpel_file(cpel_file); + title = cpel_file; + } else if (event_file) { + read_events(event_file); + title = event_file; + } + + set_window_title(title); + + gtk_signal_connect (GTK_OBJECT (g_mainwindow), "key_press_event", + (GtkSignalFunc) view1_handle_key_press_event, NULL); + gtk_container_add(GTK_CONTAINER(g_mainvbox), g_mainhbox); + gtk_widget_show(g_mainhbox); + gtk_container_add(GTK_CONTAINER(g_mainwindow), g_mainvbox); + gtk_widget_show(g_mainvbox); + gtk_widget_show(g_mainwindow); + + gtk_main(); + return(0); +} diff --git a/src/tools/g2/menu1.c b/src/tools/g2/menu1.c new file mode 100644 index 00000000..fce81fa6 --- /dev/null +++ b/src/tools/g2/menu1.c @@ -0,0 +1,565 @@ +/* + *------------------------------------------------------------------ + * Copyright (c) 2006-2016 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#define GTK_ENABLE_BROKEN // DGMS +#include +#include +#include "g2.h" +#include + +/* + * locals + */ +static GtkWidget *s_mainmenubar; +static GtkWidget *s_filemenu; +static GtkWidget *s_readdefs; +static GtkWidget *s_readevents; +static GtkWidget *s_readeventsclock; +static GtkWidget *s_readcpel; +static GtkWidget *s_readclib; +static GtkWidget *s_print; +static GtkWidget *s_quit; + +static GtkWidget *s_mainfilemenu; +static GtkWidget *s_help_general; +static GtkWidget *s_help_about; +static GtkWidget *s_mainhelpmenu; +static GtkWidget *s_helpmenu; + +static GtkWidget *s_filesel; +static GtkWidget *s_eventsel; + +typedef struct md_ { + GtkWidget *entry; + GtkWidget *label; + GtkWidget *dialog; + boolean (*callback)(char *); + char *retry_text; +} md_t; + +char *general_help = "\n" +"G2 is a performance event visualization tool.\n" +"\n" +"To view CPEL-format event data:\n" +"g2 --cpel \n" +"or use the File Menu->Read CPEL file option.\n" +"\n" +"To view vppinfra-format (.../open-repo/vppinfra/vppinfra/elog.h) event data:\n" +"g2 --clib \n" +"or use the File Menu->Read clib file option.\n" +"\n" +"To toggle event detail boxes, left-mouse-click on an event.\n" +"\n" +"To zoom to an area, depress the left mouse button. Move the\n" +"mouse. Release the mouse.\n" +"\n" +"To use the time ruler, depress the right mouse button. Move the\n" +"mouse. Release when done.\n" +"\n" +"To push a track to the bottom, \n" +"\n" +"To pull a track to the top, \n" +"\n" +"To selectively color/uncolor a track, \n" +"\n" +"To make the mouse scrollwheel faster, press \n" +"\n" +"Hotkeys, supposedly Quake-like:\n" +" w - zoom-in\n" +" s - zoom-out\n" +" a - pan-left\n" +" d - pan-right\n" +" r - pan-up\n" +" f - pan-down\n" +" t - less traces\n" +" g - more traces\n" +"\n" +" e - toggle summary-mode\n" +" c - toggle color-mode\n" +"\n" +" x - take snapshot\n" +" z - go to next snapshot\n" +" p - put snapshots to snapshots.g2 \n" +" l - load snapshots from snapshots.g2\n" +"\n" +"q - quit\n" +"Send comments / bug reports to the \"fd.io\" mailing list.\n"; + +/**************************************************************************** +* debug_dialog_callback +****************************************************************************/ + +boolean debug_dialog_callback (char *s) +{ + g_print("Dialog result: %s", s); + return (TRUE); +} + +/**************************************************************************** +* get_dialog_value +****************************************************************************/ + +static void get_dialog_value (GtkWidget *dialog, gpointer user_data) +{ + md_t *md = (md_t *)user_data; + char * cb_arg; + + cb_arg = (char *) gtk_entry_get_text(GTK_ENTRY(md->entry)); + + if ((*md->callback)(cb_arg)) { + gtk_grab_remove(md->dialog); + gtk_widget_destroy(md->dialog); + } else { + gtk_label_set_text (GTK_LABEL(md->label), md->retry_text); + } +} + +/**************************************************************************** +* modal_dialog +****************************************************************************/ + +void modal_dialog (char *label_text, char *retry_text, char *default_value, + boolean (*cb)(char *)) +{ + GtkWidget *dialog, *label, *ok_button, *entry; + static md_t dlg; + md_t *md = &dlg; + + dialog = gtk_dialog_new(); + label = gtk_label_new(label_text); + + entry = gtk_entry_new(); + if (default_value) + gtk_entry_set_text(GTK_ENTRY(entry), default_value); + + ok_button = gtk_button_new_with_label("OK"); + + md->entry = entry; + md->label = label; + md->retry_text = retry_text; + md->dialog = dialog; + if (cb) + md->callback = cb; + else + md->callback = debug_dialog_callback; + + gtk_signal_connect (GTK_OBJECT (ok_button), "clicked", + GTK_SIGNAL_FUNC(get_dialog_value), (gpointer) md); + + gtk_signal_connect (GTK_OBJECT (entry), "activate", + GTK_SIGNAL_FUNC(get_dialog_value), (gpointer) md); + + gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->action_area), + entry); + + gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->action_area), + ok_button); + gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), label); + gtk_widget_show_all(dialog); + gtk_widget_grab_focus(entry); + gtk_grab_add(dialog); +} + +/**************************************************************************** +* get_eventdef_name +****************************************************************************/ + +static void get_eventdef_name (GtkFileSelection *sel, gpointer user_data) +{ + char *filename = (char *) gtk_file_selection_get_filename ( + GTK_FILE_SELECTION(s_filesel)); + read_event_definitions(filename); + set_window_title(filename); +} + +/**************************************************************************** +* read_eventdef_callback +****************************************************************************/ + +static void read_eventdef_callback(GtkToggleButton *item, gpointer data) +{ + + s_filesel = gtk_file_selection_new("Read Event Definitions From..."); + + gtk_file_selection_set_filename(GTK_FILE_SELECTION(s_filesel), + "../h/elog.h"); + + gtk_signal_connect (GTK_OBJECT ( + GTK_FILE_SELECTION(s_filesel)->ok_button), + "clicked", + GTK_SIGNAL_FUNC(get_eventdef_name), NULL); + + gtk_signal_connect_object (GTK_OBJECT ( + GTK_FILE_SELECTION(s_filesel)->ok_button), + "clicked", + GTK_SIGNAL_FUNC (gtk_widget_destroy), + (gpointer) s_filesel); + + gtk_signal_connect_object (GTK_OBJECT ( + GTK_FILE_SELECTION(s_filesel)->cancel_button), + "clicked", + GTK_SIGNAL_FUNC (gtk_widget_destroy), + (gpointer) s_filesel); + gtk_file_selection_hide_fileop_buttons(GTK_FILE_SELECTION(s_filesel)); + gtk_widget_show (s_filesel); +} + +/**************************************************************************** +* get_events_name +****************************************************************************/ + +static void get_events_name (GtkFileSelection *sel, gpointer user_data) +{ + char *filename = (char *) gtk_file_selection_get_filename ( + GTK_FILE_SELECTION(s_eventsel)); + read_events(filename); + view1_display_when_idle(); +} + + +/**************************************************************************** +* get_ticks_per_ns +****************************************************************************/ + +static boolean get_ticks_per_ns (char *value) +{ + double rv; + + rv = atof (value); + + if (rv == 0.0 || rv > 100000) + return(FALSE); + + ticks_per_ns = rv; + ticks_per_ns_set = TRUE; + + gtk_widget_show(s_eventsel); + return(TRUE); +} + +/**************************************************************************** +* read_events_callback +****************************************************************************/ + +static void read_events_callback(GtkToggleButton *item, gpointer data) +{ + char tmpbuf [32]; + + s_eventsel = gtk_file_selection_new("Read Events From..."); + + gtk_signal_connect (GTK_OBJECT ( + GTK_FILE_SELECTION(s_eventsel)->ok_button), + "clicked", + GTK_SIGNAL_FUNC(get_events_name), NULL); + + gtk_signal_connect_object (GTK_OBJECT ( + GTK_FILE_SELECTION(s_eventsel)->ok_button), + "clicked", + GTK_SIGNAL_FUNC (gtk_widget_destroy), + (gpointer) s_eventsel); + + gtk_signal_connect_object (GTK_OBJECT ( + GTK_FILE_SELECTION(s_eventsel)->cancel_button), + "clicked", + GTK_SIGNAL_FUNC (gtk_widget_destroy), + (gpointer) s_eventsel); + gtk_file_selection_hide_fileop_buttons(GTK_FILE_SELECTION(s_eventsel)); + + if (ticks_per_ns_set) + gtk_widget_show (s_eventsel); + else { + sprintf(tmpbuf, "%.3f", ticks_per_ns); + modal_dialog ("Please enter clock ticks per nanosecond", + "Invalid: Please enter clock ticks per nanosecond", + tmpbuf, get_ticks_per_ns); + } +} + +/**************************************************************************** +* read_eventclock_callback +****************************************************************************/ + +static void read_eventsclock_callback(GtkToggleButton *item, gpointer data) +{ + ticks_per_ns_set = FALSE; + read_events_callback(item, data); +} + +/**************************************************************************** +* infobox_size_request +****************************************************************************/ + +void infobox_size_request (GtkWidget *widget, GtkRequisition *req, + gpointer user_data) +{ + char *text = (char *)user_data; + char *cp; + int widest_line_in_chars; + int w; + int nlines; + + /* + * You'd think that the string extent function would work here. + * You'd be wrong. + */ + nlines = w = widest_line_in_chars = 0; + for (cp = text; *cp; cp++) { + if (*cp == '\n') { + if (w > widest_line_in_chars) { + widest_line_in_chars = w; + } + w = 0; + nlines++; + } + w++; + } + + nlines++; + + req->width = (widest_line_in_chars * 8) + 20; + req->height = (nlines * 13) + 10; +} + +/**************************************************************************** +* infobox +****************************************************************************/ + +void infobox(char *label_text, char *text) +{ + GtkWidget *dialog, *label, *ok_button, *entry; + GtkWidget *box; + + dialog = gtk_dialog_new(); + label = gtk_label_new(label_text); + + entry = gtk_text_new(NULL, NULL); + + gtk_signal_connect (GTK_OBJECT (entry), "size-request", + GTK_SIGNAL_FUNC(infobox_size_request), + (gpointer) text); + + gtk_text_insert(GTK_TEXT(entry), g_font, &fg_black, &bg_white, + text, -1); + + gtk_text_set_editable(GTK_TEXT(entry), FALSE); + + ok_button = gtk_button_new_with_label("OK"); + + gtk_signal_connect_object (GTK_OBJECT (ok_button), "clicked", + GTK_SIGNAL_FUNC(gtk_widget_destroy), + (gpointer) GTK_OBJECT(dialog)); + + box = gtk_vbox_new(FALSE, 5); + + + gtk_box_pack_start(GTK_BOX(box), entry, TRUE, TRUE, 0); + gtk_box_pack_start(GTK_BOX(box), ok_button, FALSE, FALSE, 0); + + gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->action_area), + box); + + gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), label); + gtk_widget_show_all(dialog); +} + +/**************************************************************************** +* help_general_callback +****************************************************************************/ + +static void help_general_callback(GtkToggleButton *item, gpointer data) +{ + infobox("General Help", general_help); +} + +/**************************************************************************** +* help_about_callback +****************************************************************************/ + +static void help_about_callback(GtkToggleButton *item, gpointer data) +{ + char tmpbuf [1024]; + sprintf (tmpbuf, "G2 -- Graphical Event Viewer\n\n"); + view1_about(tmpbuf); + pointsel_about(tmpbuf); + events_about(tmpbuf); + sprintf (tmpbuf+strlen(tmpbuf), "\n%s\n", version_string); + sprintf (tmpbuf+strlen(tmpbuf), "%s\n", minor_v_string); + infobox("About", tmpbuf); +} + + +/**************************************************************************** +* get_cpel_name +****************************************************************************/ + +static void get_cpel_name (GtkFileSelection *sel, gpointer user_data) +{ + char *filename = (char *)gtk_file_selection_get_filename ( + GTK_FILE_SELECTION(s_filesel)); + read_cpel_file(filename); + set_window_title(filename); +} + +/**************************************************************************** +* get_clib_name +****************************************************************************/ + +static void get_clib_name (GtkFileSelection *sel, gpointer user_data) +{ + char *filename = (char *) gtk_file_selection_get_filename ( + GTK_FILE_SELECTION(s_filesel)); + read_clib_file(filename); + set_window_title(filename); +} + +/**************************************************************************** +* read_cpel_callback +****************************************************************************/ + +static void read_cpel_callback(GtkToggleButton *item, gpointer data) +{ + + s_filesel = gtk_file_selection_new("Read CPEL data from..."); + + gtk_file_selection_set_filename(GTK_FILE_SELECTION(s_filesel), + "cpel.out"); + + gtk_signal_connect (GTK_OBJECT ( + GTK_FILE_SELECTION(s_filesel)->ok_button), + "clicked", + GTK_SIGNAL_FUNC(get_cpel_name), NULL); + + gtk_signal_connect_object (GTK_OBJECT ( + GTK_FILE_SELECTION(s_filesel)->ok_button), + "clicked", + GTK_SIGNAL_FUNC (gtk_widget_destroy), + (gpointer) s_filesel); + + gtk_signal_connect_object (GTK_OBJECT ( + GTK_FILE_SELECTION(s_filesel)->cancel_button), + "clicked", + GTK_SIGNAL_FUNC (gtk_widget_destroy), + (gpointer) s_filesel); + gtk_file_selection_hide_fileop_buttons(GTK_FILE_SELECTION(s_filesel)); + gtk_widget_show (s_filesel); +} + +/**************************************************************************** +* read_clib_callback +****************************************************************************/ + +static void read_clib_callback(GtkToggleButton *item, gpointer data) +{ + + s_filesel = gtk_file_selection_new("Read clib data From..."); + + gtk_file_selection_set_filename(GTK_FILE_SELECTION(s_filesel), + "clib.out"); + + gtk_signal_connect (GTK_OBJECT ( + GTK_FILE_SELECTION(s_filesel)->ok_button), + "clicked", + GTK_SIGNAL_FUNC(get_clib_name), NULL); + + gtk_signal_connect_object (GTK_OBJECT ( + GTK_FILE_SELECTION(s_filesel)->ok_button), + "clicked", + GTK_SIGNAL_FUNC (gtk_widget_destroy), + (gpointer) s_filesel); + + gtk_signal_connect_object (GTK_OBJECT ( + GTK_FILE_SELECTION(s_filesel)->cancel_button), + "clicked", + GTK_SIGNAL_FUNC (gtk_widget_destroy), + (gpointer) s_filesel); + gtk_file_selection_hide_fileop_buttons(GTK_FILE_SELECTION(s_filesel)); + gtk_widget_show (s_filesel); +} + +/**************************************************************************** +* menu1_init +****************************************************************************/ + +void menu1_init(void) +{ + + s_filemenu = gtk_menu_new(); + + s_readcpel = gtk_menu_item_new_with_label + ("Read CPEL file"); + gtk_menu_append(GTK_MENU(s_filemenu), s_readcpel); + gtk_signal_connect(GTK_OBJECT(s_readcpel), "activate", + GTK_SIGNAL_FUNC(read_cpel_callback), 0); + + s_readclib = gtk_menu_item_new_with_label + ("Read CLIB file"); + gtk_menu_append(GTK_MENU(s_filemenu), s_readclib); + gtk_signal_connect(GTK_OBJECT(s_readclib), "activate", + GTK_SIGNAL_FUNC(read_clib_callback), 0); + + s_readdefs = gtk_menu_item_new_with_label ("Read Event Definitions"); + gtk_menu_append(GTK_MENU(s_filemenu), s_readdefs); + gtk_signal_connect(GTK_OBJECT(s_readdefs), "activate", + GTK_SIGNAL_FUNC(read_eventdef_callback), 0); + + s_readevents = gtk_menu_item_new_with_label ("Read Event Log"); + gtk_menu_append(GTK_MENU(s_filemenu), s_readevents); + gtk_signal_connect(GTK_OBJECT(s_readevents), "activate", + GTK_SIGNAL_FUNC(read_events_callback), 0); + + s_readeventsclock = gtk_menu_item_new_with_label + ("Read Event Log with Different Clock Rate"); + gtk_menu_append(GTK_MENU(s_filemenu), s_readeventsclock); + gtk_signal_connect(GTK_OBJECT(s_readeventsclock), "activate", + GTK_SIGNAL_FUNC(read_eventsclock_callback), 0); + + s_print = gtk_menu_item_new_with_label ("Print"); + gtk_menu_append(GTK_MENU(s_filemenu), s_print); + gtk_signal_connect(GTK_OBJECT(s_print), "activate", + GTK_SIGNAL_FUNC(view1_print_callback), 0); + + s_quit = gtk_menu_item_new_with_label ("Exit"); + gtk_menu_append(GTK_MENU(s_filemenu), s_quit); + gtk_signal_connect(GTK_OBJECT(s_quit), "activate", + GTK_SIGNAL_FUNC(gtk_main_quit), 0); + + s_mainfilemenu = gtk_menu_item_new_with_label("File"); + gtk_menu_item_set_submenu(GTK_MENU_ITEM(s_mainfilemenu), s_filemenu); + + s_helpmenu = gtk_menu_new(); + + s_help_general = gtk_menu_item_new_with_label ("General"); + gtk_menu_append(GTK_MENU(s_helpmenu), s_help_general); + gtk_signal_connect(GTK_OBJECT(s_help_general), "activate", + GTK_SIGNAL_FUNC(help_general_callback), 0); + + s_help_about = gtk_menu_item_new_with_label ("About"); + gtk_menu_append(GTK_MENU(s_helpmenu), s_help_about); + gtk_signal_connect(GTK_OBJECT(s_help_about), "activate", + GTK_SIGNAL_FUNC(help_about_callback), 0); + + s_mainhelpmenu = gtk_menu_item_new_with_label("Help"); + gtk_menu_item_set_submenu(GTK_MENU_ITEM(s_mainhelpmenu), s_helpmenu); + + s_mainmenubar = gtk_menu_bar_new(); + gtk_menu_bar_append(GTK_MENU_BAR(s_mainmenubar), s_mainfilemenu); + gtk_menu_bar_append(GTK_MENU_BAR(s_mainmenubar), s_mainhelpmenu); + gtk_widget_show_all(s_mainmenubar); + + gtk_box_pack_start(GTK_BOX(g_mainvbox), s_mainmenubar, FALSE, FALSE, 0); +} diff --git a/src/tools/g2/mkversion.c b/src/tools/g2/mkversion.c new file mode 100644 index 00000000..3523fbe6 --- /dev/null +++ b/src/tools/g2/mkversion.c @@ -0,0 +1,77 @@ +/* + *------------------------------------------------------------------ + * Copyright (c) 1997-2016 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include + +int main (int argc, char **argv) +{ + time_t now; + FILE *ofp; + char *dateval; + char *username; + char *userstr; + char *datestr; + int i; + char propname[32]; + char *propvalue; + char timestr[64]; + char *cp; + + if (argc < 4) { + printf ("usage: mkversion ostype version outputfile\n"); + exit (1); + } + + ofp = fopen (argv[3], "w"); + if (ofp == NULL) { + printf ("Couldn't create %s\n", argv[3]); + exit (1); + } + + now = time (0); + + fprintf (ofp, "/*\n"); + fprintf (ofp, " * G2 Version Stamp, %s", + ctime (&now)); + fprintf (ofp, " * Automatically generated, hand edits are pointless.\n"); + fprintf (ofp, " */\n\n"); + + fprintf (ofp, + "const char *version_string = \"G2 (%s) major version %s\";\n", + argv[1], argv[2]); + + username = (char *) cuserid (0); + + strcpy(timestr, ctime(&now)); + + cp = timestr; + + while (*cp) { + cp++; + } + if (*--cp == '\n') + *cp = 0; + + fprintf (ofp, + "const char *minor_v_string = \"Built by %s at %s\";\n", + username, timestr); + + exit (0); +} + + diff --git a/src/tools/g2/pointsel.c b/src/tools/g2/pointsel.c new file mode 100644 index 00000000..018dc213 --- /dev/null +++ b/src/tools/g2/pointsel.c @@ -0,0 +1,854 @@ +/* + *------------------------------------------------------------------ + * Copyright (c) 2005-2016 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include +#include +#include +#include "g2.h" + +/* + * globals + */ +event_def_t g_eventdefs[NEVENTS]; + +/* + * locals + */ +static GtkWidget *s_pointselbox; +static FILE *s_hfp; +static FILE *s_elog_hfp; +static int s_basenum; +static GtkWidget *s_event_buttons[NEVENTS]; +static int s_min_shown_pointsel; +static int s_max_shown_pointsel; +static GtkWidget *s_allbutton; +static GtkWidget *s_nonebutton; +static GtkWidget *s_pointselbuttons; +static GtkWidget *s_ps_vscroll; +static GtkObject *s_ps_vsadj; +static int g_neventdefs; + +enum button_click { + ALL_BUTTON=1, + NONE_BUTTON, +}; + +/* + * config params + */ +int c_maxpointsel; + +/**************************************************************************** +* recompute_vscrollbar +****************************************************************************/ + +static void recompute_ps_vscrollbar (void) +{ + GtkAdjustment *adj; + ulong limit; + + adj = GTK_ADJUSTMENT(s_ps_vsadj); + +#ifdef NOTDEF + /* This seems like the right calculation, but seems not to work */ + if (g_neventdefs > c_maxpointsel) + limit = g_neventdefs - c_maxpointsel; + else + limit = g_neventdefs; +#else + limit = g_neventdefs-1; +#endif + + adj->lower = (gfloat)0.00; + adj->upper = (gfloat)limit; + adj->value = (gfloat)0.00; + adj->step_increment = (gfloat)1.00; + adj->page_increment = (gfloat)(c_maxpointsel / 3); + adj->page_size = (gfloat)c_maxpointsel; + gtk_adjustment_changed(adj); + gtk_adjustment_value_changed(adj); + gtk_widget_show(s_ps_vscroll); +} + +/**************************************************************************** +* point_select_callback +****************************************************************************/ + +static void point_select_callback(GtkToggleButton *item, gpointer data) +{ + int i = (int) (unsigned long long) data; + + g_eventdefs[i].selected = gtk_toggle_button_get_active( + GTK_TOGGLE_BUTTON(s_event_buttons[i])); + view1_display_when_idle(); +} + +/**************************************************************************** +* up_button +****************************************************************************/ + +static void up_button(void) +{ + int i; + int increment = c_maxpointsel/4; + + if (s_min_shown_pointsel == 0) + return; + + s_min_shown_pointsel -= increment; + + if (s_min_shown_pointsel < 0) + s_min_shown_pointsel = 0; + + s_max_shown_pointsel = s_min_shown_pointsel + c_maxpointsel; + + for (i = 0; i < g_neventdefs; i++) { + if (i >= s_min_shown_pointsel && + i <= s_max_shown_pointsel) + gtk_widget_show(s_event_buttons[i]); + else + gtk_widget_hide(s_event_buttons[i]); + } + +} + +#ifdef NOTDEF +/**************************************************************************** +* down_button +****************************************************************************/ + +static void down_button(void) +{ + int i; + int increment = c_maxpointsel/4; + + if (s_max_shown_pointsel == g_neventdefs) + return; + + s_max_shown_pointsel += increment; + + if (s_max_shown_pointsel >= g_neventdefs) + s_max_shown_pointsel = (g_neventdefs-1); + + s_min_shown_pointsel = s_max_shown_pointsel - c_maxpointsel; + + if (s_min_shown_pointsel < 0) + s_min_shown_pointsel = 0; + + for (i = 0; i < g_neventdefs; i++) { + if (i >= s_min_shown_pointsel && + i <= s_max_shown_pointsel) + gtk_widget_show(s_event_buttons[i]); + else + gtk_widget_hide(s_event_buttons[i]); + } + +} +#endif + +/**************************************************************************** +* button_click_callback +****************************************************************************/ + +static void button_click_callback(GtkButton *item, gpointer data) +{ + int i; + enum button_click click = (enum button_click)data; + + switch (click) { + case ALL_BUTTON: + for (i = 0; i < g_neventdefs; i++) { + gtk_toggle_button_set_active ( + GTK_TOGGLE_BUTTON(s_event_buttons[i]), TRUE); + g_eventdefs[i].selected = TRUE; + } + break; + + case NONE_BUTTON: + for (i = 0; i < g_neventdefs; i++) { + gtk_toggle_button_set_active ( + GTK_TOGGLE_BUTTON(s_event_buttons[i]), FALSE); + g_eventdefs[i].selected = FALSE; + } + break; + } +} + +/**************************************************************************** +* scroll_callback +****************************************************************************/ + +static void scroll_callback (GtkAdjustment *adj, GtkWidget *notused) +{ + int i; + + s_min_shown_pointsel = (int)adj->value; + s_max_shown_pointsel = s_min_shown_pointsel + c_maxpointsel; + + for (i = 0; i < g_neventdefs; i++) { + if (i >= s_min_shown_pointsel && + i <= s_max_shown_pointsel) + gtk_widget_show(s_event_buttons[i]); + else + gtk_widget_hide(s_event_buttons[i]); + } +} + +/**************************************************************************** +* point_selector_init +****************************************************************************/ + +void point_selector_init(void) +{ + + c_maxpointsel = atol(getprop_default("event_selector_lines", "20")); + + s_pointselbox = gtk_vbox_new(FALSE,5); + + s_pointselbuttons = gtk_hbox_new(FALSE,5); + + s_allbutton = gtk_button_new_with_label("ALL"); + gtk_widget_show(s_allbutton); + s_nonebutton = gtk_button_new_with_label("NONE"); + gtk_widget_show(s_nonebutton); + + gtk_signal_connect (GTK_OBJECT(s_allbutton), "clicked", + GTK_SIGNAL_FUNC(button_click_callback), + (gpointer) ALL_BUTTON); + + gtk_signal_connect (GTK_OBJECT(s_nonebutton), "clicked", + GTK_SIGNAL_FUNC(button_click_callback), + (gpointer) NONE_BUTTON); + + gtk_box_pack_start(GTK_BOX(s_pointselbuttons), s_allbutton, FALSE, + FALSE, 0); + gtk_box_pack_start(GTK_BOX(s_pointselbuttons), s_nonebutton, FALSE, + FALSE, 0); + + gtk_widget_show(s_pointselbuttons); + gtk_widget_ref(s_pointselbuttons); + + gtk_box_pack_start(GTK_BOX(s_pointselbox), s_pointselbuttons, FALSE, + FALSE, 0); + + gtk_box_pack_end (GTK_BOX(g_mainhbox), s_pointselbox, + FALSE, FALSE, 0); + + s_ps_vsadj = gtk_adjustment_new(0.0 /* initial value */, + 0.0 /* minimum value */, + 2000.0 /* maximum value */, + 0.1 /* step increment */, + 10.0/* page increment */, + 10.0/* page size */); + + s_ps_vscroll = gtk_vscrollbar_new (GTK_ADJUSTMENT(s_ps_vsadj)); + gtk_signal_connect (GTK_OBJECT (s_ps_vsadj), "value-changed", + GTK_SIGNAL_FUNC (scroll_callback), + (gpointer)s_ps_vscroll); + gtk_box_pack_end(GTK_BOX(g_mainhbox), s_ps_vscroll, FALSE, FALSE, 0); +} + +/**************************************************************************** +* sxerox +****************************************************************************/ + +char *sxerox (char *s) +{ + char *rv; + + /* Note: g_malloc does or dies... */ + rv = (char *)g_malloc(strlen(s)+1); + strcpy (rv, s); + return (rv); +} + +/**************************************************************************** +* reset_point_selector +****************************************************************************/ + +static void reset_point_selector(void) +{ + int i; + + gtk_widget_hide(s_pointselbox); + gtk_widget_hide(s_pointselbuttons); + gtk_widget_hide(s_ps_vscroll); + gtk_container_remove(GTK_CONTAINER(s_pointselbox), + s_pointselbuttons); + + for (i = 0; i < g_neventdefs; i++) { + if (s_event_buttons[i]) { + gtk_container_remove(GTK_CONTAINER(s_pointselbox), + s_event_buttons[i]); + s_event_buttons[i] = 0; + } + } +} + +/**************************************************************************** +* create_point_selector +****************************************************************************/ + +static void create_point_selector(void) +{ + int i; + char tmpbuf [1024]; + event_def_t *ep; + GtkWidget *wp; + + for (i = 0; i < g_neventdefs; i++) { + ep = &g_eventdefs[i]; + sprintf(tmpbuf, "[%lu] %s", ep->event, + ep->name ? ep->name : "(none)"); + /* Hack to reduce width of point selectors */ + if (strlen(tmpbuf) > 50) { + tmpbuf[50] = 0; + } + + wp = gtk_check_button_new_with_label (tmpbuf); + s_event_buttons[i] = wp; + gtk_signal_connect (GTK_OBJECT(wp), "toggled", + GTK_SIGNAL_FUNC(point_select_callback), + (gpointer) (unsigned long long) i); + gtk_toggle_button_set_active ( + GTK_TOGGLE_BUTTON(wp), TRUE); + gtk_box_pack_start(GTK_BOX(s_pointselbox), wp, FALSE, FALSE, 0); + } + + /* set up scroll parameters by faking an up-button */ + s_min_shown_pointsel = 1; + up_button(); + + gtk_box_pack_start(GTK_BOX(s_pointselbox), s_pointselbuttons, FALSE, + FALSE, 0); + gtk_widget_show(s_pointselbuttons); + gtk_widget_show(s_pointselbox); + gtk_widget_show(s_ps_vscroll); +} + +/**************************************************************************** +* remove_all_events +****************************************************************************/ + +static void remove_all_events(void) +{ + event_def_t *ep; + int i; + + for (i = 0; i < g_neventdefs; i++) { + ep = &g_eventdefs[i]; + if (!ep->is_clib) { + if (ep->name) + g_free(ep->name); + if(ep->format) + g_free(ep->format); + } + } + g_neventdefs = 0; +} + +/**************************************************************************** +* add_event +****************************************************************************/ + +static void add_event(ulong event, char *name, char *format) +{ + int i; + event_def_t *ep; + + if (g_neventdefs >= NEVENTS) { + g_error("Too many event definitions, increase NEVENTS!"); + /*NOTREACHED*/ + } + + /* Simple dup check, probably not needed very often */ + for (i = 0; i < g_neventdefs; i++) { + if (g_eventdefs[i].event == event) { + g_warning("Duplicate def event %lu: first definition retained\n", + event); + return; + } + } + + ep = &g_eventdefs[g_neventdefs++]; + + ep->event = event; + ep->name = sxerox(name); + ep->format = sxerox(format); + ep->selected = TRUE; +} + +/**************************************************************************** +* add_event_from_cpel_file +****************************************************************************/ + +void add_event_from_cpel_file(ulong event, char *event_format, + char *datum_format) +{ + event_def_t *ep; + + if (g_neventdefs >= NEVENTS) { + g_error("Too many event definitions, increase NEVENTS!"); + /*NOTREACHED*/ + } + + ep = &g_eventdefs[g_neventdefs++]; + + ep->event = event; + /* + * Duplicate the strings for backward compatibility. Otherwise, + * the g_free above will barf because the name/format strings are + * actually in mmap'ed memory + */ + ep->name = sxerox(event_format); + ep->format = sxerox(datum_format); + ep->selected = TRUE; +} + +/**************************************************************************** +* add_event_from_clib_file +****************************************************************************/ + +void add_event_from_clib_file(unsigned int event, char *name, + unsigned int vec_index) +{ + event_def_t *ep; + + if (g_neventdefs >= NEVENTS) { + g_error("Too many event definitions, increase NEVENTS!"); + /*NOTREACHED*/ + } + + ep = &g_eventdefs[g_neventdefs++]; + + ep->event = event; + + ep->name = sxerox(name); + ep->format = (void *)(unsigned long long) vec_index; + ep->selected = TRUE; + ep->is_clib = TRUE; +} + +/**************************************************************************** +* read_header_file - eats header file lines of the form +* +* #define EVENT_FOO 123 / * name: %d * / +* +****************************************************************************/ + +static void read_header_file (void) +{ + char tmpbuf [1024]; + char *name, *format; + char *cp; + unsigned long event; + int ev_num_flag; + + while (fgets (tmpbuf, sizeof (tmpbuf), s_hfp)) + { + cp = tmpbuf; + ev_num_flag = 0; + + if (strncmp (cp, "#define", 7)) + continue; + + /* skip #define */ + while (*cp && !(isspace ((int)*cp))) + cp++; + + if (*cp == 0) + continue; + + /* skip ws after #define */ + while (*cp && isspace ((int)*cp)) + cp++; + + if (*cp == 0) + continue; + + /* skip symbolic name */ + while (*cp && !(isspace ((int)*cp))) + cp++; + + if (*cp == 0) + continue; + + /* skip ws after symbolic name */ + while (*cp && isspace ((int)*cp)) + cp++; + + if (*cp == 0) + continue; + + event = 0; + + if (!strncmp(cp, "EV_NUM", 6)) { + cp += 6; + ev_num_flag = 1; + + while (*cp && *cp != '(') + cp++; + + if (*cp == 0) + continue; + + cp++; + + while (*cp && isspace ((int)*cp)) + cp++; + + } + + /* eat event code. */ + while (*cp && isdigit ((int)*cp)) + { + event = event * 10 + (*cp - '0'); + cp++; + } + + if (*cp == 0) + continue; + + if (ev_num_flag) { + while (*cp && *cp != ')') + cp++; + if (*cp == 0) + continue; + cp++; + event += s_basenum; + } + + /* skip ws after event code */ + while (*cp && isspace ((int)*cp)) + cp++; + + if (*cp != '/') + continue; + + cp++; + + if (*cp != '*') + continue; + + cp++; + + /* skip ws after comment start */ + while (*cp && isspace ((int)*cp)) + cp++; + + if (*cp == 0) + continue; + + name = cp; + + /* accumulate name */ + while (*cp && *cp != ':' && *cp != '*') + cp++; + + if (*cp == 0) + continue; + + *cp++ = 0; + + /* skip ws after name: */ + while (*cp && isspace ((int)*cp)) + cp++; + + if (*cp == 0 || *cp == '/') + { + format = " "; + goto write_it; + } + + format = cp; + + /* accumulate format string */ + while (*cp && !isspace ((int)*cp)) + cp++; + + *cp = 0; + + write_it: + + add_event (event, name, format); + } +} + +/**************************************************************************** +* read_header_files - eats header file lines of the form +* +* #define FILE1_BASE 100 / * pointdefs: ../vpn/vpn_points.h * / +* +****************************************************************************/ + +static boolean read_header_files (void) +{ + char *cp, *name; + char tmpbuf [1024]; + int basenum; + boolean rv=FALSE; + + while (fgets (tmpbuf, sizeof (tmpbuf), s_elog_hfp)) + { + cp = tmpbuf; + + if (strncmp (cp, "#define", 7)) + continue; + + cp += 7; + + /* skip ws after #define */ + while (*cp && isspace ((int)*cp)) + cp++; + + if (*cp == 0) + continue; + + /* skip EV_COMPxxx_START */ + while (*cp && !isspace((int)*cp)) + cp++; + + if (*cp == 0) + continue; + + /* skip ws after EV_COMPxxx_START */ + while (*cp && isspace ((int)*cp)) + cp++; + + if (*cp == 0) + continue; + + basenum = atol (cp); + + /* skip #define */ + while (*cp && (*cp != '/')) + cp++; + + if (*cp == 0) + continue; + + cp++; + if (*cp != '*') + continue; + + cp++; + + /* skip ws after comment start */ + while (*cp && isspace ((int)*cp)) + cp++; + + if (*cp == 0) + continue; + + if (strncmp (cp, "pointdefs:", 10)) + continue; + + cp += 10; + + /* skip ws after comment start */ + while (*cp && isspace ((int)*cp)) + cp++; + + name = cp; + + while (*cp && !isspace ((int)*cp)) + cp++; + + *cp = 0; + + s_hfp = fopen (name, "rt"); + + if (s_hfp == NULL) { + g_warning ("Couldn't open header file %s\n", name); + continue; + } + rv = TRUE; + + s_basenum = basenum; + + read_header_file(); + + fclose (s_hfp); + } + return(rv); +} + +/**************************************************************************** +* event_def_cmp +****************************************************************************/ + +int event_def_cmp(const void *a1, const void *a2) +{ + event_def_t *e1 = (event_def_t *)a1; + event_def_t *e2 = (event_def_t *)a2; + + if (e1->event < e2->event) + return(-1); + else if (e1->event == e2->event) + return(0); + else + return(1); +} + +/**************************************************************************** +* sort_event_definitions +****************************************************************************/ + +void sort_event_definitions(void) +{ + qsort(&g_eventdefs[0], g_neventdefs, sizeof(event_def_t), event_def_cmp); +} + +static boolean remove_needed=TRUE; + +void finalize_events(void) +{ + sort_event_definitions(); + create_point_selector(); + recompute_ps_vscrollbar(); + view1_display_when_idle(); + remove_needed = TRUE; +} + +void initialize_events(void) +{ + if (remove_needed) { + reset_point_selector(); + remove_all_events(); + remove_needed = FALSE; + } +} + +/**************************************************************************** +* read_event_definitions +****************************************************************************/ + +boolean read_event_definitions (char *filename) +{ + char tmpbuf [128]; + + initialize_events(); + + s_elog_hfp = fopen (filename, "rt"); + if (s_elog_hfp == NULL) { + sprintf (tmpbuf, "Couldn't open %s\n", filename); + infobox ("Open Failed", tmpbuf); + return(FALSE); + } + /* Presume "elog.h". Note fallthrough... */ + if (read_header_files()) { + sort_event_definitions(); + create_point_selector(); + recompute_ps_vscrollbar(); + fclose(s_elog_hfp); + view1_display_when_idle(); + remove_needed = TRUE; + return(TRUE); + } + fclose(s_elog_hfp); + + s_hfp = fopen (filename, "rt"); + if (s_hfp == NULL) { + sprintf (tmpbuf, "Couldn't open %s\n", filename); + infobox ("Read Event Definition Failure", tmpbuf); + return(FALSE); + } + + read_header_file(); + + /* Happens if the user feeds us the wrong file, for example */ + if (g_neventdefs == 0) { + sprintf (tmpbuf, "No event definitions found in %s\n", filename); + infobox ("No Event Definitions?", tmpbuf); + return(FALSE); + } + finalize_events(); + return(TRUE); +} + +static event_def_t dummy_event; +static char dummy_string[32]; + +/**************************************************************************** +* find_event_definition +* Binary search for first event whose time is >= t +****************************************************************************/ + +event_def_t *find_event_definition (ulong code) +{ + int index, bottom, top; + event_def_t *edp; + + if (g_neventdefs == 0) + goto use_dummy; + + bottom = g_neventdefs-1; + top = 0; + + while (1) { + index = (bottom + top) / 2; + + edp = (g_eventdefs + index); + + if (edp->event == code) + return(edp); + + if (top >= bottom) { + use_dummy: + edp = &dummy_event; + edp->selected = TRUE; + edp->event = code; + edp->format = "0x%x"; + sprintf (dummy_string, "E%lu", code); + edp->name = &dummy_string[0]; + return(edp); + } + + if (edp->event < code) + top = index + 1; + else + bottom = index - 1; + } +} + +/**************************************************************************** +* pointsel_next_snapshot +* Set dialog buttons from snapshot +****************************************************************************/ + +void pointsel_next_snapshot(void) +{ + int i; + + for (i = 0; i < g_neventdefs; i++) { + gtk_toggle_button_set_active ( + GTK_TOGGLE_BUTTON(s_event_buttons[i]), + g_eventdefs[i].selected); + } +} + +/**************************************************************************** +* pointsel_about +****************************************************************************/ + +void pointsel_about (char *tmpbuf) +{ + sprintf (tmpbuf+strlen(tmpbuf), "%d event definitions\n", + g_neventdefs); +} diff --git a/src/tools/g2/props.c b/src/tools/g2/props.c new file mode 100644 index 00000000..a23dc050 --- /dev/null +++ b/src/tools/g2/props.c @@ -0,0 +1,279 @@ +/* + *------------------------------------------------------------------ + * Copyright (c) 1997-2016 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include +#include +#include +#include +#include +#include + +static char *sxerox (char *s); +void exit(int); + +#define NBUCKETS 97 + +typedef struct prop_ { + struct prop_ *next; + char *name; + char *value; +} prop_t; + +static prop_t *buckets [NBUCKETS]; +static int hash_shifts[4] = {24, 16, 8, 0}; + +/* + * getprop + */ + +char *getprop (char *name) +{ + unsigned char *cp; + unsigned long hash=0; + prop_t *bp; + int i=0; + + for (cp = (unsigned char *) name; *cp; cp++) + hash ^= (*cp)<<(hash_shifts[(i++)&0x3]); + + bp = buckets [hash%NBUCKETS]; + + while (bp && strcmp (bp->name, name)) { + bp = bp->next; + } + + if (bp == NULL) + return (0); + else + return (bp->value); +} + +/* + * getprop_default + */ + +char *getprop_default (char *name, char *def) +{ + char *rv; + rv = getprop (name); + if (rv) + return (rv); + else + return (def); +} + +/* + * addprop + */ + +void addprop (char *name, char *value) +{ + unsigned char *cp; + unsigned long hash=0; + prop_t **bpp; + prop_t *bp; + int i=0; + + bp = (prop_t *)g_malloc (sizeof (prop_t)); + + bp->next = 0; + bp->name = sxerox (name); + bp->value = sxerox (value); + + for (cp = (unsigned char *)name; *cp; cp++) + hash ^= (*cp)<<(hash_shifts[(i++)&0x3]); + + bpp = &buckets [hash%NBUCKETS]; + + if (*bpp == NULL) + *bpp = bp; + else { + bp->next = *bpp; + *bpp = bp; + } +} + +/* + * sxerox + */ + +static char *sxerox (char *s) +{ + char *rv = (char *) g_malloc (strlen (s) + 1); + strcpy (rv, s); + return rv; +} + +/* + * readprops + */ + +#define START 0 +#define READNAME 1 +#define READVALUE 2 +#define C_COMMENT 3 +#define CPP_COMMENT 4 + +int readprops (char *filename) +{ + FILE *ifp; + unsigned char c; + int state=START; + int linenum=1; + char namebuf [128]; + char valbuf [512]; + int i; + + ifp = fopen (filename, "r"); + + if (ifp == NULL) + return (-1); + + while (1) { + + readchar: + c = getc (ifp); + + again: + switch (state) { + case START: + if (feof (ifp)) { + fclose (ifp); + return (0); + } + + if (c == ' ' || c == '\t') + goto readchar; + + if (c == '\n') { + linenum++; + goto readchar; + } + if (isalpha (c) || (c == '_')) { + state = READNAME; + goto again; + } + if (c == '/') { + c = getc (ifp); + if (c == '/') { + state = CPP_COMMENT; + goto readchar; + } else if (c == '*') { + state = C_COMMENT; + goto readchar; + } else { + fprintf (stderr, "unknown token '/' line %d\n", + linenum); + exit (1); + } + } + fprintf (stderr, "unknown token '%c' line %d\n", + c, linenum); + exit (1); + break; + + case CPP_COMMENT: + while (1) { + c = getc (ifp); + if (feof (ifp)) + return (0); + if (c == '\n') { + linenum++; + state = START; + goto readchar; + } + } + break; + + case C_COMMENT: + while (1) { + c = getc (ifp); + if (feof (ifp)) { + fprintf (stderr, "unterminated comment, line %d\n", + linenum); + exit (1); + } + if (c == '*') { + staragain: + c = getc (ifp); + if (c == '/') { + state = START; + goto readchar; + } + if (c == '*') + goto staragain; + } + } + break; + + case READNAME: + i = 0; + namebuf[i++] = c; + while (1) { + c = getc (ifp); + if (feof (ifp)) { + fprintf (stderr, "EOF while reading a name, line %d\n", + linenum); + exit (1); + } + if ((!isalnum (c)) && (c != '_')) { + namebuf [i] = 0; + state = READVALUE; + goto again; + } + namebuf [i++] = c; + } + break; + + case READVALUE: + i = 0; + while ((c == ' ') || (c == '\t') || (c == '=')) { + c = getc (ifp); + if (feof (ifp)) { + fprintf (stderr, "EOF while reading a value, line %d\n", + linenum); + exit (1); + } + } + goto firsttime; + while (1) { + c = getc (ifp); + + firsttime: + if (c == '\\') { + c = getc (ifp); + if (feof (ifp)) { + fprintf (stderr, "EOF after '\\', line %d\n", + linenum); + exit (1); + } + valbuf[i++] = c; + continue; + } + if (c == '\n') { + linenum++; + while (valbuf [i-1] == ' ' || valbuf[i-1] == '\t') + i--; + valbuf[i] = 0; + addprop (namebuf, valbuf); + state = START; + goto readchar; + } + valbuf[i++] = c; + } + + } + } +} diff --git a/src/tools/g2/props.h b/src/tools/g2/props.h new file mode 100644 index 00000000..6289941d --- /dev/null +++ b/src/tools/g2/props.h @@ -0,0 +1,21 @@ +/* + *------------------------------------------------------------------ + * Copyright (c) 1997-2016 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +extern char *getprop (char *name); +extern char *getprop_default (char *name, char *def); +extern void addprop (char *name, char *value); +extern int readprops (char *filename); +extern int writeprops (char *filename); diff --git a/src/tools/g2/view1.c b/src/tools/g2/view1.c new file mode 100644 index 00000000..ec394cc3 --- /dev/null +++ b/src/tools/g2/view1.c @@ -0,0 +1,3077 @@ +/* + *------------------------------------------------------------------ + * Copyright (c) 2005-2016 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include +#include +#include "g2.h" +#include +#include +#include +#include + +/* + * The main event display view. + * + * Important variables: + * + * "da" -- the drawing area, aka the screen representation of the + * event view. + * + * "pm" -- the backing pixmap for the drawing area. Note that + * all graphics operations target this backing + * store, then call gtk_widget_draw to copy a rectangle from + * the backing store onto the screen. + * + * "s_v1" -- pointer to the current v1_geometry_t object. + * + * Box heirarchy: + * s_view1_vbox + * s_view1_hbox + * da s_view1_vmenubox + * s_view1_topbutton("Top") + * s_view1_vscroll (vertical scrollbar) + * s_view1_bottombutton("Bottom") + * s_view1_hmenubox + * s_view1_startbutton("Start"); + * s_view1_hscroll(horizontal scrollbar) + * s_view1_endbutton("End") + * s_view1_zoominbutton("Zoomin") + * s_view1_searchbutton("Search") + * s_view1_searchagainbutton("Search Again") + * s_view1_zoomoutbutton("Zoomout") + * s_view1_label + */ + +/* + * Globals + */ + +GdkFont *g_font; /* a fixed-width font to use */ +GdkColor fg_black = {0, 0, 0, 0}; +GdkColor bg_white = {0, 65535, 65535, 65535}; +static boolean summary_mode = TRUE; /* start out in summary mode */ +static boolean color_mode = FALSE; /* start out in color mode */ + +/* + * Locals + */ + +/* + * user_data values passed to view1_button_click_callback, + * which is used by the various action buttons noted above + */ +enum view1_button_click { + TOP_BUTTON=1, + BOTTOM_BUTTON, + START_BUTTON, + ZOOMIN_BUTTON, + SEARCH_BUTTON, + SEARCH_AGAIN_BUTTON, + ZOOMOUT_BUTTON, + END_BUTTON, + MORE_TRACES_BUTTON, + LESS_TRACES_BUTTON, + SNAP_BUTTON, + NEXT_BUTTON, + DEL_BUTTON, + CHASE_EVENT_BUTTON, + CHASE_DATUM_BUTTON, + CHASE_TRACK_BUTTON, + UNCHASE_BUTTON, + FORWARD_BUTTON, + BACKWARD_BUTTON, + SUMMARY_BUTTON, + NOSUMMARY_BUTTON, +}; + +enum chase_mode { + CHASE_EVENT=1, + CHASE_DATUM, + CHASE_TRACK, +}; + +enum sc_dir { + SRCH_CHASE_FORWARD = 0, + SRCH_CHASE_BACKWARD = 1, +}; + +static GtkWidget *s_view1_hbox; /* see box heirarchy chart */ +static GtkWidget *s_view1_vbox; /* see box heirarchy chart */ +static GtkWidget *da; /* main drawing area */ +static GdkPixmap *pm; /* and its backing pixmap */ +static GdkCursor *norm_cursor; /* the "normal" cursor */ + +/* + * view geometry parameters + * + * Remember: + * Y increases down the page. + * Strip origin is at the top + * Payday is Friday + * Don't put your fingers in your mouth. + * + * Most of these values are in pixels + */ + +typedef struct v1_geometry { + int pid_ax_width; /* Width of the PID axis */ + int time_ax_height; /* Height of the time axis */ + int time_ax_spacing; /* TimeAxis: Space between tick-marks */ + int strip_height; /* Height of a regular PID trace */ + int pop_offset; /* Vertical offset of the detail box */ + int pid_ax_offset; /* Vertical offset of the PID axis */ + int event_offset; /* Vertical offset of the event boxes */ + int total_height; /* total height of da, see configure_event */ + int total_width; /* ditto, for width */ + + /* Derived values */ + int first_pid_index; /* Index of first displayed PID */ + int npids; /* Max number of displayed pids */ + ulonglong minvistime; /* in usec */ + ulonglong maxvistime; /* in usec */ +} v1_geometry_t; + + +/* The active geometry object */ +static v1_geometry_t s_v1record; +static v1_geometry_t *s_v1 = &s_v1record; + +/* The color array */ +static GdkColor *s_color; + +/* Snapshot ring */ +typedef struct snapshot { + struct snapshot *next; + /* Screen geometry */ + v1_geometry_t geometry; + boolean show_event[NEVENTS]; + pid_sort_t *pidvec; + /* + * Note: not worth recomputing the vertical scrollbar, just save + * its value here + */ + gfloat vscroll_value; + boolean summary_mode; + boolean color_mode; +} snapshot_t; + +static snapshot_t *s_snapshots; +static snapshot_t *s_cursnap; +static event_t *s_last_selected_event; + +/* + * various widgets, see the box heirarchy chart above + * The toolkit keeps track of these things, we could lose many of + * these pointers. + */ +static GtkWidget *s_view1_vmenubox; +static GtkWidget *s_view1_topbutton; +static GtkWidget *s_view1_bottombutton; +static GtkWidget *s_view1_more_traces_button; +static GtkWidget *s_view1_less_traces_button; + +static GtkWidget *s_view1_hmenubox; +static GtkWidget *s_view1_hmenubox2; +static GtkWidget *s_view1_startbutton; +static GtkWidget *s_view1_zoominbutton; +static GtkWidget *s_view1_searchbutton; +static GtkWidget *s_view1_srchagainbutton; +static GtkWidget *s_view1_zoomoutbutton; +static GtkWidget *s_view1_endbutton; + +static GtkWidget *s_view1_snapbutton; +static GtkWidget *s_view1_nextbutton; +static GtkWidget *s_view1_delbutton; + +static GtkWidget *s_view1_chase_event_button; +static GtkWidget *s_view1_chase_datum_button; +static GtkWidget *s_view1_chase_track_button; +static GtkWidget *s_view1_unchasebutton; + +static GtkWidget *s_view1_forward_button; +static GtkWidget *s_view1_backward_button; + +static GtkWidget *s_view1_summary_button; +static GtkWidget *s_view1_nosummary_button; + +static GtkWidget *s_view1_hscroll; +static GtkObject *s_view1_hsadj; + +static GtkWidget *s_view1_vscroll; +static GtkObject *s_view1_vsadj; + +static GtkWidget *s_view1_label; + +/* + * Search context + */ +static ulong s_srchcode; /* search event code */ +static int s_srchindex; /* last hit was at this event index */ +static boolean s_result_up; /* The SEARCH RESULT dongle is displayed */ +static boolean s_srchfail_up; /* The status line "Search Failed" is up */ +static int srch_chase_dir; /* search/chase dir, 0=>forward */ + + +/* + * Print context + */ +static int s_print_offset; /* Magic offset added to line, tbox fn codes */ +static FILE *s_printfp; + +/* + * Forward reference prototypes + */ +static void display_pid_axis(v1_geometry_t *vp); +static void display_event_data(v1_geometry_t *vp); +static void display_time_axis(v1_geometry_t *vp); +static void view1_button_click_callback(GtkButton *item, gpointer data); + +/* + * config params + */ + +gint c_view1_draw_width; +gint c_view1_draw_height; + +/* + * Zoom-In / Time Ruler cursor + */ + +#define zi_width 32 +#define zi_height 32 +#define zi_x_hot 22 +#define zi_y_hot 14 +static unsigned char zi_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, + 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, + 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, + 0x00, 0x00, 0x82, 0x00, 0x00, 0x00, 0x84, 0x00, 0x00, 0x00, 0x88, 0x00, + 0x00, 0x00, 0x90, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x00, 0x00, 0xc0, 0x00, + 0x00, 0xfc, 0xff, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0xa0, 0x00, + 0x00, 0x00, 0x90, 0x00, 0x00, 0x00, 0x88, 0x00, 0x00, 0x00, 0x84, 0x00, + 0x00, 0x00, 0x82, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, + 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, + 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + +static unsigned char zi_bkgd[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, + 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, + 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, + 0x00, 0x00, 0x82, 0x00, 0x00, 0x00, 0x84, 0x00, 0x00, 0x00, 0x88, 0x00, + 0x00, 0x00, 0x90, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x00, 0x00, 0xc0, 0x00, + 0x00, 0xfc, 0xff, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0xa0, 0x00, + 0x00, 0x00, 0x90, 0x00, 0x00, 0x00, 0x88, 0x00, 0x00, 0x00, 0x84, 0x00, + 0x00, 0x00, 0x82, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, + 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, + 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + +static GdkCursor *zi_cursor; +static GdkPixmap *zi_source, *zi_mask; + +/* + * Frequently-used small computations, best + * done correctly once and instantiated. + */ + +/**************************************************************************** +* dtime_per_pixel +****************************************************************************/ + +static inline double dtime_per_pixel(v1_geometry_t *vp) +{ + return ((double)(vp->maxvistime - vp->minvistime)) / + ((double)(vp->total_width - vp->pid_ax_width)); +} + +/**************************************************************************** +* message_line +* Changes the status line. Pass "" to clear the status line. +****************************************************************************/ + +void message_line (char *s) +{ + gtk_label_set_text (GTK_LABEL(s_view1_label), s); +} + +/**************************************************************************** +* set_window_title +* Changes the window title to include the specified filename. +****************************************************************************/ + +void set_window_title (const char *filename) +{ + char title[128]; + snprintf(title, sizeof(title), "g2 (%s)", filename); + gtk_window_set_title(GTK_WINDOW(g_mainwindow), title); +} + +/**************************************************************************** +* recompute_hscrollbar +* Adjust the horizontal scrollbar's adjustment object. +* +* GtkAdjustments are really cool, but have to be set up exactly +* right or the various client objects screw up completely. +* +* Note: this function is *not* called when the user clicks the scrollbar. +****************************************************************************/ + +static void recompute_hscrollbar (void) +{ + ulonglong current_width; + ulonglong event_incdec; + GtkAdjustment *adj; + event_t *ep; + + if (g_nevents == 0) + return; + + ep = (g_events + (g_nevents-1)); + current_width = s_v1->maxvistime - s_v1->minvistime; + event_incdec = (current_width) / 6; + + adj = GTK_ADJUSTMENT(s_view1_hsadj); + + /* + * Structure member decoder ring + * ----------------------------- + * lower the minimum possible value + * value the current value + * upper the maximum possible value + * step_increment end button click increment + * page_increment click in trough increment + * page_size size of currently visible area + */ + + adj->lower = (gfloat)0.00; + adj->value = (gfloat)s_v1->minvistime; + + /* Minor click: move about 1/6 of a page */ + adj->step_increment = (gfloat)event_incdec; + + /* Major click: move about 1/3 of a page. */ + adj->page_increment = (gfloat)(2*event_incdec); + + /* allow the user to go a bit past the end */ + adj->upper = adj->page_increment/3 + (gfloat)(ep->time); + adj->page_size = (gfloat)(current_width); + + /* + * Tell all clients (e.g. the visible scrollbar) to + * make themselves look right + */ + gtk_adjustment_changed(adj); + gtk_adjustment_value_changed(adj); +} + +/**************************************************************************** +* recompute_vscrollbar +* Ditto, for the vertical scrollbar +****************************************************************************/ + +static void recompute_vscrollbar (void) +{ + GtkAdjustment *adj; + + adj = GTK_ADJUSTMENT(s_view1_vsadj); + + adj->lower = (gfloat)0.00; + adj->upper = (gfloat)g_npids; + adj->value = (gfloat)0.00; + adj->step_increment = 1.00; + adj->page_increment = (gfloat)(s_v1->npids / 3); + adj->page_size = (gfloat)s_v1->npids; + gtk_adjustment_changed(adj); + gtk_adjustment_value_changed(adj); +} + +/**************************************************************************** +* format_popbox_string +****************************************************************************/ + +elog_main_t elog_main; + +void format_popbox_string (char *tmpbuf, int len, event_t *ep, event_def_t *edp) +{ + char *fp; + +#ifdef NOTDEF + sprintf(tmpbuf,"%d:", ep->code); +#endif + if (ep->flags & EVENT_FLAG_CLIB) { + elog_event_t *eep; + u8 *s; + + eep = get_clib_event (ep->datum); + + s = format (0, "%U", format_elog_event, &elog_main, eep); + memcpy (tmpbuf, s, vec_len(s)); + tmpbuf[vec_len(s)] = 0; + vec_free(s); + return; + } + + snprintf(tmpbuf, len, "%s", edp->name); + fp = edp->format; + /* Make sure there's a real format string. If so, add it */ + while (fp && *fp) { + if (*fp != ' ') { + snprintf(tmpbuf+strlen(tmpbuf), len - strlen(tmpbuf), ": "); + /* %s only supported for cpel files */ + if (fp[1] == 's') { + snprintf(tmpbuf+strlen(tmpbuf), len - strlen(tmpbuf), + edp->format, strtab_ref(ep->datum)); + } else { + snprintf(tmpbuf+strlen(tmpbuf), len - strlen(tmpbuf), + edp->format, ep->datum); + } + return; + } + fp++; + } +} + +/**************************************************************************** + * add_snapshot + ****************************************************************************/ + +static void add_snapshot(void) +{ + int i; + snapshot_t *new = g_malloc(sizeof(snapshot_t)); + + memcpy(&new->geometry, s_v1, sizeof(new->geometry)); + for (i = 0; i < NEVENTS; i++) { + new->show_event[i] = g_eventdefs[i].selected; + } + new->pidvec = g_malloc(sizeof(pid_sort_t)*g_npids); + memcpy(new->pidvec, g_pids, sizeof(pid_sort_t)*g_npids); + new->vscroll_value = GTK_ADJUSTMENT(s_view1_vsadj)->value; + new->summary_mode = summary_mode; + new->color_mode = color_mode; + + if (s_snapshots) { + new->next = s_snapshots; + s_snapshots = new; + } else { + new->next = 0; + s_snapshots = new; + } + s_cursnap = new; +} + +/**************************************************************************** + * next_snapshot + ****************************************************************************/ + +static void next_snapshot(void) +{ + snapshot_t *next; + int i; + pid_sort_t *psp; + pid_data_t *pp; + + if (!s_snapshots) { + infobox("No snapshots", "\nNo snapshots in the ring...\n"); + return; + } + + next = s_cursnap->next; + if (next == 0) + next = s_snapshots; + + s_cursnap = next; + + memcpy(s_v1, &next->geometry, sizeof(next->geometry)); + for (i = 0; i < NEVENTS; i++) { + g_eventdefs[i].selected = next->show_event[i]; + } + memcpy(g_pids, next->pidvec, sizeof(pid_sort_t)*g_npids); + color_mode = next->color_mode; + /* + * Update summary mode via a button push so that the button state is + * updated accordingly. (Should ideally clean up the view/controller + * separation properly one day.) + */ + if (summary_mode != next->summary_mode) { + view1_button_click_callback + (NULL, (gpointer)(unsigned long long) + (summary_mode ? NOSUMMARY_BUTTON : SUMMARY_BUTTON)); + } + + /* Fix the pid structure index mappings */ + psp = g_pids; + + for (i = 0; i < g_npids; i++) { + pp = psp->pid; + pp->pid_index = i; + psp++; + } + GTK_ADJUSTMENT(s_view1_vsadj)->value = next->vscroll_value; + gtk_adjustment_value_changed(GTK_ADJUSTMENT(s_view1_vsadj)); + recompute_hscrollbar(); + pointsel_next_snapshot(); + view1_display_when_idle(); +} + + +/**************************************************************************** + * del_snapshot + ****************************************************************************/ + +static void del_snapshot(void) +{ + snapshot_t *prev; + snapshot_t *this; + + if (!s_snapshots) { + infobox("No snapshots", "\nNo snapshots to delete...\n"); + return; + } + + prev = NULL; + this = s_snapshots; + + while (this && this != s_cursnap) { + prev = this; + this = this->next; + } + + if (this != s_cursnap) { + infobox("BUG", "\nSnapshot AWOL!\n"); + return; + } + + s_cursnap = this->next; + + /* middle of the list? */ + if (prev) { + prev->next = this->next; + g_free(this->pidvec); + g_free(this); + } else { /* start of the list */ + s_snapshots = this->next; + g_free(this->pidvec); + g_free(this); + } + + /* Note: both will be NULL after last delete */ + if (s_cursnap == NULL) + s_cursnap = s_snapshots; +} + +/**************************************************************************** + * write_snapshot + * + * VERY primitive right now - not endian or version independent, and only + * writes to "snapshots.g2" in the current directory + ****************************************************************************/ +static void write_snapshot(void) +{ + FILE *file = NULL; + snapshot_t *snap; + char *error = NULL; + int records = 0; + + if (s_snapshots == NULL) { + error = "No snapshots defined"; + errno = 0; + } + + if (!error) { + file = fopen("snapshots.g2", "w"); + if (file == NULL) { + error = "Unable to open snapshots.g2"; + } + } + + /* + * Simply serialize the arch-dependent binary data, without a care in the + * world. Don't come running to me if you try to read it and crash. + */ + for (snap = s_snapshots; !error && snap != NULL; snap = snap->next) { + if (fwrite(&snap->geometry, + sizeof(snap->geometry), 1, file) != 1 || + fwrite(&snap->show_event, + sizeof(snap->show_event), 1, file) != 1 || + fwrite(snap->pidvec, + sizeof(pid_sort_t) * g_npids, 1, file) != 1 || + fwrite(&snap->vscroll_value, + sizeof(snap->vscroll_value), 1, file) != 1 || + fwrite(&snap->summary_mode, + sizeof(snap->summary_mode), 1, file) != 1 || + fwrite(&snap->color_mode, + sizeof(snap->color_mode), 1, file) != 1) { + error = "Error writing data"; + } + records++; + } + + if (!error) { + if (fclose(file)) { + error = "Unable to close file"; + } + } + + if (error) { + infobox(error, strerror(errno)); + } else { + char buf[64]; + snprintf(buf, sizeof(buf), "Wrote %d snapshots to snapshots.g2", + records); + message_line(buf); + } +} + +/**************************************************************************** + * read_snapshot + * + * VERY primitive right now - not endian or version independent, and only reads + * from "snapshots.g2" in the current directory + ****************************************************************************/ +static void read_snapshot(void) +{ + FILE *file; + snapshot_t *snap, *next_snap; + snapshot_t *new_snaps = NULL; + char *error = NULL; + int len, i, records = 0; + pid_data_t *pp; + + file = fopen("snapshots.g2", "r"); + if (file == NULL) { + error = "Unable to open snapshots.g2"; + } + + /* + * Read in the snapshots and link them together. We insert them backwards, + * but that's tolerable. If the data is in anyway not what we expect, we'll + * probably crash. Sorry. + */ + while (!error && !feof(file)) { + snap = g_malloc(sizeof(*snap)); + snap->pidvec = NULL; /* so we can free this if there's an error */ + + len = fread(&snap->geometry, sizeof(snap->geometry), 1, file); + if (len == 0) { + /* EOF */ + g_free(snap); + break; + } else { + /* insert into list straight away */ + snap->next = new_snaps; + new_snaps = snap; + } + if (len != 1) { + error = "Problem reading first item from file"; + break; + } + if (fread(&snap->show_event, sizeof(snap->show_event), 1, file) != 1) { + error = "Problem reading second item from file"; + break; + } + len = sizeof(pid_sort_t) * g_npids; + snap->pidvec = g_malloc(len); + if (fread(snap->pidvec, len, 1, file) != 1) { + error = "Problem reading third item from file"; + break; + } + if (fread(&snap->vscroll_value, + sizeof(snap->vscroll_value), 1, file) != 1 || + fread(&snap->summary_mode, + sizeof(snap->summary_mode), 1, file) != 1 || + fread(&snap->color_mode, + sizeof(snap->color_mode), 1, file) != 1) { + error = "Problem reading final items from file"; + break; + } + + /* + * Fix up the pointers from the sorted pid vector back into our pid + * data objects, by walking the linked list of pid_data_t objects for + * every one looking for a match. This is O(n^2) grossness, but in real + * life there aren't that many pids, and it seems zippy enough. + */ + for (i = 0; i < g_npids; i++) { + for (pp = g_pid_data_list; pp != NULL; pp = pp->next) { + if (pp->pid_value == snap->pidvec[i].pid_value) { + break; + } + } + if (pp != NULL) { + snap->pidvec[i].pid = pp; + } else { + error = "Snapshot file referenced unknown pids"; + break; + } + } + + records++; + } + + if (!error) { + if (fclose(file)) { + error = "Unable to close file"; + } + } + + if (error) { + /* + * Problem - clear up any detritus + */ + infobox(error, strerror(errno)); + for (snap = new_snaps; snap != NULL; snap = next_snap) { + next_snap = snap->next; + g_free(snap); + g_free(snap->pidvec); + } + } else { + /* + * Success! trash the old snapshots and replace with the new + */ + for (snap = s_snapshots; snap != NULL; snap = next_snap) { + next_snap = snap->next; + g_free(snap->pidvec); + g_free(snap); + } + + s_cursnap = s_snapshots = new_snaps; + } + + if (error) { + infobox(error, strerror(errno)); + } else { + char buf[64]; + snprintf(buf, sizeof(buf), + "Read %d snapshots from snapshots.g2", records); + message_line(buf); + } +} + +/**************************************************************************** +* set_color +* +* Set the color for the specified pid_index, or COLOR_DEFAULT to return it +* to the usual black. +****************************************************************************/ +#define COLOR_DEFAULT (-1) +static void set_color(int pid_index) +{ + if (pid_index == COLOR_DEFAULT || !color_mode) { + gdk_gc_set_foreground(da->style->black_gc, &fg_black); + } else { + gdk_gc_set_foreground(da->style->black_gc, + &s_color[g_pids[pid_index].color_index]); + } +} + +/**************************************************************************** +* toggle_event_select +****************************************************************************/ + +static void toggle_event_select(GdkEventButton *event, v1_geometry_t *vp) +{ + int pid_index, start_index; + int x, y; + GdkRectangle *rp; + GdkRectangle hit_rect; + GdkRectangle dummy; + event_t *ep; + event_def_t *edp; + char tmpbuf [1024]; + double time_per_pixel; + + if (g_nevents == 0) + return; + + time_per_pixel = dtime_per_pixel(vp); + + start_index = find_event_index (vp->minvistime); + + /* Too far right? */ + if (start_index >= g_nevents) + return; + + /* + * To see if the mouse hit a visible event, use a variant + * of the event display loop. + */ + + hit_rect.x = (int)event->x; + hit_rect.y = (int)event->y; + hit_rect.width = 1; + hit_rect.height = 1; + + ep = (g_events + start_index); + + while ((ep->time < vp->maxvistime) && + (ep < (g_events + g_nevents))) { + pid_index = ep->pid->pid_index; + + /* First filter: pid out of range */ + if ((pid_index < vp->first_pid_index) || + (pid_index >= vp->first_pid_index + vp->npids)) { + ep++; + continue; + } + + /* Second filter: event hidden */ + edp = find_event_definition (ep->code); + if (!edp->selected) { + ep++; + continue; + } + + /* + * At this point, we know that the point is at least on the + * screen. See if the mouse hit within the bounding box + */ + + /* + * $$$$ maybe keep looping until off the edge, + * maintain a "best hit", then declare that one the winner? + */ + + pid_index -= vp->first_pid_index; + + y = pid_index*vp->strip_height + vp->event_offset; + + x = vp->pid_ax_width + + (int)(((double)(ep->time - vp->minvistime)) / time_per_pixel); + + /* Perhaps we're trying to toggle the detail box? */ + if (ep->flags & EVENT_FLAG_SELECT) { + /* Figure out the dimensions of the detail box */ + format_popbox_string(tmpbuf, sizeof(tmpbuf), ep, edp); + rp = tbox(tmpbuf, x, y - vp->pop_offset, TBOX_GETRECT_BOXED); + if (gdk_rectangle_intersect(rp, &hit_rect, &dummy)) { + ep->flags &= ~EVENT_FLAG_SELECT; + view1_display_when_idle(); + break; + } + } + + sprintf(tmpbuf, "%ld", ep->code); + + /* Figure out the dimensions of the regular box */ + rp = tbox(tmpbuf, x, y, TBOX_GETRECT_EVENT); + + if (gdk_rectangle_intersect(rp, &hit_rect, &dummy)) { + /* we hit the rectangle. */ + if (ep->flags & EVENT_FLAG_SELECT) { + ep->flags &= ~EVENT_FLAG_SELECT; + view1_display_when_idle(); + break; + } else { + set_color(ep->pid->pid_index); + + /* It wasn't selected, so put up the detail box */ + format_popbox_string(tmpbuf, sizeof(tmpbuf), ep, edp); + tbox(tmpbuf, x, y - vp->pop_offset, TBOX_DRAW_BOXED); + line(x, y-vp->pop_offset, x, y, LINE_DRAW_BLACK); + ep->flags |= EVENT_FLAG_SELECT; + ep->flags &= ~EVENT_FLAG_SEARCHRSLT; + s_last_selected_event = ep; + } + break; + } + ep++; + } +} + +/**************************************************************************** +* move_current_track +****************************************************************************/ + +typedef enum { MOVE_TOP, MOVE_BOTTOM } move_type; + +static void move_current_track(GdkEventButton *event, + v1_geometry_t *vp, + move_type type) +{ + int i; + int pid_index; + int y, delta_y; + pid_sort_t *new_pidvec; + pid_sort_t *psp; + pid_sort_t *pold, *pnew; + pid_data_t *pp; + + if (g_nevents == 0) + return; + + /* Scan pid/track axis locations, looking for a match */ + for (i = 0; i < vp->npids; i++) { + y = i*vp->strip_height + vp->pid_ax_offset; + delta_y = y - event->y; + if (delta_y < 0) + delta_y = -delta_y; + if (delta_y < 10) { + goto found; + } + + } + infobox("NOTE", "\nNo PID/Track In Range\nPlease Try Again"); + return; + + found: + pid_index = i + vp->first_pid_index; + + new_pidvec = g_malloc(sizeof(pid_sort_t)*g_npids); + pold = g_pids; + pnew = new_pidvec; + + if (type == MOVE_TOP) { + /* move to top */ + *pnew++ = g_pids[pid_index]; + for (i = 0; i < pid_index; i++) + *pnew++ = *pold++; + pold++; + i++; + for (; i < g_npids; i++) + *pnew++ = *pold++; + } else { + /* move to bottom */ + for (i = 0; i < pid_index; i++) + *pnew++ = *pold++; + pold++; + i++; + for (; i < g_npids; i++) + *pnew++ = *pold++; + *pnew = g_pids[pid_index]; + } + + g_free(g_pids); + g_pids = new_pidvec; + + /* + * Revert the pid_index mapping to an identity map, + */ + psp = g_pids; + + for (i = 0; i < g_npids; i++) { + pp = psp->pid; + pp->pid_index = i; + psp++; + } + view1_display_when_idle(); +} + +/**************************************************************************** +* zoom_event +* Process a zoom gesture. The use of doubles is required to avoid +* truncating the various variable values, which in turn would lead to +* some pretty random-looking zoom responses. +****************************************************************************/ + +void zoom_event(GdkEventButton *e1, GdkEventButton *e2, v1_geometry_t *vp) +{ + double xrange; + double time_per_pixel; + double width_in_pixels; + double center_on_time, width_in_time; + double center_on_pixel; + + /* + * Clip the zoom area to the event display area. + * Otherwise, center_on_time - width_in_time is in hyperspace + * to the left of zero + */ + + if (e1->x < vp->pid_ax_width) + e1->x = vp->pid_ax_width; + + if (e2->x < vp->pid_ax_width) + e2->x = vp->pid_ax_width; + + if (e2->x == e1->x) + goto loser_zoom_repaint; + + xrange = (double) (e2->x - e1->x); + if (xrange < 0.00) + xrange = -xrange; + + /* Actually, width in pixels of half the zoom area */ + width_in_pixels = xrange / 2.00; + time_per_pixel = dtime_per_pixel(vp); + width_in_time = width_in_pixels * time_per_pixel; + + /* Center the screen on the center of the zoom area */ + center_on_pixel = (double)((e2->x + e1->x) / 2.00) - + (double)vp->pid_ax_width; + center_on_time = center_on_pixel*time_per_pixel + (double)vp->minvistime; + + /* + * Transform back to 64-bit integer microseconds, reset the + * scrollbar, schedule a repaint. + */ + vp->minvistime = (ulonglong)(center_on_time - width_in_time); + vp->maxvistime = (ulonglong)(center_on_time + width_in_time); + +loser_zoom_repaint: + recompute_hscrollbar(); + + view1_display_when_idle(); +} + +/**************************************************************************** +* scroll_y +* +* Scroll up or down by the specified delta +* +****************************************************************************/ +static void scroll_y(int delta) +{ + int new_index = s_v1->first_pid_index + delta; + if (new_index + s_v1->npids > g_npids) + new_index = g_npids - s_v1->npids; + if (new_index < 0) + new_index = 0; + + if (new_index != s_v1->first_pid_index) { + s_v1->first_pid_index = new_index; + GTK_ADJUSTMENT(s_view1_vsadj)->value = (gdouble)new_index; + gtk_adjustment_value_changed(GTK_ADJUSTMENT(s_view1_vsadj)); + view1_display_when_idle(); + } +} + +/**************************************************************************** +* view1_handle_key_press_event +* Relevant definitions in: /usr/include/gtk-1.2/gdk/gdktypes.h +* +* This routine implements hotkeys for the Quake generation: +* +* W - zoom in +* S - zoom out +* A - pan left +* D - pan right +* R - pan up +* F - pan down +* T - more traces +* G - fewer traces +* +* E - toggle summary mode +* C - toggle color mode +* +* X - take snapshot +* Z - next snapshot +* P - persist snapshots to file +* L - load snapshots from file +* +* ctrl-Q - exit +* +****************************************************************************/ +gint +view1_handle_key_press_event (GtkWidget *widget, GdkEventKey *event) +{ + long long delta; + + switch (event->keyval) { + case GDK_w: // zoom in + view1_button_click_callback(NULL, (gpointer)ZOOMIN_BUTTON); + break; + + case GDK_s: // zoom out + view1_button_click_callback(NULL, (gpointer)ZOOMOUT_BUTTON); + break; + + case GDK_a: // pan left + delta = (s_v1->maxvistime - s_v1->minvistime) / 6; + if (s_v1->minvistime < delta) { + delta = s_v1->minvistime; + } + s_v1->minvistime -= delta; + s_v1->maxvistime -= delta; + recompute_hscrollbar(); + break; + + case GDK_d: // pan right + delta = (s_v1->maxvistime - s_v1->minvistime) / 6; + if (s_v1->maxvistime + delta > g_events[g_nevents - 1].time) { + /* + * @@@ this doesn't seem to quite reach the far right hand + * side correctly - not sure why. + */ + delta = g_events[g_nevents - 1].time - s_v1->maxvistime; + } + s_v1->minvistime += delta; + s_v1->maxvistime += delta; + recompute_hscrollbar(); + break; + + case GDK_r: // pan up + scroll_y(-1); + break; + + case GDK_f: // pan down + scroll_y(+1); + break; + + case GDK_t: // fewer tracks + view1_button_click_callback(NULL, (gpointer)LESS_TRACES_BUTTON); + break; + + case GDK_g: // more tracks + view1_button_click_callback(NULL, (gpointer)MORE_TRACES_BUTTON); + break; + + case GDK_e: // toggle summary mode + view1_button_click_callback + (NULL, (gpointer)(unsigned long long) + (summary_mode ? NOSUMMARY_BUTTON : SUMMARY_BUTTON)); + break; + + case GDK_c: // toggle color mode + color_mode ^= 1; + view1_display_when_idle(); + break; + + case GDK_p: // persist snapshots + write_snapshot(); + break; + + case GDK_l: // load snapshots + read_snapshot(); + break; + + case GDK_x: // take snapshot + view1_button_click_callback(NULL, (gpointer)SNAP_BUTTON); + break; + + case GDK_z: // next snapshot + view1_button_click_callback(NULL, (gpointer)NEXT_BUTTON); + break; + + case GDK_q: // ctrl-q is exit + if (event->state & GDK_CONTROL_MASK) { + gtk_main_quit(); + } + break; + } + return TRUE; +} + +/**************************************************************************** +* button_press_event +* Relevant definitions in: /usr/include/gtk-1.2/gdk/gdktypes.h +* +* This routine implements three functions: zoom-to-area, time ruler, and +* show/hide event detail popup. +* +* The left mouse button (button 1) has two simultaneous functions: event +* detail popup, and zoom-to-area. If the press and release events occur +* within a small delta-x, it's a detail popup event. Otherwise, it's +* an area zoom. +* +* The right mouse button (button 3) implements the time ruler. +****************************************************************************/ + +static gint +button_press_event (GtkWidget *widget, GdkEventButton *event) +{ + static GdkEventButton press1_event; + static boolean press1_valid; + static GdkEventButton press3_event; + static guint32 last_truler_time; + static boolean press3_valid; + static boolean zoom_bar_up; + int time_ax_y, xdelta; + char tmpbuf [128]; + double time_per_pixel; + + time_ax_y = 0; + + switch(event->type) { + case GDK_BUTTON_PRESS: + /* Capture the appropriate starting point */ + if (event->button == 1) { + press1_valid = TRUE; + press1_event = *event; + return(TRUE); + } + if (event->button == 3) { + press3_valid = TRUE; + press3_event = *event; + return(TRUE); + } + return(TRUE); + + case GDK_BUTTON_RELEASE: + /* Time ruler */ + if (press3_valid) { + press3_valid = FALSE; + /* Fix the cursor, and repaint the screen from scratch */ + gdk_window_set_cursor (da->window, norm_cursor); + view1_display_when_idle(); + return(TRUE); + } + /* Event select / zoom-to-area */ + if (press1_valid) { + press1_valid = FALSE; + xdelta = (int)(press1_event.x - event->x); + if (xdelta < 0) + xdelta = -xdelta; + + /* is the mouse more or less where it started? */ + if (xdelta < 10) { + /* Control-left-mouse => sink the track */ + /* Shift-left-mouse => raise the track */ + if ((press1_event.state & GDK_CONTROL_MASK) == + GDK_CONTROL_MASK) { + move_current_track(event, s_v1, MOVE_BOTTOM); + } else if ((press1_event.state & GDK_SHIFT_MASK) == + GDK_SHIFT_MASK) { + move_current_track(event, s_v1, MOVE_TOP); + } else { + /* No modifiers: toggle the event */ + toggle_event_select(event, s_v1); + } + /* Repaint to get rid of the zoom bar */ + if (zoom_bar_up) { + /* Fix the cursor and leave. No zoom */ + gdk_window_set_cursor (da->window, norm_cursor); + zoom_bar_up = FALSE; + break; + } + } else { /* mouse moved enough to zoom */ + zoom_event(&press1_event, event, s_v1); + gdk_window_set_cursor (da->window, norm_cursor); + zoom_bar_up = FALSE; + } + } else if (event->button == 4) { + /* scroll wheel up */ + scroll_y(event->state & GDK_SHIFT_MASK ? -10 : -1); + } else if (event->button == 5) { + /* scroll wheel down */ + scroll_y(event->state & GDK_SHIFT_MASK ? +10 : +1); + } + return(TRUE); + + case GDK_MOTION_NOTIFY: + /* Button one followed by motion: draw zoom fence and fix cursor */ + if (press1_valid) { + /* Fence, cursor already set */ + if (zoom_bar_up) + return(TRUE); + + xdelta = (int)(press1_event.x - event->x); + if (xdelta < 0) + xdelta = -xdelta; + + /* Haven't moved enough to declare a zoom sequence yet */ + if (xdelta < 10) + return(TRUE); + + /* Draw the zoom fence, use the key-down X coordinate */ + time_ax_y = s_v1->npids * s_v1->strip_height + s_v1->pid_ax_offset; + + line((int)(press1_event.x), s_v1->pop_offset, + (int)(press1_event.x), time_ax_y, LINE_DRAW_BLACK); + tbox("Zoom From Here...", (int)(press1_event.x), s_v1->pop_offset, + TBOX_DRAW_BOXED); + gdk_window_set_cursor(da->window, zi_cursor); + zoom_bar_up = TRUE; + return(TRUE); + } + if (press3_valid) { + double nsec; + + gdk_window_set_cursor(da->window, zi_cursor); + + /* + * Some filtration is needed on Solaris, or the server will hang + */ + if (event->time - last_truler_time < 75) + return(TRUE); + + last_truler_time = event->time; + + line((int)(press3_event.x), s_v1->pop_offset, + (int)(press3_event.x), time_ax_y, LINE_DRAW_BLACK); + + xdelta = (int)(press3_event.x - event->x); + if (xdelta < 0) + xdelta = -xdelta; + + time_per_pixel = ((double)(s_v1->maxvistime - s_v1->minvistime)) / + ((double)(s_v1->total_width - s_v1->pid_ax_width)); + + time_ax_y = s_v1->npids * s_v1->strip_height + s_v1->pid_ax_offset; + + line((int)(press3_event.x), s_v1->pop_offset, + (int)(press3_event.x), time_ax_y, LINE_DRAW_BLACK); + /* + * Note: use a fixed-width format so it looks like we're + * erasing and redrawing the box. + */ + nsec = ((double)xdelta)*time_per_pixel; + if (nsec >1e9) { + sprintf(tmpbuf, "%8.3f sec ", nsec/1e9); + } else if (nsec > 1e6) { + sprintf(tmpbuf, "%8.3f msec", nsec/1e6); + } else if (nsec > 1e3) { + sprintf(tmpbuf, "%8.3f usec", nsec/1e3); + } else { + sprintf(tmpbuf, "%8.0f nsec", nsec); + } + tbox(tmpbuf, (int)(press3_event.x), s_v1->pop_offset, + TBOX_DRAW_BOXED); + return(TRUE); + } + + default: + break; +#ifdef DEBUG + g_print("button:\ttype = %d\n", event->type); + g_print("\twindow = 0x%x\n", event->window); + g_print("\tsend_event = %d\n", event->send_event); + g_print("\ttime = %d\n", event->time); + g_print("\tx = %6.2f\n", event->x); + g_print("\ty = %6.2f\n", event->y); + g_print("\tpressure = %6.2f\n", event->pressure); + g_print("\txtilt = %6.2f\n", event->xtilt); + g_print("\tytilt = %6.2f\n", event->ytilt); + g_print("\tstate = %d\n", event->state); + g_print("\tbutton = %d\n", event->button); + g_print("\tsource = %d\n", event->source); + g_print("\tdeviceid = %d\n", event->deviceid); + g_print("\tx_root = %6.2f\n", event->x_root); + g_print("\ty_root = %6.2f\n", event->y_root); + return(TRUE); +#endif + } + + view1_display_when_idle(); + + return(TRUE); +} + +/**************************************************************************** +* configure_event +* Happens when the window manager resizes the viewer's main window. +****************************************************************************/ + +static gint +configure_event (GtkWidget *widget, GdkEventConfigure *event) +{ + /* Toss the previous drawing area backing store pixmap */ + if (pm) + gdk_pixmap_unref(pm); + + /* Create a new pixmap, paint it */ + pm = gdk_pixmap_new(widget->window, + widget->allocation.width, + widget->allocation.height, + -1); + gdk_draw_rectangle (pm, + widget->style->white_gc, + TRUE, + 0, 0, + widget->allocation.width, + widget->allocation.height); + + /* Reset the view geometry parameters, as required */ + s_v1->total_width = widget->allocation.width; + s_v1->total_height = widget->allocation.height; + s_v1->npids = (s_v1->total_height - s_v1->time_ax_height) / + s_v1->strip_height; + + /* Schedule a repaint */ + view1_display_when_idle(); + return(TRUE); +} + +/**************************************************************************** +* expose_event +* Use backing store to fix the screen. +****************************************************************************/ +static gint expose_event (GtkWidget *widget, GdkEventExpose *event) +{ + gdk_draw_pixmap(widget->window, + widget->style->fg_gc[GTK_WIDGET_STATE (widget)], + pm, + event->area.x, event->area.y, + event->area.x, event->area.y, + event->area.width, event->area.height); + + return(FALSE); +} + +/**************************************************************************** +* event_search_internal +* This routine searches forward from s_srchindex, looking for s_srchcode; +* wraps at the end of the buffer. +****************************************************************************/ + +boolean event_search_internal (void) +{ + event_t *ep; + int i; + int index; + int pid_index; + boolean full_redisplay = FALSE; + ulonglong current_width; + char tmpbuf [64]; + + /* No events yet? Act like the search worked, to avoid a loop */ + if (g_nevents == 0) + return(TRUE); + + ep = (g_events + s_srchindex); + ep->flags &= ~EVENT_FLAG_SEARCHRSLT; + + /* + * Assume the user wants to search [plus or minus] + * from where they are. + */ +#ifdef notdef + if (ep->time < s_v1->minvistime) + s_srchindex = find_event_index (s_v1->minvistime); +#endif + + for (i = 1; i <= g_nevents; i++) { + index = (srch_chase_dir == SRCH_CHASE_BACKWARD) ? + (s_srchindex - i) % g_nevents : + (i + s_srchindex) % g_nevents; + + ep = (g_events + index); + + if (ep->code == s_srchcode) { + if (s_srchfail_up) + message_line(""); + s_srchindex = index; + pid_index = ep->pid->pid_index; + + /* Need a vertical scroll? */ + if ((pid_index < s_v1->first_pid_index) || + (pid_index >= s_v1->first_pid_index + s_v1->npids)) { + if (pid_index > (g_npids - s_v1->npids)) + pid_index = (g_npids - s_v1->npids); + s_v1->first_pid_index = pid_index; + GTK_ADJUSTMENT(s_view1_vsadj)->value = + (gdouble)s_v1->first_pid_index; + gtk_adjustment_value_changed(GTK_ADJUSTMENT(s_view1_vsadj)); + full_redisplay = TRUE; + } + + /* Need a horizontal scroll? */ + if (ep->time < s_v1->minvistime || ep->time > s_v1->maxvistime) { + current_width = (s_v1->maxvistime - s_v1->minvistime); + if (ep->time < ((current_width+1) / 2)) { + s_v1->minvistime = 0ll; + s_v1->maxvistime = current_width; + } else { + s_v1->minvistime = ep->time - ((current_width+1)/2); + s_v1->maxvistime = ep->time + ((current_width+1)/2); + } + recompute_hscrollbar(); + full_redisplay = TRUE; + } + ep->flags |= EVENT_FLAG_SEARCHRSLT; + full_redisplay = TRUE; + +#ifdef NOTDEF + if (!full_redisplay){ + if (!s_result_up) { + s_result_up = TRUE; + time_per_pixel = dtime_per_pixel(s_v1); + + y = pid_index*s_v1->strip_height + s_v1->event_offset; + x = s_v1->pid_ax_width + + (int)(((double)(ep->time - s_v1->minvistime)) / + time_per_pixel); + sprintf(tmpbuf, "SEARCH RESULT"); + tbox(tmpbuf, x, y - s_v1->pop_offset, TBOX_DRAW_BOXED); + line(x, y-s_v1->pop_offset, x, y, LINE_DRAW_BLACK); + } else { + full_redisplay = TRUE; + } + } +#endif + + if (full_redisplay) + view1_display_when_idle(); + return(TRUE); + } + } + sprintf (tmpbuf, "Search for event %ld failed...\n", s_srchcode); + message_line(tmpbuf); + s_srchfail_up = TRUE; + return(TRUE); +} + +/**************************************************************************** +* event_search_callback +****************************************************************************/ + +boolean event_search_callback (char *s) +{ + /* No events yet? Act like the search worked, to avoid a loop */ + if (g_nevents == 0) + return(TRUE); + + s_srchcode = atol(s); + + if (s_srchcode == 0) + return(FALSE); + + return(event_search_internal()); +} + +/**************************************************************************** +* event_search +****************************************************************************/ + +static void event_search (void) +{ + modal_dialog ("Event Search: Please Enter Event Code", + "Invalid: Please Reenter Event Code", NULL, + event_search_callback); +} + +/**************************************************************************** +* init_track_colors +****************************************************************************/ +static void init_track_colors(void) +{ + int i; + unsigned hash; + char *label_char; + unsigned RGB[3]; + gboolean dont_care[g_npids]; + + /* + * If we've already allocated the colors once, then in theory we should + * just be able to re-order the GCs already created to match the new track + * order; the track -> color mapping doesn't currently change at runtime. + * However, it's easier just to allocate everything from fresh. As a nod in + * the direction of politeness towards our poor abused X server, we at + * least mop up the previously allocated GCs first, although in practice + * even omitting this didn't seem to cause a problem. + */ + if (s_color != NULL ) { + gdk_colormap_free_colors(gtk_widget_get_colormap(da), + s_color, g_npids); + memset(s_color, 0, sizeof(GdkColor) * g_npids); + } else { + /* + * First time through: allocate the array to hold the GCs. + */ + s_color = g_malloc(sizeof(GdkColor) * g_npids); + } + + /* + * Go through and assign a color for each track. + */ + for (i = 0; i < g_npids; i++) { + /* + * We compute the color from a hash of the thread name. That way we get + * a distribution of different colors, and the same thread has the same + * color across multiple data sets. Unfortunately, even though the + * process name and thread id are invariant across data sets, the + * process id isn't, so we want to exclude that from the hash. Since + * the pid appears in parentheses after the process name and tid, we + * can just stop at the '(' character. + * + * We could create a substring and use the CLIB Jenkins hash, but given + * we're hashing ascii data, a suitable Bernstein hash is pretty much + * just as good, and it's easiest just to compute it inline. + */ + label_char = get_track_label(g_pids[i].pid_value); + hash = 0; + while (*label_char != '\0' && *label_char != '(') { + hash = hash * 33 + *label_char++; + } + hash += hash >> 5; /* even out the lower order bits a touch */ + + /* + * OK, now we have our hash. We get the color by using the first three + * bytes of the hash for the RGB values (expanded from 8 to 16 bits), + * and then use the fourth byte to choose one of R, G, B and mask this + * one down. This ensures the color can't be too close to white and + * therefore hard to see. + * + * We also drop the top bit of the green, since bright green on its own + * is hard to see against white. Generally we err on the side of + * keeping it dark, rather than using the full spectrum of colors. This + * does result in something of a preponderance of muddy colors and a + * bit of a lack of cheery bright ones, but at least you can read + * everything. It would be nice to do better. + */ + RGB[0] = (hash & 0xff000000) >> 16; + RGB[1] = (hash & 0x007f0000) >> 8; + RGB[2] = (hash & 0x0000ff00); + RGB[hash % 3] &= 0x1fff; + + { + GdkColor color = {0, RGB[0], RGB[1], RGB[2]}; + s_color[i] = color; + g_pids[i].color_index = i; + } + } + + /* + * Actually allocate the colors in one bulk operation. We ignore the return + * values. + */ + gdk_colormap_alloc_colors(gtk_widget_get_colormap(da), + s_color, g_npids, FALSE, TRUE, dont_care); +} + + +/**************************************************************************** +* chase_event_etc +* Reorder the pid_index fields so the viewer "chases" the last selected +* event. +****************************************************************************/ + +static void chase_event_etc(enum chase_mode mode) +{ + pid_sort_t *psp, *new_pidvec; + pid_data_t *pp; + event_t *ep; + int pids_mapped; + ulong code_to_chase; + ulong datum_to_chase; + ulong pid_to_chase; + int i; + int winner; + + if (!s_last_selected_event) { + infobox("No selected event", + "\nPlease select an event and try again...\n"); + return; + } + + /* Clear all index assignments */ + psp = g_pids; + for (i = 0; i < g_npids; i++) { + pp = psp->pid; + pp->pid_index = 0xFFFFFFFF; + psp++; + } + + ep = s_last_selected_event; + code_to_chase = ep->code; + datum_to_chase = ep->datum; + pid_to_chase = ep->pid->pid_value; + pids_mapped = 0; + new_pidvec = g_malloc(sizeof(pid_sort_t)*g_npids); + + while (1) { + if (srch_chase_dir == SRCH_CHASE_FORWARD) { + if (ep >= g_events + g_nevents) + break; + } else { + if (ep < g_events) + break; + } + + winner = 0; + switch(mode) { + case CHASE_EVENT: + if (ep->code == code_to_chase) { + winner = 1; + } + break; + + case CHASE_DATUM: + if (ep->datum == datum_to_chase) { + winner = 1; + } + break; + + case CHASE_TRACK: + if (ep->pid->pid_value == pid_to_chase) { + winner = 1; + } + break; + + default: + infobox("BUG", "unknown mode in chase_event_etc\n"); + break; + } + + if (winner) { + if (ep->pid->pid_index == 0xFFFFFFFF) { + ep->pid->pid_index = pids_mapped; + new_pidvec[pids_mapped].pid = ep->pid; + new_pidvec[pids_mapped].pid_value = ep->pid->pid_value; + new_pidvec[pids_mapped].color_index = 0; + pids_mapped++; + if (pids_mapped == g_npids) + break; + } + } + if (srch_chase_dir == SRCH_CHASE_FORWARD) + ep++; + else + ep--; + } + + /* Pass 2, first-to-last, to collect stragglers */ + ep = g_events; + + while (ep < g_events + g_nevents) { + if (ep->pid->pid_index == 0xFFFFFFFF) { + ep->pid->pid_index = pids_mapped; + new_pidvec[pids_mapped].pid = ep->pid; + new_pidvec[pids_mapped].pid_value = ep->pid->pid_value; + new_pidvec[pids_mapped].color_index = 0; + pids_mapped++; + if (pids_mapped == g_npids) + break; + } + ep++; + } + + if (pids_mapped != g_npids) { + infobox("BUG", "\nDidn't map all pids in chase_event_etc\n"); + } + + g_free (g_pids); + g_pids = new_pidvec; + + /* + * The new g_pids vector contains the "chase" sort, so we revert + * the pid_index mapping to an identity map + */ + psp = g_pids; + + for (i = 0; i < g_npids; i++) { + pp = psp->pid; + pp->pid_index = i; + psp++; + } + + /* AutoScroll the PID axis so we show the first "chased" event */ + s_v1->first_pid_index = 0; + GTK_ADJUSTMENT(s_view1_vsadj)->value = 0.00; + gtk_adjustment_value_changed(GTK_ADJUSTMENT(s_view1_vsadj)); + init_track_colors(); + view1_display_when_idle(); +} + +/**************************************************************************** +* unchase_event_etc +* Copy g_original_pids to g_pids, revert index mapping +****************************************************************************/ +static void unchase_event_etc(void) +{ + int i; + pid_sort_t *psp; + pid_data_t *pp; + + memcpy (g_pids, g_original_pids, sizeof(pid_sort_t)*g_npids); + + /* Fix the pid structure index mappings */ + psp = g_pids; + + for (i = 0; i < g_npids; i++) { + pp = psp->pid; + pp->pid_index = i; + psp++; + } + + /* Scroll PID axis to the top */ + s_v1->first_pid_index = 0; + GTK_ADJUSTMENT(s_view1_vsadj)->value = 0.00; + gtk_adjustment_value_changed(GTK_ADJUSTMENT(s_view1_vsadj)); + init_track_colors(); + view1_display_when_idle(); +} + +/**************************************************************************** +* print_ps_header +* To fit a reasonable-sized landscape mode plot onto letter-size paper, +* scale everything by .75. +****************************************************************************/ + +static void print_ps_header (v1_geometry_t *vp, char *filename) +{ + time_t now; + + now = time(0); + + fprintf(s_printfp, "%%%%!PS-Adobe-3.0 EPSF-3.0\n"); + fprintf(s_printfp, "%%%%Creator: G2 Event Viewer\n"); + fprintf(s_printfp, "%%%%Title: %s\n", filename); + fprintf(s_printfp, "%%%%CreationDate: %s", ctime(&now)); + fprintf(s_printfp, "%%%%DocumentData: Clean7Bit\n"); + fprintf(s_printfp, "%%%%Origin: 0 0\n"); + fprintf(s_printfp, "%%%%BoundingBox: 0 0 %d %d\n", vp->total_height, + vp->total_width); + fprintf(s_printfp, "%%%%LanguageLevel: 2\n"); + fprintf(s_printfp, "%%%%Pages: 1\n"); + fprintf(s_printfp, "%%%%Page: 1 1\n"); + fprintf(s_printfp, "%%%%EOF\n"); + fprintf(s_printfp, "/Times-Roman findfont\n"); + fprintf(s_printfp, "12 scalefont\n"); + fprintf(s_printfp, "setfont\n"); + fprintf(s_printfp, ".75 .75 scale\n"); +} + +/**************************************************************************** +* xrt +* Xcoordinate rotate and translate. We need to emit postscript that +* has a reasonable aspect ratio for printing. To do that, we rotate the +* intended picture by 90 degrees, using the standard 2D rotation +* formula: +* +* Xr = x*cos(theta) - y*sin(theta); +* Yr = x*sin(theta) + y*cos(theta); +* +* If we let theta = 90, this reduces to +* Xr = -y +* Yr = x +* +* Translate back to the origin in X by adding Ymax, yielding +* Xrt = Ymax - y +****************************************************************************/ + +static inline int xrt(int x, int y) +{ + return (s_v1->total_height - y); +} + +static inline int yrt(int x, int y) +{ + return(x); +} + +/**************************************************************************** +* print_screen_callback +****************************************************************************/ + +static boolean print_screen_callback(char *filename) +{ + s_printfp = fopen (filename, "wt"); + + if (s_printfp == NULL) + return(FALSE); + + /* + * This variable allows us to magically turn the view1 display + * code into a print-driver, with a minimum of fuss. The idea is to + * magically change TBOX_DRAW_XXX into TBOX_PRINT_XXX by adding + * the required value, aka s_print_offset. + * Make sure to fix g2.h if you mess here, or vice versa. + */ + s_print_offset = TBOX_PRINT_PLAIN - TBOX_DRAW_PLAIN; + + print_ps_header(s_v1, filename); + + display_pid_axis(s_v1); + display_event_data(s_v1); + display_time_axis(s_v1); + + fclose (s_printfp); + s_printfp = 0; + s_print_offset = 0; + + /* For tactile feedback */ + view1_display_when_idle(); + return(TRUE); +} + +/**************************************************************************** +* view1_button_click_callback +****************************************************************************/ + +static void view1_button_click_callback(GtkButton *item, gpointer data) +{ + enum view1_button_click click = (enum view1_button_click) data; + event_t *ep; + ulonglong event_incdec; + ulonglong current_width; + ulonglong zoom_delta; + + + current_width = s_v1->maxvistime - s_v1->minvistime; + event_incdec = (current_width) / 3; + + if (event_incdec == 0LL) + event_incdec = 1; + + zoom_delta = (s_v1->maxvistime - s_v1->minvistime) / 6; + + switch(click) { + case TOP_BUTTON: + /* First PID to top of window */ + s_v1->first_pid_index = 0; + GTK_ADJUSTMENT(s_view1_vsadj)->value = 0.00; + gtk_adjustment_value_changed(GTK_ADJUSTMENT(s_view1_vsadj)); + break; + + case BOTTOM_BUTTON: + s_v1->first_pid_index = g_npids - s_v1->npids; + if (s_v1->first_pid_index < 0) + s_v1->first_pid_index = 0; + GTK_ADJUSTMENT(s_view1_vsadj)->value = (gdouble)s_v1->first_pid_index; + gtk_adjustment_value_changed(GTK_ADJUSTMENT(s_view1_vsadj)); + break; + + case SNAP_BUTTON: + add_snapshot(); + break; + + case NEXT_BUTTON: + next_snapshot(); + break; + + case DEL_BUTTON: + del_snapshot(); + break; + + case CHASE_EVENT_BUTTON: + chase_event_etc(CHASE_EVENT); + break; + + case CHASE_DATUM_BUTTON: + chase_event_etc(CHASE_DATUM); + break; + + case CHASE_TRACK_BUTTON: + chase_event_etc(CHASE_TRACK); + break; + + case UNCHASE_BUTTON: + unchase_event_etc(); + break; + + case START_BUTTON: + start_button: + s_v1->minvistime = 0LL; + s_v1->maxvistime = current_width; + recompute_hscrollbar(); + break; + + case ZOOMIN_BUTTON: + s_v1->minvistime += zoom_delta; + s_v1->maxvistime -= zoom_delta; + recompute_hscrollbar(); + break; + + case SEARCH_AGAIN_BUTTON: + if (s_srchcode) { + event_search_internal(); + break; + } + /* NOTE FALLTHROUGH */ + + case SEARCH_BUTTON: + event_search(); + break; + + case ZOOMOUT_BUTTON: + if (zoom_delta == 0LL) + zoom_delta = 1; + + if (s_v1->minvistime >= zoom_delta) { + s_v1->minvistime -= zoom_delta; + s_v1->maxvistime += zoom_delta; + } else { + s_v1->minvistime = 0; + s_v1->maxvistime += zoom_delta*2; + } + + if ((s_v1->maxvistime - s_v1->minvistime) * 8 > + g_events[g_nevents-1].time * 9) { + s_v1->minvistime = 0; + s_v1->maxvistime = g_events[g_nevents-1].time * 9 / 8; + } + recompute_hscrollbar(); + break; + + case END_BUTTON: + ep = (g_events + g_nevents - 1); + s_v1->maxvistime = ep->time + event_incdec/3; + s_v1->minvistime = s_v1->maxvistime - current_width; + if (s_v1->minvistime > s_v1->maxvistime) + goto start_button; + recompute_hscrollbar(); + break; + + case MORE_TRACES_BUTTON: + /* Reduce the strip height to fit more traces on screen */ + s_v1->strip_height -= 1; + + if (s_v1->strip_height < 1) { + s_v1->strip_height = 1; + } + + /* Recalculate the number of strips on the screen */ + s_v1->npids = (s_v1->total_height - s_v1->time_ax_height) / + s_v1->strip_height; + recompute_vscrollbar(); + break; + + case LESS_TRACES_BUTTON: + /* Increase the strip height to fit fewer on the screen */ + s_v1->strip_height += 1; + if (s_v1->strip_height > 80) { + s_v1->strip_height = 80; + } + + /* Recalculate the number of strips on the screen */ + s_v1->npids = (s_v1->total_height - s_v1->time_ax_height) / + s_v1->strip_height; + recompute_vscrollbar(); + break; + + case FORWARD_BUTTON: + srch_chase_dir = SRCH_CHASE_FORWARD; + gtk_widget_hide (s_view1_forward_button); + gtk_widget_show (s_view1_backward_button); + break; + + case BACKWARD_BUTTON: + srch_chase_dir = SRCH_CHASE_BACKWARD; + gtk_widget_show (s_view1_forward_button); + gtk_widget_hide (s_view1_backward_button); + break; + + case SUMMARY_BUTTON: + summary_mode = TRUE; + gtk_widget_hide (s_view1_summary_button); + gtk_widget_show (s_view1_nosummary_button); + break; + + case NOSUMMARY_BUTTON: + summary_mode = FALSE; + gtk_widget_show (s_view1_summary_button); + gtk_widget_hide (s_view1_nosummary_button); + break; + } + + view1_display_when_idle(); +} + +/**************************************************************************** +* view1_print_callback +****************************************************************************/ + +void view1_print_callback (GtkToggleButton *notused, gpointer nu2) +{ + modal_dialog("Print Screen (PostScript format) to file:", + "Invalid file: Print Screen to file:", + "g2.ps", print_screen_callback); +} + +/**************************************************************************** +* view1_hscroll +****************************************************************************/ + +static void view1_hscroll (GtkAdjustment *adj, GtkWidget *notused) +{ + ulonglong current_width; + + current_width = (s_v1->maxvistime - s_v1->minvistime); + + s_v1->minvistime = (ulonglong)(adj->value); + s_v1->maxvistime = s_v1->minvistime + current_width; + + view1_display_when_idle(); + +#ifdef NOTDEF + g_print ("adj->lower = %.2f\n", adj->lower); + g_print ("adj->upper = %.2f\n", adj->upper); + g_print ("adj->value = %.2f\n", adj->value); + g_print ("adj->step_increment = %.2f\n", adj->step_increment); + g_print ("adj->page_increment = %.2f\n", adj->page_increment); + g_print ("adj->page_size = %.2f\n", adj->page_size); +#endif +} + +/**************************************************************************** +* view1_vscroll +****************************************************************************/ + +static void view1_vscroll (GtkAdjustment *adj, GtkWidget *notused) +{ + s_v1->first_pid_index = (int)adj->value; + view1_display_when_idle(); +} + +void set_pid_ax_width(int width) +{ + s_v1->pid_ax_width = width; + view1_display_when_idle(); +} + +/**************************************************************************** +* view1_init +****************************************************************************/ + +void view1_init(void) +{ + + c_view1_draw_width = atol(getprop_default("drawbox_width", "700")); + c_view1_draw_height = atol(getprop_default("drawbox_height", "400")); + + s_v1->pid_ax_width = 80; + s_v1->time_ax_height = 80; + s_v1->time_ax_spacing = 100; + s_v1->strip_height = 25; + s_v1->pop_offset = 20; + s_v1->pid_ax_offset = 34; + s_v1->event_offset = 40; + s_v1->total_height = c_view1_draw_height; + s_v1->total_width = c_view1_draw_width; + s_v1->first_pid_index = 0; + + s_v1->npids = (s_v1->total_height - s_v1->time_ax_height) / + s_v1->strip_height; + + s_v1->minvistime = 0; + s_v1->maxvistime = 200; + + s_view1_vbox = gtk_vbox_new(FALSE, 5); + + s_view1_hbox = gtk_hbox_new(FALSE, 5); + + da = gtk_drawing_area_new(); + gtk_drawing_area_size(GTK_DRAWING_AREA(da), c_view1_draw_width, + c_view1_draw_height); + +#ifdef NOTDEF + gtk_signal_connect (GTK_OBJECT (da), "motion_notify_event", + (GtkSignalFunc) motion_notify_event, NULL); +#endif + + gtk_signal_connect (GTK_OBJECT (da), "expose_event", + (GtkSignalFunc) expose_event, NULL); + + gtk_signal_connect (GTK_OBJECT(da),"configure_event", + (GtkSignalFunc) configure_event, NULL); + + gtk_signal_connect (GTK_OBJECT (da), "button_press_event", + (GtkSignalFunc) button_press_event, NULL); + + gtk_signal_connect (GTK_OBJECT (da), "button_release_event", + (GtkSignalFunc) button_press_event, NULL); + + gtk_signal_connect (GTK_OBJECT (da), "motion_notify_event", + (GtkSignalFunc) button_press_event, NULL); + + gtk_widget_set_events (da, GDK_BUTTON_PRESS_MASK + | GDK_BUTTON_RELEASE_MASK | GDK_EXPOSURE_MASK + | GDK_BUTTON_MOTION_MASK); + + + gtk_box_pack_start(GTK_BOX(s_view1_hbox), da, TRUE, TRUE, 0); + + g_font = gdk_font_load ("8x13"); + if (g_font == NULL) { + g_error("Couldn't load 8x13 font...\n"); + } + gdk_font_ref(g_font); + + /* PID axis menu */ + s_view1_vmenubox = gtk_vbox_new(FALSE, 5); + + s_view1_vsadj = gtk_adjustment_new(0.0 /* initial value */, + 0.0 /* minimum value */, + 2000.0 /* maximum value */, + 0.1 /* step increment */, + 10.0/* page increment */, + 10.0/* page size */); + + s_view1_vscroll = gtk_vscrollbar_new (GTK_ADJUSTMENT(s_view1_vsadj)); + + gtk_signal_connect (GTK_OBJECT (s_view1_vsadj), "value-changed", + GTK_SIGNAL_FUNC (view1_vscroll), + (gpointer)s_view1_vscroll); + + s_view1_topbutton = gtk_button_new_with_label("Top"); + s_view1_bottombutton = gtk_button_new_with_label("Bottom"); + + gtk_signal_connect (GTK_OBJECT(s_view1_topbutton), "clicked", + GTK_SIGNAL_FUNC(view1_button_click_callback), + (gpointer) TOP_BUTTON); + + gtk_signal_connect (GTK_OBJECT(s_view1_bottombutton), "clicked", + GTK_SIGNAL_FUNC(view1_button_click_callback), + (gpointer) BOTTOM_BUTTON); + + /* More Traces button and Less Traces button */ + s_view1_more_traces_button = gtk_button_new_with_label("More Traces"); + s_view1_less_traces_button = gtk_button_new_with_label("Less Traces"); + gtk_signal_connect (GTK_OBJECT(s_view1_more_traces_button), "clicked", + GTK_SIGNAL_FUNC(view1_button_click_callback), + (gpointer) MORE_TRACES_BUTTON); + gtk_signal_connect (GTK_OBJECT(s_view1_less_traces_button), "clicked", + GTK_SIGNAL_FUNC(view1_button_click_callback), + (gpointer) LESS_TRACES_BUTTON); + +#ifdef NOTDEF + /* Trick to bottom-justify the menu: */ + s_view1_pad1 = gtk_vbox_new(FALSE, 0); + gtk_box_pack_start (GTK_BOX(s_view1_vmenubox), s_view1_pad1, + TRUE, FALSE, 0); + +#endif + + gtk_box_pack_start (GTK_BOX(s_view1_vmenubox), s_view1_topbutton, + FALSE, FALSE, 0); + + gtk_box_pack_start (GTK_BOX(s_view1_vmenubox), s_view1_vscroll, + TRUE, TRUE, 0); + + gtk_box_pack_start (GTK_BOX(s_view1_vmenubox), s_view1_bottombutton, + FALSE, FALSE, 0); + + gtk_box_pack_start (GTK_BOX(s_view1_vmenubox), s_view1_more_traces_button, + FALSE, FALSE, 0); + + gtk_box_pack_start (GTK_BOX(s_view1_vmenubox), s_view1_less_traces_button, + FALSE, FALSE, 0); + + gtk_box_pack_start (GTK_BOX(s_view1_hbox), s_view1_vmenubox, + FALSE, FALSE, 0); + + /* Time axis menu */ + + s_view1_hmenubox = gtk_hbox_new(FALSE, 5); + + s_view1_startbutton = gtk_button_new_with_label("Start"); + + s_view1_zoominbutton = gtk_button_new_with_label("ZoomIn"); + + s_view1_searchbutton = gtk_button_new_with_label("Search"); + + s_view1_srchagainbutton = gtk_button_new_with_label("Search Again"); + + s_view1_zoomoutbutton = gtk_button_new_with_label("ZoomOut"); + + s_view1_endbutton = gtk_button_new_with_label("End"); + + gtk_signal_connect (GTK_OBJECT(s_view1_startbutton), "clicked", + GTK_SIGNAL_FUNC(view1_button_click_callback), + (gpointer) START_BUTTON); + + gtk_signal_connect (GTK_OBJECT(s_view1_zoominbutton), "clicked", + GTK_SIGNAL_FUNC(view1_button_click_callback), + (gpointer) ZOOMIN_BUTTON); + + gtk_signal_connect (GTK_OBJECT(s_view1_searchbutton), "clicked", + GTK_SIGNAL_FUNC(view1_button_click_callback), + (gpointer) SEARCH_BUTTON); + + gtk_signal_connect (GTK_OBJECT(s_view1_srchagainbutton), "clicked", + GTK_SIGNAL_FUNC(view1_button_click_callback), + (gpointer) SEARCH_AGAIN_BUTTON); + + gtk_signal_connect (GTK_OBJECT(s_view1_zoomoutbutton), "clicked", + GTK_SIGNAL_FUNC(view1_button_click_callback), + (gpointer) ZOOMOUT_BUTTON); + + gtk_signal_connect (GTK_OBJECT(s_view1_endbutton), "clicked", + GTK_SIGNAL_FUNC(view1_button_click_callback), + (gpointer) END_BUTTON); + + s_view1_hsadj = gtk_adjustment_new(0.0 /* initial value */, + 0.0 /* minimum value */, + 2000.0 /* maximum value */, + 0.1 /* step increment */, + 10.0/* page increment */, + 10.0/* page size */); + + s_view1_hscroll = gtk_hscrollbar_new (GTK_ADJUSTMENT(s_view1_hsadj)); + + gtk_signal_connect (GTK_OBJECT (s_view1_hsadj), "value-changed", + GTK_SIGNAL_FUNC (view1_hscroll), + (gpointer)s_view1_hscroll); + + gtk_box_pack_start (GTK_BOX(s_view1_hmenubox), s_view1_startbutton, + FALSE, FALSE, 0); + + gtk_box_pack_start (GTK_BOX(s_view1_hmenubox), s_view1_hscroll, + TRUE, TRUE, 0); + + gtk_box_pack_start (GTK_BOX(s_view1_hmenubox), s_view1_endbutton, + FALSE, FALSE, 0); + + gtk_box_pack_start (GTK_BOX(s_view1_hmenubox), s_view1_zoominbutton, + FALSE, FALSE, 0); + + gtk_box_pack_start (GTK_BOX(s_view1_hmenubox), s_view1_searchbutton, + FALSE, FALSE, 0); + + gtk_box_pack_start (GTK_BOX(s_view1_hmenubox), s_view1_srchagainbutton, + FALSE, FALSE, 0); + + gtk_box_pack_start (GTK_BOX(s_view1_hmenubox), s_view1_zoomoutbutton, + FALSE, FALSE, 0); + + gtk_box_pack_start (GTK_BOX(s_view1_vbox), s_view1_hbox, + TRUE, TRUE, 0); + + gtk_box_pack_start (GTK_BOX(s_view1_vbox), s_view1_hmenubox, + FALSE, FALSE, 0); + + + s_view1_hmenubox2 = gtk_hbox_new(FALSE, 5); + + s_view1_snapbutton = gtk_button_new_with_label("Snap"); + + s_view1_nextbutton = gtk_button_new_with_label("Next"); + + s_view1_delbutton = gtk_button_new_with_label("Del"); + + s_view1_chase_event_button = gtk_button_new_with_label("ChaseEvent"); + + s_view1_chase_datum_button = gtk_button_new_with_label("ChaseDatum"); + + s_view1_chase_track_button = gtk_button_new_with_label("ChaseTrack"); + + s_view1_unchasebutton = gtk_button_new_with_label("NoChase"); + + s_view1_forward_button = gtk_button_new_with_label("->SrchChase(is<-)"); + s_view1_backward_button = gtk_button_new_with_label("<-SrchChase(is->)"); + + s_view1_summary_button = gtk_button_new_with_label("Summary"); + s_view1_nosummary_button = gtk_button_new_with_label("NoSummary"); + + gtk_signal_connect (GTK_OBJECT(s_view1_snapbutton), "clicked", + GTK_SIGNAL_FUNC(view1_button_click_callback), + (gpointer) SNAP_BUTTON); + + gtk_signal_connect (GTK_OBJECT(s_view1_nextbutton), "clicked", + GTK_SIGNAL_FUNC(view1_button_click_callback), + (gpointer) NEXT_BUTTON); + + gtk_signal_connect (GTK_OBJECT(s_view1_delbutton), "clicked", + GTK_SIGNAL_FUNC(view1_button_click_callback), + (gpointer) DEL_BUTTON); + + gtk_signal_connect (GTK_OBJECT(s_view1_chase_event_button), "clicked", + GTK_SIGNAL_FUNC(view1_button_click_callback), + (gpointer) CHASE_EVENT_BUTTON); + + gtk_signal_connect (GTK_OBJECT(s_view1_chase_datum_button), "clicked", + GTK_SIGNAL_FUNC(view1_button_click_callback), + (gpointer) CHASE_DATUM_BUTTON); + + gtk_signal_connect (GTK_OBJECT(s_view1_chase_track_button), "clicked", + GTK_SIGNAL_FUNC(view1_button_click_callback), + (gpointer) CHASE_TRACK_BUTTON); + + gtk_signal_connect (GTK_OBJECT(s_view1_unchasebutton), "clicked", + GTK_SIGNAL_FUNC(view1_button_click_callback), + (gpointer) UNCHASE_BUTTON); + + gtk_signal_connect (GTK_OBJECT(s_view1_forward_button), "clicked", + GTK_SIGNAL_FUNC(view1_button_click_callback), + (gpointer) FORWARD_BUTTON); + + gtk_signal_connect (GTK_OBJECT(s_view1_backward_button), "clicked", + GTK_SIGNAL_FUNC(view1_button_click_callback), + (gpointer) BACKWARD_BUTTON); + + gtk_signal_connect (GTK_OBJECT(s_view1_summary_button), "clicked", + GTK_SIGNAL_FUNC(view1_button_click_callback), + (gpointer) SUMMARY_BUTTON); + + gtk_signal_connect (GTK_OBJECT(s_view1_nosummary_button), "clicked", + GTK_SIGNAL_FUNC(view1_button_click_callback), + (gpointer) NOSUMMARY_BUTTON); + + gtk_box_pack_start (GTK_BOX(s_view1_vbox), s_view1_hmenubox2, + FALSE, FALSE, 0); + + gtk_box_pack_start (GTK_BOX(s_view1_hmenubox2), s_view1_snapbutton, + FALSE, FALSE, 0); + + gtk_box_pack_start (GTK_BOX(s_view1_hmenubox2), s_view1_nextbutton, + FALSE, FALSE, 0); + + gtk_box_pack_start (GTK_BOX(s_view1_hmenubox2), s_view1_delbutton, + FALSE, FALSE, 0); + + gtk_box_pack_start (GTK_BOX(s_view1_hmenubox2), s_view1_chase_event_button, + FALSE, FALSE, 0); + + gtk_box_pack_start (GTK_BOX(s_view1_hmenubox2), s_view1_chase_datum_button, + FALSE, FALSE, 0); + + gtk_box_pack_start (GTK_BOX(s_view1_hmenubox2), s_view1_chase_track_button, + FALSE, FALSE, 0); + + gtk_box_pack_start (GTK_BOX(s_view1_hmenubox2), s_view1_unchasebutton, + FALSE, FALSE, 0); + + gtk_box_pack_start (GTK_BOX(s_view1_hmenubox2), s_view1_forward_button, + FALSE, FALSE, 0); + + gtk_box_pack_start (GTK_BOX(s_view1_hmenubox2), s_view1_backward_button, + FALSE, FALSE, 0); + + gtk_box_pack_start (GTK_BOX(s_view1_hmenubox2), s_view1_summary_button, + FALSE, FALSE, 0); + + gtk_box_pack_start (GTK_BOX(s_view1_hmenubox2), s_view1_nosummary_button, + FALSE, FALSE, 0); + + s_view1_label = gtk_label_new(NULL); + + gtk_box_pack_start (GTK_BOX(s_view1_vbox), s_view1_label, + FALSE, FALSE, 0); + + gtk_box_pack_start (GTK_BOX(g_mainhbox), s_view1_vbox, + TRUE, TRUE, 0); + + gtk_widget_show_all (s_view1_vbox); + GTK_WIDGET_SET_FLAGS(da, GTK_CAN_FOCUS); + gtk_widget_grab_focus(da); + + gtk_widget_hide (s_view1_forward_button); + gtk_widget_hide (summary_mode ? s_view1_summary_button + : s_view1_nosummary_button); + + zi_source = gdk_bitmap_create_from_data (NULL, (char *)zi_bits, zi_width, + zi_height); + zi_mask = gdk_bitmap_create_from_data (NULL, (char *)zi_bkgd, zi_width, + zi_height); + + zi_cursor = (GdkCursor *) gdk_cursor_new_from_pixmap (zi_source, + zi_mask, &fg_black, + &bg_white, zi_x_hot, + zi_y_hot); + gdk_pixmap_unref (zi_source); + gdk_pixmap_unref (zi_mask); + + norm_cursor = (GdkCursor *) gdk_cursor_new (GDK_TOP_LEFT_ARROW); +} + +/**************************************************************************** +* line_print +****************************************************************************/ + +void line_print (int x1, int y1, int x2, int y2) +{ + fprintf(s_printfp, "newpath\n"); + fprintf(s_printfp, "%d %d moveto\n", xrt(x1, s_v1->total_height - y1), + yrt(x1, s_v1->total_height - y1)); + + fprintf(s_printfp, "%d %d lineto\n", xrt (x2, s_v1->total_height - y2), + yrt (x2, s_v1->total_height - y2)); + fprintf(s_printfp, "1 setlinewidth\n"); + fprintf(s_printfp, "stroke\n"); +} + +/**************************************************************************** +* tbox_print +****************************************************************************/ +GdkRectangle *tbox_print (char *s, int x, int y, enum view1_tbox_fn function, + GdkRectangle *rp) +{ + if (function == TBOX_PRINT_BOXED) { + rp->width -= 4; + } + + if ((function == TBOX_PRINT_BOXED) || + (function == TBOX_PRINT_EVENT)) { + + fprintf(s_printfp, "newpath\n"); + fprintf(s_printfp, "0 setlinewidth\n"); + fprintf(s_printfp, "%d %d moveto\n", + xrt(rp->x, s_v1->total_height - rp->y), + yrt(rp->x, s_v1->total_height - rp->y)); + + fprintf(s_printfp, "%d %d lineto\n", + xrt (rp->x+rp->width, s_v1->total_height - rp->y), + yrt (rp->x+rp->width, s_v1->total_height - rp->y)); + + fprintf(s_printfp, "%d %d lineto\n", + xrt(rp->x+rp->width, s_v1->total_height - (rp->y+rp->height)), + yrt(rp->x+rp->width, s_v1->total_height - (rp->y+rp->height))); + + fprintf(s_printfp, "%d %d lineto\n", + xrt(rp->x, s_v1->total_height - (rp->y+rp->height)), + yrt(rp->x, s_v1->total_height - (rp->y+rp->height))); + + fprintf(s_printfp, "%d %d lineto\n", + xrt(rp->x, s_v1->total_height - rp->y), + yrt(rp->x, s_v1->total_height - rp->y)); + + fprintf(s_printfp, "stroke\n"); + } + + if ((function == TBOX_PRINT_BOXED) || + (function == TBOX_PRINT_PLAIN)) { + + fprintf(s_printfp, "newpath\n"); + fprintf(s_printfp, "%d %d moveto\n", + xrt(x, s_v1->total_height - (y-2)), + yrt(x, s_v1->total_height - (y-2))); + fprintf(s_printfp, "gsave\n"); + fprintf(s_printfp, "90 rotate\n"); + fprintf(s_printfp, "(%s) show\n", s); + fprintf(s_printfp, "grestore\n"); + } + + return(rp); +} + +/**************************************************************************** +* tbox - draws an optionally boxed string whose lower lefthand +* corner is at (x, y). As usual, Y is backwards. +****************************************************************************/ + +GdkRectangle *tbox (char *s, int x, int y, enum view1_tbox_fn function) +{ + static GdkRectangle update_rect; + gint lbearing, rbearing, width, ascent, descent; + + gdk_string_extents (g_font, s, + &lbearing, &rbearing, + &width, &ascent, &descent); + + /* + * If we have enough room to display full size events, then just + * use the BOXED function instead of the EVENT function. + */ + if (s_v1->strip_height > 9) { + switch (function) { + case TBOX_DRAW_EVENT: function = TBOX_DRAW_BOXED; break; + case TBOX_GETRECT_EVENT: function = TBOX_GETRECT_BOXED; break; + case TBOX_PRINT_EVENT: function = TBOX_PRINT_BOXED; break; + default: + break; + /* Nothing */ + } + } + + switch (function) { + case TBOX_DRAW_BOXED: + gdk_draw_rectangle (pm, da->style->white_gc, TRUE, + x, y - (ascent+descent+3), width + 2, + ascent + descent + 3); + + gdk_draw_rectangle (pm, da->style->black_gc, FALSE, + x, y - (ascent+descent+3), width + 2, + ascent + descent + 3); + + gdk_draw_string (pm, g_font, da->style->black_gc, + x + 1, y - 1, (const gchar *)s); + /* NOTE FALLTHROUGH */ + case TBOX_GETRECT_BOXED: + update_rect.x = x; + update_rect.y = y -(ascent+descent+3); + update_rect.width = width + 3; + update_rect.height = ascent + descent + 4; + if (function == TBOX_DRAW_BOXED) + gtk_widget_draw (da, &update_rect); + break; + + case TBOX_DRAW_EVENT: + /* We have a small event to draw...no text */ + gdk_draw_rectangle (pm, da->style->black_gc, FALSE, + x, y - 1, 3, 3); + /* NOTE FALLTHROUGH */ + case TBOX_GETRECT_EVENT: + update_rect.x = x; + update_rect.y = y - 1; + update_rect.width = 4; + update_rect.height = 4; + if (function == TBOX_DRAW_EVENT) + gtk_widget_draw (da, &update_rect); + break; + + + case TBOX_DRAW_PLAIN: + + gdk_draw_string (pm, g_font, da->style->black_gc, + x + 1, y - 1, (const gchar *)s); + /* NOTE FALLTHROUGH */ + case TBOX_GETRECT_PLAIN: + update_rect.x = x; + update_rect.y = y -(ascent+descent+1); + update_rect.width = width; + update_rect.height = ascent + descent; + if (function == TBOX_DRAW_PLAIN) + gtk_widget_draw (da, &update_rect); + break; + + case TBOX_PRINT_BOXED: + update_rect.x = x; + update_rect.y = y -(ascent+descent+3); + update_rect.width = width + 3; + update_rect.height = ascent + descent + 4; + /* note fallthrough */ + case TBOX_PRINT_PLAIN: + return(tbox_print(s, x, y, function, &update_rect)); + + case TBOX_PRINT_EVENT: + /* We have a small event box to print...no text */ + update_rect.x = x; + update_rect.y = y - 1; + update_rect.width = 4; + update_rect.height = 4; + return(tbox_print(s, x, y, function, &update_rect)); + } + return(&update_rect); +} + +/**************************************************************************** +* line +* +* For lines there is a primitive batching facility, that doesn't update +* the drawing area until the batch is complete. This is handy for drawing +* the pid axis and for summary mode. +* +* line_batch_mode contains the state for this: +* +* BATCH_OFF: no batching, update for every line +* BATCH_NEW: just entered a batch, so initialize the area to update from +* scratch +* BATCH_EXISTING: have drawn at least one line in batch mode, so the update +* area should only be expanded from now on to include the +* union of the "rectangular hull" of all lines +****************************************************************************/ + +static enum { BATCH_OFF, BATCH_NEW, BATCH_EXISTING } line_batch_mode; +static int line_batch_count; +static int line_minx, line_miny, line_maxx, line_maxy; + +void line_batch_start (void) +{ + line_batch_mode = BATCH_NEW; + line_batch_count = 0; +} + +void line_batch_end (void) +{ + GdkRectangle update_rect; + if (line_batch_count > 0) { + update_rect.x = line_minx; + update_rect.y = line_miny; + update_rect.width = (line_maxx - line_minx) + 1; + update_rect.height = (line_maxy - line_miny) + 1; + gtk_widget_draw (da, &update_rect); + } + line_batch_mode = BATCH_OFF; +} + +void line (int x1, int y1, int x2, int y2, enum view1_line_fn function) +{ + GdkRectangle update_rect; + GdkGC *gc = NULL; + + switch(function) { + case LINE_DRAW_BLACK: + gc = da->style->black_gc; + break; + + case LINE_DRAW_WHITE: + gc = da->style->white_gc; + break; + + case LINE_PRINT: + line_print (x1, y1, x2, y2); + return; + } + + gdk_draw_line (pm, gc, x1, y1, x2, y2); + + switch (line_batch_mode) { + case BATCH_OFF: + update_rect.x = x1; + update_rect.y = y1; + update_rect.width = (x2-x1) + 1; + update_rect.height = (y2-y1) + 1; + gtk_widget_draw (da, &update_rect); + break; + + case BATCH_NEW: + line_minx = x1; + line_maxx = x2; + line_miny = y1; + line_maxy = y2; + line_batch_mode = BATCH_EXISTING; + line_batch_count = 1; + break; + + case BATCH_EXISTING: + if (line_minx > x1) + line_minx = x1; + if (line_miny > y1) + line_miny = y1; + if (line_maxx < x2) + line_maxx = x2; + if (line_maxy < y2) + line_maxy = y2; + line_batch_count++; + break; + } +} + + +/**************************************************************************** +* display_pid_axis +****************************************************************************/ + +static void display_pid_axis(v1_geometry_t *vp) +{ + int y, i, label_tick; + int last_printed_y = -vp->strip_height; + pid_sort_t *pp; + int pid_index; + char *label_fmt; + char tmpbuf [128]; + + /* No pids yet? Outta here */ + if (g_pids == NULL) + return; + + line_batch_start(); + + for (i = 0; i < vp->npids; i++) { + pid_index = vp->first_pid_index + i; + if (pid_index >= g_npids) + break; + + set_color(pid_index); + pp = (g_pids + pid_index); + + label_fmt = get_track_label(pp->pid_value); + snprintf(tmpbuf, sizeof(tmpbuf)-1, label_fmt, pp->pid_value); + + y = i*vp->strip_height + vp->pid_ax_offset; + + /* + * Have we incremented enough space to have another label not + * overlap the previous label? + */ + if (y - last_printed_y > 9) { + /* Draw label */ + tbox(tmpbuf, 0, y +4, TBOX_DRAW_PLAIN+s_print_offset); + + last_printed_y = y; + + /* + * And let the line stick out a bit more to indicate this label + * relates to the following line. + */ + label_tick = 4; + } + else { + label_tick = 0; + } + + /* Draw axis line, but only if the lines aren't too close together */ + if (vp->strip_height > 4) { + line(vp->pid_ax_width - label_tick, y+4*s_print_offset, + vp->total_width, y+4*s_print_offset, + LINE_DRAW_BLACK+s_print_offset); + } + } + + set_color(COLOR_DEFAULT); + line_batch_end(); +} + +/**************************************************************************** +* view1_read_events_callback +* New event data just showed up, reset a few things. +****************************************************************************/ + +void view1_read_events_callback(void) +{ + int max_vis_index; + + s_v1->first_pid_index = 0; + + max_vis_index = 300; + if (max_vis_index > g_nevents) + max_vis_index = g_nevents-1; + + s_v1->minvistime = 0LL; + s_v1->maxvistime = (g_events[g_nevents - 1].time * 9)/ 8; + s_srchindex = 0; + s_srchcode = 0; + s_last_selected_event = 0; + + init_track_colors(); + + recompute_hscrollbar(); + recompute_vscrollbar(); +} + +/**************************************************************************** +* display_event_data +****************************************************************************/ + +static void display_event_data(v1_geometry_t *vp) +{ + int start_index; + int pid_index; + int x, y; + event_t *ep; + event_def_t *edp; + double time_per_pixel; + char tmpbuf[1024]; + GdkRectangle *print_rect; + int *last_x_used; + + /* Happens if one loads the event def header first, for example. */ + if (g_nevents == 0) + return; + + time_per_pixel = dtime_per_pixel(vp); + + start_index = find_event_index (vp->minvistime); + + /* Scrolled too far right? */ + if (start_index >= g_nevents) + return; + + ep = (g_events + start_index); + + if (s_print_offset || summary_mode) { + last_x_used = (int *)g_malloc0(vp->npids * sizeof(int)); + } else { + last_x_used = NULL; + } + + line_batch_start(); + + while (ep < (g_events + g_nevents) && + (ep->time < vp->maxvistime)) { + pid_index = ep->pid->pid_index; + set_color(pid_index); + + /* First filter: pid out of range */ + if ((pid_index < vp->first_pid_index) || + (pid_index >= vp->first_pid_index + vp->npids)) { + ep++; + continue; + } + + /* Second filter: event hidden */ + edp = find_event_definition (ep->code); + if (!edp->selected) { + ep++; + continue; + } + + /* Display it... */ + + pid_index -= vp->first_pid_index; + + y = pid_index*vp->strip_height + vp->event_offset; + + x = vp->pid_ax_width + + (int)(((double)(ep->time - vp->minvistime)) / time_per_pixel); + + if (last_x_used != NULL && x < last_x_used[pid_index]) { + ep++; + continue; + } + + if (ep->flags & (EVENT_FLAG_SELECT | EVENT_FLAG_SEARCHRSLT)) { + if (ep->flags & EVENT_FLAG_SELECT) { + format_popbox_string(tmpbuf, sizeof(tmpbuf), ep, edp); +#ifdef NOTDEF + sprintf(tmpbuf, edp->name); + sprintf(tmpbuf+strlen(tmpbuf), ": "); + sprintf(tmpbuf+strlen(tmpbuf), edp->format, ep->datum); +#endif + } else { + sprintf(tmpbuf, "SEARCH RESULT"); + } + print_rect = tbox(tmpbuf, x, y - vp->pop_offset, + TBOX_DRAW_BOXED+s_print_offset); + line(x, y-vp->pop_offset, x, y, LINE_DRAW_BLACK+s_print_offset); + if (last_x_used != NULL) + last_x_used[pid_index] = x + print_rect->width; + } + if (summary_mode) { + int delta = vp->strip_height / 3; + if (delta < 1) + delta = 1; + y = pid_index*vp->strip_height + vp->pid_ax_offset; + line(x, y - delta, x, y + delta, LINE_DRAW_BLACK); + last_x_used[pid_index] = x + 1; + } else { + sprintf(tmpbuf, "%ld", ep->code); + print_rect = tbox(tmpbuf, x, y, TBOX_DRAW_EVENT+s_print_offset); + if (last_x_used != NULL) + last_x_used[pid_index] = x + print_rect->width; + } + + ep++; + } + if (last_x_used) + g_free(last_x_used); + line_batch_end(); + set_color(COLOR_DEFAULT); +} + +/**************************************************************************** +* display_clear +****************************************************************************/ + +static void display_clear(void) +{ + GdkRectangle update_rect; + + gdk_draw_rectangle (pm, da->style->white_gc, TRUE, + 0, 0, da->allocation.width, + da->allocation.height); + + update_rect.x = 0; + update_rect.y = 0; + update_rect.width = da->allocation.width; + update_rect.height = da->allocation.height; + + gtk_widget_draw (da, &update_rect); +} + +/**************************************************************************** +* display_time_axis +****************************************************************************/ + +static void display_time_axis(v1_geometry_t *vp) +{ + int x, y, i; + int xoffset, nticks; + char tmpbuf [128]; + double unit_divisor; + double time; + char *units; + double time_per_pixel; + + y = vp->npids * vp->strip_height + vp->pid_ax_offset; + + x = vp->pid_ax_width; + + nticks = (vp->total_width - vp->pid_ax_width) / vp->time_ax_spacing; + + time_per_pixel = dtime_per_pixel(vp); + + units = "ns"; + unit_divisor = 1.00; + + if ((vp->maxvistime / unit_divisor) > 1000) { + units = "us"; + unit_divisor = 1000.00; + } + + if ((vp->maxvistime / unit_divisor) > 1000) { + units = "ms"; + unit_divisor = 1000.00*1000.00; + } + if ((vp->maxvistime / unit_divisor) > 1000) { + units = "s"; + unit_divisor = 1000.00*1000.00*1000.00; + } + + /* Draw line */ + line(x, y, vp->total_width, y, LINE_DRAW_BLACK+s_print_offset); + + xoffset = 0; + + for (i = 0; i < nticks; i++) { + /* Tick mark */ + line(x+xoffset, y-3, x+xoffset, y+3, LINE_DRAW_BLACK+s_print_offset); + + time = (double)(x + xoffset - vp->pid_ax_width); + time *= time_per_pixel; + time += (double)(vp->minvistime); + time /= unit_divisor; + + sprintf (tmpbuf, "%.2f%s", time, units); + + tbox(tmpbuf, x+xoffset, y+15, TBOX_DRAW_PLAIN+s_print_offset); + + xoffset += vp->time_ax_spacing; + } +} + +/**************************************************************************** +* clear_scoreboard +* Forget about any temporary displays, they're gone now... +****************************************************************************/ + +static void clear_scoreboard(void) +{ + s_result_up = FALSE; +} + +/**************************************************************************** +* view1_display +****************************************************************************/ + +void view1_display(void) +{ + display_clear(); + display_pid_axis(s_v1); + display_event_data(s_v1); + display_time_axis(s_v1); + clear_scoreboard(); +} + +static gint idle_tag; + +/**************************************************************************** +* view1_display_eventually +****************************************************************************/ + +static void view1_display_eventually(void) +{ + gtk_idle_remove(idle_tag); + idle_tag = 0; + view1_display(); +} + + +/**************************************************************************** +* view1_display_when_idle +****************************************************************************/ + +void view1_display_when_idle(void) +{ + if (idle_tag == 0) { + idle_tag = gtk_idle_add((GtkFunction) view1_display_eventually, 0); + } +} + +/**************************************************************************** +* view1_about +****************************************************************************/ + +void view1_about (char *tmpbuf) +{ + int nsnaps; + snapshot_t *snaps; + + sprintf(tmpbuf+strlen(tmpbuf), "Minvistime %lld\nMaxvistime %lld\n", + s_v1->minvistime, s_v1->maxvistime); + sprintf(tmpbuf+strlen(tmpbuf), "Strip Height %d\n", + s_v1->strip_height); + + for (nsnaps = 0, snaps = s_snapshots; snaps; snaps = snaps->next) { + nsnaps++; + } + sprintf(tmpbuf+strlen(tmpbuf), "%d snapshots in the ring\n", nsnaps); +} diff --git a/src/tools/perftool/c2cpel.c b/src/tools/perftool/c2cpel.c new file mode 100644 index 00000000..38e6fe52 --- /dev/null +++ b/src/tools/perftool/c2cpel.c @@ -0,0 +1,248 @@ +/* + *------------------------------------------------------------------ + * Copyright (c) 2006-2016 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "cpel.h" +#include "cpel_util.h" + +static elog_main_t elog_main; + +/* + * convert_clib_file + */ +void convert_clib_file(char *clib_file) +{ + clib_error_t *error = 0; + int i; + elog_main_t *em = &elog_main; + double starttime, delta; + + error = elog_read_file (&elog_main, clib_file); + + if (error) { + clib_warning("%U", format_clib_error, error); + exit (1); + } + + em = &elog_main; + + starttime = em->events[0].time; + + for (i = 0; i < vec_len (em->events); i++) { + elog_event_t *e; /* clib event */ + evt_t *ep; /* xxx2cpel event */ + u8 *s; + u64 timestamp; + elog_event_type_t *t; + u8 *brief_event_name; + u8 *track_name; + int j; + + e = vec_elt_at_index(em->events, i); + + /* Seconds since start of log */ + delta = e->time - starttime; + + /* u64 nanoseconds since start of log */ + timestamp = delta * 1e9; + + s = format (0, "%U%c", format_elog_event, em, e, 0); + + /* allocate an event instance */ + vec_add2(the_events, ep, 1); + ep->timestamp = timestamp; + + /* convert string event code to a real number */ + t = vec_elt_at_index (em->event_types, e->type); + + /* + * Construct a reasonable event name. + * Truncate the format string at the first whitespace break + * or printf format character. + */ + brief_event_name = format (0, "%s", t->format); + + for (j = 0; j < vec_len (brief_event_name); j++) { + if (brief_event_name[j] == ' ' || + brief_event_name[j] == '%' || + brief_event_name[j] == '(') { + brief_event_name[j] = 0; + break; + } + } + /* Throw away that much of the formatted event */ + vec_delete (s, j+1, 0); + + ep->event_id = find_or_add_event(brief_event_name, "%s"); + + track_name = format (0, "%U%c", format_elog_track, em, e, 0); + + ep->track_id = find_or_add_track (track_name); + + ep->datum = find_or_add_strtab(s); + + vec_free (track_name); + vec_free(brief_event_name); + vec_free(s); + } +} + +u8 *vec_basename (char *s) +{ + u8 * rv; + char *cp = s; + + while (*cp) + cp++; + + cp--; + + while (cp > s && *cp != '/') + cp--; + + if (cp > s) + cp++; + + rv = format (0, "%s", cp); + return rv; +} + + +int event_compare (const void *a0, const void *a1) +{ + evt_t *e0 = (evt_t *)a0; + evt_t *e1 = (evt_t *)a1; + + if (e0->timestamp < e1->timestamp) + return -1; + else if (e0->timestamp > e1->timestamp) + return 1; + return 0; +} + +int main (int argc, char **argv) +{ + int curarg=1; + char **inputfiles = 0; + char *outputfile = 0; + FILE *ofp; + + if (argc < 3) + goto usage; + + while (curarg < argc) { + if (!strncmp(argv[curarg], "--input-file", 3)) { + curarg++; + if (curarg < argc) { + vec_add1 (inputfiles, argv[curarg]); + curarg++; + continue; + } + clib_warning("Missing filename after --input-file\n"); + exit (1); + } + + if (!strncmp(argv[curarg], "--output-file", 3)) { + curarg ++; + if (curarg < argc) { + outputfile = argv[curarg]; + curarg ++; + continue; + } + clib_warning("Missing filename after --output-file\n"); + exit(1); + } + vec_add1 (inputfiles, argv[curarg]); + curarg++; + continue; + + usage: + fformat(stderr, + "c2cpel [--input-file] --output-file \n"); + exit(1); + } + + if (vec_len(inputfiles) == 0 || outputfile == 0) + goto usage; + + if (vec_len(inputfiles) > 1) + goto usage; + + cpel_util_init(); + + convert_clib_file (inputfiles[0]); + + ofp = fopen (outputfile, "w"); + if (ofp == NULL) { + clib_unix_warning ("couldn't create %s", outputfile); + exit (1); + } + + alpha_sort_tracks(); + fixup_event_tracks(); + + /* + * Four sections: string-table, event definitions, track defs, events. + */ + if (!write_cpel_header(ofp, 4)) { + clib_warning ("Error writing cpel header to %s...\n", outputfile); + unlink(outputfile); + exit(1); + } + + if (!write_string_table(ofp)) { + clib_warning ("Error writing string table to %s...\n", outputfile); + unlink(outputfile); + exit(1); + } + + if (!write_event_defs(ofp)) { + clib_warning ("Error writing event defs to %s...\n", outputfile); + unlink(outputfile); + exit(1); + } + + if (!write_track_defs(ofp)) { + clib_warning ("Error writing track defs to %s...\n", outputfile); + unlink(outputfile); + exit(1); + } + + if (!write_events(ofp, (u64) 1e9)) { + clib_warning ("Error writing events to %s...\n", outputfile); + unlink(outputfile); + exit(1); + + } + fclose(ofp); + exit (0); +} diff --git a/src/tools/perftool/configure.ac b/src/tools/perftool/configure.ac new file mode 100644 index 00000000..f4a98697 --- /dev/null +++ b/src/tools/perftool/configure.ac @@ -0,0 +1,12 @@ +AC_INIT(perftool, 2.0) +AM_INIT_AUTOMAKE +AM_SILENT_RULES([yes]) + +AC_CHECK_LIB([vppinfra], [clib_mem_get_page_size],, + AC_MSG_ERROR([Please install the vpp-lib package])) +AC_CHECK_HEADER([vppinfra/clib.h],, + AC_MSG_ERROR([Please install the vpp-dev package])) + +AM_PROG_LIBTOOL + +AC_OUTPUT([Makefile]) diff --git a/src/tools/perftool/cpel.h b/src/tools/perftool/cpel.h new file mode 100644 index 00000000..0bfb1a68 --- /dev/null +++ b/src/tools/perftool/cpel.h @@ -0,0 +1,83 @@ +/* + *------------------------------------------------------------------ + * Copyright (c) 2005-2016 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _CPEL_H_ +#define _CPEL_H_ 1 + +typedef struct cpel_file_header_ { + unsigned char endian_version; + unsigned char pad; + unsigned short nsections; + unsigned int file_date; +} cpel_file_header_t; + +#define CPEL_FILE_LITTLE_ENDIAN 0x80 +#define CPEL_FILE_VERSION 0x01 +#define CPEL_FILE_VERSION_MASK 0x7F + +typedef struct cpel_section_header_ { + unsigned int section_type; + unsigned int data_length; /* does NOT include type and itself */ +} cpel_section_header_t; + +#define CPEL_SECTION_STRTAB 1 +/* string at offset 0 is the name of the table */ + +#define CPEL_SECTION_SYMTAB 2 +#define CPEL_SECTION_EVTDEF 3 + +typedef struct event_definition_section_header_ { + char string_table_name[64]; + unsigned int number_of_event_definitions; +} event_definition_section_header_t; + +typedef struct event_definition_ { + unsigned int event; + unsigned int event_format; + unsigned int datum_format; +} event_definition_t; + +#define CPEL_SECTION_TRACKDEF 4 + +typedef struct track_definition_section_header_ { + char string_table_name[64]; + unsigned int number_of_track_definitions; +} track_definition_section_header_t; + +typedef struct track_definition_ { + unsigned int track; + unsigned int track_format; +} track_definition_t; + +#define CPEL_SECTION_EVENT 5 + +typedef struct event_section_header_ { + char string_table_name[64]; + unsigned int number_of_events; + unsigned int clock_ticks_per_second; +} event_section_header_t; + +typedef struct event_entry_ { + unsigned int time[2]; + unsigned int track; + unsigned int event_code; + unsigned int event_datum; +} event_entry_t; + +#define CPEL_NUM_SECTION_TYPES 5 + +#endif /* _CPEL_H_ */ + diff --git a/src/tools/perftool/cpel_util.c b/src/tools/perftool/cpel_util.c new file mode 100644 index 00000000..7ee9b6e2 --- /dev/null +++ b/src/tools/perftool/cpel_util.c @@ -0,0 +1,456 @@ +/* + *------------------------------------------------------------------ + * Copyright (c) 2006-2016 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "cpel.h" +#include "cpel_util.h" + +evt_t *the_events; + +track_t *the_tracks; +u32 *track_alpha_map; + +event_definition_t *the_event_definitions; +i64 min_timestamp; + +/* Hash tables, used to find previous instances of the same items */ +uword *the_track_hash; +uword *the_msg_event_hash; +uword *the_strtab_hash; +uword *the_pidtid_hash; +uword *the_pid_to_name_hash; +u8 *the_strtab; + +uword *the_event_id_bitmap; + +/* + * find_or_add_strtab + * Finds or adds a string to the string table + */ +u32 find_or_add_strtab(void *s_arg) +{ + uword *p; + int len; + u8 *this_string; + u8 *scopy=0; + char *s = s_arg; + + p = hash_get_mem(the_strtab_hash, s); + if (p) { + return (p[0]); + } + + /* + * Here's a CLIB bear-trap. We can't add the string-table + * strings to the to the hash table (directly), since it + * expands and moves periodically. All of the hash table + * entries turn into dangling references, yadda yadda. + */ + + len = strlen(s)+1; + vec_add2(the_strtab, this_string, len); + memcpy(this_string, s, len); + + /* Make a copy which won't be moving around... */ + vec_validate(scopy, len); + memcpy(scopy, s, len); + + hash_set_mem(the_strtab_hash, scopy, this_string - the_strtab); + + return(this_string - the_strtab); +} + +/* + * find_or_add_track + * returns index in track table + */ +u32 find_or_add_track(void *s_arg) +{ + uword *p; + track_t *this_track; + u8 *copy_s; + char *s=s_arg; + + p = hash_get_mem(the_track_hash, s); + if (p) { + return (p[0]); + } + vec_add2(the_tracks, this_track, 1); + + this_track->original_index = this_track - the_tracks; + this_track->strtab_offset = find_or_add_strtab(s); + + copy_s = (u8 *)vec_dup(s); + + hash_set_mem(the_track_hash, copy_s, this_track - the_tracks); + return(this_track - the_tracks); +} + +/* + * find_or_add_event + * Adds an event to the event definition vector and add it to + * the event hash table + */ + +u32 find_or_add_event(void *s_arg, char *datum_format) +{ + uword *p; + u8 *copy_s; + event_definition_t *this_event_definition; + u32 event_id; + char *s=s_arg; + + p = hash_get_mem(the_msg_event_hash, s); + if (p) { + return (p[0]); + } + vec_add2(the_event_definitions, this_event_definition, 1); + + /* Allocate a new event-id */ + event_id = clib_bitmap_first_clear (the_event_id_bitmap); + the_event_id_bitmap = clib_bitmap_set(the_event_id_bitmap, event_id, 1); + this_event_definition->event = event_id; + this_event_definition->event_format = find_or_add_strtab(s); + this_event_definition->datum_format = find_or_add_strtab(datum_format); + + copy_s = (u8 *)vec_dup(s); + + hash_set_mem(the_msg_event_hash, copy_s, event_id); + + return(event_id); +} + +/* + * write_string_table + */ +int write_string_table(FILE *ofp) +{ + cpel_section_header_t sh; + + /* Round up string table size */ + while (vec_len(the_strtab) & 0x7) + vec_add1(the_strtab, 0); + + sh.section_type = ntohl(CPEL_SECTION_STRTAB); + sh.data_length = ntohl(vec_len(the_strtab)); + + if (fwrite(&sh, sizeof(sh), 1, ofp) != 1) + return(0); + + if (fwrite(the_strtab, 1, vec_len(the_strtab), ofp) != + vec_len(the_strtab)) + return(0); + + return(1); +} + +/* + * write_cpel_header + */ +int write_cpel_header(FILE *ofp, u32 nsections) +{ + cpel_file_header_t h; + + h.endian_version = CPEL_FILE_VERSION; + h.pad = 0; + h.nsections = ntohs(nsections); + h.file_date = ntohl(time(0)); + if (fwrite(&h, sizeof(h), 1, ofp) != 1) + return (0); + + return(1); +} + +/* + * write_event_defs + */ +int write_event_defs(FILE *ofp) +{ + cpel_section_header_t sh; + event_definition_section_header_t edsh; + event_definition_t *this_event_definition; + int i; + + /* Next, the event definitions */ + sh.section_type = ntohl(CPEL_SECTION_EVTDEF); + sh.data_length = ntohl(vec_len(the_event_definitions) + *sizeof(the_event_definitions[0]) + + sizeof(event_definition_section_header_t)); + + if (fwrite(&sh, sizeof(sh), 1, ofp) != 1) + return(0); + + memset(&edsh, 0, sizeof(edsh)); + + strcpy(edsh.string_table_name, "FileStrtab"); + edsh.number_of_event_definitions = ntohl(vec_len(the_event_definitions)); + + if (fwrite(&edsh, sizeof(edsh), 1, ofp) != 1) + return(0); + + for (i = 0; i < vec_len(the_event_definitions); i++) { + this_event_definition = &the_event_definitions[i]; + /* Endian fixup */ + this_event_definition->event = ntohl(this_event_definition->event); + this_event_definition->event_format = + ntohl(this_event_definition->event_format); + this_event_definition->datum_format = + ntohl(this_event_definition->datum_format); + + if (fwrite(this_event_definition, sizeof(the_event_definitions[0]), + 1, ofp) != 1) + return(0); + } + return(1); +} + +/* + * ntohll + */ +u64 ntohll (u64 x) { + if (clib_arch_is_little_endian) + x = ((((x >> 0) & 0xff) << 56) + | (((x >> 8) & 0xff) << 48) + | (((x >> 16) & 0xff) << 40) + | (((x >> 24) & 0xff) << 32) + | (((x >> 32) & 0xff) << 24) + | (((x >> 40) & 0xff) << 16) + | (((x >> 48) & 0xff) << 8) + | (((x >> 56) & 0xff) << 0)); + + return x; +} + +/* + * write_events + */ +int write_events(FILE *ofp, u64 clock_ticks_per_second) +{ + cpel_section_header_t sh; + event_section_header_t eh; + u32 number_of_events; + int i; + event_entry_t e; + u64 net_timestamp; + evt_t *this_event; + u32 time0, time1; + + number_of_events = vec_len(the_events); + + sh.section_type = ntohl(CPEL_SECTION_EVENT); + sh.data_length = ntohl(number_of_events * sizeof(e) + + sizeof(event_section_header_t)); + + if (fwrite(&sh, sizeof(sh), 1, ofp) != 1) + return(0); + + memset(&eh, 0, sizeof(eh)); + strcpy(eh.string_table_name, "FileStrtab"); + eh.number_of_events = ntohl(number_of_events); + eh.clock_ticks_per_second = ntohl(clock_ticks_per_second); + + if (fwrite(&eh, sizeof(eh), 1, ofp) != 1) + return(0); + + for (i = 0; i < number_of_events; i++) { + this_event = &the_events[i]; + net_timestamp = ntohll(this_event->timestamp); + + time1 = net_timestamp>>32; + time0 = net_timestamp & 0xFFFFFFFF; + + e.time[0] = time0; + e.time[1] = time1; + e.track = ntohl(this_event->track_id); + e.event_code = ntohl(this_event->event_id); + e.event_datum = ntohl(this_event->datum); + + if (fwrite(&e, sizeof(e), 1, ofp) != 1) + return(0); + } + return(1); +} + +/* + * write_track_defs + */ +int write_track_defs(FILE *ofp) +{ + cpel_section_header_t sh; + track_definition_section_header_t tdsh; + track_definition_t record; + track_definition_t *this_track_definition = &record; + int i; + event_definition_section_header_t edsh; + + /* Next, the event definitions */ + sh.section_type = ntohl(CPEL_SECTION_TRACKDEF); + sh.data_length = ntohl(vec_len(the_tracks) + *sizeof(this_track_definition[0]) + + sizeof(track_definition_section_header_t)); + + if (fwrite(&sh, sizeof(sh), 1, ofp) != 1) + return(0); + + memset(&tdsh, 0, sizeof(tdsh)); + + strcpy(tdsh.string_table_name, "FileStrtab"); + tdsh.number_of_track_definitions = ntohl(vec_len(the_tracks)); + + if (fwrite(&tdsh, sizeof(edsh), 1, ofp) != 1) + return(0); + + for (i = 0; i < vec_len(the_tracks); i++) { + this_track_definition->track = ntohl(i); + this_track_definition->track_format = + ntohl(the_tracks[i].strtab_offset); + + if (fwrite(this_track_definition, sizeof(this_track_definition[0]), + 1, ofp) != 1) + return(0); + } + return(1); +} + +void cpel_util_init (void) +{ + u8 *eventstr; + + the_strtab_hash = hash_create_string (0, sizeof (uword)); + the_msg_event_hash = hash_create_string (0, sizeof (uword)); + the_track_hash = hash_create_string (0, sizeof (uword)); + the_pidtid_hash = hash_create_string (0, sizeof(uword)); + the_pid_to_name_hash = hash_create(0, sizeof(uword)); + + /* Must be first, or no supper... */ + find_or_add_strtab("FileStrtab"); + + /* Historical canned events, no longer used. */ + if (0) { + /* event 0 (not used) */ + eventstr = format(0, "PlaceholderNotUsed"); + vec_add1(eventstr, 0); + find_or_add_event(eventstr, "%s"); + vec_free(eventstr); + + /* event 1 (thread on CPU) */ + eventstr = format(0, "THREAD/THRUNNING"); + vec_add1(eventstr, 0); + find_or_add_event(eventstr, "%s"); + vec_free(eventstr); + + /* event 2 (thread ready) */ + eventstr = format(0, "THREAD/THREADY"); + vec_add1(eventstr, 0); + find_or_add_event(eventstr, "%s"); + vec_free(eventstr); + + /* event 3 (function enter) */ + eventstr = format(0, "FUNC/ENTER"); + vec_add1(eventstr, 0); + find_or_add_event(eventstr, "0x%x"); + vec_free(eventstr); + + /* event 4 (function enter) */ + eventstr = format(0, "FUNC/EXIT"); + vec_add1(eventstr, 0); + find_or_add_event(eventstr, "0x%x"); + vec_free(eventstr); + } +} + +/* + * alpha_compare_tracks + */ +static int alpha_compare_tracks(const void *a1, const void *a2) +{ + int i; + track_t *t1 = (track_t *)a1; + track_t *t2 = (track_t *)a2; + u8 *s1 = &the_strtab[t1->strtab_offset]; + u8 *s2 = &the_strtab[t2->strtab_offset]; + + for (i = 0; s1[i] && s2[i]; i++) { + if (s1[i] < s2[i]) + return(-1); + if (s1[i] > s2[i]) + return(1); + } + return(0); +} + +/* + * alpha_sort_tracks + * Alphabetically sort tracks, set up a mapping + * vector so we can quickly map the original track index to + * the new/improved/alpha-sorted index + */ +void alpha_sort_tracks(void) +{ + track_t *this_track; + int i; + + qsort(the_tracks, vec_len(the_tracks), sizeof(track_t), + alpha_compare_tracks); + + vec_validate(track_alpha_map, vec_len(the_tracks)); + _vec_len(track_alpha_map) = vec_len(the_tracks); + + for (i = 0; i < vec_len(the_tracks); i++) { + this_track = &the_tracks[i]; + track_alpha_map[this_track->original_index] = i; + } +} + +/* + * fixup_event_tracks + * Use the track alpha mapping to account for the alphabetic + * sort performed by the previous routine + */ +void fixup_event_tracks(void) +{ + int i; + u32 old_track; + + for (i = 0; i < vec_len(the_events); i++) { + old_track = the_events[i].track_id; + the_events[i].track_id = track_alpha_map[old_track]; + } +} + +/* Indispensable for debugging in gdb... */ + +u32 vl(void *x) +{ + return vec_len(x); +} diff --git a/src/tools/perftool/cpel_util.h b/src/tools/perftool/cpel_util.h new file mode 100644 index 00000000..b76f7a4b --- /dev/null +++ b/src/tools/perftool/cpel_util.h @@ -0,0 +1,68 @@ +/* + *------------------------------------------------------------------ + * Copyright (c) 2006-2016 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __cpel_util_h__ +#define __cpel_util_h__ + +/* + * Our idea of an event, as opposed to a CPEL event + */ +typedef struct evt_ { + u64 timestamp; + u32 track_id; + u32 event_id; + u32 datum; +} evt_t; + +evt_t *the_events; + +/* + * Track object, so we can sort the tracks alphabetically and + * fix the events later + */ +typedef struct track_ { + u32 original_index; + u32 strtab_offset; +} track_t; + +track_t *the_tracks; +u32 *track_alpha_map; + +event_definition_t *the_event_definitions; +i64 min_timestamp; + +/* Hash tables, used to find previous instances of the same items */ +uword *the_track_hash; +uword *the_msg_event_hash; +uword *the_strtab_hash; +uword *the_pidtid_hash; +uword *the_pid_to_name_hash; +u8 *the_strtab; + +u32 find_or_add_strtab(void *s_arg); +u32 find_or_add_track(void *s_arg); +u32 find_or_add_event(void *s_arg, char *datum_format); +int write_string_table(FILE *ofp); +int write_cpel_header(FILE *ofp, u32 nsections); +int write_event_defs(FILE *ofp); +u64 ntohll (u64 x); +int write_events(FILE *ofp, u64 clock_ticks_per_second); +int write_track_defs(FILE *ofp); +void cpel_util_init (void); +void alpha_sort_tracks(void); +void fixup_event_tracks(void); + +#endif /* __cpel_util_h__ */ diff --git a/src/tools/perftool/cpelatency.c b/src/tools/perftool/cpelatency.c new file mode 100644 index 00000000..7b87d606 --- /dev/null +++ b/src/tools/perftool/cpelatency.c @@ -0,0 +1,927 @@ +/* + *------------------------------------------------------------------ + * Copyright (c) 2006-2016 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "cpel.h" +#include + +char *time_format = "%.03d:%.02d:%.02d:%.03d:%.03d "; +static char version[] = "cpelatency 2.0"; + +#define USEC_PER_MS 1000LL +#define USEC_PER_SECOND (1000*USEC_PER_MS) +#define USEC_PER_MINUTE (60*USEC_PER_SECOND) +#define USEC_PER_HOUR (60*USEC_PER_MINUTE) + +uword *the_strtab_hash; /* (name, base-VA) hash of all string tables */ +uword *the_evtdef_hash; /* (event-id, event-definition) hash */ +uword *the_trackdef_hash; /* (track-id, track-definition) hash */ +uword *the_pidtid_hash; /* ("pid:xxx tid:yy", track-definition) hash */ + +f64 ticks_per_us; +u32 start_event_code = 2; /* default: XR thread ready event */ +u32 end_event_code = 1; /* default: XR thread running event */ +int exclude_kernel_from_summary_stats=1; +int summary_stats_only; +int scatterplot; +u8 *name_filter; +int have_trackdefs; + +typedef enum { + SORT_MAX_TIME=1, + SORT_MAX_OCCURRENCES, + SORT_NAME, +} sort_t; + +sort_t sort_type = SORT_MAX_TIME; + +int widest_name_format=5; +int widest_track_format=20; + +typedef struct bound_event_ { + u32 event_code; + u8 *event_str; + u8 *datum_str; + u32 is_strtab_ref; +} bound_event_t; + +bound_event_t *bound_events; + +typedef struct bound_track_ { + u32 track; + u8 *track_str; + u64 state_start_ticks; + u64 *ticks_in_state; /* vector of state occurrences */ + f64 mean_ticks_in_state; + f64 variance_ticks_in_state; + f64 total_ticks_in_state; +} bound_track_t; + +bound_track_t *bound_tracks; + +void fatal(char *s) +{ + fprintf(stderr, "%s", s); + exit(1); +} + +typedef enum { + PASS1=1, + PASS2=2, +} pass_t; + +typedef struct { + int (*pass1)(cpel_section_header_t *, int, FILE *); + int (*pass2)(cpel_section_header_t *, int, FILE *); +} section_processor_t; + +int bad_section(cpel_section_header_t *sh, int verbose, FILE *ofp) +{ + fprintf(ofp, "Bad (type 0) section, skipped...\n"); + return(0); +} + +int noop_pass(cpel_section_header_t *sh, int verbose, FILE *ofp) +{ + return(0); +} + +int strtab_pass1(cpel_section_header_t *sh, int verbose, FILE *ofp) +{ + uword *p; + u8 *strtab_data_area = (u8 *)(sh+1); + + /* Multiple string tables with the same name are Bad... */ + p = hash_get_mem(the_strtab_hash, strtab_data_area); + if (p) { + fprintf(ofp, "Duplicate string table name %s", strtab_data_area); + } + /* + * Looks funny, but we really do want key = first string in the + * table, value = address(first string in the table) + */ + hash_set_mem(the_strtab_hash, strtab_data_area, strtab_data_area); + if (verbose) { + fprintf(ofp, "String Table %s\n", strtab_data_area); + } + return(0); +} + +int evtdef_pass1(cpel_section_header_t *sh, int verbose, FILE *ofp) +{ + int i, nevents; + event_definition_section_header_t *edh; + event_definition_t *ep; + u8 *this_strtab; + u32 event_code; + uword *p; + bound_event_t *bp; + int thislen; + + edh = (event_definition_section_header_t *)(sh+1); + nevents = ntohl(edh->number_of_event_definitions); + + if (verbose) { + fprintf(ofp, "Event Definition Section: %d definitions\n", + nevents); + } + + p = hash_get_mem(the_strtab_hash, edh->string_table_name); + if (!p) { + fprintf(ofp, "Fatal: couldn't find string table\n"); + return(1); + } + this_strtab = (u8 *)p[0]; + + ep = (event_definition_t *)(edh+1); + + for (i = 0; i < nevents; i++) { + event_code = ntohl(ep->event); + p = hash_get(the_evtdef_hash, event_code); + if (p) { + fprintf(ofp, "Event %d redefined, retain first definition\n", + event_code); + continue; + } + vec_add2(bound_events, bp, 1); + bp->event_code = event_code; + bp->event_str = this_strtab + ntohl(ep->event_format); + bp->datum_str = this_strtab + ntohl(ep->datum_format); + bp->is_strtab_ref = 0; + /* Decide if the datum format is a %s format => strtab reference */ + { + int j; + int seen_percent=0; + + for (j = 0; j < strlen((char *) bp->datum_str); j++) { + if (bp->datum_str[j] == '%'){ + seen_percent=1; + continue; + } + if (seen_percent && bp->datum_str[j] == 's') { + bp->is_strtab_ref = 1; + } + } + } + + hash_set(the_evtdef_hash, event_code, bp - bound_events); + + thislen = strlen((char *) bp->event_str); + if (thislen > widest_name_format) + widest_name_format = thislen; + + ep++; + } + return (0); +} + +int trackdef_pass1(cpel_section_header_t *sh, int verbose, FILE *ofp) +{ + int i, nevents; + track_definition_section_header_t *tdh; + track_definition_t *tp; + u8 *this_strtab; + u32 track_code; + uword *p; + bound_track_t *btp; + int thislen; + u8 *pidstr; + u8 *pidtid_str; + u8 *cp; + int tid, pid; + + tdh = (track_definition_section_header_t *)(sh+1); + nevents = ntohl(tdh->number_of_track_definitions); + + if (verbose) { + fprintf(ofp, "Track Definition Section: %d definitions\n", + nevents); + } + + p = hash_get_mem(the_strtab_hash, tdh->string_table_name); + if (!p) { + fprintf(ofp, "Fatal: couldn't find string table\n"); + return(1); + } + this_strtab = (u8 *)p[0]; + + tp = (track_definition_t *)(tdh+1); + + for (i = 0; i < nevents; i++) { + track_code = ntohl(tp->track); + p = hash_get(the_trackdef_hash, track_code); + if (p) { + fprintf(stderr, "track %d redefined, retain first definition\n", + track_code); + continue; + } + vec_add2(bound_tracks, btp, 1); + btp->track = track_code; + btp->track_str = this_strtab + ntohl(tp->track_format); + hash_set(the_trackdef_hash, track_code, btp - bound_tracks); + + if (verbose) { + fprintf(stderr, "adding track '%s'\n", btp->track_str); + } + + thislen = strlen((char *) btp->track_str); + if (thislen > widest_track_format) + widest_track_format = thislen; + + /* convert track_str "eth_server t11(20498)" to "pid:20498 tid:11" */ + cp = btp->track_str; + while (*cp && *cp != '(') + cp++; + if (!*cp) { + fprintf(stderr, "error canonicalizing '%s'\n", btp->track_str); + goto out; + } + pidstr = cp+1; /* remember location of PID */ + + while (cp > btp->track_str && *cp != 't') + cp--; + + if (cp == btp->track_str) { + fprintf(stderr, "error canonicalizing '%s'\n", btp->track_str); + goto out; + } + tid = atol((char *)(cp+1)); + pid = atol((char *) pidstr); + pidtid_str = format(0, "pid:%d tid:%d", pid, tid); + vec_add1(pidtid_str, 0); + + /* + * Note: duplicates are possible due to thread create / + * thread destroy operations. + */ + p = hash_get_mem(the_pidtid_hash, pidtid_str); + if (p) { + vec_free(pidtid_str); + goto out; + } + hash_set_mem(the_pidtid_hash, pidtid_str, btp - bound_tracks); + + out: + tp++; + } + have_trackdefs = 1; + return (0); +} + +int unsupported_pass (cpel_section_header_t *sh, int verbose, FILE *ofp) +{ + if (verbose) { + fprintf(ofp, "Unsupported type %d section\n", + ntohl(sh->section_type)); + } + return(0); +} + +int event_pass2(cpel_section_header_t *sh, int verbose, FILE *ofp) +{ + event_section_header_t *eh; + int nevents; + int i; + uword *p; + event_entry_t *ep; + u64 now; + u32 time0, time1; + u32 track_code; + u8 *this_strtab; + u64 ticks_in_state; + bound_track_t *btp; + bound_track_t *state_track=0; + u8 *pidtid_str; + u8 *pidtid_dup; + u8 *ecp; + u32 event_code; + + eh = (event_section_header_t *)(sh+1); + nevents = ntohl(eh->number_of_events); + ticks_per_us = ((double)ntohl(eh->clock_ticks_per_second)) / 1e6; + + if (verbose) { + fprintf(ofp, "%.3f ticks_per_us\n", ticks_per_us); + } + + ep = (event_entry_t *)(eh+1); + + p = hash_get_mem(the_strtab_hash, eh->string_table_name); + if (!p) { + fprintf(ofp, "Fatal: couldn't find string table\n"); + return(1); + } + this_strtab = (u8 *)p[0]; + + /* + * Some logger implementation that doesn't produce + * trackdef sections, synthesize the bound_tracks vector + */ + if (!have_trackdefs) { + for (i = 0; i < nevents; i++) { + track_code = ntohl(ep->track); + pidtid_dup = format(0, "%d", track_code); + vec_add1(pidtid_dup, 0); + p = hash_get_mem(the_pidtid_hash, pidtid_dup); + if (!p) { + vec_add2(bound_tracks, btp, 1); + btp->track = track_code; + btp->track_str = pidtid_dup; + hash_set(the_trackdef_hash, track_code, btp - bound_tracks); + hash_set_mem(the_pidtid_hash, pidtid_dup, btp - bound_tracks); + } else { + vec_free(pidtid_dup); + } + ep++; + } + } + + ep = (event_entry_t *)(eh+1); + + for (i = 0; i < nevents; i++) { + time0 = ntohl (ep->time[0]); + time1 = ntohl (ep->time[1]); + + now = (((u64) time0)<<32) | time1; + + event_code = ntohl(ep->event_code); + + /* Find the corresponding track via the pidtid hash table */ + if (event_code == start_event_code || event_code == end_event_code) { + if (have_trackdefs) { + pidtid_str = this_strtab + ntohl(ep->event_datum); + pidtid_dup = format(0, (char *) pidtid_str); + vec_add1(pidtid_dup, 0); + ecp = &pidtid_dup[vec_len(pidtid_dup)-1]; + while (*--ecp == ' ') + *ecp = 0; + } else { + pidtid_dup = format(0, "%d", ntohl(ep->track)); + vec_add1(pidtid_dup, 0); + } + + p = hash_get_mem(the_pidtid_hash, pidtid_dup); + if (!p) { + fprintf(stderr, "warning: couldn't find '%s'\n", + pidtid_dup); + vec_free(pidtid_dup); + ep++; + continue; + } + state_track = &bound_tracks[p[0]]; + } + /* Found the start-event code ? */ + if (event_code == start_event_code) { + state_track->state_start_ticks = now; + } else if (event_code == end_event_code) { + /* + * Add a ticks-in-state record, unless + * e.g. the log started with the exit event + */ + if (state_track->state_start_ticks) { + ticks_in_state = now - state_track->state_start_ticks; + vec_add1(state_track->ticks_in_state, ticks_in_state); + state_track->state_start_ticks = 0; + } + /* Otherwise, nothing */ + } + ep++; + } + return(0); +} + +/* + * Note: If necessary, add passes / columns to this table to + * handle section order dependencies. + */ + +section_processor_t processors[CPEL_NUM_SECTION_TYPES+1] = +{ + {bad_section, noop_pass}, /* type 0 -- f**ked */ + {strtab_pass1, noop_pass}, /* type 1 -- STRTAB */ + {unsupported_pass, noop_pass}, /* type 2 -- SYMTAB */ + {evtdef_pass1, noop_pass}, /* type 3 -- EVTDEF */ + {trackdef_pass1, noop_pass}, /* type 4 -- TRACKDEF */ + {noop_pass, event_pass2}, /* type 5 -- EVENTS */ +}; + + +int process_section(cpel_section_header_t *sh, int verbose, FILE *ofp, + pass_t pass) +{ + u32 type; + type = ntohl(sh->section_type); + int rv; + int (*fp)(cpel_section_header_t *, int, FILE *); + + if (type > CPEL_NUM_SECTION_TYPES) { + fprintf(stderr, "Unknown section type %d\n", type); + return(1); + } + switch(pass) { + case PASS1: + fp = processors[type].pass1; + break; + + case PASS2: + fp = processors[type].pass2; + break; + + default: + fprintf(stderr, "Unknown pass %d\n", pass); + return(1); + } + + rv = (*fp)(sh, verbose, ofp); + + return(rv); +} + +int cpel_dump_file_header(cpel_file_header_t *fh, int verbose, FILE *ofp) +{ + time_t file_time; + + if (verbose) { + fprintf(ofp, "CPEL file: %s-endian, version %d\n", + ((fh->endian_version & CPEL_FILE_LITTLE_ENDIAN) ? + "little" : "big"), + fh->endian_version & CPEL_FILE_VERSION_MASK); + + file_time = ntohl(fh->file_date); + + fprintf(ofp, "File created %s", ctime(&file_time)); + fprintf(ofp, "File has %d sections\n", + ntohs(fh->nsections)); + } + + return(0); +} + + +int cpel_dump(u8 *cpel, int verbose, FILE *ofp) +{ + cpel_file_header_t *fh; + cpel_section_header_t *sh; + u16 nsections; + u32 section_size; + int i; + + /* First, the file header */ + fh = (cpel_file_header_t *)cpel; + if (fh->endian_version != CPEL_FILE_VERSION) { + if (fh->endian_version & CPEL_FILE_LITTLE_ENDIAN) { + fprintf(stderr, "Little endian data format not supported\n"); + return(1); + } + fprintf(stderr, "Unsupported file version 0x%x\n", + fh->endian_version); + return(1); + } + cpel_dump_file_header(fh, verbose, ofp); + nsections = ntohs(fh->nsections); + + /* + * Take two passes through the file. PASS1 builds + * data structures, PASS2 actually dumps the file. + * Just in case the sections are in an unobvious order. + */ + sh = (cpel_section_header_t *)(fh+1); + for (i = 0; i < nsections; i++) { + section_size = ntohl(sh->data_length); + + if(verbose) { + fprintf(ofp, "Section type %d, size %d\n", ntohl(sh->section_type), + section_size); + } + + if(process_section(sh, verbose, ofp, PASS1)) + return(1); + + sh++; + sh = (cpel_section_header_t *)(((u8 *)sh)+section_size); + } + + sh = (cpel_section_header_t *)(fh+1); + for (i = 0; i < nsections; i++) { + if(process_section(sh, verbose, ofp, PASS2)) + return(1); + section_size = ntohl(sh->data_length); + sh++; + sh = (cpel_section_header_t *)(((u8 *)sh)+section_size); + } + return(0); +} + +void compute_state_statistics(int verbose, FILE *ofp) +{ + int i, j; + bound_track_t *bp; + f64 fticks; + + /* Across the bound tracks */ + for (i = 0; i < vec_len(bound_tracks); i++) { + bp = &bound_tracks[i]; + bp->mean_ticks_in_state = 0.0; + bp->variance_ticks_in_state = 0.0; + bp->total_ticks_in_state = 0.0; + for (j = 0; j < vec_len(bp->ticks_in_state); j++) { + bp->total_ticks_in_state += (f64) bp->ticks_in_state[j]; + } + /* Compute mean */ + if (vec_len(bp->ticks_in_state)) { + bp->mean_ticks_in_state = bp->total_ticks_in_state / + ((f64) vec_len(bp->ticks_in_state)); + } + /* Accumulate sum: (Xi-Xbar)**2 */ + for (j = 0; j < vec_len(bp->ticks_in_state); j++) { + fticks = bp->ticks_in_state[j]; + bp->variance_ticks_in_state += + (fticks - bp->mean_ticks_in_state)* + (fticks - bp->mean_ticks_in_state); + } + /* Compute s**2, the unbiased estimator of sigma**2 */ + if (vec_len(bp->ticks_in_state) > 1) { + bp->variance_ticks_in_state /= (f64) + (vec_len(bp->ticks_in_state)-1); + } + } +} + +int track_compare_max (const void *arg1, const void *arg2) +{ + bound_track_t *a1 = (bound_track_t *)arg1; + bound_track_t *a2 = (bound_track_t *)arg2; + f64 v1, v2; + + v1 = a1->total_ticks_in_state; + v2 = a2->total_ticks_in_state; + + if (v1 < v2) + return (1); + else if (v1 == v2) + return (0); + else return (-1); +} + +int track_compare_occurrences (const void *arg1, const void *arg2) +{ + bound_track_t *a1 = (bound_track_t *)arg1; + bound_track_t *a2 = (bound_track_t *)arg2; + f64 v1, v2; + + v1 = (f64) vec_len(a1->ticks_in_state); + v2 = (f64) vec_len(a2->ticks_in_state); + + if (v1 < v2) + return (1); + else if (v1 == v2) + return (0); + else return (-1); +} + +int track_compare_name (const void *arg1, const void *arg2) +{ + bound_track_t *a1 = (bound_track_t *)arg1; + bound_track_t *a2 = (bound_track_t *)arg2; + + return (strcmp((char *)(a1->track_str), (char *)(a2->track_str))); +} + +void sort_state_statistics(sort_t type, FILE *ofp) +{ + int (*compare)(const void *, const void *) = 0; + + if (summary_stats_only) + return; + + switch(type) { + case SORT_MAX_TIME: + fprintf(ofp, "Results sorted by max time in state.\n\n"); + compare = track_compare_max; + break; + + case SORT_MAX_OCCURRENCES: + fprintf(ofp, "Results sorted by max occurrences of state.\n\n"); + compare = track_compare_occurrences; + break; + + case SORT_NAME: + compare = track_compare_name; + fprintf(ofp, "Results sorted by process name, thread ID, PID\n\n"); + break; + + default: + fatal("sort type not set?"); + } + + qsort (bound_tracks, vec_len(bound_tracks), + sizeof (bound_track_t), compare); +} + +void print_state_statistics(int verbose, FILE *ofp) +{ + int i,j; + u8 *trackpad; + bound_track_t *bp; + f64 total_time = 0.0; + f64 total_switches = 0.0; + + trackpad = format(0, "%%-%ds ", widest_track_format); + vec_add1(trackpad, 0); + + if (!summary_stats_only) { + fprintf(ofp, (char *)trackpad, "ProcName Thread(PID)"); + fprintf(ofp, " Mean(us) Stdev(us) Total(us) N\n"); + } + + for (i = 0; i < vec_len(bound_tracks); i++) { + bp = &bound_tracks[i]; + if (bp->mean_ticks_in_state == 0.0) + continue; + + if (name_filter && + strncmp((char *)bp->track_str, (char *)name_filter, + strlen((char *)name_filter))) + continue; + + /* + * Exclude kernel threads (e.g. idle thread) from + * state statistics + */ + if (exclude_kernel_from_summary_stats && + !strncmp((char *) bp->track_str, "kernel ", 7)) + continue; + + total_switches += (f64) vec_len(bp->ticks_in_state); + + if (!summary_stats_only) { + fprintf(ofp, (char *) trackpad, bp->track_str); + fprintf(ofp, "%10.3f +- %10.3f", + bp->mean_ticks_in_state / ticks_per_us, + sqrt(bp->variance_ticks_in_state) + / ticks_per_us); + fprintf(ofp, "%12.3f", + bp->total_ticks_in_state / ticks_per_us); + fprintf(ofp, "%8d\n", vec_len(bp->ticks_in_state)); + } + + if (scatterplot) { + for (j = 0; j < vec_len(bp->ticks_in_state); j++) { + fprintf(ofp, "%.3f\n", + (f64)bp->ticks_in_state[j] / ticks_per_us); + } + } + + total_time += bp->total_ticks_in_state; + } + + if (!summary_stats_only) + fprintf(ofp, "\n"); + fprintf(ofp, "Note: the following statistics %s kernel-thread activity.\n", + exclude_kernel_from_summary_stats ? "exclude" : "include"); + if (name_filter) + fprintf(ofp, + "Note: only pid/proc/threads matching '%s' are included.\n", + name_filter); + + fprintf(ofp, + "Total time in state: %10.3f (us), Total state occurrences: %.0f\n", + total_time / ticks_per_us, total_switches); + fprintf(ofp, "Average time in state: %10.3f (us)\n", + (total_time / total_switches) / ticks_per_us); + fprintf(ofp, "State start event: %d, state end event: %d\n", + start_event_code, end_event_code); +} + +char *mapfile (char *file) +{ + struct stat statb; + char *rv; + int maphfile; + size_t mapfsize; + + maphfile = open (file, O_RDONLY); + + if (maphfile < 0) + { + fprintf (stderr, "Couldn't read %s, skipping it...\n", file); + return (NULL); + } + + if (fstat (maphfile, &statb) < 0) + { + fprintf (stderr, "Couldn't get size of %s, skipping it...\n", file); + return (NULL); + } + + /* Don't try to mmap directories, FIFOs, semaphores, etc. */ + if (! (statb.st_mode & S_IFREG)) { + fprintf (stderr, "%s is not a regular file, skipping it...\n", file); + return (NULL); + } + + mapfsize = statb.st_size; + + if (mapfsize < 3) + { + fprintf (stderr, "%s zero-length, skipping it...\n", file); + close (maphfile); + return (NULL); + } + + rv = mmap (0, mapfsize, PROT_READ, MAP_SHARED, maphfile, 0); + + if (rv == 0) + { + fprintf (stderr, "%s problem mapping, I quit...\n", file); + exit (-1); + } + close (maphfile); + return (rv); +} + +/* + * main + */ +int main (int argc, char **argv) +{ + char *cpel_file = 0; + char *outputfile = 0; + FILE *ofp; + char *cpel; + int verbose=0; + int curarg=1; + + while (curarg < argc) { + if (!strncmp(argv[curarg], "--input-file", 3)) { + curarg++; + if (curarg < argc) { + cpel_file = argv[curarg]; + curarg++; + continue; + } + fatal("Missing filename after --input-file\n"); + } + if (!strncmp(argv[curarg], "--output-file", 3)) { + curarg ++; + if (curarg < argc) { + outputfile = argv[curarg]; + curarg ++; + continue; + } + fatal("Missing filename after --output-file\n"); + } + if (!strncmp(argv[curarg], "--verbose", 3)) { + curarg++; + verbose++; + continue; + } + if (!strncmp(argv[curarg], "--scatterplot", 4)) { + curarg++; + scatterplot=1; + continue; + } + + if (!strncmp(argv[curarg], "--start-event", 4)) { + curarg++; + if (curarg < argc) { + start_event_code = atol(argv[curarg]); + curarg ++; + continue; + } + fatal("Missing integer after --start-event\n"); + } + if (!strncmp(argv[curarg], "--end-event", 4)) { + curarg++; + if (curarg < argc) { + end_event_code = atol(argv[curarg]); + curarg ++; + continue; + } + fatal("Missing integer after --end-event\n"); + } + if (!strncmp(argv[curarg], "--max-time-sort", 7)) { + sort_type = SORT_MAX_TIME; + curarg++; + continue; + } + if (!strncmp(argv[curarg], "--max-occurrence-sort", 7)) { + sort_type = SORT_MAX_OCCURRENCES; + curarg++; + continue; + } + if (!strncmp(argv[curarg], "--name-sort", 3)) { + sort_type = SORT_NAME; + curarg++; + continue; + } + if (!strncmp(argv[curarg], "--kernel-included", 3)) { + exclude_kernel_from_summary_stats = 0; + curarg++; + continue; + } + if (!strncmp(argv[curarg], "--summary", 3)) { + summary_stats_only=1; + curarg++; + continue; + } + if (!strncmp(argv[curarg], "--filter", 3)) { + curarg ++; + if (curarg < argc) { + name_filter = (u8 *) argv[curarg]; + curarg ++; + continue; + } + fatal("Missing filter string after --filter\n"); + } + + + usage: + fprintf(stderr, + "cpelatency --input-file [--output-file ]\n"); + fprintf(stderr, + " [--start-event ] [--verbose]\n"); + fprintf(stderr, + " [--end-event ]\n"); + fprintf(stderr, + " [--max-time-sort(default) | --max-occurrence-sort |\n"); + + fprintf(stderr, + " --name-sort-sort] [--kernel-included]\n"); + + fprintf(stderr, + " [--summary-stats-only] [--scatterplot]\n"); + + fprintf(stderr, "%s\n", version); + exit(1); + } + + if (cpel_file == 0) + goto usage; + + cpel = mapfile(cpel_file); + if (cpel == 0) { + fprintf(stderr, "Couldn't map %s...\n", cpel_file); + exit(1); + } + + if (!outputfile) { + ofp = fdopen(1, "w"); + if (ofp == NULL) { + fprintf(stderr, "Couldn't fdopen(1)?\n"); + exit(1); + } + } else { + ofp = fopen(outputfile, "w"); + if (ofp == NULL) { + fprintf(stderr, "Couldn't create %s...\n", outputfile); + exit(1); + } + } + + the_strtab_hash = hash_create_string (0, sizeof (uword)); + the_evtdef_hash = hash_create (0, sizeof (uword)); + the_trackdef_hash = hash_create (0, sizeof (uword)); + the_pidtid_hash = hash_create_string (0, sizeof(uword)); + + if (cpel_dump((u8 *)cpel, verbose, ofp)) { + if (outputfile) + unlink(outputfile); + } + + compute_state_statistics(verbose, ofp); + sort_state_statistics(sort_type, ofp); + print_state_statistics(verbose, ofp); + + fclose(ofp); + return(0); +} diff --git a/src/tools/perftool/cpeldump.c b/src/tools/perftool/cpeldump.c new file mode 100644 index 00000000..9011bd03 --- /dev/null +++ b/src/tools/perftool/cpeldump.c @@ -0,0 +1,638 @@ +/* + *------------------------------------------------------------------ + * Copyright (c) 2006-2016 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "cpel.h" + +char *time_format = "%.03d:%.02d:%.02d:%.03d:%.03d "; +static char version[] = "cpeldump 2.0"; + +#define USEC_PER_MS 1000LL +#define USEC_PER_SECOND (1000*USEC_PER_MS) +#define USEC_PER_MINUTE (60*USEC_PER_SECOND) +#define USEC_PER_HOUR (60*USEC_PER_MINUTE) + +uword *the_strtab_hash; /* (name, base-VA) hash of all string tables */ +uword *the_evtdef_hash; /* (event-id, event-definition) hash */ +uword *the_trackdef_hash; /* (track-id, track-definition) hash */ + +int widest_name_format=5; +int widest_track_format=5; + +typedef struct bound_event_ { + u32 event_code; + u8 *event_str; + u8 *datum_str; + u32 is_strtab_ref; +} bound_event_t; + +bound_event_t *bound_events; + +typedef struct bound_track_ { + u32 track; + u8 *track_str; +} bound_track_t; + +bound_track_t *bound_tracks; + +void fatal(char *s) +{ + fprintf(stderr, "%s", s); + exit(1); +} + +typedef enum { + PASS1=1, + PASS2=2, +} pass_t; + +typedef struct { + int (*pass1)(cpel_section_header_t *, int, FILE *); + int (*pass2)(cpel_section_header_t *, int, FILE *); +} section_processor_t; + +int bad_section(cpel_section_header_t *sh, int verbose, FILE *ofp) +{ + fprintf(ofp, "Bad (type 0) section, skipped...\n"); + return(0); +} + +int noop_pass(cpel_section_header_t *sh, int verbose, FILE *ofp) +{ + return(0); +} + +int strtab_pass1(cpel_section_header_t *sh, int verbose, FILE *ofp) +{ + uword *p; + u8 *strtab_data_area = (u8 *)(sh+1); + + /* Multiple string tables with the same name are Bad... */ + p = hash_get_mem(the_strtab_hash, strtab_data_area); + if (p) { + fprintf(ofp, "Duplicate string table name %s", strtab_data_area); + } + /* + * Looks funny, but we really do want key = first string in the + * table, value = address(first string in the table) + */ + hash_set_mem(the_strtab_hash, strtab_data_area, strtab_data_area); + if (verbose) { + fprintf(stderr, "String Table %s\n", strtab_data_area); + } + return(0); +} + +int evtdef_pass1(cpel_section_header_t *sh, int verbose, FILE *ofp) +{ + int i, nevents; + event_definition_section_header_t *edh; + event_definition_t *ep; + u8 *this_strtab; + u32 event_code; + uword *p; + bound_event_t *bp; + int thislen; + + edh = (event_definition_section_header_t *)(sh+1); + nevents = ntohl(edh->number_of_event_definitions); + + if (verbose) { + fprintf(stderr, "Event Definition Section: %d definitions\n", + nevents); + } + + p = hash_get_mem(the_strtab_hash, edh->string_table_name); + if (!p) { + fprintf(ofp, "Fatal: couldn't find string table\n"); + return(1); + } + this_strtab = (u8 *)p[0]; + + ep = (event_definition_t *)(edh+1); + + for (i = 0; i < nevents; i++) { + event_code = ntohl(ep->event); + p = hash_get(the_evtdef_hash, event_code); + if (p) { + fprintf(ofp, "Event %d redefined, retain first definition\n", + event_code); + continue; + } + vec_add2(bound_events, bp, 1); + bp->event_code = event_code; + bp->event_str = this_strtab + ntohl(ep->event_format); + bp->datum_str = this_strtab + ntohl(ep->datum_format); + bp->is_strtab_ref = 0; + /* Decide if the datum format is a %s format => strtab reference */ + { + int j; + int seen_percent=0; + + for (j = 0; j < strlen((char *)bp->datum_str); j++) { + if (bp->datum_str[j] == '%'){ + seen_percent=1; + continue; + } + if (seen_percent && bp->datum_str[j] == 's') { + bp->is_strtab_ref = 1; + } + } + } + + hash_set(the_evtdef_hash, event_code, bp - bound_events); + + thislen = strlen((char *)bp->event_str); + if (thislen > widest_name_format) + widest_name_format = thislen; + + ep++; + } + return (0); +} + +int trackdef_pass1(cpel_section_header_t *sh, int verbose, FILE *ofp) +{ + int i, nevents; + track_definition_section_header_t *tdh; + track_definition_t *tp; + u8 *this_strtab; + u32 track_code; + uword *p; + bound_track_t *btp; + int thislen; + + tdh = (track_definition_section_header_t *)(sh+1); + nevents = ntohl(tdh->number_of_track_definitions); + + if (verbose) { + fprintf(stderr, "Track Definition Section: %d definitions\n", + nevents); + } + + p = hash_get_mem(the_strtab_hash, tdh->string_table_name); + if (!p) { + fprintf(ofp, "Fatal: couldn't find string table\n"); + return(1); + } + this_strtab = (u8 *)p[0]; + + tp = (track_definition_t *)(tdh+1); + + for (i = 0; i < nevents; i++) { + track_code = ntohl(tp->track); + p = hash_get(the_trackdef_hash, track_code); + if (p) { + fprintf(ofp, "track %d redefined, retain first definition\n", + track_code); + continue; + } + vec_add2(bound_tracks, btp, 1); + btp->track = track_code; + btp->track_str = this_strtab + ntohl(tp->track_format); + hash_set(the_trackdef_hash, track_code, btp - bound_tracks); + + thislen = strlen((char *)btp->track_str); + if (thislen > widest_track_format) + widest_track_format = thislen; + tp++; + } + return (0); +} + +int unsupported_pass (cpel_section_header_t *sh, int verbose, FILE *ofp) +{ + if (verbose) { + fprintf(stderr, "Unsupported type %d section\n", + ntohl(sh->section_type)); + } + return(0); +} + +int event_pass2(cpel_section_header_t *sh, int verbose, FILE *ofp) +{ + event_section_header_t *eh; + f64 ticks_per_us; + u32 event_code, track_code; + u64 starttime = 0xFFFFFFFFFFFFFFFFULL; + int nevents; + int i; + uword *p; + event_entry_t *ep; + u64 now; + u64 delta; + u32 hours, minutes, seconds, msec, usec; + u32 time0, time1; + double d; + bound_event_t *bp; + bound_event_t generic_event; + bound_track_t *tp=0; + bound_track_t generic_track; + u32 last_track_code; + u8 *s, *evtpad, *trackpad; + u8 *this_strtab; + + generic_event.event_str = (u8 *)"%d"; + generic_event.datum_str = (u8 *)"0x%08x"; + generic_event.is_strtab_ref = 0; + + generic_track.track_str = (u8 *)"%d"; + last_track_code = 0xdeadbeef; + + eh = (event_section_header_t *)(sh+1); + nevents = ntohl(eh->number_of_events); + ticks_per_us = ((double)ntohl(eh->clock_ticks_per_second)) / 1e6; + + if (verbose) { + fprintf(stderr, "Event section: %d events, %.3f ticks_per_us\n", + nevents, ticks_per_us); + } + + ep = (event_entry_t *)(eh+1); + + p = hash_get_mem(the_strtab_hash, eh->string_table_name); + if (!p) { + fprintf(ofp, "Fatal: couldn't find string table\n"); + return(1); + } + this_strtab = (u8 *)p[0]; + + evtpad = format(0, "%%-%ds ", widest_name_format); + vec_add1(evtpad, 0); + trackpad = format(0, "%%-%ds ", widest_track_format); + vec_add1(trackpad, 0); + + for (i = 0; i < nevents; i++) { + time0 = ntohl (ep->time[0]); + time1 = ntohl (ep->time[1]); + + now = (((u64) time0)<<32) | time1; + + /* Convert from bus ticks to usec */ + d = now; + d /= ticks_per_us; + + now = d; + + if (starttime == 0xFFFFFFFFFFFFFFFFULL) + starttime = now; + + delta = now - starttime; + + /* Delta = time since first event, in usec */ + + hours = delta / USEC_PER_HOUR; + if (hours) + delta -= ((u64) hours * USEC_PER_HOUR); + minutes = delta / USEC_PER_MINUTE; + if (minutes) + delta -= ((u64) minutes * USEC_PER_MINUTE); + seconds = delta / USEC_PER_SECOND; + if (seconds) + delta -= ((u64) seconds * USEC_PER_SECOND); + msec = delta / USEC_PER_MS; + if (msec) + delta -= ((u64) msec * USEC_PER_MS); + + usec = delta; + + /* Output the timestamp */ + fprintf(ofp, time_format, hours, minutes, seconds, msec, usec); + + /* output the track */ + track_code = ntohl(ep->track); + + if (track_code != last_track_code) { + p = hash_get(the_trackdef_hash, track_code); + if (p) { + tp = &bound_tracks[p[0]]; + } else { + tp = &generic_track; + } + } + s = format(0, (char *)tp->track_str, track_code); + vec_add1(s, 0); + fprintf(ofp, (char *)trackpad, s); + vec_free(s); + + /* output the event and datum */ + if (0 && verbose) { + fprintf(stderr, "raw event code %d, raw event datum 0x%x\n", + ntohl(ep->event_code), ntohl(ep->event_datum)); + } + + event_code = ntohl(ep->event_code); + p = hash_get(the_evtdef_hash, event_code); + if (p) { + bp = &bound_events[p[0]]; + } else { + bp = &generic_event; + } + s = format(0, (char *)bp->event_str, ntohl(ep->event_code)); + vec_add1(s, 0); + fprintf(ofp, (char *)evtpad, s); + vec_free(s); + if (bp->is_strtab_ref) { + fprintf(ofp, (char *) bp->datum_str, + &this_strtab[ntohl(ep->event_datum)]); + } else { + fprintf(ofp, (char *) bp->datum_str, ntohl(ep->event_datum)); + } + fputs("\n", ofp); + ep++; + } + vec_free(evtpad); + vec_free(trackpad); + return(0); +} + +/* + * Note: If necessary, add passes / columns to this table to + * handle section order dependencies. + */ + +section_processor_t processors[CPEL_NUM_SECTION_TYPES+1] = +{ + {bad_section, noop_pass}, /* type 0 -- f**ked */ + {strtab_pass1, noop_pass}, /* type 1 -- STRTAB */ + {unsupported_pass, noop_pass}, /* type 2 -- SYMTAB */ + {evtdef_pass1, noop_pass}, /* type 3 -- EVTDEF */ + {trackdef_pass1, noop_pass}, /* type 4 -- TRACKDEF */ + {noop_pass, event_pass2}, /* type 5 -- EVENTS */ +}; + + +int process_section(cpel_section_header_t *sh, int verbose, FILE *ofp, + pass_t pass) +{ + u32 type; + type = ntohl(sh->section_type); + int rv; + int (*fp)(cpel_section_header_t *, int, FILE *); + + if (type > CPEL_NUM_SECTION_TYPES) { + fprintf(stderr, "Unknown section type %d\n", type); + return(1); + } + switch(pass) { + case PASS1: + fp = processors[type].pass1; + break; + + case PASS2: + fp = processors[type].pass2; + break; + + default: + fprintf(stderr, "Unknown pass %d\n", pass); + return(1); + } + + rv = (*fp)(sh, verbose, ofp); + + return(rv); +} + +int cpel_dump_file_header(cpel_file_header_t *fh, int verbose, FILE *ofp) +{ + time_t file_time; + + if (verbose) { + fprintf(stderr, "CPEL file: %s-endian, version %d\n", + ((fh->endian_version & CPEL_FILE_LITTLE_ENDIAN) ? + "little" : "big"), + fh->endian_version & CPEL_FILE_VERSION_MASK); + + file_time = ntohl(fh->file_date); + + fprintf(stderr, "File created %s", ctime(&file_time)); + fprintf(stderr, "File has %d sections\n", + ntohs(fh->nsections)); + } + + return(0); +} + + +int cpel_dump(u8 *cpel, int verbose, FILE *ofp) +{ + cpel_file_header_t *fh; + cpel_section_header_t *sh; + u16 nsections; + u32 section_size; + int i; + + /* First, the file header */ + fh = (cpel_file_header_t *)cpel; + if (fh->endian_version != CPEL_FILE_VERSION) { + if (fh->endian_version & CPEL_FILE_LITTLE_ENDIAN) { + fprintf(stderr, "Little endian data format not supported\n"); + return(1); + } + fprintf(stderr, "Unsupported file version 0x%x\n", + fh->endian_version); + return(1); + } + cpel_dump_file_header(fh, verbose, ofp); + nsections = ntohs(fh->nsections); + + /* + * Take two passes through the file. PASS1 builds + * data structures, PASS2 actually dumps the file. + * Just in case the sections are in an unobvious order. + */ + sh = (cpel_section_header_t *)(fh+1); + for (i = 0; i < nsections; i++) { + section_size = ntohl(sh->data_length); + + if(verbose) { + fprintf(stderr, + "Section type %d, size %d\n", ntohl(sh->section_type), + section_size); + } + + if(process_section(sh, verbose, ofp, PASS1)) + return(1); + + sh++; + sh = (cpel_section_header_t *)(((u8 *)sh)+section_size); + } + + sh = (cpel_section_header_t *)(fh+1); + for (i = 0; i < nsections; i++) { + if(process_section(sh, verbose, ofp, PASS2)) + return(1); + section_size = ntohl(sh->data_length); + sh++; + sh = (cpel_section_header_t *)(((u8 *)sh)+section_size); + } + return(0); +} + + +char *mapfile (char *file) +{ + struct stat statb; + char *rv; + int maphfile; + size_t mapfsize; + + maphfile = open (file, O_RDONLY); + + if (maphfile < 0) + { + fprintf (stderr, "Couldn't read %s, skipping it...\n", file); + return (NULL); + } + + if (fstat (maphfile, &statb) < 0) + { + fprintf (stderr, "Couldn't get size of %s, skipping it...\n", file); + return (NULL); + } + + /* Don't try to mmap directories, FIFOs, semaphores, etc. */ + if (! (statb.st_mode & S_IFREG)) { + fprintf (stderr, "%s is not a regular file, skipping it...\n", file); + return (NULL); + } + + mapfsize = statb.st_size; + + if (mapfsize < 3) + { + fprintf (stderr, "%s zero-length, skipping it...\n", file); + close (maphfile); + return (NULL); + } + + rv = mmap (0, mapfsize, PROT_READ, MAP_SHARED, maphfile, 0); + + if (rv == 0) + { + fprintf (stderr, "%s problem mapping, I quit...\n", file); + exit (-1); + } + close (maphfile); + return (rv); +} + +/* + * main + */ +int main (int argc, char **argv) +{ + char *cpel_file = 0; + char *outputfile = 0; + FILE *ofp; + char *cpel; + int verbose=0; + int curarg=1; + + while (curarg < argc) { + if (!strncmp(argv[curarg], "--input-file", 3)) { + curarg++; + if (curarg < argc) { + cpel_file = argv[curarg]; + curarg++; + continue; + } + fatal("Missing filename after --input-file\n"); + } + if (!strncmp(argv[curarg], "--output-file", 3)) { + curarg ++; + if (curarg < argc) { + outputfile = argv[curarg]; + curarg ++; + continue; + } + fatal("Missing filename after --output-file\n"); + } + if (!strncmp(argv[curarg], "--verbose", 3)) { + curarg++; + verbose = 1; + continue; + } + + usage: + fprintf(stderr, + "cpeldump --input-file [--output-file ]\n"); + fprintf(stderr, "%s\n", version); + exit(1); + } + + if (cpel_file == 0) + goto usage; + + cpel = mapfile(cpel_file); + if (cpel == 0) { + fprintf(stderr, "Couldn't map %s...\n", cpel_file); + exit(1); + } + + if (!outputfile) { + ofp = fdopen(1, "w"); + if (ofp == NULL) { + fprintf(stderr, "Couldn't fdopen(1)?\n"); + exit(1); + } + } else { + ofp = fopen(outputfile, "w"); + if (ofp == NULL) { + fprintf(stderr, "Couldn't create %s...\n", outputfile); + exit(1); + } + } + + the_strtab_hash = hash_create_string (0, sizeof (uword)); + the_evtdef_hash = hash_create (0, sizeof (uword)); + the_trackdef_hash = hash_create (0, sizeof (uword)); + +#ifdef TEST_TRACK_INFO + { + bound_track_t *btp; + vec_add2(bound_tracks, btp, 1); + btp->track = 0; + btp->track_str = "cpu %d"; + hash_set(the_trackdef_hash, 0, btp - bound_tracks); + hash_set(the_trackdef_hash, 1, btp - bound_tracks); + } +#endif + + if (cpel_dump((u8 *)cpel, verbose, ofp)) { + if (outputfile) + unlink(outputfile); + } + + fclose(ofp); + return(0); +} diff --git a/src/tools/perftool/cpelinreg.c b/src/tools/perftool/cpelinreg.c new file mode 100644 index 00000000..115afad7 --- /dev/null +++ b/src/tools/perftool/cpelinreg.c @@ -0,0 +1,892 @@ +/* + *------------------------------------------------------------------ + * Copyright (c) 2008-2016 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Search for O(N**2) functions bracketed by before/after + * events. The "before" event's datum is used as a tag, e.g. which function + * did we call that's strongly O(N). + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "cpel.h" + +FILE *g_ifp; +char *g_ifile; + +typedef unsigned long long ulonglong; + +void process_traces (void); +void record_instance (ulong tag, ulonglong time); +void report_actors (void); +void scatterplot_data(void); +int entry_event, exit_event; +int nokey; +char *version = "cpelinreg 2.0"; +int model_these[10]; +int model_index; +int summary_stats; +ulonglong first_start_time; +ulonglong last_end_time; +ulonglong total_time; +ulong scatterkey; +int inline_mokus; + +typedef struct bound_track_ { + u32 track_code; + u32 *start_datum; + u8 *dup_event; + int state; + u64 *start_time; + u64 thread_timestamp; + u64 time_thread_on_cpu; +} bound_track_t; + +bound_track_t *bound_tracks; +uword *the_trackdef_hash; + + +#define MAXSTACK 128 + +typedef struct instance_ { + struct instance_ *next; + ulonglong time; +}instance_t; + +typedef struct actor_ { + struct actor_ *next; + ulong key; + struct instance_ *first; + struct instance_ *last; + double a; + double b; + double min; + double max; + double mean; + double r; + ulong ninst; +} actor_t; + +#define NBUCKETS 1811 + +actor_t *hash[NBUCKETS]; + +actor_t *find_or_create_actor (ulong key) +{ + ulong bucket; + actor_t *ap; + u8 *mem; + + bucket = key % NBUCKETS; + + ap = hash[bucket]; + + if (ap == NULL) { + /* Ensure 8-byte alignment to avoid (double) alignment faults */ + mem = malloc(sizeof(*ap) + 4); + if (((uword)(mem)) & 0x7) + mem += 4; + ap = (actor_t *)mem; + + if (ap == NULL) { + fprintf (stderr, "out of memory...\n"); + exit (1); + } + ap->next = 0; + ap->key = key; + ap->first = 0; + ap->last = 0; + ap->a = 0.00; + ap->b = 0.00; + hash [bucket] = ap; + return (ap); + } + + while (ap) { + if (ap->key == key) + return (ap); + ap = ap->next; + } + + mem = malloc(sizeof(*ap)+4); + if (((uword)(mem) & 0x7)) + mem += 4; + ap = (actor_t *)mem; + + if (ap == NULL) { + fprintf (stderr, "out of memory...\n"); + exit (1); + } + ap->key = key; + ap->first = 0; + ap->last = 0; + ap->a = 0.00; + ap->b = 0.00; + + ap->next = hash[bucket]; + hash[bucket] = ap; + + return (ap); +} + +void record_instance (ulong key, ulonglong time) +{ + actor_t *ap; + instance_t *ip; + + if (nokey) + key = 0; + + ap = find_or_create_actor (key); + + ip = (instance_t *)malloc(sizeof(*ip)); + if (ip == NULL) { + fprintf (stderr, "out of memory...\n"); + exit (1); + } + ip->time = time; + ip->next = 0; + + if (ap->first == 0) { + ap->first = ip; + ap->last = ip; + ap->ninst = 1; + } else { + ap->last->next = ip; + ap->last = ip; + ap->ninst++; + } +} + +#define NINSTANCE 200000 + +double x[NINSTANCE]; +double y[NINSTANCE]; + +int actor_compare (const void *arg1, const void *arg2) +{ + double e10k1, e10k2; + actor_t **a1 = (actor_t **)arg1; + actor_t **a2 = (actor_t **)arg2; + double ninst1, ninst2; + + ninst1 = ((double)((*a1)->ninst)); + ninst2 = ((double)((*a2)->ninst)); + + e10k1 = ninst1 * ((*a1)->mean); + e10k2 = ninst2 * ((*a2)->mean); + + if (e10k1 < e10k2) + return (1); + else if (e10k1 == e10k2) + return (0); + else + return (-1); +} + +void report_actors (void) +{ + int i; + actor_t *ap; + instance_t *ip; + int nactors = 0; + int ninstance; + actor_t **actor_vector; + double e10k; + extern void linreg (double *x, double *y, int nitems, double *a, double *b, + double *minp, double *maxp, double *meanp, double *r); + + for (i = 0; i < NBUCKETS; i++) { + ap = hash[i]; + if (ap == NULL) + continue; + while (ap) { + nactors++; + ninstance = 0; + + ip = ap->first; + + while (ip) { + if (ninstance < NINSTANCE) { + x[ninstance] = ninstance; + y[ninstance] = ((double)ip->time); + ninstance++; + } + ip = ip->next; + } + if (ninstance > 1) { +#if DEBUG > 0 + int j; + + for (j = 0; j < ninstance; j++) { + printf("x[%d] = %10.2f, y[%d] = %10.2f\n", + j, x[j], j, y[j]); + } +#endif + + linreg (x, y, ninstance, &ap->a, &ap->b, &ap->min, + &ap->max, &ap->mean, &ap->r); + } else { + ap->a = 0.00; + ap->b = 0.00; + } + + ap = ap->next; + } + } + + actor_vector = (actor_t **)malloc (nactors*sizeof(*actor_vector)); + nactors = 0; + + for (i = 0; i < NBUCKETS; i++) { + ap = hash[i]; + if (ap == NULL) + continue; + while (ap) { + if ((ap->a != 0.00) || (ap->b != 0.00)) { + actor_vector[nactors++] = ap; + } + ap = ap->next; + } + } + + qsort (actor_vector, nactors, sizeof (actor_t *), actor_compare); + + if (summary_stats) + printf("NInst Offset Slope T(Ninst) Min Max Avg %%InstTime R Key"); + else + printf("NInst Offset Slope T(Ninst) Key"); + + for (i = 0; i < model_index; i++) { + printf ("T @ %-8d ", model_these[i]); + } + + printf ("\n"); + + for (i = 0; i < nactors; i++) { + int j; + double ninst; + double pcttot; + ap = actor_vector[i]; + ninst = ap->ninst; + + e10k = ninst * (ap->a + ap->b*((ninst-1.0)/2.0)); + + if (ap->ninst) { + if (summary_stats) { + pcttot = (e10k / ((double)total_time)) * 100.0; + printf ("%6ld %11.2f %11.2f %11.2f %11.2f %11.2f %11.2f %11.2f %11.2f 0x%08lx ", + ap->ninst, ap->a, ap->b, e10k, ap->min, + ap->max, ap->mean, pcttot, ap->r, ap->key); + } + else + printf ("%6ld %11.2f %11.2f %11.2f 0x%08lx ", + ap->ninst, ap->a, ap->b, e10k, ap->key); + + for (j = 0; j < model_index; j++) { + ninst = model_these[j]; + e10k = ninst * (ap->a + ap->b*((ninst-1.0)/2.0)); + printf ("%10.2f ", e10k); + } + printf ("\n"); + } + } +} + +void scatterplot_data(void) +{ + actor_t *ap; + int i; + instance_t *ip; + double time; + int count=0; + + for (i = 0; i < NBUCKETS; i++) { + ap = hash[i]; + if (ap == NULL) + continue; + while (ap) { + if (ap->key == scatterkey){ + ip = ap->first; + while (ip) { + time = ((double)ip->time); + printf ("%d\t%.0f\n", count++, time); + ip = ip->next; + } + return; + } + ap = ap->next; + } + } +} + + +void fatal(char *s) +{ + fprintf(stderr, "%s", s); + fprintf(stderr, "\n"); + exit(1); +} + +typedef enum { + PASS1=1, +} pass_t; + +typedef struct { + int (*pass1)(cpel_section_header_t *, int, FILE *); +} section_processor_t; + +int bad_section(cpel_section_header_t *sh, int verbose, FILE *ofp) +{ + fprintf(ofp, "Bad (type 0) section, skipped...\n"); + return(0); +} + +int noop_pass(cpel_section_header_t *sh, int verbose, FILE *ofp) +{ + return(0); +} + +int unsupported_pass (cpel_section_header_t *sh, int verbose, FILE *ofp) +{ + if (verbose) { + fprintf(ofp, "Unsupported type %d section\n", + ntohl(sh->section_type)); + } + return(0); +} + +int trackdef_pass(cpel_section_header_t *sh, int verbose, FILE *ofp) +{ + int i, nevents; + track_definition_section_header_t *tdh; + track_definition_t *tp; + u32 track_code; + uword *p; + bound_track_t *btp; + + tdh = (track_definition_section_header_t *)(sh+1); + nevents = ntohl(tdh->number_of_track_definitions); + + if (verbose) { + fprintf(stderr, "Track Definition Section: %d definitions\n", + nevents); + } + + tp = (track_definition_t *)(tdh+1); + + for (i = 0; i < nevents; i++) { + track_code = ntohl(tp->track); + p = hash_get(the_trackdef_hash, track_code); + if (p) { + fprintf(ofp, "track %d redefined, retain first definition\n", + track_code); + continue; + } + vec_add2(bound_tracks, btp, 1); + btp->track_code = track_code; + hash_set(the_trackdef_hash, track_code, btp - bound_tracks); + tp++; + } + return (0); +} + + +int event_pass (cpel_section_header_t *sh, int verbose, FILE *ofp) +{ + event_section_header_t *eh; + event_entry_t *ep; + f64 ticks_per_us; + long output_count; + long dup_events = 0; + ulonglong end_time = 0; + double t; + int sp, ancestor; + int nevents, i; + u64 now; + u64 time0, time1; + double d; + u32 last_track_code = 0xdeafb00b; + u32 track_code; + u32 event_code, event_datum; + bound_track_t *tp = 0; + uword *p; + + output_count = 0; + total_time = 0; + + eh = (event_section_header_t *)(sh+1); + nevents = ntohl(eh->number_of_events); + ticks_per_us = ((double)ntohl(eh->clock_ticks_per_second))/1e6; + + if (verbose) { + fprintf(ofp, "%.3f ticks_per_us\n", ticks_per_us); + } + + ep = (event_entry_t *)(eh+1); + + time0 = ntohl (ep->time[0]); + time1 = ntohl (ep->time[1]); + + now = (((u64) time0)<<32) | time1; + d = now; + d /= ticks_per_us; + first_start_time = d; + + for (i = 0; i < nevents; i++) { + time0 = ntohl (ep->time[0]); + time1 = ntohl (ep->time[1]); + + now = (((u64) time0)<<32) | time1; + + /* Convert from bus ticks to usec */ + d = now; + d /= ticks_per_us; + + now = d; + + track_code = ntohl(ep->track); + event_code = ntohl(ep->event_code); + event_datum = ntohl(ep->event_datum); + + if (track_code != last_track_code) { + if (tp) { + tp->thread_timestamp += now - tp->time_thread_on_cpu; + tp->time_thread_on_cpu = 0; + } + p = hash_get(the_trackdef_hash, track_code); + if (!p) { + /* synthesize a new track */ + vec_add2(bound_tracks, tp, 1); + tp->track_code = track_code; + hash_set(the_trackdef_hash, track_code, tp - bound_tracks); + } else { + tp = bound_tracks + p[0]; + } + last_track_code = track_code; + tp->time_thread_on_cpu = now; + } + + if (event_code != entry_event && + event_code != exit_event) { + ep++; + continue; + } + + again: + switch (tp->state) { + case 0: /* not in state */ + /* Another exit event? Stack pop */ + if (event_code == exit_event) { + /* Only if we have something on the stack */ + if (vec_len(tp->start_datum) > 0) { + tp->state = 1; + goto again; + } else { + fprintf (stderr, + "End event before start event, key 0x%x.", + ntohl(ep->event_datum)); + fprintf (stderr, " Interpret results carefully...\n"); + } + } + + tp->state = 1; + if (vec_len(tp->start_datum) >= MAXSTACK) { + int j; + + fprintf (stderr, "stack overflow..\n"); + for (j = vec_len(tp->start_datum)-1; j >= 0; j--) { + fprintf(stderr, "stack[%d]: datum 0x%x\n", + j, tp->start_datum[j]); + } + fprintf (stderr, + "Stack overflow... This occurs when " + "(start, datum)...(end, datum) events\n" + "are not properly paired.\n\n" + "A typical scenario looks like this:\n\n" + " ...\n" + " ELOG(..., START_EVENT, datum);\n" + " if (condition)\n" + " return; /*oops, forgot the end event*/\n" + " ELOG(..., END_EVENT, datum);\n" + " ...\n\n" + "The datum stack dump (above) should make it clear\n" + "where to start looking for a sneak path...\n"); + + exit (1); + } + vec_add1(tp->start_datum, event_datum); + vec_add1(tp->start_time, (tp->thread_timestamp + (now - tp->time_thread_on_cpu))); +#ifdef HAVING_TROUBLE + printf ("sp %lld key 0x%x start time %llu\n", + (long long) vec_len(tp->start_time)-1, event_datum, + (unsigned long long) + tp->start_time [vec_len(tp->start_time)-1]); + printf ("timestamp %llu, now %llu, thread on cpu %llu\n", + (unsigned long long) tp->thread_timestamp, + (unsigned long long) now, + (unsigned long long) tp->time_thread_on_cpu); +#endif + + + + /* + * Multiple identical enter events? If the user knows that + * gcc is producing bogus events due to inline functions, + * trash the duplicate. + */ + if (inline_mokus + && vec_len (tp->start_datum) > 1 + && tp->start_datum [vec_len(tp->start_datum)-1] == + tp->start_datum [vec_len(tp->start_datum)-2]) { + vec_add1 (tp->dup_event, 1); + } else { + vec_add1 (tp->dup_event, 0); + } + + + ep++; + continue; + + case 1: /* in state */ + /* Another entry event? Stack push*/ + if (event_code == entry_event) { + tp->state = 0; + goto again; + } + + if (vec_len(tp->start_datum) == 0) { + fprintf (stderr, "Stack underflow...\n"); + exit (1); + } + + sp = vec_len(tp->start_time)-1; + + end_time = tp->thread_timestamp + (now - tp->time_thread_on_cpu); + + if (!tp->dup_event[sp]) { +#ifdef HAVING_TROUBLE + printf ("sp %d key 0x%x charged %llu\n", sp, + tp->start_datum[sp], end_time - tp->start_time[sp]); + printf (" start %llu, end %llu\n", (unsigned long long) tp->start_time[sp], + (unsigned long long) end_time); +#endif + + record_instance (tp->start_datum[sp], (end_time - + tp->start_time[sp])); + + /* Factor out our time from surrounding services, if any */ + for (ancestor = sp-1; ancestor >= 0; ancestor--) { +#ifdef HAVING_TROUBLE + printf ("Factor out %lld from key 0x%08x\n", + (end_time - tp->start_time[sp]), tp->start_datum[ancestor]); +#endif + tp->start_time[ancestor] += (end_time - tp->start_time[sp]); + } + output_count++; + total_time += (end_time - tp->start_time[sp]); + tp->state = 0; + } else { + dup_events++; + } + _vec_len(tp->start_datum) = sp; + _vec_len(tp->start_time) = sp; + _vec_len(tp->dup_event) = sp; + } + + ep++; + } + last_end_time = now; + + if (scatterkey) { + scatterplot_data(); + exit (0); + } + + if (output_count) { + t = (double)total_time; + printf ("%ld instances of state, %.2f microseconds average\n", + output_count, t / output_count); + + printf ("Total instrumented runtime: %.2f microseconds\n", + ((double)total_time)); + printf ("Total runtime: %lld microseconds\n", + last_end_time - first_start_time); + + t /= (double)(last_end_time - first_start_time); + t *= 100.0; + + if (dup_events) { + printf ("Suppressed %ld duplicate state entry events\n", + dup_events); + } + printf ("Instrumented code accounts for %.2f%% of total time.\n\n", + t); + report_actors(); + } else { + printf ("No instances of state...\n"); + } + + return(0); +} + +/* + * Note: If necessary, add passes / columns to this table to + * handle section order dependencies. + */ + +section_processor_t processors[CPEL_NUM_SECTION_TYPES+1] = +{ + {unsupported_pass}, /* type 0 -- f**ked */ + {noop_pass}, /* type 1 -- STRTAB */ + {noop_pass}, /* type 2 -- SYMTAB */ + {noop_pass}, /* type 3 -- EVTDEF */ + {trackdef_pass}, /* type 4 -- TRACKDEF */ + {event_pass}, /* type 5 -- EVENTS */ +}; + +int process_section(cpel_section_header_t *sh, int verbose, FILE *ofp, + pass_t pass) +{ + u32 type; + type = ntohl(sh->section_type); + int rv; + int (*fp)(cpel_section_header_t *, int, FILE *); + + if (type > CPEL_NUM_SECTION_TYPES) { + fprintf(stderr, "Unknown section type %d\n", type); + return(1); + } + switch(pass) { + case PASS1: + fp = processors[type].pass1; + break; + + default: + fprintf(stderr, "Unknown pass %d\n", pass); + return(1); + } + + rv = (*fp)(sh, verbose, ofp); + + return(rv); +} + +char *mapfile (char *file) +{ + struct stat statb; + char *rv; + int maphfile; + size_t mapfsize; + + maphfile = open (file, O_RDONLY); + + if (maphfile < 0) + { + fprintf (stderr, "Couldn't read %s, skipping it...\n", file); + return (NULL); + } + + if (fstat (maphfile, &statb) < 0) + { + fprintf (stderr, "Couldn't get size of %s, skipping it...\n", file); + return (NULL); + } + + /* Don't try to mmap directories, FIFOs, semaphores, etc. */ + if (! (statb.st_mode & S_IFREG)) { + fprintf (stderr, "%s is not a regular file, skipping it...\n", file); + return (NULL); + } + + mapfsize = statb.st_size; + + if (mapfsize < 3) + { + fprintf (stderr, "%s zero-length, skipping it...\n", file); + close (maphfile); + return (NULL); + } + + rv = mmap (0, mapfsize, PROT_READ, MAP_SHARED, maphfile, 0); + + if (rv == 0) + { + fprintf (stderr, "%s problem mapping, I quit...\n", file); + exit (-1); + } + close (maphfile); + return (rv); +} + +int process_file (u8 *cpel, int verbose) +{ + cpel_file_header_t *fh; + cpel_section_header_t *sh; + u16 nsections; + u32 section_size; + int i; + FILE *ofp = stderr; + + /* First, the file header */ + fh = (cpel_file_header_t *)cpel; + if (fh->endian_version != CPEL_FILE_VERSION) { + if (fh->endian_version & CPEL_FILE_LITTLE_ENDIAN) { + fprintf(stderr, "Little endian data format not supported\n"); + return(1); + } + fprintf(stderr, "Unsupported file version 0x%x\n", + fh->endian_version); + return(1); + } + nsections = ntohs(fh->nsections); + + /* + * Take a passe through the file. + */ + sh = (cpel_section_header_t *)(fh+1); + for (i = 0; i < nsections; i++) { + section_size = ntohl(sh->data_length); + + if(verbose) { + fprintf(ofp, "Section type %d, size %d\n", + ntohl(sh->section_type), + section_size); + } + + if(process_section(sh, verbose, ofp, PASS1)) + return(1); + + sh++; + sh = (cpel_section_header_t *)(((u8 *)sh)+section_size); + } + + return(0); +} + +/**************************************************************************** +* main - +****************************************************************************/ + +int main (int argc, char **argv) +{ + int curarg = 1; + u8 *cpel = 0; + int verbose = 0; + + if (argc < 6) + { + fprintf (stderr, "usage: cpelinreg -i \n"); + fprintf (stderr, " -s start-event --e end-event [-nokey]\n"); + fprintf (stderr, " [-m ][-xtra-stats]\n"); + fprintf (stderr, " [-keyscatterplot ]\n\n"); + fprintf (stderr, "%s\n", version); + exit (1); + } + + while (curarg < argc) { + if (!strncmp (argv[curarg], "-ifile", 2)) { + curarg++; + g_ifile = argv[curarg++]; + continue; + } + if (!strncmp (argv[curarg], "-start", 2)) { + curarg++; + entry_event = atol (argv [curarg++]); + continue; + } + if (!strncmp (argv[curarg], "-end", 2)) { + curarg++; + exit_event = atol (argv [curarg++]); + continue; + } + + if (!strncmp(argv[curarg], "-badinlines", 2)) { + curarg++; + inline_mokus = 1; + continue; + } + + if (!strncmp (argv[curarg], "-x", 2)) { + curarg++; + summary_stats=1; + continue; + } + if (!strncmp (argv[curarg], "-nokey", 2)) { + curarg++; + nokey = 1; + continue; + } + if (!strncmp (argv[curarg], "-keyscatterplot", 2)) { + curarg++; + sscanf (argv[curarg], "%lx", &scatterkey); + curarg++; + continue; + } + + if (!strncmp (argv[curarg], "-model", 2)) { + if (model_index >= sizeof(model_these) / sizeof(int)) { + fprintf (stderr, "Too many model requests\n"); + exit (1); + } + curarg++; + model_these[model_index++] = atol (argv [curarg++]); + continue; + } + if (!strncmp (argv[curarg], "-verbose", 2)) { + verbose++; + curarg++; + continue; + } + + fprintf (stderr, "unknown switch '%s'\n", argv[curarg]); + exit (1); + } + + cpel = (u8 *)mapfile(g_ifile); + + if (cpel == NULL) + { + fprintf (stderr, "Couldn't open %s\n", g_ifile); + exit (1); + } + + printf ("Extracting state info from %s\nentry_event %d, exit_event %d\n", + g_ifile, entry_event, exit_event); + if (nokey) { + printf ("All state instances mapped to a single actor chain\n"); + } + + the_trackdef_hash = hash_create (0, sizeof (uword)); + + process_file(cpel, verbose); + exit (0); +} diff --git a/src/tools/perftool/cpelstate.c b/src/tools/perftool/cpelstate.c new file mode 100644 index 00000000..3fd9ccb9 --- /dev/null +++ b/src/tools/perftool/cpelstate.c @@ -0,0 +1,822 @@ +/* + *------------------------------------------------------------------ + * Copyright (c) 2006-2016 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "cpel.h" +#include + +char *time_format = "%.03d:%.02d:%.02d:%.03d:%.03d "; +static char version[] = "cpelstate 2.0h"; + +#define USEC_PER_MS 1000LL +#define USEC_PER_SECOND (1000*USEC_PER_MS) +#define USEC_PER_MINUTE (60*USEC_PER_SECOND) +#define USEC_PER_HOUR (60*USEC_PER_MINUTE) + +uword *the_strtab_hash; /* (name, base-VA) hash of all string tables */ +uword *the_evtdef_hash; /* (event-id, event-definition) hash */ +uword *the_trackdef_hash; /* (track-id, track-definition) hash */ + +f64 ticks_per_us; +u32 state_event_code = 1; /* default: XR thread-on-cpu */ +int exclude_kernel_from_summary_stats=1; +int summary_stats_only; +int scatterplot; +u8 *name_filter; + +typedef enum { + SORT_MAX_TIME=1, + SORT_MAX_OCCURRENCES, + SORT_NAME, +} sort_t; + +sort_t sort_type = SORT_MAX_TIME; + +int widest_name_format=5; +int widest_track_format=5; + +typedef struct bound_event_ { + u32 event_code; + u8 *event_str; + u8 *datum_str; + u32 is_strtab_ref; +} bound_event_t; + +bound_event_t *bound_events; + +typedef struct bound_track_ { + u32 track; + u8 *track_str; + u64 *ticks_in_state; /* vector of state occurrences */ + f64 mean_ticks_in_state; + f64 variance_ticks_in_state; + f64 total_ticks_in_state; +} bound_track_t; + +bound_track_t *bound_tracks; + +void fatal(char *s) +{ + fprintf(stderr, "%s", s); + exit(1); +} + +typedef enum { + PASS1=1, + PASS2=2, +} pass_t; + +typedef struct { + int (*pass1)(cpel_section_header_t *, int, FILE *); + int (*pass2)(cpel_section_header_t *, int, FILE *); +} section_processor_t; + +int bad_section(cpel_section_header_t *sh, int verbose, FILE *ofp) +{ + fprintf(ofp, "Bad (type 0) section, skipped...\n"); + return(0); +} + +int noop_pass(cpel_section_header_t *sh, int verbose, FILE *ofp) +{ + return(0); +} + +int strtab_pass1(cpel_section_header_t *sh, int verbose, FILE *ofp) +{ + uword *p; + u8 *strtab_data_area = (u8 *)(sh+1); + + /* Multiple string tables with the same name are Bad... */ + p = hash_get_mem(the_strtab_hash, strtab_data_area); + if (p) { + fprintf(ofp, "Duplicate string table name %s", strtab_data_area); + } + /* + * Looks funny, but we really do want key = first string in the + * table, value = address(first string in the table) + */ + hash_set_mem(the_strtab_hash, strtab_data_area, strtab_data_area); + if (verbose) { + fprintf(ofp, "String Table %s\n", strtab_data_area); + } + return(0); +} + +int evtdef_pass1(cpel_section_header_t *sh, int verbose, FILE *ofp) +{ + int i, nevents; + event_definition_section_header_t *edh; + event_definition_t *ep; + u8 *this_strtab; + u32 event_code; + uword *p; + bound_event_t *bp; + int thislen; + + edh = (event_definition_section_header_t *)(sh+1); + nevents = ntohl(edh->number_of_event_definitions); + + if (verbose) { + fprintf(ofp, "Event Definition Section: %d definitions\n", + nevents); + } + + p = hash_get_mem(the_strtab_hash, edh->string_table_name); + if (!p) { + fprintf(ofp, "Fatal: couldn't find string table\n"); + return(1); + } + this_strtab = (u8 *)p[0]; + + ep = (event_definition_t *)(edh+1); + + for (i = 0; i < nevents; i++) { + event_code = ntohl(ep->event); + p = hash_get(the_evtdef_hash, event_code); + if (p) { + fprintf(ofp, "Event %d redefined, retain first definition\n", + event_code); + continue; + } + vec_add2(bound_events, bp, 1); + bp->event_code = event_code; + bp->event_str = this_strtab + ntohl(ep->event_format); + bp->datum_str = this_strtab + ntohl(ep->datum_format); + bp->is_strtab_ref = 0; + /* Decide if the datum format is a %s format => strtab reference */ + { + int j; + int seen_percent=0; + + for (j = 0; j < strlen((char *)(bp->datum_str)); j++) { + if (bp->datum_str[j] == '%'){ + seen_percent=1; + continue; + } + if (seen_percent && bp->datum_str[j] == 's') { + bp->is_strtab_ref = 1; + } + } + } + + hash_set(the_evtdef_hash, event_code, bp - bound_events); + + thislen = strlen((char *)bp->event_str); + if (thislen > widest_name_format) + widest_name_format = thislen; + + ep++; + } + return (0); +} + +int trackdef_pass1(cpel_section_header_t *sh, int verbose, FILE *ofp) +{ + int i, nevents; + track_definition_section_header_t *tdh; + track_definition_t *tp; + u8 *this_strtab; + u32 track_code; + uword *p; + bound_track_t *btp; + int thislen; + + tdh = (track_definition_section_header_t *)(sh+1); + nevents = ntohl(tdh->number_of_track_definitions); + + if (verbose) { + fprintf(ofp, "Track Definition Section: %d definitions\n", + nevents); + } + + p = hash_get_mem(the_strtab_hash, tdh->string_table_name); + if (!p) { + fprintf(ofp, "Fatal: couldn't find string table\n"); + return(1); + } + this_strtab = (u8 *)p[0]; + + tp = (track_definition_t *)(tdh+1); + + for (i = 0; i < nevents; i++) { + track_code = ntohl(tp->track); + p = hash_get(the_trackdef_hash, track_code); + if (p) { + fprintf(ofp, "track %d redefined, retain first definition\n", + track_code); + continue; + } + vec_add2(bound_tracks, btp, 1); + btp->track = track_code; + btp->track_str = this_strtab + ntohl(tp->track_format); + hash_set(the_trackdef_hash, track_code, btp - bound_tracks); + + thislen = strlen((char *)(btp->track_str)); + if (thislen > widest_track_format) + widest_track_format = thislen; + tp++; + } + return (0); +} + +int unsupported_pass (cpel_section_header_t *sh, int verbose, FILE *ofp) +{ + if (verbose) { + fprintf(ofp, "Unsupported type %d section\n", + ntohl(sh->section_type)); + } + return(0); +} + +int event_pass2(cpel_section_header_t *sh, int verbose, FILE *ofp) +{ + event_section_header_t *eh; + u32 track_code; + int nevents; + int i; + uword *p; + event_entry_t *ep; + u64 now; + u32 time0, time1; + bound_track_t generic_track; + u32 last_track_code; + u64 state_start_ticks=0; + u64 ticks_in_state; + bound_track_t *state_track=0; + int in_state=0; + generic_track.track_str = (u8 *) "%d"; + last_track_code = 0xdeafbeef; + + eh = (event_section_header_t *)(sh+1); + nevents = ntohl(eh->number_of_events); + ticks_per_us = ((double)ntohl(eh->clock_ticks_per_second))/1e6; + + if (verbose) { + fprintf(ofp, "%.3f ticks_per_us\n", ticks_per_us); + } + + ep = (event_entry_t *)(eh+1); + + p = hash_get_mem(the_strtab_hash, eh->string_table_name); + if (!p) { + fprintf(ofp, "Fatal: couldn't find string table\n"); + return(1); + } + + for (i = 0; i < nevents; i++) { + time0 = ntohl (ep->time[0]); + time1 = ntohl (ep->time[1]); + + now = (((u64) time0)<<32) | time1; + + /* Found the state-change event ? */ + if (ntohl(ep->event_code) == state_event_code) { + /* + * Add a ticks-in-state record, unless + * this is the "prime mover" event instance + */ + if (in_state) { + ticks_in_state = now - state_start_ticks; + vec_add1(state_track->ticks_in_state, ticks_in_state); + } + /* switch to now-current track */ + state_start_ticks = now; + track_code = ntohl(ep->track); + if (track_code != last_track_code) { + p = hash_get(the_trackdef_hash, track_code); + if (p) { + state_track = &bound_tracks[p[0]]; + } else { + state_track = &generic_track; + } + last_track_code = track_code; + } + in_state = 1; + } + ep++; + } + return(0); +} + +/* + * Note: If necessary, add passes / columns to this table to + * handle section order dependencies. + */ + +section_processor_t processors[CPEL_NUM_SECTION_TYPES+1] = +{ + {bad_section, noop_pass}, /* type 0 -- f**ked */ + {strtab_pass1, noop_pass}, /* type 1 -- STRTAB */ + {unsupported_pass, noop_pass}, /* type 2 -- SYMTAB */ + {evtdef_pass1, noop_pass}, /* type 3 -- EVTDEF */ + {trackdef_pass1, noop_pass}, /* type 4 -- TRACKDEF */ + {noop_pass, event_pass2}, /* type 5 -- EVENTS */ +}; + + +int process_section(cpel_section_header_t *sh, int verbose, FILE *ofp, + pass_t pass) +{ + u32 type; + type = ntohl(sh->section_type); + int rv; + int (*fp)(cpel_section_header_t *, int, FILE *); + + if (type > CPEL_NUM_SECTION_TYPES) { + fprintf(stderr, "Unknown section type %d\n", type); + return(1); + } + switch(pass) { + case PASS1: + fp = processors[type].pass1; + break; + + case PASS2: + fp = processors[type].pass2; + break; + + default: + fprintf(stderr, "Unknown pass %d\n", pass); + return(1); + } + + rv = (*fp)(sh, verbose, ofp); + + return(rv); +} + +int cpel_dump_file_header(cpel_file_header_t *fh, int verbose, FILE *ofp) +{ + time_t file_time; + + if (verbose) { + fprintf(ofp, "CPEL file: %s-endian, version %d\n", + ((fh->endian_version & CPEL_FILE_LITTLE_ENDIAN) ? + "little" : "big"), + fh->endian_version & CPEL_FILE_VERSION_MASK); + + file_time = ntohl(fh->file_date); + + fprintf(ofp, "File created %s", ctime(&file_time)); + fprintf(ofp, "File has %d sections\n", + ntohs(fh->nsections)); + } + + return(0); +} + + +int cpel_dump(u8 *cpel, int verbose, FILE *ofp) +{ + cpel_file_header_t *fh; + cpel_section_header_t *sh; + u16 nsections; + u32 section_size; + int i; + + /* First, the file header */ + fh = (cpel_file_header_t *)cpel; + if (fh->endian_version != CPEL_FILE_VERSION) { + if (fh->endian_version & CPEL_FILE_LITTLE_ENDIAN) { + fprintf(stderr, "Little endian data format not supported\n"); + return(1); + } + fprintf(stderr, "Unsupported file version 0x%x\n", + fh->endian_version); + return(1); + } + cpel_dump_file_header(fh, verbose, ofp); + nsections = ntohs(fh->nsections); + + /* + * Take two passes through the file. PASS1 builds + * data structures, PASS2 actually dumps the file. + * Just in case the sections are in an unobvious order. + */ + sh = (cpel_section_header_t *)(fh+1); + for (i = 0; i < nsections; i++) { + section_size = ntohl(sh->data_length); + + if(verbose) { + fprintf(ofp, "Section type %d, size %d\n", ntohl(sh->section_type), + section_size); + } + + if(process_section(sh, verbose, ofp, PASS1)) + return(1); + + sh++; + sh = (cpel_section_header_t *)(((u8 *)sh)+section_size); + } + + sh = (cpel_section_header_t *)(fh+1); + for (i = 0; i < nsections; i++) { + if(process_section(sh, verbose, ofp, PASS2)) + return(1); + section_size = ntohl(sh->data_length); + sh++; + sh = (cpel_section_header_t *)(((u8 *)sh)+section_size); + } + return(0); +} + +void compute_state_statistics(int verbose, FILE *ofp) +{ + int i, j; + bound_track_t *bp; + f64 fticks; + + /* Across the bound tracks */ + for (i = 0; i < vec_len(bound_tracks); i++) { + bp = &bound_tracks[i]; + bp->mean_ticks_in_state = 0.0; + bp->variance_ticks_in_state = 0.0; + bp->total_ticks_in_state = 0.0; + for (j = 0; j < vec_len(bp->ticks_in_state); j++) { + bp->total_ticks_in_state += (f64) bp->ticks_in_state[j]; + } + /* Compute mean */ + if (vec_len(bp->ticks_in_state)) { + bp->mean_ticks_in_state = bp->total_ticks_in_state / + ((f64) vec_len(bp->ticks_in_state)); + } + /* Accumulate sum: (Xi-Xbar)**2 */ + for (j = 0; j < vec_len(bp->ticks_in_state); j++) { + fticks = bp->ticks_in_state[j]; + bp->variance_ticks_in_state += + (fticks - bp->mean_ticks_in_state)* + (fticks - bp->mean_ticks_in_state); + } + /* Compute s**2, the unbiased estimator of sigma**2 */ + if (vec_len(bp->ticks_in_state) > 1) { + bp->variance_ticks_in_state /= (f64) + (vec_len(bp->ticks_in_state)-1); + } + } +} + +int track_compare_max (const void *arg1, const void *arg2) +{ + bound_track_t *a1 = (bound_track_t *)arg1; + bound_track_t *a2 = (bound_track_t *)arg2; + f64 v1, v2; + + v1 = a1->total_ticks_in_state; + v2 = a2->total_ticks_in_state; + + if (v1 < v2) + return (1); + else if (v1 == v2) + return (0); + else return (-1); +} + +int track_compare_occurrences (const void *arg1, const void *arg2) +{ + bound_track_t *a1 = (bound_track_t *)arg1; + bound_track_t *a2 = (bound_track_t *)arg2; + f64 v1, v2; + + v1 = (f64) vec_len(a1->ticks_in_state); + v2 = (f64) vec_len(a2->ticks_in_state); + + if (v1 < v2) + return (1); + else if (v1 == v2) + return (0); + else return (-1); +} + +int track_compare_name (const void *arg1, const void *arg2) +{ + bound_track_t *a1 = (bound_track_t *)arg1; + bound_track_t *a2 = (bound_track_t *)arg2; + + return (strcmp((char *)(a1->track_str), (char *)(a2->track_str))); +} + +void sort_state_statistics(sort_t type, FILE *ofp) +{ + int (*compare)(const void *, const void *)=0; + + if (summary_stats_only) + return; + + switch(type) { + case SORT_MAX_TIME: + fprintf(ofp, "Results sorted by max time in state.\n"); + compare = track_compare_max; + break; + + case SORT_MAX_OCCURRENCES: + fprintf(ofp, "Results sorted by max occurrences of state.\n"); + compare = track_compare_occurrences; + break; + + case SORT_NAME: + compare = track_compare_name; + fprintf(ofp, "Results sorted by process-id/name/thread ID\n"); + break; + + default: + fatal("sort type not set?"); + } + + qsort (bound_tracks, vec_len(bound_tracks), + sizeof (bound_track_t), compare); +} + +void print_state_statistics(int verbose, FILE *ofp) +{ + int i,j; + u8 *trackpad; + bound_track_t *bp; + f64 total_time = 0.0; + f64 total_switches = 0.0; + + trackpad = format(0, "%%-%ds ", widest_track_format); + vec_add1(trackpad, 0); + + if (!summary_stats_only) { + fprintf(ofp, (char *)trackpad, "ProcThread"); + fprintf(ofp, " Mean(us) Stdev(us) Total(us) N\n"); + } + + for (i = 0; i < vec_len(bound_tracks); i++) { + bp = &bound_tracks[i]; + if (bp->mean_ticks_in_state == 0.0) + continue; + + if (name_filter && + strncmp((char *)(bp->track_str), (char *)name_filter, + strlen((char *)name_filter))) + continue; + + /* + * Exclude kernel threads (e.g. idle thread) from + * state statistics + */ + if (exclude_kernel_from_summary_stats && + !strncmp((char *)(bp->track_str), "kernel ", 7)) + continue; + + total_switches += (f64) vec_len(bp->ticks_in_state); + + if (!summary_stats_only) { + fprintf(ofp, (char *) trackpad, bp->track_str); + fprintf(ofp, "%10.3f +- %10.3f", + bp->mean_ticks_in_state / ticks_per_us, + sqrt(bp->variance_ticks_in_state) + / (f64) ticks_per_us); + fprintf(ofp, "%12.3f", + bp->total_ticks_in_state / ticks_per_us); + fprintf(ofp, "%8d\n", (int)vec_len(bp->ticks_in_state)); + } + + if (scatterplot) { + for (j = 0; j < vec_len(bp->ticks_in_state); j++) { + fprintf(ofp, "%.3f\n", + (f64)bp->ticks_in_state[j] / ticks_per_us); + } + } + + total_time += bp->total_ticks_in_state; + } + + if (!summary_stats_only) + fprintf(ofp, "\n"); + fprintf(ofp, "Note: the following statistics %s kernel-thread activity.\n", + exclude_kernel_from_summary_stats ? "exclude" : "include"); + if (name_filter) + fprintf(ofp, + "Note: only pid/proc/threads matching '%s' are included.\n", + name_filter); + + fprintf(ofp, + "Total runtime: %10.3f (us), Total state switches: %.0f\n", + total_time / ticks_per_us, total_switches); + fprintf(ofp, "Average time in state: %10.3f (us)\n", + (total_time / total_switches) / ticks_per_us); +} + +char *mapfile (char *file) +{ + struct stat statb; + char *rv; + int maphfile; + size_t mapfsize; + + maphfile = open (file, O_RDONLY); + + if (maphfile < 0) + { + fprintf (stderr, "Couldn't read %s, skipping it...\n", file); + return (NULL); + } + + if (fstat (maphfile, &statb) < 0) + { + fprintf (stderr, "Couldn't get size of %s, skipping it...\n", file); + return (NULL); + } + + /* Don't try to mmap directories, FIFOs, semaphores, etc. */ + if (! (statb.st_mode & S_IFREG)) { + fprintf (stderr, "%s is not a regular file, skipping it...\n", file); + return (NULL); + } + + mapfsize = statb.st_size; + + if (mapfsize < 3) + { + fprintf (stderr, "%s zero-length, skipping it...\n", file); + close (maphfile); + return (NULL); + } + + rv = mmap (0, mapfsize, PROT_READ, MAP_SHARED, maphfile, 0); + + if (rv == 0) + { + fprintf (stderr, "%s problem mapping, I quit...\n", file); + exit (-1); + } + close (maphfile); + return (rv); +} + +/* + * main + */ +int main (int argc, char **argv) +{ + char *cpel_file = 0; + char *outputfile = 0; + FILE *ofp; + char *cpel; + int verbose=0; + int curarg=1; + + while (curarg < argc) { + if (!strncmp(argv[curarg], "--input-file", 3)) { + curarg++; + if (curarg < argc) { + cpel_file = argv[curarg]; + curarg++; + continue; + } + fatal("Missing filename after --input-file\n"); + } + if (!strncmp(argv[curarg], "--output-file", 3)) { + curarg ++; + if (curarg < argc) { + outputfile = argv[curarg]; + curarg ++; + continue; + } + fatal("Missing filename after --output-file\n"); + } + if (!strncmp(argv[curarg], "--verbose", 3)) { + curarg++; + verbose++; + continue; + } + if (!strncmp(argv[curarg], "--scatterplot", 4)) { + curarg++; + scatterplot=1; + continue; + } + + if (!strncmp(argv[curarg], "--state-event", 4)) { + curarg++; + if (curarg < argc) { + state_event_code = atol(argv[curarg]); + curarg ++; + continue; + } + fatal("Missing integer after --state-event\n"); + } + if (!strncmp(argv[curarg], "--max-time-sort", 7)) { + sort_type = SORT_MAX_TIME; + curarg++; + continue; + } + if (!strncmp(argv[curarg], "--max-occurrence-sort", 7)) { + sort_type = SORT_MAX_OCCURRENCES; + curarg++; + continue; + } + if (!strncmp(argv[curarg], "--name-sort", 3)) { + sort_type = SORT_NAME; + curarg++; + continue; + } + if (!strncmp(argv[curarg], "--kernel-included", 3)) { + exclude_kernel_from_summary_stats = 0; + curarg++; + continue; + } + if (!strncmp(argv[curarg], "--summary", 3)) { + summary_stats_only=1; + curarg++; + continue; + } + if (!strncmp(argv[curarg], "--filter", 3)) { + curarg ++; + if (curarg < argc) { + name_filter = (u8 *)argv[curarg]; + curarg ++; + continue; + } + fatal("Missing filter string after --filter\n"); + } + + + usage: + fprintf(stderr, + "cpelstate --input-file [--output-file ]\n"); + fprintf(stderr, + " [--state-event ] [--verbose]\n"); + fprintf(stderr, + " [--max-time-sort(default) | --max-occurrence-sort |\n"); + + fprintf(stderr, + " --name-sort-sort] [--kernel-included]\n"); + + fprintf(stderr, + " [--summary-stats-only] [--scatterplot]\n"); + + fprintf(stderr, "%s\n", version); + exit(1); + } + + if (cpel_file == 0) + goto usage; + + cpel = mapfile(cpel_file); + if (cpel == 0) { + fprintf(stderr, "Couldn't map %s...\n", cpel_file); + exit(1); + } + + if (!outputfile) { + ofp = fdopen(1, "w"); + if (ofp == NULL) { + fprintf(stderr, "Couldn't fdopen(1)?\n"); + exit(1); + } + } else { + ofp = fopen(outputfile, "w"); + if (ofp == NULL) { + fprintf(stderr, "Couldn't create %s...\n", outputfile); + exit(1); + } + } + + the_strtab_hash = hash_create_string (0, sizeof (uword)); + the_evtdef_hash = hash_create (0, sizeof (uword)); + the_trackdef_hash = hash_create (0, sizeof (uword)); + + if (cpel_dump((u8 *) cpel, verbose, ofp)) { + if (outputfile) + unlink(outputfile); + } + + compute_state_statistics(verbose, ofp); + sort_state_statistics(sort_type, ofp); + print_state_statistics(verbose, ofp); + + fclose(ofp); + return(0); +} diff --git a/src/tools/perftool/delsvec.c b/src/tools/perftool/delsvec.c new file mode 100644 index 00000000..724935d3 --- /dev/null +++ b/src/tools/perftool/delsvec.c @@ -0,0 +1,315 @@ +/* + *------------------------------------------------------------------ + * Copyright (c) 2006-2016 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* Break up a delimited string into a vector of substrings */ + +#include +#include +#include +#include +#include + +/* + * #define UNIT_TESTS 1 + * #define MATCH_TRACE 1 + */ + +/* + * delsvec + * break up an input string into a vector of [null-terminated] u8 *'s + * + * Each supplied delimiter character results in a string in the output + * vector, unless the delimiters occur back-to-back. When matched, + * a whitespace character in the delimiter consumes an arbitrary + * run of whitespace. See the unit tests at the end of this file + * for a set of examples. + * + * Returns a u8 **, or NULL if the input fails to match. It is assumed + * that both input and fmt are C strings, not necessarily vectors. + * + * Output strings are both vectors and proper C strings. + */ + +static u8 **string_cache; +static u8 **svec_cache; + +void delsvec_recycle_this_string (u8 *s) +{ + if (s) { + _vec_len (s) = 0; + vec_add1(string_cache, s); + } +} + +void delsvec_recycle_this_svec (u8 **svec) +{ + if (svec) { + if (svec_cache) { + vec_free (svec_cache); + } + _vec_len (svec) = 0; + svec_cache = svec; + } +} + +int pvl (char *a) +{ + return vec_len(a); +} + +u8 **delsvec(void *input_arg, char *fmt) +{ + u8 **rv = 0; + int input_index=0; + u8 *this; + int dirflag=0; + int i; + u8 *input = input_arg; + + if (svec_cache) { + rv = svec_cache; + svec_cache = 0; + } + + while (fmt) { + dirflag=0; + if (vec_len (string_cache) > 0) { + this = string_cache [vec_len(string_cache)-1]; + _vec_len (string_cache) = vec_len (string_cache) - 1; + } else + this = 0; + /* + * '*' means one of two things: match the rest of the input, + * or match as many characters as possible + */ + if (fmt[0] == '*') { + fmt++; + dirflag=1; + /* + * no more format: eat rest of string... + */ + if (!fmt[0]) { + for (;input[input_index]; input_index++) + vec_add1(this, input[input_index]); + if (vec_len(this)) { + vec_add1(this, 0); +#ifdef MATCH_TRACE + printf("final star-match adds: '%s'\n", this); +#endif + vec_add1(rv, this); + } else { + vec_add1(string_cache, this); + } + + return(rv); + } + } + /* + * Left-to-right scan, adding chars until next delimiter char + * appears. + */ + if (!dirflag) { + while (input[input_index]) { + if (input[input_index] == fmt[0]) { + /* If we just (exact) matched a whitespace delimiter */ + if (fmt[0] == ' '){ + /* scan forward eating whitespace */ + while (input[input_index] == ' ' || + input[input_index] == '\t' || + input[input_index] == '\n') + input_index++; + input_index--; + } + goto found; + } + /* If we're looking for whitespace */ + if (fmt[0] == ' ') { + /* and we have whitespace */ + if (input[input_index] == ' ' || + input[input_index] == '\t' || + input[input_index] == '\n') { + /* scan forward eating whitespace */ + while (input[input_index] == ' ' || + input[input_index] == '\t' || + input[input_index] == '\n') { + input_index++; + } + input_index--; + goto found; + } + } + /* Not a delimiter, save it */ + vec_add1(this, input[input_index]); + input_index++; + } + /* + * Fell off the wagon, clean up and bail out + */ + bail: + +#ifdef MATCH_TRACE + printf("failed, fmt[0] = '%c', input[%d]='%s'\n", + fmt[0], input_index, &input[input_index]); +#endif + delsvec_recycle_this_string(this); + for (i = 0; i < vec_len(rv); i++) + delsvec_recycle_this_string(rv[i]); + delsvec_recycle_this_svec(rv); + return(0); + + found: + /* + * Delimiter matched + */ + input_index++; + fmt++; + /* + * If we actually accumulated non-delimiter characters, + * add them to the result vector + */ + if (vec_len(this)) { + vec_add1(this, 0); +#ifdef MATCH_TRACE + printf("match: add '%s'\n", this); +#endif + vec_add1(rv, this); + } else { + vec_add1(string_cache, this); + } + } else { + /* + * right-to-left scan, '*' not at + * the end of the delimiter string + */ + i = input_index; + while (input[++i]) + ; /* scan forward */ + i--; + while (i > input_index) { + if (input[i] == fmt[0]) + goto found2; + + if (fmt[0] == ' ' || fmt[0] == '\t' || + fmt[0] == '\n') { + if (input[i] == ' ' || + input[i] == '\t' || + input[i] == '\n') + goto found2; + } + i--; + } + goto bail; + + found2: + for (; input_index < i; input_index++) { + vec_add1(this, input[input_index]); + } + input_index++; + fmt++; + vec_add1(this, 0); +#ifdef MATCH_TRACE + printf("inner '*' match: add '%s'\n", this); +#endif + vec_add1(rv, this); + } + } + return (rv); +} + +#ifdef UNIT_TESTS + +typedef struct utest_ { + char *string; + char *fmt; +} utest_t; + +utest_t tests[] = { +#ifdef NOTDEF + {"Dec 7 08:56", + " :*"}, + {"Dec 17 08:56", + " :*"}, + {"Dec 7 08:56:41.239 install/inst_repl 0/9/CPU0 t1 [40989] File List:Successfully blobbified file list. Took 1 milliseconds", + " ::. / // [] *"}, + {"RP/0/9/CPU0:Dec 7 08:55:28.550 : sam_server[291]: SAM backs up digest list to memory file", + "///: ::. : []: *"}, + /* Expected to fail */ + {"Dec 7 08:56:41.239 install/inst_repl 0/9/CPU0 t1 [40989] File List:Successfully blobbified file list. Took 1 milliseconds", + "///: ::. : : *"}, + /* Expected to fail */ + {"RP/0/9/CPU0:Dec 7 08:55:28.550 : sam_server[291]: SAM backs up digest list to memory file", + " ::. / // [] *"}, + {"THIS that and + theother", "*+ *"}, + {"Dec 12 15:33:07.103 ifmgr/errors 0/RP0/CPU0 3# t2 Failed to open IM connection: No such file or directory", " ::. / // *"}, + {"Dec 16 21:43:47.328 ifmgr/bulk 0/3/CPU0 t8 Bulk DPC async download complete. Partitions 1, node_count 1, total_out 0, out_offset 0, out_expected 0: No error"," ::. / // *"}, + {"t:0x53034bd6 CPU:00 PROCESS :PROCCREATE_NAME", + ": : :*"}, + {" pid:1", " *"}, + {"t:0x53034cbb CPU:00 THREAD :THCREATE pid:1 tid:1", + ": : : pid: tid:*"}, + {"t:0x5303f950 CPU:00 COMM :REC_PULSE scoid:0x40000003 pid:364659", + ": : : *"}, + {"/hfr-base-3.3.85/lib/libttyconnection.dll 0xfc000000 0x0000306c 0xfc027000 0x000001c8 1", + " *"}, + {"Feb 28 02:38:26.123 seqtrace 0/1/CPU0 t8 :msg_receive:ifmgr/t8:IMC_MSG_MTU_UPDATE:ppp_ma/t1", + " ::. // ::::*"}, + + {"Feb 28 02:38:26.123 seqtrace 0/1/CPU0 t8 :msg_send_event:call:ifmgr/t8:124/0:cdp/t1", + " ::. // :msg_send_event::::*"}, + + {"Feb 28 02:38:26.125 seqtrace 0/1/CPU0 t1 :msg_receive_event:cdp/t1:124/0", + " ::. // :msg_receive_event::*"} + {"t:0x645dd86d CPU:00 USREVENT:EVENT:100, d0:0x00000002 d1:0x00000000", + ": : USREVENT:EVENT:, d0: *"} + {"t:0x5303f950 CPU:00 COMM :REC_PULSE scoid:0x40000003 pid:364659", + ": : : *"}, + {"t:0x2ccf9f5a CPU:00 INT_ENTR:0x80000000 (-2147483648) IP:0x002d8b18", + ": : INT_ENTR: IP:*"} + {"t:0xd473951c CPU:00 KER_EXIT:SCHED_GET/88 ret_val:2 sched_priority:10", + ": : KER_EXIT:SCHED_GET : sched_priority:*"} + {"t:0x00000123 CPU:01 SYSTEM :FUNC_ENTER thisfn:0x40e62048 call_site:0x00000000", + ": : SYSTEM :FUNC_ thisfn: *"}, + {"t:0x5af8de95 CPU:00 INT_HANDLER_ENTR:0x0000004d (77) PID:8200 IP:0x00000000 AREA:0x0bf9b290", ": : INT_HANDLER_*"}, +#endif + {"t:0x6d1ff92f CPU:00 CONTROL: BUFFER sequence = 1053, num_events = 714", + ": : CONTROL*"}, + {"t:0x6d1ff92f CPU:00 CONTROL :TIME msb:0x0000003c lsb(offset):0x6d1ff921", + ": : CONTROL*"}, +}; + +int main (int argc, char **argv) +{ + int i, j; + u8 **svec; + + for (j = 0; j < ARRAY_LEN(tests); j++) { + printf ("input string: '%s'\n", tests[j].string); + printf ("delimiter arg: '%s'\n", tests[j].fmt); + printf ("parse trace:\n"); + svec = delsvec(tests[j].string, tests[j].fmt); + if (!svec) { + printf("index %d failed\n", j); + continue; + } + printf("%d substring vectors\n", vec_len(svec)); + for (i = 0; i < vec_len(svec); i++) { + printf("[%d]: '%s'\n", i, svec[i]); + } + printf ("-------------------\n"); + } + exit(0); +} +#endif diff --git a/src/tools/perftool/linreg.c b/src/tools/perftool/linreg.c new file mode 100644 index 00000000..084091bb --- /dev/null +++ b/src/tools/perftool/linreg.c @@ -0,0 +1,78 @@ +/* + *------------------------------------------------------------------ + * Copyright (c) 2006-2016 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* see "Numerical Recipies in C, 2nd ed." p 665 */ + +#include +#include + +/* + * linreg + * Linear regression of (xi, yi), returns parameters for least-squares + * fit y = a + bx. Also, compute Pearson's R. + */ +void linreg (double *x, double *y, int nitems, double *a, double *b, + double *minp, double *maxp, double *meanp, double *r) +{ + double sx = 0.0; + double sy = 0.0; + double st2 = 0.0; + double min = y[0]; + double max = 0.0; + double ss, meanx, meany, t; + double errx, erry, prodsum, sqerrx, sqerry; + int i; + + *b = 0.0; + + for (i = 0; i < nitems; i++) { + sx += x[i]; + sy += y[i]; + if (y[i] < min) + min = y[i]; + if (y[i] > max) + max = y[i]; + } + ss = nitems; + meanx = sx / ss; + meany = *meanp = sy / ss; + *minp = min; + *maxp = max; + + for (i = 0; i < nitems; i++) { + t = x[i] - meanx; + st2 += t*t; + *b += t*y[i]; + } + + *b /= st2; + *a = (sy-sx*(*b))/ss; + + prodsum = 0.0; + sqerrx = 0.0; + sqerry = 0.0; + + /* Compute numerator of Pearson's R */ + for (i = 0; i < nitems; i++) { + errx = x[i] - meanx; + erry = y[i] - meany; + prodsum += errx * erry; + sqerrx += errx*errx; + sqerry += erry*erry; + } + + *r = prodsum / (sqrt(sqerrx)*sqrt(sqerry)); +} diff --git a/src/tools/perftool/new.cpel b/src/tools/perftool/new.cpel new file mode 100644 index 00000000..b0f35958 Binary files /dev/null and b/src/tools/perftool/new.cpel differ diff --git a/src/tools/perftool/new.elog b/src/tools/perftool/new.elog new file mode 100644 index 00000000..2d99bb16 Binary files /dev/null and b/src/tools/perftool/new.elog differ diff --git a/src/tools/perftool/props.c b/src/tools/perftool/props.c new file mode 100644 index 00000000..84af5b1c --- /dev/null +++ b/src/tools/perftool/props.c @@ -0,0 +1,280 @@ +/* + *------------------------------------------------------------------ + * Copyright (c) 2006-2016 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include +#include +#include +#include + +static char *sxerox (char *s); + +#define NBUCKETS 97 + +typedef struct prop_ { + struct prop_ *next; + char *name; + char *value; +} prop_t; + +static prop_t *buckets [NBUCKETS]; +static int hash_shifts[4] = {24, 16, 8, 0}; + +/* + * getprop + */ + +char *getprop (char *name) +{ + unsigned char *cp; + unsigned long hash=0; + prop_t *bp; + int i=0; + + for (cp = (unsigned char *) name; *cp; cp++) + hash ^= (*cp)<<(hash_shifts[(i++)&0x3]); + + bp = buckets [hash%NBUCKETS]; + + while (bp && strcmp(bp->name, name)) { + bp = bp->next; + } + + if (bp == NULL) + return (0); + else + return (bp->value); +} + +/* + * getprop_default + */ + +char *getprop_default (char *name, char *def) +{ + char *rv; + rv = getprop (name); + if (rv) + return (rv); + else + return (def); +} + +/* + * addprop + */ + +void addprop (char *name, char *value) +{ + unsigned char *cp; + unsigned long hash=0; + prop_t **bpp; + prop_t *bp; + int i=0; + + bp = (prop_t *)malloc (sizeof (prop_t)); + + bp->next = 0; + bp->name = sxerox (name); + bp->value = sxerox (value); + + for (cp = (unsigned char *)name; *cp; cp++) + hash ^= (*cp)<<(hash_shifts[(i++)&0x3]); + + bpp = &buckets [hash%NBUCKETS]; + + if (*bpp == NULL) + *bpp = bp; + else { + bp->next = *bpp; + *bpp = bp; + } +} + +/* + * sxerox + */ + +static char *sxerox (char *s) +{ + char *rv = (char *) malloc (strlen (s) + 1); + strcpy (rv, s); + return rv; +} + +/* + * readprops + */ + +#define START 0 +#define READNAME 1 +#define READVALUE 2 +#define C_COMMENT 3 +#define CPP_COMMENT 4 + +int readprops (char *filename) +{ + FILE *ifp; + unsigned char c; + int state=START; + int linenum=1; + char namebuf [128]; + char valbuf [512]; + int i; + + ifp = fopen (filename, "r"); + + if (ifp == NULL) + return (-1); + + while (1) { + + readchar: + c = getc (ifp); + + again: + switch (state) { + case START: + if (feof (ifp)) { + fclose (ifp); + return (0); + } + + if (c == ' ' || c == '\t') + goto readchar; + + if (c == '\n') { + linenum++; + goto readchar; + } + if (isalpha (c) || (c == '_')) { + state = READNAME; + goto again; + } + if (c == '/') { + c = getc (ifp); + if (c == '/') { + state = CPP_COMMENT; + goto readchar; + } else if (c == '*') { + state = C_COMMENT; + goto readchar; + } else { + fprintf (stderr, "unknown token '/' line %d\n", + linenum); + exit(1); + } + } + fprintf (stderr, "unknown token '%c' line %d\n", + c, linenum); + exit (1); + break; + + case CPP_COMMENT: + while (1) { + c = getc (ifp); + if (feof (ifp)) + return (0); + if (c == '\n') { + linenum++; + state = START; + goto readchar; + } + } + break; + + case C_COMMENT: + while (1) { + c = getc (ifp); + if (feof (ifp)) { + fprintf (stderr, "unterminated comment, line %d\n", + linenum); + exit (1); + } + if (c == '*') { + staragain: + c = getc (ifp); + if (c == '/') { + state = START; + goto readchar; + } + if (c == '*') + goto staragain; + } + } + break; + + case READNAME: + i = 0; + namebuf[i++] = c; + while (1) { + c = getc (ifp); + if (feof (ifp)) { + fprintf (stderr, "EOF while reading a name, line %d\n", + linenum); + exit (1); + } + if ((!isalnum (c)) && (c != '_')) { + namebuf [i] = 0; + state = READVALUE; + goto again; + } + namebuf [i++] = c; + } + break; + + case READVALUE: + i = 0; + while ((c == ' ') || (c == '\t') || (c == '=')) { + c = getc (ifp); + if (feof (ifp)) { + fprintf (stderr, "EOF while reading a value, line %d\n", + linenum); + exit (1); + } + } + goto firsttime; + while (1) { + c = getc (ifp); + + firsttime: + if (c == '\\') { + c = getc (ifp); + if (feof (ifp)) { + fprintf (stderr, "EOF after '\\', line %d\n", + linenum); + exit (1); + } + valbuf[i++] = c; + continue; + } + if (c == '\n') { + linenum++; + while (valbuf [i-1] == ' ' || valbuf[i-1] == '\t') + i--; + valbuf[i] = 0; + addprop (namebuf, valbuf); + state = START; + goto readchar; + } + valbuf[i++] = c; + } + + } + } +} diff --git a/src/tools/vppapigen/configure.ac b/src/tools/vppapigen/configure.ac new file mode 100644 index 00000000..16ad59d2 --- /dev/null +++ b/src/tools/vppapigen/configure.ac @@ -0,0 +1,14 @@ +# -*- Autoconf -*- +# Copyright (c) 2008 by cisco Systems, Inc. +# All rights reserved. +# Process this file with autoconf to produce a configure script. + +AC_INIT(vppapigen, 1.0) +AM_INIT_AUTOMAKE +AM_SILENT_RULES([yes]) + +# Checks for programs. +AC_PROG_CC +AC_PROG_YACC + +AC_OUTPUT([Makefile]) diff --git a/src/tools/vppapigen/gram.y b/src/tools/vppapigen/gram.y new file mode 100644 index 00000000..de26af8d --- /dev/null +++ b/src/tools/vppapigen/gram.y @@ -0,0 +1,90 @@ +%{ +/* + * gram.y - message definition language + * + * Copyright (c) 2009 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +extern void yyerror (char *s); +extern int yylex (void); + +#define YYSTYPE void * + +void generate (YYSTYPE); + YYSTYPE add_slist(YYSTYPE, YYSTYPE); + YYSTYPE add_define(YYSTYPE, YYSTYPE); + YYSTYPE suppress_version(void); + YYSTYPE add_defbody(YYSTYPE, YYSTYPE); + YYSTYPE add_primtype(YYSTYPE, YYSTYPE, YYSTYPE); + YYSTYPE add_complex(YYSTYPE, YYSTYPE); + YYSTYPE add_union(YYSTYPE, YYSTYPE); + YYSTYPE add_scalar_vbl(YYSTYPE); + YYSTYPE add_vector_vbl(YYSTYPE, YYSTYPE); + YYSTYPE add_variable_length_vector_vbl(YYSTYPE, YYSTYPE); + YYSTYPE set_flags(YYSTYPE, YYSTYPE); +%} + +%token NAME RPAR LPAR SEMI LBRACK RBRACK NUMBER PRIMTYPE BARF +%token TPACKED DEFINE LCURLY RCURLY STRING UNION +%token HELPER_STRING COMMA +%token NOVERSION MANUAL_PRINT MANUAL_ENDIAN TYPEONLY DONT_TRACE + +%% + +pgm: slist {generate ($1);} + ; + +slist: slist stmt {$$ = add_slist ($1, $2);} + | stmt {$$ = $1;} + ; + +stmt: flist defn {$$ = set_flags($1, $2);} + | defn {$$ = $1;} + ; + +flist: flist flag {$$ = (YYSTYPE)(unsigned long long) + ((unsigned long long) $1 + | (unsigned long long) $2);} + | flag {$$ = $1;} + ; + +flag: + MANUAL_PRINT {$$ = $1;} + | MANUAL_ENDIAN {$$ = $1;} + | DONT_TRACE {$$ = $1;} + | TYPEONLY {$$ = $1;} + ; + +defn: DEFINE NAME LCURLY defbody RCURLY SEMI + {$$ = add_define($2, $4);} + + | NOVERSION SEMI + {$$ = suppress_version();} + ; + +defbody: defbody onedef {$$ = add_defbody($1, $2);} + | onedef {$$ = $1;} + ; + +onedef: PRIMTYPE vbl SEMI {$$ = add_primtype($1, $2, 0);} + | TPACKED PRIMTYPE vbl SEMI {$$ = add_primtype($1, $2, $3);} + | NAME vbl SEMI {$$ = add_complex($1, $2);} + | UNION NAME LCURLY defbody RCURLY SEMI + {$$ = add_union($2, $4);} + ; + +vbl: NAME {$$ = add_scalar_vbl($1);} + | NAME LBRACK NUMBER RBRACK {$$ = add_vector_vbl($1, $3);} + | NAME LBRACK NAME RBRACK {$$ = add_variable_length_vector_vbl($1, $3);} + ; diff --git a/src/tools/vppapigen/lex.c b/src/tools/vppapigen/lex.c new file mode 100644 index 00000000..733942ad --- /dev/null +++ b/src/tools/vppapigen/lex.c @@ -0,0 +1,1067 @@ +/* + *------------------------------------------------------------------ + * lex.c - API generator lexical analyzer + * + * Copyright (c) 1996-2009 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------ + */ + +#include +#include +#include +#include +#include +#include + +#include "lex.h" +#include "node.h" +#include "tools/vppapigen/gram.h" + +FILE *ifp, *ofp, *pythonfp, *jsonfp; +char *vlib_app_name = "vpp"; +int dump_tree; +time_t starttime; +char *input_filename; +char *current_filename; +int current_filename_allocated; +unsigned long input_crc; +unsigned long message_crc; +int yydebug; + +/* + * lexer variable definitions + */ + +static const char *version = "0.1"; +static int the_lexer_linenumber = 1; +static enum lex_state the_lexer_state = START_STATE; + +/* + * private prototypes + */ +static void usage (char *); +static int name_check (const char *, YYSTYPE *); +static int name_compare (const char *, const char *); +extern int yydebug; +extern YYSTYPE yylval; + +unsigned int crc32c_table[256] = { + 0x00000000, 0xF26B8303, 0xE13B70F7, 0x1350F3F4, + 0xC79A971F, 0x35F1141C, 0x26A1E7E8, 0xD4CA64EB, + 0x8AD958CF, 0x78B2DBCC, 0x6BE22838, 0x9989AB3B, + 0x4D43CFD0, 0xBF284CD3, 0xAC78BF27, 0x5E133C24, + 0x105EC76F, 0xE235446C, 0xF165B798, 0x030E349B, + 0xD7C45070, 0x25AFD373, 0x36FF2087, 0xC494A384, + 0x9A879FA0, 0x68EC1CA3, 0x7BBCEF57, 0x89D76C54, + 0x5D1D08BF, 0xAF768BBC, 0xBC267848, 0x4E4DFB4B, + 0x20BD8EDE, 0xD2D60DDD, 0xC186FE29, 0x33ED7D2A, + 0xE72719C1, 0x154C9AC2, 0x061C6936, 0xF477EA35, + 0xAA64D611, 0x580F5512, 0x4B5FA6E6, 0xB93425E5, + 0x6DFE410E, 0x9F95C20D, 0x8CC531F9, 0x7EAEB2FA, + 0x30E349B1, 0xC288CAB2, 0xD1D83946, 0x23B3BA45, + 0xF779DEAE, 0x05125DAD, 0x1642AE59, 0xE4292D5A, + 0xBA3A117E, 0x4851927D, 0x5B016189, 0xA96AE28A, + 0x7DA08661, 0x8FCB0562, 0x9C9BF696, 0x6EF07595, + 0x417B1DBC, 0xB3109EBF, 0xA0406D4B, 0x522BEE48, + 0x86E18AA3, 0x748A09A0, 0x67DAFA54, 0x95B17957, + 0xCBA24573, 0x39C9C670, 0x2A993584, 0xD8F2B687, + 0x0C38D26C, 0xFE53516F, 0xED03A29B, 0x1F682198, + 0x5125DAD3, 0xA34E59D0, 0xB01EAA24, 0x42752927, + 0x96BF4DCC, 0x64D4CECF, 0x77843D3B, 0x85EFBE38, + 0xDBFC821C, 0x2997011F, 0x3AC7F2EB, 0xC8AC71E8, + 0x1C661503, 0xEE0D9600, 0xFD5D65F4, 0x0F36E6F7, + 0x61C69362, 0x93AD1061, 0x80FDE395, 0x72966096, + 0xA65C047D, 0x5437877E, 0x4767748A, 0xB50CF789, + 0xEB1FCBAD, 0x197448AE, 0x0A24BB5A, 0xF84F3859, + 0x2C855CB2, 0xDEEEDFB1, 0xCDBE2C45, 0x3FD5AF46, + 0x7198540D, 0x83F3D70E, 0x90A324FA, 0x62C8A7F9, + 0xB602C312, 0x44694011, 0x5739B3E5, 0xA55230E6, + 0xFB410CC2, 0x092A8FC1, 0x1A7A7C35, 0xE811FF36, + 0x3CDB9BDD, 0xCEB018DE, 0xDDE0EB2A, 0x2F8B6829, + 0x82F63B78, 0x709DB87B, 0x63CD4B8F, 0x91A6C88C, + 0x456CAC67, 0xB7072F64, 0xA457DC90, 0x563C5F93, + 0x082F63B7, 0xFA44E0B4, 0xE9141340, 0x1B7F9043, + 0xCFB5F4A8, 0x3DDE77AB, 0x2E8E845F, 0xDCE5075C, + 0x92A8FC17, 0x60C37F14, 0x73938CE0, 0x81F80FE3, + 0x55326B08, 0xA759E80B, 0xB4091BFF, 0x466298FC, + 0x1871A4D8, 0xEA1A27DB, 0xF94AD42F, 0x0B21572C, + 0xDFEB33C7, 0x2D80B0C4, 0x3ED04330, 0xCCBBC033, + 0xA24BB5A6, 0x502036A5, 0x4370C551, 0xB11B4652, + 0x65D122B9, 0x97BAA1BA, 0x84EA524E, 0x7681D14D, + 0x2892ED69, 0xDAF96E6A, 0xC9A99D9E, 0x3BC21E9D, + 0xEF087A76, 0x1D63F975, 0x0E330A81, 0xFC588982, + 0xB21572C9, 0x407EF1CA, 0x532E023E, 0xA145813D, + 0x758FE5D6, 0x87E466D5, 0x94B49521, 0x66DF1622, + 0x38CC2A06, 0xCAA7A905, 0xD9F75AF1, 0x2B9CD9F2, + 0xFF56BD19, 0x0D3D3E1A, 0x1E6DCDEE, 0xEC064EED, + 0xC38D26C4, 0x31E6A5C7, 0x22B65633, 0xD0DDD530, + 0x0417B1DB, 0xF67C32D8, 0xE52CC12C, 0x1747422F, + 0x49547E0B, 0xBB3FFD08, 0xA86F0EFC, 0x5A048DFF, + 0x8ECEE914, 0x7CA56A17, 0x6FF599E3, 0x9D9E1AE0, + 0xD3D3E1AB, 0x21B862A8, 0x32E8915C, 0xC083125F, + 0x144976B4, 0xE622F5B7, 0xF5720643, 0x07198540, + 0x590AB964, 0xAB613A67, 0xB831C993, 0x4A5A4A90, + 0x9E902E7B, 0x6CFBAD78, 0x7FAB5E8C, 0x8DC0DD8F, + 0xE330A81A, 0x115B2B19, 0x020BD8ED, 0xF0605BEE, + 0x24AA3F05, 0xD6C1BC06, 0xC5914FF2, 0x37FACCF1, + 0x69E9F0D5, 0x9B8273D6, 0x88D28022, 0x7AB90321, + 0xAE7367CA, 0x5C18E4C9, 0x4F48173D, 0xBD23943E, + 0xF36E6F75, 0x0105EC76, 0x12551F82, 0xE03E9C81, + 0x34F4F86A, 0xC69F7B69, 0xD5CF889D, 0x27A40B9E, + 0x79B737BA, 0x8BDCB4B9, 0x988C474D, 0x6AE7C44E, + 0xBE2DA0A5, 0x4C4623A6, 0x5F16D052, 0xAD7D5351 +}; + +static inline unsigned long CRC8 (unsigned long crc, + unsigned char d) +{ + return ((crc >> 8) ^ crc32c_table[(crc ^ d) & 0xFF]); +} +static inline unsigned long CRC16 (unsigned long crc, + unsigned short d) +{ + crc = CRC8 (crc, d & 0xff); + d = d >> 8; + crc = CRC8 (crc, d & 0xff); + return crc; +} + + +static unsigned long +crc_eliding_c_comments (const char *buf, unsigned long crc) +{ + const char *p; + enum { cOTHER, /* */ + cSTRING, /* "... */ + cSBACKSLASH, /* "...\ */ + cCHAR, /* '... */ + cCBACKSLASH, /* '...\ */ + cSLASH, /* / */ + cSLASH_SLASH, /* //... */ + cSLASH_STAR, /* / *... */ + cSTAR /* / *...* */ + } ss = cOTHER; + + for (p = buf; ;) { + unsigned char c = *p++; + + switch (c) { + case 0: + switch (ss) { + case cOTHER: + return (crc); + case cSTRING: case cSBACKSLASH: + case cCHAR: case cCBACKSLASH: + case cSLASH: case cSLASH_SLASH: case cSLASH_STAR: case cSTAR: + fprintf (stderr, "Inopportune EOF: %s\n", buf); + exit (1); + } + break; + case '\"': + switch (ss) { + case cOTHER: ss = cSTRING; break; /* start string */ + case cSTRING: ss = cOTHER; break; /* end string */ + case cSBACKSLASH: ss = cSTRING; break; + case cCHAR: break; + case cCBACKSLASH: ss = cCHAR; break; + case cSLASH: crc = CRC8 (crc, '/'); ss = cOTHER; break; + case cSLASH_SLASH: continue; /* in comment */ + case cSLASH_STAR: continue; /* in comment */ + case cSTAR: ss = cSLASH_STAR; continue; /* in comment */ + } + break; + case '\\': + switch (ss) { + case cOTHER: break; + case cSTRING: ss = cSBACKSLASH; break; + case cSBACKSLASH: ss = cSTRING; break; + case cCHAR: ss = cCBACKSLASH; break; + case cCBACKSLASH: ss = cCHAR; break; + case cSLASH: crc = CRC8 (crc, '/'); ; ss = cOTHER; break; + case cSLASH_SLASH: continue; /* in comment */ + case cSLASH_STAR: continue; /* in comment */ + case cSTAR: ss = cSLASH_STAR; continue; /* in comment */ + } + break; + case '/': + switch (ss) { + case cOTHER: ss = cSLASH; continue; /* potential comment */ + case cSTRING: break; + case cSBACKSLASH: ss = cSTRING; break; + case cCHAR: break; + case cCBACKSLASH: ss = cCHAR; break; + case cSLASH: ss = cSLASH_SLASH; continue; /* start comment */ + case cSLASH_SLASH: continue; /* in comment */ + case cSLASH_STAR: continue; /* in comment */ + case cSTAR: ss = cOTHER; continue; /* end of comment */ + } + break; + case '*': + switch (ss) { + case cOTHER: break; + case cSTRING: break; + case cSBACKSLASH: ss = cSTRING; break; + case cCHAR: break; + case cCBACKSLASH: ss = cCHAR; break; + case cSLASH: ss = cSLASH_STAR; continue; /* start comment */ + case cSLASH_SLASH: continue; /* in comment */ + case cSLASH_STAR: ss = cSTAR; continue; /* potential end */ + case cSTAR: continue; /* still potential end of comment */ + } + break; + case '\n': case '\r': case ' ': case '\t': case '\014': + switch (ss) { + case cOTHER: continue; /* ignore all whitespace */ + case cSTRING: break; + case cSBACKSLASH: ss = cSTRING; break; + case cCHAR: break; + case cCBACKSLASH: ss = cCHAR; break; + case cSLASH: c = '/'; ss = cOTHER; break; + case cSLASH_SLASH: + if (c == '\n' || c == '\r') ss = cOTHER; /* end comment */ + continue; + case cSLASH_STAR: continue; /* in comment */ + case cSTAR: ss = cSLASH_STAR; continue; /* in comment */ + } + default: + switch (ss) { + case cOTHER: break; + case cSTRING: break; + case cSBACKSLASH: ss = cSTRING; break; + case cCHAR: break; + case cCBACKSLASH: ss = cCHAR; break; + case cSLASH: crc = CRC8 (crc, '/'); ss = cOTHER; break; + case cSLASH_SLASH: continue; /* in comment */ + case cSLASH_STAR: continue; /* in comment */ + case cSTAR: ss = cSLASH_STAR; continue; /* in comment */ + } + } + crc = CRC8 (crc, c); + } +} + +/* + * main + */ +int main (int argc, char **argv) +{ + int curarg = 1; + char *ofile=0; + char *pythonfile=0; + char *jsonfile=0; + char *show_name=0; + + while (curarg < argc) { + if (!strncmp (argv [curarg], "--verbose", 3)) { + fprintf (stderr, "%s version %s\n", argv [0], version); + curarg++; + continue; + } + + if (!strncmp (argv [curarg], "--yydebug", 3)) { + yydebug = 1; + curarg++; + continue; + } + + if (!strncmp (argv [curarg], "--dump", 3)) { + dump_tree = 1; + curarg++; + continue; + } + + if (!strncmp (argv[curarg], "--show-name", 3)) { + curarg++; + if (curarg < argc) { + show_name = argv[curarg]; + curarg++; + continue; + } else { + fprintf(stderr, "Missing filename after --show-name \n"); + exit(1); + } + } + + if (!strncmp (argv [curarg], "--input", 3)) { + curarg++; + if (curarg < argc) { + input_filename = argv[curarg]; + if (!strcmp (argv [curarg], "-")) + ifp = stdin; + else + ifp = fopen (argv [curarg], "r"); + if (ifp == NULL) { + fprintf (stderr, "Couldn't open input file %s\n", + argv[curarg]); + exit (1); + } + curarg++; + } else { + fprintf(stderr, "Missing filename after --input\n"); + exit(1); + } + continue; + } + if (!strncmp (argv [curarg], "--output", 3)) { + curarg++; + if (curarg < argc) { + ofp = fopen (argv[curarg], "w"); + if (ofp == NULL) { + fprintf (stderr, "Couldn't open output file %s\n", + argv[curarg]); + exit (1); + } + ofile = argv[curarg]; + curarg++; + } else { + fprintf(stderr, "Missing filename after --output\n"); + exit(1); + } + continue; + } + if (!strncmp (argv [curarg], "--python", 8)) { + curarg++; + if (curarg < argc) { + if (!strcmp(argv[curarg], "-")) { + pythonfp = stdout; + } else { + pythonfp = fopen(argv[curarg], "w"); + pythonfile = argv[curarg]; + } + if (pythonfp == NULL) { + fprintf (stderr, "Couldn't open python output file %s\n", + argv[curarg]); + exit (1); + } + curarg++; + } else { + fprintf(stderr, "Missing filename after --python\n"); + exit(1); + } + continue; + } + if (!strncmp (argv [curarg], "--json", 6)) { + curarg++; + if (curarg < argc) { + if (!strcmp(argv[curarg], "-")) { + jsonfp = stdout; + } else { + jsonfp = fopen(argv[curarg], "w"); + jsonfile = argv[curarg]; + } + if (jsonfp == NULL) { + fprintf (stderr, "Couldn't open JSON output file %s\n", + argv[curarg]); + exit (1); + } + curarg++; + } else { + fprintf(stderr, "Missing filename after --json\n"); + exit(1); + } + continue; + } + if (!strncmp (argv [curarg], "--app", 4)) { + curarg++; + if (curarg < argc) { + vlib_app_name = argv[curarg]; + curarg++; + } else { + fprintf(stderr, "Missing app name after --app\n"); + exit(1); + } + continue; + } + + usage(argv[0]); + exit (1); + } + if (ofp == NULL) { + ofile = 0; + } + if (pythonfp == NULL) { + pythonfile = 0; + } + if (jsonfp == NULL) { + jsonfile = 0; + } + if (ifp == NULL) { + fprintf(stderr, "No input file specified...\n"); + exit(1); + } + if (show_name) { + input_filename = show_name; + } + + starttime = time (0); + + if (yyparse() == 0) { + fclose (ifp); + curarg -= 2; + if (ofile) { + printf ("Output written to %s\n", ofile); + fclose (ofp); + } + if (pythonfile) { + printf ("Python bindings written to %s\n", pythonfile); + fclose (pythonfp); + } + if (jsonfile) { + printf ("JSON bindings written to %s\n", jsonfile); + fclose (jsonfp); + } + } + else { + fclose (ifp); + if (ofp) + fclose (ofp); + if (ofile) { + printf ("Removing %s\n", ofile); + unlink (ofile); + } + if (pythonfile) { + printf ("Removing %s\n", pythonfile); + unlink (pythonfile); + } + if (jsonfile) { + printf ("Removing %s\n", jsonfile); + unlink (jsonfile); + } + exit (1); + } + exit (0); +} + +/* + * usage + */ +static void usage (char *progname) +{ + fprintf (stderr, + "usage: %s --input [--output ] " + "[--json ] [--python ]\n%s", + progname, + " [--yydebug] [--dump-tree]\n"); + exit (1); +} + +/* + * yyerror + */ +void yyerror (char *s) +{ + fprintf (stderr, "%s:%d %s\n", current_filename, the_lexer_linenumber, s); +} + +static char namebuf [MAXNAME]; + +static inline char +getc_char (FILE *ifp) +{ + return ((char)(getc(ifp) & 0x7f)); +} + +/* + * yylex (well, yylex_1: The real yylex below does crc-hackery) + */ +static int yylex_1 (void) +{ + int nameidx=0; + char c; + enum { LP_INITIAL_WHITESPACE, LP_LINE_NUMBER, + LP_PRE_FILENAME_WHITESPACE, LP_FILENAME, + LP_POST_FILENAME, + LP_OTHER + } lp_substate = LP_INITIAL_WHITESPACE; + + again: + switch (the_lexer_state) { + /* + * START state -- looking for something interesting + */ + case START_STATE: + c = getc_char (ifp); + if (feof (ifp)) + return (EOF); + + switch (c) { + case '\n': + the_lexer_linenumber++; + goto again; + + case '#': + the_lexer_state = LINE_PRAGMA_STATE; + lp_substate = LP_INITIAL_WHITESPACE; + goto again; + + /* FALLTHROUGH */ + case '\t': + case ' ': + goto again; + + case '(': + return (LPAR); + + case ')': + return (RPAR); + + case ';': + return (SEMI); + + case '[': + return (LBRACK); + + case ']': + return (RBRACK); + + case '{': + return (LCURLY); + + case '}': + return (RCURLY); + + case ',': + return (COMMA); + + case '"': + nameidx = 0; + the_lexer_state = STRING_STATE; + goto again; + + case '@': + nameidx = 0; + the_lexer_state = HELPER_STATE; + goto again; + + case '/': + c = getc_char (ifp); + if (feof (ifp)) + return (EOF); + + if (c == '/') { + the_lexer_state = CPP_COMMENT_STATE; + goto again; + } else if (c == '*') { + the_lexer_state = C_COMMENT_STATE; + goto again; + } else { + fprintf (stderr, "unknown token /%c at line %d\n", + c, the_lexer_linenumber); + return (BARF); + } + + case '\\': + c = getc_char (ifp); + if (feof (ifp)) + return (EOF); + + /* Note fallthrough... */ + + default: + if (isalpha (c) || c == '_') { + namebuf [0] = c; + nameidx = 1; + the_lexer_state = NAME_STATE; + goto again; + } else if (isdigit(c)) { + namebuf [0] = c; + nameidx = 1; + the_lexer_state = NUMBER_STATE; + goto again; + } + + fprintf (stderr, "unknown token %c at line %d\n", + c, the_lexer_linenumber); + return (BARF); + } + + /* + * NAME state -- eat the rest of a name + */ + case NAME_STATE: + c = getc_char (ifp); + if (feof (ifp)) + return (EOF); + + if (!isalnum (c) && c != '_') { + ungetc (c, ifp); + namebuf [nameidx] = 0; + the_lexer_state = START_STATE; + return (name_check (namebuf, &yylval)); + } + if (nameidx >= (MAXNAME-1)) { + fprintf(stderr, "lex input buffer overflow...\n"); + exit(1); + } + namebuf [nameidx++] = c; + goto again; + + /* + * NUMBER state -- eat the rest of a number + */ + case NUMBER_STATE: + c = getc_char (ifp); + if (feof (ifp)) + return (EOF); + + if (!isdigit (c)) { + ungetc (c, ifp); + namebuf [nameidx] = 0; + the_lexer_state = START_STATE; + yylval = (void *) atol(namebuf); + return (NUMBER); + } + if (nameidx >= (MAXNAME-1)) { + fprintf(stderr, "lex input buffer overflow...\n"); + exit(1); + } + namebuf [nameidx++] = c; + goto again; + + /* + * C_COMMENT state -- eat a peach + */ + case C_COMMENT_STATE: + c = getc_char (ifp); + if (feof (ifp)) + return (EOF); + if (c == '*') { + c = getc_char (ifp); + if (feof (ifp)) + return (EOF); + if (c == '/') { + the_lexer_state = START_STATE; + goto again; + } + } + if (c == '\n') + the_lexer_linenumber++; + goto again; + + /* + * CPP_COMMENT state -- eat a plum + */ + + case CPP_COMMENT_STATE: + c = getc_char (ifp); + if (feof (ifp)) + return (EOF); + if (c == '\n') { + the_lexer_linenumber++; + the_lexer_state = START_STATE; + goto again; + } + goto again; + + case STRING_STATE: + c = getc_char (ifp); + if (feof (ifp)) + return (EOF); + switch (c) { + case '\\': + c = getc_char (ifp); + if (feof (ifp)) + return (EOF); + namebuf[nameidx++] = c; + goto again; + + case '"': + namebuf[nameidx] = 0; + yylval = (YYSTYPE) sxerox (namebuf); + the_lexer_state = START_STATE; + return (STRING); + + default: + if (c == '\n') + the_lexer_linenumber++; + + if (nameidx >= (MAXNAME-1)) { + fprintf(stderr, "lex input buffer overflow...\n"); + exit(1); + } + namebuf[nameidx++] = c; + goto again; + } + break; + + case HELPER_STATE: + c = getc_char (ifp); + if (feof (ifp)) + return (EOF); + switch (c) { + case '\\': + c = getc_char (ifp); + if (feof (ifp)) + return (EOF); + namebuf[nameidx] = c; + goto again; + + case '@': + namebuf[nameidx] = 0; + yylval = (YYSTYPE) sxerox (namebuf); + the_lexer_state = START_STATE; + return (HELPER_STRING); + + default: + if (c == '\n') + the_lexer_linenumber++; + + /* + * CPP makes it approximately impossible to + * type "#define FOO 123", so we provide a + * lexical trick to achieve that result + */ + + if (c == '$') + c = '#'; + + if (nameidx >= (MAXNAME-1)) { + fprintf(stderr, "lex input buffer overflow...\n"); + exit(1); + } + namebuf[nameidx++] = c; + goto again; + } + break; + + case LINE_PRAGMA_STATE: + /* We're only interested in lines of the form # 259 "foo.c" 17 */ + + switch (lp_substate) { + + case LP_INITIAL_WHITESPACE: /* no number seen yet */ + c = getc_char(ifp); + if (feof(ifp)) + return(EOF); + if (c >= '0' && c <= '9') { + namebuf[nameidx++] = c; + lp_substate = LP_LINE_NUMBER; + } else if (c == '\n') { + goto lp_end_of_line; + } else if (c != ' ' && c != '\t') { + /* Nothing */ + } else { + lp_substate = LP_OTHER; + } + goto again; + + case LP_LINE_NUMBER: /* eating linenumber */ + c = getc_char(ifp); + if (feof(ifp)) + return(EOF); + if (c >= '0' && c <= '9') { + namebuf[nameidx++] = c; + } else if (c == ' ' || c == '\t') { + namebuf[nameidx++] = 0; + the_lexer_linenumber = atol(namebuf); + lp_substate = LP_PRE_FILENAME_WHITESPACE; + } else if (c == '\n') { + goto lp_end_of_line; + } else { + lp_substate = LP_OTHER; + } + goto again; + + case LP_PRE_FILENAME_WHITESPACE: /* awaiting filename */ + c = getc_char(ifp); + if (feof(ifp)) + return(EOF); + + if (c == '"') { + lp_substate = LP_FILENAME; + nameidx = 0; + } else if (c == ' ' || c == '\t') { + /* nothing */ + } else if (c == '\n') { + goto lp_end_of_line; + } else { + lp_substate = LP_OTHER; + } + goto again; + + case LP_FILENAME: /* eating filename */ + c = getc_char(ifp); + if (feof(ifp)) + return(EOF); + + if (c == '"') { + lp_substate = LP_POST_FILENAME; + namebuf[nameidx] = 0; + } else if (c == '\n') { + goto lp_end_of_line; /* syntax error... */ + } else { + namebuf[nameidx++] = c; + } + goto again; + + case LP_POST_FILENAME: /* ignoring rest of line */ + case LP_OTHER: + c = getc_char(ifp); + if (feof(ifp)) + return(EOF); + + if (c == '\n') { + if (lp_substate == LP_POST_FILENAME) { + if (current_filename_allocated) { + current_filename_allocated = 0; + free(current_filename); + } + + if (!strcmp(namebuf, "")) { + current_filename = input_filename; + } else { + current_filename = sxerox(namebuf); + current_filename_allocated = 1; + } + } + lp_end_of_line: + the_lexer_state = START_STATE; + nameidx = 0; + } + goto again; + } + break; + } + fprintf (stderr, "LEXER BUG!\n"); + exit (1); + /* NOTREACHED */ + return (0); +} + +/* + * Parse a token and side-effect input_crc + * in a whitespace- and comment-insensitive fashion. + */ +int yylex (void) +{ + /* + * Accumulate a crc32-based signature while processing the + * input file. The goal is to come up with a magic number + * which changes precisely when the original input file changes + * but which ignores whitespace changes. + */ + unsigned long crc = input_crc; + int node_type = yylex_1 (); + unsigned long crc2 = message_crc; + int use_helper_string = 0; + unsigned short code; + + switch (node_type) { + case PRIMTYPE: + case NAME: + case NUMBER: + case STRING: + case HELPER_STRING: + use_helper_string = 1; + break; + + /* Other node types have no "substate" */ + /* This code is written in this curious fashion because we + * want the generated CRC to be independent of the particular + * values a particular version of lex/bison assigned to various states. + */ + + case RPAR: code = 258; break; + case LPAR: code = 259; break; + case SEMI: code = 260; break; + case LBRACK: code = 261; break; + case RBRACK: code = 262; break; + case BARF: code = 265; break; + case TPACKED: code = 266; break; + case DEFINE: code = 267; break; + case LCURLY: code = 268; break; + case RCURLY: code = 269; break; + case UNION: code = 271; break; + case COMMA: code = 273; break; + case NOVERSION: code = 274; break; + case MANUAL_PRINT: code = 275; break; + case MANUAL_ENDIAN: code = 276; break; + case TYPEONLY: code = 278; break; + case DONT_TRACE: code = 279; break; + + case EOF: code = ~0; break; /* hysterical compatibility */ + + default: + fprintf(stderr, "yylex: node_type %d missing state CRC cookie\n", + node_type); + exit(1); + } + + if (use_helper_string) + { + /* We know these types accumulated token text into namebuf */ + /* HELPER_STRING may still contain C comments. Argh. */ + crc = crc_eliding_c_comments (namebuf, crc); + crc2 = crc_eliding_c_comments (namebuf, crc2); + } else + { + crc = CRC16 (crc, code); + crc2 = CRC16 (crc2, code); + } + + input_crc = crc; + message_crc = crc2; + return (node_type); +} + +/* + * name_check -- see if the name we just ate + * matches a known keyword. If so, set yylval + * to a new instance of , and return PARSER_MACRO + * + * Otherwise, set yylval to sxerox (s) and return NAME + */ + +static struct keytab { + char *name; + enum node_subclass subclass_id; +} keytab [] = +/* Keep the table sorted, binary search used below! */ +{ + {"define", NODE_DEFINE}, + {"dont_trace", NODE_DONT_TRACE}, + {"f64", NODE_F64}, + {"i16", NODE_I16}, + {"i32", NODE_I32}, + {"i64", NODE_I64}, + {"i8", NODE_I8}, + {"manual_endian", NODE_MANUAL_ENDIAN}, + {"manual_print", NODE_MANUAL_PRINT}, + {"noversion", NODE_NOVERSION}, + {"packed", NODE_PACKED}, + {"typeonly", NODE_TYPEONLY}, + {"u16", NODE_U16}, + {"u32", NODE_U32}, + {"u64", NODE_U64}, + {"u8", NODE_U8}, + {"union", NODE_UNION}, + {"uword", NODE_UWORD}, +}; + +static int name_check (const char *s, YYSTYPE *token_value) +{ + enum node_subclass subclass_id; + int top, bot, mid; + int result; + + for (top = 0, bot = (sizeof(keytab) / sizeof(struct keytab))-1; + bot >= top; ) { + mid = (top + bot) / 2; + result = name_compare (s, keytab[mid].name); + if (result < 0) + bot = mid - 1; + else if (result > 0) + top = mid + 1; + else { + subclass_id = keytab[mid].subclass_id; + + switch (subclass_id) { + case NODE_U8: + case NODE_U16: + case NODE_U32: + case NODE_U64: + case NODE_I8: + case NODE_I16: + case NODE_I32: + case NODE_I64: + case NODE_F64: + case NODE_UWORD: + *token_value = make_node(subclass_id); + return (PRIMTYPE); + + case NODE_PACKED: + *token_value = make_node(subclass_id); + return (TPACKED); + + case NODE_DEFINE: + message_crc = 0; + *token_value = make_node(subclass_id); + return(DEFINE); + + case NODE_MANUAL_PRINT: + *token_value = (YYSTYPE) NODE_FLAG_MANUAL_PRINT; + return (MANUAL_PRINT); + + case NODE_MANUAL_ENDIAN: + *token_value = (YYSTYPE) NODE_FLAG_MANUAL_ENDIAN; + return (MANUAL_ENDIAN); + + case NODE_TYPEONLY: + *token_value = (YYSTYPE) NODE_FLAG_TYPEONLY; + return(TYPEONLY); + + case NODE_DONT_TRACE: + *token_value = (YYSTYPE) NODE_FLAG_DONT_TRACE; + return(DONT_TRACE); + + case NODE_NOVERSION: + return(NOVERSION); + + case NODE_UNION: + return(UNION); + + default: + fprintf (stderr, "fatal: keytab botch!\n"); + exit (1); + } + } + } + *token_value = (YYSTYPE) sxerox (s); + return (NAME); +} + +/* + * sxerox + */ + +char *sxerox (const char *s) +{ + int len = strlen (s); + char *rv; + + rv = (char *) malloc (len+1); + if (rv == 0) { + fprintf(stderr, "Out of memory..."); + exit (1); + } + + strcpy (rv, s); + return (rv); +} + +/* + * name_compare + */ + +int name_compare (const char *s1, const char *s2) +{ + char c1, c2; + + while (*s1 && *s2) { + c1 = *s1++; + c2 = *s2++; + + c1 = tolower (c1); + c2 = tolower (c2); + if (c1 < c2) + return (-1); + else if (c1 > c2) + return (1); + } + if (*s1 < *s2) + return (-1); + else if (*s1 > *s2) + return (1); + return (0); +} diff --git a/src/tools/vppapigen/lex.h b/src/tools/vppapigen/lex.h new file mode 100644 index 00000000..a0fdc735 --- /dev/null +++ b/src/tools/vppapigen/lex.h @@ -0,0 +1,50 @@ +/* + *------------------------------------------------------------------ + * lex.h - definitions for the api generator's lexical + * analyzer. + * + * Copyright (c) 1996-2009 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------ + */ + +#ifndef _LEX_H_ +#define _LEX_H_ 1 + +extern int yylex (void); +extern void yyerror (char *); +extern int yyparse (void); + +#ifndef YYSTYPE +#define YYSTYPE void * +#endif + +#include "tools/vppapigen/gram.h" + +enum lex_state { + START_STATE = 1, + NAME_STATE, + NUMBER_STATE, + C_COMMENT_STATE, + CPP_COMMENT_STATE, + STRING_STATE, + HELPER_STATE, + LINE_PRAGMA_STATE, +}; + +#define MAXNAME 64000 + +extern unsigned long input_crc; +extern unsigned long message_crc; + +#endif /* _LEX_H_ */ diff --git a/src/tools/vppapigen/node.c b/src/tools/vppapigen/node.c new file mode 100644 index 00000000..260c6f2e --- /dev/null +++ b/src/tools/vppapigen/node.c @@ -0,0 +1,1527 @@ +/* + *------------------------------------------------------------------ + * node.c - the api generator's semantic back-end + * + * Copyright (c) 2004-2009 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------ + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "lex.h" +#include "node.h" + +#define YYSTYPE void * + +FILE *ofp; +FILE *pythonfp; +FILE *jsonfp; +time_t starttime; +char *vlib_app_name; +char *input_filename; +node_vft_t *the_vft[NODE_N_TYPES]; +static int indent; +static int dont_output_version; +int dump_tree; +static char *fixed_name; +static char tmpbuf [MAXNAME]; +static char *current_def_name; +static char *current_union_name; +static char *current_type_fmt; +static char *current_type_cast; +static char current_id; +static char current_is_complex; +static char *current_endianfun; +static char *current_type_name; + +void indent_me(FILE *ofp) +{ + int i; + + for (i = 0; i < indent; i++) + putc(' ', ofp); +} + +char *uppercase (char *s) +{ + char *cp; + + cp = tmpbuf; + + while (*s && (cp < tmpbuf + (sizeof(tmpbuf)-1))) { + if (*s >= 'a' && *s <= 'z') + *cp++ = *s++ - ('a' - 'A'); + else + *cp++ = *s++; + } + *cp = 0; + return(tmpbuf); +} + +char *lowercase (char *s) +{ + char *cp; + + cp = tmpbuf; + + while (*s && (cp < tmpbuf + (sizeof(tmpbuf)-1))) { + if (*s >= 'A' && *s <= 'Z') + *cp++ = *s++ + ('a' - 'A'); + else + *cp++ = *s++; + } + *cp = 0; + return(tmpbuf); +} + +void primtype_recursive_print(node_t *this, i8 *fmt) +{ + fputs((char *)fmt, stdout); + + if (this->deeper) { + node_vft_t *vftp = the_vft[this->deeper->type]; + vftp->print(this->deeper); + } +} + +void primtype_recursive_generate(node_t *this, enum passid which, FILE *ofp, + i8 *type_name, i8 *type_fmt, i8 *type_cast) +{ + node_vft_t *vftp; + + current_type_name = (char *)type_name; + current_type_cast = (char *)type_cast; + + switch(which) { + case TYPEDEF_PASS: + fputs((char *)type_name, ofp); + fputs(" ", ofp); + break; + + case PRINTFUN_PASS: + current_type_fmt = (char *)type_fmt; + break; + + case ENDIANFUN_PASS: + vftp = the_vft[this->type]; + current_endianfun = vftp->endian_converter; + break; + + case PYTHON_PASS: + fputs("('", pythonfp); + fputs((char *)type_name, pythonfp); + fputs("', ", pythonfp); + break; + + case JSON_PASS: + fputs("[\"", jsonfp); + fputs((char *)type_name, jsonfp); + fputs("\", ", jsonfp); + break; + + default: + fprintf(stderr, "primtype_recursive_generate: unimp pass %d\n", which); + break; + } + + if (this->deeper) { + vftp = the_vft[this->deeper->type]; + vftp->generate(this->deeper, which, ofp); + } +} + +void node_illegal_print (node_t *this) +{ + fprintf(stderr, "node_illegal_print called\n"); + exit(0); +} + +void node_illegal_generate (node_t *this, enum passid notused, FILE *ofp) +{ + fprintf(stderr, "node_illegal_generate called\n"); + exit(0); +} + +node_vft_t node_illegal_vft = { + node_illegal_print, + node_illegal_generate, + "illegal" +}; + +void node_u8_print (node_t *this) +{ + primtype_recursive_print(this, "u8 "); +} + +void node_u8_generate (node_t *this, enum passid which, FILE *ofp) +{ + primtype_recursive_generate(this, which, ofp, "u8", "%u", "(unsigned)"); +} + +node_vft_t node_u8_vft = { + node_u8_print, + node_u8_generate, + NULL +}; + +void node_u16_print (node_t *this) +{ + primtype_recursive_print(this, "u16 "); +} + +void node_u16_generate (node_t *this, enum passid which, FILE *ofp) +{ + primtype_recursive_generate(this, which, ofp, "u16", "%u", "(unsigned)"); +} + +node_vft_t node_u16_vft = { + node_u16_print, + node_u16_generate, + "clib_net_to_host_u16" +}; + +void node_u32_print (node_t *this) +{ + primtype_recursive_print(this, "u32 "); +} + +void node_u32_generate (node_t *this, enum passid which, FILE *ofp) +{ + primtype_recursive_generate(this, which, ofp, "u32", "%u", "(unsigned)"); +} + +node_vft_t node_u32_vft = { + node_u32_print, + node_u32_generate, + "clib_net_to_host_u32", +}; + +void node_u64_print (node_t *this) +{ + primtype_recursive_print(this, "u64 "); +} + +void node_u64_generate (node_t *this, enum passid which, FILE *ofp) +{ + primtype_recursive_generate(this, which, ofp, "u64", "%llu", + "(long long)"); +} + +node_vft_t node_u64_vft = { + node_u64_print, + node_u64_generate, + "clib_net_to_host_u64" +}; + +void node_i8_print (node_t *this) +{ + primtype_recursive_print(this, "i8 "); +} + +void node_i8_generate (node_t *this, enum passid which, FILE *ofp) +{ + primtype_recursive_generate(this, which, ofp, "i8", "%d", "(int)"); +} + +node_vft_t node_i8_vft = { + node_i8_print, + node_i8_generate, + "" +}; + +void node_i16_print (node_t *this) +{ + primtype_recursive_print(this, "i16 "); +} + +void node_i16_generate (node_t *this, enum passid which, FILE *ofp) +{ + primtype_recursive_generate(this, which, ofp, "i16", "%d", "(int)"); +} + +node_vft_t node_i16_vft = { + node_i16_print, + node_i16_generate, + "clib_net_to_host_u16" +}; + +void node_i32_print (node_t *this) +{ + primtype_recursive_print(this, "i32 "); +} + +void node_i32_generate (node_t *this, enum passid which, FILE *ofp) +{ + primtype_recursive_generate(this, which, ofp, "i32", "%ld", "(long)"); +} + +node_vft_t node_i32_vft = { + node_i32_print, + node_i32_generate, + "clib_net_to_host_u32" +}; + +void node_i64_print (node_t *this) +{ + primtype_recursive_print(this, "i64 "); +} + +void node_i64_generate (node_t *this, enum passid which, FILE *ofp) +{ + primtype_recursive_generate(this, which, ofp, "i64", "%lld", + "(long long)"); +} + +node_vft_t node_i64_vft = { + node_i64_print, + node_i64_generate, + "clib_net_to_host_u64" +}; + +void node_f64_print (node_t *this) +{ + primtype_recursive_print(this, "f64 "); +} + +void node_f64_generate (node_t *this, enum passid which, FILE *ofp) +{ + primtype_recursive_generate(this, which, ofp, "f64", "%.2f", + "(double)"); +} + +node_vft_t node_f64_vft = { + node_f64_print, + node_f64_generate, + " ", /* FP numbers are sent in host byte order */ +}; + + +void node_packed_print (node_t *this) +{ + primtype_recursive_print (this, "packed "); +} + +void node_packed_generate (node_t *this, enum passid which, FILE *ofp) +{ + primtype_recursive_generate(this, which, ofp, "PACKED", "", ""); +} + +node_vft_t node_packed_vft = { + node_packed_print, + node_packed_generate, + 0, +}; + +void node_define_print (node_t *this) +{ + fprintf(stdout, "define %s {\n", CDATA0); + if (this->deeper) { + node_vft_t *vftp = the_vft[this->deeper->type]; + fprintf(stdout, " "); + vftp->print(this->deeper); + } + fprintf(stdout, "};\n"); +} + +void node_define_generate (node_t *this, enum passid which, FILE *fp) +{ + node_t *child; + + switch(which) { + case TYPEDEF_PASS: + fprintf(fp, "typedef VL_API_PACKED(struct _vl_api_%s {\n", CDATA0); + child = this->deeper; + indent += 4; + while (child) { + node_vft_t *vftp = the_vft[child->type]; + indent_me(fp); + vftp->generate(child, which, fp); + child = child->peer; + } + indent -= 4; + fprintf(fp, "}) vl_api_%s_t;\n\n", CDATA0); + break; + + case ENDIANFUN_PASS: + case PRINTFUN_PASS: + child = this->deeper; + while (child) { + node_vft_t *vftp = the_vft[child->type]; + vftp->generate(child, which, fp); + child = child->peer; + } + break; + + case PYTHON_PASS: + fprintf(fp, "('%s',\n", CDATA0); + child = this->deeper; + indent += 4; + while (child) { + node_vft_t *vftp = the_vft[child->type]; + indent_me(fp); + vftp->generate(child, which, fp); + child = child->peer; + } + indent -= 4; + fprintf(fp, "),\n\n"); + break; + + case JSON_PASS: + fprintf(fp, "[\"%s\",\n", CDATA0); + child = this->deeper; + indent += 4; + while (child) { + node_vft_t *vftp = the_vft[child->type]; + indent_me(fp); + vftp->generate(child, which, fp); + child = child->peer; + fprintf(fp, ",\n"); + } + indent_me(fp); + fprintf (fp, "{\"crc\" : \"0x%08x\"}\n", (u32)(u64)CDATA3); + indent -= 4; + indent_me(fp); + fprintf(fp, "]"); + break; + + default: + fprintf(stderr, "node_define_generate: unimp pass %d\n", which); + break; + } +} + +node_vft_t node_define_vft = { + node_define_print, + node_define_generate, + 0, +}; + +void node_union_print (node_t *this) +{ + primtype_recursive_print (this, "union "); +} + +void node_union_generate (node_t *this, enum passid which, FILE *fp) +{ + node_t *child; + node_t *uelem; + int case_id=1; + + switch(which) { + case TYPEDEF_PASS: + fprintf(fp, "u8 _%s_which;\n", CDATA0); + indent_me(fp); + fprintf(fp, "union _%s {\n", CDATA0); + child = this->deeper; + indent += 4; + + while (child) { + node_vft_t *vftp = the_vft[child->type]; + indent_me(fp); + vftp->generate(child, which, fp); + child = child->peer; + } + indent -= 4; + indent_me(fp); + fprintf(fp, "} %s;\n", CDATA0); + break; + + case PRINTFUN_PASS: + case ENDIANFUN_PASS: + uelem = this->deeper; + + indent_me(fp); + fprintf(fp, "switch(a->_%s_which) {\n", + CDATA0); + indent += 4; + current_union_name = CDATA0; + + /* Walk the list of objects in this union */ + while (uelem) { + node_vft_t *vftp = the_vft[uelem->type]; + indent -= 4; + indent_me(fp); + fprintf(fp, "case %d:\n", case_id); + case_id++; + indent += 4; + /* Drill down on each element */ + vftp->generate(uelem, which, fp); + indent_me(fp); + fprintf(fp, "break;\n"); + uelem = uelem->peer; + } + current_union_name = 0; + indent -= 4; + indent_me(fp); + fprintf(fp, "default:\n"); + indent += 4; + indent_me(fp); + if (which == PRINTFUN_PASS) { + fprintf(fp, + "vl_print(handle, \"WARNING: _%s_which not set.\\n\");\n", + CDATA0); + } + indent_me(fp); + fprintf(fp, "break;\n"); + indent -= 4; + indent_me(fp); + fprintf(fp, "}\n"); + break; + + default: + fprintf(stderr, "node_union_generate: unimp pass %d\n", which); + break; + } +} + + +node_vft_t node_union_vft = { + node_union_print, + node_union_generate, + 0, +}; + +void node_scalar_print (node_t *this) +{ + fprintf(stdout, "%s", CDATA0); + primtype_recursive_print (this, ""); +} + +void node_scalar_generate (node_t *this, enum passid which, FILE *fp) +{ + char *union_prefix = ""; + + if (current_union_name) { + sprintf(tmpbuf, "%s.", current_union_name); + union_prefix = tmpbuf; + } + + switch(which) { + case TYPEDEF_PASS: + fprintf(fp, "%s;\n", CDATA0); + break; + + case PRINTFUN_PASS: + indent_me(fp); + if (current_is_complex) { + fprintf(fp, "vl_api_%s_t_print(a->%s%s, handle);\n", + current_type_name, union_prefix, CDATA0); + } else { + if (!strcmp(current_type_fmt, "uword")) { + fprintf(fp, + "vl_print(handle, \"%s%s: \" _uword_fmt \"\\n\", %s a->%s%s);\n", + union_prefix, CDATA0, "(_uword_cast)", + union_prefix, CDATA0); + } else { + fprintf(fp, + "vl_print(handle, \"%s%s: %s\\n\", %s a->%s%s);\n", + union_prefix, CDATA0, + current_type_fmt, current_type_cast, + union_prefix, CDATA0); + } + } + break; + + case ENDIANFUN_PASS: + indent_me(fp); + if (current_is_complex) { + fprintf(fp, "vl_api%s_t_endian(a->%s%s);\n", + current_type_name, union_prefix, CDATA0); + } else { + /* Current_endianfun == NULL means e.g. it's a u8... */ + if (current_endianfun) { + fprintf(fp, "a->%s%s = %s(a->%s%s);\n", union_prefix, + CDATA0, current_endianfun, + union_prefix, CDATA0); + } else { + fprintf(fp, "/* a->%s%s = a->%s%s (no-op) */\n", + union_prefix, CDATA0, + union_prefix, CDATA0); + } + } + break; + case PYTHON_PASS: + fprintf(fp, "'%s'),\n", CDATA0); + break; + + case JSON_PASS: + fprintf(fp, "\"%s\"]", CDATA0); + break; + + default: + fprintf(stderr, "node_scalar_generate: unimp pass %d\n", which); + } + if (this->deeper) { + fprintf(stderr, "broken recursion in node_scalar_generate\n"); + } +} + + +node_vft_t node_scalar_vft = { + node_scalar_print, + node_scalar_generate, + 0, +}; + +void node_vector_print (node_t *this) +{ + primtype_recursive_print (this, "vector "); +} + +void node_vector_generate (node_t *this, enum passid which, FILE *fp) +{ + char *union_prefix = ""; + + if (current_union_name) { + sprintf(tmpbuf, "%s.", current_union_name); + union_prefix = tmpbuf; + } + + switch(which) { + case TYPEDEF_PASS: + fprintf(fp, "%s[%d];\n", CDATA0, IDATA1); + break; + + case PRINTFUN_PASS: + /* Don't bother about "u8 data [0];" et al. */ + if (IDATA1 == 0) + break; + + indent_me(fp); + fprintf(fp, "{\n"); + indent += 4; + indent_me(fp); + fprintf(fp, "int _i;\n"); + indent_me(fp); + fprintf(fp, "for (_i = 0; _i < %d; _i++) {\n", + IDATA1); + indent += 4; + indent_me(fp); + if (current_is_complex) { + fprintf(fp, "vl_print(handle, \"%s%s[%%d]: ", + union_prefix, CDATA0); + fprintf(fp, + "vl_print_%s (handle, a->%s%s[_i]);\n", + CDATA0, union_prefix, CDATA0); + } else { + fprintf(fp, + "vl_print(handle, \"%s%s[%%d]: %s\\n\", _i, a->%s%s[_i]);\n", + union_prefix, CDATA0, + current_type_fmt, + union_prefix, CDATA0); + } + indent -= 4; + indent_me(fp); + fprintf(fp, "}\n"); + indent -= 4; + indent_me(fp); + fprintf(fp, "}\n"); + break; + + case ENDIANFUN_PASS: + /* Don't bother about "u8 data [0];" et al. */ + if (IDATA1 == 0) + break; + /* If this is a simple endian swap, but the endian swap method is a no-op, + * then indicate this is a no-op in a comment. + */ + if (!current_is_complex && current_endianfun == NULL) { + indent_me(fp); + fprintf(fp, "/* a->%s%s[0..%d] = a->%s%s[0..%d] (no-op) */\n", + union_prefix, CDATA0, IDATA1 - 1, + union_prefix, CDATA0, IDATA1 - 1); + break; + } + + indent_me(fp); + fprintf(fp, "{\n"); + indent += 4; + indent_me(fp); + fprintf(fp, "int _i;\n"); + indent_me(fp); + fprintf(fp, "for (_i = 0; _i < %d; _i++) {\n", + IDATA1); + indent += 4; + indent_me(fp); + if (current_is_complex) { + fprintf(fp, + "vl_api_%s_t_endian (a->%s%s[_i]);\n", + current_type_name, union_prefix, CDATA0); + } else { + fprintf(fp, + "a->%s%s[_i] = %s(a->%s%s[_i]);\n", + union_prefix, CDATA0, + current_endianfun, + union_prefix, CDATA0); + } + indent -= 4; + indent_me(fp); + fprintf(fp, "}\n"); + indent -= 4; + indent_me(fp); + fprintf(fp, "}\n"); + break; + case PYTHON_PASS: + if (CDATA2 != 0) { // variable length vector + fprintf(fp, "'%s', '%d', '%s'),\n", CDATA0, IDATA1, CDATA2); + } else { + fprintf(fp, "'%s', '%d'),\n", CDATA0, IDATA1); + } + break; + + case JSON_PASS: + if (CDATA2 != 0) { /* variable length vector */ + fprintf(fp, "\"%s\", %d, \"%s\"]", CDATA0, IDATA1, CDATA2); + } else { + fprintf(fp, "\"%s\", %d]", CDATA0, IDATA1); + } + break; + + default: + fprintf(stderr, "node_vector_generate: unimp pass %d\n", which); + } + if (this->deeper) { + fprintf(stderr, "broken recursion in node_vector_generate\n"); + } +} + +node_vft_t node_vector_vft = { + node_vector_print, + node_vector_generate, + 0, +}; + +void node_complex_print (node_t *this) +{ + primtype_recursive_print (this, "complex "); +} + +void node_complex_generate (node_t *this, enum passid which, FILE *fp) +{ + node_t *deeper; + node_vft_t *vftp; + char *member_name = "broken!"; + char *union_prefix = ""; + + if (current_union_name) { + sprintf(tmpbuf, "%s.", current_union_name); + union_prefix = tmpbuf; + } + + current_is_complex++; + + switch(which) { + case TYPEDEF_PASS: + fprintf(fp, "%s ", CDATA0); + deeper = this->deeper; + if (deeper) { + vftp = the_vft[deeper->type]; + vftp->generate(deeper, which, fp); + } + break; + + case PRINTFUN_PASS: + deeper = this->deeper; + while (deeper) { + if (deeper->type == NODE_SCALAR || + deeper->type == NODE_VECTOR) { + member_name = deeper->data[0]; + break; + } + deeper = deeper->deeper; + } + indent_me(fp); + fprintf(fp, "vl_print(handle, \"%s%s ----- \\n\");\n", + union_prefix, member_name); + indent_me(fp); + fprintf(fp, "%s_print(&a->%s%s, handle);\n", + CDATA0, union_prefix, member_name); + indent_me(fp); + fprintf(fp, "vl_print(handle, \"%s%s ----- END \\n\");\n", + union_prefix, member_name); + break; + + case ENDIANFUN_PASS: + deeper = this->deeper; + while (deeper) { + if (deeper->type == NODE_SCALAR || + deeper->type == NODE_VECTOR) { + member_name = deeper->data[0]; + break; + } + deeper = deeper->deeper; + } + + indent_me(fp); + fprintf(fp, "%s_endian(&a->%s%s);\n", + CDATA0, union_prefix, member_name); + break; + case PYTHON_PASS: + fprintf(fp, "('%s',", CDATA0); + deeper = this->deeper; + if (deeper) { + vftp = the_vft[deeper->type]; + vftp->generate(deeper, which, fp); + } + break; + + case JSON_PASS: + fprintf(fp, "[\"%s\", ", CDATA0); + deeper = this->deeper; + if (deeper) { + vftp = the_vft[deeper->type]; + vftp->generate(deeper, which, fp); + } + break; + + default: + fprintf(stderr, "node_complex_generate unimp pass %d...\n", which); + break; + } + current_is_complex--; +} + +node_vft_t node_complex_vft = { + node_complex_print, + node_complex_generate, + 0, +}; + +void node_noversion_print (node_t *this) +{ + primtype_recursive_print (this, "noversion "); +} + +void node_noversion_generate (node_t *this, enum passid which, FILE *ofp) +{ + fprintf(stderr, "node_noversion_generate called...\n"); +} + +node_vft_t node_noversion_vft = { + node_noversion_print, + node_noversion_generate, + 0, +}; + +void node_uword_print (node_t *this) +{ + primtype_recursive_print(this, "uword "); +} + +void node_uword_generate (node_t *this, enum passid which, FILE *ofp) +{ + primtype_recursive_generate(this, which, ofp, "uword", "uword", ""); +} + +node_vft_t node_uword_vft = { + node_uword_print, + node_uword_generate, + "clib_net_to_host_uword", +}; + +node_vft_t *the_vft[NODE_N_TYPES] = { + &node_illegal_vft, + &node_u8_vft, + &node_u16_vft, + &node_u32_vft, + &node_u64_vft, + &node_i8_vft, + &node_i16_vft, + &node_i32_vft, + &node_i64_vft, + &node_f64_vft, + &node_packed_vft, + &node_define_vft, + &node_union_vft, + &node_scalar_vft, + &node_vector_vft, + &node_complex_vft, + &node_noversion_vft, + &node_uword_vft, +}; + +void *make_node (enum node_subclass type) +{ + node_t *rv; + + rv = (node_t *) malloc (sizeof (*rv)); + if (rv == 0) { + fprintf (stderr, "fatal: make_node out of memory\n"); + exit (1); + } + bzero (rv, sizeof (*rv)); + rv->type = type; + return ((void *) rv); +} + +YYSTYPE deeper (YYSTYPE arg1, YYSTYPE arg2) +{ + node_t *np1 = (node_t *) arg1; + node_t *np2 = (node_t *) arg2; + node_t *hook_point; + + hook_point = np1; + + while (hook_point->deeper) + hook_point = hook_point->deeper; + + hook_point->deeper = np2; + return (arg1); +} + +YYSTYPE addpeer (YYSTYPE arg1, YYSTYPE arg2) +{ + node_t *np1 = (node_t *) arg1; + node_t *np2 = (node_t *) arg2; + node_t *hook_point; + + hook_point = np1; + + while (hook_point->peer) + hook_point = hook_point->peer; + + hook_point->peer = np2; + return (arg1); +} + +/* + * add_slist (stmt_list, stmt) + */ + +YYSTYPE add_slist (YYSTYPE a1, YYSTYPE a2) +{ + if (a1 && a2) + return (addpeer(a1, a2)); + else if(a1) + return(a1); + else + return(a2); +} + +/* + * add_define (char *name, defn_list); + */ +YYSTYPE add_define (YYSTYPE a1, YYSTYPE a2) +{ + node_t *np; + + np = make_node(NODE_DEFINE); + np->data[0] = a1; + np->data[3] = (void *) message_crc; + deeper((YYSTYPE)np, a2); + return ((YYSTYPE) np); +} + +/* + * add_defbody (defn_list, new_defn) + */ +YYSTYPE add_defbody (YYSTYPE a1, YYSTYPE a2) +{ + return (addpeer(a1, a2)); +} + +/* + * add_primtype ([packed], primitive type, instance) + */ + +YYSTYPE add_primtype (YYSTYPE a1, YYSTYPE a2, YYSTYPE a3) +{ + /* Hook instance to type node */ + deeper (a1, a2); + if (a3) { + deeper(a1, a3); + } + return (a1); +} + +/* + * add_complex(char *type_name, instance) + */ + +YYSTYPE add_complex (YYSTYPE a1, YYSTYPE a2) +{ + node_t *np; + + np = make_node(NODE_COMPLEX); + np->data[0] = (void *) a1; + + deeper((YYSTYPE)np, a2); + return ((YYSTYPE) np); +} + +/* + * add_union(char *type_name, definition) + */ + +YYSTYPE add_union (YYSTYPE a1, YYSTYPE a2) +{ + node_t *np; + + np = make_node(NODE_UNION); + np->data[0] = (void *) a1; + + deeper((YYSTYPE)np, a2); + return ((YYSTYPE) np); +} + + +/* + * add_vector_vbl (node_t *variable, YYSTYPE size) + */ + +YYSTYPE add_vector_vbl (YYSTYPE a1, YYSTYPE a2) +{ + node_t *np; + + np = make_node(NODE_VECTOR); + np->data[0] = (void *) a1; + np->data[1] = (void *) a2; + return ((YYSTYPE) np); +} + +/* + * add_vector_vbl (char *vector_name, char *vector_length_var) + */ + +YYSTYPE add_variable_length_vector_vbl (YYSTYPE vector_name, YYSTYPE vector_length_var) +{ + node_t *np; + + np = make_node(NODE_VECTOR); + np->data[0] = (void *) vector_name; + np->data[1] = (void *) 0; // vector size used for vpe.api.h generation (array of length zero) + np->data[2] = (void *) vector_length_var; // name of the variable that stores vector length + return ((YYSTYPE) np); +} + +/* + * add_scalar_vbl (char *name) + */ +YYSTYPE add_scalar_vbl (YYSTYPE a1) +{ + node_t *np; + + np = make_node(NODE_SCALAR); + np->data[0] = (void *) a1; + return ((YYSTYPE) np); +} + +/* + * set_flags (int flags, msg(=0?)) + */ +YYSTYPE set_flags(YYSTYPE a1, YYSTYPE a2) +{ + node_t *np; + int flags; + + np = (node_t *)a2; + if (!np) + return(0); + + flags = (int)(uword) a1; + + np->flags |= flags; + return (a2); +} +/* + * suppress_version + */ +YYSTYPE suppress_version (void) +{ + dont_output_version = 1; + return (0); +} + +void dump(node_t *np) +{ + node_vft_t *vftp; + + while (np) { + vftp = the_vft[np->type]; + vftp->print(np); + np = np->peer; + } +} + +char *fixup_input_filename(void) +{ + char *cp; + + cp = (char *)input_filename; + + while (*cp) + cp++; + + cp--; + + while (cp > input_filename && *cp != '/') + cp--; + if (*cp == '/') + cp++; + + strncpy (tmpbuf, cp, sizeof(tmpbuf)-1); + + cp = tmpbuf; + + while (*cp) + cp++; + + cp--; + + while (cp > tmpbuf && *cp != '.') + cp--; + + if (*cp == '.') + *cp = 0; + + return (sxerox(tmpbuf)); +} + +void generate_top_boilerplate(FILE *fp) + +{ + char *datestring = ctime(&starttime); + fixed_name = fixup_input_filename(); + + datestring[24] = 0; + + fprintf (fp, "/*\n"); + fprintf (fp, " * VLIB API definitions %s\n", datestring); + fprintf (fp, " * Input file: %s\n", input_filename); + fprintf (fp, " * Automatically generated: please edit the input file "); + fprintf (fp, "NOT this file!\n"); + fprintf (fp, " */\n\n"); + fprintf (fp, "#if defined(vl_msg_id)||defined(vl_union_id)||"); + fprintf (fp, "defined(vl_printfun) \\\n ||defined(vl_endianfun)||"); + fprintf (fp, " defined(vl_api_version)||defined(vl_typedefs) \\\n"); + fprintf (fp, " ||defined(vl_msg_name)||defined(vl_msg_name_crc_list)\n"); + fprintf (fp, "/* ok, something was selected */\n"); + fprintf (fp, "#else\n"); + fprintf (fp, "#warning no content included from %s\n", input_filename); + fprintf (fp, "#endif\n\n"); + fprintf (fp, "#define VL_API_PACKED(x) x __attribute__ ((packed))\n\n"); +} + +void generate_bottom_boilerplate(FILE *fp) + +{ + fprintf (fp, "\n#ifdef vl_api_version\n"); + + if (dont_output_version) { + fprintf (fp, "/* WARNING: API FILE VERSION CHECK DISABLED */\n"); + input_crc = 0; + } + + fprintf (fp, "vl_api_version(%s, 0x%08x)\n\n", + fixed_name, (unsigned int)input_crc); + fprintf (fp, "#endif\n\n"); +} + +void generate_msg_ids(YYSTYPE a1, FILE *fp) +{ + node_t *np = (node_t *)a1; + + fprintf (fp, "\n/****** Message ID / handler enum ******/\n\n"); + fprintf (fp, "#ifdef vl_msg_id\n"); + + while (np) { + if (np->type == NODE_DEFINE) { + if (!(np->flags & NODE_FLAG_TYPEONLY)) { + fprintf (fp, "vl_msg_id(VL_API_%s, vl_api_%s_t_handler)\n", + uppercase(np->data[0]), (i8 *)np->data[0]); + } else { + fprintf (fp, "/* typeonly: %s */\n", (i8 *)np->data[0]); + } + } + np = np->peer; + } + fprintf (fp, "#endif\n"); + +} + +void generate_msg_names(YYSTYPE a1, FILE *fp) +{ + node_t *np = (node_t *)a1; + + fprintf (fp, "\n/****** Message names ******/\n\n"); + + fprintf (fp, "#ifdef vl_msg_name\n"); + + while (np) { + if (np->type == NODE_DEFINE) { + if (!(np->flags & NODE_FLAG_TYPEONLY)) { + fprintf (fp, "vl_msg_name(vl_api_%s_t, %d)\n", + (i8 *) np->data[0], + (np->flags & NODE_FLAG_DONT_TRACE ? 0 : 1)); + } else { + fprintf (fp, "/* typeonly: %s */\n", (i8 *)np->data[0]); + } + } + np = np->peer; + } + fprintf (fp, "#endif\n\n"); +} + +void generate_msg_name_crc_list (YYSTYPE a1, FILE *fp) +{ + node_t *np = (node_t *)a1; + char *unique_suffix, *cp; + + unique_suffix = sxerox(fixed_name); + + cp = unique_suffix; + while (*cp && (*cp != '.')) + cp++; + if (*cp == '.') + *cp = 0; + + fprintf (fp, "\n/****** Message name, crc list ******/\n\n"); + + fprintf (fp, "#ifdef vl_msg_name_crc_list\n"); + fprintf (fp, "#define foreach_vl_msg_name_crc_%s ", unique_suffix); + + while (np) { + if (np->type == NODE_DEFINE) { + if (!(np->flags & NODE_FLAG_TYPEONLY)) { + fprintf (fp, "\\\n_(VL_API_%s, %s, %08x) ", + uppercase (np->data[0]), (i8 *) np->data[0], + (u32)(u64)np->data[3]); + } + } + np = np->peer; + } + fprintf (fp, "\n#endif\n\n"); + free (unique_suffix); +} + +void generate_typedefs(YYSTYPE a1, FILE *fp) +{ + node_t *np = (node_t *)a1; + node_vft_t *vftp; + + fprintf(fp, "\n/****** Typedefs *****/\n\n"); + fprintf(fp, "#ifdef vl_typedefs\n\n"); + + /* Walk the top-level node-list */ + while (np) { + if (np->type == NODE_DEFINE) { + /* Yeah, this is pedantic */ + vftp = the_vft[np->type]; + vftp->generate(np, TYPEDEF_PASS, fp); + } + np = np->peer; + } + fprintf(fp, "#endif /* vl_typedefs */\n\n"); +} + +void union_walk_one_defn(node_t *np, FILE *fp) +{ + node_t *vblp; + node_t *uelem; + + /* Walk the list of typed objects in this msg def */ + while (np) { + if (np->type == NODE_UNION) { + current_union_name = np->data[0]; + uelem = np->deeper; + + /* Walk the list of objects in this union */ + while (uelem) { + vblp = uelem->deeper; + /* Drill down on each element, find the variable name */ + while(vblp) { + if (vblp->type == NODE_SCALAR || + vblp->type == NODE_VECTOR || + vblp->type == NODE_COMPLEX) { + fprintf(ofp, "#define %s_", + uppercase(current_def_name)); + fprintf(ofp, "%s_", uppercase(current_union_name)); + fprintf(ofp, "%s %d\n",uppercase(vblp->data[0]), + current_id); + current_id++; + break; + } + vblp = vblp->deeper; + } + uelem = uelem->peer; + } + current_union_name = 0; + current_id = 1; + } + np = np->peer; + } +} + +void generate_uniondefs(YYSTYPE a1, FILE *fp) +{ + node_t *np = (node_t *)a1; + + fprintf(fp, "/****** Discriminated Union Definitions *****/\n\n"); + fprintf(fp, "#ifdef vl_union_id\n\n"); + + /* Walk the top-level node-list */ + while (np) { + if (np->type == NODE_DEFINE) { + current_id = 1; + current_def_name = np->data[0]; + union_walk_one_defn(np->deeper, fp); + } + np = np->peer; + } + fprintf(fp, "\n#endif /* vl_union_id */\n\n"); +} + +void generate_printfun(YYSTYPE a1, FILE *fp) +{ + node_t *np = (node_t *)a1; + node_vft_t *vftp; + + fprintf(fp, "/****** Print functions *****/\n\n"); + fprintf(fp, "#ifdef vl_printfun\n\n"); + + fprintf(fp, "#ifdef LP64\n"); + fputs ("#define _uword_fmt \"%lld\"\n", fp); + fputs ("#define _uword_cast (long long)\n", fp); + fprintf(fp, "#else\n"); + fputs("#define _uword_fmt \"%ld\"\n", fp); + fputs ("#define _uword_cast long\n", fp); + fprintf(fp, "#endif\n\n"); + + /* Walk the top-level node-list */ + while (np) { + if (np->type == NODE_DEFINE) { + if (!(np->flags & NODE_FLAG_MANUAL_PRINT)) { + fprintf(fp, + "static inline void *vl_api_%s_t_print (vl_api_%s_t *a,", + (i8 *)np->data[0], (i8 *) np->data[0]); + fprintf(fp, "void *handle)\n{\n"); + /* output the message name */ + fprintf(fp, + " vl_print(handle, \"vl_api_%s_t:\\n\");\n", + (i8 *)np->data[0]); + + indent += 4; + /* Yeah, this is pedantic */ + vftp = the_vft[np->type]; + vftp->generate(np, PRINTFUN_PASS, fp); + fprintf(fp, " return handle;\n"); + fprintf(fp, "}\n\n"); + indent -= 4; + } else { + fprintf(fp, "/***** manual: vl_api_%s_t_print *****/\n\n", + (i8 *) np->data[0]); + } + } + np = np->peer; + } + fprintf(fp, "#endif /* vl_printfun */\n\n"); +} + +void generate_endianfun(YYSTYPE a1, FILE *fp) +{ + node_t *np = (node_t *)a1; + node_vft_t *vftp; + + fprintf(fp, "\n/****** Endian swap functions *****/\n\n"); + fprintf(fp, "#ifdef vl_endianfun\n\n"); + fprintf(fp, "#undef clib_net_to_host_uword\n"); + fprintf(fp, "#ifdef LP64\n"); + fprintf(fp, "#define clib_net_to_host_uword clib_net_to_host_u64\n"); + fprintf(fp, "#else\n"); + fprintf(fp, "#define clib_net_to_host_uword clib_net_to_host_u32\n"); + fprintf(fp, "#endif\n\n"); + + /* Walk the top-level node-list */ + while (np) { + if (np->type == NODE_DEFINE) { + if (!(np->flags & NODE_FLAG_MANUAL_ENDIAN)) { + fprintf(fp, + "static inline void vl_api_%s_t_endian (vl_api_%s_t *a)\n{\n", + (i8 *) np->data[0], (i8 *) np->data[0]); + indent += 4; + /* Yeah, this is pedantic */ + vftp = the_vft[np->type]; + vftp->generate(np, ENDIANFUN_PASS, fp); + fprintf(fp, "}\n\n"); + indent -= 4; + } else { + fprintf(fp, "/***** manual: vl_api_%s_t_endian *****/\n\n", + (i8 *) np->data[0]); + } + } + np = np->peer; + } + fprintf(fp, "#endif /* vl_endianfun */\n\n"); +} + +void add_msg_ids(YYSTYPE a1) +{ + node_t *np = (node_t *)a1; + node_t *new_u16; + node_t *new_vbl; + + /* Walk the top-level node-list */ + while (np) { + if (np->type == NODE_DEFINE) { + if (!(np->flags & NODE_FLAG_TYPEONLY)) { + /* add the parse tree for "u16 _vl_msg_id" */ + new_u16 = make_node(NODE_U16); + new_u16->peer = np->deeper; + np->deeper = new_u16; + new_vbl = make_node(NODE_SCALAR); + new_vbl->data[0] = sxerox("_vl_msg_id"); + new_u16->deeper = new_vbl; + } + } + np = np->peer; + } +} + +void generate_python_msg_definitions(YYSTYPE a1, FILE *fp) +{ + node_t *np = (node_t *)a1; + node_vft_t *vftp; + fprintf (fp, "messages = [\n"); + /* Walk the top-level node-list */ + while (np) { + if (np->type == NODE_DEFINE && !(np->flags & NODE_FLAG_TYPEONLY)) { + /* Yeah, this is pedantic */ + vftp = the_vft[np->type]; + vftp->generate(np, PYTHON_PASS, fp); + } + np = np->peer; + } + fprintf (fp, "\n]\n"); +} + +static bool +is_typeonly_check(node_t *np, bool typeonly) +{ + bool is_typeonly = (np->flags & NODE_FLAG_TYPEONLY); + return (is_typeonly == typeonly); +} + +static void +generate_json_definitions(YYSTYPE a1, FILE *fp, bool typeonly) +{ + node_t *np = (node_t *)a1; + node_vft_t *vftp; + indent_me(fp); + if (typeonly) + fprintf (fp, "\"types\" : [\n"); + else + fprintf (fp, "\"messages\" : [\n"); + + /* Walk the top-level node-list */ + bool comma = false; + indent += 4; + while (np) { + if (np->type == NODE_DEFINE && is_typeonly_check(np, typeonly)) { + /* Yeah, this is pedantic */ + vftp = the_vft[np->type]; + indent_me(fp); + vftp->generate(np, JSON_PASS, fp); + comma = true; + } + np = np->peer; + if (comma && np && + np->type == NODE_DEFINE && is_typeonly_check(np, typeonly)) + fprintf (fp, ",\n"); + + } + indent -= 4; + fprintf (fp, "\n"); + indent_me(fp); + fprintf(fp, "]"); +} + +void generate_python_typeonly_definitions(YYSTYPE a1, FILE *fp) +{ + node_t *np = (node_t *)a1; + node_vft_t *vftp; + fprintf (fp, "types = [\n"); + /* Walk the top-level node-list */ + while (np) { + if (np->type == NODE_DEFINE && (np->flags & NODE_FLAG_TYPEONLY)) { + vftp = the_vft[np->type]; + vftp->generate(np, PYTHON_PASS, fp); + } + np = np->peer; + } + fprintf (fp, "\n]\n"); +} + +void generate_python(YYSTYPE a1, FILE *fp) +{ + generate_python_typeonly_definitions(a1, fp); + generate_python_msg_definitions(a1, fp); + + /* + * API CRC signature + */ + fprintf (fp, "vl_api_version = 0x%08x\n\n", (unsigned int)input_crc); +} + +void generate_json(YYSTYPE a1, FILE *fp) +{ + fprintf (fp, "{\n"); + indent += 4; + generate_json_definitions(a1, fp, true); + fprintf (fp, ",\n"); + generate_json_definitions(a1, fp, false); + + /* + * API CRC signature + */ + fprintf (fp, ",\n\"vl_api_version\" :\"0x%08x\"\n", + (unsigned int)input_crc); + fprintf (fp, "}\n"); +} + +void generate(YYSTYPE a1) +{ + if (dump_tree) { + dump((node_t *)a1); + } + + add_msg_ids(a1); + + if (ofp) { + generate_top_boilerplate(ofp); + + generate_msg_ids(a1, ofp); + generate_msg_names(a1, ofp); + generate_msg_name_crc_list(a1, ofp); + generate_typedefs(a1, ofp); + generate_uniondefs(a1, ofp); + generate_printfun(a1, ofp); + generate_endianfun(a1, ofp); + + generate_bottom_boilerplate(ofp); + } + if (pythonfp) { + generate_python(a1, pythonfp); + } + if (jsonfp) { + generate_json(a1, jsonfp); + } +} diff --git a/src/tools/vppapigen/node.h b/src/tools/vppapigen/node.h new file mode 100644 index 00000000..297d6036 --- /dev/null +++ b/src/tools/vppapigen/node.h @@ -0,0 +1,94 @@ +/* + *------------------------------------------------------------------ + * node.h - definitions for an API generator + * + * Copyright (c) 2004-2009 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------ + */ + +#ifndef _node_h_ +#define _node_h_ + +/* + * Global prototypes + */ + +char *sxerox (const char *s); + +enum node_subclass { /* WARNING: indices must match the vft... */ + NODE_ILLEGAL=0, + NODE_U8, + NODE_U16, + NODE_U32, + NODE_U64, + NODE_I8, + NODE_I16, + NODE_I32, + NODE_I64, + NODE_F64, + NODE_PACKED, + NODE_DEFINE, + NODE_UNION, + NODE_SCALAR, + NODE_VECTOR, + NODE_COMPLEX, + NODE_NOVERSION, + NODE_UWORD, + NODE_N_TYPES, /* number of node types with VFT's */ + + /* pseudo-node(s) used in the lexer keyword table, but + NOT in need of a VFT... */ + NODE_TYPEONLY, + NODE_MANUAL_PRINT, + NODE_MANUAL_ENDIAN, + NODE_DONT_TRACE, +}; + +enum passid { + TYPEDEF_PASS=1, + UNION_DEF_PASS, + ENDIANFUN_PASS, + PRINTFUN_PASS, + PYTHON_PASS, + JSON_PASS, +}; + +extern void *make_node (enum node_subclass type); + +typedef struct node_ { + enum node_subclass type; + struct node_ *peer; + struct node_ *deeper; + int flags; + void *data[4]; +} node_t; + +/* To shut up gcc-4.2.x warnings */ +#define CDATA0 ((char *)(this->data[0])) +#define IDATA1 ((int)(uword)(this->data[1])) +#define CDATA2 ((char *)(this->data[2])) +#define CDATA3 ((char *)(this->data[3])) + +#define NODE_FLAG_MANUAL_PRINT (1<<0) +#define NODE_FLAG_MANUAL_ENDIAN (1<<1) +#define NODE_FLAG_TYPEONLY (1<<3) +#define NODE_FLAG_DONT_TRACE (1<<4) + +typedef struct node_vft_ { + void (*print)(struct node_ *); + void (*generate)(struct node_ *, enum passid id, FILE *ofp); + char *endian_converter; +} node_vft_t; + +#endif /* _node_h */ diff --git a/src/vat/api_format.c b/src/vat/api_format.c new file mode 100644 index 00000000..e6c0f244 --- /dev/null +++ b/src/vat/api_format.c @@ -0,0 +1,17829 @@ +/* + *------------------------------------------------------------------ + * api_format.c + * + * Copyright (c) 2014-2016 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------ + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "vat/json_format.h" + +#include +#include + +#define vl_typedefs /* define message structures */ +#include +#undef vl_typedefs + +/* declare message handlers for each api */ + +#define vl_endianfun /* define message structures */ +#include +#undef vl_endianfun + +/* instantiate all the print functions we know about */ +#define vl_print(handle, ...) +#define vl_printfun +#include +#undef vl_printfun + +static uword +api_unformat_sw_if_index (unformat_input_t * input, va_list * args) +{ + vat_main_t *vam = va_arg (*args, vat_main_t *); + u32 *result = va_arg (*args, u32 *); + u8 *if_name; + uword *p; + + if (!unformat (input, "%s", &if_name)) + return 0; + + p = hash_get_mem (vam->sw_if_index_by_interface_name, if_name); + if (p == 0) + return 0; + *result = p[0]; + return 1; +} + +void vat_suspend (vlib_main_t * vm, f64 interval); + +#if VPP_API_TEST_BUILTIN == 0 +/* Parse an IP4 address %d.%d.%d.%d. */ +uword +unformat_ip4_address (unformat_input_t * input, va_list * args) +{ + u8 *result = va_arg (*args, u8 *); + unsigned a[4]; + + if (!unformat (input, "%d.%d.%d.%d", &a[0], &a[1], &a[2], &a[3])) + return 0; + + if (a[0] >= 256 || a[1] >= 256 || a[2] >= 256 || a[3] >= 256) + return 0; + + result[0] = a[0]; + result[1] = a[1]; + result[2] = a[2]; + result[3] = a[3]; + + return 1; +} + +uword +unformat_ethernet_address (unformat_input_t * input, va_list * args) +{ + u8 *result = va_arg (*args, u8 *); + u32 i, a[6]; + + if (!unformat (input, "%_%x:%x:%x:%x:%x:%x%_", + &a[0], &a[1], &a[2], &a[3], &a[4], &a[5])) + return 0; + + /* Check range. */ + for (i = 0; i < 6; i++) + if (a[i] >= (1 << 8)) + return 0; + + for (i = 0; i < 6; i++) + result[i] = a[i]; + + return 1; +} + +/* Returns ethernet type as an int in host byte order. */ +uword +unformat_ethernet_type_host_byte_order (unformat_input_t * input, + va_list * args) +{ + u16 *result = va_arg (*args, u16 *); + int type; + + /* Numeric type. */ + if (unformat (input, "0x%x", &type) || unformat (input, "%d", &type)) + { + if (type >= (1 << 16)) + return 0; + *result = type; + return 1; + } + return 0; +} + +/* Parse an IP6 address. */ +uword +unformat_ip6_address (unformat_input_t * input, va_list * args) +{ + ip6_address_t *result = va_arg (*args, ip6_address_t *); + u16 hex_quads[8]; + uword hex_quad, n_hex_quads, hex_digit, n_hex_digits; + uword c, n_colon, double_colon_index; + + n_hex_quads = hex_quad = n_hex_digits = n_colon = 0; + double_colon_index = ARRAY_LEN (hex_quads); + while ((c = unformat_get_input (input)) != UNFORMAT_END_OF_INPUT) + { + hex_digit = 16; + if (c >= '0' && c <= '9') + hex_digit = c - '0'; + else if (c >= 'a' && c <= 'f') + hex_digit = c + 10 - 'a'; + else if (c >= 'A' && c <= 'F') + hex_digit = c + 10 - 'A'; + else if (c == ':' && n_colon < 2) + n_colon++; + else + { + unformat_put_input (input); + break; + } + + /* Too many hex quads. */ + if (n_hex_quads >= ARRAY_LEN (hex_quads)) + return 0; + + if (hex_digit < 16) + { + hex_quad = (hex_quad << 4) | hex_digit; + + /* Hex quad must fit in 16 bits. */ + if (n_hex_digits >= 4) + return 0; + + n_colon = 0; + n_hex_digits++; + } + + /* Save position of :: */ + if (n_colon == 2) + { + /* More than one :: ? */ + if (double_colon_index < ARRAY_LEN (hex_quads)) + return 0; + double_colon_index = n_hex_quads; + } + + if (n_colon > 0 && n_hex_digits > 0) + { + hex_quads[n_hex_quads++] = hex_quad; + hex_quad = 0; + n_hex_digits = 0; + } + } + + if (n_hex_digits > 0) + hex_quads[n_hex_quads++] = hex_quad; + + { + word i; + + /* Expand :: to appropriate number of zero hex quads. */ + if (double_colon_index < ARRAY_LEN (hex_quads)) + { + word n_zero = ARRAY_LEN (hex_quads) - n_hex_quads; + + for (i = n_hex_quads - 1; i >= (signed) double_colon_index; i--) + hex_quads[n_zero + i] = hex_quads[i]; + + for (i = 0; i < n_zero; i++) + hex_quads[double_colon_index + i] = 0; + + n_hex_quads = ARRAY_LEN (hex_quads); + } + + /* Too few hex quads given. */ + if (n_hex_quads < ARRAY_LEN (hex_quads)) + return 0; + + for (i = 0; i < ARRAY_LEN (hex_quads); i++) + result->as_u16[i] = clib_host_to_net_u16 (hex_quads[i]); + + return 1; + } +} + +uword +unformat_ipsec_policy_action (unformat_input_t * input, va_list * args) +{ + u32 *r = va_arg (*args, u32 *); + + if (0); +#define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_POLICY_ACTION_##f; + foreach_ipsec_policy_action +#undef _ + else + return 0; + return 1; +} + +uword +unformat_ipsec_crypto_alg (unformat_input_t * input, va_list * args) +{ + u32 *r = va_arg (*args, u32 *); + + if (0); +#define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_CRYPTO_ALG_##f; + foreach_ipsec_crypto_alg +#undef _ + else + return 0; + return 1; +} + +u8 * +format_ipsec_crypto_alg (u8 * s, va_list * args) +{ + u32 i = va_arg (*args, u32); + u8 *t = 0; + + switch (i) + { +#define _(v,f,str) case IPSEC_CRYPTO_ALG_##f: t = (u8 *) str; break; + foreach_ipsec_crypto_alg +#undef _ + default: + return format (s, "unknown"); + } + return format (s, "%s", t); +} + +uword +unformat_ipsec_integ_alg (unformat_input_t * input, va_list * args) +{ + u32 *r = va_arg (*args, u32 *); + + if (0); +#define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_INTEG_ALG_##f; + foreach_ipsec_integ_alg +#undef _ + else + return 0; + return 1; +} + +u8 * +format_ipsec_integ_alg (u8 * s, va_list * args) +{ + u32 i = va_arg (*args, u32); + u8 *t = 0; + + switch (i) + { +#define _(v,f,str) case IPSEC_INTEG_ALG_##f: t = (u8 *) str; break; + foreach_ipsec_integ_alg +#undef _ + default: + return format (s, "unknown"); + } + return format (s, "%s", t); +} + +uword +unformat_ikev2_auth_method (unformat_input_t * input, va_list * args) +{ + u32 *r = va_arg (*args, u32 *); + + if (0); +#define _(v,f,s) else if (unformat (input, s)) *r = IKEV2_AUTH_METHOD_##f; + foreach_ikev2_auth_method +#undef _ + else + return 0; + return 1; +} + +uword +unformat_ikev2_id_type (unformat_input_t * input, va_list * args) +{ + u32 *r = va_arg (*args, u32 *); + + if (0); +#define _(v,f,s) else if (unformat (input, s)) *r = IKEV2_ID_TYPE_##f; + foreach_ikev2_id_type +#undef _ + else + return 0; + return 1; +} +#endif /* VPP_API_TEST_BUILTIN */ + +static uword +unformat_policer_rate_type (unformat_input_t * input, va_list * args) +{ + u8 *r = va_arg (*args, u8 *); + + if (unformat (input, "kbps")) + *r = SSE2_QOS_RATE_KBPS; + else if (unformat (input, "pps")) + *r = SSE2_QOS_RATE_PPS; + else + return 0; + return 1; +} + +static uword +unformat_policer_round_type (unformat_input_t * input, va_list * args) +{ + u8 *r = va_arg (*args, u8 *); + + if (unformat (input, "closest")) + *r = SSE2_QOS_ROUND_TO_CLOSEST; + else if (unformat (input, "up")) + *r = SSE2_QOS_ROUND_TO_UP; + else if (unformat (input, "down")) + *r = SSE2_QOS_ROUND_TO_DOWN; + else + return 0; + return 1; +} + +static uword +unformat_policer_type (unformat_input_t * input, va_list * args) +{ + u8 *r = va_arg (*args, u8 *); + + if (unformat (input, "1r2c")) + *r = SSE2_QOS_POLICER_TYPE_1R2C; + else if (unformat (input, "1r3c")) + *r = SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697; + else if (unformat (input, "2r3c-2698")) + *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698; + else if (unformat (input, "2r3c-4115")) + *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115; + else if (unformat (input, "2r3c-mef5cf1")) + *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1; + else + return 0; + return 1; +} + +static uword +unformat_dscp (unformat_input_t * input, va_list * va) +{ + u8 *r = va_arg (*va, u8 *); + + if (0); +#define _(v,f,str) else if (unformat (input, str)) *r = VNET_DSCP_##f; + foreach_vnet_dscp +#undef _ + else + return 0; + return 1; +} + +static uword +unformat_policer_action_type (unformat_input_t * input, va_list * va) +{ + sse2_qos_pol_action_params_st *a + = va_arg (*va, sse2_qos_pol_action_params_st *); + + if (unformat (input, "drop")) + a->action_type = SSE2_QOS_ACTION_DROP; + else if (unformat (input, "transmit")) + a->action_type = SSE2_QOS_ACTION_TRANSMIT; + else if (unformat (input, "mark-and-transmit %U", unformat_dscp, &a->dscp)) + a->action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT; + else + return 0; + return 1; +} + +static uword +unformat_policer_classify_table_type (unformat_input_t * input, va_list * va) +{ + u32 *r = va_arg (*va, u32 *); + u32 tid; + + if (unformat (input, "ip4")) + tid = POLICER_CLASSIFY_TABLE_IP4; + else if (unformat (input, "ip6")) + tid = POLICER_CLASSIFY_TABLE_IP6; + else if (unformat (input, "l2")) + tid = POLICER_CLASSIFY_TABLE_L2; + else + return 0; + + *r = tid; + return 1; +} + +static uword +unformat_flow_classify_table_type (unformat_input_t * input, va_list * va) +{ + u32 *r = va_arg (*va, u32 *); + u32 tid; + + if (unformat (input, "ip4")) + tid = FLOW_CLASSIFY_TABLE_IP4; + else if (unformat (input, "ip6")) + tid = FLOW_CLASSIFY_TABLE_IP6; + else + return 0; + + *r = tid; + return 1; +} + +#if (VPP_API_TEST_BUILTIN==0) +u8 * +format_ip4_address (u8 * s, va_list * args) +{ + u8 *a = va_arg (*args, u8 *); + return format (s, "%d.%d.%d.%d", a[0], a[1], a[2], a[3]); +} + +u8 * +format_ip6_address (u8 * s, va_list * args) +{ + ip6_address_t *a = va_arg (*args, ip6_address_t *); + u32 i, i_max_n_zero, max_n_zeros, i_first_zero, n_zeros, last_double_colon; + + i_max_n_zero = ARRAY_LEN (a->as_u16); + max_n_zeros = 0; + i_first_zero = i_max_n_zero; + n_zeros = 0; + for (i = 0; i < ARRAY_LEN (a->as_u16); i++) + { + u32 is_zero = a->as_u16[i] == 0; + if (is_zero && i_first_zero >= ARRAY_LEN (a->as_u16)) + { + i_first_zero = i; + n_zeros = 0; + } + n_zeros += is_zero; + if ((!is_zero && n_zeros > max_n_zeros) + || (i + 1 >= ARRAY_LEN (a->as_u16) && n_zeros > max_n_zeros)) + { + i_max_n_zero = i_first_zero; + max_n_zeros = n_zeros; + i_first_zero = ARRAY_LEN (a->as_u16); + n_zeros = 0; + } + } + + last_double_colon = 0; + for (i = 0; i < ARRAY_LEN (a->as_u16); i++) + { + if (i == i_max_n_zero && max_n_zeros > 1) + { + s = format (s, "::"); + i += max_n_zeros - 1; + last_double_colon = 1; + } + else + { + s = format (s, "%s%x", + (last_double_colon || i == 0) ? "" : ":", + clib_net_to_host_u16 (a->as_u16[i])); + last_double_colon = 0; + } + } + + return s; +} + +/* Format an IP46 address. */ +u8 * +format_ip46_address (u8 * s, va_list * args) +{ + ip46_address_t *ip46 = va_arg (*args, ip46_address_t *); + ip46_type_t type = va_arg (*args, ip46_type_t); + int is_ip4 = 1; + + switch (type) + { + case IP46_TYPE_ANY: + is_ip4 = ip46_address_is_ip4 (ip46); + break; + case IP46_TYPE_IP4: + is_ip4 = 1; + break; + case IP46_TYPE_IP6: + is_ip4 = 0; + break; + } + + return is_ip4 ? + format (s, "%U", format_ip4_address, &ip46->ip4) : + format (s, "%U", format_ip6_address, &ip46->ip6); +} + +u8 * +format_ethernet_address (u8 * s, va_list * args) +{ + u8 *a = va_arg (*args, u8 *); + + return format (s, "%02x:%02x:%02x:%02x:%02x:%02x", + a[0], a[1], a[2], a[3], a[4], a[5]); +} +#endif + +static void +increment_v4_address (ip4_address_t * a) +{ + u32 v; + + v = ntohl (a->as_u32) + 1; + a->as_u32 = ntohl (v); +} + +static void +increment_v6_address (ip6_address_t * a) +{ + u64 v0, v1; + + v0 = clib_net_to_host_u64 (a->as_u64[0]); + v1 = clib_net_to_host_u64 (a->as_u64[1]); + + v1 += 1; + if (v1 == 0) + v0 += 1; + a->as_u64[0] = clib_net_to_host_u64 (v0); + a->as_u64[1] = clib_net_to_host_u64 (v1); +} + +static void +increment_mac_address (u64 * mac) +{ + u64 tmp = *mac; + + tmp = clib_net_to_host_u64 (tmp); + tmp += 1 << 16; /* skip unused (least significant) octets */ + tmp = clib_host_to_net_u64 (tmp); + *mac = tmp; +} + +static void vl_api_create_loopback_reply_t_handler + (vl_api_create_loopback_reply_t * mp) +{ + vat_main_t *vam = &vat_main; + i32 retval = ntohl (mp->retval); + + vam->retval = retval; + vam->regenerate_interface_table = 1; + vam->sw_if_index = ntohl (mp->sw_if_index); + vam->result_ready = 1; +} + +static void vl_api_create_loopback_reply_t_handler_json + (vl_api_create_loopback_reply_t * mp) +{ + vat_main_t *vam = &vat_main; + vat_json_node_t node; + + vat_json_init_object (&node); + vat_json_object_add_int (&node, "retval", ntohl (mp->retval)); + vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index)); + + vat_json_print (vam->ofp, &node); + vat_json_free (&node); + vam->retval = ntohl (mp->retval); + vam->result_ready = 1; +} + +static void vl_api_af_packet_create_reply_t_handler + (vl_api_af_packet_create_reply_t * mp) +{ + vat_main_t *vam = &vat_main; + i32 retval = ntohl (mp->retval); + + vam->retval = retval; + vam->regenerate_interface_table = 1; + vam->sw_if_index = ntohl (mp->sw_if_index); + vam->result_ready = 1; +} + +static void vl_api_af_packet_create_reply_t_handler_json + (vl_api_af_packet_create_reply_t * mp) +{ + vat_main_t *vam = &vat_main; + vat_json_node_t node; + + vat_json_init_object (&node); + vat_json_object_add_int (&node, "retval", ntohl (mp->retval)); + vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index)); + + vat_json_print (vam->ofp, &node); + vat_json_free (&node); + + vam->retval = ntohl (mp->retval); + vam->result_ready = 1; +} + +static void vl_api_create_vlan_subif_reply_t_handler + (vl_api_create_vlan_subif_reply_t * mp) +{ + vat_main_t *vam = &vat_main; + i32 retval = ntohl (mp->retval); + + vam->retval = retval; + vam->regenerate_interface_table = 1; + vam->sw_if_index = ntohl (mp->sw_if_index); + vam->result_ready = 1; +} + +static void vl_api_create_vlan_subif_reply_t_handler_json + (vl_api_create_vlan_subif_reply_t * mp) +{ + vat_main_t *vam = &vat_main; + vat_json_node_t node; + + vat_json_init_object (&node); + vat_json_object_add_int (&node, "retval", ntohl (mp->retval)); + vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index)); + + vat_json_print (vam->ofp, &node); + vat_json_free (&node); + + vam->retval = ntohl (mp->retval); + vam->result_ready = 1; +} + +static void vl_api_create_subif_reply_t_handler + (vl_api_create_subif_reply_t * mp) +{ + vat_main_t *vam = &vat_main; + i32 retval = ntohl (mp->retval); + + vam->retval = retval; + vam->regenerate_interface_table = 1; + vam->sw_if_index = ntohl (mp->sw_if_index); + vam->result_ready = 1; +} + +static void vl_api_create_subif_reply_t_handler_json + (vl_api_create_subif_reply_t * mp) +{ + vat_main_t *vam = &vat_main; + vat_json_node_t node; + + vat_json_init_object (&node); + vat_json_object_add_int (&node, "retval", ntohl (mp->retval)); + vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index)); + + vat_json_print (vam->ofp, &node); + vat_json_free (&node); + + vam->retval = ntohl (mp->retval); + vam->result_ready = 1; +} + +static void vl_api_interface_name_renumber_reply_t_handler + (vl_api_interface_name_renumber_reply_t * mp) +{ + vat_main_t *vam = &vat_main; + i32 retval = ntohl (mp->retval); + + vam->retval = retval; + vam->regenerate_interface_table = 1; + vam->result_ready = 1; +} + +static void vl_api_interface_name_renumber_reply_t_handler_json + (vl_api_interface_name_renumber_reply_t * mp) +{ + vat_main_t *vam = &vat_main; + vat_json_node_t node; + + vat_json_init_object (&node); + vat_json_object_add_int (&node, "retval", ntohl (mp->retval)); + + vat_json_print (vam->ofp, &node); + vat_json_free (&node); + + vam->retval = ntohl (mp->retval); + vam->result_ready = 1; +} + +/* + * Special-case: build the interface table, maintain + * the next loopback sw_if_index vbl. + */ +static void vl_api_sw_interface_details_t_handler + (vl_api_sw_interface_details_t * mp) +{ + vat_main_t *vam = &vat_main; + u8 *s = format (0, "%s%c", mp->interface_name, 0); + + hash_set_mem (vam->sw_if_index_by_interface_name, s, + ntohl (mp->sw_if_index)); + + /* In sub interface case, fill the sub interface table entry */ + if (mp->sw_if_index != mp->sup_sw_if_index) + { + sw_interface_subif_t *sub = NULL; + + vec_add2 (vam->sw_if_subif_table, sub, 1); + + vec_validate (sub->interface_name, strlen ((char *) s) + 1); + strncpy ((char *) sub->interface_name, (char *) s, + vec_len (sub->interface_name)); + sub->sw_if_index = ntohl (mp->sw_if_index); + sub->sub_id = ntohl (mp->sub_id); + + sub->sub_dot1ad = mp->sub_dot1ad; + sub->sub_number_of_tags = mp->sub_number_of_tags; + sub->sub_outer_vlan_id = ntohs (mp->sub_outer_vlan_id); + sub->sub_inner_vlan_id = ntohs (mp->sub_inner_vlan_id); + sub->sub_exact_match = mp->sub_exact_match; + sub->sub_default = mp->sub_default; + sub->sub_outer_vlan_id_any = mp->sub_outer_vlan_id_any; + sub->sub_inner_vlan_id_any = mp->sub_inner_vlan_id_any; + + /* vlan tag rewrite */ + sub->vtr_op = ntohl (mp->vtr_op); + sub->vtr_push_dot1q = ntohl (mp->vtr_push_dot1q); + sub->vtr_tag1 = ntohl (mp->vtr_tag1); + sub->vtr_tag2 = ntohl (mp->vtr_tag2); + } +} + +static void vl_api_sw_interface_details_t_handler_json + (vl_api_sw_interface_details_t * mp) +{ + vat_main_t *vam = &vat_main; + vat_json_node_t *node = NULL; + + if (VAT_JSON_ARRAY != vam->json_tree.type) + { + ASSERT (VAT_JSON_NONE == vam->json_tree.type); + vat_json_init_array (&vam->json_tree); + } + node = vat_json_array_add (&vam->json_tree); + + vat_json_init_object (node); + vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index)); + vat_json_object_add_uint (node, "sup_sw_if_index", + ntohl (mp->sup_sw_if_index)); + vat_json_object_add_uint (node, "l2_address_length", + ntohl (mp->l2_address_length)); + vat_json_object_add_bytes (node, "l2_address", mp->l2_address, + sizeof (mp->l2_address)); + vat_json_object_add_string_copy (node, "interface_name", + mp->interface_name); + vat_json_object_add_uint (node, "admin_up_down", mp->admin_up_down); + vat_json_object_add_uint (node, "link_up_down", mp->link_up_down); + vat_json_object_add_uint (node, "link_duplex", mp->link_duplex); + vat_json_object_add_uint (node, "link_speed", mp->link_speed); + vat_json_object_add_uint (node, "mtu", ntohs (mp->link_mtu)); + vat_json_object_add_uint (node, "sub_id", ntohl (mp->sub_id)); + vat_json_object_add_uint (node, "sub_dot1ad", mp->sub_dot1ad); + vat_json_object_add_uint (node, "sub_number_of_tags", + mp->sub_number_of_tags); + vat_json_object_add_uint (node, "sub_outer_vlan_id", + ntohs (mp->sub_outer_vlan_id)); + vat_json_object_add_uint (node, "sub_inner_vlan_id", + ntohs (mp->sub_inner_vlan_id)); + vat_json_object_add_uint (node, "sub_exact_match", mp->sub_exact_match); + vat_json_object_add_uint (node, "sub_default", mp->sub_default); + vat_json_object_add_uint (node, "sub_outer_vlan_id_any", + mp->sub_outer_vlan_id_any); + vat_json_object_add_uint (node, "sub_inner_vlan_id_any", + mp->sub_inner_vlan_id_any); + vat_json_object_add_uint (node, "vtr_op", ntohl (mp->vtr_op)); + vat_json_object_add_uint (node, "vtr_push_dot1q", + ntohl (mp->vtr_push_dot1q)); + vat_json_object_add_uint (node, "vtr_tag1", ntohl (mp->vtr_tag1)); + vat_json_object_add_uint (node, "vtr_tag2", ntohl (mp->vtr_tag2)); +} + +static void vl_api_sw_interface_set_flags_t_handler + (vl_api_sw_interface_set_flags_t * mp) +{ + vat_main_t *vam = &vat_main; + if (vam->interface_event_display) + errmsg ("interface flags: sw_if_index %d %s %s", + ntohl (mp->sw_if_index), + mp->admin_up_down ? "admin-up" : "admin-down", + mp->link_up_down ? "link-up" : "link-down"); +} + +static void vl_api_sw_interface_set_flags_t_handler_json + (vl_api_sw_interface_set_flags_t * mp) +{ + /* JSON output not supported */ +} + +static void +vl_api_cli_reply_t_handler (vl_api_cli_reply_t * mp) +{ + vat_main_t *vam = &vat_main; + i32 retval = ntohl (mp->retval); + + vam->retval = retval; + vam->shmem_result = (u8 *) mp->reply_in_shmem; + vam->result_ready = 1; +} + +static void +vl_api_cli_reply_t_handler_json (vl_api_cli_reply_t * mp) +{ + vat_main_t *vam = &vat_main; + vat_json_node_t node; + api_main_t *am = &api_main; + void *oldheap; + u8 *reply; + + vat_json_init_object (&node); + vat_json_object_add_int (&node, "retval", ntohl (mp->retval)); + vat_json_object_add_uint (&node, "reply_in_shmem", + ntohl (mp->reply_in_shmem)); + /* Toss the shared-memory original... */ + pthread_mutex_lock (&am->vlib_rp->mutex); + oldheap = svm_push_data_heap (am->vlib_rp); + + reply = (u8 *) (mp->reply_in_shmem); + vec_free (reply); + + svm_pop_heap (oldheap); + pthread_mutex_unlock (&am->vlib_rp->mutex); + + vat_json_print (vam->ofp, &node); + vat_json_free (&node); + + vam->retval = ntohl (mp->retval); + vam->result_ready = 1; +} + +static void +vl_api_cli_inband_reply_t_handler (vl_api_cli_inband_reply_t * mp) +{ + vat_main_t *vam = &vat_main; + i32 retval = ntohl (mp->retval); + + vam->retval = retval; + vam->cmd_reply = mp->reply; + vam->result_ready = 1; +} + +static void +vl_api_cli_inband_reply_t_handler_json (vl_api_cli_inband_reply_t * mp) +{ + vat_main_t *vam = &vat_main; + vat_json_node_t node; + + vat_json_init_object (&node); + vat_json_object_add_int (&node, "retval", ntohl (mp->retval)); + vat_json_object_add_string_copy (&node, "reply", mp->reply); + + vat_json_print (vam->ofp, &node); + vat_json_free (&node); + + vam->retval = ntohl (mp->retval); + vam->result_ready = 1; +} + +static void vl_api_classify_add_del_table_reply_t_handler + (vl_api_classify_add_del_table_reply_t * mp) +{ + vat_main_t *vam = &vat_main; + i32 retval = ntohl (mp->retval); + if (vam->async_mode) + { + vam->async_errors += (retval < 0); + } + else + { + vam->retval = retval; + if (retval == 0 && + ((mp->new_table_index != 0xFFFFFFFF) || + (mp->skip_n_vectors != 0xFFFFFFFF) || + (mp->match_n_vectors != 0xFFFFFFFF))) + /* + * Note: this is just barely thread-safe, depends on + * the main thread spinning waiting for an answer... + */ + errmsg ("new index %d, skip_n_vectors %d, match_n_vectors %d", + ntohl (mp->new_table_index), + ntohl (mp->skip_n_vectors), ntohl (mp->match_n_vectors)); + vam->result_ready = 1; + } +} + +static void vl_api_classify_add_del_table_reply_t_handler_json + (vl_api_classify_add_del_table_reply_t * mp) +{ + vat_main_t *vam = &vat_main; + vat_json_node_t node; + + vat_json_init_object (&node); + vat_json_object_add_int (&node, "retval", ntohl (mp->retval)); + vat_json_object_add_uint (&node, "new_table_index", + ntohl (mp->new_table_index)); + vat_json_object_add_uint (&node, "skip_n_vectors", + ntohl (mp->skip_n_vectors)); + vat_json_object_add_uint (&node, "match_n_vectors", + ntohl (mp->match_n_vectors)); + + vat_json_print (vam->ofp, &node); + vat_json_free (&node); + + vam->retval = ntohl (mp->retval); + vam->result_ready = 1; +} + +static void vl_api_get_node_index_reply_t_handler + (vl_api_get_node_index_reply_t * mp) +{ + vat_main_t *vam = &vat_main; + i32 retval = ntohl (mp->retval); + if (vam->async_mode) + { + vam->async_errors += (retval < 0); + } + else + { + vam->retval = retval; + if (retval == 0) + errmsg ("node index %d", ntohl (mp->node_index)); + vam->result_ready = 1; + } +} + +static void vl_api_get_node_index_reply_t_handler_json + (vl_api_get_node_index_reply_t * mp) +{ + vat_main_t *vam = &vat_main; + vat_json_node_t node; + + vat_json_init_object (&node); + vat_json_object_add_int (&node, "retval", ntohl (mp->retval)); + vat_json_object_add_uint (&node, "node_index", ntohl (mp->node_index)); + + vat_json_print (vam->ofp, &node); + vat_json_free (&node); + + vam->retval = ntohl (mp->retval); + vam->result_ready = 1; +} + +static void vl_api_get_next_index_reply_t_handler + (vl_api_get_next_index_reply_t * mp) +{ + vat_main_t *vam = &vat_main; + i32 retval = ntohl (mp->retval); + if (vam->async_mode) + { + vam->async_errors += (retval < 0); + } + else + { + vam->retval = retval; + if (retval == 0) + errmsg ("next node index %d", ntohl (mp->next_index)); + vam->result_ready = 1; + } +} + +static void vl_api_get_next_index_reply_t_handler_json + (vl_api_get_next_index_reply_t * mp) +{ + vat_main_t *vam = &vat_main; + vat_json_node_t node; + + vat_json_init_object (&node); + vat_json_object_add_int (&node, "retval", ntohl (mp->retval)); + vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index)); + + vat_json_print (vam->ofp, &node); + vat_json_free (&node); + + vam->retval = ntohl (mp->retval); + vam->result_ready = 1; +} + +static void vl_api_add_node_next_reply_t_handler + (vl_api_add_node_next_reply_t * mp) +{ + vat_main_t *vam = &vat_main; + i32 retval = ntohl (mp->retval); + if (vam->async_mode) + { + vam->async_errors += (retval < 0); + } + else + { + vam->retval = retval; + if (retval == 0) + errmsg ("next index %d", ntohl (mp->next_index)); + vam->result_ready = 1; + } +} + +static void vl_api_add_node_next_reply_t_handler_json + (vl_api_add_node_next_reply_t * mp) +{ + vat_main_t *vam = &vat_main; + vat_json_node_t node; + + vat_json_init_object (&node); + vat_json_object_add_int (&node, "retval", ntohl (mp->retval)); + vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index)); + + vat_json_print (vam->ofp, &node); + vat_json_free (&node); + + vam->retval = ntohl (mp->retval); + vam->result_ready = 1; +} + +static void vl_api_show_version_reply_t_handler + (vl_api_show_version_reply_t * mp) +{ + vat_main_t *vam = &vat_main; + i32 retval = ntohl (mp->retval); + + if (retval >= 0) + { + errmsg (" program: %s", mp->program); + errmsg (" version: %s", mp->version); + errmsg (" build date: %s", mp->build_date); + errmsg ("build directory: %s", mp->build_directory); + } + vam->retval = retval; + vam->result_ready = 1; +} + +static void vl_api_show_version_reply_t_handler_json + (vl_api_show_version_reply_t * mp) +{ + vat_main_t *vam = &vat_main; + vat_json_node_t node; + + vat_json_init_object (&node); + vat_json_object_add_int (&node, "retval", ntohl (mp->retval)); + vat_json_object_add_string_copy (&node, "program", mp->program); + vat_json_object_add_string_copy (&node, "version", mp->version); + vat_json_object_add_string_copy (&node, "build_date", mp->build_date); + vat_json_object_add_string_copy (&node, "build_directory", + mp->build_directory); + + vat_json_print (vam->ofp, &node); + vat_json_free (&node); + + vam->retval = ntohl (mp->retval); + vam->result_ready = 1; +} + +static void +vl_api_ip4_arp_event_t_handler (vl_api_ip4_arp_event_t * mp) +{ + errmsg ("arp %s event: address %U new mac %U sw_if_index %d", + mp->mac_ip ? "mac/ip binding" : "address resolution", + format_ip4_address, &mp->address, + format_ethernet_address, mp->new_mac, mp->sw_if_index); +} + +static void +vl_api_ip4_arp_event_t_handler_json (vl_api_ip4_arp_event_t * mp) +{ + /* JSON output not supported */ +} + +static void +vl_api_ip6_nd_event_t_handler (vl_api_ip6_nd_event_t * mp) +{ + errmsg ("ip6 nd %s event: address %U new mac %U sw_if_index %d", + mp->mac_ip ? "mac/ip binding" : "address resolution", + format_ip6_address, mp->address, + format_ethernet_address, mp->new_mac, mp->sw_if_index); +} + +static void +vl_api_ip6_nd_event_t_handler_json (vl_api_ip6_nd_event_t * mp) +{ + /* JSON output not supported */ +} + +/* + * Special-case: build the bridge domain table, maintain + * the next bd id vbl. + */ +static void vl_api_bridge_domain_details_t_handler + (vl_api_bridge_domain_details_t * mp) +{ + vat_main_t *vam = &vat_main; + u32 n_sw_ifs = ntohl (mp->n_sw_ifs); + + print (vam->ofp, "\n%-3s %-3s %-3s %-3s %-3s %-3s", + " ID", "LRN", "FWD", "FLD", "BVI", "#IF"); + + print (vam->ofp, "%3d %3d %3d %3d %3d %3d", + ntohl (mp->bd_id), mp->learn, mp->forward, + mp->flood, ntohl (mp->bvi_sw_if_index), n_sw_ifs); + + if (n_sw_ifs) + print (vam->ofp, "\n\n%s %s %s", "sw_if_index", "SHG", "Interface Name"); +} + +static void vl_api_bridge_domain_details_t_handler_json + (vl_api_bridge_domain_details_t * mp) +{ + vat_main_t *vam = &vat_main; + vat_json_node_t *node, *array = NULL; + + if (VAT_JSON_ARRAY != vam->json_tree.type) + { + ASSERT (VAT_JSON_NONE == vam->json_tree.type); + vat_json_init_array (&vam->json_tree); + } + node = vat_json_array_add (&vam->json_tree); + + vat_json_init_object (node); + vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id)); + vat_json_object_add_uint (node, "flood", mp->flood); + vat_json_object_add_uint (node, "forward", mp->forward); + vat_json_object_add_uint (node, "learn", mp->learn); + vat_json_object_add_uint (node, "bvi_sw_if_index", + ntohl (mp->bvi_sw_if_index)); + vat_json_object_add_uint (node, "n_sw_ifs", ntohl (mp->n_sw_ifs)); + array = vat_json_object_add (node, "sw_if"); + vat_json_init_array (array); +} + +/* + * Special-case: build the bridge domain sw if table. + */ +static void vl_api_bridge_domain_sw_if_details_t_handler + (vl_api_bridge_domain_sw_if_details_t * mp) +{ + vat_main_t *vam = &vat_main; + hash_pair_t *p; + u8 *sw_if_name = 0; + u32 sw_if_index; + + sw_if_index = ntohl (mp->sw_if_index); + /* *INDENT-OFF* */ + hash_foreach_pair (p, vam->sw_if_index_by_interface_name, + ({ + if ((u32) p->value[0] == sw_if_index) + { + sw_if_name = (u8 *)(p->key); + break; + } + })); + /* *INDENT-ON* */ + + print (vam->ofp, "%7d %3d %s", sw_if_index, + mp->shg, sw_if_name ? (char *) sw_if_name : + "sw_if_index not found!"); +} + +static void vl_api_bridge_domain_sw_if_details_t_handler_json + (vl_api_bridge_domain_sw_if_details_t * mp) +{ + vat_main_t *vam = &vat_main; + vat_json_node_t *node = NULL; + uword last_index = 0; + + ASSERT (VAT_JSON_ARRAY == vam->json_tree.type); + ASSERT (vec_len (vam->json_tree.array) >= 1); + last_index = vec_len (vam->json_tree.array) - 1; + node = &vam->json_tree.array[last_index]; + node = vat_json_object_get_element (node, "sw_if"); + ASSERT (NULL != node); + node = vat_json_array_add (node); + + vat_json_init_object (node); + vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id)); + vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index)); + vat_json_object_add_uint (node, "shg", mp->shg); +} + +static void vl_api_control_ping_reply_t_handler + (vl_api_control_ping_reply_t * mp) +{ + vat_main_t *vam = &vat_main; + i32 retval = ntohl (mp->retval); + if (vam->async_mode) + { + vam->async_errors += (retval < 0); + } + else + { + vam->retval = retval; + vam->result_ready = 1; + } +} + +static void vl_api_control_ping_reply_t_handler_json + (vl_api_control_ping_reply_t * mp) +{ + vat_main_t *vam = &vat_main; + i32 retval = ntohl (mp->retval); + + if (VAT_JSON_NONE != vam->json_tree.type) + { + vat_json_print (vam->ofp, &vam->json_tree); + vat_json_free (&vam->json_tree); + vam->json_tree.type = VAT_JSON_NONE; + } + else + { + /* just print [] */ + vat_json_init_array (&vam->json_tree); + vat_json_print (vam->ofp, &vam->json_tree); + vam->json_tree.type = VAT_JSON_NONE; + } + + vam->retval = retval; + vam->result_ready = 1; +} + +static void +vl_api_l2_flags_reply_t_handler (vl_api_l2_flags_reply_t * mp) +{ + vat_main_t *vam = &vat_main; + i32 retval = ntohl (mp->retval); + if (vam->async_mode) + { + vam->async_errors += (retval < 0); + } + else + { + vam->retval = retval; + vam->result_ready = 1; + } +} + +static void vl_api_l2_flags_reply_t_handler_json + (vl_api_l2_flags_reply_t * mp) +{ + vat_main_t *vam = &vat_main; + vat_json_node_t node; + + vat_json_init_object (&node); + vat_json_object_add_int (&node, "retval", ntohl (mp->retval)); + vat_json_object_add_uint (&node, "resulting_feature_bitmap", + ntohl (mp->resulting_feature_bitmap)); + + vat_json_print (vam->ofp, &node); + vat_json_free (&node); + + vam->retval = ntohl (mp->retval); + vam->result_ready = 1; +} + +static void vl_api_bridge_flags_reply_t_handler + (vl_api_bridge_flags_reply_t * mp) +{ + vat_main_t *vam = &vat_main; + i32 retval = ntohl (mp->retval); + if (vam->async_mode) + { + vam->async_errors += (retval < 0); + } + else + { + vam->retval = retval; + vam->result_ready = 1; + } +} + +static void vl_api_bridge_flags_reply_t_handler_json + (vl_api_bridge_flags_reply_t * mp) +{ + vat_main_t *vam = &vat_main; + vat_json_node_t node; + + vat_json_init_object (&node); + vat_json_object_add_int (&node, "retval", ntohl (mp->retval)); + vat_json_object_add_uint (&node, "resulting_feature_bitmap", + ntohl (mp->resulting_feature_bitmap)); + + vat_json_print (vam->ofp, &node); + vat_json_free (&node); + + vam->retval = ntohl (mp->retval); + vam->result_ready = 1; +} + +static void vl_api_tap_connect_reply_t_handler + (vl_api_tap_connect_reply_t * mp) +{ + vat_main_t *vam = &vat_main; + i32 retval = ntohl (mp->retval); + if (vam->async_mode) + { + vam->async_errors += (retval < 0); + } + else + { + vam->retval = retval; + vam->sw_if_index = ntohl (mp->sw_if_index); + vam->result_ready = 1; + } + +} + +static void vl_api_tap_connect_reply_t_handler_json + (vl_api_tap_connect_reply_t * mp) +{ + vat_main_t *vam = &vat_main; + vat_json_node_t node; + + vat_json_init_object (&node); + vat_json_object_add_int (&node, "retval", ntohl (mp->retval)); + vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index)); + + vat_json_print (vam->ofp, &node); + vat_json_free (&node); + + vam->retval = ntohl (mp->retval); + vam->result_ready = 1; + +} + +static void +vl_api_tap_modify_reply_t_handler (vl_api_tap_modify_reply_t * mp) +{ + vat_main_t *vam = &vat_main; + i32 retval = ntohl (mp->retval); + if (vam->async_mode) + { + vam->async_errors += (retval < 0); + } + else + { + vam->retval = retval; + vam->sw_if_index = ntohl (mp->sw_if_index); + vam->result_ready = 1; + } +} + +static void vl_api_tap_modify_reply_t_handler_json + (vl_api_tap_modify_reply_t * mp) +{ + vat_main_t *vam = &vat_main; + vat_json_node_t node; + + vat_json_init_object (&node); + vat_json_object_add_int (&node, "retval", ntohl (mp->retval)); + vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index)); + + vat_json_print (vam->ofp, &node); + vat_json_free (&node); + + vam->retval = ntohl (mp->retval); + vam->result_ready = 1; +} + +static void +vl_api_tap_delete_reply_t_handler (vl_api_tap_delete_reply_t * mp) +{ + vat_main_t *vam = &vat_main; + i32 retval = ntohl (mp->retval); + if (vam->async_mode) + { + vam->async_errors += (retval < 0); + } + else + { + vam->retval = retval; + vam->result_ready = 1; + } +} + +static void vl_api_tap_delete_reply_t_handler_json + (vl_api_tap_delete_reply_t * mp) +{ + vat_main_t *vam = &vat_main; + vat_json_node_t node; + + vat_json_init_object (&node); + vat_json_object_add_int (&node, "retval", ntohl (mp->retval)); + + vat_json_print (vam->ofp, &node); + vat_json_free (&node); + + vam->retval = ntohl (mp->retval); + vam->result_ready = 1; +} + +static void vl_api_mpls_tunnel_add_del_reply_t_handler + (vl_api_mpls_tunnel_add_del_reply_t * mp) +{ + vat_main_t *vam = &vat_main; + i32 retval = ntohl (mp->retval); + if (vam->async_mode) + { + vam->async_errors += (retval < 0); + } + else + { + vam->retval = retval; + vam->result_ready = 1; + } +} + +static void vl_api_mpls_tunnel_add_del_reply_t_handler_json + (vl_api_mpls_tunnel_add_del_reply_t * mp) +{ + vat_main_t *vam = &vat_main; + vat_json_node_t node; + + vat_json_init_object (&node); + vat_json_object_add_int (&node, "retval", ntohl (mp->retval)); + vat_json_object_add_uint (&node, "tunnel_sw_if_index", + ntohl (mp->sw_if_index)); + + vat_json_print (vam->ofp, &node); + vat_json_free (&node); + + vam->retval = ntohl (mp->retval); + vam->result_ready = 1; +} + +static void vl_api_l2tpv3_create_tunnel_reply_t_handler + (vl_api_l2tpv3_create_tunnel_reply_t * mp) +{ + vat_main_t *vam = &vat_main; + i32 retval = ntohl (mp->retval); + if (vam->async_mode) + { + vam->async_errors += (retval < 0); + } + else + { + vam->retval = retval; + vam->sw_if_index = ntohl (mp->sw_if_index); + vam->result_ready = 1; + } +} + +static void vl_api_l2tpv3_create_tunnel_reply_t_handler_json + (vl_api_l2tpv3_create_tunnel_reply_t * mp) +{ + vat_main_t *vam = &vat_main; + vat_json_node_t node; + + vat_json_init_object (&node); + vat_json_object_add_int (&node, "retval", ntohl (mp->retval)); + vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index)); + + vat_json_print (vam->ofp, &node); + vat_json_free (&node); + + vam->retval = ntohl (mp->retval); + vam->result_ready = 1; +} + + +static void vl_api_lisp_add_del_locator_set_reply_t_handler + (vl_api_lisp_add_del_locator_set_reply_t * mp) +{ + vat_main_t *vam = &vat_main; + i32 retval = ntohl (mp->retval); + if (vam->async_mode) + { + vam->async_errors += (retval < 0); + } + else + { + vam->retval = retval; + vam->result_ready = 1; + } +} + +static void vl_api_lisp_add_del_locator_set_reply_t_handler_json + (vl_api_lisp_add_del_locator_set_reply_t * mp) +{ + vat_main_t *vam = &vat_main; + vat_json_node_t node; + + vat_json_init_object (&node); + vat_json_object_add_int (&node, "retval", ntohl (mp->retval)); + vat_json_object_add_uint (&node, "locator_set_index", ntohl (mp->ls_index)); + + vat_json_print (vam->ofp, &node); + vat_json_free (&node); + + vam->retval = ntohl (mp->retval); + vam->result_ready = 1; +} + +static void vl_api_vxlan_add_del_tunnel_reply_t_handler + (vl_api_vxlan_add_del_tunnel_reply_t * mp) +{ + vat_main_t *vam = &vat_main; + i32 retval = ntohl (mp->retval); + if (vam->async_mode) + { + vam->async_errors += (retval < 0); + } + else + { + vam->retval = retval; + vam->sw_if_index = ntohl (mp->sw_if_index); + vam->result_ready = 1; + } +} + +static void vl_api_vxlan_add_del_tunnel_reply_t_handler_json + (vl_api_vxlan_add_del_tunnel_reply_t * mp) +{ + vat_main_t *vam = &vat_main; + vat_json_node_t node; + + vat_json_init_object (&node); + vat_json_object_add_int (&node, "retval", ntohl (mp->retval)); + vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index)); + + vat_json_print (vam->ofp, &node); + vat_json_free (&node); + + vam->retval = ntohl (mp->retval); + vam->result_ready = 1; +} + +static void vl_api_gre_add_del_tunnel_reply_t_handler + (vl_api_gre_add_del_tunnel_reply_t * mp) +{ + vat_main_t *vam = &vat_main; + i32 retval = ntohl (mp->retval); + if (vam->async_mode) + { + vam->async_errors += (retval < 0); + } + else + { + vam->retval = retval; + vam->sw_if_index = ntohl (mp->sw_if_index); + vam->result_ready = 1; + } +} + +static void vl_api_gre_add_del_tunnel_reply_t_handler_json + (vl_api_gre_add_del_tunnel_reply_t * mp) +{ + vat_main_t *vam = &vat_main; + vat_json_node_t node; + + vat_json_init_object (&node); + vat_json_object_add_int (&node, "retval", ntohl (mp->retval)); + vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index)); + + vat_json_print (vam->ofp, &node); + vat_json_free (&node); + + vam->retval = ntohl (mp->retval); + vam->result_ready = 1; +} + +static void vl_api_create_vhost_user_if_reply_t_handler + (vl_api_create_vhost_user_if_reply_t * mp) +{ + vat_main_t *vam = &vat_main; + i32 retval = ntohl (mp->retval); + if (vam->async_mode) + { + vam->async_errors += (retval < 0); + } + else + { + vam->retval = retval; + vam->sw_if_index = ntohl (mp->sw_if_index); + vam->result_ready = 1; + } +} + +static void vl_api_create_vhost_user_if_reply_t_handler_json + (vl_api_create_vhost_user_if_reply_t * mp) +{ + vat_main_t *vam = &vat_main; + vat_json_node_t node; + + vat_json_init_object (&node); + vat_json_object_add_int (&node, "retval", ntohl (mp->retval)); + vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index)); + + vat_json_print (vam->ofp, &node); + vat_json_free (&node); + + vam->retval = ntohl (mp->retval); + vam->result_ready = 1; +} + +static void vl_api_ip_address_details_t_handler + (vl_api_ip_address_details_t * mp) +{ + vat_main_t *vam = &vat_main; + static ip_address_details_t empty_ip_address_details = { {0} }; + ip_address_details_t *address = NULL; + ip_details_t *current_ip_details = NULL; + ip_details_t *details = NULL; + + details = vam->ip_details_by_sw_if_index[vam->is_ipv6]; + + if (!details || vam->current_sw_if_index >= vec_len (details) + || !details[vam->current_sw_if_index].present) + { + errmsg ("ip address details arrived but not stored"); + errmsg ("ip_dump should be called first"); + return; + } + + current_ip_details = vec_elt_at_index (details, vam->current_sw_if_index); + +#define addresses (current_ip_details->addr) + + vec_validate_init_empty (addresses, vec_len (addresses), + empty_ip_address_details); + + address = vec_elt_at_index (addresses, vec_len (addresses) - 1); + + clib_memcpy (&address->ip, &mp->ip, sizeof (address->ip)); + address->prefix_length = mp->prefix_length; +#undef addresses +} + +static void vl_api_ip_address_details_t_handler_json + (vl_api_ip_address_details_t * mp) +{ + vat_main_t *vam = &vat_main; + vat_json_node_t *node = NULL; + struct in6_addr ip6; + struct in_addr ip4; + + if (VAT_JSON_ARRAY != vam->json_tree.type) + { + ASSERT (VAT_JSON_NONE == vam->json_tree.type); + vat_json_init_array (&vam->json_tree); + } + node = vat_json_array_add (&vam->json_tree); + + vat_json_init_object (node); + if (vam->is_ipv6) + { + clib_memcpy (&ip6, mp->ip, sizeof (ip6)); + vat_json_object_add_ip6 (node, "ip", ip6); + } + else + { + clib_memcpy (&ip4, mp->ip, sizeof (ip4)); + vat_json_object_add_ip4 (node, "ip", ip4); + } + vat_json_object_add_uint (node, "prefix_length", mp->prefix_length); +} + +static void +vl_api_ip_details_t_handler (vl_api_ip_details_t * mp) +{ + vat_main_t *vam = &vat_main; + static ip_details_t empty_ip_details = { 0 }; + ip_details_t *ip = NULL; + u32 sw_if_index = ~0; + + sw_if_index = ntohl (mp->sw_if_index); + + vec_validate_init_empty (vam->ip_details_by_sw_if_index[vam->is_ipv6], + sw_if_index, empty_ip_details); + + ip = vec_elt_at_index (vam->ip_details_by_sw_if_index[vam->is_ipv6], + sw_if_index); + + ip->present = 1; +} + +static void +vl_api_ip_details_t_handler_json (vl_api_ip_details_t * mp) +{ + vat_main_t *vam = &vat_main; + + if (VAT_JSON_ARRAY != vam->json_tree.type) + { + ASSERT (VAT_JSON_NONE == vam->json_tree.type); + vat_json_init_array (&vam->json_tree); + } + vat_json_array_add_uint (&vam->json_tree, + clib_net_to_host_u32 (mp->sw_if_index)); +} + +static void vl_api_map_domain_details_t_handler_json + (vl_api_map_domain_details_t * mp) +{ + vat_json_node_t *node = NULL; + vat_main_t *vam = &vat_main; + struct in6_addr ip6; + struct in_addr ip4; + + if (VAT_JSON_ARRAY != vam->json_tree.type) + { + ASSERT (VAT_JSON_NONE == vam->json_tree.type); + vat_json_init_array (&vam->json_tree); + } + + node = vat_json_array_add (&vam->json_tree); + vat_json_init_object (node); + + vat_json_object_add_uint (node, "domain_index", + clib_net_to_host_u32 (mp->domain_index)); + clib_memcpy (&ip6, mp->ip6_prefix, sizeof (ip6)); + vat_json_object_add_ip6 (node, "ip6_prefix", ip6); + clib_memcpy (&ip4, mp->ip4_prefix, sizeof (ip4)); + vat_json_object_add_ip4 (node, "ip4_prefix", ip4); + clib_memcpy (&ip6, mp->ip6_src, sizeof (ip6)); + vat_json_object_add_ip6 (node, "ip6_src", ip6); + vat_json_object_add_int (node, "ip6_prefix_len", mp->ip6_prefix_len); + vat_json_object_add_int (node, "ip4_prefix_len", mp->ip4_prefix_len); + vat_json_object_add_int (node, "ip6_src_len", mp->ip6_src_len); + vat_json_object_add_int (node, "ea_bits_len", mp->ea_bits_len); + vat_json_object_add_int (node, "psid_offset", mp->psid_offset); + vat_json_object_add_int (node, "psid_length", mp->psid_length); + vat_json_object_add_uint (node, "flags", mp->flags); + vat_json_object_add_uint (node, "mtu", clib_net_to_host_u16 (mp->mtu)); + vat_json_object_add_int (node, "is_translation", mp->is_translation); +} + +static void vl_api_map_domain_details_t_handler + (vl_api_map_domain_details_t * mp) +{ + vat_main_t *vam = &vat_main; + + if (mp->is_translation) + { + print (vam->ofp, + "* %U/%d (ipv4-prefix) %U/%d (ipv6-prefix) %U/%d (ip6-src) index: %u", + format_ip4_address, mp->ip4_prefix, mp->ip4_prefix_len, + format_ip6_address, mp->ip6_prefix, mp->ip6_prefix_len, + format_ip6_address, mp->ip6_src, mp->ip6_src_len, + clib_net_to_host_u32 (mp->domain_index)); + } + else + { + print (vam->ofp, + "* %U/%d (ipv4-prefix) %U/%d (ipv6-prefix) %U (ip6-src) index: %u", + format_ip4_address, mp->ip4_prefix, mp->ip4_prefix_len, + format_ip6_address, mp->ip6_prefix, mp->ip6_prefix_len, + format_ip6_address, mp->ip6_src, + clib_net_to_host_u32 (mp->domain_index)); + } + print (vam->ofp, " ea-len %d psid-offset %d psid-len %d mtu %d %s", + mp->ea_bits_len, mp->psid_offset, mp->psid_length, mp->mtu, + mp->is_translation ? "map-t" : ""); +} + +static void vl_api_map_rule_details_t_handler_json + (vl_api_map_rule_details_t * mp) +{ + struct in6_addr ip6; + vat_json_node_t *node = NULL; + vat_main_t *vam = &vat_main; + + if (VAT_JSON_ARRAY != vam->json_tree.type) + { + ASSERT (VAT_JSON_NONE == vam->json_tree.type); + vat_json_init_array (&vam->json_tree); + } + + node = vat_json_array_add (&vam->json_tree); + vat_json_init_object (node); + + vat_json_object_add_uint (node, "psid", clib_net_to_host_u16 (mp->psid)); + clib_memcpy (&ip6, mp->ip6_dst, sizeof (ip6)); + vat_json_object_add_ip6 (node, "ip6_dst", ip6); +} + +static void +vl_api_map_rule_details_t_handler (vl_api_map_rule_details_t * mp) +{ + vat_main_t *vam = &vat_main; + print (vam->ofp, " %d (psid) %U (ip6-dst)", + clib_net_to_host_u16 (mp->psid), format_ip6_address, mp->ip6_dst); +} + +static void +vl_api_dhcp_compl_event_t_handler (vl_api_dhcp_compl_event_t * mp) +{ + errmsg ("DHCP compl event: pid %d %s hostname %s host_addr %U " + "router_addr %U host_mac %U", + mp->pid, mp->is_ipv6 ? "ipv6" : "ipv4", mp->hostname, + format_ip4_address, &mp->host_address, + format_ip4_address, &mp->router_address, + format_ethernet_address, mp->host_mac); +} + +static void vl_api_dhcp_compl_event_t_handler_json + (vl_api_dhcp_compl_event_t * mp) +{ + /* JSON output not supported */ +} + +static void +set_simple_interface_counter (u8 vnet_counter_type, u32 sw_if_index, + u32 counter) +{ + vat_main_t *vam = &vat_main; + static u64 default_counter = 0; + + vec_validate_init_empty (vam->simple_interface_counters, vnet_counter_type, + NULL); + vec_validate_init_empty (vam->simple_interface_counters[vnet_counter_type], + sw_if_index, default_counter); + vam->simple_interface_counters[vnet_counter_type][sw_if_index] = counter; +} + +static void +set_combined_interface_counter (u8 vnet_counter_type, u32 sw_if_index, + interface_counter_t counter) +{ + vat_main_t *vam = &vat_main; + static interface_counter_t default_counter = { 0, }; + + vec_validate_init_empty (vam->combined_interface_counters, + vnet_counter_type, NULL); + vec_validate_init_empty (vam->combined_interface_counters + [vnet_counter_type], sw_if_index, default_counter); + vam->combined_interface_counters[vnet_counter_type][sw_if_index] = counter; +} + +static void vl_api_vnet_interface_counters_t_handler + (vl_api_vnet_interface_counters_t * mp) +{ + /* not supported */ +} + +static void vl_api_vnet_interface_counters_t_handler_json + (vl_api_vnet_interface_counters_t * mp) +{ + interface_counter_t counter; + vlib_counter_t *v; + u64 *v_packets; + u64 packets; + u32 count; + u32 first_sw_if_index; + int i; + + count = ntohl (mp->count); + first_sw_if_index = ntohl (mp->first_sw_if_index); + + if (!mp->is_combined) + { + v_packets = (u64 *) & mp->data; + for (i = 0; i < count; i++) + { + packets = + clib_net_to_host_u64 (clib_mem_unaligned (v_packets, u64)); + set_simple_interface_counter (mp->vnet_counter_type, + first_sw_if_index + i, packets); + v_packets++; + } + } + else + { + v = (vlib_counter_t *) & mp->data; + for (i = 0; i < count; i++) + { + counter.packets = + clib_net_to_host_u64 (clib_mem_unaligned (&v->packets, u64)); + counter.bytes = + clib_net_to_host_u64 (clib_mem_unaligned (&v->bytes, u64)); + set_combined_interface_counter (mp->vnet_counter_type, + first_sw_if_index + i, counter); + v++; + } + } +} + +static u32 +ip4_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id) +{ + vat_main_t *vam = &vat_main; + u32 i; + + for (i = 0; i < vec_len (vam->ip4_fib_counters_vrf_id_by_index); i++) + { + if (vam->ip4_fib_counters_vrf_id_by_index[i] == vrf_id) + { + return i; + } + } + return ~0; +} + +static u32 +ip6_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id) +{ + vat_main_t *vam = &vat_main; + u32 i; + + for (i = 0; i < vec_len (vam->ip6_fib_counters_vrf_id_by_index); i++) + { + if (vam->ip6_fib_counters_vrf_id_by_index[i] == vrf_id) + { + return i; + } + } + return ~0; +} + +static void vl_api_vnet_ip4_fib_counters_t_handler + (vl_api_vnet_ip4_fib_counters_t * mp) +{ + /* not supported */ +} + +static void vl_api_vnet_ip4_fib_counters_t_handler_json + (vl_api_vnet_ip4_fib_counters_t * mp) +{ + vat_main_t *vam = &vat_main; + vl_api_ip4_fib_counter_t *v; + ip4_fib_counter_t *counter; + struct in_addr ip4; + u32 vrf_id; + u32 vrf_index; + u32 count; + int i; + + vrf_id = ntohl (mp->vrf_id); + vrf_index = ip4_fib_counters_get_vrf_index_by_vrf_id (vrf_id); + if (~0 == vrf_index) + { + vrf_index = vec_len (vam->ip4_fib_counters_vrf_id_by_index); + vec_validate (vam->ip4_fib_counters_vrf_id_by_index, vrf_index); + vam->ip4_fib_counters_vrf_id_by_index[vrf_index] = vrf_id; + vec_validate (vam->ip4_fib_counters, vrf_index); + vam->ip4_fib_counters[vrf_index] = NULL; + } + + vec_free (vam->ip4_fib_counters[vrf_index]); + v = (vl_api_ip4_fib_counter_t *) & mp->c; + count = ntohl (mp->count); + for (i = 0; i < count; i++) + { + vec_validate (vam->ip4_fib_counters[vrf_index], i); + counter = &vam->ip4_fib_counters[vrf_index][i]; + clib_memcpy (&ip4, &v->address, sizeof (ip4)); + counter->address = ip4; + counter->address_length = v->address_length; + counter->packets = clib_net_to_host_u64 (v->packets); + counter->bytes = clib_net_to_host_u64 (v->bytes); + v++; + } +} + +static void vl_api_vnet_ip6_fib_counters_t_handler + (vl_api_vnet_ip6_fib_counters_t * mp) +{ + /* not supported */ +} + +static void vl_api_vnet_ip6_fib_counters_t_handler_json + (vl_api_vnet_ip6_fib_counters_t * mp) +{ + vat_main_t *vam = &vat_main; + vl_api_ip6_fib_counter_t *v; + ip6_fib_counter_t *counter; + struct in6_addr ip6; + u32 vrf_id; + u32 vrf_index; + u32 count; + int i; + + vrf_id = ntohl (mp->vrf_id); + vrf_index = ip6_fib_counters_get_vrf_index_by_vrf_id (vrf_id); + if (~0 == vrf_index) + { + vrf_index = vec_len (vam->ip6_fib_counters_vrf_id_by_index); + vec_validate (vam->ip6_fib_counters_vrf_id_by_index, vrf_index); + vam->ip6_fib_counters_vrf_id_by_index[vrf_index] = vrf_id; + vec_validate (vam->ip6_fib_counters, vrf_index); + vam->ip6_fib_counters[vrf_index] = NULL; + } + + vec_free (vam->ip6_fib_counters[vrf_index]); + v = (vl_api_ip6_fib_counter_t *) & mp->c; + count = ntohl (mp->count); + for (i = 0; i < count; i++) + { + vec_validate (vam->ip6_fib_counters[vrf_index], i); + counter = &vam->ip6_fib_counters[vrf_index][i]; + clib_memcpy (&ip6, &v->address, sizeof (ip6)); + counter->address = ip6; + counter->address_length = v->address_length; + counter->packets = clib_net_to_host_u64 (v->packets); + counter->bytes = clib_net_to_host_u64 (v->bytes); + v++; + } +} + +static void vl_api_get_first_msg_id_reply_t_handler + (vl_api_get_first_msg_id_reply_t * mp) +{ + vat_main_t *vam = &vat_main; + i32 retval = ntohl (mp->retval); + + if (vam->async_mode) + { + vam->async_errors += (retval < 0); + } + else + { + vam->retval = retval; + vam->result_ready = 1; + } + if (retval >= 0) + { + errmsg ("first message id %d", ntohs (mp->first_msg_id)); + } +} + +static void vl_api_get_first_msg_id_reply_t_handler_json + (vl_api_get_first_msg_id_reply_t * mp) +{ + vat_main_t *vam = &vat_main; + vat_json_node_t node; + + vat_json_init_object (&node); + vat_json_object_add_int (&node, "retval", ntohl (mp->retval)); + vat_json_object_add_uint (&node, "first_msg_id", + (uint) ntohs (mp->first_msg_id)); + + vat_json_print (vam->ofp, &node); + vat_json_free (&node); + + vam->retval = ntohl (mp->retval); + vam->result_ready = 1; +} + +static void vl_api_get_node_graph_reply_t_handler + (vl_api_get_node_graph_reply_t * mp) +{ + vat_main_t *vam = &vat_main; + api_main_t *am = &api_main; + i32 retval = ntohl (mp->retval); + u8 *pvt_copy, *reply; + void *oldheap; + vlib_node_t *node; + int i; + + if (vam->async_mode) + { + vam->async_errors += (retval < 0); + } + else + { + vam->retval = retval; + vam->result_ready = 1; + } + + /* "Should never happen..." */ + if (retval != 0) + return; + + reply = (u8 *) (mp->reply_in_shmem); + pvt_copy = vec_dup (reply); + + /* Toss the shared-memory original... */ + pthread_mutex_lock (&am->vlib_rp->mutex); + oldheap = svm_push_data_heap (am->vlib_rp); + + vec_free (reply); + + svm_pop_heap (oldheap); + pthread_mutex_unlock (&am->vlib_rp->mutex); + + if (vam->graph_nodes) + { + hash_free (vam->graph_node_index_by_name); + + for (i = 0; i < vec_len (vam->graph_nodes); i++) + { + node = vam->graph_nodes[i]; + vec_free (node->name); + vec_free (node->next_nodes); + vec_free (node); + } + vec_free (vam->graph_nodes); + } + + vam->graph_node_index_by_name = hash_create_string (0, sizeof (uword)); + vam->graph_nodes = vlib_node_unserialize (pvt_copy); + vec_free (pvt_copy); + + for (i = 0; i < vec_len (vam->graph_nodes); i++) + { + node = vam->graph_nodes[i]; + hash_set_mem (vam->graph_node_index_by_name, node->name, i); + } +} + +static void vl_api_get_node_graph_reply_t_handler_json + (vl_api_get_node_graph_reply_t * mp) +{ + vat_main_t *vam = &vat_main; + api_main_t *am = &api_main; + void *oldheap; + vat_json_node_t node; + u8 *reply; + + /* $$$$ make this real? */ + vat_json_init_object (&node); + vat_json_object_add_int (&node, "retval", ntohl (mp->retval)); + vat_json_object_add_uint (&node, "reply_in_shmem", mp->reply_in_shmem); + + reply = (u8 *) (mp->reply_in_shmem); + + /* Toss the shared-memory original... */ + pthread_mutex_lock (&am->vlib_rp->mutex); + oldheap = svm_push_data_heap (am->vlib_rp); + + vec_free (reply); + + svm_pop_heap (oldheap); + pthread_mutex_unlock (&am->vlib_rp->mutex); + + vat_json_print (vam->ofp, &node); + vat_json_free (&node); + + vam->retval = ntohl (mp->retval); + vam->result_ready = 1; +} + +static void +vl_api_lisp_locator_details_t_handler (vl_api_lisp_locator_details_t * mp) +{ + vat_main_t *vam = &vat_main; + u8 *s = 0; + + if (mp->local) + { + s = format (s, "%=16d%=16d%=16d", + ntohl (mp->sw_if_index), mp->priority, mp->weight); + } + else + { + s = format (s, "%=16U%=16d%=16d", + mp->is_ipv6 ? format_ip6_address : + format_ip4_address, + mp->ip_address, mp->priority, mp->weight); + } + + print (vam->ofp, "%v", s); + vec_free (s); +} + +static void +vl_api_lisp_locator_details_t_handler_json (vl_api_lisp_locator_details_t * + mp) +{ + vat_main_t *vam = &vat_main; + vat_json_node_t *node = NULL; + struct in6_addr ip6; + struct in_addr ip4; + + if (VAT_JSON_ARRAY != vam->json_tree.type) + { + ASSERT (VAT_JSON_NONE == vam->json_tree.type); + vat_json_init_array (&vam->json_tree); + } + node = vat_json_array_add (&vam->json_tree); + vat_json_init_object (node); + + vat_json_object_add_uint (node, "local", mp->local ? 1 : 0); + vat_json_object_add_uint (node, "priority", mp->priority); + vat_json_object_add_uint (node, "weight", mp->weight); + + if (mp->local) + vat_json_object_add_uint (node, "sw_if_index", + clib_net_to_host_u32 (mp->sw_if_index)); + else + { + if (mp->is_ipv6) + { + clib_memcpy (&ip6, mp->ip_address, sizeof (ip6)); + vat_json_object_add_ip6 (node, "address", ip6); + } + else + { + clib_memcpy (&ip4, mp->ip_address, sizeof (ip4)); + vat_json_object_add_ip4 (node, "address", ip4); + } + } +} + +static void +vl_api_lisp_locator_set_details_t_handler (vl_api_lisp_locator_set_details_t * + mp) +{ + vat_main_t *vam = &vat_main; + u8 *ls_name = 0; + + ls_name = format (0, "%s", mp->ls_name); + + print (vam->ofp, "%=10d%=15v", clib_net_to_host_u32 (mp->ls_index), + ls_name); + vec_free (ls_name); +} + +static void + vl_api_lisp_locator_set_details_t_handler_json + (vl_api_lisp_locator_set_details_t * mp) +{ + vat_main_t *vam = &vat_main; + vat_json_node_t *node = 0; + u8 *ls_name = 0; + + ls_name = format (0, "%s", mp->ls_name); + vec_add1 (ls_name, 0); + + if (VAT_JSON_ARRAY != vam->json_tree.type) + { + ASSERT (VAT_JSON_NONE == vam->json_tree.type); + vat_json_init_array (&vam->json_tree); + } + node = vat_json_array_add (&vam->json_tree); + + vat_json_init_object (node); + vat_json_object_add_string_copy (node, "ls_name", ls_name); + vat_json_object_add_uint (node, "ls_index", + clib_net_to_host_u32 (mp->ls_index)); + vec_free (ls_name); +} + +static u8 * +format_lisp_flat_eid (u8 * s, va_list * args) +{ + u32 type = va_arg (*args, u32); + u8 *eid = va_arg (*args, u8 *); + u32 eid_len = va_arg (*args, u32); + + switch (type) + { + case 0: + return format (s, "%U/%d", format_ip4_address, eid, eid_len); + case 1: + return format (s, "%U/%d", format_ip6_address, eid, eid_len); + case 2: + return format (s, "%U", format_ethernet_address, eid); + } + return 0; +} + +static u8 * +format_lisp_eid_vat (u8 * s, va_list * args) +{ + u32 type = va_arg (*args, u32); + u8 *eid = va_arg (*args, u8 *); + u32 eid_len = va_arg (*args, u32); + u8 *seid = va_arg (*args, u8 *); + u32 seid_len = va_arg (*args, u32); + u32 is_src_dst = va_arg (*args, u32); + + if (is_src_dst) + s = format (s, "%U|", format_lisp_flat_eid, type, seid, seid_len); + + s = format (s, "%U", format_lisp_flat_eid, type, eid, eid_len); + + return s; +} + +static void +vl_api_lisp_eid_table_details_t_handler (vl_api_lisp_eid_table_details_t * mp) +{ + vat_main_t *vam = &vat_main; + u8 *s = 0, *eid = 0; + + if (~0 == mp->locator_set_index) + s = format (0, "action: %d", mp->action); + else + s = format (0, "%d", clib_net_to_host_u32 (mp->locator_set_index)); + + eid = format (0, "%U", format_lisp_eid_vat, + mp->eid_type, + mp->eid, + mp->eid_prefix_len, + mp->seid, mp->seid_prefix_len, mp->is_src_dst); + vec_add1 (eid, 0); + + print (vam->ofp, "[%d] %-35s%-20s%-30s%-20d%-20d%-10d%-20s", + clib_net_to_host_u32 (mp->vni), + eid, + mp->is_local ? "local" : "remote", + s, clib_net_to_host_u32 (mp->ttl), mp->authoritative, + clib_net_to_host_u16 (mp->key_id), mp->key); + + vec_free (s); + vec_free (eid); +} + +static void +vl_api_lisp_eid_table_details_t_handler_json (vl_api_lisp_eid_table_details_t + * mp) +{ + vat_main_t *vam = &vat_main; + vat_json_node_t *node = 0; + u8 *eid = 0; + + if (VAT_JSON_ARRAY != vam->json_tree.type) + { + ASSERT (VAT_JSON_NONE == vam->json_tree.type); + vat_json_init_array (&vam->json_tree); + } + node = vat_json_array_add (&vam->json_tree); + + vat_json_init_object (node); + if (~0 == mp->locator_set_index) + vat_json_object_add_uint (node, "action", mp->action); + else + vat_json_object_add_uint (node, "locator_set_index", + clib_net_to_host_u32 (mp->locator_set_index)); + + vat_json_object_add_uint (node, "is_local", mp->is_local ? 1 : 0); + eid = format (0, "%U", format_lisp_eid_vat, + mp->eid_type, + mp->eid, + mp->eid_prefix_len, + mp->seid, mp->seid_prefix_len, mp->is_src_dst); + vec_add1 (eid, 0); + vat_json_object_add_string_copy (node, "eid", eid); + vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni)); + vat_json_object_add_uint (node, "ttl", clib_net_to_host_u32 (mp->ttl)); + vat_json_object_add_uint (node, "authoritative", (mp->authoritative)); + + if (mp->key_id) + { + vat_json_object_add_uint (node, "key_id", + clib_net_to_host_u16 (mp->key_id)); + vat_json_object_add_string_copy (node, "key", mp->key); + } + vec_free (eid); +} + +static void + vl_api_lisp_eid_table_map_details_t_handler + (vl_api_lisp_eid_table_map_details_t * mp) +{ + vat_main_t *vam = &vat_main; + + u8 *line = format (0, "%=10d%=10d", + clib_net_to_host_u32 (mp->vni), + clib_net_to_host_u32 (mp->dp_table)); + print (vam->ofp, "%v", line); + vec_free (line); +} + +static void + vl_api_lisp_eid_table_map_details_t_handler_json + (vl_api_lisp_eid_table_map_details_t * mp) +{ + vat_main_t *vam = &vat_main; + vat_json_node_t *node = NULL; + + if (VAT_JSON_ARRAY != vam->json_tree.type) + { + ASSERT (VAT_JSON_NONE == vam->json_tree.type); + vat_json_init_array (&vam->json_tree); + } + node = vat_json_array_add (&vam->json_tree); + vat_json_init_object (node); + vat_json_object_add_uint (node, "dp_table", + clib_net_to_host_u32 (mp->dp_table)); + vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni)); +} + +static void + vl_api_lisp_eid_table_vni_details_t_handler + (vl_api_lisp_eid_table_vni_details_t * mp) +{ + vat_main_t *vam = &vat_main; + + u8 *line = format (0, "%d", clib_net_to_host_u32 (mp->vni)); + print (vam->ofp, "%v", line); + vec_free (line); +} + +static void + vl_api_lisp_eid_table_vni_details_t_handler_json + (vl_api_lisp_eid_table_vni_details_t * mp) +{ + vat_main_t *vam = &vat_main; + vat_json_node_t *node = NULL; + + if (VAT_JSON_ARRAY != vam->json_tree.type) + { + ASSERT (VAT_JSON_NONE == vam->json_tree.type); + vat_json_init_array (&vam->json_tree); + } + node = vat_json_array_add (&vam->json_tree); + vat_json_init_object (node); + vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni)); +} + +static u8 * +format_decap_next (u8 * s, va_list * args) +{ + u32 next_index = va_arg (*args, u32); + + switch (next_index) + { + case LISP_GPE_INPUT_NEXT_DROP: + return format (s, "drop"); + case LISP_GPE_INPUT_NEXT_IP4_INPUT: + return format (s, "ip4"); + case LISP_GPE_INPUT_NEXT_IP6_INPUT: + return format (s, "ip6"); + default: + return format (s, "unknown %d", next_index); + } + return s; +} + +static void +vl_api_lisp_gpe_tunnel_details_t_handler (vl_api_lisp_gpe_tunnel_details_t * + mp) +{ + vat_main_t *vam = &vat_main; + u8 *iid_str; + u8 *flag_str = NULL; + + iid_str = format (0, "%d (0x%x)", ntohl (mp->iid), ntohl (mp->iid)); + +#define _(n,v) if (mp->flags & v) flag_str = format (flag_str, "%s-bit ", #n); + foreach_lisp_gpe_flag_bit; +#undef _ + + print (vam->ofp, "%=20d%=30U%=16U%=16d%=16d%=16U" + "%=16d%=16d%=16sd=16d%=16s%=16s", + mp->tunnels, + mp->is_ipv6 ? format_ip6_address : format_ip4_address, + mp->source_ip, + mp->is_ipv6 ? format_ip6_address : format_ip4_address, + mp->destination_ip, + ntohl (mp->encap_fib_id), + ntohl (mp->decap_fib_id), + format_decap_next, ntohl (mp->dcap_next), + mp->ver_res >> 6, + flag_str, mp->next_protocol, mp->ver_res, mp->res, iid_str); + + vec_free (iid_str); +} + +static void + vl_api_lisp_gpe_tunnel_details_t_handler_json + (vl_api_lisp_gpe_tunnel_details_t * mp) +{ + vat_main_t *vam = &vat_main; + vat_json_node_t *node = NULL; + struct in6_addr ip6; + struct in_addr ip4; + u8 *next_decap_str; + + next_decap_str = format (0, "%U", format_decap_next, htonl (mp->dcap_next)); + + if (VAT_JSON_ARRAY != vam->json_tree.type) + { + ASSERT (VAT_JSON_NONE == vam->json_tree.type); + vat_json_init_array (&vam->json_tree); + } + node = vat_json_array_add (&vam->json_tree); + + vat_json_init_object (node); + vat_json_object_add_uint (node, "tunel", mp->tunnels); + if (mp->is_ipv6) + { + clib_memcpy (&ip6, mp->source_ip, sizeof (ip6)); + vat_json_object_add_ip6 (node, "source address", ip6); + clib_memcpy (&ip6, mp->destination_ip, sizeof (ip6)); + vat_json_object_add_ip6 (node, "destination address", ip6); + } + else + { + clib_memcpy (&ip4, mp->source_ip, sizeof (ip4)); + vat_json_object_add_ip4 (node, "source address", ip4); + clib_memcpy (&ip4, mp->destination_ip, sizeof (ip4)); + vat_json_object_add_ip4 (node, "destination address", ip4); + } + vat_json_object_add_uint (node, "fib encap", ntohl (mp->encap_fib_id)); + vat_json_object_add_uint (node, "fib decap", ntohl (mp->decap_fib_id)); + vat_json_object_add_string_copy (node, "decap next", next_decap_str); + vat_json_object_add_uint (node, "lisp version", mp->ver_res >> 6); + vat_json_object_add_uint (node, "flags", mp->flags); + vat_json_object_add_uint (node, "next protocol", mp->next_protocol); + vat_json_object_add_uint (node, "ver_res", mp->ver_res); + vat_json_object_add_uint (node, "res", mp->res); + vat_json_object_add_uint (node, "iid", ntohl (mp->iid)); + + vec_free (next_decap_str); +} + +static void + vl_api_show_lisp_map_register_state_reply_t_handler + (vl_api_show_lisp_map_register_state_reply_t * mp) +{ + vat_main_t *vam = &vat_main; + int retval = clib_net_to_host_u32 (mp->retval); + + print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled"); + + vam->retval = retval; + vam->result_ready = 1; +} + +static void + vl_api_show_lisp_map_register_state_reply_t_handler_json + (vl_api_show_lisp_map_register_state_reply_t * mp) +{ + vat_main_t *vam = &vat_main; + vat_json_node_t _node, *node = &_node; + int retval = clib_net_to_host_u32 (mp->retval); + + u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled"); + + vat_json_init_object (node); + vat_json_object_add_string_copy (node, "state", s); + + vat_json_print (vam->ofp, node); + vat_json_free (node); + + vam->retval = retval; + vam->result_ready = 1; + vec_free (s); +} + +static void + vl_api_show_lisp_rloc_probe_state_reply_t_handler + (vl_api_show_lisp_rloc_probe_state_reply_t * mp) +{ + vat_main_t *vam = &vat_main; + int retval = clib_net_to_host_u32 (mp->retval); + + if (retval) + goto end; + + print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled"); +end: + vam->retval = retval; + vam->result_ready = 1; +} + +static void + vl_api_show_lisp_rloc_probe_state_reply_t_handler_json + (vl_api_show_lisp_rloc_probe_state_reply_t * mp) +{ + vat_main_t *vam = &vat_main; + vat_json_node_t _node, *node = &_node; + int retval = clib_net_to_host_u32 (mp->retval); + + u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled"); + vat_json_init_object (node); + vat_json_object_add_string_copy (node, "state", s); + + vat_json_print (vam->ofp, node); + vat_json_free (node); + + vam->retval = retval; + vam->result_ready = 1; + vec_free (s); +} + +static void + vl_api_lisp_adjacencies_get_reply_t_handler + (vl_api_lisp_adjacencies_get_reply_t * mp) +{ + vat_main_t *vam = &vat_main; + u32 i, n; + int retval = clib_net_to_host_u32 (mp->retval); + vl_api_lisp_adjacency_t *a; + + if (retval) + goto end; + + n = clib_net_to_host_u32 (mp->count); + + for (i = 0; i < n; i++) + { + a = &mp->adjacencies[i]; + print (vam->ofp, "%U %40U", + format_lisp_flat_eid, a->eid_type, a->leid, a->leid_prefix_len, + format_lisp_flat_eid, a->eid_type, a->reid, a->reid_prefix_len); + } + +end: + vam->retval = retval; + vam->result_ready = 1; +} + +static void + vl_api_lisp_adjacencies_get_reply_t_handler_json + (vl_api_lisp_adjacencies_get_reply_t * mp) +{ + u8 *s = 0; + vat_main_t *vam = &vat_main; + vat_json_node_t *e = 0, root; + u32 i, n; + int retval = clib_net_to_host_u32 (mp->retval); + vl_api_lisp_adjacency_t *a; + + if (retval) + goto end; + + n = clib_net_to_host_u32 (mp->count); + vat_json_init_array (&root); + + for (i = 0; i < n; i++) + { + e = vat_json_array_add (&root); + a = &mp->adjacencies[i]; + + vat_json_init_object (e); + s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->leid, + a->leid_prefix_len); + vec_add1 (s, 0); + vat_json_object_add_string_copy (e, "leid", s); + vec_free (s); + + s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->reid, + a->reid_prefix_len); + vec_add1 (s, 0); + vat_json_object_add_string_copy (e, "reid", s); + vec_free (s); + } + + vat_json_print (vam->ofp, &root); + vat_json_free (&root); + +end: + vam->retval = retval; + vam->result_ready = 1; +} + +static void +vl_api_lisp_map_server_details_t_handler (vl_api_lisp_map_server_details_t + * mp) +{ + vat_main_t *vam = &vat_main; + + print (vam->ofp, "%=20U", + mp->is_ipv6 ? format_ip6_address : format_ip4_address, + mp->ip_address); +} + +static void + vl_api_lisp_map_server_details_t_handler_json + (vl_api_lisp_map_server_details_t * mp) +{ + vat_main_t *vam = &vat_main; + vat_json_node_t *node = NULL; + struct in6_addr ip6; + struct in_addr ip4; + + if (VAT_JSON_ARRAY != vam->json_tree.type) + { + ASSERT (VAT_JSON_NONE == vam->json_tree.type); + vat_json_init_array (&vam->json_tree); + } + node = vat_json_array_add (&vam->json_tree); + + vat_json_init_object (node); + if (mp->is_ipv6) + { + clib_memcpy (&ip6, mp->ip_address, sizeof (ip6)); + vat_json_object_add_ip6 (node, "map-server", ip6); + } + else + { + clib_memcpy (&ip4, mp->ip_address, sizeof (ip4)); + vat_json_object_add_ip4 (node, "map-server", ip4); + } +} + +static void +vl_api_lisp_map_resolver_details_t_handler (vl_api_lisp_map_resolver_details_t + * mp) +{ + vat_main_t *vam = &vat_main; + + print (vam->ofp, "%=20U", + mp->is_ipv6 ? format_ip6_address : format_ip4_address, + mp->ip_address); +} + +static void + vl_api_lisp_map_resolver_details_t_handler_json + (vl_api_lisp_map_resolver_details_t * mp) +{ + vat_main_t *vam = &vat_main; + vat_json_node_t *node = NULL; + struct in6_addr ip6; + struct in_addr ip4; + + if (VAT_JSON_ARRAY != vam->json_tree.type) + { + ASSERT (VAT_JSON_NONE == vam->json_tree.type); + vat_json_init_array (&vam->json_tree); + } + node = vat_json_array_add (&vam->json_tree); + + vat_json_init_object (node); + if (mp->is_ipv6) + { + clib_memcpy (&ip6, mp->ip_address, sizeof (ip6)); + vat_json_object_add_ip6 (node, "map resolver", ip6); + } + else + { + clib_memcpy (&ip4, mp->ip_address, sizeof (ip4)); + vat_json_object_add_ip4 (node, "map resolver", ip4); + } +} + +static void + vl_api_show_lisp_status_reply_t_handler + (vl_api_show_lisp_status_reply_t * mp) +{ + vat_main_t *vam = &vat_main; + i32 retval = ntohl (mp->retval); + + if (0 <= retval) + { + print (vam->ofp, "feature: %s\ngpe: %s", + mp->feature_status ? "enabled" : "disabled", + mp->gpe_status ? "enabled" : "disabled"); + } + + vam->retval = retval; + vam->result_ready = 1; +} + +static void + vl_api_show_lisp_status_reply_t_handler_json + (vl_api_show_lisp_status_reply_t * mp) +{ + vat_main_t *vam = &vat_main; + vat_json_node_t node; + u8 *gpe_status = NULL; + u8 *feature_status = NULL; + + gpe_status = format (0, "%s", mp->gpe_status ? "enabled" : "disabled"); + feature_status = format (0, "%s", + mp->feature_status ? "enabled" : "disabled"); + vec_add1 (gpe_status, 0); + vec_add1 (feature_status, 0); + + vat_json_init_object (&node); + vat_json_object_add_string_copy (&node, "gpe_status", gpe_status); + vat_json_object_add_string_copy (&node, "feature_status", feature_status); + + vec_free (gpe_status); + vec_free (feature_status); + + vat_json_print (vam->ofp, &node); + vat_json_free (&node); + + vam->retval = ntohl (mp->retval); + vam->result_ready = 1; +} + +static void + vl_api_lisp_get_map_request_itr_rlocs_reply_t_handler + (vl_api_lisp_get_map_request_itr_rlocs_reply_t * mp) +{ + vat_main_t *vam = &vat_main; + i32 retval = ntohl (mp->retval); + + if (retval >= 0) + { + print (vam->ofp, "%=20s", mp->locator_set_name); + } + + vam->retval = retval; + vam->result_ready = 1; +} + +static void + vl_api_lisp_get_map_request_itr_rlocs_reply_t_handler_json + (vl_api_lisp_get_map_request_itr_rlocs_reply_t * mp) +{ + vat_main_t *vam = &vat_main; + vat_json_node_t *node = NULL; + + if (VAT_JSON_ARRAY != vam->json_tree.type) + { + ASSERT (VAT_JSON_NONE == vam->json_tree.type); + vat_json_init_array (&vam->json_tree); + } + node = vat_json_array_add (&vam->json_tree); + + vat_json_init_object (node); + vat_json_object_add_string_copy (node, "itr-rlocs", mp->locator_set_name); + + vat_json_print (vam->ofp, node); + vat_json_free (node); + + vam->retval = ntohl (mp->retval); + vam->result_ready = 1; +} + +static u8 * +format_lisp_map_request_mode (u8 * s, va_list * args) +{ + u32 mode = va_arg (*args, u32); + + switch (mode) + { + case 0: + return format (0, "dst-only"); + case 1: + return format (0, "src-dst"); + } + return 0; +} + +static void + vl_api_show_lisp_map_request_mode_reply_t_handler + (vl_api_show_lisp_map_request_mode_reply_t * mp) +{ + vat_main_t *vam = &vat_main; + i32 retval = ntohl (mp->retval); + + if (0 <= retval) + { + u32 mode = mp->mode; + print (vam->ofp, "map_request_mode: %U", + format_lisp_map_request_mode, mode); + } + + vam->retval = retval; + vam->result_ready = 1; +} + +static void + vl_api_show_lisp_map_request_mode_reply_t_handler_json + (vl_api_show_lisp_map_request_mode_reply_t * mp) +{ + vat_main_t *vam = &vat_main; + vat_json_node_t node; + u8 *s = 0; + u32 mode; + + mode = mp->mode; + s = format (0, "%U", format_lisp_map_request_mode, mode); + vec_add1 (s, 0); + + vat_json_init_object (&node); + vat_json_object_add_string_copy (&node, "map_request_mode", s); + vat_json_print (vam->ofp, &node); + vat_json_free (&node); + + vec_free (s); + vam->retval = ntohl (mp->retval); + vam->result_ready = 1; +} + +static void +vl_api_show_lisp_pitr_reply_t_handler (vl_api_show_lisp_pitr_reply_t * mp) +{ + vat_main_t *vam = &vat_main; + i32 retval = ntohl (mp->retval); + + if (0 <= retval) + { + print (vam->ofp, "%-20s%-16s", + mp->status ? "enabled" : "disabled", + mp->status ? (char *) mp->locator_set_name : ""); + } + + vam->retval = retval; + vam->result_ready = 1; +} + +static void +vl_api_show_lisp_pitr_reply_t_handler_json (vl_api_show_lisp_pitr_reply_t * + mp) +{ + vat_main_t *vam = &vat_main; + vat_json_node_t node; + u8 *status = 0; + + status = format (0, "%s", mp->status ? "enabled" : "disabled"); + vec_add1 (status, 0); + + vat_json_init_object (&node); + vat_json_object_add_string_copy (&node, "status", status); + if (mp->status) + { + vat_json_object_add_string_copy (&node, "locator_set", + mp->locator_set_name); + } + + vec_free (status); + + vat_json_print (vam->ofp, &node); + vat_json_free (&node); + + vam->retval = ntohl (mp->retval); + vam->result_ready = 1; +} + +static u8 * +format_policer_type (u8 * s, va_list * va) +{ + u32 i = va_arg (*va, u32); + + if (i == SSE2_QOS_POLICER_TYPE_1R2C) + s = format (s, "1r2c"); + else if (i == SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697) + s = format (s, "1r3c"); + else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698) + s = format (s, "2r3c-2698"); + else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115) + s = format (s, "2r3c-4115"); + else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1) + s = format (s, "2r3c-mef5cf1"); + else + s = format (s, "ILLEGAL"); + return s; +} + +static u8 * +format_policer_rate_type (u8 * s, va_list * va) +{ + u32 i = va_arg (*va, u32); + + if (i == SSE2_QOS_RATE_KBPS) + s = format (s, "kbps"); + else if (i == SSE2_QOS_RATE_PPS) + s = format (s, "pps"); + else + s = format (s, "ILLEGAL"); + return s; +} + +static u8 * +format_policer_round_type (u8 * s, va_list * va) +{ + u32 i = va_arg (*va, u32); + + if (i == SSE2_QOS_ROUND_TO_CLOSEST) + s = format (s, "closest"); + else if (i == SSE2_QOS_ROUND_TO_UP) + s = format (s, "up"); + else if (i == SSE2_QOS_ROUND_TO_DOWN) + s = format (s, "down"); + else + s = format (s, "ILLEGAL"); + return s; +} + +static u8 * +format_policer_action_type (u8 * s, va_list * va) +{ + u32 i = va_arg (*va, u32); + + if (i == SSE2_QOS_ACTION_DROP) + s = format (s, "drop"); + else if (i == SSE2_QOS_ACTION_TRANSMIT) + s = format (s, "transmit"); + else if (i == SSE2_QOS_ACTION_MARK_AND_TRANSMIT) + s = format (s, "mark-and-transmit"); + else + s = format (s, "ILLEGAL"); + return s; +} + +static u8 * +format_dscp (u8 * s, va_list * va) +{ + u32 i = va_arg (*va, u32); + char *t = 0; + + switch (i) + { +#define _(v,f,str) case VNET_DSCP_##f: t = str; break; + foreach_vnet_dscp +#undef _ + default: + return format (s, "ILLEGAL"); + } + s = format (s, "%s", t); + return s; +} + +static void +vl_api_policer_details_t_handler (vl_api_policer_details_t * mp) +{ + vat_main_t *vam = &vat_main; + u8 *conform_dscp_str, *exceed_dscp_str, *violate_dscp_str; + + if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT) + conform_dscp_str = format (0, "%U", format_dscp, mp->conform_dscp); + else + conform_dscp_str = format (0, ""); + + if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT) + exceed_dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp); + else + exceed_dscp_str = format (0, ""); + + if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT) + violate_dscp_str = format (0, "%U", format_dscp, mp->violate_dscp); + else + violate_dscp_str = format (0, ""); + + print (vam->ofp, "Name \"%s\", type %U, cir %u, eir %u, cb %u, eb %u, " + "rate type %U, round type %U, %s rate, %s color-aware, " + "cir %u tok/period, pir %u tok/period, scale %u, cur lim %u, " + "cur bkt %u, ext lim %u, ext bkt %u, last update %llu" + "conform action %U%s, exceed action %U%s, violate action %U%s", + mp->name, + format_policer_type, mp->type, + ntohl (mp->cir), + ntohl (mp->eir), + clib_net_to_host_u64 (mp->cb), + clib_net_to_host_u64 (mp->eb), + format_policer_rate_type, mp->rate_type, + format_policer_round_type, mp->round_type, + mp->single_rate ? "single" : "dual", + mp->color_aware ? "is" : "not", + ntohl (mp->cir_tokens_per_period), + ntohl (mp->pir_tokens_per_period), + ntohl (mp->scale), + ntohl (mp->current_limit), + ntohl (mp->current_bucket), + ntohl (mp->extended_limit), + ntohl (mp->extended_bucket), + clib_net_to_host_u64 (mp->last_update_time), + format_policer_action_type, mp->conform_action_type, + conform_dscp_str, + format_policer_action_type, mp->exceed_action_type, + exceed_dscp_str, + format_policer_action_type, mp->violate_action_type, + violate_dscp_str); + + vec_free (conform_dscp_str); + vec_free (exceed_dscp_str); + vec_free (violate_dscp_str); +} + +static void vl_api_policer_details_t_handler_json + (vl_api_policer_details_t * mp) +{ + vat_main_t *vam = &vat_main; + vat_json_node_t *node; + u8 *rate_type_str, *round_type_str, *type_str; + u8 *conform_action_str, *exceed_action_str, *violate_action_str; + + rate_type_str = format (0, "%U", format_policer_rate_type, mp->rate_type); + round_type_str = + format (0, "%U", format_policer_round_type, mp->round_type); + type_str = format (0, "%U", format_policer_type, mp->type); + conform_action_str = format (0, "%U", format_policer_action_type, + mp->conform_action_type); + exceed_action_str = format (0, "%U", format_policer_action_type, + mp->exceed_action_type); + violate_action_str = format (0, "%U", format_policer_action_type, + mp->violate_action_type); + + if (VAT_JSON_ARRAY != vam->json_tree.type) + { + ASSERT (VAT_JSON_NONE == vam->json_tree.type); + vat_json_init_array (&vam->json_tree); + } + node = vat_json_array_add (&vam->json_tree); + + vat_json_init_object (node); + vat_json_object_add_string_copy (node, "name", mp->name); + vat_json_object_add_uint (node, "cir", ntohl (mp->cir)); + vat_json_object_add_uint (node, "eir", ntohl (mp->eir)); + vat_json_object_add_uint (node, "cb", ntohl (mp->cb)); + vat_json_object_add_uint (node, "eb", ntohl (mp->eb)); + vat_json_object_add_string_copy (node, "rate_type", rate_type_str); + vat_json_object_add_string_copy (node, "round_type", round_type_str); + vat_json_object_add_string_copy (node, "type", type_str); + vat_json_object_add_uint (node, "single_rate", mp->single_rate); + vat_json_object_add_uint (node, "color_aware", mp->color_aware); + vat_json_object_add_uint (node, "scale", ntohl (mp->scale)); + vat_json_object_add_uint (node, "cir_tokens_per_period", + ntohl (mp->cir_tokens_per_period)); + vat_json_object_add_uint (node, "eir_tokens_per_period", + ntohl (mp->pir_tokens_per_period)); + vat_json_object_add_uint (node, "current_limit", ntohl (mp->current_limit)); + vat_json_object_add_uint (node, "current_bucket", + ntohl (mp->current_bucket)); + vat_json_object_add_uint (node, "extended_limit", + ntohl (mp->extended_limit)); + vat_json_object_add_uint (node, "extended_bucket", + ntohl (mp->extended_bucket)); + vat_json_object_add_uint (node, "last_update_time", + ntohl (mp->last_update_time)); + vat_json_object_add_string_copy (node, "conform_action", + conform_action_str); + if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT) + { + u8 *dscp_str = format (0, "%U", format_dscp, mp->conform_dscp); + vat_json_object_add_string_copy (node, "conform_dscp", dscp_str); + vec_free (dscp_str); + } + vat_json_object_add_string_copy (node, "exceed_action", exceed_action_str); + if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT) + { + u8 *dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp); + vat_json_object_add_string_copy (node, "exceed_dscp", dscp_str); + vec_free (dscp_str); + } + vat_json_object_add_string_copy (node, "violate_action", + violate_action_str); + if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT) + { + u8 *dscp_str = format (0, "%U", format_dscp, mp->violate_dscp); + vat_json_object_add_string_copy (node, "violate_dscp", dscp_str); + vec_free (dscp_str); + } + + vec_free (rate_type_str); + vec_free (round_type_str); + vec_free (type_str); + vec_free (conform_action_str); + vec_free (exceed_action_str); + vec_free (violate_action_str); +} + +static void +vl_api_classify_table_ids_reply_t_handler (vl_api_classify_table_ids_reply_t * + mp) +{ + vat_main_t *vam = &vat_main; + int i, count = ntohl (mp->count); + + if (count > 0) + print (vam->ofp, "classify table ids (%d) : ", count); + for (i = 0; i < count; i++) + { + print (vam->ofp, "%d", ntohl (mp->ids[i])); + print (vam->ofp, (i < count - 1) ? "," : ""); + } + vam->retval = ntohl (mp->retval); + vam->result_ready = 1; +} + +static void + vl_api_classify_table_ids_reply_t_handler_json + (vl_api_classify_table_ids_reply_t * mp) +{ + vat_main_t *vam = &vat_main; + int i, count = ntohl (mp->count); + + if (count > 0) + { + vat_json_node_t node; + + vat_json_init_object (&node); + for (i = 0; i < count; i++) + { + vat_json_object_add_uint (&node, "table_id", ntohl (mp->ids[i])); + } + vat_json_print (vam->ofp, &node); + vat_json_free (&node); + } + vam->retval = ntohl (mp->retval); + vam->result_ready = 1; +} + +static void + vl_api_classify_table_by_interface_reply_t_handler + (vl_api_classify_table_by_interface_reply_t * mp) +{ + vat_main_t *vam = &vat_main; + u32 table_id; + + table_id = ntohl (mp->l2_table_id); + if (table_id != ~0) + print (vam->ofp, "l2 table id : %d", table_id); + else + print (vam->ofp, "l2 table id : No input ACL tables configured"); + table_id = ntohl (mp->ip4_table_id); + if (table_id != ~0) + print (vam->ofp, "ip4 table id : %d", table_id); + else + print (vam->ofp, "ip4 table id : No input ACL tables configured"); + table_id = ntohl (mp->ip6_table_id); + if (table_id != ~0) + print (vam->ofp, "ip6 table id : %d", table_id); + else + print (vam->ofp, "ip6 table id : No input ACL tables configured"); + vam->retval = ntohl (mp->retval); + vam->result_ready = 1; +} + +static void + vl_api_classify_table_by_interface_reply_t_handler_json + (vl_api_classify_table_by_interface_reply_t * mp) +{ + vat_main_t *vam = &vat_main; + vat_json_node_t node; + + vat_json_init_object (&node); + + vat_json_object_add_int (&node, "l2_table_id", ntohl (mp->l2_table_id)); + vat_json_object_add_int (&node, "ip4_table_id", ntohl (mp->ip4_table_id)); + vat_json_object_add_int (&node, "ip6_table_id", ntohl (mp->ip6_table_id)); + + vat_json_print (vam->ofp, &node); + vat_json_free (&node); + + vam->retval = ntohl (mp->retval); + vam->result_ready = 1; +} + +static void vl_api_policer_add_del_reply_t_handler + (vl_api_policer_add_del_reply_t * mp) +{ + vat_main_t *vam = &vat_main; + i32 retval = ntohl (mp->retval); + if (vam->async_mode) + { + vam->async_errors += (retval < 0); + } + else + { + vam->retval = retval; + vam->result_ready = 1; + if (retval == 0 && mp->policer_index != 0xFFFFFFFF) + /* + * Note: this is just barely thread-safe, depends on + * the main thread spinning waiting for an answer... + */ + errmsg ("policer index %d", ntohl (mp->policer_index)); + } +} + +static void vl_api_policer_add_del_reply_t_handler_json + (vl_api_policer_add_del_reply_t * mp) +{ + vat_main_t *vam = &vat_main; + vat_json_node_t node; + + vat_json_init_object (&node); + vat_json_object_add_int (&node, "retval", ntohl (mp->retval)); + vat_json_object_add_uint (&node, "policer_index", + ntohl (mp->policer_index)); + + vat_json_print (vam->ofp, &node); + vat_json_free (&node); + + vam->retval = ntohl (mp->retval); + vam->result_ready = 1; +} + +/* Format hex dump. */ +u8 * +format_hex_bytes (u8 * s, va_list * va) +{ + u8 *bytes = va_arg (*va, u8 *); + int n_bytes = va_arg (*va, int); + uword i; + + /* Print short or long form depending on byte count. */ + uword short_form = n_bytes <= 32; + uword indent = format_get_indent (s); + + if (n_bytes == 0) + return s; + + for (i = 0; i < n_bytes; i++) + { + if (!short_form && (i % 32) == 0) + s = format (s, "%08x: ", i); + s = format (s, "%02x", bytes[i]); + if (!short_form && ((i + 1) % 32) == 0 && (i + 1) < n_bytes) + s = format (s, "\n%U", format_white_space, indent); + } + + return s; +} + +static void +vl_api_classify_table_info_reply_t_handler (vl_api_classify_table_info_reply_t + * mp) +{ + vat_main_t *vam = &vat_main; + i32 retval = ntohl (mp->retval); + if (retval == 0) + { + print (vam->ofp, "classify table info :"); + print (vam->ofp, "sessions: %d nexttbl: %d nextnode: %d", + ntohl (mp->active_sessions), ntohl (mp->next_table_index), + ntohl (mp->miss_next_index)); + print (vam->ofp, "nbuckets: %d skip: %d match: %d", + ntohl (mp->nbuckets), ntohl (mp->skip_n_vectors), + ntohl (mp->match_n_vectors)); + print (vam->ofp, "mask: %U", format_hex_bytes, mp->mask, + ntohl (mp->mask_length)); + } + vam->retval = retval; + vam->result_ready = 1; +} + +static void + vl_api_classify_table_info_reply_t_handler_json + (vl_api_classify_table_info_reply_t * mp) +{ + vat_main_t *vam = &vat_main; + vat_json_node_t node; + + i32 retval = ntohl (mp->retval); + if (retval == 0) + { + vat_json_init_object (&node); + + vat_json_object_add_int (&node, "sessions", + ntohl (mp->active_sessions)); + vat_json_object_add_int (&node, "nexttbl", + ntohl (mp->next_table_index)); + vat_json_object_add_int (&node, "nextnode", + ntohl (mp->miss_next_index)); + vat_json_object_add_int (&node, "nbuckets", ntohl (mp->nbuckets)); + vat_json_object_add_int (&node, "skip", ntohl (mp->skip_n_vectors)); + vat_json_object_add_int (&node, "match", ntohl (mp->match_n_vectors)); + u8 *s = format (0, "%U%c", format_hex_bytes, mp->mask, + ntohl (mp->mask_length), 0); + vat_json_object_add_string_copy (&node, "mask", s); + + vat_json_print (vam->ofp, &node); + vat_json_free (&node); + } + vam->retval = ntohl (mp->retval); + vam->result_ready = 1; +} + +static void +vl_api_classify_session_details_t_handler (vl_api_classify_session_details_t * + mp) +{ + vat_main_t *vam = &vat_main; + + print (vam->ofp, "next_index: %d advance: %d opaque: %d ", + ntohl (mp->hit_next_index), ntohl (mp->advance), + ntohl (mp->opaque_index)); + print (vam->ofp, "mask: %U", format_hex_bytes, mp->match, + ntohl (mp->match_length)); +} + +static void + vl_api_classify_session_details_t_handler_json + (vl_api_classify_session_details_t * mp) +{ + vat_main_t *vam = &vat_main; + vat_json_node_t *node = NULL; + + if (VAT_JSON_ARRAY != vam->json_tree.type) + { + ASSERT (VAT_JSON_NONE == vam->json_tree.type); + vat_json_init_array (&vam->json_tree); + } + node = vat_json_array_add (&vam->json_tree); + + vat_json_init_object (node); + vat_json_object_add_int (node, "next_index", ntohl (mp->hit_next_index)); + vat_json_object_add_int (node, "advance", ntohl (mp->advance)); + vat_json_object_add_int (node, "opaque", ntohl (mp->opaque_index)); + u8 *s = + format (0, "%U%c", format_hex_bytes, mp->match, ntohl (mp->match_length), + 0); + vat_json_object_add_string_copy (node, "match", s); +} + +static void vl_api_pg_create_interface_reply_t_handler + (vl_api_pg_create_interface_reply_t * mp) +{ + vat_main_t *vam = &vat_main; + + vam->retval = ntohl (mp->retval); + vam->result_ready = 1; +} + +static void vl_api_pg_create_interface_reply_t_handler_json + (vl_api_pg_create_interface_reply_t * mp) +{ + vat_main_t *vam = &vat_main; + vat_json_node_t node; + + i32 retval = ntohl (mp->retval); + if (retval == 0) + { + vat_json_init_object (&node); + + vat_json_object_add_int (&node, "sw_if_index", ntohl (mp->sw_if_index)); + + vat_json_print (vam->ofp, &node); + vat_json_free (&node); + } + vam->retval = ntohl (mp->retval); + vam->result_ready = 1; +} + +static void vl_api_policer_classify_details_t_handler + (vl_api_policer_classify_details_t * mp) +{ + vat_main_t *vam = &vat_main; + + print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index), + ntohl (mp->table_index)); +} + +static void vl_api_policer_classify_details_t_handler_json + (vl_api_policer_classify_details_t * mp) +{ + vat_main_t *vam = &vat_main; + vat_json_node_t *node; + + if (VAT_JSON_ARRAY != vam->json_tree.type) + { + ASSERT (VAT_JSON_NONE == vam->json_tree.type); + vat_json_init_array (&vam->json_tree); + } + node = vat_json_array_add (&vam->json_tree); + + vat_json_init_object (node); + vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index)); + vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index)); +} + +static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler + (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp) +{ + vat_main_t *vam = &vat_main; + i32 retval = ntohl (mp->retval); + if (vam->async_mode) + { + vam->async_errors += (retval < 0); + } + else + { + vam->retval = retval; + vam->sw_if_index = ntohl (mp->sw_if_index); + vam->result_ready = 1; + } +} + +static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler_json + (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp) +{ + vat_main_t *vam = &vat_main; + vat_json_node_t node; + + vat_json_init_object (&node); + vat_json_object_add_int (&node, "retval", ntohl (mp->retval)); + vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index)); + + vat_json_print (vam->ofp, &node); + vat_json_free (&node); + + vam->retval = ntohl (mp->retval); + vam->result_ready = 1; +} + +static void vl_api_flow_classify_details_t_handler + (vl_api_flow_classify_details_t * mp) +{ + vat_main_t *vam = &vat_main; + + print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index), + ntohl (mp->table_index)); +} + +static void vl_api_flow_classify_details_t_handler_json + (vl_api_flow_classify_details_t * mp) +{ + vat_main_t *vam = &vat_main; + vat_json_node_t *node; + + if (VAT_JSON_ARRAY != vam->json_tree.type) + { + ASSERT (VAT_JSON_NONE == vam->json_tree.type); + vat_json_init_array (&vam->json_tree); + } + node = vat_json_array_add (&vam->json_tree); + + vat_json_init_object (node); + vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index)); + vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index)); +} + + + +#define vl_api_vnet_ip4_fib_counters_t_endian vl_noop_handler +#define vl_api_vnet_ip4_fib_counters_t_print vl_noop_handler +#define vl_api_vnet_ip6_fib_counters_t_endian vl_noop_handler +#define vl_api_vnet_ip6_fib_counters_t_print vl_noop_handler +#define vl_api_lisp_adjacencies_get_reply_t_endian vl_noop_handler +#define vl_api_lisp_adjacencies_get_reply_t_print vl_noop_handler + +/* + * Generate boilerplate reply handlers, which + * dig the return value out of the xxx_reply_t API message, + * stick it into vam->retval, and set vam->result_ready + * + * Could also do this by pointing N message decode slots at + * a single function, but that could break in subtle ways. + */ + +#define foreach_standard_reply_retval_handler \ +_(sw_interface_set_flags_reply) \ +_(sw_interface_add_del_address_reply) \ +_(sw_interface_set_table_reply) \ +_(sw_interface_set_mpls_enable_reply) \ +_(sw_interface_set_vpath_reply) \ +_(sw_interface_set_vxlan_bypass_reply) \ +_(sw_interface_set_l2_bridge_reply) \ +_(sw_interface_set_dpdk_hqos_pipe_reply) \ +_(sw_interface_set_dpdk_hqos_subport_reply) \ +_(sw_interface_set_dpdk_hqos_tctbl_reply) \ +_(bridge_domain_add_del_reply) \ +_(sw_interface_set_l2_xconnect_reply) \ +_(l2fib_add_del_reply) \ +_(ip_add_del_route_reply) \ +_(mpls_route_add_del_reply) \ +_(mpls_ip_bind_unbind_reply) \ +_(proxy_arp_add_del_reply) \ +_(proxy_arp_intfc_enable_disable_reply) \ +_(sw_interface_set_unnumbered_reply) \ +_(ip_neighbor_add_del_reply) \ +_(reset_vrf_reply) \ +_(oam_add_del_reply) \ +_(reset_fib_reply) \ +_(dhcp_proxy_config_reply) \ +_(dhcp_proxy_config_2_reply) \ +_(dhcp_proxy_set_vss_reply) \ +_(dhcp_client_config_reply) \ +_(set_ip_flow_hash_reply) \ +_(sw_interface_ip6_enable_disable_reply) \ +_(sw_interface_ip6_set_link_local_address_reply) \ +_(sw_interface_ip6nd_ra_prefix_reply) \ +_(sw_interface_ip6nd_ra_config_reply) \ +_(set_arp_neighbor_limit_reply) \ +_(l2_patch_add_del_reply) \ +_(sr_tunnel_add_del_reply) \ +_(sr_policy_add_del_reply) \ +_(sr_multicast_map_add_del_reply) \ +_(classify_add_del_session_reply) \ +_(classify_set_interface_ip_table_reply) \ +_(classify_set_interface_l2_tables_reply) \ +_(l2tpv3_set_tunnel_cookies_reply) \ +_(l2tpv3_interface_enable_disable_reply) \ +_(l2tpv3_set_lookup_key_reply) \ +_(l2_fib_clear_table_reply) \ +_(l2_interface_efp_filter_reply) \ +_(l2_interface_vlan_tag_rewrite_reply) \ +_(modify_vhost_user_if_reply) \ +_(delete_vhost_user_if_reply) \ +_(want_ip4_arp_events_reply) \ +_(want_ip6_nd_events_reply) \ +_(input_acl_set_interface_reply) \ +_(ipsec_spd_add_del_reply) \ +_(ipsec_interface_add_del_spd_reply) \ +_(ipsec_spd_add_del_entry_reply) \ +_(ipsec_sad_add_del_entry_reply) \ +_(ipsec_sa_set_key_reply) \ +_(ikev2_profile_add_del_reply) \ +_(ikev2_profile_set_auth_reply) \ +_(ikev2_profile_set_id_reply) \ +_(ikev2_profile_set_ts_reply) \ +_(ikev2_set_local_key_reply) \ +_(delete_loopback_reply) \ +_(bd_ip_mac_add_del_reply) \ +_(map_del_domain_reply) \ +_(map_add_del_rule_reply) \ +_(want_interface_events_reply) \ +_(want_stats_reply) \ +_(cop_interface_enable_disable_reply) \ +_(cop_whitelist_enable_disable_reply) \ +_(sw_interface_clear_stats_reply) \ +_(ioam_enable_reply) \ +_(ioam_disable_reply) \ +_(lisp_add_del_locator_reply) \ +_(lisp_add_del_local_eid_reply) \ +_(lisp_add_del_remote_mapping_reply) \ +_(lisp_add_del_adjacency_reply) \ +_(lisp_gpe_add_del_fwd_entry_reply) \ +_(lisp_add_del_map_resolver_reply) \ +_(lisp_add_del_map_server_reply) \ +_(lisp_gpe_enable_disable_reply) \ +_(lisp_gpe_add_del_iface_reply) \ +_(lisp_enable_disable_reply) \ +_(lisp_rloc_probe_enable_disable_reply) \ +_(lisp_map_register_enable_disable_reply) \ +_(lisp_pitr_set_locator_set_reply) \ +_(lisp_map_request_mode_reply) \ +_(lisp_add_del_map_request_itr_rlocs_reply) \ +_(lisp_eid_table_add_del_map_reply) \ +_(vxlan_gpe_add_del_tunnel_reply) \ +_(af_packet_delete_reply) \ +_(policer_classify_set_interface_reply) \ +_(netmap_create_reply) \ +_(netmap_delete_reply) \ +_(set_ipfix_exporter_reply) \ +_(set_ipfix_classify_stream_reply) \ +_(ipfix_classify_table_add_del_reply) \ +_(flow_classify_set_interface_reply) \ +_(sw_interface_span_enable_disable_reply) \ +_(pg_capture_reply) \ +_(pg_enable_disable_reply) \ +_(ip_source_and_port_range_check_add_del_reply) \ +_(ip_source_and_port_range_check_interface_add_del_reply)\ +_(delete_subif_reply) \ +_(l2_interface_pbb_tag_rewrite_reply) \ +_(punt_reply) \ +_(feature_enable_disable_reply) \ +_(sw_interface_tag_add_del_reply) \ +_(sw_interface_set_mtu_reply) + +#define _(n) \ + static void vl_api_##n##_t_handler \ + (vl_api_##n##_t * mp) \ + { \ + vat_main_t * vam = &vat_main; \ + i32 retval = ntohl(mp->retval); \ + if (vam->async_mode) { \ + vam->async_errors += (retval < 0); \ + } else { \ + vam->retval = retval; \ + vam->result_ready = 1; \ + } \ + } +foreach_standard_reply_retval_handler; +#undef _ + +#define _(n) \ + static void vl_api_##n##_t_handler_json \ + (vl_api_##n##_t * mp) \ + { \ + vat_main_t * vam = &vat_main; \ + vat_json_node_t node; \ + vat_json_init_object(&node); \ + vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \ + vat_json_print(vam->ofp, &node); \ + vam->retval = ntohl(mp->retval); \ + vam->result_ready = 1; \ + } +foreach_standard_reply_retval_handler; +#undef _ + +/* + * Table of message reply handlers, must include boilerplate handlers + * we just generated + */ + +#define foreach_vpe_api_reply_msg \ +_(CREATE_LOOPBACK_REPLY, create_loopback_reply) \ +_(SW_INTERFACE_DETAILS, sw_interface_details) \ +_(SW_INTERFACE_SET_FLAGS, sw_interface_set_flags) \ +_(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \ +_(CONTROL_PING_REPLY, control_ping_reply) \ +_(CLI_REPLY, cli_reply) \ +_(CLI_INBAND_REPLY, cli_inband_reply) \ +_(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \ + sw_interface_add_del_address_reply) \ +_(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \ +_(SW_INTERFACE_SET_MPLS_ENABLE_REPLY, sw_interface_set_mpls_enable_reply) \ +_(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \ +_(SW_INTERFACE_SET_VXLAN_BYPASS_REPLY, sw_interface_set_vxlan_bypass_reply) \ +_(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \ + sw_interface_set_l2_xconnect_reply) \ +_(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \ + sw_interface_set_l2_bridge_reply) \ +_(SW_INTERFACE_SET_DPDK_HQOS_PIPE_REPLY, \ + sw_interface_set_dpdk_hqos_pipe_reply) \ +_(SW_INTERFACE_SET_DPDK_HQOS_SUBPORT_REPLY, \ + sw_interface_set_dpdk_hqos_subport_reply) \ +_(SW_INTERFACE_SET_DPDK_HQOS_TCTBL_REPLY, \ + sw_interface_set_dpdk_hqos_tctbl_reply) \ +_(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \ +_(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \ +_(BRIDGE_DOMAIN_SW_IF_DETAILS, bridge_domain_sw_if_details) \ +_(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \ +_(L2_FLAGS_REPLY, l2_flags_reply) \ +_(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \ +_(TAP_CONNECT_REPLY, tap_connect_reply) \ +_(TAP_MODIFY_REPLY, tap_modify_reply) \ +_(TAP_DELETE_REPLY, tap_delete_reply) \ +_(SW_INTERFACE_TAP_DETAILS, sw_interface_tap_details) \ +_(IP_ADD_DEL_ROUTE_REPLY, ip_add_del_route_reply) \ +_(MPLS_ROUTE_ADD_DEL_REPLY, mpls_route_add_del_reply) \ +_(MPLS_IP_BIND_UNBIND_REPLY, mpls_ip_bind_unbind_reply) \ +_(PROXY_ARP_ADD_DEL_REPLY, proxy_arp_add_del_reply) \ +_(PROXY_ARP_INTFC_ENABLE_DISABLE_REPLY, \ + proxy_arp_intfc_enable_disable_reply) \ +_(MPLS_TUNNEL_ADD_DEL_REPLY, mpls_tunnel_add_del_reply) \ +_(SW_INTERFACE_SET_UNNUMBERED_REPLY, \ + sw_interface_set_unnumbered_reply) \ +_(IP_NEIGHBOR_ADD_DEL_REPLY, ip_neighbor_add_del_reply) \ +_(RESET_VRF_REPLY, reset_vrf_reply) \ +_(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \ +_(CREATE_SUBIF_REPLY, create_subif_reply) \ +_(OAM_ADD_DEL_REPLY, oam_add_del_reply) \ +_(RESET_FIB_REPLY, reset_fib_reply) \ +_(DHCP_PROXY_CONFIG_REPLY, dhcp_proxy_config_reply) \ +_(DHCP_PROXY_CONFIG_2_REPLY, dhcp_proxy_config_2_reply) \ +_(DHCP_PROXY_SET_VSS_REPLY, dhcp_proxy_set_vss_reply) \ +_(DHCP_CLIENT_CONFIG_REPLY, dhcp_client_config_reply) \ +_(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \ +_(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \ + sw_interface_ip6_enable_disable_reply) \ +_(SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS_REPLY, \ + sw_interface_ip6_set_link_local_address_reply) \ +_(SW_INTERFACE_IP6ND_RA_PREFIX_REPLY, \ + sw_interface_ip6nd_ra_prefix_reply) \ +_(SW_INTERFACE_IP6ND_RA_CONFIG_REPLY, \ + sw_interface_ip6nd_ra_config_reply) \ +_(SET_ARP_NEIGHBOR_LIMIT_REPLY, set_arp_neighbor_limit_reply) \ +_(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \ +_(SR_TUNNEL_ADD_DEL_REPLY, sr_tunnel_add_del_reply) \ +_(SR_POLICY_ADD_DEL_REPLY, sr_policy_add_del_reply) \ +_(SR_MULTICAST_MAP_ADD_DEL_REPLY, sr_multicast_map_add_del_reply) \ +_(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \ +_(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \ +_(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \ +classify_set_interface_ip_table_reply) \ +_(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \ + classify_set_interface_l2_tables_reply) \ +_(GET_NODE_INDEX_REPLY, get_node_index_reply) \ +_(ADD_NODE_NEXT_REPLY, add_node_next_reply) \ +_(L2TPV3_CREATE_TUNNEL_REPLY, l2tpv3_create_tunnel_reply) \ +_(L2TPV3_SET_TUNNEL_COOKIES_REPLY, l2tpv3_set_tunnel_cookies_reply) \ +_(L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY, \ + l2tpv3_interface_enable_disable_reply) \ +_(L2TPV3_SET_LOOKUP_KEY_REPLY, l2tpv3_set_lookup_key_reply) \ +_(SW_IF_L2TPV3_TUNNEL_DETAILS, sw_if_l2tpv3_tunnel_details) \ +_(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \ +_(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \ +_(GRE_ADD_DEL_TUNNEL_REPLY, gre_add_del_tunnel_reply) \ +_(GRE_TUNNEL_DETAILS, gre_tunnel_details) \ +_(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \ +_(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \ +_(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \ +_(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \ +_(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \ +_(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \ +_(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \ +_(SHOW_VERSION_REPLY, show_version_reply) \ +_(L2_FIB_TABLE_ENTRY, l2_fib_table_entry) \ +_(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \ +_(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \ +_(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \ +_(WANT_IP4_ARP_EVENTS_REPLY, want_ip4_arp_events_reply) \ +_(IP4_ARP_EVENT, ip4_arp_event) \ +_(WANT_IP6_ND_EVENTS_REPLY, want_ip6_nd_events_reply) \ +_(IP6_ND_EVENT, ip6_nd_event) \ +_(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \ +_(IP_ADDRESS_DETAILS, ip_address_details) \ +_(IP_DETAILS, ip_details) \ +_(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \ +_(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \ +_(IPSEC_SPD_ADD_DEL_ENTRY_REPLY, ipsec_spd_add_del_entry_reply) \ +_(IPSEC_SAD_ADD_DEL_ENTRY_REPLY, ipsec_sad_add_del_entry_reply) \ +_(IPSEC_SA_SET_KEY_REPLY, ipsec_sa_set_key_reply) \ +_(IKEV2_PROFILE_ADD_DEL_REPLY, ikev2_profile_add_del_reply) \ +_(IKEV2_PROFILE_SET_AUTH_REPLY, ikev2_profile_set_auth_reply) \ +_(IKEV2_PROFILE_SET_ID_REPLY, ikev2_profile_set_id_reply) \ +_(IKEV2_PROFILE_SET_TS_REPLY, ikev2_profile_set_ts_reply) \ +_(IKEV2_SET_LOCAL_KEY_REPLY, ikev2_set_local_key_reply) \ +_(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \ +_(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \ +_(DHCP_COMPL_EVENT, dhcp_compl_event) \ +_(VNET_INTERFACE_COUNTERS, vnet_interface_counters) \ +_(VNET_IP4_FIB_COUNTERS, vnet_ip4_fib_counters) \ +_(VNET_IP6_FIB_COUNTERS, vnet_ip6_fib_counters) \ +_(MAP_ADD_DOMAIN_REPLY, map_add_domain_reply) \ +_(MAP_DEL_DOMAIN_REPLY, map_del_domain_reply) \ +_(MAP_ADD_DEL_RULE_REPLY, map_add_del_rule_reply) \ +_(MAP_DOMAIN_DETAILS, map_domain_details) \ +_(MAP_RULE_DETAILS, map_rule_details) \ +_(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \ +_(WANT_STATS_REPLY, want_stats_reply) \ +_(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \ +_(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \ +_(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \ +_(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \ +_(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \ +_(IOAM_ENABLE_REPLY, ioam_enable_reply) \ +_(IOAM_DISABLE_REPLY, ioam_disable_reply) \ +_(LISP_ADD_DEL_LOCATOR_SET_REPLY, lisp_add_del_locator_set_reply) \ +_(LISP_ADD_DEL_LOCATOR_REPLY, lisp_add_del_locator_reply) \ +_(LISP_ADD_DEL_LOCAL_EID_REPLY, lisp_add_del_local_eid_reply) \ +_(LISP_ADD_DEL_REMOTE_MAPPING_REPLY, lisp_add_del_remote_mapping_reply) \ +_(LISP_ADD_DEL_ADJACENCY_REPLY, lisp_add_del_adjacency_reply) \ +_(LISP_GPE_ADD_DEL_FWD_ENTRY_REPLY, lisp_gpe_add_del_fwd_entry_reply) \ +_(LISP_ADD_DEL_MAP_RESOLVER_REPLY, lisp_add_del_map_resolver_reply) \ +_(LISP_ADD_DEL_MAP_SERVER_REPLY, lisp_add_del_map_server_reply) \ +_(LISP_GPE_ENABLE_DISABLE_REPLY, lisp_gpe_enable_disable_reply) \ +_(LISP_ENABLE_DISABLE_REPLY, lisp_enable_disable_reply) \ +_(LISP_MAP_REGISTER_ENABLE_DISABLE_REPLY, \ + lisp_map_register_enable_disable_reply) \ +_(LISP_RLOC_PROBE_ENABLE_DISABLE_REPLY, \ + lisp_rloc_probe_enable_disable_reply) \ +_(LISP_PITR_SET_LOCATOR_SET_REPLY, lisp_pitr_set_locator_set_reply) \ +_(LISP_MAP_REQUEST_MODE_REPLY, lisp_map_request_mode_reply) \ +_(LISP_EID_TABLE_ADD_DEL_MAP_REPLY, lisp_eid_table_add_del_map_reply) \ +_(LISP_GPE_ADD_DEL_IFACE_REPLY, lisp_gpe_add_del_iface_reply) \ +_(LISP_LOCATOR_SET_DETAILS, lisp_locator_set_details) \ +_(LISP_LOCATOR_DETAILS, lisp_locator_details) \ +_(LISP_EID_TABLE_DETAILS, lisp_eid_table_details) \ +_(LISP_EID_TABLE_MAP_DETAILS, lisp_eid_table_map_details) \ +_(LISP_EID_TABLE_VNI_DETAILS, lisp_eid_table_vni_details) \ +_(LISP_GPE_TUNNEL_DETAILS, lisp_gpe_tunnel_details) \ +_(LISP_MAP_RESOLVER_DETAILS, lisp_map_resolver_details) \ +_(LISP_MAP_SERVER_DETAILS, lisp_map_server_details) \ +_(LISP_ADJACENCIES_GET_REPLY, lisp_adjacencies_get_reply) \ +_(SHOW_LISP_STATUS_REPLY, show_lisp_status_reply) \ +_(LISP_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \ + lisp_add_del_map_request_itr_rlocs_reply) \ +_(LISP_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \ + lisp_get_map_request_itr_rlocs_reply) \ +_(SHOW_LISP_PITR_REPLY, show_lisp_pitr_reply) \ +_(SHOW_LISP_MAP_REQUEST_MODE_REPLY, show_lisp_map_request_mode_reply) \ +_(SHOW_LISP_RLOC_PROBE_STATE_REPLY, show_lisp_rloc_probe_state_reply) \ +_(SHOW_LISP_MAP_REGISTER_STATE_REPLY, \ + show_lisp_map_register_state_reply) \ +_(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \ +_(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \ +_(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \ +_(POLICER_DETAILS, policer_details) \ +_(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \ +_(POLICER_CLASSIFY_DETAILS, policer_classify_details) \ +_(NETMAP_CREATE_REPLY, netmap_create_reply) \ +_(NETMAP_DELETE_REPLY, netmap_delete_reply) \ +_(MPLS_TUNNEL_DETAILS, mpls_tunnel_details) \ +_(MPLS_FIB_DETAILS, mpls_fib_details) \ +_(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \ +_(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \ +_(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \ +_(CLASSIFY_SESSION_DETAILS, classify_session_details) \ +_(SET_IPFIX_EXPORTER_REPLY, set_ipfix_exporter_reply) \ +_(IPFIX_EXPORTER_DETAILS, ipfix_exporter_details) \ +_(SET_IPFIX_CLASSIFY_STREAM_REPLY, set_ipfix_classify_stream_reply) \ +_(IPFIX_CLASSIFY_STREAM_DETAILS, ipfix_classify_stream_details) \ +_(IPFIX_CLASSIFY_TABLE_ADD_DEL_REPLY, ipfix_classify_table_add_del_reply) \ +_(IPFIX_CLASSIFY_TABLE_DETAILS, ipfix_classify_table_details) \ +_(FLOW_CLASSIFY_SET_INTERFACE_REPLY, flow_classify_set_interface_reply) \ +_(FLOW_CLASSIFY_DETAILS, flow_classify_details) \ +_(SW_INTERFACE_SPAN_ENABLE_DISABLE_REPLY, sw_interface_span_enable_disable_reply) \ +_(SW_INTERFACE_SPAN_DETAILS, sw_interface_span_details) \ +_(GET_NEXT_INDEX_REPLY, get_next_index_reply) \ +_(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \ +_(PG_CAPTURE_REPLY, pg_capture_reply) \ +_(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \ +_(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \ + ip_source_and_port_range_check_add_del_reply) \ +_(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \ + ip_source_and_port_range_check_interface_add_del_reply) \ +_(IPSEC_GRE_ADD_DEL_TUNNEL_REPLY, ipsec_gre_add_del_tunnel_reply) \ +_(IPSEC_GRE_TUNNEL_DETAILS, ipsec_gre_tunnel_details) \ +_(DELETE_SUBIF_REPLY, delete_subif_reply) \ +_(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \ +_(PUNT_REPLY, punt_reply) \ +_(IP_FIB_DETAILS, ip_fib_details) \ +_(IP6_FIB_DETAILS, ip6_fib_details) \ +_(FEATURE_ENABLE_DISABLE_REPLY, feature_enable_disable_reply) \ +_(SW_INTERFACE_TAG_ADD_DEL_REPLY, sw_interface_tag_add_del_reply) \ +_(L2_XCONNECT_DETAILS, l2_xconnect_details) \ +_(SW_INTERFACE_SET_MTU_REPLY, sw_interface_set_mtu_reply) \ +_(IP_NEIGHBOR_DETAILS, ip_neighbor_details) \ +_(SW_INTERFACE_GET_TABLE_REPLY, sw_interface_get_table_reply) + +/* M: construct, but don't yet send a message */ + +#define M(T,t) \ +do { \ + vam->result_ready = 0; \ + mp = vl_msg_api_alloc_as_if_client(sizeof(*mp)); \ + memset (mp, 0, sizeof (*mp)); \ + mp->_vl_msg_id = ntohs (VL_API_##T); \ + mp->client_index = vam->my_client_index; \ +} while(0); + +#define M2(T,t,n) \ +do { \ + vam->result_ready = 0; \ + mp = vl_msg_api_alloc_as_if_client(sizeof(*mp)+(n)); \ + memset (mp, 0, sizeof (*mp)); \ + mp->_vl_msg_id = ntohs (VL_API_##T); \ + mp->client_index = vam->my_client_index; \ +} while(0); + + +/* S: send a message */ +#define S (vl_msg_api_send_shmem (vam->vl_input_queue, (u8 *)&mp)) + +/* W: wait for results, with timeout */ +#define W \ +do { \ + timeout = vat_time_now (vam) + 1.0; \ + \ + while (vat_time_now (vam) < timeout) { \ + if (vam->result_ready == 1) { \ + return (vam->retval); \ + } \ + vat_suspend (vam->vlib_main, 1e-3); \ + } \ + return -99; \ +} while(0); + +/* W2: wait for results, with timeout */ +#define W2(body) \ +do { \ + timeout = vat_time_now (vam) + 1.0; \ + \ + while (vat_time_now (vam) < timeout) { \ + if (vam->result_ready == 1) { \ + (body); \ + return (vam->retval); \ + } \ + vat_suspend (vam->vlib_main, 1e-3); \ + } \ + return -99; \ +} while(0); + +typedef struct +{ + u8 *name; + u32 value; +} name_sort_t; + + +#define STR_VTR_OP_CASE(op) \ + case L2_VTR_ ## op: \ + return "" # op; + +static const char * +str_vtr_op (u32 vtr_op) +{ + switch (vtr_op) + { + STR_VTR_OP_CASE (DISABLED); + STR_VTR_OP_CASE (PUSH_1); + STR_VTR_OP_CASE (PUSH_2); + STR_VTR_OP_CASE (POP_1); + STR_VTR_OP_CASE (POP_2); + STR_VTR_OP_CASE (TRANSLATE_1_1); + STR_VTR_OP_CASE (TRANSLATE_1_2); + STR_VTR_OP_CASE (TRANSLATE_2_1); + STR_VTR_OP_CASE (TRANSLATE_2_2); + } + + return "UNKNOWN"; +} + +static int +dump_sub_interface_table (vat_main_t * vam) +{ + const sw_interface_subif_t *sub = NULL; + + if (vam->json_output) + { + clib_warning + ("JSON output supported only for VPE API calls and dump_stats_table"); + return -99; + } + + print (vam->ofp, + "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s", + "Interface", "sw_if_index", + "sub id", "dot1ad", "tags", "outer id", + "inner id", "exact", "default", "outer any", "inner any"); + + vec_foreach (sub, vam->sw_if_subif_table) + { + print (vam->ofp, + "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d", + sub->interface_name, + sub->sw_if_index, + sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q", + sub->sub_number_of_tags, sub->sub_outer_vlan_id, + sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default, + sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any); + if (sub->vtr_op != L2_VTR_DISABLED) + { + print (vam->ofp, + " vlan-tag-rewrite - op: %-14s [ dot1q: %d " + "tag1: %d tag2: %d ]", + str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q, + sub->vtr_tag1, sub->vtr_tag2); + } + } + + return 0; +} + +static int +name_sort_cmp (void *a1, void *a2) +{ + name_sort_t *n1 = a1; + name_sort_t *n2 = a2; + + return strcmp ((char *) n1->name, (char *) n2->name); +} + +static int +dump_interface_table (vat_main_t * vam) +{ + hash_pair_t *p; + name_sort_t *nses = 0, *ns; + + if (vam->json_output) + { + clib_warning + ("JSON output supported only for VPE API calls and dump_stats_table"); + return -99; + } + + /* *INDENT-OFF* */ + hash_foreach_pair (p, vam->sw_if_index_by_interface_name, + ({ + vec_add2 (nses, ns, 1); + ns->name = (u8 *)(p->key); + ns->value = (u32) p->value[0]; + })); + /* *INDENT-ON* */ + + vec_sort_with_function (nses, name_sort_cmp); + + print (vam->ofp, "%-25s%-15s", "Interface", "sw_if_index"); + vec_foreach (ns, nses) + { + print (vam->ofp, "%-25s%-15d", ns->name, ns->value); + } + vec_free (nses); + return 0; +} + +static int +dump_ip_table (vat_main_t * vam, int is_ipv6) +{ + const ip_details_t *det = NULL; + const ip_address_details_t *address = NULL; + u32 i = ~0; + + print (vam->ofp, "%-12s", "sw_if_index"); + + vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6]) + { + i++; + if (!det->present) + { + continue; + } + print (vam->ofp, "%-12d", i); + print (vam->ofp, " %-30s%-13s", "Address", "Prefix length"); + if (!det->addr) + { + continue; + } + vec_foreach (address, det->addr) + { + print (vam->ofp, + " %-30U%-13d", + is_ipv6 ? format_ip6_address : format_ip4_address, + address->ip, address->prefix_length); + } + } + + return 0; +} + +static int +dump_ipv4_table (vat_main_t * vam) +{ + if (vam->json_output) + { + clib_warning + ("JSON output supported only for VPE API calls and dump_stats_table"); + return -99; + } + + return dump_ip_table (vam, 0); +} + +static int +dump_ipv6_table (vat_main_t * vam) +{ + if (vam->json_output) + { + clib_warning + ("JSON output supported only for VPE API calls and dump_stats_table"); + return -99; + } + + return dump_ip_table (vam, 1); +} + +static char * +counter_type_to_str (u8 counter_type, u8 is_combined) +{ + if (!is_combined) + { + switch (counter_type) + { + case VNET_INTERFACE_COUNTER_DROP: + return "drop"; + case VNET_INTERFACE_COUNTER_PUNT: + return "punt"; + case VNET_INTERFACE_COUNTER_IP4: + return "ip4"; + case VNET_INTERFACE_COUNTER_IP6: + return "ip6"; + case VNET_INTERFACE_COUNTER_RX_NO_BUF: + return "rx-no-buf"; + case VNET_INTERFACE_COUNTER_RX_MISS: + return "rx-miss"; + case VNET_INTERFACE_COUNTER_RX_ERROR: + return "rx-error"; + case VNET_INTERFACE_COUNTER_TX_ERROR: + return "tx-error"; + default: + return "INVALID-COUNTER-TYPE"; + } + } + else + { + switch (counter_type) + { + case VNET_INTERFACE_COUNTER_RX: + return "rx"; + case VNET_INTERFACE_COUNTER_TX: + return "tx"; + default: + return "INVALID-COUNTER-TYPE"; + } + } +} + +static int +dump_stats_table (vat_main_t * vam) +{ + vat_json_node_t node; + vat_json_node_t *msg_array; + vat_json_node_t *msg; + vat_json_node_t *counter_array; + vat_json_node_t *counter; + interface_counter_t c; + u64 packets; + ip4_fib_counter_t *c4; + ip6_fib_counter_t *c6; + int i, j; + + if (!vam->json_output) + { + clib_warning ("dump_stats_table supported only in JSON format"); + return -99; + } + + vat_json_init_object (&node); + + /* interface counters */ + msg_array = vat_json_object_add (&node, "interface_counters"); + vat_json_init_array (msg_array); + for (i = 0; i < vec_len (vam->simple_interface_counters); i++) + { + msg = vat_json_array_add (msg_array); + vat_json_init_object (msg); + vat_json_object_add_string_copy (msg, "vnet_counter_type", + (u8 *) counter_type_to_str (i, 0)); + vat_json_object_add_int (msg, "is_combined", 0); + counter_array = vat_json_object_add (msg, "data"); + vat_json_init_array (counter_array); + for (j = 0; j < vec_len (vam->simple_interface_counters[i]); j++) + { + packets = vam->simple_interface_counters[i][j]; + vat_json_array_add_uint (counter_array, packets); + } + } + for (i = 0; i < vec_len (vam->combined_interface_counters); i++) + { + msg = vat_json_array_add (msg_array); + vat_json_init_object (msg); + vat_json_object_add_string_copy (msg, "vnet_counter_type", + (u8 *) counter_type_to_str (i, 1)); + vat_json_object_add_int (msg, "is_combined", 1); + counter_array = vat_json_object_add (msg, "data"); + vat_json_init_array (counter_array); + for (j = 0; j < vec_len (vam->combined_interface_counters[i]); j++) + { + c = vam->combined_interface_counters[i][j]; + counter = vat_json_array_add (counter_array); + vat_json_init_object (counter); + vat_json_object_add_uint (counter, "packets", c.packets); + vat_json_object_add_uint (counter, "bytes", c.bytes); + } + } + + /* ip4 fib counters */ + msg_array = vat_json_object_add (&node, "ip4_fib_counters"); + vat_json_init_array (msg_array); + for (i = 0; i < vec_len (vam->ip4_fib_counters); i++) + { + msg = vat_json_array_add (msg_array); + vat_json_init_object (msg); + vat_json_object_add_uint (msg, "vrf_id", + vam->ip4_fib_counters_vrf_id_by_index[i]); + counter_array = vat_json_object_add (msg, "c"); + vat_json_init_array (counter_array); + for (j = 0; j < vec_len (vam->ip4_fib_counters[i]); j++) + { + counter = vat_json_array_add (counter_array); + vat_json_init_object (counter); + c4 = &vam->ip4_fib_counters[i][j]; + vat_json_object_add_ip4 (counter, "address", c4->address); + vat_json_object_add_uint (counter, "address_length", + c4->address_length); + vat_json_object_add_uint (counter, "packets", c4->packets); + vat_json_object_add_uint (counter, "bytes", c4->bytes); + } + } + + /* ip6 fib counters */ + msg_array = vat_json_object_add (&node, "ip6_fib_counters"); + vat_json_init_array (msg_array); + for (i = 0; i < vec_len (vam->ip6_fib_counters); i++) + { + msg = vat_json_array_add (msg_array); + vat_json_init_object (msg); + vat_json_object_add_uint (msg, "vrf_id", + vam->ip6_fib_counters_vrf_id_by_index[i]); + counter_array = vat_json_object_add (msg, "c"); + vat_json_init_array (counter_array); + for (j = 0; j < vec_len (vam->ip6_fib_counters[i]); j++) + { + counter = vat_json_array_add (counter_array); + vat_json_init_object (counter); + c6 = &vam->ip6_fib_counters[i][j]; + vat_json_object_add_ip6 (counter, "address", c6->address); + vat_json_object_add_uint (counter, "address_length", + c6->address_length); + vat_json_object_add_uint (counter, "packets", c6->packets); + vat_json_object_add_uint (counter, "bytes", c6->bytes); + } + } + + vat_json_print (vam->ofp, &node); + vat_json_free (&node); + + return 0; +} + +int +exec (vat_main_t * vam) +{ + api_main_t *am = &api_main; + vl_api_cli_request_t *mp; + f64 timeout; + void *oldheap; + u8 *cmd = 0; + unformat_input_t *i = vam->input; + + if (vec_len (i->buffer) == 0) + return -1; + + if (vam->exec_mode == 0 && unformat (i, "mode")) + { + vam->exec_mode = 1; + return 0; + } + if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit"))) + { + vam->exec_mode = 0; + return 0; + } + + + M (CLI_REQUEST, cli_request); + + /* + * Copy cmd into shared memory. + * In order for the CLI command to work, it + * must be a vector ending in \n, not a C-string ending + * in \n\0. + */ + pthread_mutex_lock (&am->vlib_rp->mutex); + oldheap = svm_push_data_heap (am->vlib_rp); + + vec_validate (cmd, vec_len (vam->input->buffer) - 1); + clib_memcpy (cmd, vam->input->buffer, vec_len (vam->input->buffer)); + + svm_pop_heap (oldheap); + pthread_mutex_unlock (&am->vlib_rp->mutex); + + mp->cmd_in_shmem = (u64) cmd; + S; + timeout = vat_time_now (vam) + 10.0; + + while (vat_time_now (vam) < timeout) + { + if (vam->result_ready == 1) + { + u8 *free_me; + if (vam->shmem_result != NULL) + print (vam->ofp, "%s", vam->shmem_result); + pthread_mutex_lock (&am->vlib_rp->mutex); + oldheap = svm_push_data_heap (am->vlib_rp); + + free_me = (u8 *) vam->shmem_result; + vec_free (free_me); + + svm_pop_heap (oldheap); + pthread_mutex_unlock (&am->vlib_rp->mutex); + return 0; + } + } + return -99; +} + +/* + * Future replacement of exec() that passes CLI buffers directly in + * the API messages instead of an additional shared memory area. + */ +static int +exec_inband (vat_main_t * vam) +{ + vl_api_cli_inband_t *mp; + f64 timeout; + unformat_input_t *i = vam->input; + + if (vec_len (i->buffer) == 0) + return -1; + + if (vam->exec_mode == 0 && unformat (i, "mode")) + { + vam->exec_mode = 1; + return 0; + } + if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit"))) + { + vam->exec_mode = 0; + return 0; + } + + /* + * In order for the CLI command to work, it + * must be a vector ending in \n, not a C-string ending + * in \n\0. + */ + u32 len = vec_len (vam->input->buffer); + M2 (CLI_INBAND, cli_inband, len); + clib_memcpy (mp->cmd, vam->input->buffer, len); + mp->length = htonl (len); + + S; + W2 (print (vam->ofp, "%s", vam->cmd_reply)); +} + +static int +api_create_loopback (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + vl_api_create_loopback_t *mp; + f64 timeout; + u8 mac_address[6]; + u8 mac_set = 0; + + memset (mac_address, 0, sizeof (mac_address)); + + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "mac %U", unformat_ethernet_address, mac_address)) + mac_set = 1; + else + break; + } + + /* Construct the API message */ + M (CREATE_LOOPBACK, create_loopback); + if (mac_set) + clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address)); + + S; + W; +} + +static int +api_delete_loopback (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + vl_api_delete_loopback_t *mp; + f64 timeout; + u32 sw_if_index = ~0; + + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "sw_if_index %d", &sw_if_index)) + ; + else + break; + } + + if (sw_if_index == ~0) + { + errmsg ("missing sw_if_index"); + return -99; + } + + /* Construct the API message */ + M (DELETE_LOOPBACK, delete_loopback); + mp->sw_if_index = ntohl (sw_if_index); + + S; + W; +} + +static int +api_want_stats (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + vl_api_want_stats_t *mp; + f64 timeout; + int enable = -1; + + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "enable")) + enable = 1; + else if (unformat (i, "disable")) + enable = 0; + else + break; + } + + if (enable == -1) + { + errmsg ("missing enable|disable"); + return -99; + } + + M (WANT_STATS, want_stats); + mp->enable_disable = enable; + + S; + W; +} + +static int +api_want_interface_events (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + vl_api_want_interface_events_t *mp; + f64 timeout; + int enable = -1; + + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "enable")) + enable = 1; + else if (unformat (i, "disable")) + enable = 0; + else + break; + } + + if (enable == -1) + { + errmsg ("missing enable|disable"); + return -99; + } + + M (WANT_INTERFACE_EVENTS, want_interface_events); + mp->enable_disable = enable; + + vam->interface_event_display = enable; + + S; + W; +} + + +/* Note: non-static, called once to set up the initial intfc table */ +int +api_sw_interface_dump (vat_main_t * vam) +{ + vl_api_sw_interface_dump_t *mp; + f64 timeout; + hash_pair_t *p; + name_sort_t *nses = 0, *ns; + sw_interface_subif_t *sub = NULL; + + /* Toss the old name table */ + /* *INDENT-OFF* */ + hash_foreach_pair (p, vam->sw_if_index_by_interface_name, + ({ + vec_add2 (nses, ns, 1); + ns->name = (u8 *)(p->key); + ns->value = (u32) p->value[0]; + })); + /* *INDENT-ON* */ + + hash_free (vam->sw_if_index_by_interface_name); + + vec_foreach (ns, nses) vec_free (ns->name); + + vec_free (nses); + + vec_foreach (sub, vam->sw_if_subif_table) + { + vec_free (sub->interface_name); + } + vec_free (vam->sw_if_subif_table); + + /* recreate the interface name hash table */ + vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword)); + + /* Get list of ethernets */ + M (SW_INTERFACE_DUMP, sw_interface_dump); + mp->name_filter_valid = 1; + strncpy ((char *) mp->name_filter, "Ether", sizeof (mp->name_filter) - 1); + S; + + /* and local / loopback interfaces */ + M (SW_INTERFACE_DUMP, sw_interface_dump); + mp->name_filter_valid = 1; + strncpy ((char *) mp->name_filter, "lo", sizeof (mp->name_filter) - 1); + S; + + /* and packet-generator interfaces */ + M (SW_INTERFACE_DUMP, sw_interface_dump); + mp->name_filter_valid = 1; + strncpy ((char *) mp->name_filter, "pg", sizeof (mp->name_filter) - 1); + S; + + /* and vxlan-gpe tunnel interfaces */ + M (SW_INTERFACE_DUMP, sw_interface_dump); + mp->name_filter_valid = 1; + strncpy ((char *) mp->name_filter, "vxlan_gpe", + sizeof (mp->name_filter) - 1); + S; + + /* and vxlan tunnel interfaces */ + M (SW_INTERFACE_DUMP, sw_interface_dump); + mp->name_filter_valid = 1; + strncpy ((char *) mp->name_filter, "vxlan", sizeof (mp->name_filter) - 1); + S; + + /* and host (af_packet) interfaces */ + M (SW_INTERFACE_DUMP, sw_interface_dump); + mp->name_filter_valid = 1; + strncpy ((char *) mp->name_filter, "host", sizeof (mp->name_filter) - 1); + S; + + /* and l2tpv3 tunnel interfaces */ + M (SW_INTERFACE_DUMP, sw_interface_dump); + mp->name_filter_valid = 1; + strncpy ((char *) mp->name_filter, "l2tpv3_tunnel", + sizeof (mp->name_filter) - 1); + S; + + /* and GRE tunnel interfaces */ + M (SW_INTERFACE_DUMP, sw_interface_dump); + mp->name_filter_valid = 1; + strncpy ((char *) mp->name_filter, "gre", sizeof (mp->name_filter) - 1); + S; + + /* and LISP-GPE interfaces */ + M (SW_INTERFACE_DUMP, sw_interface_dump); + mp->name_filter_valid = 1; + strncpy ((char *) mp->name_filter, "lisp_gpe", + sizeof (mp->name_filter) - 1); + S; + + /* and IPSEC tunnel interfaces */ + M (SW_INTERFACE_DUMP, sw_interface_dump); + mp->name_filter_valid = 1; + strncpy ((char *) mp->name_filter, "ipsec", sizeof (mp->name_filter) - 1); + S; + + /* Use a control ping for synchronization */ + { + vl_api_control_ping_t *mp; + M (CONTROL_PING, control_ping); + S; + } + W; +} + +static int +api_sw_interface_set_flags (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + vl_api_sw_interface_set_flags_t *mp; + f64 timeout; + u32 sw_if_index; + u8 sw_if_index_set = 0; + u8 admin_up = 0, link_up = 0; + + /* Parse args required to build the message */ + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "admin-up")) + admin_up = 1; + else if (unformat (i, "admin-down")) + admin_up = 0; + else if (unformat (i, "link-up")) + link_up = 1; + else if (unformat (i, "link-down")) + link_up = 0; + else + if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index)) + sw_if_index_set = 1; + else if (unformat (i, "sw_if_index %d", &sw_if_index)) + sw_if_index_set = 1; + else + break; + } + + if (sw_if_index_set == 0) + { + errmsg ("missing interface name or sw_if_index"); + return -99; + } + + /* Construct the API message */ + M (SW_INTERFACE_SET_FLAGS, sw_interface_set_flags); + mp->sw_if_index = ntohl (sw_if_index); + mp->admin_up_down = admin_up; + mp->link_up_down = link_up; + + /* send it... */ + S; + + /* Wait for a reply, return the good/bad news... */ + W; +} + +static int +api_sw_interface_clear_stats (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + vl_api_sw_interface_clear_stats_t *mp; + f64 timeout; + u32 sw_if_index; + u8 sw_if_index_set = 0; + + /* Parse args required to build the message */ + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index)) + sw_if_index_set = 1; + else if (unformat (i, "sw_if_index %d", &sw_if_index)) + sw_if_index_set = 1; + else + break; + } + + /* Construct the API message */ + M (SW_INTERFACE_CLEAR_STATS, sw_interface_clear_stats); + + if (sw_if_index_set == 1) + mp->sw_if_index = ntohl (sw_if_index); + else + mp->sw_if_index = ~0; + + /* send it... */ + S; + + /* Wait for a reply, return the good/bad news... */ + W; +} + +static int +api_sw_interface_set_dpdk_hqos_pipe (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + vl_api_sw_interface_set_dpdk_hqos_pipe_t *mp; + f64 timeout; + u32 sw_if_index; + u8 sw_if_index_set = 0; + u32 subport; + u8 subport_set = 0; + u32 pipe; + u8 pipe_set = 0; + u32 profile; + u8 profile_set = 0; + + /* Parse args required to build the message */ + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "rx %U", api_unformat_sw_if_index, vam, &sw_if_index)) + sw_if_index_set = 1; + else if (unformat (i, "sw_if_index %u", &sw_if_index)) + sw_if_index_set = 1; + else if (unformat (i, "subport %u", &subport)) + subport_set = 1; + else + if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index)) + sw_if_index_set = 1; + else if (unformat (i, "pipe %u", &pipe)) + pipe_set = 1; + else if (unformat (i, "profile %u", &profile)) + profile_set = 1; + else + break; + } + + if (sw_if_index_set == 0) + { + errmsg ("missing interface name or sw_if_index"); + return -99; + } + + if (subport_set == 0) + { + errmsg ("missing subport "); + return -99; + } + + if (pipe_set == 0) + { + errmsg ("missing pipe"); + return -99; + } + + if (profile_set == 0) + { + errmsg ("missing profile"); + return -99; + } + + M (SW_INTERFACE_SET_DPDK_HQOS_PIPE, sw_interface_set_dpdk_hqos_pipe); + + mp->sw_if_index = ntohl (sw_if_index); + mp->subport = ntohl (subport); + mp->pipe = ntohl (pipe); + mp->profile = ntohl (profile); + + + S; + W; + /* NOTREACHED */ + return 0; +} + +static int +api_sw_interface_set_dpdk_hqos_subport (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + vl_api_sw_interface_set_dpdk_hqos_subport_t *mp; + f64 timeout; + u32 sw_if_index; + u8 sw_if_index_set = 0; + u32 subport; + u8 subport_set = 0; + u32 tb_rate = 1250000000; /* 10GbE */ + u32 tb_size = 1000000; + u32 tc_rate[] = { 1250000000, 1250000000, 1250000000, 1250000000 }; + u32 tc_period = 10; + + /* Parse args required to build the message */ + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "rx %U", api_unformat_sw_if_index, vam, &sw_if_index)) + sw_if_index_set = 1; + else if (unformat (i, "sw_if_index %u", &sw_if_index)) + sw_if_index_set = 1; + else if (unformat (i, "subport %u", &subport)) + subport_set = 1; + else + if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index)) + sw_if_index_set = 1; + else if (unformat (i, "rate %u", &tb_rate)) + { + u32 tc_id; + + for (tc_id = 0; tc_id < (sizeof (tc_rate) / sizeof (tc_rate[0])); + tc_id++) + tc_rate[tc_id] = tb_rate; + } + else if (unformat (i, "bktsize %u", &tb_size)) + ; + else if (unformat (i, "tc0 %u", &tc_rate[0])) + ; + else if (unformat (i, "tc1 %u", &tc_rate[1])) + ; + else if (unformat (i, "tc2 %u", &tc_rate[2])) + ; + else if (unformat (i, "tc3 %u", &tc_rate[3])) + ; + else if (unformat (i, "period %u", &tc_period)) + ; + else + break; + } + + if (sw_if_index_set == 0) + { + errmsg ("missing interface name or sw_if_index"); + return -99; + } + + if (subport_set == 0) + { + errmsg ("missing subport "); + return -99; + } + + M (SW_INTERFACE_SET_DPDK_HQOS_SUBPORT, sw_interface_set_dpdk_hqos_subport); + + mp->sw_if_index = ntohl (sw_if_index); + mp->subport = ntohl (subport); + mp->tb_rate = ntohl (tb_rate); + mp->tb_size = ntohl (tb_size); + mp->tc_rate[0] = ntohl (tc_rate[0]); + mp->tc_rate[1] = ntohl (tc_rate[1]); + mp->tc_rate[2] = ntohl (tc_rate[2]); + mp->tc_rate[3] = ntohl (tc_rate[3]); + mp->tc_period = ntohl (tc_period); + + S; + W; + /* NOTREACHED */ + return 0; +} + +static int +api_sw_interface_set_dpdk_hqos_tctbl (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + vl_api_sw_interface_set_dpdk_hqos_tctbl_t *mp; + f64 timeout; + u32 sw_if_index; + u8 sw_if_index_set = 0; + u8 entry_set = 0; + u8 tc_set = 0; + u8 queue_set = 0; + u32 entry, tc, queue; + + /* Parse args required to build the message */ + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "rx %U", api_unformat_sw_if_index, vam, &sw_if_index)) + sw_if_index_set = 1; + else if (unformat (i, "sw_if_index %u", &sw_if_index)) + sw_if_index_set = 1; + else if (unformat (i, "entry %d", &entry)) + entry_set = 1; + else if (unformat (i, "tc %d", &tc)) + tc_set = 1; + else if (unformat (i, "queue %d", &queue)) + queue_set = 1; + else + break; + } + + if (sw_if_index_set == 0) + { + errmsg ("missing interface name or sw_if_index"); + return -99; + } + + if (entry_set == 0) + { + errmsg ("missing entry "); + return -99; + } + + if (tc_set == 0) + { + errmsg ("missing traffic class "); + return -99; + } + + if (queue_set == 0) + { + errmsg ("missing queue "); + return -99; + } + + M (SW_INTERFACE_SET_DPDK_HQOS_TCTBL, sw_interface_set_dpdk_hqos_tctbl); + + mp->sw_if_index = ntohl (sw_if_index); + mp->entry = ntohl (entry); + mp->tc = ntohl (tc); + mp->queue = ntohl (queue); + + S; + W; + /* NOTREACHED */ + return 0; +} + +static int +api_sw_interface_add_del_address (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + vl_api_sw_interface_add_del_address_t *mp; + f64 timeout; + u32 sw_if_index; + u8 sw_if_index_set = 0; + u8 is_add = 1, del_all = 0; + u32 address_length = 0; + u8 v4_address_set = 0; + u8 v6_address_set = 0; + ip4_address_t v4address; + ip6_address_t v6address; + + /* Parse args required to build the message */ + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "del-all")) + del_all = 1; + else if (unformat (i, "del")) + is_add = 0; + else + if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index)) + sw_if_index_set = 1; + else if (unformat (i, "sw_if_index %d", &sw_if_index)) + sw_if_index_set = 1; + else if (unformat (i, "%U/%d", + unformat_ip4_address, &v4address, &address_length)) + v4_address_set = 1; + else if (unformat (i, "%U/%d", + unformat_ip6_address, &v6address, &address_length)) + v6_address_set = 1; + else + break; + } + + if (sw_if_index_set == 0) + { + errmsg ("missing interface name or sw_if_index"); + return -99; + } + if (v4_address_set && v6_address_set) + { + errmsg ("both v4 and v6 addresses set"); + return -99; + } + if (!v4_address_set && !v6_address_set && !del_all) + { + errmsg ("no addresses set"); + return -99; + } + + /* Construct the API message */ + M (SW_INTERFACE_ADD_DEL_ADDRESS, sw_interface_add_del_address); + + mp->sw_if_index = ntohl (sw_if_index); + mp->is_add = is_add; + mp->del_all = del_all; + if (v6_address_set) + { + mp->is_ipv6 = 1; + clib_memcpy (mp->address, &v6address, sizeof (v6address)); + } + else + { + clib_memcpy (mp->address, &v4address, sizeof (v4address)); + } + mp->address_length = address_length; + + /* send it... */ + S; + + /* Wait for a reply, return good/bad news */ + W; +} + +static int +api_sw_interface_set_mpls_enable (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + vl_api_sw_interface_set_mpls_enable_t *mp; + f64 timeout; + u32 sw_if_index; + u8 sw_if_index_set = 0; + u8 enable = 1; + + /* Parse args required to build the message */ + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index)) + sw_if_index_set = 1; + else if (unformat (i, "sw_if_index %d", &sw_if_index)) + sw_if_index_set = 1; + else if (unformat (i, "disable")) + enable = 0; + else if (unformat (i, "dis")) + enable = 0; + else + break; + } + + if (sw_if_index_set == 0) + { + errmsg ("missing interface name or sw_if_index"); + return -99; + } + + /* Construct the API message */ + M (SW_INTERFACE_SET_MPLS_ENABLE, sw_interface_set_mpls_enable); + + mp->sw_if_index = ntohl (sw_if_index); + mp->enable = enable; + + /* send it... */ + S; + + /* Wait for a reply... */ + W; +} + +static int +api_sw_interface_set_table (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + vl_api_sw_interface_set_table_t *mp; + f64 timeout; + u32 sw_if_index, vrf_id = 0; + u8 sw_if_index_set = 0; + u8 is_ipv6 = 0; + + /* Parse args required to build the message */ + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index)) + sw_if_index_set = 1; + else if (unformat (i, "sw_if_index %d", &sw_if_index)) + sw_if_index_set = 1; + else if (unformat (i, "vrf %d", &vrf_id)) + ; + else if (unformat (i, "ipv6")) + is_ipv6 = 1; + else + break; + } + + if (sw_if_index_set == 0) + { + errmsg ("missing interface name or sw_if_index"); + return -99; + } + + /* Construct the API message */ + M (SW_INTERFACE_SET_TABLE, sw_interface_set_table); + + mp->sw_if_index = ntohl (sw_if_index); + mp->is_ipv6 = is_ipv6; + mp->vrf_id = ntohl (vrf_id); + + /* send it... */ + S; + + /* Wait for a reply... */ + W; +} + +static void vl_api_sw_interface_get_table_reply_t_handler + (vl_api_sw_interface_get_table_reply_t * mp) +{ + vat_main_t *vam = &vat_main; + + print (vam->ofp, "%d", ntohl (mp->vrf_id)); + + vam->retval = ntohl (mp->retval); + vam->result_ready = 1; + +} + +static void vl_api_sw_interface_get_table_reply_t_handler_json + (vl_api_sw_interface_get_table_reply_t * mp) +{ + vat_main_t *vam = &vat_main; + vat_json_node_t node; + + vat_json_init_object (&node); + vat_json_object_add_int (&node, "retval", ntohl (mp->retval)); + vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id)); + + vat_json_print (vam->ofp, &node); + vat_json_free (&node); + + vam->retval = ntohl (mp->retval); + vam->result_ready = 1; +} + +static int +api_sw_interface_get_table (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + vl_api_sw_interface_get_table_t *mp; + u32 sw_if_index; + u8 sw_if_index_set = 0; + u8 is_ipv6 = 0; + f64 timeout; + + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index)) + sw_if_index_set = 1; + else if (unformat (i, "sw_if_index %d", &sw_if_index)) + sw_if_index_set = 1; + else if (unformat (i, "ipv6")) + is_ipv6 = 1; + else + break; + } + + if (sw_if_index_set == 0) + { + errmsg ("missing interface name or sw_if_index"); + return -99; + } + + M (SW_INTERFACE_GET_TABLE, sw_interface_get_table); + mp->sw_if_index = htonl (sw_if_index); + mp->is_ipv6 = is_ipv6; + + S; + W; +} + +static int +api_sw_interface_set_vpath (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + vl_api_sw_interface_set_vpath_t *mp; + f64 timeout; + u32 sw_if_index = 0; + u8 sw_if_index_set = 0; + u8 is_enable = 0; + + /* Parse args required to build the message */ + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index)) + sw_if_index_set = 1; + else if (unformat (i, "sw_if_index %d", &sw_if_index)) + sw_if_index_set = 1; + else if (unformat (i, "enable")) + is_enable = 1; + else if (unformat (i, "disable")) + is_enable = 0; + else + break; + } + + if (sw_if_index_set == 0) + { + errmsg ("missing interface name or sw_if_index"); + return -99; + } + + /* Construct the API message */ + M (SW_INTERFACE_SET_VPATH, sw_interface_set_vpath); + + mp->sw_if_index = ntohl (sw_if_index); + mp->enable = is_enable; + + /* send it... */ + S; + + /* Wait for a reply... */ + W; +} + +static int +api_sw_interface_set_vxlan_bypass (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + vl_api_sw_interface_set_vxlan_bypass_t *mp; + f64 timeout; + u32 sw_if_index = 0; + u8 sw_if_index_set = 0; + u8 is_enable = 0; + u8 is_ipv6 = 0; + + /* Parse args required to build the message */ + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index)) + sw_if_index_set = 1; + else if (unformat (i, "sw_if_index %d", &sw_if_index)) + sw_if_index_set = 1; + else if (unformat (i, "enable")) + is_enable = 1; + else if (unformat (i, "disable")) + is_enable = 0; + else if (unformat (i, "ip4")) + is_ipv6 = 0; + else if (unformat (i, "ip6")) + is_ipv6 = 1; + else + break; + } + + if (sw_if_index_set == 0) + { + errmsg ("missing interface name or sw_if_index"); + return -99; + } + + /* Construct the API message */ + M (SW_INTERFACE_SET_VXLAN_BYPASS, sw_interface_set_vxlan_bypass); + + mp->sw_if_index = ntohl (sw_if_index); + mp->enable = is_enable; + mp->is_ipv6 = is_ipv6; + + /* send it... */ + S; + + /* Wait for a reply... */ + W; +} + +static int +api_sw_interface_set_l2_xconnect (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + vl_api_sw_interface_set_l2_xconnect_t *mp; + f64 timeout; + u32 rx_sw_if_index; + u8 rx_sw_if_index_set = 0; + u32 tx_sw_if_index; + u8 tx_sw_if_index_set = 0; + u8 enable = 1; + + /* Parse args required to build the message */ + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index)) + rx_sw_if_index_set = 1; + else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index)) + tx_sw_if_index_set = 1; + else if (unformat (i, "rx")) + { + if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "%U", api_unformat_sw_if_index, vam, + &rx_sw_if_index)) + rx_sw_if_index_set = 1; + } + else + break; + } + else if (unformat (i, "tx")) + { + if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "%U", api_unformat_sw_if_index, vam, + &tx_sw_if_index)) + tx_sw_if_index_set = 1; + } + else + break; + } + else if (unformat (i, "enable")) + enable = 1; + else if (unformat (i, "disable")) + enable = 0; + else + break; + } + + if (rx_sw_if_index_set == 0) + { + errmsg ("missing rx interface name or rx_sw_if_index"); + return -99; + } + + if (enable && (tx_sw_if_index_set == 0)) + { + errmsg ("missing tx interface name or tx_sw_if_index"); + return -99; + } + + M (SW_INTERFACE_SET_L2_XCONNECT, sw_interface_set_l2_xconnect); + + mp->rx_sw_if_index = ntohl (rx_sw_if_index); + mp->tx_sw_if_index = ntohl (tx_sw_if_index); + mp->enable = enable; + + S; + W; + /* NOTREACHED */ + return 0; +} + +static int +api_sw_interface_set_l2_bridge (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + vl_api_sw_interface_set_l2_bridge_t *mp; + f64 timeout; + u32 rx_sw_if_index; + u8 rx_sw_if_index_set = 0; + u32 bd_id; + u8 bd_id_set = 0; + u8 bvi = 0; + u32 shg = 0; + u8 enable = 1; + + /* Parse args required to build the message */ + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "sw_if_index %d", &rx_sw_if_index)) + rx_sw_if_index_set = 1; + else if (unformat (i, "bd_id %d", &bd_id)) + bd_id_set = 1; + else + if (unformat + (i, "%U", api_unformat_sw_if_index, vam, &rx_sw_if_index)) + rx_sw_if_index_set = 1; + else if (unformat (i, "shg %d", &shg)) + ; + else if (unformat (i, "bvi")) + bvi = 1; + else if (unformat (i, "enable")) + enable = 1; + else if (unformat (i, "disable")) + enable = 0; + else + break; + } + + if (rx_sw_if_index_set == 0) + { + errmsg ("missing rx interface name or sw_if_index"); + return -99; + } + + if (enable && (bd_id_set == 0)) + { + errmsg ("missing bridge domain"); + return -99; + } + + M (SW_INTERFACE_SET_L2_BRIDGE, sw_interface_set_l2_bridge); + + mp->rx_sw_if_index = ntohl (rx_sw_if_index); + mp->bd_id = ntohl (bd_id); + mp->shg = (u8) shg; + mp->bvi = bvi; + mp->enable = enable; + + S; + W; + /* NOTREACHED */ + return 0; +} + +static int +api_bridge_domain_dump (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + vl_api_bridge_domain_dump_t *mp; + f64 timeout; + u32 bd_id = ~0; + + /* Parse args required to build the message */ + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "bd_id %d", &bd_id)) + ; + else + break; + } + + M (BRIDGE_DOMAIN_DUMP, bridge_domain_dump); + mp->bd_id = ntohl (bd_id); + S; + + /* Use a control ping for synchronization */ + { + vl_api_control_ping_t *mp; + M (CONTROL_PING, control_ping); + S; + } + + W; + /* NOTREACHED */ + return 0; +} + +static int +api_bridge_domain_add_del (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + vl_api_bridge_domain_add_del_t *mp; + f64 timeout; + u32 bd_id = ~0; + u8 is_add = 1; + u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0; + u32 mac_age = 0; + + /* Parse args required to build the message */ + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "bd_id %d", &bd_id)) + ; + else if (unformat (i, "flood %d", &flood)) + ; + else if (unformat (i, "uu-flood %d", &uu_flood)) + ; + else if (unformat (i, "forward %d", &forward)) + ; + else if (unformat (i, "learn %d", &learn)) + ; + else if (unformat (i, "arp-term %d", &arp_term)) + ; + else if (unformat (i, "mac-age %d", &mac_age)) + ; + else if (unformat (i, "del")) + { + is_add = 0; + flood = uu_flood = forward = learn = 0; + } + else + break; + } + + if (bd_id == ~0) + { + errmsg ("missing bridge domain"); + return -99; + } + + if (mac_age > 255) + { + errmsg ("mac age must be less than 256 "); + return -99; + } + + M (BRIDGE_DOMAIN_ADD_DEL, bridge_domain_add_del); + + mp->bd_id = ntohl (bd_id); + mp->flood = flood; + mp->uu_flood = uu_flood; + mp->forward = forward; + mp->learn = learn; + mp->arp_term = arp_term; + mp->is_add = is_add; + mp->mac_age = (u8) mac_age; + + S; + W; + /* NOTREACHED */ + return 0; +} + +static int +api_l2fib_add_del (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + vl_api_l2fib_add_del_t *mp; + f64 timeout; + u64 mac = 0; + u8 mac_set = 0; + u32 bd_id; + u8 bd_id_set = 0; + u32 sw_if_index = ~0; + u8 sw_if_index_set = 0; + u8 is_add = 1; + u8 static_mac = 0; + u8 filter_mac = 0; + u8 bvi_mac = 0; + int count = 1; + f64 before = 0; + int j; + + /* Parse args required to build the message */ + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "mac %U", unformat_ethernet_address, &mac)) + mac_set = 1; + else if (unformat (i, "bd_id %d", &bd_id)) + bd_id_set = 1; + else if (unformat (i, "sw_if_index %d", &sw_if_index)) + sw_if_index_set = 1; + else if (unformat (i, "sw_if")) + { + if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat + (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index)) + sw_if_index_set = 1; + } + else + break; + } + else if (unformat (i, "static")) + static_mac = 1; + else if (unformat (i, "filter")) + { + filter_mac = 1; + static_mac = 1; + } + else if (unformat (i, "bvi")) + { + bvi_mac = 1; + static_mac = 1; + } + else if (unformat (i, "del")) + is_add = 0; + else if (unformat (i, "count %d", &count)) + ; + else + break; + } + + if (mac_set == 0) + { + errmsg ("missing mac address"); + return -99; + } + + if (bd_id_set == 0) + { + errmsg ("missing bridge domain"); + return -99; + } + + if (is_add && sw_if_index_set == 0 && filter_mac == 0) + { + errmsg ("missing interface name or sw_if_index"); + return -99; + } + + if (count > 1) + { + /* Turn on async mode */ + vam->async_mode = 1; + vam->async_errors = 0; + before = vat_time_now (vam); + } + + for (j = 0; j < count; j++) + { + M (L2FIB_ADD_DEL, l2fib_add_del); + + mp->mac = mac; + mp->bd_id = ntohl (bd_id); + mp->is_add = is_add; + + if (is_add) + { + mp->sw_if_index = ntohl (sw_if_index); + mp->static_mac = static_mac; + mp->filter_mac = filter_mac; + mp->bvi_mac = bvi_mac; + } + increment_mac_address (&mac); + /* send it... */ + S; + } + + if (count > 1) + { + vl_api_control_ping_t *mp; + f64 after; + + /* Shut off async mode */ + vam->async_mode = 0; + + M (CONTROL_PING, control_ping); + S; + + timeout = vat_time_now (vam) + 1.0; + while (vat_time_now (vam) < timeout) + if (vam->result_ready == 1) + goto out; + vam->retval = -99; + + out: + if (vam->retval == -99) + errmsg ("timeout"); + + if (vam->async_errors > 0) + { + errmsg ("%d asynchronous errors", vam->async_errors); + vam->retval = -98; + } + vam->async_errors = 0; + after = vat_time_now (vam); + + print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec", + count, after - before, count / (after - before)); + } + else + { + /* Wait for a reply... */ + W; + } + /* Return the good/bad news */ + return (vam->retval); +} + +static int +api_l2_flags (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + vl_api_l2_flags_t *mp; + f64 timeout; + u32 sw_if_index; + u32 feature_bitmap = 0; + u8 sw_if_index_set = 0; + + /* Parse args required to build the message */ + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "sw_if_index %d", &sw_if_index)) + sw_if_index_set = 1; + else if (unformat (i, "sw_if")) + { + if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat + (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index)) + sw_if_index_set = 1; + } + else + break; + } + else if (unformat (i, "learn")) + feature_bitmap |= L2INPUT_FEAT_LEARN; + else if (unformat (i, "forward")) + feature_bitmap |= L2INPUT_FEAT_FWD; + else if (unformat (i, "flood")) + feature_bitmap |= L2INPUT_FEAT_FLOOD; + else if (unformat (i, "uu-flood")) + feature_bitmap |= L2INPUT_FEAT_UU_FLOOD; + else + break; + } + + if (sw_if_index_set == 0) + { + errmsg ("missing interface name or sw_if_index"); + return -99; + } + + M (L2_FLAGS, l2_flags); + + mp->sw_if_index = ntohl (sw_if_index); + mp->feature_bitmap = ntohl (feature_bitmap); + + S; + W; + /* NOTREACHED */ + return 0; +} + +static int +api_bridge_flags (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + vl_api_bridge_flags_t *mp; + f64 timeout; + u32 bd_id; + u8 bd_id_set = 0; + u8 is_set = 1; + u32 flags = 0; + + /* Parse args required to build the message */ + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "bd_id %d", &bd_id)) + bd_id_set = 1; + else if (unformat (i, "learn")) + flags |= L2_LEARN; + else if (unformat (i, "forward")) + flags |= L2_FWD; + else if (unformat (i, "flood")) + flags |= L2_FLOOD; + else if (unformat (i, "uu-flood")) + flags |= L2_UU_FLOOD; + else if (unformat (i, "arp-term")) + flags |= L2_ARP_TERM; + else if (unformat (i, "off")) + is_set = 0; + else if (unformat (i, "disable")) + is_set = 0; + else + break; + } + + if (bd_id_set == 0) + { + errmsg ("missing bridge domain"); + return -99; + } + + M (BRIDGE_FLAGS, bridge_flags); + + mp->bd_id = ntohl (bd_id); + mp->feature_bitmap = ntohl (flags); + mp->is_set = is_set; + + S; + W; + /* NOTREACHED */ + return 0; +} + +static int +api_bd_ip_mac_add_del (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + vl_api_bd_ip_mac_add_del_t *mp; + f64 timeout; + u32 bd_id; + u8 is_ipv6 = 0; + u8 is_add = 1; + u8 bd_id_set = 0; + u8 ip_set = 0; + u8 mac_set = 0; + ip4_address_t v4addr; + ip6_address_t v6addr; + u8 macaddr[6]; + + + /* Parse args required to build the message */ + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "bd_id %d", &bd_id)) + { + bd_id_set++; + } + else if (unformat (i, "%U", unformat_ip4_address, &v4addr)) + { + ip_set++; + } + else if (unformat (i, "%U", unformat_ip6_address, &v6addr)) + { + ip_set++; + is_ipv6++; + } + else if (unformat (i, "%U", unformat_ethernet_address, macaddr)) + { + mac_set++; + } + else if (unformat (i, "del")) + is_add = 0; + else + break; + } + + if (bd_id_set == 0) + { + errmsg ("missing bridge domain"); + return -99; + } + else if (ip_set == 0) + { + errmsg ("missing IP address"); + return -99; + } + else if (mac_set == 0) + { + errmsg ("missing MAC address"); + return -99; + } + + M (BD_IP_MAC_ADD_DEL, bd_ip_mac_add_del); + + mp->bd_id = ntohl (bd_id); + mp->is_ipv6 = is_ipv6; + mp->is_add = is_add; + if (is_ipv6) + clib_memcpy (mp->ip_address, &v6addr, sizeof (v6addr)); + else + clib_memcpy (mp->ip_address, &v4addr, sizeof (v4addr)); + clib_memcpy (mp->mac_address, macaddr, 6); + S; + W; + /* NOTREACHED */ + return 0; +} + +static int +api_tap_connect (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + vl_api_tap_connect_t *mp; + f64 timeout; + u8 mac_address[6]; + u8 random_mac = 1; + u8 name_set = 0; + u8 *tap_name; + u8 *tag = 0; + + memset (mac_address, 0, sizeof (mac_address)); + + /* Parse args required to build the message */ + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "mac %U", unformat_ethernet_address, mac_address)) + { + random_mac = 0; + } + else if (unformat (i, "random-mac")) + random_mac = 1; + else if (unformat (i, "tapname %s", &tap_name)) + name_set = 1; + else if (unformat (i, "tag %s", &tag)) + ; + else + break; + } + + if (name_set == 0) + { + errmsg ("missing tap name"); + return -99; + } + if (vec_len (tap_name) > 63) + { + errmsg ("tap name too long"); + return -99; + } + vec_add1 (tap_name, 0); + + if (vec_len (tag) > 63) + { + errmsg ("tag too long"); + return -99; + } + + /* Construct the API message */ + M (TAP_CONNECT, tap_connect); + + mp->use_random_mac = random_mac; + clib_memcpy (mp->mac_address, mac_address, 6); + clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name)); + if (tag) + clib_memcpy (mp->tag, tag, vec_len (tag)); + + vec_free (tap_name); + vec_free (tag); + + /* send it... */ + S; + + /* Wait for a reply... */ + W; +} + +static int +api_tap_modify (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + vl_api_tap_modify_t *mp; + f64 timeout; + u8 mac_address[6]; + u8 random_mac = 1; + u8 name_set = 0; + u8 *tap_name; + u32 sw_if_index = ~0; + u8 sw_if_index_set = 0; + + memset (mac_address, 0, sizeof (mac_address)); + + /* Parse args required to build the message */ + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index)) + sw_if_index_set = 1; + else if (unformat (i, "sw_if_index %d", &sw_if_index)) + sw_if_index_set = 1; + else if (unformat (i, "mac %U", unformat_ethernet_address, mac_address)) + { + random_mac = 0; + } + else if (unformat (i, "random-mac")) + random_mac = 1; + else if (unformat (i, "tapname %s", &tap_name)) + name_set = 1; + else + break; + } + + if (sw_if_index_set == 0) + { + errmsg ("missing vpp interface name"); + return -99; + } + if (name_set == 0) + { + errmsg ("missing tap name"); + return -99; + } + if (vec_len (tap_name) > 63) + { + errmsg ("tap name too long"); + } + vec_add1 (tap_name, 0); + + /* Construct the API message */ + M (TAP_MODIFY, tap_modify); + + mp->use_random_mac = random_mac; + mp->sw_if_index = ntohl (sw_if_index); + clib_memcpy (mp->mac_address, mac_address, 6); + clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name)); + vec_free (tap_name); + + /* send it... */ + S; + + /* Wait for a reply... */ + W; +} + +static int +api_tap_delete (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + vl_api_tap_delete_t *mp; + f64 timeout; + u32 sw_if_index = ~0; + u8 sw_if_index_set = 0; + + /* Parse args required to build the message */ + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index)) + sw_if_index_set = 1; + else if (unformat (i, "sw_if_index %d", &sw_if_index)) + sw_if_index_set = 1; + else + break; + } + + if (sw_if_index_set == 0) + { + errmsg ("missing vpp interface name"); + return -99; + } + + /* Construct the API message */ + M (TAP_DELETE, tap_delete); + + mp->sw_if_index = ntohl (sw_if_index); + + /* send it... */ + S; + + /* Wait for a reply... */ + W; +} + +static int +api_ip_add_del_route (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + vl_api_ip_add_del_route_t *mp; + f64 timeout; + u32 sw_if_index = ~0, vrf_id = 0; + u8 is_ipv6 = 0; + u8 is_local = 0, is_drop = 0; + u8 is_unreach = 0, is_prohibit = 0; + u8 create_vrf_if_needed = 0; + u8 is_add = 1; + u32 next_hop_weight = 1; + u8 not_last = 0; + u8 is_multipath = 0; + u8 address_set = 0; + u8 address_length_set = 0; + u32 next_hop_table_id = 0; + u32 resolve_attempts = 0; + u32 dst_address_length = 0; + u8 next_hop_set = 0; + ip4_address_t v4_dst_address, v4_next_hop_address; + ip6_address_t v6_dst_address, v6_next_hop_address; + int count = 1; + int j; + f64 before = 0; + u32 random_add_del = 0; + u32 *random_vector = 0; + uword *random_hash; + u32 random_seed = 0xdeaddabe; + u32 classify_table_index = ~0; + u8 is_classify = 0; + u8 resolve_host = 0, resolve_attached = 0; + mpls_label_t *next_hop_out_label_stack = NULL; + mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID; + mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID; + + /* Parse args required to build the message */ + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index)) + ; + else if (unformat (i, "sw_if_index %d", &sw_if_index)) + ; + else if (unformat (i, "%U", unformat_ip4_address, &v4_dst_address)) + { + address_set = 1; + is_ipv6 = 0; + } + else if (unformat (i, "%U", unformat_ip6_address, &v6_dst_address)) + { + address_set = 1; + is_ipv6 = 1; + } + else if (unformat (i, "/%d", &dst_address_length)) + { + address_length_set = 1; + } + + else if (is_ipv6 == 0 && unformat (i, "via %U", unformat_ip4_address, + &v4_next_hop_address)) + { + next_hop_set = 1; + } + else if (is_ipv6 == 1 && unformat (i, "via %U", unformat_ip6_address, + &v6_next_hop_address)) + { + next_hop_set = 1; + } + else if (unformat (i, "resolve-attempts %d", &resolve_attempts)) + ; + else if (unformat (i, "weight %d", &next_hop_weight)) + ; + else if (unformat (i, "drop")) + { + is_drop = 1; + } + else if (unformat (i, "null-send-unreach")) + { + is_unreach = 1; + } + else if (unformat (i, "null-send-prohibit")) + { + is_prohibit = 1; + } + else if (unformat (i, "local")) + { + is_local = 1; + } + else if (unformat (i, "classify %d", &classify_table_index)) + { + is_classify = 1; + } + else if (unformat (i, "del")) + is_add = 0; + else if (unformat (i, "add")) + is_add = 1; + else if (unformat (i, "not-last")) + not_last = 1; + else if (unformat (i, "resolve-via-host")) + resolve_host = 1; + else if (unformat (i, "resolve-via-attached")) + resolve_attached = 1; + else if (unformat (i, "multipath")) + is_multipath = 1; + else if (unformat (i, "vrf %d", &vrf_id)) + ; + else if (unformat (i, "create-vrf")) + create_vrf_if_needed = 1; + else if (unformat (i, "count %d", &count)) + ; + else if (unformat (i, "lookup-in-vrf %d", &next_hop_table_id)) + ; + else if (unformat (i, "next-hop-table %d", &next_hop_table_id)) + ; + else if (unformat (i, "out-label %d", &next_hop_out_label)) + vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label)); + else if (unformat (i, "via-label %d", &next_hop_via_label)) + ; + else if (unformat (i, "random")) + random_add_del = 1; + else if (unformat (i, "seed %d", &random_seed)) + ; + else + { + clib_warning ("parse error '%U'", format_unformat_error, i); + return -99; + } + } + + if (!next_hop_set && !is_drop && !is_local && + !is_classify && !is_unreach && !is_prohibit && + MPLS_LABEL_INVALID == next_hop_via_label) + { + errmsg + ("next hop / local / drop / unreach / prohibit / classify not set"); + return -99; + } + + if (next_hop_set && MPLS_LABEL_INVALID != next_hop_via_label) + { + errmsg ("next hop and next-hop via label set"); + return -99; + } + if (address_set == 0) + { + errmsg ("missing addresses"); + return -99; + } + + if (address_length_set == 0) + { + errmsg ("missing address length"); + return -99; + } + + /* Generate a pile of unique, random routes */ + if (random_add_del) + { + u32 this_random_address; + random_hash = hash_create (count, sizeof (uword)); + + hash_set (random_hash, v4_next_hop_address.as_u32, 1); + for (j = 0; j <= count; j++) + { + do + { + this_random_address = random_u32 (&random_seed); + this_random_address = + clib_host_to_net_u32 (this_random_address); + } + while (hash_get (random_hash, this_random_address)); + vec_add1 (random_vector, this_random_address); + hash_set (random_hash, this_random_address, 1); + } + hash_free (random_hash); + v4_dst_address.as_u32 = random_vector[0]; + } + + if (count > 1) + { + /* Turn on async mode */ + vam->async_mode = 1; + vam->async_errors = 0; + before = vat_time_now (vam); + } + + for (j = 0; j < count; j++) + { + /* Construct the API message */ + M2 (IP_ADD_DEL_ROUTE, ip_add_del_route, + sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack)); + + mp->next_hop_sw_if_index = ntohl (sw_if_index); + mp->table_id = ntohl (vrf_id); + mp->create_vrf_if_needed = create_vrf_if_needed; + + mp->is_add = is_add; + mp->is_drop = is_drop; + mp->is_unreach = is_unreach; + mp->is_prohibit = is_prohibit; + mp->is_ipv6 = is_ipv6; + mp->is_local = is_local; + mp->is_classify = is_classify; + mp->is_multipath = is_multipath; + mp->is_resolve_host = resolve_host; + mp->is_resolve_attached = resolve_attached; + mp->not_last = not_last; + mp->next_hop_weight = next_hop_weight; + mp->dst_address_length = dst_address_length; + mp->next_hop_table_id = ntohl (next_hop_table_id); + mp->classify_table_index = ntohl (classify_table_index); + mp->next_hop_via_label = ntohl (next_hop_via_label); + mp->next_hop_n_out_labels = vec_len (next_hop_out_label_stack); + if (0 != mp->next_hop_n_out_labels) + { + memcpy (mp->next_hop_out_label_stack, + next_hop_out_label_stack, + vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t)); + vec_free (next_hop_out_label_stack); + } + + if (is_ipv6) + { + clib_memcpy (mp->dst_address, &v6_dst_address, + sizeof (v6_dst_address)); + if (next_hop_set) + clib_memcpy (mp->next_hop_address, &v6_next_hop_address, + sizeof (v6_next_hop_address)); + increment_v6_address (&v6_dst_address); + } + else + { + clib_memcpy (mp->dst_address, &v4_dst_address, + sizeof (v4_dst_address)); + if (next_hop_set) + clib_memcpy (mp->next_hop_address, &v4_next_hop_address, + sizeof (v4_next_hop_address)); + if (random_add_del) + v4_dst_address.as_u32 = random_vector[j + 1]; + else + increment_v4_address (&v4_dst_address); + } + /* send it... */ + S; + /* If we receive SIGTERM, stop now... */ + if (vam->do_exit) + break; + } + + /* When testing multiple add/del ops, use a control-ping to sync */ + if (count > 1) + { + vl_api_control_ping_t *mp; + f64 after; + + /* Shut off async mode */ + vam->async_mode = 0; + + M (CONTROL_PING, control_ping); + S; + + timeout = vat_time_now (vam) + 1.0; + while (vat_time_now (vam) < timeout) + if (vam->result_ready == 1) + goto out; + vam->retval = -99; + + out: + if (vam->retval == -99) + errmsg ("timeout"); + + if (vam->async_errors > 0) + { + errmsg ("%d asynchronous errors", vam->async_errors); + vam->retval = -98; + } + vam->async_errors = 0; + after = vat_time_now (vam); + + /* slim chance, but we might have eaten SIGTERM on the first iteration */ + if (j > 0) + count = j; + + print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec", + count, after - before, count / (after - before)); + } + else + { + /* Wait for a reply... */ + W; + } + + /* Return the good/bad news */ + return (vam->retval); +} + +static int +api_mpls_route_add_del (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + vl_api_mpls_route_add_del_t *mp; + f64 timeout; + u32 sw_if_index = ~0, table_id = 0; + u8 create_table_if_needed = 0; + u8 is_add = 1; + u32 next_hop_weight = 1; + u8 is_multipath = 0; + u32 next_hop_table_id = 0; + u8 next_hop_set = 0; + ip4_address_t v4_next_hop_address = { + .as_u32 = 0, + }; + ip6_address_t v6_next_hop_address = { {0} }; + int count = 1; + int j; + f64 before = 0; + u32 classify_table_index = ~0; + u8 is_classify = 0; + u8 resolve_host = 0, resolve_attached = 0; + mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID; + mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID; + mpls_label_t *next_hop_out_label_stack = NULL; + mpls_label_t local_label = MPLS_LABEL_INVALID; + u8 is_eos = 0; + u8 next_hop_proto_is_ip4 = 1; + + /* Parse args required to build the message */ + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index)) + ; + else if (unformat (i, "sw_if_index %d", &sw_if_index)) + ; + else if (unformat (i, "%d", &local_label)) + ; + else if (unformat (i, "eos")) + is_eos = 1; + else if (unformat (i, "non-eos")) + is_eos = 0; + else if (unformat (i, "via %U", unformat_ip4_address, + &v4_next_hop_address)) + { + next_hop_set = 1; + next_hop_proto_is_ip4 = 1; + } + else if (unformat (i, "via %U", unformat_ip6_address, + &v6_next_hop_address)) + { + next_hop_set = 1; + next_hop_proto_is_ip4 = 0; + } + else if (unformat (i, "weight %d", &next_hop_weight)) + ; + else if (unformat (i, "create-table")) + create_table_if_needed = 1; + else if (unformat (i, "classify %d", &classify_table_index)) + { + is_classify = 1; + } + else if (unformat (i, "del")) + is_add = 0; + else if (unformat (i, "add")) + is_add = 1; + else if (unformat (i, "resolve-via-host")) + resolve_host = 1; + else if (unformat (i, "resolve-via-attached")) + resolve_attached = 1; + else if (unformat (i, "multipath")) + is_multipath = 1; + else if (unformat (i, "count %d", &count)) + ; + else if (unformat (i, "lookup-in-ip4-table %d", &next_hop_table_id)) + { + next_hop_set = 1; + next_hop_proto_is_ip4 = 1; + } + else if (unformat (i, "lookup-in-ip6-table %d", &next_hop_table_id)) + { + next_hop_set = 1; + next_hop_proto_is_ip4 = 0; + } + else if (unformat (i, "next-hop-table %d", &next_hop_table_id)) + ; + else if (unformat (i, "via-label %d", &next_hop_via_label)) + ; + else if (unformat (i, "out-label %d", &next_hop_out_label)) + vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label)); + else + { + clib_warning ("parse error '%U'", format_unformat_error, i); + return -99; + } + } + + if (!next_hop_set && !is_classify) + { + errmsg ("next hop / classify not set"); + return -99; + } + + if (MPLS_LABEL_INVALID == local_label) + { + errmsg ("missing label"); + return -99; + } + + if (count > 1) + { + /* Turn on async mode */ + vam->async_mode = 1; + vam->async_errors = 0; + before = vat_time_now (vam); + } + + for (j = 0; j < count; j++) + { + /* Construct the API message */ + M2 (MPLS_ROUTE_ADD_DEL, mpls_route_add_del, + sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack)); + + mp->mr_next_hop_sw_if_index = ntohl (sw_if_index); + mp->mr_table_id = ntohl (table_id); + mp->mr_create_table_if_needed = create_table_if_needed; + + mp->mr_is_add = is_add; + mp->mr_next_hop_proto_is_ip4 = next_hop_proto_is_ip4; + mp->mr_is_classify = is_classify; + mp->mr_is_multipath = is_multipath; + mp->mr_is_resolve_host = resolve_host; + mp->mr_is_resolve_attached = resolve_attached; + mp->mr_next_hop_weight = next_hop_weight; + mp->mr_next_hop_table_id = ntohl (next_hop_table_id); + mp->mr_classify_table_index = ntohl (classify_table_index); + mp->mr_next_hop_via_label = ntohl (next_hop_via_label); + mp->mr_label = ntohl (local_label); + mp->mr_eos = is_eos; + + mp->mr_next_hop_n_out_labels = vec_len (next_hop_out_label_stack); + if (0 != mp->mr_next_hop_n_out_labels) + { + memcpy (mp->mr_next_hop_out_label_stack, + next_hop_out_label_stack, + vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t)); + vec_free (next_hop_out_label_stack); + } + + if (next_hop_set) + { + if (next_hop_proto_is_ip4) + { + clib_memcpy (mp->mr_next_hop, + &v4_next_hop_address, + sizeof (v4_next_hop_address)); + } + else + { + clib_memcpy (mp->mr_next_hop, + &v6_next_hop_address, + sizeof (v6_next_hop_address)); + } + } + local_label++; + + /* send it... */ + S; + /* If we receive SIGTERM, stop now... */ + if (vam->do_exit) + break; + } + + /* When testing multiple add/del ops, use a control-ping to sync */ + if (count > 1) + { + vl_api_control_ping_t *mp; + f64 after; + + /* Shut off async mode */ + vam->async_mode = 0; + + M (CONTROL_PING, control_ping); + S; + + timeout = vat_time_now (vam) + 1.0; + while (vat_time_now (vam) < timeout) + if (vam->result_ready == 1) + goto out; + vam->retval = -99; + + out: + if (vam->retval == -99) + errmsg ("timeout"); + + if (vam->async_errors > 0) + { + errmsg ("%d asynchronous errors", vam->async_errors); + vam->retval = -98; + } + vam->async_errors = 0; + after = vat_time_now (vam); + + /* slim chance, but we might have eaten SIGTERM on the first iteration */ + if (j > 0) + count = j; + + print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec", + count, after - before, count / (after - before)); + } + else + { + /* Wait for a reply... */ + W; + } + + /* Return the good/bad news */ + return (vam->retval); +} + +static int +api_mpls_ip_bind_unbind (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + vl_api_mpls_ip_bind_unbind_t *mp; + f64 timeout; + u32 ip_table_id = 0; + u8 create_table_if_needed = 0; + u8 is_bind = 1; + u8 is_ip4 = 1; + ip4_address_t v4_address; + ip6_address_t v6_address; + u32 address_length; + u8 address_set = 0; + mpls_label_t local_label = MPLS_LABEL_INVALID; + + /* Parse args required to build the message */ + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "%U/%d", unformat_ip4_address, + &v4_address, &address_length)) + { + is_ip4 = 1; + address_set = 1; + } + else if (unformat (i, "%U/%d", unformat_ip6_address, + &v6_address, &address_length)) + { + is_ip4 = 0; + address_set = 1; + } + else if (unformat (i, "%d", &local_label)) + ; + else if (unformat (i, "create-table")) + create_table_if_needed = 1; + else if (unformat (i, "table-id %d", &ip_table_id)) + ; + else if (unformat (i, "unbind")) + is_bind = 0; + else if (unformat (i, "bind")) + is_bind = 1; + else + { + clib_warning ("parse error '%U'", format_unformat_error, i); + return -99; + } + } + + if (!address_set) + { + errmsg ("IP addres not set"); + return -99; + } + + if (MPLS_LABEL_INVALID == local_label) + { + errmsg ("missing label"); + return -99; + } + + /* Construct the API message */ + M (MPLS_IP_BIND_UNBIND, mpls_ip_bind_unbind); + + mp->mb_create_table_if_needed = create_table_if_needed; + mp->mb_is_bind = is_bind; + mp->mb_is_ip4 = is_ip4; + mp->mb_ip_table_id = ntohl (ip_table_id); + mp->mb_mpls_table_id = 0; + mp->mb_label = ntohl (local_label); + mp->mb_address_length = address_length; + + if (is_ip4) + clib_memcpy (mp->mb_address, &v4_address, sizeof (v4_address)); + else + clib_memcpy (mp->mb_address, &v6_address, sizeof (v6_address)); + + /* send it... */ + S; + + /* Wait for a reply... */ + W; +} + +static int +api_proxy_arp_add_del (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + vl_api_proxy_arp_add_del_t *mp; + f64 timeout; + u32 vrf_id = 0; + u8 is_add = 1; + ip4_address_t lo, hi; + u8 range_set = 0; + + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "vrf %d", &vrf_id)) + ; + else if (unformat (i, "%U - %U", unformat_ip4_address, &lo, + unformat_ip4_address, &hi)) + range_set = 1; + else if (unformat (i, "del")) + is_add = 0; + else + { + clib_warning ("parse error '%U'", format_unformat_error, i); + return -99; + } + } + + if (range_set == 0) + { + errmsg ("address range not set"); + return -99; + } + + M (PROXY_ARP_ADD_DEL, proxy_arp_add_del); + + mp->vrf_id = ntohl (vrf_id); + mp->is_add = is_add; + clib_memcpy (mp->low_address, &lo, sizeof (mp->low_address)); + clib_memcpy (mp->hi_address, &hi, sizeof (mp->hi_address)); + + S; + W; + /* NOTREACHED */ + return 0; +} + +static int +api_proxy_arp_intfc_enable_disable (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + vl_api_proxy_arp_intfc_enable_disable_t *mp; + f64 timeout; + u32 sw_if_index; + u8 enable = 1; + u8 sw_if_index_set = 0; + + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index)) + sw_if_index_set = 1; + else if (unformat (i, "sw_if_index %d", &sw_if_index)) + sw_if_index_set = 1; + else if (unformat (i, "enable")) + enable = 1; + else if (unformat (i, "disable")) + enable = 0; + else + { + clib_warning ("parse error '%U'", format_unformat_error, i); + return -99; + } + } + + if (sw_if_index_set == 0) + { + errmsg ("missing interface name or sw_if_index"); + return -99; + } + + M (PROXY_ARP_INTFC_ENABLE_DISABLE, proxy_arp_intfc_enable_disable); + + mp->sw_if_index = ntohl (sw_if_index); + mp->enable_disable = enable; + + S; + W; + /* NOTREACHED */ + return 0; +} + +static int +api_mpls_tunnel_add_del (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + vl_api_mpls_tunnel_add_del_t *mp; + f64 timeout; + + u8 is_add = 1; + u8 l2_only = 0; + u32 sw_if_index = ~0; + u32 next_hop_sw_if_index = ~0; + u32 next_hop_proto_is_ip4 = 1; + + u32 next_hop_table_id = 0; + ip4_address_t v4_next_hop_address = { + .as_u32 = 0, + }; + ip6_address_t v6_next_hop_address = { {0} }; + mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID, *labels = NULL; + + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "add")) + is_add = 1; + else if (unformat (i, "del sw_if_index %d", &sw_if_index)) + is_add = 0; + else if (unformat (i, "sw_if_index %d", &next_hop_sw_if_index)) + ; + else if (unformat (i, "via %U", + unformat_ip4_address, &v4_next_hop_address)) + { + next_hop_proto_is_ip4 = 1; + } + else if (unformat (i, "via %U", + unformat_ip6_address, &v6_next_hop_address)) + { + next_hop_proto_is_ip4 = 0; + } + else if (unformat (i, "l2-only")) + l2_only = 1; + else if (unformat (i, "next-hop-table %d", &next_hop_table_id)) + ; + else if (unformat (i, "out-label %d", &next_hop_out_label)) + vec_add1 (labels, ntohl (next_hop_out_label)); + else + { + clib_warning ("parse error '%U'", format_unformat_error, i); + return -99; + } + } + + M2 (MPLS_TUNNEL_ADD_DEL, mpls_tunnel_add_del, + sizeof (mpls_label_t) * vec_len (labels)); + + mp->mt_next_hop_sw_if_index = ntohl (next_hop_sw_if_index); + mp->mt_sw_if_index = ntohl (sw_if_index); + mp->mt_is_add = is_add; + mp->mt_l2_only = l2_only; + mp->mt_next_hop_table_id = ntohl (next_hop_table_id); + mp->mt_next_hop_proto_is_ip4 = next_hop_proto_is_ip4; + + mp->mt_next_hop_n_out_labels = vec_len (labels); + + if (0 != mp->mt_next_hop_n_out_labels) + { + clib_memcpy (mp->mt_next_hop_out_label_stack, labels, + sizeof (mpls_label_t) * mp->mt_next_hop_n_out_labels); + vec_free (labels); + } + + if (next_hop_proto_is_ip4) + { + clib_memcpy (mp->mt_next_hop, + &v4_next_hop_address, sizeof (v4_next_hop_address)); + } + else + { + clib_memcpy (mp->mt_next_hop, + &v6_next_hop_address, sizeof (v6_next_hop_address)); + } + + S; + W; + /* NOTREACHED */ + return 0; +} + +static int +api_sw_interface_set_unnumbered (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + vl_api_sw_interface_set_unnumbered_t *mp; + f64 timeout; + u32 sw_if_index; + u32 unnum_sw_index = ~0; + u8 is_add = 1; + u8 sw_if_index_set = 0; + + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index)) + sw_if_index_set = 1; + else if (unformat (i, "sw_if_index %d", &sw_if_index)) + sw_if_index_set = 1; + else if (unformat (i, "unnum_if_index %d", &unnum_sw_index)) + ; + else if (unformat (i, "del")) + is_add = 0; + else + { + clib_warning ("parse error '%U'", format_unformat_error, i); + return -99; + } + } + + if (sw_if_index_set == 0) + { + errmsg ("missing interface name or sw_if_index"); + return -99; + } + + M (SW_INTERFACE_SET_UNNUMBERED, sw_interface_set_unnumbered); + + mp->sw_if_index = ntohl (sw_if_index); + mp->unnumbered_sw_if_index = ntohl (unnum_sw_index); + mp->is_add = is_add; + + S; + W; + /* NOTREACHED */ + return 0; +} + +static int +api_ip_neighbor_add_del (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + vl_api_ip_neighbor_add_del_t *mp; + f64 timeout; + u32 sw_if_index; + u8 sw_if_index_set = 0; + u32 vrf_id = 0; + u8 is_add = 1; + u8 is_static = 0; + u8 mac_address[6]; + u8 mac_set = 0; + u8 v4_address_set = 0; + u8 v6_address_set = 0; + ip4_address_t v4address; + ip6_address_t v6address; + + memset (mac_address, 0, sizeof (mac_address)); + + /* Parse args required to build the message */ + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "mac %U", unformat_ethernet_address, mac_address)) + { + mac_set = 1; + } + else if (unformat (i, "del")) + is_add = 0; + else + if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index)) + sw_if_index_set = 1; + else if (unformat (i, "sw_if_index %d", &sw_if_index)) + sw_if_index_set = 1; + else if (unformat (i, "is_static")) + is_static = 1; + else if (unformat (i, "vrf %d", &vrf_id)) + ; + else if (unformat (i, "dst %U", unformat_ip4_address, &v4address)) + v4_address_set = 1; + else if (unformat (i, "dst %U", unformat_ip6_address, &v6address)) + v6_address_set = 1; + else + { + clib_warning ("parse error '%U'", format_unformat_error, i); + return -99; + } + } + + if (sw_if_index_set == 0) + { + errmsg ("missing interface name or sw_if_index"); + return -99; + } + if (v4_address_set && v6_address_set) + { + errmsg ("both v4 and v6 addresses set"); + return -99; + } + if (!v4_address_set && !v6_address_set) + { + errmsg ("no address set"); + return -99; + } + + /* Construct the API message */ + M (IP_NEIGHBOR_ADD_DEL, ip_neighbor_add_del); + + mp->sw_if_index = ntohl (sw_if_index); + mp->is_add = is_add; + mp->vrf_id = ntohl (vrf_id); + mp->is_static = is_static; + if (mac_set) + clib_memcpy (mp->mac_address, mac_address, 6); + if (v6_address_set) + { + mp->is_ipv6 = 1; + clib_memcpy (mp->dst_address, &v6address, sizeof (v6address)); + } + else + { + /* mp->is_ipv6 = 0; via memset in M macro above */ + clib_memcpy (mp->dst_address, &v4address, sizeof (v4address)); + } + + /* send it... */ + S; + + /* Wait for a reply, return good/bad news */ + W; + + /* NOTREACHED */ + return 0; +} + +static int +api_reset_vrf (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + vl_api_reset_vrf_t *mp; + f64 timeout; + u32 vrf_id = 0; + u8 is_ipv6 = 0; + u8 vrf_id_set = 0; + + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "vrf %d", &vrf_id)) + vrf_id_set = 1; + else if (unformat (i, "ipv6")) + is_ipv6 = 1; + else + { + clib_warning ("parse error '%U'", format_unformat_error, i); + return -99; + } + } + + if (vrf_id_set == 0) + { + errmsg ("missing vrf id"); + return -99; + } + + M (RESET_VRF, reset_vrf); + + mp->vrf_id = ntohl (vrf_id); + mp->is_ipv6 = is_ipv6; + + S; + W; + /* NOTREACHED */ + return 0; +} + +static int +api_create_vlan_subif (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + vl_api_create_vlan_subif_t *mp; + f64 timeout; + u32 sw_if_index; + u8 sw_if_index_set = 0; + u32 vlan_id; + u8 vlan_id_set = 0; + + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "sw_if_index %d", &sw_if_index)) + sw_if_index_set = 1; + else + if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index)) + sw_if_index_set = 1; + else if (unformat (i, "vlan %d", &vlan_id)) + vlan_id_set = 1; + else + { + clib_warning ("parse error '%U'", format_unformat_error, i); + return -99; + } + } + + if (sw_if_index_set == 0) + { + errmsg ("missing interface name or sw_if_index"); + return -99; + } + + if (vlan_id_set == 0) + { + errmsg ("missing vlan_id"); + return -99; + } + M (CREATE_VLAN_SUBIF, create_vlan_subif); + + mp->sw_if_index = ntohl (sw_if_index); + mp->vlan_id = ntohl (vlan_id); + + S; + W; + /* NOTREACHED */ + return 0; +} + +#define foreach_create_subif_bit \ +_(no_tags) \ +_(one_tag) \ +_(two_tags) \ +_(dot1ad) \ +_(exact_match) \ +_(default_sub) \ +_(outer_vlan_id_any) \ +_(inner_vlan_id_any) + +static int +api_create_subif (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + vl_api_create_subif_t *mp; + f64 timeout; + u32 sw_if_index; + u8 sw_if_index_set = 0; + u32 sub_id; + u8 sub_id_set = 0; + u32 no_tags = 0; + u32 one_tag = 0; + u32 two_tags = 0; + u32 dot1ad = 0; + u32 exact_match = 0; + u32 default_sub = 0; + u32 outer_vlan_id_any = 0; + u32 inner_vlan_id_any = 0; + u32 tmp; + u16 outer_vlan_id = 0; + u16 inner_vlan_id = 0; + + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "sw_if_index %d", &sw_if_index)) + sw_if_index_set = 1; + else + if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index)) + sw_if_index_set = 1; + else if (unformat (i, "sub_id %d", &sub_id)) + sub_id_set = 1; + else if (unformat (i, "outer_vlan_id %d", &tmp)) + outer_vlan_id = tmp; + else if (unformat (i, "inner_vlan_id %d", &tmp)) + inner_vlan_id = tmp; + +#define _(a) else if (unformat (i, #a)) a = 1 ; + foreach_create_subif_bit +#undef _ + else + { + clib_warning ("parse error '%U'", format_unformat_error, i); + return -99; + } + } + + if (sw_if_index_set == 0) + { + errmsg ("missing interface name or sw_if_index"); + return -99; + } + + if (sub_id_set == 0) + { + errmsg ("missing sub_id"); + return -99; + } + M (CREATE_SUBIF, create_subif); + + mp->sw_if_index = ntohl (sw_if_index); + mp->sub_id = ntohl (sub_id); + +#define _(a) mp->a = a; + foreach_create_subif_bit; +#undef _ + + mp->outer_vlan_id = ntohs (outer_vlan_id); + mp->inner_vlan_id = ntohs (inner_vlan_id); + + S; + W; + /* NOTREACHED */ + return 0; +} + +static int +api_oam_add_del (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + vl_api_oam_add_del_t *mp; + f64 timeout; + u32 vrf_id = 0; + u8 is_add = 1; + ip4_address_t src, dst; + u8 src_set = 0; + u8 dst_set = 0; + + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "vrf %d", &vrf_id)) + ; + else if (unformat (i, "src %U", unformat_ip4_address, &src)) + src_set = 1; + else if (unformat (i, "dst %U", unformat_ip4_address, &dst)) + dst_set = 1; + else if (unformat (i, "del")) + is_add = 0; + else + { + clib_warning ("parse error '%U'", format_unformat_error, i); + return -99; + } + } + + if (src_set == 0) + { + errmsg ("missing src addr"); + return -99; + } + + if (dst_set == 0) + { + errmsg ("missing dst addr"); + return -99; + } + + M (OAM_ADD_DEL, oam_add_del); + + mp->vrf_id = ntohl (vrf_id); + mp->is_add = is_add; + clib_memcpy (mp->src_address, &src, sizeof (mp->src_address)); + clib_memcpy (mp->dst_address, &dst, sizeof (mp->dst_address)); + + S; + W; + /* NOTREACHED */ + return 0; +} + +static int +api_reset_fib (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + vl_api_reset_fib_t *mp; + f64 timeout; + u32 vrf_id = 0; + u8 is_ipv6 = 0; + u8 vrf_id_set = 0; + + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "vrf %d", &vrf_id)) + vrf_id_set = 1; + else if (unformat (i, "ipv6")) + is_ipv6 = 1; + else + { + clib_warning ("parse error '%U'", format_unformat_error, i); + return -99; + } + } + + if (vrf_id_set == 0) + { + errmsg ("missing vrf id"); + return -99; + } + + M (RESET_FIB, reset_fib); + + mp->vrf_id = ntohl (vrf_id); + mp->is_ipv6 = is_ipv6; + + S; + W; + /* NOTREACHED */ + return 0; +} + +static int +api_dhcp_proxy_config (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + vl_api_dhcp_proxy_config_t *mp; + f64 timeout; + u32 vrf_id = 0; + u8 is_add = 1; + u8 insert_cid = 1; + u8 v4_address_set = 0; + u8 v6_address_set = 0; + ip4_address_t v4address; + ip6_address_t v6address; + u8 v4_src_address_set = 0; + u8 v6_src_address_set = 0; + ip4_address_t v4srcaddress; + ip6_address_t v6srcaddress; + + /* Parse args required to build the message */ + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "del")) + is_add = 0; + else if (unformat (i, "vrf %d", &vrf_id)) + ; + else if (unformat (i, "insert-cid %d", &insert_cid)) + ; + else if (unformat (i, "svr %U", unformat_ip4_address, &v4address)) + v4_address_set = 1; + else if (unformat (i, "svr %U", unformat_ip6_address, &v6address)) + v6_address_set = 1; + else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress)) + v4_src_address_set = 1; + else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress)) + v6_src_address_set = 1; + else + break; + } + + if (v4_address_set && v6_address_set) + { + errmsg ("both v4 and v6 server addresses set"); + return -99; + } + if (!v4_address_set && !v6_address_set) + { + errmsg ("no server addresses set"); + return -99; + } + + if (v4_src_address_set && v6_src_address_set) + { + errmsg ("both v4 and v6 src addresses set"); + return -99; + } + if (!v4_src_address_set && !v6_src_address_set) + { + errmsg ("no src addresses set"); + return -99; + } + + if (!(v4_src_address_set && v4_address_set) && + !(v6_src_address_set && v6_address_set)) + { + errmsg ("no matching server and src addresses set"); + return -99; + } + + /* Construct the API message */ + M (DHCP_PROXY_CONFIG, dhcp_proxy_config); + + mp->insert_circuit_id = insert_cid; + mp->is_add = is_add; + mp->vrf_id = ntohl (vrf_id); + if (v6_address_set) + { + mp->is_ipv6 = 1; + clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address)); + clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address)); + } + else + { + clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address)); + clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address)); + } + + /* send it... */ + S; + + /* Wait for a reply, return good/bad news */ + W; + /* NOTREACHED */ + return 0; +} + +static int +api_dhcp_proxy_config_2 (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + vl_api_dhcp_proxy_config_2_t *mp; + f64 timeout; + u32 rx_vrf_id = 0; + u32 server_vrf_id = 0; + u8 is_add = 1; + u8 insert_cid = 1; + u8 v4_address_set = 0; + u8 v6_address_set = 0; + ip4_address_t v4address; + ip6_address_t v6address; + u8 v4_src_address_set = 0; + u8 v6_src_address_set = 0; + ip4_address_t v4srcaddress; + ip6_address_t v6srcaddress; + + /* Parse args required to build the message */ + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "del")) + is_add = 0; + else if (unformat (i, "rx_vrf_id %d", &rx_vrf_id)) + ; + else if (unformat (i, "server_vrf_id %d", &server_vrf_id)) + ; + else if (unformat (i, "insert-cid %d", &insert_cid)) + ; + else if (unformat (i, "svr %U", unformat_ip4_address, &v4address)) + v4_address_set = 1; + else if (unformat (i, "svr %U", unformat_ip6_address, &v6address)) + v6_address_set = 1; + else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress)) + v4_src_address_set = 1; + else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress)) + v6_src_address_set = 1; + else + break; + } + + if (v4_address_set && v6_address_set) + { + errmsg ("both v4 and v6 server addresses set"); + return -99; + } + if (!v4_address_set && !v6_address_set) + { + errmsg ("no server addresses set"); + return -99; + } + + if (v4_src_address_set && v6_src_address_set) + { + errmsg ("both v4 and v6 src addresses set"); + return -99; + } + if (!v4_src_address_set && !v6_src_address_set) + { + errmsg ("no src addresses set"); + return -99; + } + + if (!(v4_src_address_set && v4_address_set) && + !(v6_src_address_set && v6_address_set)) + { + errmsg ("no matching server and src addresses set"); + return -99; + } + + /* Construct the API message */ + M (DHCP_PROXY_CONFIG_2, dhcp_proxy_config_2); + + mp->insert_circuit_id = insert_cid; + mp->is_add = is_add; + mp->rx_vrf_id = ntohl (rx_vrf_id); + mp->server_vrf_id = ntohl (server_vrf_id); + if (v6_address_set) + { + mp->is_ipv6 = 1; + clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address)); + clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address)); + } + else + { + clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address)); + clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address)); + } + + /* send it... */ + S; + + /* Wait for a reply, return good/bad news */ + W; + /* NOTREACHED */ + return 0; +} + +static int +api_dhcp_proxy_set_vss (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + vl_api_dhcp_proxy_set_vss_t *mp; + f64 timeout; + u8 is_ipv6 = 0; + u8 is_add = 1; + u32 tbl_id; + u8 tbl_id_set = 0; + u32 oui; + u8 oui_set = 0; + u32 fib_id; + u8 fib_id_set = 0; + + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "tbl_id %d", &tbl_id)) + tbl_id_set = 1; + if (unformat (i, "fib_id %d", &fib_id)) + fib_id_set = 1; + if (unformat (i, "oui %d", &oui)) + oui_set = 1; + else if (unformat (i, "ipv6")) + is_ipv6 = 1; + else if (unformat (i, "del")) + is_add = 0; + else + { + clib_warning ("parse error '%U'", format_unformat_error, i); + return -99; + } + } + + if (tbl_id_set == 0) + { + errmsg ("missing tbl id"); + return -99; + } + + if (fib_id_set == 0) + { + errmsg ("missing fib id"); + return -99; + } + if (oui_set == 0) + { + errmsg ("missing oui"); + return -99; + } + + M (DHCP_PROXY_SET_VSS, dhcp_proxy_set_vss); + mp->tbl_id = ntohl (tbl_id); + mp->fib_id = ntohl (fib_id); + mp->oui = ntohl (oui); + mp->is_ipv6 = is_ipv6; + mp->is_add = is_add; + + S; + W; + /* NOTREACHED */ + return 0; +} + +static int +api_dhcp_client_config (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + vl_api_dhcp_client_config_t *mp; + f64 timeout; + u32 sw_if_index; + u8 sw_if_index_set = 0; + u8 is_add = 1; + u8 *hostname = 0; + u8 disable_event = 0; + + /* Parse args required to build the message */ + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "del")) + is_add = 0; + else + if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index)) + sw_if_index_set = 1; + else if (unformat (i, "sw_if_index %d", &sw_if_index)) + sw_if_index_set = 1; + else if (unformat (i, "hostname %s", &hostname)) + ; + else if (unformat (i, "disable_event")) + disable_event = 1; + else + break; + } + + if (sw_if_index_set == 0) + { + errmsg ("missing interface name or sw_if_index"); + return -99; + } + + if (vec_len (hostname) > 63) + { + errmsg ("hostname too long"); + } + vec_add1 (hostname, 0); + + /* Construct the API message */ + M (DHCP_CLIENT_CONFIG, dhcp_client_config); + + mp->sw_if_index = ntohl (sw_if_index); + clib_memcpy (mp->hostname, hostname, vec_len (hostname)); + vec_free (hostname); + mp->is_add = is_add; + mp->want_dhcp_event = disable_event ? 0 : 1; + mp->pid = getpid (); + + /* send it... */ + S; + + /* Wait for a reply, return good/bad news */ + W; + /* NOTREACHED */ + return 0; +} + +static int +api_set_ip_flow_hash (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + vl_api_set_ip_flow_hash_t *mp; + f64 timeout; + u32 vrf_id = 0; + u8 is_ipv6 = 0; + u8 vrf_id_set = 0; + u8 src = 0; + u8 dst = 0; + u8 sport = 0; + u8 dport = 0; + u8 proto = 0; + u8 reverse = 0; + + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "vrf %d", &vrf_id)) + vrf_id_set = 1; + else if (unformat (i, "ipv6")) + is_ipv6 = 1; + else if (unformat (i, "src")) + src = 1; + else if (unformat (i, "dst")) + dst = 1; + else if (unformat (i, "sport")) + sport = 1; + else if (unformat (i, "dport")) + dport = 1; + else if (unformat (i, "proto")) + proto = 1; + else if (unformat (i, "reverse")) + reverse = 1; + + else + { + clib_warning ("parse error '%U'", format_unformat_error, i); + return -99; + } + } + + if (vrf_id_set == 0) + { + errmsg ("missing vrf id"); + return -99; + } + + M (SET_IP_FLOW_HASH, set_ip_flow_hash); + mp->src = src; + mp->dst = dst; + mp->sport = sport; + mp->dport = dport; + mp->proto = proto; + mp->reverse = reverse; + mp->vrf_id = ntohl (vrf_id); + mp->is_ipv6 = is_ipv6; + + S; + W; + /* NOTREACHED */ + return 0; +} + +static int +api_sw_interface_ip6_enable_disable (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + vl_api_sw_interface_ip6_enable_disable_t *mp; + f64 timeout; + u32 sw_if_index; + u8 sw_if_index_set = 0; + u8 enable = 0; + + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index)) + sw_if_index_set = 1; + else if (unformat (i, "sw_if_index %d", &sw_if_index)) + sw_if_index_set = 1; + else if (unformat (i, "enable")) + enable = 1; + else if (unformat (i, "disable")) + enable = 0; + else + { + clib_warning ("parse error '%U'", format_unformat_error, i); + return -99; + } + } + + if (sw_if_index_set == 0) + { + errmsg ("missing interface name or sw_if_index"); + return -99; + } + + M (SW_INTERFACE_IP6_ENABLE_DISABLE, sw_interface_ip6_enable_disable); + + mp->sw_if_index = ntohl (sw_if_index); + mp->enable = enable; + + S; + W; + /* NOTREACHED */ + return 0; +} + +static int +api_sw_interface_ip6_set_link_local_address (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + vl_api_sw_interface_ip6_set_link_local_address_t *mp; + f64 timeout; + u32 sw_if_index; + u8 sw_if_index_set = 0; + u32 address_length = 0; + u8 v6_address_set = 0; + ip6_address_t v6address; + + /* Parse args required to build the message */ + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index)) + sw_if_index_set = 1; + else if (unformat (i, "sw_if_index %d", &sw_if_index)) + sw_if_index_set = 1; + else if (unformat (i, "%U/%d", + unformat_ip6_address, &v6address, &address_length)) + v6_address_set = 1; + else + break; + } + + if (sw_if_index_set == 0) + { + errmsg ("missing interface name or sw_if_index"); + return -99; + } + if (!v6_address_set) + { + errmsg ("no address set"); + return -99; + } + + /* Construct the API message */ + M (SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS, + sw_interface_ip6_set_link_local_address); + + mp->sw_if_index = ntohl (sw_if_index); + clib_memcpy (mp->address, &v6address, sizeof (v6address)); + mp->address_length = address_length; + + /* send it... */ + S; + + /* Wait for a reply, return good/bad news */ + W; + + /* NOTREACHED */ + return 0; +} + + +static int +api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + vl_api_sw_interface_ip6nd_ra_prefix_t *mp; + f64 timeout; + u32 sw_if_index; + u8 sw_if_index_set = 0; + u32 address_length = 0; + u8 v6_address_set = 0; + ip6_address_t v6address; + u8 use_default = 0; + u8 no_advertise = 0; + u8 off_link = 0; + u8 no_autoconfig = 0; + u8 no_onlink = 0; + u8 is_no = 0; + u32 val_lifetime = 0; + u32 pref_lifetime = 0; + + /* Parse args required to build the message */ + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index)) + sw_if_index_set = 1; + else if (unformat (i, "sw_if_index %d", &sw_if_index)) + sw_if_index_set = 1; + else if (unformat (i, "%U/%d", + unformat_ip6_address, &v6address, &address_length)) + v6_address_set = 1; + else if (unformat (i, "val_life %d", &val_lifetime)) + ; + else if (unformat (i, "pref_life %d", &pref_lifetime)) + ; + else if (unformat (i, "def")) + use_default = 1; + else if (unformat (i, "noadv")) + no_advertise = 1; + else if (unformat (i, "offl")) + off_link = 1; + else if (unformat (i, "noauto")) + no_autoconfig = 1; + else if (unformat (i, "nolink")) + no_onlink = 1; + else if (unformat (i, "isno")) + is_no = 1; + else + { + clib_warning ("parse error '%U'", format_unformat_error, i); + return -99; + } + } + + if (sw_if_index_set == 0) + { + errmsg ("missing interface name or sw_if_index"); + return -99; + } + if (!v6_address_set) + { + errmsg ("no address set"); + return -99; + } + + /* Construct the API message */ + M (SW_INTERFACE_IP6ND_RA_PREFIX, sw_interface_ip6nd_ra_prefix); + + mp->sw_if_index = ntohl (sw_if_index); + clib_memcpy (mp->address, &v6address, sizeof (v6address)); + mp->address_length = address_length; + mp->use_default = use_default; + mp->no_advertise = no_advertise; + mp->off_link = off_link; + mp->no_autoconfig = no_autoconfig; + mp->no_onlink = no_onlink; + mp->is_no = is_no; + mp->val_lifetime = ntohl (val_lifetime); + mp->pref_lifetime = ntohl (pref_lifetime); + + /* send it... */ + S; + + /* Wait for a reply, return good/bad news */ + W; + + /* NOTREACHED */ + return 0; +} + +static int +api_sw_interface_ip6nd_ra_config (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + vl_api_sw_interface_ip6nd_ra_config_t *mp; + f64 timeout; + u32 sw_if_index; + u8 sw_if_index_set = 0; + u8 suppress = 0; + u8 managed = 0; + u8 other = 0; + u8 ll_option = 0; + u8 send_unicast = 0; + u8 cease = 0; + u8 is_no = 0; + u8 default_router = 0; + u32 max_interval = 0; + u32 min_interval = 0; + u32 lifetime = 0; + u32 initial_count = 0; + u32 initial_interval = 0; + + + /* Parse args required to build the message */ + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index)) + sw_if_index_set = 1; + else if (unformat (i, "sw_if_index %d", &sw_if_index)) + sw_if_index_set = 1; + else if (unformat (i, "maxint %d", &max_interval)) + ; + else if (unformat (i, "minint %d", &min_interval)) + ; + else if (unformat (i, "life %d", &lifetime)) + ; + else if (unformat (i, "count %d", &initial_count)) + ; + else if (unformat (i, "interval %d", &initial_interval)) + ; + else if (unformat (i, "suppress") || unformat (i, "surpress")) + suppress = 1; + else if (unformat (i, "managed")) + managed = 1; + else if (unformat (i, "other")) + other = 1; + else if (unformat (i, "ll")) + ll_option = 1; + else if (unformat (i, "send")) + send_unicast = 1; + else if (unformat (i, "cease")) + cease = 1; + else if (unformat (i, "isno")) + is_no = 1; + else if (unformat (i, "def")) + default_router = 1; + else + { + clib_warning ("parse error '%U'", format_unformat_error, i); + return -99; + } + } + + if (sw_if_index_set == 0) + { + errmsg ("missing interface name or sw_if_index"); + return -99; + } + + /* Construct the API message */ + M (SW_INTERFACE_IP6ND_RA_CONFIG, sw_interface_ip6nd_ra_config); + + mp->sw_if_index = ntohl (sw_if_index); + mp->max_interval = ntohl (max_interval); + mp->min_interval = ntohl (min_interval); + mp->lifetime = ntohl (lifetime); + mp->initial_count = ntohl (initial_count); + mp->initial_interval = ntohl (initial_interval); + mp->suppress = suppress; + mp->managed = managed; + mp->other = other; + mp->ll_option = ll_option; + mp->send_unicast = send_unicast; + mp->cease = cease; + mp->is_no = is_no; + mp->default_router = default_router; + + /* send it... */ + S; + + /* Wait for a reply, return good/bad news */ + W; + + /* NOTREACHED */ + return 0; +} + +static int +api_set_arp_neighbor_limit (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + vl_api_set_arp_neighbor_limit_t *mp; + f64 timeout; + u32 arp_nbr_limit; + u8 limit_set = 0; + u8 is_ipv6 = 0; + + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "arp_nbr_limit %d", &arp_nbr_limit)) + limit_set = 1; + else if (unformat (i, "ipv6")) + is_ipv6 = 1; + else + { + clib_warning ("parse error '%U'", format_unformat_error, i); + return -99; + } + } + + if (limit_set == 0) + { + errmsg ("missing limit value"); + return -99; + } + + M (SET_ARP_NEIGHBOR_LIMIT, set_arp_neighbor_limit); + + mp->arp_neighbor_limit = ntohl (arp_nbr_limit); + mp->is_ipv6 = is_ipv6; + + S; + W; + /* NOTREACHED */ + return 0; +} + +static int +api_l2_patch_add_del (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + vl_api_l2_patch_add_del_t *mp; + f64 timeout; + u32 rx_sw_if_index; + u8 rx_sw_if_index_set = 0; + u32 tx_sw_if_index; + u8 tx_sw_if_index_set = 0; + u8 is_add = 1; + + /* Parse args required to build the message */ + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index)) + rx_sw_if_index_set = 1; + else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index)) + tx_sw_if_index_set = 1; + else if (unformat (i, "rx")) + { + if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "%U", api_unformat_sw_if_index, vam, + &rx_sw_if_index)) + rx_sw_if_index_set = 1; + } + else + break; + } + else if (unformat (i, "tx")) + { + if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "%U", api_unformat_sw_if_index, vam, + &tx_sw_if_index)) + tx_sw_if_index_set = 1; + } + else + break; + } + else if (unformat (i, "del")) + is_add = 0; + else + break; + } + + if (rx_sw_if_index_set == 0) + { + errmsg ("missing rx interface name or rx_sw_if_index"); + return -99; + } + + if (tx_sw_if_index_set == 0) + { + errmsg ("missing tx interface name or tx_sw_if_index"); + return -99; + } + + M (L2_PATCH_ADD_DEL, l2_patch_add_del); + + mp->rx_sw_if_index = ntohl (rx_sw_if_index); + mp->tx_sw_if_index = ntohl (tx_sw_if_index); + mp->is_add = is_add; + + S; + W; + /* NOTREACHED */ + return 0; +} + +static int +api_ioam_enable (vat_main_t * vam) +{ + unformat_input_t *input = vam->input; + vl_api_ioam_enable_t *mp; + f64 timeout; + u32 id = 0; + int has_trace_option = 0; + int has_pot_option = 0; + int has_seqno_option = 0; + int has_analyse_option = 0; + + while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) + { + if (unformat (input, "trace")) + has_trace_option = 1; + else if (unformat (input, "pot")) + has_pot_option = 1; + else if (unformat (input, "seqno")) + has_seqno_option = 1; + else if (unformat (input, "analyse")) + has_analyse_option = 1; + else + break; + } + M (IOAM_ENABLE, ioam_enable); + mp->id = htons (id); + mp->seqno = has_seqno_option; + mp->analyse = has_analyse_option; + mp->pot_enable = has_pot_option; + mp->trace_enable = has_trace_option; + + S; + W; + + return (0); + +} + + +static int +api_ioam_disable (vat_main_t * vam) +{ + vl_api_ioam_disable_t *mp; + f64 timeout; + + M (IOAM_DISABLE, ioam_disable); + S; + W; + return 0; +} + +static int +api_sr_tunnel_add_del (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + vl_api_sr_tunnel_add_del_t *mp; + f64 timeout; + int is_del = 0; + int pl_index; + ip6_address_t src_address; + int src_address_set = 0; + ip6_address_t dst_address; + u32 dst_mask_width; + int dst_address_set = 0; + u16 flags = 0; + u32 rx_table_id = 0; + u32 tx_table_id = 0; + ip6_address_t *segments = 0; + ip6_address_t *this_seg; + ip6_address_t *tags = 0; + ip6_address_t *this_tag; + ip6_address_t next_address, tag; + u8 *name = 0; + u8 *policy_name = 0; + + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "del")) + is_del = 1; + else if (unformat (i, "name %s", &name)) + ; + else if (unformat (i, "policy %s", &policy_name)) + ; + else if (unformat (i, "rx_fib_id %d", &rx_table_id)) + ; + else if (unformat (i, "tx_fib_id %d", &tx_table_id)) + ; + else if (unformat (i, "src %U", unformat_ip6_address, &src_address)) + src_address_set = 1; + else if (unformat (i, "dst %U/%d", + unformat_ip6_address, &dst_address, &dst_mask_width)) + dst_address_set = 1; + else if (unformat (i, "next %U", unformat_ip6_address, &next_address)) + { + vec_add2 (segments, this_seg, 1); + clib_memcpy (this_seg->as_u8, next_address.as_u8, + sizeof (*this_seg)); + } + else if (unformat (i, "tag %U", unformat_ip6_address, &tag)) + { + vec_add2 (tags, this_tag, 1); + clib_memcpy (this_tag->as_u8, tag.as_u8, sizeof (*this_tag)); + } + else if (unformat (i, "clean")) + flags |= IP6_SR_HEADER_FLAG_CLEANUP; + else if (unformat (i, "protected")) + flags |= IP6_SR_HEADER_FLAG_PROTECTED; + else if (unformat (i, "InPE %d", &pl_index)) + { + if (pl_index <= 0 || pl_index > 4) + { + pl_index_range_error: + errmsg ("pl index %d out of range", pl_index); + return -99; + } + flags |= + IP6_SR_HEADER_FLAG_PL_ELT_INGRESS_PE << (3 * (pl_index - 1)); + } + else if (unformat (i, "EgPE %d", &pl_index)) + { + if (pl_index <= 0 || pl_index > 4) + goto pl_index_range_error; + flags |= + IP6_SR_HEADER_FLAG_PL_ELT_EGRESS_PE << (3 * (pl_index - 1)); + } + else if (unformat (i, "OrgSrc %d", &pl_index)) + { + if (pl_index <= 0 || pl_index > 4) + goto pl_index_range_error; + flags |= + IP6_SR_HEADER_FLAG_PL_ELT_ORIG_SRC_ADDR << (3 * (pl_index - 1)); + } + else + break; + } + + if (!src_address_set) + { + errmsg ("src address required"); + return -99; + } + + if (!dst_address_set) + { + errmsg ("dst address required"); + return -99; + } + + if (!segments) + { + errmsg ("at least one sr segment required"); + return -99; + } + + M2 (SR_TUNNEL_ADD_DEL, sr_tunnel_add_del, + vec_len (segments) * sizeof (ip6_address_t) + + vec_len (tags) * sizeof (ip6_address_t)); + + clib_memcpy (mp->src_address, &src_address, sizeof (mp->src_address)); + clib_memcpy (mp->dst_address, &dst_address, sizeof (mp->dst_address)); + mp->dst_mask_width = dst_mask_width; + mp->flags_net_byte_order = clib_host_to_net_u16 (flags); + mp->n_segments = vec_len (segments); + mp->n_tags = vec_len (tags); + mp->is_add = is_del == 0; + clib_memcpy (mp->segs_and_tags, segments, + vec_len (segments) * sizeof (ip6_address_t)); + clib_memcpy (mp->segs_and_tags + + vec_len (segments) * sizeof (ip6_address_t), tags, + vec_len (tags) * sizeof (ip6_address_t)); + + mp->outer_vrf_id = ntohl (rx_table_id); + mp->inner_vrf_id = ntohl (tx_table_id); + memcpy (mp->name, name, vec_len (name)); + memcpy (mp->policy_name, policy_name, vec_len (policy_name)); + + vec_free (segments); + vec_free (tags); + + S; + W; + /* NOTREACHED */ +} + +static int +api_sr_policy_add_del (vat_main_t * vam) +{ + unformat_input_t *input = vam->input; + vl_api_sr_policy_add_del_t *mp; + f64 timeout; + int is_del = 0; + u8 *name = 0; + u8 *tunnel_name = 0; + u8 **tunnel_names = 0; + + int name_set = 0; + int tunnel_set = 0; + int j = 0; + int tunnel_names_length = 1; // Init to 1 to offset the #tunnel_names counter byte + int tun_name_len = 0; // Different naming convention used as confusing these would be "bad" (TM) + + while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) + { + if (unformat (input, "del")) + is_del = 1; + else if (unformat (input, "name %s", &name)) + name_set = 1; + else if (unformat (input, "tunnel %s", &tunnel_name)) + { + if (tunnel_name) + { + vec_add1 (tunnel_names, tunnel_name); + /* For serializer: + - length = #bytes to store in serial vector + - +1 = byte to store that length + */ + tunnel_names_length += (vec_len (tunnel_name) + 1); + tunnel_set = 1; + tunnel_name = 0; + } + } + else + break; + } + + if (!name_set) + { + errmsg ("policy name required"); + return -99; + } + + if ((!tunnel_set) && (!is_del)) + { + errmsg ("tunnel name required"); + return -99; + } + + M2 (SR_POLICY_ADD_DEL, sr_policy_add_del, tunnel_names_length); + + + + mp->is_add = !is_del; + + memcpy (mp->name, name, vec_len (name)); + // Since mp->tunnel_names is of type u8[0] and not a u8 *, u8 ** needs to be serialized + u8 *serial_orig = 0; + vec_validate (serial_orig, tunnel_names_length); + *serial_orig = vec_len (tunnel_names); // Store the number of tunnels as length in first byte of serialized vector + serial_orig += 1; // Move along one byte to store the length of first tunnel_name + + for (j = 0; j < vec_len (tunnel_names); j++) + { + tun_name_len = vec_len (tunnel_names[j]); + *serial_orig = tun_name_len; // Store length of tunnel name in first byte of Length/Value pair + serial_orig += 1; // Move along one byte to store the actual tunnel name + memcpy (serial_orig, tunnel_names[j], tun_name_len); + serial_orig += tun_name_len; // Advance past the copy + } + memcpy (mp->tunnel_names, serial_orig - tunnel_names_length, tunnel_names_length); // Regress serial_orig to head then copy fwd + + vec_free (tunnel_names); + vec_free (tunnel_name); + + S; + W; + /* NOTREACHED */ +} + +static int +api_sr_multicast_map_add_del (vat_main_t * vam) +{ + unformat_input_t *input = vam->input; + vl_api_sr_multicast_map_add_del_t *mp; + f64 timeout; + int is_del = 0; + ip6_address_t multicast_address; + u8 *policy_name = 0; + int multicast_address_set = 0; + + while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) + { + if (unformat (input, "del")) + is_del = 1; + else + if (unformat + (input, "address %U", unformat_ip6_address, &multicast_address)) + multicast_address_set = 1; + else if (unformat (input, "sr-policy %s", &policy_name)) + ; + else + break; + } + + if (!is_del && !policy_name) + { + errmsg ("sr-policy name required"); + return -99; + } + + + if (!multicast_address_set) + { + errmsg ("address required"); + return -99; + } + + M (SR_MULTICAST_MAP_ADD_DEL, sr_multicast_map_add_del); + + mp->is_add = !is_del; + memcpy (mp->policy_name, policy_name, vec_len (policy_name)); + clib_memcpy (mp->multicast_address, &multicast_address, + sizeof (mp->multicast_address)); + + + vec_free (policy_name); + + S; + W; + /* NOTREACHED */ +} + + +#define foreach_tcp_proto_field \ +_(src_port) \ +_(dst_port) + +#define foreach_udp_proto_field \ +_(src_port) \ +_(dst_port) + +#define foreach_ip4_proto_field \ +_(src_address) \ +_(dst_address) \ +_(tos) \ +_(length) \ +_(fragment_id) \ +_(ttl) \ +_(protocol) \ +_(checksum) + +uword +unformat_tcp_mask (unformat_input_t * input, va_list * args) +{ + u8 **maskp = va_arg (*args, u8 **); + u8 *mask = 0; + u8 found_something = 0; + tcp_header_t *tcp; + +#define _(a) u8 a=0; + foreach_tcp_proto_field; +#undef _ + + while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) + { + if (0); +#define _(a) else if (unformat (input, #a)) a=1; + foreach_tcp_proto_field +#undef _ + else + break; + } + +#define _(a) found_something += a; + foreach_tcp_proto_field; +#undef _ + + if (found_something == 0) + return 0; + + vec_validate (mask, sizeof (*tcp) - 1); + + tcp = (tcp_header_t *) mask; + +#define _(a) if (a) memset (&tcp->a, 0xff, sizeof (tcp->a)); + foreach_tcp_proto_field; +#undef _ + + *maskp = mask; + return 1; +} + +uword +unformat_udp_mask (unformat_input_t * input, va_list * args) +{ + u8 **maskp = va_arg (*args, u8 **); + u8 *mask = 0; + u8 found_something = 0; + udp_header_t *udp; + +#define _(a) u8 a=0; + foreach_udp_proto_field; +#undef _ + + while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) + { + if (0); +#define _(a) else if (unformat (input, #a)) a=1; + foreach_udp_proto_field +#undef _ + else + break; + } + +#define _(a) found_something += a; + foreach_udp_proto_field; +#undef _ + + if (found_something == 0) + return 0; + + vec_validate (mask, sizeof (*udp) - 1); + + udp = (udp_header_t *) mask; + +#define _(a) if (a) memset (&udp->a, 0xff, sizeof (udp->a)); + foreach_udp_proto_field; +#undef _ + + *maskp = mask; + return 1; +} + +typedef struct +{ + u16 src_port, dst_port; +} tcpudp_header_t; + +uword +unformat_l4_mask (unformat_input_t * input, va_list * args) +{ + u8 **maskp = va_arg (*args, u8 **); + u16 src_port = 0, dst_port = 0; + tcpudp_header_t *tcpudp; + + while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) + { + if (unformat (input, "tcp %U", unformat_tcp_mask, maskp)) + return 1; + else if (unformat (input, "udp %U", unformat_udp_mask, maskp)) + return 1; + else if (unformat (input, "src_port")) + src_port = 0xFFFF; + else if (unformat (input, "dst_port")) + dst_port = 0xFFFF; + else + return 0; + } + + if (!src_port && !dst_port) + return 0; + + u8 *mask = 0; + vec_validate (mask, sizeof (tcpudp_header_t) - 1); + + tcpudp = (tcpudp_header_t *) mask; + tcpudp->src_port = src_port; + tcpudp->dst_port = dst_port; + + *maskp = mask; + + return 1; +} + +uword +unformat_ip4_mask (unformat_input_t * input, va_list * args) +{ + u8 **maskp = va_arg (*args, u8 **); + u8 *mask = 0; + u8 found_something = 0; + ip4_header_t *ip; + +#define _(a) u8 a=0; + foreach_ip4_proto_field; +#undef _ + u8 version = 0; + u8 hdr_length = 0; + + + while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) + { + if (unformat (input, "version")) + version = 1; + else if (unformat (input, "hdr_length")) + hdr_length = 1; + else if (unformat (input, "src")) + src_address = 1; + else if (unformat (input, "dst")) + dst_address = 1; + else if (unformat (input, "proto")) + protocol = 1; + +#define _(a) else if (unformat (input, #a)) a=1; + foreach_ip4_proto_field +#undef _ + else + break; + } + +#define _(a) found_something += a; + foreach_ip4_proto_field; +#undef _ + + if (found_something == 0) + return 0; + + vec_validate (mask, sizeof (*ip) - 1); + + ip = (ip4_header_t *) mask; + +#define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a)); + foreach_ip4_proto_field; +#undef _ + + ip->ip_version_and_header_length = 0; + + if (version) + ip->ip_version_and_header_length |= 0xF0; + + if (hdr_length) + ip->ip_version_and_header_length |= 0x0F; + + *maskp = mask; + return 1; +} + +#define foreach_ip6_proto_field \ +_(src_address) \ +_(dst_address) \ +_(payload_length) \ +_(hop_limit) \ +_(protocol) + +uword +unformat_ip6_mask (unformat_input_t * input, va_list * args) +{ + u8 **maskp = va_arg (*args, u8 **); + u8 *mask = 0; + u8 found_something = 0; + ip6_header_t *ip; + u32 ip_version_traffic_class_and_flow_label; + +#define _(a) u8 a=0; + foreach_ip6_proto_field; +#undef _ + u8 version = 0; + u8 traffic_class = 0; + u8 flow_label = 0; + + while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) + { + if (unformat (input, "version")) + version = 1; + else if (unformat (input, "traffic-class")) + traffic_class = 1; + else if (unformat (input, "flow-label")) + flow_label = 1; + else if (unformat (input, "src")) + src_address = 1; + else if (unformat (input, "dst")) + dst_address = 1; + else if (unformat (input, "proto")) + protocol = 1; + +#define _(a) else if (unformat (input, #a)) a=1; + foreach_ip6_proto_field +#undef _ + else + break; + } + +#define _(a) found_something += a; + foreach_ip6_proto_field; +#undef _ + + if (found_something == 0) + return 0; + + vec_validate (mask, sizeof (*ip) - 1); + + ip = (ip6_header_t *) mask; + +#define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a)); + foreach_ip6_proto_field; +#undef _ + + ip_version_traffic_class_and_flow_label = 0; + + if (version) + ip_version_traffic_class_and_flow_label |= 0xF0000000; + + if (traffic_class) + ip_version_traffic_class_and_flow_label |= 0x0FF00000; + + if (flow_label) + ip_version_traffic_class_and_flow_label |= 0x000FFFFF; + + ip->ip_version_traffic_class_and_flow_label = + clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label); + + *maskp = mask; + return 1; +} + +uword +unformat_l3_mask (unformat_input_t * input, va_list * args) +{ + u8 **maskp = va_arg (*args, u8 **); + + while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) + { + if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp)) + return 1; + else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp)) + return 1; + else + break; + } + return 0; +} + +uword +unformat_l2_mask (unformat_input_t * input, va_list * args) +{ + u8 **maskp = va_arg (*args, u8 **); + u8 *mask = 0; + u8 src = 0; + u8 dst = 0; + u8 proto = 0; + u8 tag1 = 0; + u8 tag2 = 0; + u8 ignore_tag1 = 0; + u8 ignore_tag2 = 0; + u8 cos1 = 0; + u8 cos2 = 0; + u8 dot1q = 0; + u8 dot1ad = 0; + int len = 14; + + while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) + { + if (unformat (input, "src")) + src = 1; + else if (unformat (input, "dst")) + dst = 1; + else if (unformat (input, "proto")) + proto = 1; + else if (unformat (input, "tag1")) + tag1 = 1; + else if (unformat (input, "tag2")) + tag2 = 1; + else if (unformat (input, "ignore-tag1")) + ignore_tag1 = 1; + else if (unformat (input, "ignore-tag2")) + ignore_tag2 = 1; + else if (unformat (input, "cos1")) + cos1 = 1; + else if (unformat (input, "cos2")) + cos2 = 1; + else if (unformat (input, "dot1q")) + dot1q = 1; + else if (unformat (input, "dot1ad")) + dot1ad = 1; + else + break; + } + if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad + + ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0) + return 0; + + if (tag1 || ignore_tag1 || cos1 || dot1q) + len = 18; + if (tag2 || ignore_tag2 || cos2 || dot1ad) + len = 22; + + vec_validate (mask, len - 1); + + if (dst) + memset (mask, 0xff, 6); + + if (src) + memset (mask + 6, 0xff, 6); + + if (tag2 || dot1ad) + { + /* inner vlan tag */ + if (tag2) + { + mask[19] = 0xff; + mask[18] = 0x0f; + } + if (cos2) + mask[18] |= 0xe0; + if (proto) + mask[21] = mask[20] = 0xff; + if (tag1) + { + mask[15] = 0xff; + mask[14] = 0x0f; + } + if (cos1) + mask[14] |= 0xe0; + *maskp = mask; + return 1; + } + if (tag1 | dot1q) + { + if (tag1) + { + mask[15] = 0xff; + mask[14] = 0x0f; + } + if (cos1) + mask[14] |= 0xe0; + if (proto) + mask[16] = mask[17] = 0xff; + + *maskp = mask; + return 1; + } + if (cos2) + mask[18] |= 0xe0; + if (cos1) + mask[14] |= 0xe0; + if (proto) + mask[12] = mask[13] = 0xff; + + *maskp = mask; + return 1; +} + +uword +unformat_classify_mask (unformat_input_t * input, va_list * args) +{ + u8 **maskp = va_arg (*args, u8 **); + u32 *skipp = va_arg (*args, u32 *); + u32 *matchp = va_arg (*args, u32 *); + u32 match; + u8 *mask = 0; + u8 *l2 = 0; + u8 *l3 = 0; + u8 *l4 = 0; + int i; + + while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) + { + if (unformat (input, "hex %U", unformat_hex_string, &mask)) + ; + else if (unformat (input, "l2 %U", unformat_l2_mask, &l2)) + ; + else if (unformat (input, "l3 %U", unformat_l3_mask, &l3)) + ; + else if (unformat (input, "l4 %U", unformat_l4_mask, &l4)) + ; + else + break; + } + + if (l4 && !l3) + { + vec_free (mask); + vec_free (l2); + vec_free (l4); + return 0; + } + + if (mask || l2 || l3 || l4) + { + if (l2 || l3 || l4) + { + /* "With a free Ethernet header in every package" */ + if (l2 == 0) + vec_validate (l2, 13); + mask = l2; + if (vec_len (l3)) + { + vec_append (mask, l3); + vec_free (l3); + } + if (vec_len (l4)) + { + vec_append (mask, l4); + vec_free (l4); + } + } + + /* Scan forward looking for the first significant mask octet */ + for (i = 0; i < vec_len (mask); i++) + if (mask[i]) + break; + + /* compute (skip, match) params */ + *skipp = i / sizeof (u32x4); + vec_delete (mask, *skipp * sizeof (u32x4), 0); + + /* Pad mask to an even multiple of the vector size */ + while (vec_len (mask) % sizeof (u32x4)) + vec_add1 (mask, 0); + + match = vec_len (mask) / sizeof (u32x4); + + for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4)) + { + u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4))); + if (*tmp || *(tmp + 1)) + break; + match--; + } + if (match == 0) + clib_warning ("BUG: match 0"); + + _vec_len (mask) = match * sizeof (u32x4); + + *matchp = match; + *maskp = mask; + + return 1; + } + + return 0; +} + +#define foreach_l2_next \ +_(drop, DROP) \ +_(ethernet, ETHERNET_INPUT) \ +_(ip4, IP4_INPUT) \ +_(ip6, IP6_INPUT) + +uword +unformat_l2_next_index (unformat_input_t * input, va_list * args) +{ + u32 *miss_next_indexp = va_arg (*args, u32 *); + u32 next_index = 0; + u32 tmp; + +#define _(n,N) \ + if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;} + foreach_l2_next; +#undef _ + + if (unformat (input, "%d", &tmp)) + { + next_index = tmp; + goto out; + } + + return 0; + +out: + *miss_next_indexp = next_index; + return 1; +} + +#define foreach_ip_next \ +_(drop, DROP) \ +_(local, LOCAL) \ +_(rewrite, REWRITE) + +uword +unformat_ip_next_index (unformat_input_t * input, va_list * args) +{ + u32 *miss_next_indexp = va_arg (*args, u32 *); + u32 next_index = 0; + u32 tmp; + +#define _(n,N) \ + if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;} + foreach_ip_next; +#undef _ + + if (unformat (input, "%d", &tmp)) + { + next_index = tmp; + goto out; + } + + return 0; + +out: + *miss_next_indexp = next_index; + return 1; +} + +#define foreach_acl_next \ +_(deny, DENY) + +uword +unformat_acl_next_index (unformat_input_t * input, va_list * args) +{ + u32 *miss_next_indexp = va_arg (*args, u32 *); + u32 next_index = 0; + u32 tmp; + +#define _(n,N) \ + if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;} + foreach_acl_next; +#undef _ + + if (unformat (input, "permit")) + { + next_index = ~0; + goto out; + } + else if (unformat (input, "%d", &tmp)) + { + next_index = tmp; + goto out; + } + + return 0; + +out: + *miss_next_indexp = next_index; + return 1; +} + +uword +unformat_policer_precolor (unformat_input_t * input, va_list * args) +{ + u32 *r = va_arg (*args, u32 *); + + if (unformat (input, "conform-color")) + *r = POLICE_CONFORM; + else if (unformat (input, "exceed-color")) + *r = POLICE_EXCEED; + else + return 0; + + return 1; +} + +static int +api_classify_add_del_table (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + vl_api_classify_add_del_table_t *mp; + + u32 nbuckets = 2; + u32 skip = ~0; + u32 match = ~0; + int is_add = 1; + int del_chain = 0; + u32 table_index = ~0; + u32 next_table_index = ~0; + u32 miss_next_index = ~0; + u32 memory_size = 32 << 20; + u8 *mask = 0; + f64 timeout; + u32 current_data_flag = 0; + int current_data_offset = 0; + + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "del")) + is_add = 0; + else if (unformat (i, "del-chain")) + { + is_add = 0; + del_chain = 1; + } + else if (unformat (i, "buckets %d", &nbuckets)) + ; + else if (unformat (i, "memory_size %d", &memory_size)) + ; + else if (unformat (i, "skip %d", &skip)) + ; + else if (unformat (i, "match %d", &match)) + ; + else if (unformat (i, "table %d", &table_index)) + ; + else if (unformat (i, "mask %U", unformat_classify_mask, + &mask, &skip, &match)) + ; + else if (unformat (i, "next-table %d", &next_table_index)) + ; + else if (unformat (i, "miss-next %U", unformat_ip_next_index, + &miss_next_index)) + ; + else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index, + &miss_next_index)) + ; + else if (unformat (i, "acl-miss-next %U", unformat_acl_next_index, + &miss_next_index)) + ; + else if (unformat (i, "current-data-flag %d", ¤t_data_flag)) + ; + else if (unformat (i, "current-data-offset %d", ¤t_data_offset)) + ; + else + break; + } + + if (is_add && mask == 0) + { + errmsg ("Mask required"); + return -99; + } + + if (is_add && skip == ~0) + { + errmsg ("skip count required"); + return -99; + } + + if (is_add && match == ~0) + { + errmsg ("match count required"); + return -99; + } + + if (!is_add && table_index == ~0) + { + errmsg ("table index required for delete"); + return -99; + } + + M2 (CLASSIFY_ADD_DEL_TABLE, classify_add_del_table, vec_len (mask)); + + mp->is_add = is_add; + mp->del_chain = del_chain; + mp->table_index = ntohl (table_index); + mp->nbuckets = ntohl (nbuckets); + mp->memory_size = ntohl (memory_size); + mp->skip_n_vectors = ntohl (skip); + mp->match_n_vectors = ntohl (match); + mp->next_table_index = ntohl (next_table_index); + mp->miss_next_index = ntohl (miss_next_index); + mp->current_data_flag = ntohl (current_data_flag); + mp->current_data_offset = ntohl (current_data_offset); + clib_memcpy (mp->mask, mask, vec_len (mask)); + + vec_free (mask); + + S; + W; + /* NOTREACHED */ +} + +uword +unformat_l4_match (unformat_input_t * input, va_list * args) +{ + u8 **matchp = va_arg (*args, u8 **); + + u8 *proto_header = 0; + int src_port = 0; + int dst_port = 0; + + tcpudp_header_t h; + + while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) + { + if (unformat (input, "src_port %d", &src_port)) + ; + else if (unformat (input, "dst_port %d", &dst_port)) + ; + else + return 0; + } + + h.src_port = clib_host_to_net_u16 (src_port); + h.dst_port = clib_host_to_net_u16 (dst_port); + vec_validate (proto_header, sizeof (h) - 1); + memcpy (proto_header, &h, sizeof (h)); + + *matchp = proto_header; + + return 1; +} + +uword +unformat_ip4_match (unformat_input_t * input, va_list * args) +{ + u8 **matchp = va_arg (*args, u8 **); + u8 *match = 0; + ip4_header_t *ip; + int version = 0; + u32 version_val; + int hdr_length = 0; + u32 hdr_length_val; + int src = 0, dst = 0; + ip4_address_t src_val, dst_val; + int proto = 0; + u32 proto_val; + int tos = 0; + u32 tos_val; + int length = 0; + u32 length_val; + int fragment_id = 0; + u32 fragment_id_val; + int ttl = 0; + int ttl_val; + int checksum = 0; + u32 checksum_val; + + while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) + { + if (unformat (input, "version %d", &version_val)) + version = 1; + else if (unformat (input, "hdr_length %d", &hdr_length_val)) + hdr_length = 1; + else if (unformat (input, "src %U", unformat_ip4_address, &src_val)) + src = 1; + else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val)) + dst = 1; + else if (unformat (input, "proto %d", &proto_val)) + proto = 1; + else if (unformat (input, "tos %d", &tos_val)) + tos = 1; + else if (unformat (input, "length %d", &length_val)) + length = 1; + else if (unformat (input, "fragment_id %d", &fragment_id_val)) + fragment_id = 1; + else if (unformat (input, "ttl %d", &ttl_val)) + ttl = 1; + else if (unformat (input, "checksum %d", &checksum_val)) + checksum = 1; + else + break; + } + + if (version + hdr_length + src + dst + proto + tos + length + fragment_id + + ttl + checksum == 0) + return 0; + + /* + * Aligned because we use the real comparison functions + */ + vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4)); + + ip = (ip4_header_t *) match; + + /* These are realistically matched in practice */ + if (src) + ip->src_address.as_u32 = src_val.as_u32; + + if (dst) + ip->dst_address.as_u32 = dst_val.as_u32; + + if (proto) + ip->protocol = proto_val; + + + /* These are not, but they're included for completeness */ + if (version) + ip->ip_version_and_header_length |= (version_val & 0xF) << 4; + + if (hdr_length) + ip->ip_version_and_header_length |= (hdr_length_val & 0xF); + + if (tos) + ip->tos = tos_val; + + if (length) + ip->length = clib_host_to_net_u16 (length_val); + + if (ttl) + ip->ttl = ttl_val; + + if (checksum) + ip->checksum = clib_host_to_net_u16 (checksum_val); + + *matchp = match; + return 1; +} + +uword +unformat_ip6_match (unformat_input_t * input, va_list * args) +{ + u8 **matchp = va_arg (*args, u8 **); + u8 *match = 0; + ip6_header_t *ip; + int version = 0; + u32 version_val; + u8 traffic_class = 0; + u32 traffic_class_val = 0; + u8 flow_label = 0; + u8 flow_label_val; + int src = 0, dst = 0; + ip6_address_t src_val, dst_val; + int proto = 0; + u32 proto_val; + int payload_length = 0; + u32 payload_length_val; + int hop_limit = 0; + int hop_limit_val; + u32 ip_version_traffic_class_and_flow_label; + + while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) + { + if (unformat (input, "version %d", &version_val)) + version = 1; + else if (unformat (input, "traffic_class %d", &traffic_class_val)) + traffic_class = 1; + else if (unformat (input, "flow_label %d", &flow_label_val)) + flow_label = 1; + else if (unformat (input, "src %U", unformat_ip6_address, &src_val)) + src = 1; + else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val)) + dst = 1; + else if (unformat (input, "proto %d", &proto_val)) + proto = 1; + else if (unformat (input, "payload_length %d", &payload_length_val)) + payload_length = 1; + else if (unformat (input, "hop_limit %d", &hop_limit_val)) + hop_limit = 1; + else + break; + } + + if (version + traffic_class + flow_label + src + dst + proto + + payload_length + hop_limit == 0) + return 0; + + /* + * Aligned because we use the real comparison functions + */ + vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4)); + + ip = (ip6_header_t *) match; + + if (src) + clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address)); + + if (dst) + clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address)); + + if (proto) + ip->protocol = proto_val; + + ip_version_traffic_class_and_flow_label = 0; + + if (version) + ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28; + + if (traffic_class) + ip_version_traffic_class_and_flow_label |= + (traffic_class_val & 0xFF) << 20; + + if (flow_label) + ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF); + + ip->ip_version_traffic_class_and_flow_label = + clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label); + + if (payload_length) + ip->payload_length = clib_host_to_net_u16 (payload_length_val); + + if (hop_limit) + ip->hop_limit = hop_limit_val; + + *matchp = match; + return 1; +} + +uword +unformat_l3_match (unformat_input_t * input, va_list * args) +{ + u8 **matchp = va_arg (*args, u8 **); + + while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) + { + if (unformat (input, "ip4 %U", unformat_ip4_match, matchp)) + return 1; + else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp)) + return 1; + else + break; + } + return 0; +} + +uword +unformat_vlan_tag (unformat_input_t * input, va_list * args) +{ + u8 *tagp = va_arg (*args, u8 *); + u32 tag; + + if (unformat (input, "%d", &tag)) + { + tagp[0] = (tag >> 8) & 0x0F; + tagp[1] = tag & 0xFF; + return 1; + } + + return 0; +} + +uword +unformat_l2_match (unformat_input_t * input, va_list * args) +{ + u8 **matchp = va_arg (*args, u8 **); + u8 *match = 0; + u8 src = 0; + u8 src_val[6]; + u8 dst = 0; + u8 dst_val[6]; + u8 proto = 0; + u16 proto_val; + u8 tag1 = 0; + u8 tag1_val[2]; + u8 tag2 = 0; + u8 tag2_val[2]; + int len = 14; + u8 ignore_tag1 = 0; + u8 ignore_tag2 = 0; + u8 cos1 = 0; + u8 cos2 = 0; + u32 cos1_val = 0; + u32 cos2_val = 0; + + while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) + { + if (unformat (input, "src %U", unformat_ethernet_address, &src_val)) + src = 1; + else + if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val)) + dst = 1; + else if (unformat (input, "proto %U", + unformat_ethernet_type_host_byte_order, &proto_val)) + proto = 1; + else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val)) + tag1 = 1; + else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val)) + tag2 = 1; + else if (unformat (input, "ignore-tag1")) + ignore_tag1 = 1; + else if (unformat (input, "ignore-tag2")) + ignore_tag2 = 1; + else if (unformat (input, "cos1 %d", &cos1_val)) + cos1 = 1; + else if (unformat (input, "cos2 %d", &cos2_val)) + cos2 = 1; + else + break; + } + if ((src + dst + proto + tag1 + tag2 + + ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0) + return 0; + + if (tag1 || ignore_tag1 || cos1) + len = 18; + if (tag2 || ignore_tag2 || cos2) + len = 22; + + vec_validate_aligned (match, len - 1, sizeof (u32x4)); + + if (dst) + clib_memcpy (match, dst_val, 6); + + if (src) + clib_memcpy (match + 6, src_val, 6); + + if (tag2) + { + /* inner vlan tag */ + match[19] = tag2_val[1]; + match[18] = tag2_val[0]; + if (cos2) + match[18] |= (cos2_val & 0x7) << 5; + if (proto) + { + match[21] = proto_val & 0xff; + match[20] = proto_val >> 8; + } + if (tag1) + { + match[15] = tag1_val[1]; + match[14] = tag1_val[0]; + } + if (cos1) + match[14] |= (cos1_val & 0x7) << 5; + *matchp = match; + return 1; + } + if (tag1) + { + match[15] = tag1_val[1]; + match[14] = tag1_val[0]; + if (proto) + { + match[17] = proto_val & 0xff; + match[16] = proto_val >> 8; + } + if (cos1) + match[14] |= (cos1_val & 0x7) << 5; + + *matchp = match; + return 1; + } + if (cos2) + match[18] |= (cos2_val & 0x7) << 5; + if (cos1) + match[14] |= (cos1_val & 0x7) << 5; + if (proto) + { + match[13] = proto_val & 0xff; + match[12] = proto_val >> 8; + } + + *matchp = match; + return 1; +} + + +uword +unformat_classify_match (unformat_input_t * input, va_list * args) +{ + u8 **matchp = va_arg (*args, u8 **); + u32 skip_n_vectors = va_arg (*args, u32); + u32 match_n_vectors = va_arg (*args, u32); + + u8 *match = 0; + u8 *l2 = 0; + u8 *l3 = 0; + u8 *l4 = 0; + + while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) + { + if (unformat (input, "hex %U", unformat_hex_string, &match)) + ; + else if (unformat (input, "l2 %U", unformat_l2_match, &l2)) + ; + else if (unformat (input, "l3 %U", unformat_l3_match, &l3)) + ; + else if (unformat (input, "l4 %U", unformat_l4_match, &l4)) + ; + else + break; + } + + if (l4 && !l3) + { + vec_free (match); + vec_free (l2); + vec_free (l4); + return 0; + } + + if (match || l2 || l3 || l4) + { + if (l2 || l3 || l4) + { + /* "Win a free Ethernet header in every packet" */ + if (l2 == 0) + vec_validate_aligned (l2, 13, sizeof (u32x4)); + match = l2; + if (vec_len (l3)) + { + vec_append_aligned (match, l3, sizeof (u32x4)); + vec_free (l3); + } + if (vec_len (l4)) + { + vec_append_aligned (match, l4, sizeof (u32x4)); + vec_free (l4); + } + } + + /* Make sure the vector is big enough even if key is all 0's */ + vec_validate_aligned + (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1, + sizeof (u32x4)); + + /* Set size, include skipped vectors */ + _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4); + + *matchp = match; + + return 1; + } + + return 0; +} + +static int +api_classify_add_del_session (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + vl_api_classify_add_del_session_t *mp; + int is_add = 1; + u32 table_index = ~0; + u32 hit_next_index = ~0; + u32 opaque_index = ~0; + u8 *match = 0; + i32 advance = 0; + f64 timeout; + u32 skip_n_vectors = 0; + u32 match_n_vectors = 0; + u32 action = 0; + u32 metadata = 0; + + /* + * Warning: you have to supply skip_n and match_n + * because the API client cant simply look at the classify + * table object. + */ + + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "del")) + is_add = 0; + else if (unformat (i, "hit-next %U", unformat_ip_next_index, + &hit_next_index)) + ; + else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index, + &hit_next_index)) + ; + else if (unformat (i, "acl-hit-next %U", unformat_acl_next_index, + &hit_next_index)) + ; + else if (unformat (i, "policer-hit-next %d", &hit_next_index)) + ; + else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index)) + ; + else if (unformat (i, "opaque-index %d", &opaque_index)) + ; + else if (unformat (i, "skip_n %d", &skip_n_vectors)) + ; + else if (unformat (i, "match_n %d", &match_n_vectors)) + ; + else if (unformat (i, "match %U", unformat_classify_match, + &match, skip_n_vectors, match_n_vectors)) + ; + else if (unformat (i, "advance %d", &advance)) + ; + else if (unformat (i, "table-index %d", &table_index)) + ; + else if (unformat (i, "action set-ip4-fib-id %d", &metadata)) + action = 1; + else if (unformat (i, "action set-ip6-fib-id %d", &metadata)) + action = 2; + else if (unformat (i, "action %d", &action)) + ; + else if (unformat (i, "metadata %d", &metadata)) + ; + else + break; + } + + if (table_index == ~0) + { + errmsg ("Table index required"); + return -99; + } + + if (is_add && match == 0) + { + errmsg ("Match value required"); + return -99; + } + + M2 (CLASSIFY_ADD_DEL_SESSION, classify_add_del_session, vec_len (match)); + + mp->is_add = is_add; + mp->table_index = ntohl (table_index); + mp->hit_next_index = ntohl (hit_next_index); + mp->opaque_index = ntohl (opaque_index); + mp->advance = ntohl (advance); + mp->action = action; + mp->metadata = ntohl (metadata); + clib_memcpy (mp->match, match, vec_len (match)); + vec_free (match); + + S; + W; + /* NOTREACHED */ +} + +static int +api_classify_set_interface_ip_table (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + vl_api_classify_set_interface_ip_table_t *mp; + f64 timeout; + u32 sw_if_index; + int sw_if_index_set; + u32 table_index = ~0; + u8 is_ipv6 = 0; + + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index)) + sw_if_index_set = 1; + else if (unformat (i, "sw_if_index %d", &sw_if_index)) + sw_if_index_set = 1; + else if (unformat (i, "table %d", &table_index)) + ; + else + { + clib_warning ("parse error '%U'", format_unformat_error, i); + return -99; + } + } + + if (sw_if_index_set == 0) + { + errmsg ("missing interface name or sw_if_index"); + return -99; + } + + + M (CLASSIFY_SET_INTERFACE_IP_TABLE, classify_set_interface_ip_table); + + mp->sw_if_index = ntohl (sw_if_index); + mp->table_index = ntohl (table_index); + mp->is_ipv6 = is_ipv6; + + S; + W; + /* NOTREACHED */ + return 0; +} + +static int +api_classify_set_interface_l2_tables (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + vl_api_classify_set_interface_l2_tables_t *mp; + f64 timeout; + u32 sw_if_index; + int sw_if_index_set; + u32 ip4_table_index = ~0; + u32 ip6_table_index = ~0; + u32 other_table_index = ~0; + u32 is_input = 1; + + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index)) + sw_if_index_set = 1; + else if (unformat (i, "sw_if_index %d", &sw_if_index)) + sw_if_index_set = 1; + else if (unformat (i, "ip4-table %d", &ip4_table_index)) + ; + else if (unformat (i, "ip6-table %d", &ip6_table_index)) + ; + else if (unformat (i, "other-table %d", &other_table_index)) + ; + else if (unformat (i, "is-input %d", &is_input)) + ; + else + { + clib_warning ("parse error '%U'", format_unformat_error, i); + return -99; + } + } + + if (sw_if_index_set == 0) + { + errmsg ("missing interface name or sw_if_index"); + return -99; + } + + + M (CLASSIFY_SET_INTERFACE_L2_TABLES, classify_set_interface_l2_tables); + + mp->sw_if_index = ntohl (sw_if_index); + mp->ip4_table_index = ntohl (ip4_table_index); + mp->ip6_table_index = ntohl (ip6_table_index); + mp->other_table_index = ntohl (other_table_index); + mp->is_input = (u8) is_input; + + S; + W; + /* NOTREACHED */ + return 0; +} + +static int +api_set_ipfix_exporter (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + vl_api_set_ipfix_exporter_t *mp; + ip4_address_t collector_address; + u8 collector_address_set = 0; + u32 collector_port = ~0; + ip4_address_t src_address; + u8 src_address_set = 0; + u32 vrf_id = ~0; + u32 path_mtu = ~0; + u32 template_interval = ~0; + u8 udp_checksum = 0; + f64 timeout; + + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "collector_address %U", unformat_ip4_address, + &collector_address)) + collector_address_set = 1; + else if (unformat (i, "collector_port %d", &collector_port)) + ; + else if (unformat (i, "src_address %U", unformat_ip4_address, + &src_address)) + src_address_set = 1; + else if (unformat (i, "vrf_id %d", &vrf_id)) + ; + else if (unformat (i, "path_mtu %d", &path_mtu)) + ; + else if (unformat (i, "template_interval %d", &template_interval)) + ; + else if (unformat (i, "udp_checksum")) + udp_checksum = 1; + else + break; + } + + if (collector_address_set == 0) + { + errmsg ("collector_address required"); + return -99; + } + + if (src_address_set == 0) + { + errmsg ("src_address required"); + return -99; + } + + M (SET_IPFIX_EXPORTER, set_ipfix_exporter); + + memcpy (mp->collector_address, collector_address.data, + sizeof (collector_address.data)); + mp->collector_port = htons ((u16) collector_port); + memcpy (mp->src_address, src_address.data, sizeof (src_address.data)); + mp->vrf_id = htonl (vrf_id); + mp->path_mtu = htonl (path_mtu); + mp->template_interval = htonl (template_interval); + mp->udp_checksum = udp_checksum; + + S; + W; + /* NOTREACHED */ +} + +static int +api_set_ipfix_classify_stream (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + vl_api_set_ipfix_classify_stream_t *mp; + u32 domain_id = 0; + u32 src_port = UDP_DST_PORT_ipfix; + f64 timeout; + + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "domain %d", &domain_id)) + ; + else if (unformat (i, "src_port %d", &src_port)) + ; + else + { + errmsg ("unknown input `%U'", format_unformat_error, i); + return -99; + } + } + + M (SET_IPFIX_CLASSIFY_STREAM, set_ipfix_classify_stream); + + mp->domain_id = htonl (domain_id); + mp->src_port = htons ((u16) src_port); + + S; + W; + /* NOTREACHED */ +} + +static int +api_ipfix_classify_table_add_del (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + vl_api_ipfix_classify_table_add_del_t *mp; + int is_add = -1; + u32 classify_table_index = ~0; + u8 ip_version = 0; + u8 transport_protocol = 255; + f64 timeout; + + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "add")) + is_add = 1; + else if (unformat (i, "del")) + is_add = 0; + else if (unformat (i, "table %d", &classify_table_index)) + ; + else if (unformat (i, "ip4")) + ip_version = 4; + else if (unformat (i, "ip6")) + ip_version = 6; + else if (unformat (i, "tcp")) + transport_protocol = 6; + else if (unformat (i, "udp")) + transport_protocol = 17; + else + { + errmsg ("unknown input `%U'", format_unformat_error, i); + return -99; + } + } + + if (is_add == -1) + { + errmsg ("expecting: add|del"); + return -99; + } + if (classify_table_index == ~0) + { + errmsg ("classifier table not specified"); + return -99; + } + if (ip_version == 0) + { + errmsg ("IP version not specified"); + return -99; + } + + M (IPFIX_CLASSIFY_TABLE_ADD_DEL, ipfix_classify_table_add_del); + + mp->is_add = is_add; + mp->table_id = htonl (classify_table_index); + mp->ip_version = ip_version; + mp->transport_protocol = transport_protocol; + + S; + W; + /* NOTREACHED */ +} + +static int +api_get_node_index (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + vl_api_get_node_index_t *mp; + f64 timeout; + u8 *name = 0; + + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "node %s", &name)) + ; + else + break; + } + if (name == 0) + { + errmsg ("node name required"); + return -99; + } + if (vec_len (name) >= ARRAY_LEN (mp->node_name)) + { + errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name)); + return -99; + } + + M (GET_NODE_INDEX, get_node_index); + clib_memcpy (mp->node_name, name, vec_len (name)); + vec_free (name); + + S; + W; + /* NOTREACHED */ + return 0; +} + +static int +api_get_next_index (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + vl_api_get_next_index_t *mp; + f64 timeout; + u8 *node_name = 0, *next_node_name = 0; + + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "node-name %s", &node_name)) + ; + else if (unformat (i, "next-node-name %s", &next_node_name)) + break; + } + + if (node_name == 0) + { + errmsg ("node name required"); + return -99; + } + if (vec_len (node_name) >= ARRAY_LEN (mp->node_name)) + { + errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name)); + return -99; + } + + if (next_node_name == 0) + { + errmsg ("next node name required"); + return -99; + } + if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name)) + { + errmsg ("next node name too long, max %d", ARRAY_LEN (mp->next_name)); + return -99; + } + + M (GET_NEXT_INDEX, get_next_index); + clib_memcpy (mp->node_name, node_name, vec_len (node_name)); + clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name)); + vec_free (node_name); + vec_free (next_node_name); + + S; + W; + /* NOTREACHED */ + return 0; +} + +static int +api_add_node_next (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + vl_api_add_node_next_t *mp; + f64 timeout; + u8 *name = 0; + u8 *next = 0; + + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "node %s", &name)) + ; + else if (unformat (i, "next %s", &next)) + ; + else + break; + } + if (name == 0) + { + errmsg ("node name required"); + return -99; + } + if (vec_len (name) >= ARRAY_LEN (mp->node_name)) + { + errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name)); + return -99; + } + if (next == 0) + { + errmsg ("next node required"); + return -99; + } + if (vec_len (next) >= ARRAY_LEN (mp->next_name)) + { + errmsg ("next name too long, max %d", ARRAY_LEN (mp->next_name)); + return -99; + } + + M (ADD_NODE_NEXT, add_node_next); + clib_memcpy (mp->node_name, name, vec_len (name)); + clib_memcpy (mp->next_name, next, vec_len (next)); + vec_free (name); + vec_free (next); + + S; + W; + /* NOTREACHED */ + return 0; +} + +static int +api_l2tpv3_create_tunnel (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + ip6_address_t client_address, our_address; + int client_address_set = 0; + int our_address_set = 0; + u32 local_session_id = 0; + u32 remote_session_id = 0; + u64 local_cookie = 0; + u64 remote_cookie = 0; + u8 l2_sublayer_present = 0; + vl_api_l2tpv3_create_tunnel_t *mp; + f64 timeout; + + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "client_address %U", unformat_ip6_address, + &client_address)) + client_address_set = 1; + else if (unformat (i, "our_address %U", unformat_ip6_address, + &our_address)) + our_address_set = 1; + else if (unformat (i, "local_session_id %d", &local_session_id)) + ; + else if (unformat (i, "remote_session_id %d", &remote_session_id)) + ; + else if (unformat (i, "local_cookie %lld", &local_cookie)) + ; + else if (unformat (i, "remote_cookie %lld", &remote_cookie)) + ; + else if (unformat (i, "l2-sublayer-present")) + l2_sublayer_present = 1; + else + break; + } + + if (client_address_set == 0) + { + errmsg ("client_address required"); + return -99; + } + + if (our_address_set == 0) + { + errmsg ("our_address required"); + return -99; + } + + M (L2TPV3_CREATE_TUNNEL, l2tpv3_create_tunnel); + + clib_memcpy (mp->client_address, client_address.as_u8, + sizeof (mp->client_address)); + + clib_memcpy (mp->our_address, our_address.as_u8, sizeof (mp->our_address)); + + mp->local_session_id = ntohl (local_session_id); + mp->remote_session_id = ntohl (remote_session_id); + mp->local_cookie = clib_host_to_net_u64 (local_cookie); + mp->remote_cookie = clib_host_to_net_u64 (remote_cookie); + mp->l2_sublayer_present = l2_sublayer_present; + mp->is_ipv6 = 1; + + S; + W; + /* NOTREACHED */ + return 0; +} + +static int +api_l2tpv3_set_tunnel_cookies (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + u32 sw_if_index; + u8 sw_if_index_set = 0; + u64 new_local_cookie = 0; + u64 new_remote_cookie = 0; + vl_api_l2tpv3_set_tunnel_cookies_t *mp; + f64 timeout; + + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index)) + sw_if_index_set = 1; + else if (unformat (i, "sw_if_index %d", &sw_if_index)) + sw_if_index_set = 1; + else if (unformat (i, "new_local_cookie %lld", &new_local_cookie)) + ; + else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie)) + ; + else + break; + } + + if (sw_if_index_set == 0) + { + errmsg ("missing interface name or sw_if_index"); + return -99; + } + + M (L2TPV3_SET_TUNNEL_COOKIES, l2tpv3_set_tunnel_cookies); + + mp->sw_if_index = ntohl (sw_if_index); + mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie); + mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie); + + S; + W; + /* NOTREACHED */ + return 0; +} + +static int +api_l2tpv3_interface_enable_disable (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + vl_api_l2tpv3_interface_enable_disable_t *mp; + f64 timeout; + u32 sw_if_index; + u8 sw_if_index_set = 0; + u8 enable_disable = 1; + + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index)) + sw_if_index_set = 1; + else if (unformat (i, "sw_if_index %d", &sw_if_index)) + sw_if_index_set = 1; + else if (unformat (i, "enable")) + enable_disable = 1; + else if (unformat (i, "disable")) + enable_disable = 0; + else + break; + } + + if (sw_if_index_set == 0) + { + errmsg ("missing interface name or sw_if_index"); + return -99; + } + + M (L2TPV3_INTERFACE_ENABLE_DISABLE, l2tpv3_interface_enable_disable); + + mp->sw_if_index = ntohl (sw_if_index); + mp->enable_disable = enable_disable; + + S; + W; + /* NOTREACHED */ + return 0; +} + +static int +api_l2tpv3_set_lookup_key (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + vl_api_l2tpv3_set_lookup_key_t *mp; + f64 timeout; + u8 key = ~0; + + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "lookup_v6_src")) + key = L2T_LOOKUP_SRC_ADDRESS; + else if (unformat (i, "lookup_v6_dst")) + key = L2T_LOOKUP_DST_ADDRESS; + else if (unformat (i, "lookup_session_id")) + key = L2T_LOOKUP_SESSION_ID; + else + break; + } + + if (key == (u8) ~ 0) + { + errmsg ("l2tp session lookup key unset"); + return -99; + } + + M (L2TPV3_SET_LOOKUP_KEY, l2tpv3_set_lookup_key); + + mp->key = key; + + S; + W; + /* NOTREACHED */ + return 0; +} + +static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler + (vl_api_sw_if_l2tpv3_tunnel_details_t * mp) +{ + vat_main_t *vam = &vat_main; + + print (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)", + format_ip6_address, mp->our_address, + format_ip6_address, mp->client_address, + clib_net_to_host_u32 (mp->sw_if_index)); + + print (vam->ofp, + " local cookies %016llx %016llx remote cookie %016llx", + clib_net_to_host_u64 (mp->local_cookie[0]), + clib_net_to_host_u64 (mp->local_cookie[1]), + clib_net_to_host_u64 (mp->remote_cookie)); + + print (vam->ofp, " local session-id %d remote session-id %d", + clib_net_to_host_u32 (mp->local_session_id), + clib_net_to_host_u32 (mp->remote_session_id)); + + print (vam->ofp, " l2 specific sublayer %s\n", + mp->l2_sublayer_present ? "preset" : "absent"); + +} + +static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json + (vl_api_sw_if_l2tpv3_tunnel_details_t * mp) +{ + vat_main_t *vam = &vat_main; + vat_json_node_t *node = NULL; + struct in6_addr addr; + + if (VAT_JSON_ARRAY != vam->json_tree.type) + { + ASSERT (VAT_JSON_NONE == vam->json_tree.type); + vat_json_init_array (&vam->json_tree); + } + node = vat_json_array_add (&vam->json_tree); + + vat_json_init_object (node); + + clib_memcpy (&addr, mp->our_address, sizeof (addr)); + vat_json_object_add_ip6 (node, "our_address", addr); + clib_memcpy (&addr, mp->client_address, sizeof (addr)); + vat_json_object_add_ip6 (node, "client_address", addr); + + vat_json_node_t *lc = vat_json_object_add (node, "local_cookie"); + vat_json_init_array (lc); + vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0])); + vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1])); + vat_json_object_add_uint (node, "remote_cookie", + clib_net_to_host_u64 (mp->remote_cookie)); + + printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id)); + vat_json_object_add_uint (node, "local_session_id", + clib_net_to_host_u32 (mp->local_session_id)); + vat_json_object_add_uint (node, "remote_session_id", + clib_net_to_host_u32 (mp->remote_session_id)); + vat_json_object_add_string_copy (node, "l2_sublayer", + mp->l2_sublayer_present ? (u8 *) "present" + : (u8 *) "absent"); +} + +static int +api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam) +{ + vl_api_sw_if_l2tpv3_tunnel_dump_t *mp; + f64 timeout; + + /* Get list of l2tpv3-tunnel interfaces */ + M (SW_IF_L2TPV3_TUNNEL_DUMP, sw_if_l2tpv3_tunnel_dump); + S; + + /* Use a control ping for synchronization */ + { + vl_api_control_ping_t *mp; + M (CONTROL_PING, control_ping); + S; + } + W; +} + + +static void vl_api_sw_interface_tap_details_t_handler + (vl_api_sw_interface_tap_details_t * mp) +{ + vat_main_t *vam = &vat_main; + + print (vam->ofp, "%-16s %d", + mp->dev_name, clib_net_to_host_u32 (mp->sw_if_index)); +} + +static void vl_api_sw_interface_tap_details_t_handler_json + (vl_api_sw_interface_tap_details_t * mp) +{ + vat_main_t *vam = &vat_main; + vat_json_node_t *node = NULL; + + if (VAT_JSON_ARRAY != vam->json_tree.type) + { + ASSERT (VAT_JSON_NONE == vam->json_tree.type); + vat_json_init_array (&vam->json_tree); + } + node = vat_json_array_add (&vam->json_tree); + + vat_json_init_object (node); + vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index)); + vat_json_object_add_string_copy (node, "dev_name", mp->dev_name); +} + +static int +api_sw_interface_tap_dump (vat_main_t * vam) +{ + vl_api_sw_interface_tap_dump_t *mp; + f64 timeout; + + print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index"); + /* Get list of tap interfaces */ + M (SW_INTERFACE_TAP_DUMP, sw_interface_tap_dump); + S; + + /* Use a control ping for synchronization */ + { + vl_api_control_ping_t *mp; + M (CONTROL_PING, control_ping); + S; + } + W; +} + +static uword unformat_vxlan_decap_next + (unformat_input_t * input, va_list * args) +{ + u32 *result = va_arg (*args, u32 *); + u32 tmp; + + if (unformat (input, "l2")) + *result = VXLAN_INPUT_NEXT_L2_INPUT; + else if (unformat (input, "%d", &tmp)) + *result = tmp; + else + return 0; + return 1; +} + +static int +api_vxlan_add_del_tunnel (vat_main_t * vam) +{ + unformat_input_t *line_input = vam->input; + vl_api_vxlan_add_del_tunnel_t *mp; + f64 timeout; + ip46_address_t src, dst; + u8 is_add = 1; + u8 ipv4_set = 0, ipv6_set = 0; + u8 src_set = 0; + u8 dst_set = 0; + u8 grp_set = 0; + u32 mcast_sw_if_index = ~0; + u32 encap_vrf_id = 0; + u32 decap_next_index = ~0; + u32 vni = 0; + + /* Can't "universally zero init" (={0}) due to GCC bug 53119 */ + memset (&src, 0, sizeof src); + memset (&dst, 0, sizeof dst); + + while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) + { + if (unformat (line_input, "del")) + is_add = 0; + else + if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4)) + { + ipv4_set = 1; + src_set = 1; + } + else + if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4)) + { + ipv4_set = 1; + dst_set = 1; + } + else + if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6)) + { + ipv6_set = 1; + src_set = 1; + } + else + if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6)) + { + ipv6_set = 1; + dst_set = 1; + } + else if (unformat (line_input, "group %U %U", + unformat_ip4_address, &dst.ip4, + api_unformat_sw_if_index, vam, &mcast_sw_if_index)) + { + grp_set = dst_set = 1; + ipv4_set = 1; + } + else if (unformat (line_input, "group %U", + unformat_ip4_address, &dst.ip4)) + { + grp_set = dst_set = 1; + ipv4_set = 1; + } + else if (unformat (line_input, "group %U %U", + unformat_ip6_address, &dst.ip6, + api_unformat_sw_if_index, vam, &mcast_sw_if_index)) + { + grp_set = dst_set = 1; + ipv6_set = 1; + } + else if (unformat (line_input, "group %U", + unformat_ip6_address, &dst.ip6)) + { + grp_set = dst_set = 1; + ipv6_set = 1; + } + else + if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index)) + ; + else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id)) + ; + else if (unformat (line_input, "decap-next %U", + unformat_vxlan_decap_next, &decap_next_index)) + ; + else if (unformat (line_input, "vni %d", &vni)) + ; + else + { + errmsg ("parse error '%U'", format_unformat_error, line_input); + return -99; + } + } + + if (src_set == 0) + { + errmsg ("tunnel src address not specified"); + return -99; + } + if (dst_set == 0) + { + errmsg ("tunnel dst address not specified"); + return -99; + } + + if (grp_set && !ip46_address_is_multicast (&dst)) + { + errmsg ("tunnel group address not multicast"); + return -99; + } + if (grp_set && mcast_sw_if_index == ~0) + { + errmsg ("tunnel nonexistent multicast device"); + return -99; + } + if (grp_set == 0 && ip46_address_is_multicast (&dst)) + { + errmsg ("tunnel dst address must be unicast"); + return -99; + } + + + if (ipv4_set && ipv6_set) + { + errmsg ("both IPv4 and IPv6 addresses specified"); + return -99; + } + + if ((vni == 0) || (vni >> 24)) + { + errmsg ("vni not specified or out of range"); + return -99; + } + + M (VXLAN_ADD_DEL_TUNNEL, vxlan_add_del_tunnel); + + if (ipv6_set) + { + clib_memcpy (mp->src_address, &src.ip6, sizeof (src.ip6)); + clib_memcpy (mp->dst_address, &dst.ip6, sizeof (dst.ip6)); + } + else + { + clib_memcpy (mp->src_address, &src.ip4, sizeof (src.ip4)); + clib_memcpy (mp->dst_address, &dst.ip4, sizeof (dst.ip4)); + } + mp->encap_vrf_id = ntohl (encap_vrf_id); + mp->decap_next_index = ntohl (decap_next_index); + mp->mcast_sw_if_index = ntohl (mcast_sw_if_index); + mp->vni = ntohl (vni); + mp->is_add = is_add; + mp->is_ipv6 = ipv6_set; + + S; + W; + /* NOTREACHED */ + return 0; +} + +static void vl_api_vxlan_tunnel_details_t_handler + (vl_api_vxlan_tunnel_details_t * mp) +{ + vat_main_t *vam = &vat_main; + ip46_address_t src, dst; + + ip46_from_addr_buf (mp->is_ipv6, mp->src_address, &src); + ip46_from_addr_buf (mp->is_ipv6, mp->dst_address, &dst); + + print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d", + ntohl (mp->sw_if_index), + format_ip46_address, &src, IP46_TYPE_ANY, + format_ip46_address, &dst, IP46_TYPE_ANY, + ntohl (mp->encap_vrf_id), + ntohl (mp->decap_next_index), ntohl (mp->vni), + ntohl (mp->mcast_sw_if_index)); +} + +static void vl_api_vxlan_tunnel_details_t_handler_json + (vl_api_vxlan_tunnel_details_t * mp) +{ + vat_main_t *vam = &vat_main; + vat_json_node_t *node = NULL; + + if (VAT_JSON_ARRAY != vam->json_tree.type) + { + ASSERT (VAT_JSON_NONE == vam->json_tree.type); + vat_json_init_array (&vam->json_tree); + } + node = vat_json_array_add (&vam->json_tree); + + vat_json_init_object (node); + vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index)); + if (mp->is_ipv6) + { + struct in6_addr ip6; + + clib_memcpy (&ip6, mp->src_address, sizeof (ip6)); + vat_json_object_add_ip6 (node, "src_address", ip6); + clib_memcpy (&ip6, mp->dst_address, sizeof (ip6)); + vat_json_object_add_ip6 (node, "dst_address", ip6); + } + else + { + struct in_addr ip4; + + clib_memcpy (&ip4, mp->src_address, sizeof (ip4)); + vat_json_object_add_ip4 (node, "src_address", ip4); + clib_memcpy (&ip4, mp->dst_address, sizeof (ip4)); + vat_json_object_add_ip4 (node, "dst_address", ip4); + } + vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id)); + vat_json_object_add_uint (node, "decap_next_index", + ntohl (mp->decap_next_index)); + vat_json_object_add_uint (node, "vni", ntohl (mp->vni)); + vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0); + vat_json_object_add_uint (node, "mcast_sw_if_index", + ntohl (mp->mcast_sw_if_index)); +} + +static int +api_vxlan_tunnel_dump (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + vl_api_vxlan_tunnel_dump_t *mp; + f64 timeout; + u32 sw_if_index; + u8 sw_if_index_set = 0; + + /* Parse args required to build the message */ + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "sw_if_index %d", &sw_if_index)) + sw_if_index_set = 1; + else + break; + } + + if (sw_if_index_set == 0) + { + sw_if_index = ~0; + } + + if (!vam->json_output) + { + print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s", + "sw_if_index", "src_address", "dst_address", + "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index"); + } + + /* Get list of vxlan-tunnel interfaces */ + M (VXLAN_TUNNEL_DUMP, vxlan_tunnel_dump); + + mp->sw_if_index = htonl (sw_if_index); + + S; + + /* Use a control ping for synchronization */ + { + vl_api_control_ping_t *mp; + M (CONTROL_PING, control_ping); + S; + } + W; +} + +static int +api_gre_add_del_tunnel (vat_main_t * vam) +{ + unformat_input_t *line_input = vam->input; + vl_api_gre_add_del_tunnel_t *mp; + f64 timeout; + ip4_address_t src4, dst4; + u8 is_add = 1; + u8 teb = 0; + u8 src_set = 0; + u8 dst_set = 0; + u32 outer_fib_id = 0; + + while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) + { + if (unformat (line_input, "del")) + is_add = 0; + else if (unformat (line_input, "src %U", unformat_ip4_address, &src4)) + src_set = 1; + else if (unformat (line_input, "dst %U", unformat_ip4_address, &dst4)) + dst_set = 1; + else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id)) + ; + else if (unformat (line_input, "teb")) + teb = 1; + else + { + errmsg ("parse error '%U'", format_unformat_error, line_input); + return -99; + } + } + + if (src_set == 0) + { + errmsg ("tunnel src address not specified"); + return -99; + } + if (dst_set == 0) + { + errmsg ("tunnel dst address not specified"); + return -99; + } + + + M (GRE_ADD_DEL_TUNNEL, gre_add_del_tunnel); + + clib_memcpy (&mp->src_address, &src4, sizeof (src4)); + clib_memcpy (&mp->dst_address, &dst4, sizeof (dst4)); + mp->outer_fib_id = ntohl (outer_fib_id); + mp->is_add = is_add; + mp->teb = teb; + + S; + W; + /* NOTREACHED */ + return 0; +} + +static void vl_api_gre_tunnel_details_t_handler + (vl_api_gre_tunnel_details_t * mp) +{ + vat_main_t *vam = &vat_main; + + print (vam->ofp, "%11d%15U%15U%6d%14d", + ntohl (mp->sw_if_index), + format_ip4_address, &mp->src_address, + format_ip4_address, &mp->dst_address, + mp->teb, ntohl (mp->outer_fib_id)); +} + +static void vl_api_gre_tunnel_details_t_handler_json + (vl_api_gre_tunnel_details_t * mp) +{ + vat_main_t *vam = &vat_main; + vat_json_node_t *node = NULL; + struct in_addr ip4; + + if (VAT_JSON_ARRAY != vam->json_tree.type) + { + ASSERT (VAT_JSON_NONE == vam->json_tree.type); + vat_json_init_array (&vam->json_tree); + } + node = vat_json_array_add (&vam->json_tree); + + vat_json_init_object (node); + vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index)); + clib_memcpy (&ip4, &mp->src_address, sizeof (ip4)); + vat_json_object_add_ip4 (node, "src_address", ip4); + clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4)); + vat_json_object_add_ip4 (node, "dst_address", ip4); + vat_json_object_add_uint (node, "teb", mp->teb); + vat_json_object_add_uint (node, "outer_fib_id", ntohl (mp->outer_fib_id)); +} + +static int +api_gre_tunnel_dump (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + vl_api_gre_tunnel_dump_t *mp; + f64 timeout; + u32 sw_if_index; + u8 sw_if_index_set = 0; + + /* Parse args required to build the message */ + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "sw_if_index %d", &sw_if_index)) + sw_if_index_set = 1; + else + break; + } + + if (sw_if_index_set == 0) + { + sw_if_index = ~0; + } + + if (!vam->json_output) + { + print (vam->ofp, "%11s%15s%15s%6s%14s", + "sw_if_index", "src_address", "dst_address", "teb", + "outer_fib_id"); + } + + /* Get list of gre-tunnel interfaces */ + M (GRE_TUNNEL_DUMP, gre_tunnel_dump); + + mp->sw_if_index = htonl (sw_if_index); + + S; + + /* Use a control ping for synchronization */ + { + vl_api_control_ping_t *mp; + M (CONTROL_PING, control_ping); + S; + } + W; +} + +static int +api_l2_fib_clear_table (vat_main_t * vam) +{ +// unformat_input_t * i = vam->input; + vl_api_l2_fib_clear_table_t *mp; + f64 timeout; + + M (L2_FIB_CLEAR_TABLE, l2_fib_clear_table); + + S; + W; + /* NOTREACHED */ + return 0; +} + +static int +api_l2_interface_efp_filter (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + vl_api_l2_interface_efp_filter_t *mp; + f64 timeout; + u32 sw_if_index; + u8 enable = 1; + u8 sw_if_index_set = 0; + + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index)) + sw_if_index_set = 1; + else if (unformat (i, "sw_if_index %d", &sw_if_index)) + sw_if_index_set = 1; + else if (unformat (i, "enable")) + enable = 1; + else if (unformat (i, "disable")) + enable = 0; + else + { + clib_warning ("parse error '%U'", format_unformat_error, i); + return -99; + } + } + + if (sw_if_index_set == 0) + { + errmsg ("missing sw_if_index"); + return -99; + } + + M (L2_INTERFACE_EFP_FILTER, l2_interface_efp_filter); + + mp->sw_if_index = ntohl (sw_if_index); + mp->enable_disable = enable; + + S; + W; + /* NOTREACHED */ + return 0; +} + +#define foreach_vtr_op \ +_("disable", L2_VTR_DISABLED) \ +_("push-1", L2_VTR_PUSH_1) \ +_("push-2", L2_VTR_PUSH_2) \ +_("pop-1", L2_VTR_POP_1) \ +_("pop-2", L2_VTR_POP_2) \ +_("translate-1-1", L2_VTR_TRANSLATE_1_1) \ +_("translate-1-2", L2_VTR_TRANSLATE_1_2) \ +_("translate-2-1", L2_VTR_TRANSLATE_2_1) \ +_("translate-2-2", L2_VTR_TRANSLATE_2_2) + +static int +api_l2_interface_vlan_tag_rewrite (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + vl_api_l2_interface_vlan_tag_rewrite_t *mp; + f64 timeout; + u32 sw_if_index; + u8 sw_if_index_set = 0; + u8 vtr_op_set = 0; + u32 vtr_op = 0; + u32 push_dot1q = 1; + u32 tag1 = ~0; + u32 tag2 = ~0; + + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index)) + sw_if_index_set = 1; + else if (unformat (i, "sw_if_index %d", &sw_if_index)) + sw_if_index_set = 1; + else if (unformat (i, "vtr_op %d", &vtr_op)) + vtr_op_set = 1; +#define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;} + foreach_vtr_op +#undef _ + else if (unformat (i, "push_dot1q %d", &push_dot1q)) + ; + else if (unformat (i, "tag1 %d", &tag1)) + ; + else if (unformat (i, "tag2 %d", &tag2)) + ; + else + { + clib_warning ("parse error '%U'", format_unformat_error, i); + return -99; + } + } + + if ((sw_if_index_set == 0) || (vtr_op_set == 0)) + { + errmsg ("missing vtr operation or sw_if_index"); + return -99; + } + + M (L2_INTERFACE_VLAN_TAG_REWRITE, l2_interface_vlan_tag_rewrite) + mp->sw_if_index = ntohl (sw_if_index); + mp->vtr_op = ntohl (vtr_op); + mp->push_dot1q = ntohl (push_dot1q); + mp->tag1 = ntohl (tag1); + mp->tag2 = ntohl (tag2); + + S; + W; + /* NOTREACHED */ + return 0; +} + +static int +api_create_vhost_user_if (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + vl_api_create_vhost_user_if_t *mp; + f64 timeout; + u8 *file_name; + u8 is_server = 0; + u8 file_name_set = 0; + u32 custom_dev_instance = ~0; + u8 hwaddr[6]; + u8 use_custom_mac = 0; + u8 *tag = 0; + + /* Shut up coverity */ + memset (hwaddr, 0, sizeof (hwaddr)); + + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "socket %s", &file_name)) + { + file_name_set = 1; + } + else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance)) + ; + else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr)) + use_custom_mac = 1; + else if (unformat (i, "server")) + is_server = 1; + else if (unformat (i, "tag %s", &tag)) + ; + else + break; + } + + if (file_name_set == 0) + { + errmsg ("missing socket file name"); + return -99; + } + + if (vec_len (file_name) > 255) + { + errmsg ("socket file name too long"); + return -99; + } + vec_add1 (file_name, 0); + + M (CREATE_VHOST_USER_IF, create_vhost_user_if); + + mp->is_server = is_server; + clib_memcpy (mp->sock_filename, file_name, vec_len (file_name)); + vec_free (file_name); + if (custom_dev_instance != ~0) + { + mp->renumber = 1; + mp->custom_dev_instance = ntohl (custom_dev_instance); + } + mp->use_custom_mac = use_custom_mac; + clib_memcpy (mp->mac_address, hwaddr, 6); + if (tag) + strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1); + vec_free (tag); + + S; + W; + /* NOTREACHED */ + return 0; +} + +static int +api_modify_vhost_user_if (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + vl_api_modify_vhost_user_if_t *mp; + f64 timeout; + u8 *file_name; + u8 is_server = 0; + u8 file_name_set = 0; + u32 custom_dev_instance = ~0; + u8 sw_if_index_set = 0; + u32 sw_if_index = (u32) ~ 0; + + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index)) + sw_if_index_set = 1; + else if (unformat (i, "sw_if_index %d", &sw_if_index)) + sw_if_index_set = 1; + else if (unformat (i, "socket %s", &file_name)) + { + file_name_set = 1; + } + else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance)) + ; + else if (unformat (i, "server")) + is_server = 1; + else + break; + } + + if (sw_if_index_set == 0) + { + errmsg ("missing sw_if_index or interface name"); + return -99; + } + + if (file_name_set == 0) + { + errmsg ("missing socket file name"); + return -99; + } + + if (vec_len (file_name) > 255) + { + errmsg ("socket file name too long"); + return -99; + } + vec_add1 (file_name, 0); + + M (MODIFY_VHOST_USER_IF, modify_vhost_user_if); + + mp->sw_if_index = ntohl (sw_if_index); + mp->is_server = is_server; + clib_memcpy (mp->sock_filename, file_name, vec_len (file_name)); + vec_free (file_name); + if (custom_dev_instance != ~0) + { + mp->renumber = 1; + mp->custom_dev_instance = ntohl (custom_dev_instance); + } + + S; + W; + /* NOTREACHED */ + return 0; +} + +static int +api_delete_vhost_user_if (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + vl_api_delete_vhost_user_if_t *mp; + f64 timeout; + u32 sw_if_index = ~0; + u8 sw_if_index_set = 0; + + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index)) + sw_if_index_set = 1; + else if (unformat (i, "sw_if_index %d", &sw_if_index)) + sw_if_index_set = 1; + else + break; + } + + if (sw_if_index_set == 0) + { + errmsg ("missing sw_if_index or interface name"); + return -99; + } + + + M (DELETE_VHOST_USER_IF, delete_vhost_user_if); + + mp->sw_if_index = ntohl (sw_if_index); + + S; + W; + /* NOTREACHED */ + return 0; +} + +static void vl_api_sw_interface_vhost_user_details_t_handler + (vl_api_sw_interface_vhost_user_details_t * mp) +{ + vat_main_t *vam = &vat_main; + + print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s", + (char *) mp->interface_name, + ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz), + clib_net_to_host_u64 (mp->features), mp->is_server, + ntohl (mp->num_regions), (char *) mp->sock_filename); + print (vam->ofp, " Status: '%s'", strerror (ntohl (mp->sock_errno))); +} + +static void vl_api_sw_interface_vhost_user_details_t_handler_json + (vl_api_sw_interface_vhost_user_details_t * mp) +{ + vat_main_t *vam = &vat_main; + vat_json_node_t *node = NULL; + + if (VAT_JSON_ARRAY != vam->json_tree.type) + { + ASSERT (VAT_JSON_NONE == vam->json_tree.type); + vat_json_init_array (&vam->json_tree); + } + node = vat_json_array_add (&vam->json_tree); + + vat_json_init_object (node); + vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index)); + vat_json_object_add_string_copy (node, "interface_name", + mp->interface_name); + vat_json_object_add_uint (node, "virtio_net_hdr_sz", + ntohl (mp->virtio_net_hdr_sz)); + vat_json_object_add_uint (node, "features", + clib_net_to_host_u64 (mp->features)); + vat_json_object_add_uint (node, "is_server", mp->is_server); + vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename); + vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions)); + vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno)); +} + +static int +api_sw_interface_vhost_user_dump (vat_main_t * vam) +{ + vl_api_sw_interface_vhost_user_dump_t *mp; + f64 timeout; + print (vam->ofp, + "Interface name idx hdr_sz features server regions filename"); + + /* Get list of vhost-user interfaces */ + M (SW_INTERFACE_VHOST_USER_DUMP, sw_interface_vhost_user_dump); + S; + + /* Use a control ping for synchronization */ + { + vl_api_control_ping_t *mp; + M (CONTROL_PING, control_ping); + S; + } + W; +} + +static int +api_show_version (vat_main_t * vam) +{ + vl_api_show_version_t *mp; + f64 timeout; + + M (SHOW_VERSION, show_version); + + S; + W; + /* NOTREACHED */ + return 0; +} + + +static int +api_vxlan_gpe_add_del_tunnel (vat_main_t * vam) +{ + unformat_input_t *line_input = vam->input; + vl_api_vxlan_gpe_add_del_tunnel_t *mp; + f64 timeout; + ip4_address_t local4, remote4; + ip6_address_t local6, remote6; + u8 is_add = 1; + u8 ipv4_set = 0, ipv6_set = 0; + u8 local_set = 0; + u8 remote_set = 0; + u32 encap_vrf_id = 0; + u32 decap_vrf_id = 0; + u8 protocol = ~0; + u32 vni; + u8 vni_set = 0; + + while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) + { + if (unformat (line_input, "del")) + is_add = 0; + else if (unformat (line_input, "local %U", + unformat_ip4_address, &local4)) + { + local_set = 1; + ipv4_set = 1; + } + else if (unformat (line_input, "remote %U", + unformat_ip4_address, &remote4)) + { + remote_set = 1; + ipv4_set = 1; + } + else if (unformat (line_input, "local %U", + unformat_ip6_address, &local6)) + { + local_set = 1; + ipv6_set = 1; + } + else if (unformat (line_input, "remote %U", + unformat_ip6_address, &remote6)) + { + remote_set = 1; + ipv6_set = 1; + } + else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id)) + ; + else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id)) + ; + else if (unformat (line_input, "vni %d", &vni)) + vni_set = 1; + else if (unformat (line_input, "next-ip4")) + protocol = 1; + else if (unformat (line_input, "next-ip6")) + protocol = 2; + else if (unformat (line_input, "next-ethernet")) + protocol = 3; + else if (unformat (line_input, "next-nsh")) + protocol = 4; + else + { + errmsg ("parse error '%U'", format_unformat_error, line_input); + return -99; + } + } + + if (local_set == 0) + { + errmsg ("tunnel local address not specified"); + return -99; + } + if (remote_set == 0) + { + errmsg ("tunnel remote address not specified"); + return -99; + } + if (ipv4_set && ipv6_set) + { + errmsg ("both IPv4 and IPv6 addresses specified"); + return -99; + } + + if (vni_set == 0) + { + errmsg ("vni not specified"); + return -99; + } + + M (VXLAN_GPE_ADD_DEL_TUNNEL, vxlan_gpe_add_del_tunnel); + + + if (ipv6_set) + { + clib_memcpy (&mp->local, &local6, sizeof (local6)); + clib_memcpy (&mp->remote, &remote6, sizeof (remote6)); + } + else + { + clib_memcpy (&mp->local, &local4, sizeof (local4)); + clib_memcpy (&mp->remote, &remote4, sizeof (remote4)); + } + + mp->encap_vrf_id = ntohl (encap_vrf_id); + mp->decap_vrf_id = ntohl (decap_vrf_id); + mp->protocol = protocol; + mp->vni = ntohl (vni); + mp->is_add = is_add; + mp->is_ipv6 = ipv6_set; + + S; + W; + /* NOTREACHED */ + return 0; +} + +static void vl_api_vxlan_gpe_tunnel_details_t_handler + (vl_api_vxlan_gpe_tunnel_details_t * mp) +{ + vat_main_t *vam = &vat_main; + + print (vam->ofp, "%11d%24U%24U%13d%12d%14d%14d", + ntohl (mp->sw_if_index), + format_ip46_address, &(mp->local[0]), + format_ip46_address, &(mp->remote[0]), + ntohl (mp->vni), + ntohl (mp->protocol), + ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id)); +} + +static void vl_api_vxlan_gpe_tunnel_details_t_handler_json + (vl_api_vxlan_gpe_tunnel_details_t * mp) +{ + vat_main_t *vam = &vat_main; + vat_json_node_t *node = NULL; + struct in_addr ip4; + struct in6_addr ip6; + + if (VAT_JSON_ARRAY != vam->json_tree.type) + { + ASSERT (VAT_JSON_NONE == vam->json_tree.type); + vat_json_init_array (&vam->json_tree); + } + node = vat_json_array_add (&vam->json_tree); + + vat_json_init_object (node); + vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index)); + if (mp->is_ipv6) + { + clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6)); + vat_json_object_add_ip6 (node, "local", ip6); + clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6)); + vat_json_object_add_ip6 (node, "remote", ip6); + } + else + { + clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4)); + vat_json_object_add_ip4 (node, "local", ip4); + clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4)); + vat_json_object_add_ip4 (node, "remote", ip4); + } + vat_json_object_add_uint (node, "vni", ntohl (mp->vni)); + vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol)); + vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id)); + vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id)); + vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0); +} + +static int +api_vxlan_gpe_tunnel_dump (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + vl_api_vxlan_gpe_tunnel_dump_t *mp; + f64 timeout; + u32 sw_if_index; + u8 sw_if_index_set = 0; + + /* Parse args required to build the message */ + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "sw_if_index %d", &sw_if_index)) + sw_if_index_set = 1; + else + break; + } + + if (sw_if_index_set == 0) + { + sw_if_index = ~0; + } + + if (!vam->json_output) + { + print (vam->ofp, "%11s%24s%24s%13s%15s%14s%14s", + "sw_if_index", "local", "remote", "vni", + "protocol", "encap_vrf_id", "decap_vrf_id"); + } + + /* Get list of vxlan-tunnel interfaces */ + M (VXLAN_GPE_TUNNEL_DUMP, vxlan_gpe_tunnel_dump); + + mp->sw_if_index = htonl (sw_if_index); + + S; + + /* Use a control ping for synchronization */ + { + vl_api_control_ping_t *mp; + M (CONTROL_PING, control_ping); + S; + } + W; +} + +u8 * +format_l2_fib_mac_address (u8 * s, va_list * args) +{ + u8 *a = va_arg (*args, u8 *); + + return format (s, "%02x:%02x:%02x:%02x:%02x:%02x", + a[2], a[3], a[4], a[5], a[6], a[7]); +} + +static void vl_api_l2_fib_table_entry_t_handler + (vl_api_l2_fib_table_entry_t * mp) +{ + vat_main_t *vam = &vat_main; + + print (vam->ofp, "%3" PRIu32 " %U %3" PRIu32 + " %d %d %d", + ntohl (mp->bd_id), format_l2_fib_mac_address, &mp->mac, + ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac, + mp->bvi_mac); +} + +static void vl_api_l2_fib_table_entry_t_handler_json + (vl_api_l2_fib_table_entry_t * mp) +{ + vat_main_t *vam = &vat_main; + vat_json_node_t *node = NULL; + + if (VAT_JSON_ARRAY != vam->json_tree.type) + { + ASSERT (VAT_JSON_NONE == vam->json_tree.type); + vat_json_init_array (&vam->json_tree); + } + node = vat_json_array_add (&vam->json_tree); + + vat_json_init_object (node); + vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id)); + vat_json_object_add_uint (node, "mac", clib_net_to_host_u64 (mp->mac)); + vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index)); + vat_json_object_add_uint (node, "static_mac", mp->static_mac); + vat_json_object_add_uint (node, "filter_mac", mp->filter_mac); + vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac); +} + +static int +api_l2_fib_table_dump (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + vl_api_l2_fib_table_dump_t *mp; + f64 timeout; + u32 bd_id; + u8 bd_id_set = 0; + + /* Parse args required to build the message */ + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "bd_id %d", &bd_id)) + bd_id_set = 1; + else + break; + } + + if (bd_id_set == 0) + { + errmsg ("missing bridge domain"); + return -99; + } + + print (vam->ofp, "BD-ID Mac Address sw-ndx Static Filter BVI"); + + /* Get list of l2 fib entries */ + M (L2_FIB_TABLE_DUMP, l2_fib_table_dump); + + mp->bd_id = ntohl (bd_id); + S; + + /* Use a control ping for synchronization */ + { + vl_api_control_ping_t *mp; + M (CONTROL_PING, control_ping); + S; + } + W; +} + + +static int +api_interface_name_renumber (vat_main_t * vam) +{ + unformat_input_t *line_input = vam->input; + vl_api_interface_name_renumber_t *mp; + u32 sw_if_index = ~0; + f64 timeout; + u32 new_show_dev_instance = ~0; + + while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) + { + if (unformat (line_input, "%U", api_unformat_sw_if_index, vam, + &sw_if_index)) + ; + else if (unformat (line_input, "sw_if_index %d", &sw_if_index)) + ; + else if (unformat (line_input, "new_show_dev_instance %d", + &new_show_dev_instance)) + ; + else + break; + } + + if (sw_if_index == ~0) + { + errmsg ("missing interface name or sw_if_index"); + return -99; + } + + if (new_show_dev_instance == ~0) + { + errmsg ("missing new_show_dev_instance"); + return -99; + } + + M (INTERFACE_NAME_RENUMBER, interface_name_renumber); + + mp->sw_if_index = ntohl (sw_if_index); + mp->new_show_dev_instance = ntohl (new_show_dev_instance); + + S; + W; +} + +static int +api_want_ip4_arp_events (vat_main_t * vam) +{ + unformat_input_t *line_input = vam->input; + vl_api_want_ip4_arp_events_t *mp; + f64 timeout; + ip4_address_t address; + int address_set = 0; + u32 enable_disable = 1; + + while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) + { + if (unformat (line_input, "address %U", unformat_ip4_address, &address)) + address_set = 1; + else if (unformat (line_input, "del")) + enable_disable = 0; + else + break; + } + + if (address_set == 0) + { + errmsg ("missing addresses"); + return -99; + } + + M (WANT_IP4_ARP_EVENTS, want_ip4_arp_events); + mp->enable_disable = enable_disable; + mp->pid = getpid (); + mp->address = address.as_u32; + + S; + W; +} + +static int +api_want_ip6_nd_events (vat_main_t * vam) +{ + unformat_input_t *line_input = vam->input; + vl_api_want_ip6_nd_events_t *mp; + f64 timeout; + ip6_address_t address; + int address_set = 0; + u32 enable_disable = 1; + + while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) + { + if (unformat (line_input, "address %U", unformat_ip6_address, &address)) + address_set = 1; + else if (unformat (line_input, "del")) + enable_disable = 0; + else + break; + } + + if (address_set == 0) + { + errmsg ("missing addresses"); + return -99; + } + + M (WANT_IP6_ND_EVENTS, want_ip6_nd_events); + mp->enable_disable = enable_disable; + mp->pid = getpid (); + clib_memcpy (mp->address, &address, sizeof (ip6_address_t)); + + S; + W; +} + +static int +api_input_acl_set_interface (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + vl_api_input_acl_set_interface_t *mp; + f64 timeout; + u32 sw_if_index; + int sw_if_index_set; + u32 ip4_table_index = ~0; + u32 ip6_table_index = ~0; + u32 l2_table_index = ~0; + u8 is_add = 1; + + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index)) + sw_if_index_set = 1; + else if (unformat (i, "sw_if_index %d", &sw_if_index)) + sw_if_index_set = 1; + else if (unformat (i, "del")) + is_add = 0; + else if (unformat (i, "ip4-table %d", &ip4_table_index)) + ; + else if (unformat (i, "ip6-table %d", &ip6_table_index)) + ; + else if (unformat (i, "l2-table %d", &l2_table_index)) + ; + else + { + clib_warning ("parse error '%U'", format_unformat_error, i); + return -99; + } + } + + if (sw_if_index_set == 0) + { + errmsg ("missing interface name or sw_if_index"); + return -99; + } + + M (INPUT_ACL_SET_INTERFACE, input_acl_set_interface); + + mp->sw_if_index = ntohl (sw_if_index); + mp->ip4_table_index = ntohl (ip4_table_index); + mp->ip6_table_index = ntohl (ip6_table_index); + mp->l2_table_index = ntohl (l2_table_index); + mp->is_add = is_add; + + S; + W; + /* NOTREACHED */ + return 0; +} + +static int +api_ip_address_dump (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + vl_api_ip_address_dump_t *mp; + u32 sw_if_index = ~0; + u8 sw_if_index_set = 0; + u8 ipv4_set = 0; + u8 ipv6_set = 0; + f64 timeout; + + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "sw_if_index %d", &sw_if_index)) + sw_if_index_set = 1; + else + if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index)) + sw_if_index_set = 1; + else if (unformat (i, "ipv4")) + ipv4_set = 1; + else if (unformat (i, "ipv6")) + ipv6_set = 1; + else + break; + } + + if (ipv4_set && ipv6_set) + { + errmsg ("ipv4 and ipv6 flags cannot be both set"); + return -99; + } + + if ((!ipv4_set) && (!ipv6_set)) + { + errmsg ("no ipv4 nor ipv6 flag set"); + return -99; + } + + if (sw_if_index_set == 0) + { + errmsg ("missing interface name or sw_if_index"); + return -99; + } + + vam->current_sw_if_index = sw_if_index; + vam->is_ipv6 = ipv6_set; + + M (IP_ADDRESS_DUMP, ip_address_dump); + mp->sw_if_index = ntohl (sw_if_index); + mp->is_ipv6 = ipv6_set; + S; + + /* Use a control ping for synchronization */ + { + vl_api_control_ping_t *mp; + M (CONTROL_PING, control_ping); + S; + } + W; +} + +static int +api_ip_dump (vat_main_t * vam) +{ + vl_api_ip_dump_t *mp; + unformat_input_t *in = vam->input; + int ipv4_set = 0; + int ipv6_set = 0; + int is_ipv6; + f64 timeout; + int i; + + while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT) + { + if (unformat (in, "ipv4")) + ipv4_set = 1; + else if (unformat (in, "ipv6")) + ipv6_set = 1; + else + break; + } + + if (ipv4_set && ipv6_set) + { + errmsg ("ipv4 and ipv6 flags cannot be both set"); + return -99; + } + + if ((!ipv4_set) && (!ipv6_set)) + { + errmsg ("no ipv4 nor ipv6 flag set"); + return -99; + } + + is_ipv6 = ipv6_set; + vam->is_ipv6 = is_ipv6; + + /* free old data */ + for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++) + { + vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr); + } + vec_free (vam->ip_details_by_sw_if_index[is_ipv6]); + + M (IP_DUMP, ip_dump); + mp->is_ipv6 = ipv6_set; + S; + + /* Use a control ping for synchronization */ + { + vl_api_control_ping_t *mp; + M (CONTROL_PING, control_ping); + S; + } + W; +} + +static int +api_ipsec_spd_add_del (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + vl_api_ipsec_spd_add_del_t *mp; + f64 timeout; + u32 spd_id = ~0; + u8 is_add = 1; + + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "spd_id %d", &spd_id)) + ; + else if (unformat (i, "del")) + is_add = 0; + else + { + clib_warning ("parse error '%U'", format_unformat_error, i); + return -99; + } + } + if (spd_id == ~0) + { + errmsg ("spd_id must be set"); + return -99; + } + + M (IPSEC_SPD_ADD_DEL, ipsec_spd_add_del); + + mp->spd_id = ntohl (spd_id); + mp->is_add = is_add; + + S; + W; + /* NOTREACHED */ + return 0; +} + +static int +api_ipsec_interface_add_del_spd (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + vl_api_ipsec_interface_add_del_spd_t *mp; + f64 timeout; + u32 sw_if_index; + u8 sw_if_index_set = 0; + u32 spd_id = (u32) ~ 0; + u8 is_add = 1; + + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "del")) + is_add = 0; + else if (unformat (i, "spd_id %d", &spd_id)) + ; + else + if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index)) + sw_if_index_set = 1; + else if (unformat (i, "sw_if_index %d", &sw_if_index)) + sw_if_index_set = 1; + else + { + clib_warning ("parse error '%U'", format_unformat_error, i); + return -99; + } + + } + + if (spd_id == (u32) ~ 0) + { + errmsg ("spd_id must be set"); + return -99; + } + + if (sw_if_index_set == 0) + { + errmsg ("missing interface name or sw_if_index"); + return -99; + } + + M (IPSEC_INTERFACE_ADD_DEL_SPD, ipsec_interface_add_del_spd); + + mp->spd_id = ntohl (spd_id); + mp->sw_if_index = ntohl (sw_if_index); + mp->is_add = is_add; + + S; + W; + /* NOTREACHED */ + return 0; +} + +static int +api_ipsec_spd_add_del_entry (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + vl_api_ipsec_spd_add_del_entry_t *mp; + f64 timeout; + u8 is_add = 1, is_outbound = 0, is_ipv6 = 0, is_ip_any = 1; + u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0; + i32 priority = 0; + u32 rport_start = 0, rport_stop = (u32) ~ 0; + u32 lport_start = 0, lport_stop = (u32) ~ 0; + ip4_address_t laddr4_start, laddr4_stop, raddr4_start, raddr4_stop; + ip6_address_t laddr6_start, laddr6_stop, raddr6_start, raddr6_stop; + + laddr4_start.as_u32 = raddr4_start.as_u32 = 0; + laddr4_stop.as_u32 = raddr4_stop.as_u32 = (u32) ~ 0; + laddr6_start.as_u64[0] = raddr6_start.as_u64[0] = 0; + laddr6_start.as_u64[1] = raddr6_start.as_u64[1] = 0; + laddr6_stop.as_u64[0] = raddr6_stop.as_u64[0] = (u64) ~ 0; + laddr6_stop.as_u64[1] = raddr6_stop.as_u64[1] = (u64) ~ 0; + + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "del")) + is_add = 0; + if (unformat (i, "outbound")) + is_outbound = 1; + if (unformat (i, "inbound")) + is_outbound = 0; + else if (unformat (i, "spd_id %d", &spd_id)) + ; + else if (unformat (i, "sa_id %d", &sa_id)) + ; + else if (unformat (i, "priority %d", &priority)) + ; + else if (unformat (i, "protocol %d", &protocol)) + ; + else if (unformat (i, "lport_start %d", &lport_start)) + ; + else if (unformat (i, "lport_stop %d", &lport_stop)) + ; + else if (unformat (i, "rport_start %d", &rport_start)) + ; + else if (unformat (i, "rport_stop %d", &rport_stop)) + ; + else + if (unformat + (i, "laddr_start %U", unformat_ip4_address, &laddr4_start)) + { + is_ipv6 = 0; + is_ip_any = 0; + } + else + if (unformat (i, "laddr_stop %U", unformat_ip4_address, &laddr4_stop)) + { + is_ipv6 = 0; + is_ip_any = 0; + } + else + if (unformat + (i, "raddr_start %U", unformat_ip4_address, &raddr4_start)) + { + is_ipv6 = 0; + is_ip_any = 0; + } + else + if (unformat (i, "raddr_stop %U", unformat_ip4_address, &raddr4_stop)) + { + is_ipv6 = 0; + is_ip_any = 0; + } + else + if (unformat + (i, "laddr_start %U", unformat_ip6_address, &laddr6_start)) + { + is_ipv6 = 1; + is_ip_any = 0; + } + else + if (unformat (i, "laddr_stop %U", unformat_ip6_address, &laddr6_stop)) + { + is_ipv6 = 1; + is_ip_any = 0; + } + else + if (unformat + (i, "raddr_start %U", unformat_ip6_address, &raddr6_start)) + { + is_ipv6 = 1; + is_ip_any = 0; + } + else + if (unformat (i, "raddr_stop %U", unformat_ip6_address, &raddr6_stop)) + { + is_ipv6 = 1; + is_ip_any = 0; + } + else + if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy)) + { + if (policy == IPSEC_POLICY_ACTION_RESOLVE) + { + clib_warning ("unsupported action: 'resolve'"); + return -99; + } + } + else + { + clib_warning ("parse error '%U'", format_unformat_error, i); + return -99; + } + + } + + M (IPSEC_SPD_ADD_DEL_ENTRY, ipsec_spd_add_del_entry); + + mp->spd_id = ntohl (spd_id); + mp->priority = ntohl (priority); + mp->is_outbound = is_outbound; + + mp->is_ipv6 = is_ipv6; + if (is_ipv6 || is_ip_any) + { + clib_memcpy (mp->remote_address_start, &raddr6_start, + sizeof (ip6_address_t)); + clib_memcpy (mp->remote_address_stop, &raddr6_stop, + sizeof (ip6_address_t)); + clib_memcpy (mp->local_address_start, &laddr6_start, + sizeof (ip6_address_t)); + clib_memcpy (mp->local_address_stop, &laddr6_stop, + sizeof (ip6_address_t)); + } + else + { + clib_memcpy (mp->remote_address_start, &raddr4_start, + sizeof (ip4_address_t)); + clib_memcpy (mp->remote_address_stop, &raddr4_stop, + sizeof (ip4_address_t)); + clib_memcpy (mp->local_address_start, &laddr4_start, + sizeof (ip4_address_t)); + clib_memcpy (mp->local_address_stop, &laddr4_stop, + sizeof (ip4_address_t)); + } + mp->protocol = (u8) protocol; + mp->local_port_start = ntohs ((u16) lport_start); + mp->local_port_stop = ntohs ((u16) lport_stop); + mp->remote_port_start = ntohs ((u16) rport_start); + mp->remote_port_stop = ntohs ((u16) rport_stop); + mp->policy = (u8) policy; + mp->sa_id = ntohl (sa_id); + mp->is_add = is_add; + mp->is_ip_any = is_ip_any; + S; + W; + /* NOTREACHED */ + return 0; +} + +static int +api_ipsec_sad_add_del_entry (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + vl_api_ipsec_sad_add_del_entry_t *mp; + f64 timeout; + u32 sad_id = 0, spi = 0; + u8 *ck = 0, *ik = 0; + u8 is_add = 1; + + u8 protocol = IPSEC_PROTOCOL_AH; + u8 is_tunnel = 0, is_tunnel_ipv6 = 0; + u32 crypto_alg = 0, integ_alg = 0; + ip4_address_t tun_src4; + ip4_address_t tun_dst4; + ip6_address_t tun_src6; + ip6_address_t tun_dst6; + + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "del")) + is_add = 0; + else if (unformat (i, "sad_id %d", &sad_id)) + ; + else if (unformat (i, "spi %d", &spi)) + ; + else if (unformat (i, "esp")) + protocol = IPSEC_PROTOCOL_ESP; + else if (unformat (i, "tunnel_src %U", unformat_ip4_address, &tun_src4)) + { + is_tunnel = 1; + is_tunnel_ipv6 = 0; + } + else if (unformat (i, "tunnel_dst %U", unformat_ip4_address, &tun_dst4)) + { + is_tunnel = 1; + is_tunnel_ipv6 = 0; + } + else if (unformat (i, "tunnel_src %U", unformat_ip6_address, &tun_src6)) + { + is_tunnel = 1; + is_tunnel_ipv6 = 1; + } + else if (unformat (i, "tunnel_dst %U", unformat_ip6_address, &tun_dst6)) + { + is_tunnel = 1; + is_tunnel_ipv6 = 1; + } + else + if (unformat + (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg)) + { + if (crypto_alg < IPSEC_CRYPTO_ALG_AES_CBC_128 || + crypto_alg >= IPSEC_CRYPTO_N_ALG) + { + clib_warning ("unsupported crypto-alg: '%U'", + format_ipsec_crypto_alg, crypto_alg); + return -99; + } + } + else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck)) + ; + else + if (unformat + (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg)) + { +#if DPDK_CRYPTO==1 + if (integ_alg < IPSEC_INTEG_ALG_NONE || +#else + if (integ_alg < IPSEC_INTEG_ALG_SHA1_96 || +#endif + integ_alg >= IPSEC_INTEG_N_ALG) + { + clib_warning ("unsupported integ-alg: '%U'", + format_ipsec_integ_alg, integ_alg); + return -99; + } + } + else if (unformat (i, "integ_key %U", unformat_hex_string, &ik)) + ; + else + { + clib_warning ("parse error '%U'", format_unformat_error, i); + return -99; + } + + } + +#if DPDK_CRYPTO==1 + /*Special cases, aes-gcm-128 encryption */ + if (crypto_alg == IPSEC_CRYPTO_ALG_AES_GCM_128) + { + if (integ_alg != IPSEC_INTEG_ALG_NONE + && integ_alg != IPSEC_INTEG_ALG_AES_GCM_128) + { + clib_warning + ("unsupported: aes-gcm-128 crypto-alg needs none as integ-alg"); + return -99; + } + else /*set integ-alg internally to aes-gcm-128 */ + integ_alg = IPSEC_INTEG_ALG_AES_GCM_128; + } + else if (integ_alg == IPSEC_INTEG_ALG_AES_GCM_128) + { + clib_warning ("unsupported integ-alg: aes-gcm-128"); + return -99; + } + else if (integ_alg == IPSEC_INTEG_ALG_NONE) + { + clib_warning ("unsupported integ-alg: none"); + return -99; + } +#endif + + + M (IPSEC_SAD_ADD_DEL_ENTRY, ipsec_sad_add_del_entry); + + mp->sad_id = ntohl (sad_id); + mp->is_add = is_add; + mp->protocol = protocol; + mp->spi = ntohl (spi); + mp->is_tunnel = is_tunnel; + mp->is_tunnel_ipv6 = is_tunnel_ipv6; + mp->crypto_algorithm = crypto_alg; + mp->integrity_algorithm = integ_alg; + mp->crypto_key_length = vec_len (ck); + mp->integrity_key_length = vec_len (ik); + + if (mp->crypto_key_length > sizeof (mp->crypto_key)) + mp->crypto_key_length = sizeof (mp->crypto_key); + + if (mp->integrity_key_length > sizeof (mp->integrity_key)) + mp->integrity_key_length = sizeof (mp->integrity_key); + + if (ck) + clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length); + if (ik) + clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length); + + if (is_tunnel) + { + if (is_tunnel_ipv6) + { + clib_memcpy (mp->tunnel_src_address, &tun_src6, + sizeof (ip6_address_t)); + clib_memcpy (mp->tunnel_dst_address, &tun_dst6, + sizeof (ip6_address_t)); + } + else + { + clib_memcpy (mp->tunnel_src_address, &tun_src4, + sizeof (ip4_address_t)); + clib_memcpy (mp->tunnel_dst_address, &tun_dst4, + sizeof (ip4_address_t)); + } + } + + S; + W; + /* NOTREACHED */ + return 0; +} + +static int +api_ipsec_sa_set_key (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + vl_api_ipsec_sa_set_key_t *mp; + f64 timeout; + u32 sa_id; + u8 *ck = 0, *ik = 0; + + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "sa_id %d", &sa_id)) + ; + else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck)) + ; + else if (unformat (i, "integ_key %U", unformat_hex_string, &ik)) + ; + else + { + clib_warning ("parse error '%U'", format_unformat_error, i); + return -99; + } + } + + M (IPSEC_SA_SET_KEY, ipsec_set_sa_key); + + mp->sa_id = ntohl (sa_id); + mp->crypto_key_length = vec_len (ck); + mp->integrity_key_length = vec_len (ik); + + if (mp->crypto_key_length > sizeof (mp->crypto_key)) + mp->crypto_key_length = sizeof (mp->crypto_key); + + if (mp->integrity_key_length > sizeof (mp->integrity_key)) + mp->integrity_key_length = sizeof (mp->integrity_key); + + if (ck) + clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length); + if (ik) + clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length); + + S; + W; + /* NOTREACHED */ + return 0; +} + +static int +api_ikev2_profile_add_del (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + vl_api_ikev2_profile_add_del_t *mp; + f64 timeout; + u8 is_add = 1; + u8 *name = 0; + + const char *valid_chars = "a-zA-Z0-9_"; + + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "del")) + is_add = 0; + else if (unformat (i, "name %U", unformat_token, valid_chars, &name)) + vec_add1 (name, 0); + else + { + errmsg ("parse error '%U'", format_unformat_error, i); + return -99; + } + } + + if (!vec_len (name)) + { + errmsg ("profile name must be specified"); + return -99; + } + + if (vec_len (name) > 64) + { + errmsg ("profile name too long"); + return -99; + } + + M (IKEV2_PROFILE_ADD_DEL, ikev2_profile_add_del); + + clib_memcpy (mp->name, name, vec_len (name)); + mp->is_add = is_add; + vec_free (name); + + S; + W; + /* NOTREACHED */ + return 0; +} + +static int +api_ikev2_profile_set_auth (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + vl_api_ikev2_profile_set_auth_t *mp; + f64 timeout; + u8 *name = 0; + u8 *data = 0; + u32 auth_method = 0; + u8 is_hex = 0; + + const char *valid_chars = "a-zA-Z0-9_"; + + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "name %U", unformat_token, valid_chars, &name)) + vec_add1 (name, 0); + else if (unformat (i, "auth_method %U", + unformat_ikev2_auth_method, &auth_method)) + ; + else if (unformat (i, "auth_data 0x%U", unformat_hex_string, &data)) + is_hex = 1; + else if (unformat (i, "auth_data %v", &data)) + ; + else + { + errmsg ("parse error '%U'", format_unformat_error, i); + return -99; + } + } + + if (!vec_len (name)) + { + errmsg ("profile name must be specified"); + return -99; + } + + if (vec_len (name) > 64) + { + errmsg ("profile name too long"); + return -99; + } + + if (!vec_len (data)) + { + errmsg ("auth_data must be specified"); + return -99; + } + + if (!auth_method) + { + errmsg ("auth_method must be specified"); + return -99; + } + + M (IKEV2_PROFILE_SET_AUTH, ikev2_profile_set_auth); + + mp->is_hex = is_hex; + mp->auth_method = (u8) auth_method; + mp->data_len = vec_len (data); + clib_memcpy (mp->name, name, vec_len (name)); + clib_memcpy (mp->data, data, vec_len (data)); + vec_free (name); + vec_free (data); + + S; + W; + /* NOTREACHED */ + return 0; +} + +static int +api_ikev2_profile_set_id (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + vl_api_ikev2_profile_set_id_t *mp; + f64 timeout; + u8 *name = 0; + u8 *data = 0; + u8 is_local = 0; + u32 id_type = 0; + ip4_address_t ip4; + + const char *valid_chars = "a-zA-Z0-9_"; + + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "name %U", unformat_token, valid_chars, &name)) + vec_add1 (name, 0); + else if (unformat (i, "id_type %U", unformat_ikev2_id_type, &id_type)) + ; + else if (unformat (i, "id_data %U", unformat_ip4_address, &ip4)) + { + data = vec_new (u8, 4); + clib_memcpy (data, ip4.as_u8, 4); + } + else if (unformat (i, "id_data 0x%U", unformat_hex_string, &data)) + ; + else if (unformat (i, "id_data %v", &data)) + ; + else if (unformat (i, "local")) + is_local = 1; + else if (unformat (i, "remote")) + is_local = 0; + else + { + errmsg ("parse error '%U'", format_unformat_error, i); + return -99; + } + } + + if (!vec_len (name)) + { + errmsg ("profile name must be specified"); + return -99; + } + + if (vec_len (name) > 64) + { + errmsg ("profile name too long"); + return -99; + } + + if (!vec_len (data)) + { + errmsg ("id_data must be specified"); + return -99; + } + + if (!id_type) + { + errmsg ("id_type must be specified"); + return -99; + } + + M (IKEV2_PROFILE_SET_ID, ikev2_profile_set_id); + + mp->is_local = is_local; + mp->id_type = (u8) id_type; + mp->data_len = vec_len (data); + clib_memcpy (mp->name, name, vec_len (name)); + clib_memcpy (mp->data, data, vec_len (data)); + vec_free (name); + vec_free (data); + + S; + W; + /* NOTREACHED */ + return 0; +} + +static int +api_ikev2_profile_set_ts (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + vl_api_ikev2_profile_set_ts_t *mp; + f64 timeout; + u8 *name = 0; + u8 is_local = 0; + u32 proto = 0, start_port = 0, end_port = (u32) ~ 0; + ip4_address_t start_addr, end_addr; + + const char *valid_chars = "a-zA-Z0-9_"; + + start_addr.as_u32 = 0; + end_addr.as_u32 = (u32) ~ 0; + + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "name %U", unformat_token, valid_chars, &name)) + vec_add1 (name, 0); + else if (unformat (i, "protocol %d", &proto)) + ; + else if (unformat (i, "start_port %d", &start_port)) + ; + else if (unformat (i, "end_port %d", &end_port)) + ; + else + if (unformat (i, "start_addr %U", unformat_ip4_address, &start_addr)) + ; + else if (unformat (i, "end_addr %U", unformat_ip4_address, &end_addr)) + ; + else if (unformat (i, "local")) + is_local = 1; + else if (unformat (i, "remote")) + is_local = 0; + else + { + errmsg ("parse error '%U'", format_unformat_error, i); + return -99; + } + } + + if (!vec_len (name)) + { + errmsg ("profile name must be specified"); + return -99; + } + + if (vec_len (name) > 64) + { + errmsg ("profile name too long"); + return -99; + } + + M (IKEV2_PROFILE_SET_TS, ikev2_profile_set_ts); + + mp->is_local = is_local; + mp->proto = (u8) proto; + mp->start_port = (u16) start_port; + mp->end_port = (u16) end_port; + mp->start_addr = start_addr.as_u32; + mp->end_addr = end_addr.as_u32; + clib_memcpy (mp->name, name, vec_len (name)); + vec_free (name); + + S; + W; + /* NOTREACHED */ + return 0; +} + +static int +api_ikev2_set_local_key (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + vl_api_ikev2_set_local_key_t *mp; + f64 timeout; + u8 *file = 0; + + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "file %v", &file)) + vec_add1 (file, 0); + else + { + errmsg ("parse error '%U'", format_unformat_error, i); + return -99; + } + } + + if (!vec_len (file)) + { + errmsg ("RSA key file must be specified"); + return -99; + } + + if (vec_len (file) > 256) + { + errmsg ("file name too long"); + return -99; + } + + M (IKEV2_SET_LOCAL_KEY, ikev2_set_local_key); + + clib_memcpy (mp->key_file, file, vec_len (file)); + vec_free (file); + + S; + W; + /* NOTREACHED */ + return 0; +} + +/* + * MAP + */ +static int +api_map_add_domain (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + vl_api_map_add_domain_t *mp; + f64 timeout; + + ip4_address_t ip4_prefix; + ip6_address_t ip6_prefix; + ip6_address_t ip6_src; + u32 num_m_args = 0; + u32 ip6_prefix_len = 0, ip4_prefix_len = 0, ea_bits_len = 0, psid_offset = + 0, psid_length = 0; + u8 is_translation = 0; + u32 mtu = 0; + u32 ip6_src_len = 128; + + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "ip4-pfx %U/%d", unformat_ip4_address, + &ip4_prefix, &ip4_prefix_len)) + num_m_args++; + else if (unformat (i, "ip6-pfx %U/%d", unformat_ip6_address, + &ip6_prefix, &ip6_prefix_len)) + num_m_args++; + else + if (unformat + (i, "ip6-src %U/%d", unformat_ip6_address, &ip6_src, + &ip6_src_len)) + num_m_args++; + else if (unformat (i, "ip6-src %U", unformat_ip6_address, &ip6_src)) + num_m_args++; + else if (unformat (i, "ea-bits-len %d", &ea_bits_len)) + num_m_args++; + else if (unformat (i, "psid-offset %d", &psid_offset)) + num_m_args++; + else if (unformat (i, "psid-len %d", &psid_length)) + num_m_args++; + else if (unformat (i, "mtu %d", &mtu)) + num_m_args++; + else if (unformat (i, "map-t")) + is_translation = 1; + else + { + clib_warning ("parse error '%U'", format_unformat_error, i); + return -99; + } + } + + if (num_m_args < 3) + { + errmsg ("mandatory argument(s) missing"); + return -99; + } + + /* Construct the API message */ + M (MAP_ADD_DOMAIN, map_add_domain); + + clib_memcpy (mp->ip4_prefix, &ip4_prefix, sizeof (ip4_prefix)); + mp->ip4_prefix_len = ip4_prefix_len; + + clib_memcpy (mp->ip6_prefix, &ip6_prefix, sizeof (ip6_prefix)); + mp->ip6_prefix_len = ip6_prefix_len; + + clib_memcpy (mp->ip6_src, &ip6_src, sizeof (ip6_src)); + mp->ip6_src_prefix_len = ip6_src_len; + + mp->ea_bits_len = ea_bits_len; + mp->psid_offset = psid_offset; + mp->psid_length = psid_length; + mp->is_translation = is_translation; + mp->mtu = htons (mtu); + + /* send it... */ + S; + + /* Wait for a reply, return good/bad news */ + W; +} + +static int +api_map_del_domain (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + vl_api_map_del_domain_t *mp; + f64 timeout; + + u32 num_m_args = 0; + u32 index; + + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "index %d", &index)) + num_m_args++; + else + { + clib_warning ("parse error '%U'", format_unformat_error, i); + return -99; + } + } + + if (num_m_args != 1) + { + errmsg ("mandatory argument(s) missing"); + return -99; + } + + /* Construct the API message */ + M (MAP_DEL_DOMAIN, map_del_domain); + + mp->index = ntohl (index); + + /* send it... */ + S; + + /* Wait for a reply, return good/bad news */ + W; +} + +static int +api_map_add_del_rule (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + vl_api_map_add_del_rule_t *mp; + f64 timeout; + u8 is_add = 1; + ip6_address_t ip6_dst; + u32 num_m_args = 0, index, psid = 0; + + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "index %d", &index)) + num_m_args++; + else if (unformat (i, "psid %d", &psid)) + num_m_args++; + else if (unformat (i, "dst %U", unformat_ip6_address, &ip6_dst)) + num_m_args++; + else if (unformat (i, "del")) + { + is_add = 0; + } + else + { + clib_warning ("parse error '%U'", format_unformat_error, i); + return -99; + } + } + + /* Construct the API message */ + M (MAP_ADD_DEL_RULE, map_add_del_rule); + + mp->index = ntohl (index); + mp->is_add = is_add; + clib_memcpy (mp->ip6_dst, &ip6_dst, sizeof (ip6_dst)); + mp->psid = ntohs (psid); + + /* send it... */ + S; + + /* Wait for a reply, return good/bad news */ + W; +} + +static int +api_map_domain_dump (vat_main_t * vam) +{ + vl_api_map_domain_dump_t *mp; + f64 timeout; + + /* Construct the API message */ + M (MAP_DOMAIN_DUMP, map_domain_dump); + + /* send it... */ + S; + + /* Use a control ping for synchronization */ + { + vl_api_control_ping_t *mp; + M (CONTROL_PING, control_ping); + S; + } + W; +} + +static int +api_map_rule_dump (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + vl_api_map_rule_dump_t *mp; + f64 timeout; + u32 domain_index = ~0; + + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "index %u", &domain_index)) + ; + else + break; + } + + if (domain_index == ~0) + { + clib_warning ("parse error: domain index expected"); + return -99; + } + + /* Construct the API message */ + M (MAP_RULE_DUMP, map_rule_dump); + + mp->domain_index = htonl (domain_index); + + /* send it... */ + S; + + /* Use a control ping for synchronization */ + { + vl_api_control_ping_t *mp; + M (CONTROL_PING, control_ping); + S; + } + W; +} + +static void vl_api_map_add_domain_reply_t_handler + (vl_api_map_add_domain_reply_t * mp) +{ + vat_main_t *vam = &vat_main; + i32 retval = ntohl (mp->retval); + + if (vam->async_mode) + { + vam->async_errors += (retval < 0); + } + else + { + vam->retval = retval; + vam->result_ready = 1; + } +} + +static void vl_api_map_add_domain_reply_t_handler_json + (vl_api_map_add_domain_reply_t * mp) +{ + vat_main_t *vam = &vat_main; + vat_json_node_t node; + + vat_json_init_object (&node); + vat_json_object_add_int (&node, "retval", ntohl (mp->retval)); + vat_json_object_add_uint (&node, "index", ntohl (mp->index)); + + vat_json_print (vam->ofp, &node); + vat_json_free (&node); + + vam->retval = ntohl (mp->retval); + vam->result_ready = 1; +} + +static int +api_get_first_msg_id (vat_main_t * vam) +{ + vl_api_get_first_msg_id_t *mp; + f64 timeout; + unformat_input_t *i = vam->input; + u8 *name; + u8 name_set = 0; + + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "client %s", &name)) + name_set = 1; + else + break; + } + + if (name_set == 0) + { + errmsg ("missing client name"); + return -99; + } + vec_add1 (name, 0); + + if (vec_len (name) > 63) + { + errmsg ("client name too long"); + return -99; + } + + M (GET_FIRST_MSG_ID, get_first_msg_id); + clib_memcpy (mp->name, name, vec_len (name)); + S; + W; + /* NOTREACHED */ + return 0; +} + +static int +api_cop_interface_enable_disable (vat_main_t * vam) +{ + unformat_input_t *line_input = vam->input; + vl_api_cop_interface_enable_disable_t *mp; + f64 timeout; + u32 sw_if_index = ~0; + u8 enable_disable = 1; + + while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) + { + if (unformat (line_input, "disable")) + enable_disable = 0; + if (unformat (line_input, "enable")) + enable_disable = 1; + else if (unformat (line_input, "%U", api_unformat_sw_if_index, + vam, &sw_if_index)) + ; + else if (unformat (line_input, "sw_if_index %d", &sw_if_index)) + ; + else + break; + } + + if (sw_if_index == ~0) + { + errmsg ("missing interface name or sw_if_index"); + return -99; + } + + /* Construct the API message */ + M (COP_INTERFACE_ENABLE_DISABLE, cop_interface_enable_disable); + mp->sw_if_index = ntohl (sw_if_index); + mp->enable_disable = enable_disable; + + /* send it... */ + S; + /* Wait for the reply */ + W; +} + +static int +api_cop_whitelist_enable_disable (vat_main_t * vam) +{ + unformat_input_t *line_input = vam->input; + vl_api_cop_whitelist_enable_disable_t *mp; + f64 timeout; + u32 sw_if_index = ~0; + u8 ip4 = 0, ip6 = 0, default_cop = 0; + u32 fib_id = 0; + + while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) + { + if (unformat (line_input, "ip4")) + ip4 = 1; + else if (unformat (line_input, "ip6")) + ip6 = 1; + else if (unformat (line_input, "default")) + default_cop = 1; + else if (unformat (line_input, "%U", api_unformat_sw_if_index, + vam, &sw_if_index)) + ; + else if (unformat (line_input, "sw_if_index %d", &sw_if_index)) + ; + else if (unformat (line_input, "fib-id %d", &fib_id)) + ; + else + break; + } + + if (sw_if_index == ~0) + { + errmsg ("missing interface name or sw_if_index"); + return -99; + } + + /* Construct the API message */ + M (COP_WHITELIST_ENABLE_DISABLE, cop_whitelist_enable_disable); + mp->sw_if_index = ntohl (sw_if_index); + mp->fib_id = ntohl (fib_id); + mp->ip4 = ip4; + mp->ip6 = ip6; + mp->default_cop = default_cop; + + /* send it... */ + S; + /* Wait for the reply */ + W; +} + +static int +api_get_node_graph (vat_main_t * vam) +{ + vl_api_get_node_graph_t *mp; + f64 timeout; + + M (GET_NODE_GRAPH, get_node_graph); + + /* send it... */ + S; + /* Wait for the reply */ + W; +} + +/* *INDENT-OFF* */ +/** Used for parsing LISP eids */ +typedef CLIB_PACKED(struct{ + u8 addr[16]; /**< eid address */ + u32 len; /**< prefix length if IP */ + u8 type; /**< type of eid */ +}) lisp_eid_vat_t; +/* *INDENT-ON* */ + +static uword +unformat_lisp_eid_vat (unformat_input_t * input, va_list * args) +{ + lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *); + + memset (a, 0, sizeof (a[0])); + + if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len)) + { + a->type = 0; /* ipv4 type */ + } + else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len)) + { + a->type = 1; /* ipv6 type */ + } + else if (unformat (input, "%U", unformat_ethernet_address, a->addr)) + { + a->type = 2; /* mac type */ + } + else + { + return 0; + } + + if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128)) + { + return 0; + } + + return 1; +} + +static int +lisp_eid_size_vat (u8 type) +{ + switch (type) + { + case 0: + return 4; + case 1: + return 16; + case 2: + return 6; + } + return 0; +} + +static void +lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type) +{ + clib_memcpy (dst, eid, lisp_eid_size_vat (type)); +} + +/* *INDENT-OFF* */ +/** Used for transferring locators via VPP API */ +typedef CLIB_PACKED(struct +{ + u32 sw_if_index; /**< locator sw_if_index */ + u8 priority; /**< locator priority */ + u8 weight; /**< locator weight */ +}) ls_locator_t; +/* *INDENT-ON* */ + +static int +api_lisp_add_del_locator_set (vat_main_t * vam) +{ + unformat_input_t *input = vam->input; + vl_api_lisp_add_del_locator_set_t *mp; + f64 timeout = ~0; + u8 is_add = 1; + u8 *locator_set_name = NULL; + u8 locator_set_name_set = 0; + ls_locator_t locator, *locators = 0; + u32 sw_if_index, priority, weight; + u32 data_len = 0; + + /* Parse args required to build the message */ + while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) + { + if (unformat (input, "del")) + { + is_add = 0; + } + else if (unformat (input, "locator-set %s", &locator_set_name)) + { + locator_set_name_set = 1; + } + else if (unformat (input, "sw_if_index %u p %u w %u", + &sw_if_index, &priority, &weight)) + { + locator.sw_if_index = htonl (sw_if_index); + locator.priority = priority; + locator.weight = weight; + vec_add1 (locators, locator); + } + else + if (unformat + (input, "iface %U p %u w %u", api_unformat_sw_if_index, vam, + &sw_if_index, &priority, &weight)) + { + locator.sw_if_index = htonl (sw_if_index); + locator.priority = priority; + locator.weight = weight; + vec_add1 (locators, locator); + } + else + break; + } + + if (locator_set_name_set == 0) + { + errmsg ("missing locator-set name"); + vec_free (locators); + return -99; + } + + if (vec_len (locator_set_name) > 64) + { + errmsg ("locator-set name too long"); + vec_free (locator_set_name); + vec_free (locators); + return -99; + } + vec_add1 (locator_set_name, 0); + + data_len = sizeof (ls_locator_t) * vec_len (locators); + + /* Construct the API message */ + M2 (LISP_ADD_DEL_LOCATOR_SET, lisp_add_del_locator_set, data_len); + + mp->is_add = is_add; + clib_memcpy (mp->locator_set_name, locator_set_name, + vec_len (locator_set_name)); + vec_free (locator_set_name); + + mp->locator_num = clib_host_to_net_u32 (vec_len (locators)); + if (locators) + clib_memcpy (mp->locators, locators, data_len); + vec_free (locators); + + /* send it... */ + S; + + /* Wait for a reply... */ + W; + + /* NOTREACHED */ + return 0; +} + +static int +api_lisp_add_del_locator (vat_main_t * vam) +{ + unformat_input_t *input = vam->input; + vl_api_lisp_add_del_locator_t *mp; + f64 timeout = ~0; + u32 tmp_if_index = ~0; + u32 sw_if_index = ~0; + u8 sw_if_index_set = 0; + u8 sw_if_index_if_name_set = 0; + u32 priority = ~0; + u8 priority_set = 0; + u32 weight = ~0; + u8 weight_set = 0; + u8 is_add = 1; + u8 *locator_set_name = NULL; + u8 locator_set_name_set = 0; + + /* Parse args required to build the message */ + while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) + { + if (unformat (input, "del")) + { + is_add = 0; + } + else if (unformat (input, "locator-set %s", &locator_set_name)) + { + locator_set_name_set = 1; + } + else if (unformat (input, "iface %U", api_unformat_sw_if_index, vam, + &tmp_if_index)) + { + sw_if_index_if_name_set = 1; + sw_if_index = tmp_if_index; + } + else if (unformat (input, "sw_if_index %d", &tmp_if_index)) + { + sw_if_index_set = 1; + sw_if_index = tmp_if_index; + } + else if (unformat (input, "p %d", &priority)) + { + priority_set = 1; + } + else if (unformat (input, "w %d", &weight)) + { + weight_set = 1; + } + else + break; + } + + if (locator_set_name_set == 0) + { + errmsg ("missing locator-set name"); + return -99; + } + + if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0) + { + errmsg ("missing sw_if_index"); + vec_free (locator_set_name); + return -99; + } + + if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0) + { + errmsg ("cannot use both params interface name and sw_if_index"); + vec_free (locator_set_name); + return -99; + } + + if (priority_set == 0) + { + errmsg ("missing locator-set priority"); + vec_free (locator_set_name); + return -99; + } + + if (weight_set == 0) + { + errmsg ("missing locator-set weight"); + vec_free (locator_set_name); + return -99; + } + + if (vec_len (locator_set_name) > 64) + { + errmsg ("locator-set name too long"); + vec_free (locator_set_name); + return -99; + } + vec_add1 (locator_set_name, 0); + + /* Construct the API message */ + M (LISP_ADD_DEL_LOCATOR, lisp_add_del_locator); + + mp->is_add = is_add; + mp->sw_if_index = ntohl (sw_if_index); + mp->priority = priority; + mp->weight = weight; + clib_memcpy (mp->locator_set_name, locator_set_name, + vec_len (locator_set_name)); + vec_free (locator_set_name); + + /* send it... */ + S; + + /* Wait for a reply... */ + W; + + /* NOTREACHED */ + return 0; +} + +uword +unformat_hmac_key_id (unformat_input_t * input, va_list * args) +{ + u32 *key_id = va_arg (*args, u32 *); + u8 *s = 0; + + if (unformat (input, "%s", &s)) + { + if (!strcmp ((char *) s, "sha1")) + key_id[0] = HMAC_SHA_1_96; + else if (!strcmp ((char *) s, "sha256")) + key_id[0] = HMAC_SHA_256_128; + else + { + clib_warning ("invalid key_id: '%s'", s); + key_id[0] = HMAC_NO_KEY; + } + } + else + return 0; + + vec_free (s); + return 1; +} + +static int +api_lisp_add_del_local_eid (vat_main_t * vam) +{ + unformat_input_t *input = vam->input; + vl_api_lisp_add_del_local_eid_t *mp; + f64 timeout = ~0; + u8 is_add = 1; + u8 eid_set = 0; + lisp_eid_vat_t _eid, *eid = &_eid; + u8 *locator_set_name = 0; + u8 locator_set_name_set = 0; + u32 vni = 0; + u16 key_id = 0; + u8 *key = 0; + + /* Parse args required to build the message */ + while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) + { + if (unformat (input, "del")) + { + is_add = 0; + } + else if (unformat (input, "vni %d", &vni)) + { + ; + } + else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid)) + { + eid_set = 1; + } + else if (unformat (input, "locator-set %s", &locator_set_name)) + { + locator_set_name_set = 1; + } + else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id)) + ; + else if (unformat (input, "secret-key %_%v%_", &key)) + ; + else + break; + } + + if (locator_set_name_set == 0) + { + errmsg ("missing locator-set name"); + return -99; + } + + if (0 == eid_set) + { + errmsg ("EID address not set!"); + vec_free (locator_set_name); + return -99; + } + + if (key && (0 == key_id)) + { + errmsg ("invalid key_id!"); + return -99; + } + + if (vec_len (key) > 64) + { + errmsg ("key too long"); + vec_free (key); + return -99; + } + + if (vec_len (locator_set_name) > 64) + { + errmsg ("locator-set name too long"); + vec_free (locator_set_name); + return -99; + } + vec_add1 (locator_set_name, 0); + + /* Construct the API message */ + M (LISP_ADD_DEL_LOCAL_EID, lisp_add_del_local_eid); + + mp->is_add = is_add; + lisp_eid_put_vat (mp->eid, eid->addr, eid->type); + mp->eid_type = eid->type; + mp->prefix_len = eid->len; + mp->vni = clib_host_to_net_u32 (vni); + mp->key_id = clib_host_to_net_u16 (key_id); + clib_memcpy (mp->locator_set_name, locator_set_name, + vec_len (locator_set_name)); + clib_memcpy (mp->key, key, vec_len (key)); + + vec_free (locator_set_name); + vec_free (key); + + /* send it... */ + S; + + /* Wait for a reply... */ + W; + + /* NOTREACHED */ + return 0; +} + +/* *INDENT-OFF* */ +/** Used for transferring locators via VPP API */ +typedef CLIB_PACKED(struct +{ + u8 is_ip4; /**< is locator an IPv4 address? */ + u8 priority; /**< locator priority */ + u8 weight; /**< locator weight */ + u8 addr[16]; /**< IPv4/IPv6 address */ +}) rloc_t; +/* *INDENT-ON* */ + +static int +api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam) +{ + unformat_input_t *input = vam->input; + vl_api_lisp_gpe_add_del_fwd_entry_t *mp; + f64 timeout = ~0; + u8 is_add = 1; + lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid; + lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid; + u8 rmt_eid_set = 0, lcl_eid_set = 0; + u32 action = ~0, p, w; + ip4_address_t rmt_rloc4, lcl_rloc4; + ip6_address_t rmt_rloc6, lcl_rloc6; + rloc_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0; + + memset (&rloc, 0, sizeof (rloc)); + + /* Parse args required to build the message */ + while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) + { + if (unformat (input, "del")) + { + is_add = 0; + } + else if (unformat (input, "rmt_eid %U", unformat_lisp_eid_vat, rmt_eid)) + { + rmt_eid_set = 1; + } + else if (unformat (input, "lcl_eid %U", unformat_lisp_eid_vat, lcl_eid)) + { + lcl_eid_set = 1; + } + else if (unformat (input, "p %d w %d", &p, &w)) + { + if (!curr_rloc) + { + errmsg ("No RLOC configured for setting priority/weight!"); + return -99; + } + curr_rloc->priority = p; + curr_rloc->weight = w; + } + else if (unformat (input, "loc-pair %U %U", unformat_ip4_address, + &lcl_rloc4, unformat_ip4_address, &rmt_rloc4)) + { + rloc.is_ip4 = 1; + + clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4)); + rloc.priority = rloc.weight = 0; + vec_add1 (lcl_locs, rloc); + + clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4)); + vec_add1 (rmt_locs, rloc); + /* priority and weight saved in rmt loc */ + curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1]; + } + else if (unformat (input, "loc-pair %U %U", unformat_ip6_address, + &lcl_rloc6, unformat_ip6_address, &rmt_rloc6)) + { + rloc.is_ip4 = 0; + clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6)); + rloc.priority = rloc.weight = 0; + vec_add1 (lcl_locs, rloc); + + clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6)); + vec_add1 (rmt_locs, rloc); + /* priority and weight saved in rmt loc */ + curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1]; + } + else if (unformat (input, "action %d", &action)) + { + ; + } + else + { + clib_warning ("parse error '%U'", format_unformat_error, input); + return -99; + } + } + + if (!rmt_eid_set) + { + errmsg ("remote eid addresses not set"); + return -99; + } + + if (lcl_eid_set && rmt_eid->type != lcl_eid->type) + { + errmsg ("eid types don't match"); + return -99; + } + + if (0 == rmt_locs && (u32) ~ 0 == action) + { + errmsg ("action not set for negative mapping"); + return -99; + } + + /* Construct the API message */ + M (LISP_GPE_ADD_DEL_FWD_ENTRY, lisp_gpe_add_del_fwd_entry); + + mp->is_add = is_add; + lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type); + lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type); + mp->eid_type = rmt_eid->type; + mp->rmt_len = rmt_eid->len; + mp->lcl_len = lcl_eid->len; + mp->action = action; + + if (0 != rmt_locs && 0 != lcl_locs) + { + mp->loc_num = vec_len (rmt_locs); + clib_memcpy (mp->lcl_locs, lcl_locs, + (sizeof (rloc_t) * vec_len (lcl_locs))); + clib_memcpy (mp->rmt_locs, rmt_locs, + (sizeof (rloc_t) * vec_len (rmt_locs))); + } + vec_free (lcl_locs); + vec_free (rmt_locs); + + /* send it... */ + S; + + /* Wait for a reply... */ + W; + + /* NOTREACHED */ + return 0; +} + +static int +api_lisp_add_del_map_server (vat_main_t * vam) +{ + unformat_input_t *input = vam->input; + vl_api_lisp_add_del_map_server_t *mp; + f64 timeout = ~0; + u8 is_add = 1; + u8 ipv4_set = 0; + u8 ipv6_set = 0; + ip4_address_t ipv4; + ip6_address_t ipv6; + + /* Parse args required to build the message */ + while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) + { + if (unformat (input, "del")) + { + is_add = 0; + } + else if (unformat (input, "%U", unformat_ip4_address, &ipv4)) + { + ipv4_set = 1; + } + else if (unformat (input, "%U", unformat_ip6_address, &ipv6)) + { + ipv6_set = 1; + } + else + break; + } + + if (ipv4_set && ipv6_set) + { + errmsg ("both eid v4 and v6 addresses set"); + return -99; + } + + if (!ipv4_set && !ipv6_set) + { + errmsg ("eid addresses not set"); + return -99; + } + + /* Construct the API message */ + M (LISP_ADD_DEL_MAP_SERVER, lisp_add_del_map_server); + + mp->is_add = is_add; + if (ipv6_set) + { + mp->is_ipv6 = 1; + clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6)); + } + else + { + mp->is_ipv6 = 0; + clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4)); + } + + /* send it... */ + S; + + /* Wait for a reply... */ + W; + + /* NOTREACHED */ + return 0; +} + +static int +api_lisp_add_del_map_resolver (vat_main_t * vam) +{ + unformat_input_t *input = vam->input; + vl_api_lisp_add_del_map_resolver_t *mp; + f64 timeout = ~0; + u8 is_add = 1; + u8 ipv4_set = 0; + u8 ipv6_set = 0; + ip4_address_t ipv4; + ip6_address_t ipv6; + + /* Parse args required to build the message */ + while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) + { + if (unformat (input, "del")) + { + is_add = 0; + } + else if (unformat (input, "%U", unformat_ip4_address, &ipv4)) + { + ipv4_set = 1; + } + else if (unformat (input, "%U", unformat_ip6_address, &ipv6)) + { + ipv6_set = 1; + } + else + break; + } + + if (ipv4_set && ipv6_set) + { + errmsg ("both eid v4 and v6 addresses set"); + return -99; + } + + if (!ipv4_set && !ipv6_set) + { + errmsg ("eid addresses not set"); + return -99; + } + + /* Construct the API message */ + M (LISP_ADD_DEL_MAP_RESOLVER, lisp_add_del_map_resolver); + + mp->is_add = is_add; + if (ipv6_set) + { + mp->is_ipv6 = 1; + clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6)); + } + else + { + mp->is_ipv6 = 0; + clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4)); + } + + /* send it... */ + S; + + /* Wait for a reply... */ + W; + + /* NOTREACHED */ + return 0; +} + +static int +api_lisp_gpe_enable_disable (vat_main_t * vam) +{ + unformat_input_t *input = vam->input; + vl_api_lisp_gpe_enable_disable_t *mp; + f64 timeout = ~0; + u8 is_set = 0; + u8 is_en = 1; + + /* Parse args required to build the message */ + while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) + { + if (unformat (input, "enable")) + { + is_set = 1; + is_en = 1; + } + else if (unformat (input, "disable")) + { + is_set = 1; + is_en = 0; + } + else + break; + } + + if (is_set == 0) + { + errmsg ("Value not set"); + return -99; + } + + /* Construct the API message */ + M (LISP_GPE_ENABLE_DISABLE, lisp_gpe_enable_disable); + + mp->is_en = is_en; + + /* send it... */ + S; + + /* Wait for a reply... */ + W; + + /* NOTREACHED */ + return 0; +} + +static int +api_lisp_rloc_probe_enable_disable (vat_main_t * vam) +{ + unformat_input_t *input = vam->input; + vl_api_lisp_rloc_probe_enable_disable_t *mp; + f64 timeout = ~0; + u8 is_set = 0; + u8 is_en = 0; + + /* Parse args required to build the message */ + while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) + { + if (unformat (input, "enable")) + { + is_set = 1; + is_en = 1; + } + else if (unformat (input, "disable")) + is_set = 1; + else + break; + } + + if (!is_set) + { + errmsg ("Value not set"); + return -99; + } + + /* Construct the API message */ + M (LISP_RLOC_PROBE_ENABLE_DISABLE, lisp_rloc_probe_enable_disable); + + mp->is_enabled = is_en; + + /* send it... */ + S; + + /* Wait for a reply... */ + W; + + /* NOTREACHED */ + return 0; +} + +static int +api_lisp_map_register_enable_disable (vat_main_t * vam) +{ + unformat_input_t *input = vam->input; + vl_api_lisp_map_register_enable_disable_t *mp; + f64 timeout = ~0; + u8 is_set = 0; + u8 is_en = 0; + + /* Parse args required to build the message */ + while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) + { + if (unformat (input, "enable")) + { + is_set = 1; + is_en = 1; + } + else if (unformat (input, "disable")) + is_set = 1; + else + break; + } + + if (!is_set) + { + errmsg ("Value not set"); + return -99; + } + + /* Construct the API message */ + M (LISP_MAP_REGISTER_ENABLE_DISABLE, lisp_map_register_enable_disable); + + mp->is_enabled = is_en; + + /* send it... */ + S; + + /* Wait for a reply... */ + W; + + /* NOTREACHED */ + return 0; +} + +static int +api_lisp_enable_disable (vat_main_t * vam) +{ + unformat_input_t *input = vam->input; + vl_api_lisp_enable_disable_t *mp; + f64 timeout = ~0; + u8 is_set = 0; + u8 is_en = 0; + + /* Parse args required to build the message */ + while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) + { + if (unformat (input, "enable")) + { + is_set = 1; + is_en = 1; + } + else if (unformat (input, "disable")) + { + is_set = 1; + } + else + break; + } + + if (!is_set) + { + errmsg ("Value not set"); + return -99; + } + + /* Construct the API message */ + M (LISP_ENABLE_DISABLE, lisp_enable_disable); + + mp->is_en = is_en; + + /* send it... */ + S; + + /* Wait for a reply... */ + W; + + /* NOTREACHED */ + return 0; +} + +static int +api_show_lisp_map_register_state (vat_main_t * vam) +{ + f64 timeout = ~0; + vl_api_show_lisp_map_register_state_t *mp; + + M (SHOW_LISP_MAP_REGISTER_STATE, show_lisp_map_register_state); + + /* send */ + S; + + /* wait for reply */ + W; + + return 0; +} + +static int +api_show_lisp_rloc_probe_state (vat_main_t * vam) +{ + f64 timeout = ~0; + vl_api_show_lisp_rloc_probe_state_t *mp; + + M (SHOW_LISP_RLOC_PROBE_STATE, show_lisp_rloc_probe_state); + + /* send */ + S; + + /* wait for reply */ + W; + + return 0; +} + +static int +api_show_lisp_map_request_mode (vat_main_t * vam) +{ + f64 timeout = ~0; + vl_api_show_lisp_map_request_mode_t *mp; + + M (SHOW_LISP_MAP_REQUEST_MODE, show_lisp_map_request_mode); + + /* send */ + S; + + /* wait for reply */ + W; + + return 0; +} + +static int +api_lisp_map_request_mode (vat_main_t * vam) +{ + f64 timeout = ~0; + unformat_input_t *input = vam->input; + vl_api_lisp_map_request_mode_t *mp; + u8 mode = 0; + + /* Parse args required to build the message */ + while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) + { + if (unformat (input, "dst-only")) + mode = 0; + else if (unformat (input, "src-dst")) + mode = 1; + else + { + errmsg ("parse error '%U'", format_unformat_error, input); + return -99; + } + } + + M (LISP_MAP_REQUEST_MODE, lisp_map_request_mode); + + mp->mode = mode; + + /* send */ + S; + + /* wait for reply */ + W; + + /* notreached */ + return 0; +} + +/** + * Enable/disable LISP proxy ITR. + * + * @param vam vpp API test context + * @return return code + */ +static int +api_lisp_pitr_set_locator_set (vat_main_t * vam) +{ + f64 timeout = ~0; + u8 ls_name_set = 0; + unformat_input_t *input = vam->input; + vl_api_lisp_pitr_set_locator_set_t *mp; + u8 is_add = 1; + u8 *ls_name = 0; + + /* Parse args required to build the message */ + while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) + { + if (unformat (input, "del")) + is_add = 0; + else if (unformat (input, "locator-set %s", &ls_name)) + ls_name_set = 1; + else + { + errmsg ("parse error '%U'", format_unformat_error, input); + return -99; + } + } + + if (!ls_name_set) + { + errmsg ("locator-set name not set!"); + return -99; + } + + M (LISP_PITR_SET_LOCATOR_SET, lisp_pitr_set_locator_set); + + mp->is_add = is_add; + clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name)); + vec_free (ls_name); + + /* send */ + S; + + /* wait for reply */ + W; + + /* notreached */ + return 0; +} + +static int +api_show_lisp_pitr (vat_main_t * vam) +{ + vl_api_show_lisp_pitr_t *mp; + f64 timeout = ~0; + + if (!vam->json_output) + { + print (vam->ofp, "%=20s", "lisp status:"); + } + + M (SHOW_LISP_PITR, show_lisp_pitr); + /* send it... */ + S; + + /* Wait for a reply... */ + W; + + /* NOTREACHED */ + return 0; +} + +/** + * Add/delete mapping between vni and vrf + */ +static int +api_lisp_eid_table_add_del_map (vat_main_t * vam) +{ + f64 timeout = ~0; + unformat_input_t *input = vam->input; + vl_api_lisp_eid_table_add_del_map_t *mp; + u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0; + u32 vni, vrf, bd_index; + + /* Parse args required to build the message */ + while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) + { + if (unformat (input, "del")) + is_add = 0; + else if (unformat (input, "vrf %d", &vrf)) + vrf_set = 1; + else if (unformat (input, "bd_index %d", &bd_index)) + bd_index_set = 1; + else if (unformat (input, "vni %d", &vni)) + vni_set = 1; + else + break; + } + + if (!vni_set || (!vrf_set && !bd_index_set)) + { + errmsg ("missing arguments!"); + return -99; + } + + if (vrf_set && bd_index_set) + { + errmsg ("error: both vrf and bd entered!"); + return -99; + } + + M (LISP_EID_TABLE_ADD_DEL_MAP, lisp_eid_table_add_del_map); + + mp->is_add = is_add; + mp->vni = htonl (vni); + mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index); + mp->is_l2 = bd_index_set; + + /* send */ + S; + + /* wait for reply */ + W; + + /* notreached */ + return 0; +} + +uword +unformat_negative_mapping_action (unformat_input_t * input, va_list * args) +{ + u32 *action = va_arg (*args, u32 *); + u8 *s = 0; + + if (unformat (input, "%s", &s)) + { + if (!strcmp ((char *) s, "no-action")) + action[0] = 0; + else if (!strcmp ((char *) s, "natively-forward")) + action[0] = 1; + else if (!strcmp ((char *) s, "send-map-request")) + action[0] = 2; + else if (!strcmp ((char *) s, "drop")) + action[0] = 3; + else + { + clib_warning ("invalid action: '%s'", s); + action[0] = 3; + } + } + else + return 0; + + vec_free (s); + return 1; +} + +/** + * Add/del remote mapping to/from LISP control plane + * + * @param vam vpp API test context + * @return return code + */ +static int +api_lisp_add_del_remote_mapping (vat_main_t * vam) +{ + unformat_input_t *input = vam->input; + vl_api_lisp_add_del_remote_mapping_t *mp; + f64 timeout = ~0; + u32 vni = 0; + lisp_eid_vat_t _eid, *eid = &_eid; + lisp_eid_vat_t _seid, *seid = &_seid; + u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0; + u32 action = ~0, p, w, data_len; + ip4_address_t rloc4; + ip6_address_t rloc6; + rloc_t *rlocs = 0, rloc, *curr_rloc = 0; + + memset (&rloc, 0, sizeof (rloc)); + + /* Parse args required to build the message */ + while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) + { + if (unformat (input, "del-all")) + { + del_all = 1; + } + else if (unformat (input, "del")) + { + is_add = 0; + } + else if (unformat (input, "add")) + { + is_add = 1; + } + else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid)) + { + eid_set = 1; + } + else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid)) + { + seid_set = 1; + } + else if (unformat (input, "vni %d", &vni)) + { + ; + } + else if (unformat (input, "p %d w %d", &p, &w)) + { + if (!curr_rloc) + { + errmsg ("No RLOC configured for setting priority/weight!"); + return -99; + } + curr_rloc->priority = p; + curr_rloc->weight = w; + } + else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4)) + { + rloc.is_ip4 = 1; + clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4)); + vec_add1 (rlocs, rloc); + curr_rloc = &rlocs[vec_len (rlocs) - 1]; + } + else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6)) + { + rloc.is_ip4 = 0; + clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6)); + vec_add1 (rlocs, rloc); + curr_rloc = &rlocs[vec_len (rlocs) - 1]; + } + else if (unformat (input, "action %U", + unformat_negative_mapping_action, &action)) + { + ; + } + else + { + clib_warning ("parse error '%U'", format_unformat_error, input); + return -99; + } + } + + if (0 == eid_set) + { + errmsg ("missing params!"); + return -99; + } + + if (is_add && (~0 == action) && 0 == vec_len (rlocs)) + { + errmsg ("no action set for negative map-reply!"); + return -99; + } + + data_len = vec_len (rlocs) * sizeof (rloc_t); + + M2 (LISP_ADD_DEL_REMOTE_MAPPING, lisp_add_del_remote_mapping, data_len); + mp->is_add = is_add; + mp->vni = htonl (vni); + mp->action = (u8) action; + mp->is_src_dst = seid_set; + mp->eid_len = eid->len; + mp->seid_len = seid->len; + mp->del_all = del_all; + mp->eid_type = eid->type; + lisp_eid_put_vat (mp->eid, eid->addr, eid->type); + lisp_eid_put_vat (mp->seid, seid->addr, seid->type); + + mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs)); + clib_memcpy (mp->rlocs, rlocs, data_len); + vec_free (rlocs); + + /* send it... */ + S; + + /* Wait for a reply... */ + W; + + /* NOTREACHED */ + return 0; +} + +/** + * Add/del LISP adjacency. Saves mapping in LISP control plane and updates + * forwarding entries in data-plane accordingly. + * + * @param vam vpp API test context + * @return return code + */ +static int +api_lisp_add_del_adjacency (vat_main_t * vam) +{ + unformat_input_t *input = vam->input; + vl_api_lisp_add_del_adjacency_t *mp; + f64 timeout = ~0; + u32 vni = 0; + ip4_address_t leid4, reid4; + ip6_address_t leid6, reid6; + u8 reid_mac[6] = { 0 }; + u8 leid_mac[6] = { 0 }; + u8 reid_type, leid_type; + u32 leid_len = 0, reid_len = 0, len; + u8 is_add = 1; + + leid_type = reid_type = (u8) ~ 0; + + /* Parse args required to build the message */ + while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) + { + if (unformat (input, "del")) + { + is_add = 0; + } + else if (unformat (input, "add")) + { + is_add = 1; + } + else if (unformat (input, "reid %U/%d", unformat_ip4_address, + &reid4, &len)) + { + reid_type = 0; /* ipv4 */ + reid_len = len; + } + else if (unformat (input, "reid %U/%d", unformat_ip6_address, + &reid6, &len)) + { + reid_type = 1; /* ipv6 */ + reid_len = len; + } + else if (unformat (input, "reid %U", unformat_ethernet_address, + reid_mac)) + { + reid_type = 2; /* mac */ + } + else if (unformat (input, "leid %U/%d", unformat_ip4_address, + &leid4, &len)) + { + leid_type = 0; /* ipv4 */ + leid_len = len; + } + else if (unformat (input, "leid %U/%d", unformat_ip6_address, + &leid6, &len)) + { + leid_type = 1; /* ipv6 */ + leid_len = len; + } + else if (unformat (input, "leid %U", unformat_ethernet_address, + leid_mac)) + { + leid_type = 2; /* mac */ + } + else if (unformat (input, "vni %d", &vni)) + { + ; + } + else + { + errmsg ("parse error '%U'", format_unformat_error, input); + return -99; + } + } + + if ((u8) ~ 0 == reid_type) + { + errmsg ("missing params!"); + return -99; + } + + if (leid_type != reid_type) + { + errmsg ("remote and local EIDs are of different types!"); + return -99; + } + + M (LISP_ADD_DEL_ADJACENCY, lisp_add_del_adjacency); + mp->is_add = is_add; + mp->vni = htonl (vni); + mp->leid_len = leid_len; + mp->reid_len = reid_len; + mp->eid_type = reid_type; + + switch (mp->eid_type) + { + case 0: + clib_memcpy (mp->leid, &leid4, sizeof (leid4)); + clib_memcpy (mp->reid, &reid4, sizeof (reid4)); + break; + case 1: + clib_memcpy (mp->leid, &leid6, sizeof (leid6)); + clib_memcpy (mp->reid, &reid6, sizeof (reid6)); + break; + case 2: + clib_memcpy (mp->leid, leid_mac, 6); + clib_memcpy (mp->reid, reid_mac, 6); + break; + default: + errmsg ("unknown EID type %d!", mp->eid_type); + return 0; + } + + /* send it... */ + S; + + /* Wait for a reply... */ + W; + + /* NOTREACHED */ + return 0; +} + +static int +api_lisp_gpe_add_del_iface (vat_main_t * vam) +{ + unformat_input_t *input = vam->input; + vl_api_lisp_gpe_add_del_iface_t *mp; + f64 timeout = ~0; + u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0; + u32 dp_table = 0, vni = 0; + + /* Parse args required to build the message */ + while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) + { + if (unformat (input, "up")) + { + action_set = 1; + is_add = 1; + } + else if (unformat (input, "down")) + { + action_set = 1; + is_add = 0; + } + else if (unformat (input, "table_id %d", &dp_table)) + { + dp_table_set = 1; + } + else if (unformat (input, "bd_id %d", &dp_table)) + { + dp_table_set = 1; + is_l2 = 1; + } + else if (unformat (input, "vni %d", &vni)) + { + vni_set = 1; + } + else + break; + } + + if (action_set == 0) + { + errmsg ("Action not set"); + return -99; + } + if (dp_table_set == 0 || vni_set == 0) + { + errmsg ("vni and dp_table must be set"); + return -99; + } + + /* Construct the API message */ + M (LISP_GPE_ADD_DEL_IFACE, lisp_gpe_add_del_iface); + + mp->is_add = is_add; + mp->dp_table = dp_table; + mp->is_l2 = is_l2; + mp->vni = vni; + + /* send it... */ + S; + + /* Wait for a reply... */ + W; + + /* NOTREACHED */ + return 0; +} + +/** + * Add/del map request itr rlocs from LISP control plane and updates + * + * @param vam vpp API test context + * @return return code + */ +static int +api_lisp_add_del_map_request_itr_rlocs (vat_main_t * vam) +{ + unformat_input_t *input = vam->input; + vl_api_lisp_add_del_map_request_itr_rlocs_t *mp; + f64 timeout = ~0; + u8 *locator_set_name = 0; + u8 locator_set_name_set = 0; + u8 is_add = 1; + + /* Parse args required to build the message */ + while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) + { + if (unformat (input, "del")) + { + is_add = 0; + } + else if (unformat (input, "%_%v%_", &locator_set_name)) + { + locator_set_name_set = 1; + } + else + { + clib_warning ("parse error '%U'", format_unformat_error, input); + return -99; + } + } + + if (is_add && !locator_set_name_set) + { + errmsg ("itr-rloc is not set!"); + return -99; + } + + if (is_add && vec_len (locator_set_name) > 64) + { + errmsg ("itr-rloc locator-set name too long"); + vec_free (locator_set_name); + return -99; + } + + M (LISP_ADD_DEL_MAP_REQUEST_ITR_RLOCS, lisp_add_del_map_request_itr_rlocs); + mp->is_add = is_add; + if (is_add) + { + clib_memcpy (mp->locator_set_name, locator_set_name, + vec_len (locator_set_name)); + } + else + { + memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name)); + } + vec_free (locator_set_name); + + /* send it... */ + S; + + /* Wait for a reply... */ + W; + + /* NOTREACHED */ + return 0; +} + +static int +api_lisp_locator_dump (vat_main_t * vam) +{ + unformat_input_t *input = vam->input; + vl_api_lisp_locator_dump_t *mp; + f64 timeout = ~0; + u8 is_index_set = 0, is_name_set = 0; + u8 *ls_name = 0; + u32 ls_index = ~0; + + /* Parse args required to build the message */ + while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) + { + if (unformat (input, "ls_name %_%v%_", &ls_name)) + { + is_name_set = 1; + } + else if (unformat (input, "ls_index %d", &ls_index)) + { + is_index_set = 1; + } + else + { + errmsg ("parse error '%U'", format_unformat_error, input); + return -99; + } + } + + if (!is_index_set && !is_name_set) + { + errmsg ("error: expected one of index or name!"); + return -99; + } + + if (is_index_set && is_name_set) + { + errmsg ("error: only one param expected!"); + return -99; + } + + if (vec_len (ls_name) > 62) + { + errmsg ("error: locator set name too long!"); + return -99; + } + + if (!vam->json_output) + { + print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight"); + } + + M (LISP_LOCATOR_DUMP, lisp_locator_dump); + mp->is_index_set = is_index_set; + + if (is_index_set) + mp->ls_index = clib_host_to_net_u32 (ls_index); + else + { + vec_add1 (ls_name, 0); + strncpy ((char *) mp->ls_name, (char *) ls_name, + sizeof (mp->ls_name) - 1); + } + + /* send it... */ + S; + + /* Use a control ping for synchronization */ + { + vl_api_control_ping_t *mp; + M (CONTROL_PING, control_ping); + S; + } + /* Wait for a reply... */ + W; + + /* NOTREACHED */ + return 0; +} + +static int +api_lisp_locator_set_dump (vat_main_t * vam) +{ + vl_api_lisp_locator_set_dump_t *mp; + unformat_input_t *input = vam->input; + f64 timeout = ~0; + u8 filter = 0; + + /* Parse args required to build the message */ + while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) + { + if (unformat (input, "local")) + { + filter = 1; + } + else if (unformat (input, "remote")) + { + filter = 2; + } + else + { + errmsg ("parse error '%U'", format_unformat_error, input); + return -99; + } + } + + if (!vam->json_output) + { + print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name"); + } + + M (LISP_LOCATOR_SET_DUMP, lisp_locator_set_dump); + + mp->filter = filter; + + /* send it... */ + S; + + /* Use a control ping for synchronization */ + { + vl_api_control_ping_t *mp; + M (CONTROL_PING, control_ping); + S; + } + /* Wait for a reply... */ + W; + + /* NOTREACHED */ + return 0; +} + +static int +api_lisp_eid_table_map_dump (vat_main_t * vam) +{ + u8 is_l2 = 0; + u8 mode_set = 0; + unformat_input_t *input = vam->input; + vl_api_lisp_eid_table_map_dump_t *mp; + f64 timeout = ~0; + + /* Parse args required to build the message */ + while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) + { + if (unformat (input, "l2")) + { + is_l2 = 1; + mode_set = 1; + } + else if (unformat (input, "l3")) + { + is_l2 = 0; + mode_set = 1; + } + else + { + errmsg ("parse error '%U'", format_unformat_error, input); + return -99; + } + } + + if (!mode_set) + { + errmsg ("expected one of 'l2' or 'l3' parameter!"); + return -99; + } + + if (!vam->json_output) + { + print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF"); + } + + M (LISP_EID_TABLE_MAP_DUMP, lisp_eid_table_map_dump); + mp->is_l2 = is_l2; + + /* send it... */ + S; + + /* Use a control ping for synchronization */ + { + vl_api_control_ping_t *mp; + M (CONTROL_PING, control_ping); + S; + } + /* Wait for a reply... */ + W; + + /* NOTREACHED */ + return 0; +} + +static int +api_lisp_eid_table_vni_dump (vat_main_t * vam) +{ + vl_api_lisp_eid_table_vni_dump_t *mp; + f64 timeout = ~0; + + if (!vam->json_output) + { + print (vam->ofp, "VNI"); + } + + M (LISP_EID_TABLE_VNI_DUMP, lisp_eid_table_vni_dump); + + /* send it... */ + S; + + /* Use a control ping for synchronization */ + { + vl_api_control_ping_t *mp; + M (CONTROL_PING, control_ping); + S; + } + /* Wait for a reply... */ + W; + + /* NOTREACHED */ + return 0; +} + +static int +api_lisp_eid_table_dump (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + vl_api_lisp_eid_table_dump_t *mp; + f64 timeout = ~0; + struct in_addr ip4; + struct in6_addr ip6; + u8 mac[6]; + u8 eid_type = ~0, eid_set = 0; + u32 prefix_length = ~0, t, vni = 0; + u8 filter = 0; + + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t)) + { + eid_set = 1; + eid_type = 0; + prefix_length = t; + } + else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t)) + { + eid_set = 1; + eid_type = 1; + prefix_length = t; + } + else if (unformat (i, "eid %U", unformat_ethernet_address, mac)) + { + eid_set = 1; + eid_type = 2; + } + else if (unformat (i, "vni %d", &t)) + { + vni = t; + } + else if (unformat (i, "local")) + { + filter = 1; + } + else if (unformat (i, "remote")) + { + filter = 2; + } + else + { + errmsg ("parse error '%U'", format_unformat_error, i); + return -99; + } + } + + if (!vam->json_output) + { + print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID", + "type", "ls_index", "ttl", "authoritative", "key_id", "key"); + } + + M (LISP_EID_TABLE_DUMP, lisp_eid_table_dump); + + mp->filter = filter; + if (eid_set) + { + mp->eid_set = 1; + mp->vni = htonl (vni); + mp->eid_type = eid_type; + switch (eid_type) + { + case 0: + mp->prefix_length = prefix_length; + clib_memcpy (mp->eid, &ip4, sizeof (ip4)); + break; + case 1: + mp->prefix_length = prefix_length; + clib_memcpy (mp->eid, &ip6, sizeof (ip6)); + break; + case 2: + clib_memcpy (mp->eid, mac, sizeof (mac)); + break; + default: + errmsg ("unknown EID type %d!", eid_type); + return -99; + } + } + + /* send it... */ + S; + + /* Use a control ping for synchronization */ + { + vl_api_control_ping_t *mp; + M (CONTROL_PING, control_ping); + S; + } + + /* Wait for a reply... */ + W; + + /* NOTREACHED */ + return 0; +} + +static int +api_lisp_gpe_tunnel_dump (vat_main_t * vam) +{ + vl_api_lisp_gpe_tunnel_dump_t *mp; + f64 timeout = ~0; + + if (!vam->json_output) + { + print (vam->ofp, "%=20s%=30s%=16s%=16s%=16s%=16s" + "%=16s%=16s%=16s%=16s%=16s", + "Tunel", "Source", "Destination", "Fib encap", "Fib decap", + "Decap next", "Lisp version", "Flags", "Next protocol", + "ver_res", "res", "iid"); + } + + M (LISP_GPE_TUNNEL_DUMP, lisp_gpe_tunnel_dump); + /* send it... */ + S; + + /* Use a control ping for synchronization */ + { + vl_api_control_ping_t *mp; + M (CONTROL_PING, control_ping); + S; + } + /* Wait for a reply... */ + W; + + /* NOTREACHED */ + return 0; +} + +static int +api_lisp_adjacencies_get (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + vl_api_lisp_adjacencies_get_t *mp; + f64 timeout = ~0; + u8 vni_set = 0; + u32 vni = ~0; + + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "vni %d", &vni)) + { + vni_set = 1; + } + else + { + errmsg ("parse error '%U'", format_unformat_error, i); + return -99; + } + } + + if (!vni_set) + { + errmsg ("vni not set!"); + return -99; + } + + if (!vam->json_output) + { + print (vam->ofp, "%s %40s", "leid", "reid"); + } + + M (LISP_ADJACENCIES_GET, lisp_adjacencies_get); + mp->vni = clib_host_to_net_u32 (vni); + + /* send it... */ + S; + + /* Wait for a reply... */ + W; + + /* NOTREACHED */ + return 0; +} + +static int +api_lisp_map_server_dump (vat_main_t * vam) +{ + vl_api_lisp_map_server_dump_t *mp; + f64 timeout = ~0; + + if (!vam->json_output) + { + print (vam->ofp, "%=20s", "Map server"); + } + + M (LISP_MAP_SERVER_DUMP, lisp_map_server_dump); + /* send it... */ + S; + + /* Use a control ping for synchronization */ + { + vl_api_control_ping_t *mp; + M (CONTROL_PING, control_ping); + S; + } + /* Wait for a reply... */ + W; + + /* NOTREACHED */ + return 0; +} + +static int +api_lisp_map_resolver_dump (vat_main_t * vam) +{ + vl_api_lisp_map_resolver_dump_t *mp; + f64 timeout = ~0; + + if (!vam->json_output) + { + print (vam->ofp, "%=20s", "Map resolver"); + } + + M (LISP_MAP_RESOLVER_DUMP, lisp_map_resolver_dump); + /* send it... */ + S; + + /* Use a control ping for synchronization */ + { + vl_api_control_ping_t *mp; + M (CONTROL_PING, control_ping); + S; + } + /* Wait for a reply... */ + W; + + /* NOTREACHED */ + return 0; +} + +static int +api_show_lisp_status (vat_main_t * vam) +{ + vl_api_show_lisp_status_t *mp; + f64 timeout = ~0; + + if (!vam->json_output) + { + print (vam->ofp, "%-20s%-16s", "lisp status", "locator-set"); + } + + M (SHOW_LISP_STATUS, show_lisp_status); + /* send it... */ + S; + /* Wait for a reply... */ + W; + + /* NOTREACHED */ + return 0; +} + +static int +api_lisp_get_map_request_itr_rlocs (vat_main_t * vam) +{ + vl_api_lisp_get_map_request_itr_rlocs_t *mp; + f64 timeout = ~0; + + if (!vam->json_output) + { + print (vam->ofp, "%=20s", "itr-rlocs:"); + } + + M (LISP_GET_MAP_REQUEST_ITR_RLOCS, lisp_get_map_request_itr_rlocs); + /* send it... */ + S; + /* Wait for a reply... */ + W; + + /* NOTREACHED */ + return 0; +} + +static int +api_af_packet_create (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + vl_api_af_packet_create_t *mp; + f64 timeout; + u8 *host_if_name = 0; + u8 hw_addr[6]; + u8 random_hw_addr = 1; + + memset (hw_addr, 0, sizeof (hw_addr)); + + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "name %s", &host_if_name)) + vec_add1 (host_if_name, 0); + else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr)) + random_hw_addr = 0; + else + break; + } + + if (!vec_len (host_if_name)) + { + errmsg ("host-interface name must be specified"); + return -99; + } + + if (vec_len (host_if_name) > 64) + { + errmsg ("host-interface name too long"); + return -99; + } + + M (AF_PACKET_CREATE, af_packet_create); + + clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name)); + clib_memcpy (mp->hw_addr, hw_addr, 6); + mp->use_random_hw_addr = random_hw_addr; + vec_free (host_if_name); + + S; + W2 (fprintf (vam->ofp, " new sw_if_index = %d ", vam->sw_if_index)); + /* NOTREACHED */ + return 0; +} + +static int +api_af_packet_delete (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + vl_api_af_packet_delete_t *mp; + f64 timeout; + u8 *host_if_name = 0; + + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "name %s", &host_if_name)) + vec_add1 (host_if_name, 0); + else + break; + } + + if (!vec_len (host_if_name)) + { + errmsg ("host-interface name must be specified"); + return -99; + } + + if (vec_len (host_if_name) > 64) + { + errmsg ("host-interface name too long"); + return -99; + } + + M (AF_PACKET_DELETE, af_packet_delete); + + clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name)); + vec_free (host_if_name); + + S; + W; + /* NOTREACHED */ + return 0; +} + +static int +api_policer_add_del (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + vl_api_policer_add_del_t *mp; + f64 timeout; + u8 is_add = 1; + u8 *name = 0; + u32 cir = 0; + u32 eir = 0; + u64 cb = 0; + u64 eb = 0; + u8 rate_type = 0; + u8 round_type = 0; + u8 type = 0; + u8 color_aware = 0; + sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action; + + conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT; + conform_action.dscp = 0; + exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT; + exceed_action.dscp = 0; + violate_action.action_type = SSE2_QOS_ACTION_DROP; + violate_action.dscp = 0; + + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "del")) + is_add = 0; + else if (unformat (i, "name %s", &name)) + vec_add1 (name, 0); + else if (unformat (i, "cir %u", &cir)) + ; + else if (unformat (i, "eir %u", &eir)) + ; + else if (unformat (i, "cb %u", &cb)) + ; + else if (unformat (i, "eb %u", &eb)) + ; + else if (unformat (i, "rate_type %U", unformat_policer_rate_type, + &rate_type)) + ; + else if (unformat (i, "round_type %U", unformat_policer_round_type, + &round_type)) + ; + else if (unformat (i, "type %U", unformat_policer_type, &type)) + ; + else if (unformat (i, "conform_action %U", unformat_policer_action_type, + &conform_action)) + ; + else if (unformat (i, "exceed_action %U", unformat_policer_action_type, + &exceed_action)) + ; + else if (unformat (i, "violate_action %U", unformat_policer_action_type, + &violate_action)) + ; + else if (unformat (i, "color-aware")) + color_aware = 1; + else + break; + } + + if (!vec_len (name)) + { + errmsg ("policer name must be specified"); + return -99; + } + + if (vec_len (name) > 64) + { + errmsg ("policer name too long"); + return -99; + } + + M (POLICER_ADD_DEL, policer_add_del); + + clib_memcpy (mp->name, name, vec_len (name)); + vec_free (name); + mp->is_add = is_add; + mp->cir = cir; + mp->eir = eir; + mp->cb = cb; + mp->eb = eb; + mp->rate_type = rate_type; + mp->round_type = round_type; + mp->type = type; + mp->conform_action_type = conform_action.action_type; + mp->conform_dscp = conform_action.dscp; + mp->exceed_action_type = exceed_action.action_type; + mp->exceed_dscp = exceed_action.dscp; + mp->violate_action_type = violate_action.action_type; + mp->violate_dscp = violate_action.dscp; + mp->color_aware = color_aware; + + S; + W; + /* NOTREACHED */ + return 0; +} + +static int +api_policer_dump (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + vl_api_policer_dump_t *mp; + f64 timeout = ~0; + u8 *match_name = 0; + u8 match_name_valid = 0; + + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "name %s", &match_name)) + { + vec_add1 (match_name, 0); + match_name_valid = 1; + } + else + break; + } + + M (POLICER_DUMP, policer_dump); + mp->match_name_valid = match_name_valid; + clib_memcpy (mp->match_name, match_name, vec_len (match_name)); + vec_free (match_name); + /* send it... */ + S; + + /* Use a control ping for synchronization */ + { + vl_api_control_ping_t *mp; + M (CONTROL_PING, control_ping); + S; + } + /* Wait for a reply... */ + W; + + /* NOTREACHED */ + return 0; +} + +static int +api_policer_classify_set_interface (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + vl_api_policer_classify_set_interface_t *mp; + f64 timeout; + u32 sw_if_index; + int sw_if_index_set; + u32 ip4_table_index = ~0; + u32 ip6_table_index = ~0; + u32 l2_table_index = ~0; + u8 is_add = 1; + + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index)) + sw_if_index_set = 1; + else if (unformat (i, "sw_if_index %d", &sw_if_index)) + sw_if_index_set = 1; + else if (unformat (i, "del")) + is_add = 0; + else if (unformat (i, "ip4-table %d", &ip4_table_index)) + ; + else if (unformat (i, "ip6-table %d", &ip6_table_index)) + ; + else if (unformat (i, "l2-table %d", &l2_table_index)) + ; + else + { + clib_warning ("parse error '%U'", format_unformat_error, i); + return -99; + } + } + + if (sw_if_index_set == 0) + { + errmsg ("missing interface name or sw_if_index"); + return -99; + } + + M (POLICER_CLASSIFY_SET_INTERFACE, policer_classify_set_interface); + + mp->sw_if_index = ntohl (sw_if_index); + mp->ip4_table_index = ntohl (ip4_table_index); + mp->ip6_table_index = ntohl (ip6_table_index); + mp->l2_table_index = ntohl (l2_table_index); + mp->is_add = is_add; + + S; + W; + /* NOTREACHED */ + return 0; +} + +static int +api_policer_classify_dump (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + vl_api_policer_classify_dump_t *mp; + f64 timeout = ~0; + u8 type = POLICER_CLASSIFY_N_TABLES; + + if (unformat (i, "type %U", unformat_policer_classify_table_type, &type)) + ; + else + { + errmsg ("classify table type must be specified"); + return -99; + } + + if (!vam->json_output) + { + print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table"); + } + + M (POLICER_CLASSIFY_DUMP, policer_classify_dump); + mp->type = type; + /* send it... */ + S; + + /* Use a control ping for synchronization */ + { + vl_api_control_ping_t *mp; + M (CONTROL_PING, control_ping); + S; + } + /* Wait for a reply... */ + W; + + /* NOTREACHED */ + return 0; +} + +static int +api_netmap_create (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + vl_api_netmap_create_t *mp; + f64 timeout; + u8 *if_name = 0; + u8 hw_addr[6]; + u8 random_hw_addr = 1; + u8 is_pipe = 0; + u8 is_master = 0; + + memset (hw_addr, 0, sizeof (hw_addr)); + + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "name %s", &if_name)) + vec_add1 (if_name, 0); + else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr)) + random_hw_addr = 0; + else if (unformat (i, "pipe")) + is_pipe = 1; + else if (unformat (i, "master")) + is_master = 1; + else if (unformat (i, "slave")) + is_master = 0; + else + break; + } + + if (!vec_len (if_name)) + { + errmsg ("interface name must be specified"); + return -99; + } + + if (vec_len (if_name) > 64) + { + errmsg ("interface name too long"); + return -99; + } + + M (NETMAP_CREATE, netmap_create); + + clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name)); + clib_memcpy (mp->hw_addr, hw_addr, 6); + mp->use_random_hw_addr = random_hw_addr; + mp->is_pipe = is_pipe; + mp->is_master = is_master; + vec_free (if_name); + + S; + W; + /* NOTREACHED */ + return 0; +} + +static int +api_netmap_delete (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + vl_api_netmap_delete_t *mp; + f64 timeout; + u8 *if_name = 0; + + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "name %s", &if_name)) + vec_add1 (if_name, 0); + else + break; + } + + if (!vec_len (if_name)) + { + errmsg ("interface name must be specified"); + return -99; + } + + if (vec_len (if_name) > 64) + { + errmsg ("interface name too long"); + return -99; + } + + M (NETMAP_DELETE, netmap_delete); + + clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name)); + vec_free (if_name); + + S; + W; + /* NOTREACHED */ + return 0; +} + +static void vl_api_mpls_tunnel_details_t_handler + (vl_api_mpls_tunnel_details_t * mp) +{ + vat_main_t *vam = &vat_main; + i32 len = mp->mt_next_hop_n_labels; + i32 i; + + print (vam->ofp, "[%d]: via %U %d labels ", + mp->tunnel_index, + format_ip4_address, mp->mt_next_hop, + ntohl (mp->mt_next_hop_sw_if_index)); + for (i = 0; i < len; i++) + { + print (vam->ofp, "%u ", ntohl (mp->mt_next_hop_out_labels[i])); + } + print (vam->ofp, ""); +} + +static void vl_api_mpls_tunnel_details_t_handler_json + (vl_api_mpls_tunnel_details_t * mp) +{ + vat_main_t *vam = &vat_main; + vat_json_node_t *node = NULL; + struct in_addr ip4; + i32 i; + i32 len = mp->mt_next_hop_n_labels; + + if (VAT_JSON_ARRAY != vam->json_tree.type) + { + ASSERT (VAT_JSON_NONE == vam->json_tree.type); + vat_json_init_array (&vam->json_tree); + } + node = vat_json_array_add (&vam->json_tree); + + vat_json_init_object (node); + vat_json_object_add_uint (node, "tunnel_index", ntohl (mp->tunnel_index)); + clib_memcpy (&ip4, &(mp->mt_next_hop), sizeof (ip4)); + vat_json_object_add_ip4 (node, "next_hop", ip4); + vat_json_object_add_uint (node, "next_hop_sw_if_index", + ntohl (mp->mt_next_hop_sw_if_index)); + vat_json_object_add_uint (node, "l2_only", ntohl (mp->mt_l2_only)); + vat_json_object_add_uint (node, "label_count", len); + for (i = 0; i < len; i++) + { + vat_json_object_add_uint (node, "label", + ntohl (mp->mt_next_hop_out_labels[i])); + } +} + +static int +api_mpls_tunnel_dump (vat_main_t * vam) +{ + vl_api_mpls_tunnel_dump_t *mp; + f64 timeout; + i32 index = -1; + + /* Parse args required to build the message */ + while (unformat_check_input (vam->input) != UNFORMAT_END_OF_INPUT) + { + if (!unformat (vam->input, "tunnel_index %d", &index)) + { + index = -1; + break; + } + } + + print (vam->ofp, " tunnel_index %d", index); + + M (MPLS_TUNNEL_DUMP, mpls_tunnel_dump); + mp->tunnel_index = htonl (index); + S; + + /* Use a control ping for synchronization */ + { + vl_api_control_ping_t *mp; + M (CONTROL_PING, control_ping); + S; + } + W; +} + +#define vl_api_mpls_fib_details_t_endian vl_noop_handler +#define vl_api_mpls_fib_details_t_print vl_noop_handler + +static void +vl_api_mpls_fib_details_t_handler (vl_api_mpls_fib_details_t * mp) +{ + vat_main_t *vam = &vat_main; + int count = ntohl (mp->count); + vl_api_fib_path2_t *fp; + int i; + + print (vam->ofp, + "table-id %d, label %u, ess_bit %u", + ntohl (mp->table_id), ntohl (mp->label), mp->eos_bit); + fp = mp->path; + for (i = 0; i < count; i++) + { + if (fp->afi == IP46_TYPE_IP6) + print (vam->ofp, + " weight %d, sw_if_index %d, is_local %d, is_drop %d, " + "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U", + ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local, + fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi, + format_ip6_address, fp->next_hop); + else if (fp->afi == IP46_TYPE_IP4) + print (vam->ofp, + " weight %d, sw_if_index %d, is_local %d, is_drop %d, " + "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U", + ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local, + fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi, + format_ip4_address, fp->next_hop); + fp++; + } +} + +static void vl_api_mpls_fib_details_t_handler_json + (vl_api_mpls_fib_details_t * mp) +{ + vat_main_t *vam = &vat_main; + int count = ntohl (mp->count); + vat_json_node_t *node = NULL; + struct in_addr ip4; + struct in6_addr ip6; + vl_api_fib_path2_t *fp; + int i; + + if (VAT_JSON_ARRAY != vam->json_tree.type) + { + ASSERT (VAT_JSON_NONE == vam->json_tree.type); + vat_json_init_array (&vam->json_tree); + } + node = vat_json_array_add (&vam->json_tree); + + vat_json_init_object (node); + vat_json_object_add_uint (node, "table", ntohl (mp->table_id)); + vat_json_object_add_uint (node, "s_bit", mp->eos_bit); + vat_json_object_add_uint (node, "label", ntohl (mp->label)); + vat_json_object_add_uint (node, "path_count", count); + fp = mp->path; + for (i = 0; i < count; i++) + { + vat_json_object_add_uint (node, "weight", ntohl (fp->weight)); + vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index)); + vat_json_object_add_uint (node, "is_local", fp->is_local); + vat_json_object_add_uint (node, "is_drop", fp->is_drop); + vat_json_object_add_uint (node, "is_unreach", fp->is_unreach); + vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit); + vat_json_object_add_uint (node, "next_hop_afi", fp->afi); + if (fp->afi == IP46_TYPE_IP4) + { + clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4)); + vat_json_object_add_ip4 (node, "next_hop", ip4); + } + else if (fp->afi == IP46_TYPE_IP6) + { + clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6)); + vat_json_object_add_ip6 (node, "next_hop", ip6); + } + } +} + +static int +api_mpls_fib_dump (vat_main_t * vam) +{ + vl_api_mpls_fib_dump_t *mp; + f64 timeout; + + M (MPLS_FIB_DUMP, mpls_fib_dump); + S; + + /* Use a control ping for synchronization */ + { + vl_api_control_ping_t *mp; + M (CONTROL_PING, control_ping); + S; + } + W; +} + +#define vl_api_ip_fib_details_t_endian vl_noop_handler +#define vl_api_ip_fib_details_t_print vl_noop_handler + +static void +vl_api_ip_fib_details_t_handler (vl_api_ip_fib_details_t * mp) +{ + vat_main_t *vam = &vat_main; + int count = ntohl (mp->count); + vl_api_fib_path_t *fp; + int i; + + print (vam->ofp, + "table-id %d, prefix %U/%d", + ntohl (mp->table_id), format_ip4_address, mp->address, + mp->address_length); + fp = mp->path; + for (i = 0; i < count; i++) + { + if (fp->afi == IP46_TYPE_IP6) + print (vam->ofp, + " weight %d, sw_if_index %d, is_local %d, is_drop %d, " + "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U", + ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local, + fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi, + format_ip6_address, fp->next_hop); + else if (fp->afi == IP46_TYPE_IP4) + print (vam->ofp, + " weight %d, sw_if_index %d, is_local %d, is_drop %d, " + "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U", + ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local, + fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi, + format_ip4_address, fp->next_hop); + fp++; + } +} + +static void vl_api_ip_fib_details_t_handler_json + (vl_api_ip_fib_details_t * mp) +{ + vat_main_t *vam = &vat_main; + int count = ntohl (mp->count); + vat_json_node_t *node = NULL; + struct in_addr ip4; + struct in6_addr ip6; + vl_api_fib_path_t *fp; + int i; + + if (VAT_JSON_ARRAY != vam->json_tree.type) + { + ASSERT (VAT_JSON_NONE == vam->json_tree.type); + vat_json_init_array (&vam->json_tree); + } + node = vat_json_array_add (&vam->json_tree); + + vat_json_init_object (node); + vat_json_object_add_uint (node, "table", ntohl (mp->table_id)); + clib_memcpy (&ip4, &mp->address, sizeof (ip4)); + vat_json_object_add_ip4 (node, "prefix", ip4); + vat_json_object_add_uint (node, "mask_length", mp->address_length); + vat_json_object_add_uint (node, "path_count", count); + fp = mp->path; + for (i = 0; i < count; i++) + { + vat_json_object_add_uint (node, "weight", ntohl (fp->weight)); + vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index)); + vat_json_object_add_uint (node, "is_local", fp->is_local); + vat_json_object_add_uint (node, "is_drop", fp->is_drop); + vat_json_object_add_uint (node, "is_unreach", fp->is_unreach); + vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit); + vat_json_object_add_uint (node, "next_hop_afi", fp->afi); + if (fp->afi == IP46_TYPE_IP4) + { + clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4)); + vat_json_object_add_ip4 (node, "next_hop", ip4); + } + else if (fp->afi == IP46_TYPE_IP6) + { + clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6)); + vat_json_object_add_ip6 (node, "next_hop", ip6); + } + } +} + +static int +api_ip_fib_dump (vat_main_t * vam) +{ + vl_api_ip_fib_dump_t *mp; + f64 timeout; + + M (IP_FIB_DUMP, ip_fib_dump); + S; + + /* Use a control ping for synchronization */ + { + vl_api_control_ping_t *mp; + M (CONTROL_PING, control_ping); + S; + } + W; +} + +static void vl_api_ip_neighbor_details_t_handler + (vl_api_ip_neighbor_details_t * mp) +{ + vat_main_t *vam = &vat_main; + + print (vam->ofp, "%c %U %U", + (mp->is_static) ? 'S' : 'D', + format_ethernet_address, &mp->mac_address, + (mp->is_ipv6) ? format_ip6_address : format_ip4_address, + &mp->ip_address); +} + +static void vl_api_ip_neighbor_details_t_handler_json + (vl_api_ip_neighbor_details_t * mp) +{ + + vat_main_t *vam = &vat_main; + vat_json_node_t *node; + struct in_addr ip4; + struct in6_addr ip6; + + if (VAT_JSON_ARRAY != vam->json_tree.type) + { + ASSERT (VAT_JSON_NONE == vam->json_tree.type); + vat_json_init_array (&vam->json_tree); + } + node = vat_json_array_add (&vam->json_tree); + + vat_json_init_object (node); + vat_json_object_add_string_copy (node, "flag", + (mp->is_static) ? (u8 *) "static" : (u8 *) + "dynamic"); + + vat_json_object_add_string_copy (node, "link_layer", + format (0, "%U", format_ethernet_address, + &mp->mac_address)); + + if (mp->is_ipv6) + { + clib_memcpy (&ip6, &mp->ip_address, sizeof (ip6)); + vat_json_object_add_ip6 (node, "ip_address", ip6); + } + else + { + clib_memcpy (&ip4, &mp->ip_address, sizeof (ip4)); + vat_json_object_add_ip4 (node, "ip_address", ip4); + } +} + +static int +api_ip_neighbor_dump (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + vl_api_ip_neighbor_dump_t *mp; + f64 timeout; + u8 is_ipv6 = 0; + u32 sw_if_index = ~0; + + /* Parse args required to build the message */ + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index)) + ; + else if (unformat (i, "sw_if_index %d", &sw_if_index)) + ; + else if (unformat (i, "ip6")) + is_ipv6 = 1; + else + break; + } + + if (sw_if_index == ~0) + { + errmsg ("missing interface name or sw_if_index"); + return -99; + } + + M (IP_NEIGHBOR_DUMP, ip_neighbor_dump); + mp->is_ipv6 = (u8) is_ipv6; + mp->sw_if_index = ntohl (sw_if_index); + S; + + /* Use a control ping for synchronization */ + { + vl_api_control_ping_t *mp; + M (CONTROL_PING, control_ping); + S; + } + W; +} + +#define vl_api_ip6_fib_details_t_endian vl_noop_handler +#define vl_api_ip6_fib_details_t_print vl_noop_handler + +static void +vl_api_ip6_fib_details_t_handler (vl_api_ip6_fib_details_t * mp) +{ + vat_main_t *vam = &vat_main; + int count = ntohl (mp->count); + vl_api_fib_path_t *fp; + int i; + + print (vam->ofp, + "table-id %d, prefix %U/%d", + ntohl (mp->table_id), format_ip6_address, mp->address, + mp->address_length); + fp = mp->path; + for (i = 0; i < count; i++) + { + if (fp->afi == IP46_TYPE_IP6) + print (vam->ofp, + " weight %d, sw_if_index %d, is_local %d, is_drop %d, " + "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U", + ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local, + fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi, + format_ip6_address, fp->next_hop); + else if (fp->afi == IP46_TYPE_IP4) + print (vam->ofp, + " weight %d, sw_if_index %d, is_local %d, is_drop %d, " + "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U", + ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local, + fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi, + format_ip4_address, fp->next_hop); + fp++; + } +} + +static void vl_api_ip6_fib_details_t_handler_json + (vl_api_ip6_fib_details_t * mp) +{ + vat_main_t *vam = &vat_main; + int count = ntohl (mp->count); + vat_json_node_t *node = NULL; + struct in_addr ip4; + struct in6_addr ip6; + vl_api_fib_path_t *fp; + int i; + + if (VAT_JSON_ARRAY != vam->json_tree.type) + { + ASSERT (VAT_JSON_NONE == vam->json_tree.type); + vat_json_init_array (&vam->json_tree); + } + node = vat_json_array_add (&vam->json_tree); + + vat_json_init_object (node); + vat_json_object_add_uint (node, "table", ntohl (mp->table_id)); + clib_memcpy (&ip6, &mp->address, sizeof (ip6)); + vat_json_object_add_ip6 (node, "prefix", ip6); + vat_json_object_add_uint (node, "mask_length", mp->address_length); + vat_json_object_add_uint (node, "path_count", count); + fp = mp->path; + for (i = 0; i < count; i++) + { + vat_json_object_add_uint (node, "weight", ntohl (fp->weight)); + vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index)); + vat_json_object_add_uint (node, "is_local", fp->is_local); + vat_json_object_add_uint (node, "is_drop", fp->is_drop); + vat_json_object_add_uint (node, "is_unreach", fp->is_unreach); + vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit); + vat_json_object_add_uint (node, "next_hop_afi", fp->afi); + if (fp->afi == IP46_TYPE_IP4) + { + clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4)); + vat_json_object_add_ip4 (node, "next_hop", ip4); + } + else if (fp->afi == IP46_TYPE_IP6) + { + clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6)); + vat_json_object_add_ip6 (node, "next_hop", ip6); + } + } +} + +static int +api_ip6_fib_dump (vat_main_t * vam) +{ + vl_api_ip6_fib_dump_t *mp; + f64 timeout; + + M (IP6_FIB_DUMP, ip6_fib_dump); + S; + + /* Use a control ping for synchronization */ + { + vl_api_control_ping_t *mp; + M (CONTROL_PING, control_ping); + S; + } + W; +} + +int +api_classify_table_ids (vat_main_t * vam) +{ + vl_api_classify_table_ids_t *mp; + f64 timeout; + + /* Construct the API message */ + M (CLASSIFY_TABLE_IDS, classify_table_ids); + mp->context = 0; + + S; + W; + /* NOTREACHED */ + return 0; +} + +int +api_classify_table_by_interface (vat_main_t * vam) +{ + unformat_input_t *input = vam->input; + vl_api_classify_table_by_interface_t *mp; + f64 timeout; + + u32 sw_if_index = ~0; + while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) + { + if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index)) + ; + else if (unformat (input, "sw_if_index %d", &sw_if_index)) + ; + else + break; + } + if (sw_if_index == ~0) + { + errmsg ("missing interface name or sw_if_index"); + return -99; + } + + /* Construct the API message */ + M (CLASSIFY_TABLE_BY_INTERFACE, classify_table_by_interface); + mp->context = 0; + mp->sw_if_index = ntohl (sw_if_index); + + S; + W; + /* NOTREACHED */ + return 0; +} + +int +api_classify_table_info (vat_main_t * vam) +{ + unformat_input_t *input = vam->input; + vl_api_classify_table_info_t *mp; + f64 timeout; + + u32 table_id = ~0; + while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) + { + if (unformat (input, "table_id %d", &table_id)) + ; + else + break; + } + if (table_id == ~0) + { + errmsg ("missing table id"); + return -99; + } + + /* Construct the API message */ + M (CLASSIFY_TABLE_INFO, classify_table_info); + mp->context = 0; + mp->table_id = ntohl (table_id); + + S; + W; + /* NOTREACHED */ + return 0; +} + +int +api_classify_session_dump (vat_main_t * vam) +{ + unformat_input_t *input = vam->input; + vl_api_classify_session_dump_t *mp; + f64 timeout; + + u32 table_id = ~0; + while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) + { + if (unformat (input, "table_id %d", &table_id)) + ; + else + break; + } + if (table_id == ~0) + { + errmsg ("missing table id"); + return -99; + } + + /* Construct the API message */ + M (CLASSIFY_SESSION_DUMP, classify_session_dump); + mp->context = 0; + mp->table_id = ntohl (table_id); + S; + + /* Use a control ping for synchronization */ + { + vl_api_control_ping_t *mp; + M (CONTROL_PING, control_ping); + S; + } + W; + /* NOTREACHED */ + return 0; +} + +static void +vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp) +{ + vat_main_t *vam = &vat_main; + + print (vam->ofp, "collector_address %U, collector_port %d, " + "src_address %U, vrf_id %d, path_mtu %u, " + "template_interval %u, udp_checksum %d", + format_ip4_address, mp->collector_address, + ntohs (mp->collector_port), + format_ip4_address, mp->src_address, + ntohl (mp->vrf_id), ntohl (mp->path_mtu), + ntohl (mp->template_interval), mp->udp_checksum); + + vam->retval = 0; + vam->result_ready = 1; +} + +static void + vl_api_ipfix_exporter_details_t_handler_json + (vl_api_ipfix_exporter_details_t * mp) +{ + vat_main_t *vam = &vat_main; + vat_json_node_t node; + struct in_addr collector_address; + struct in_addr src_address; + + vat_json_init_object (&node); + clib_memcpy (&collector_address, &mp->collector_address, + sizeof (collector_address)); + vat_json_object_add_ip4 (&node, "collector_address", collector_address); + vat_json_object_add_uint (&node, "collector_port", + ntohs (mp->collector_port)); + clib_memcpy (&src_address, &mp->src_address, sizeof (src_address)); + vat_json_object_add_ip4 (&node, "src_address", src_address); + vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id)); + vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu)); + vat_json_object_add_uint (&node, "template_interval", + ntohl (mp->template_interval)); + vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum); + + vat_json_print (vam->ofp, &node); + vat_json_free (&node); + vam->retval = 0; + vam->result_ready = 1; +} + +int +api_ipfix_exporter_dump (vat_main_t * vam) +{ + vl_api_ipfix_exporter_dump_t *mp; + f64 timeout; + + /* Construct the API message */ + M (IPFIX_EXPORTER_DUMP, ipfix_exporter_dump); + mp->context = 0; + + S; + W; + /* NOTREACHED */ + return 0; +} + +static int +api_ipfix_classify_stream_dump (vat_main_t * vam) +{ + vl_api_ipfix_classify_stream_dump_t *mp; + f64 timeout; + + /* Construct the API message */ + M (IPFIX_CLASSIFY_STREAM_DUMP, ipfix_classify_stream_dump); + mp->context = 0; + + S; + W; + /* NOTREACHED */ + return 0; +} + +static void + vl_api_ipfix_classify_stream_details_t_handler + (vl_api_ipfix_classify_stream_details_t * mp) +{ + vat_main_t *vam = &vat_main; + print (vam->ofp, "domain_id %d, src_port %d", + ntohl (mp->domain_id), ntohs (mp->src_port)); + vam->retval = 0; + vam->result_ready = 1; +} + +static void + vl_api_ipfix_classify_stream_details_t_handler_json + (vl_api_ipfix_classify_stream_details_t * mp) +{ + vat_main_t *vam = &vat_main; + vat_json_node_t node; + + vat_json_init_object (&node); + vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id)); + vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port)); + + vat_json_print (vam->ofp, &node); + vat_json_free (&node); + vam->retval = 0; + vam->result_ready = 1; +} + +static int +api_ipfix_classify_table_dump (vat_main_t * vam) +{ + vl_api_ipfix_classify_table_dump_t *mp; + f64 timeout; + + if (!vam->json_output) + { + print (vam->ofp, "%15s%15s%20s", "table_id", "ip_version", + "transport_protocol"); + } + + /* Construct the API message */ + M (IPFIX_CLASSIFY_TABLE_DUMP, ipfix_classify_table_dump); + + /* send it... */ + S; + + /* Use a control ping for synchronization */ + { + vl_api_control_ping_t *mp; + M (CONTROL_PING, control_ping); + S; + } + W; +} + +static void + vl_api_ipfix_classify_table_details_t_handler + (vl_api_ipfix_classify_table_details_t * mp) +{ + vat_main_t *vam = &vat_main; + print (vam->ofp, "%15d%15d%20d", ntohl (mp->table_id), mp->ip_version, + mp->transport_protocol); +} + +static void + vl_api_ipfix_classify_table_details_t_handler_json + (vl_api_ipfix_classify_table_details_t * mp) +{ + vat_json_node_t *node = NULL; + vat_main_t *vam = &vat_main; + + if (VAT_JSON_ARRAY != vam->json_tree.type) + { + ASSERT (VAT_JSON_NONE == vam->json_tree.type); + vat_json_init_array (&vam->json_tree); + } + + node = vat_json_array_add (&vam->json_tree); + vat_json_init_object (node); + + vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id)); + vat_json_object_add_uint (node, "ip_version", mp->ip_version); + vat_json_object_add_uint (node, "transport_protocol", + mp->transport_protocol); +} + +static int +api_sw_interface_span_enable_disable (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + vl_api_sw_interface_span_enable_disable_t *mp; + f64 timeout; + u32 src_sw_if_index = ~0; + u32 dst_sw_if_index = ~0; + u8 state = 3; + + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat + (i, "src %U", api_unformat_sw_if_index, vam, &src_sw_if_index)) + ; + else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index)) + ; + else + if (unformat + (i, "dst %U", api_unformat_sw_if_index, vam, &dst_sw_if_index)) + ; + else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index)) + ; + else if (unformat (i, "disable")) + state = 0; + else if (unformat (i, "rx")) + state = 1; + else if (unformat (i, "tx")) + state = 2; + else if (unformat (i, "both")) + state = 3; + else + break; + } + + M (SW_INTERFACE_SPAN_ENABLE_DISABLE, sw_interface_span_enable_disable); + + mp->sw_if_index_from = htonl (src_sw_if_index); + mp->sw_if_index_to = htonl (dst_sw_if_index); + mp->state = state; + + S; + W; + /* NOTREACHED */ + return 0; +} + +static void +vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t + * mp) +{ + vat_main_t *vam = &vat_main; + u8 *sw_if_from_name = 0; + u8 *sw_if_to_name = 0; + u32 sw_if_index_from = ntohl (mp->sw_if_index_from); + u32 sw_if_index_to = ntohl (mp->sw_if_index_to); + char *states[] = { "none", "rx", "tx", "both" }; + hash_pair_t *p; + + /* *INDENT-OFF* */ + hash_foreach_pair (p, vam->sw_if_index_by_interface_name, + ({ + if ((u32) p->value[0] == sw_if_index_from) + { + sw_if_from_name = (u8 *)(p->key); + if (sw_if_to_name) + break; + } + if ((u32) p->value[0] == sw_if_index_to) + { + sw_if_to_name = (u8 *)(p->key); + if (sw_if_from_name) + break; + } + })); + /* *INDENT-ON* */ + print (vam->ofp, "%20s => %20s (%s)", + sw_if_from_name, sw_if_to_name, states[mp->state]); +} + +static void + vl_api_sw_interface_span_details_t_handler_json + (vl_api_sw_interface_span_details_t * mp) +{ + vat_main_t *vam = &vat_main; + vat_json_node_t *node = NULL; + u8 *sw_if_from_name = 0; + u8 *sw_if_to_name = 0; + u32 sw_if_index_from = ntohl (mp->sw_if_index_from); + u32 sw_if_index_to = ntohl (mp->sw_if_index_to); + hash_pair_t *p; + + /* *INDENT-OFF* */ + hash_foreach_pair (p, vam->sw_if_index_by_interface_name, + ({ + if ((u32) p->value[0] == sw_if_index_from) + { + sw_if_from_name = (u8 *)(p->key); + if (sw_if_to_name) + break; + } + if ((u32) p->value[0] == sw_if_index_to) + { + sw_if_to_name = (u8 *)(p->key); + if (sw_if_from_name) + break; + } + })); + /* *INDENT-ON* */ + + if (VAT_JSON_ARRAY != vam->json_tree.type) + { + ASSERT (VAT_JSON_NONE == vam->json_tree.type); + vat_json_init_array (&vam->json_tree); + } + node = vat_json_array_add (&vam->json_tree); + + vat_json_init_object (node); + vat_json_object_add_uint (node, "src-if-index", sw_if_index_from); + vat_json_object_add_string_copy (node, "src-if-name", sw_if_from_name); + vat_json_object_add_uint (node, "dst-if-index", sw_if_index_to); + vat_json_object_add_string_copy (node, "dst-if-name", sw_if_to_name); + vat_json_object_add_uint (node, "state", mp->state); +} + +static int +api_sw_interface_span_dump (vat_main_t * vam) +{ + vl_api_sw_interface_span_dump_t *mp; + f64 timeout; + + M (SW_INTERFACE_SPAN_DUMP, sw_interface_span_dump); + S; + + /* Use a control ping for synchronization */ + { + vl_api_control_ping_t *mp; + M (CONTROL_PING, control_ping); + S; + } + W; +} + +int +api_pg_create_interface (vat_main_t * vam) +{ + unformat_input_t *input = vam->input; + vl_api_pg_create_interface_t *mp; + f64 timeout; + + u32 if_id = ~0; + while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) + { + if (unformat (input, "if_id %d", &if_id)) + ; + else + break; + } + if (if_id == ~0) + { + errmsg ("missing pg interface index"); + return -99; + } + + /* Construct the API message */ + M (PG_CREATE_INTERFACE, pg_create_interface); + mp->context = 0; + mp->interface_id = ntohl (if_id); + + S; + W; + /* NOTREACHED */ + return 0; +} + +int +api_pg_capture (vat_main_t * vam) +{ + unformat_input_t *input = vam->input; + vl_api_pg_capture_t *mp; + f64 timeout; + + u32 if_id = ~0; + u8 enable = 1; + u32 count = 1; + u8 pcap_file_set = 0; + u8 *pcap_file = 0; + while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) + { + if (unformat (input, "if_id %d", &if_id)) + ; + else if (unformat (input, "pcap %s", &pcap_file)) + pcap_file_set = 1; + else if (unformat (input, "count %d", &count)) + ; + else if (unformat (input, "disable")) + enable = 0; + else + break; + } + if (if_id == ~0) + { + errmsg ("missing pg interface index"); + return -99; + } + if (pcap_file_set > 0) + { + if (vec_len (pcap_file) > 255) + { + errmsg ("pcap file name is too long"); + return -99; + } + } + + u32 name_len = vec_len (pcap_file); + /* Construct the API message */ + M (PG_CAPTURE, pg_capture); + mp->context = 0; + mp->interface_id = ntohl (if_id); + mp->is_enabled = enable; + mp->count = ntohl (count); + mp->pcap_name_length = ntohl (name_len); + if (pcap_file_set != 0) + { + clib_memcpy (mp->pcap_file_name, pcap_file, name_len); + } + vec_free (pcap_file); + + S; + W; + /* NOTREACHED */ + return 0; +} + +int +api_pg_enable_disable (vat_main_t * vam) +{ + unformat_input_t *input = vam->input; + vl_api_pg_enable_disable_t *mp; + f64 timeout; + + u8 enable = 1; + u8 stream_name_set = 0; + u8 *stream_name = 0; + while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) + { + if (unformat (input, "stream %s", &stream_name)) + stream_name_set = 1; + else if (unformat (input, "disable")) + enable = 0; + else + break; + } + + if (stream_name_set > 0) + { + if (vec_len (stream_name) > 255) + { + errmsg ("stream name too long"); + return -99; + } + } + + u32 name_len = vec_len (stream_name); + /* Construct the API message */ + M (PG_ENABLE_DISABLE, pg_enable_disable); + mp->context = 0; + mp->is_enabled = enable; + if (stream_name_set != 0) + { + mp->stream_name_length = ntohl (name_len); + clib_memcpy (mp->stream_name, stream_name, name_len); + } + vec_free (stream_name); + + S; + W; + /* NOTREACHED */ + return 0; +} + +int +api_ip_source_and_port_range_check_add_del (vat_main_t * vam) +{ + unformat_input_t *input = vam->input; + vl_api_ip_source_and_port_range_check_add_del_t *mp; + f64 timeout; + + u16 *low_ports = 0; + u16 *high_ports = 0; + u16 this_low; + u16 this_hi; + ip4_address_t ip4_addr; + ip6_address_t ip6_addr; + u32 length; + u32 tmp, tmp2; + u8 prefix_set = 0; + u32 vrf_id = ~0; + u8 is_add = 1; + u8 is_ipv6 = 0; + + while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) + { + if (unformat (input, "%U/%d", unformat_ip4_address, &ip4_addr, &length)) + { + prefix_set = 1; + } + else + if (unformat + (input, "%U/%d", unformat_ip6_address, &ip6_addr, &length)) + { + prefix_set = 1; + is_ipv6 = 1; + } + else if (unformat (input, "vrf %d", &vrf_id)) + ; + else if (unformat (input, "del")) + is_add = 0; + else if (unformat (input, "port %d", &tmp)) + { + if (tmp == 0 || tmp > 65535) + { + errmsg ("port %d out of range", tmp); + return -99; + } + this_low = tmp; + this_hi = this_low + 1; + vec_add1 (low_ports, this_low); + vec_add1 (high_ports, this_hi); + } + else if (unformat (input, "range %d - %d", &tmp, &tmp2)) + { + if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535)) + { + errmsg ("incorrect range parameters"); + return -99; + } + this_low = tmp; + /* Note: in debug CLI +1 is added to high before + passing to real fn that does "the work" + (ip_source_and_port_range_check_add_del). + This fn is a wrapper around the binary API fn a + control plane will call, which expects this increment + to have occurred. Hence letting the binary API control + plane fn do the increment for consistency between VAT + and other control planes. + */ + this_hi = tmp2; + vec_add1 (low_ports, this_low); + vec_add1 (high_ports, this_hi); + } + else + break; + } + + if (prefix_set == 0) + { + errmsg ("
/ not specified"); + return -99; + } + + if (vrf_id == ~0) + { + errmsg ("VRF ID required, not specified"); + return -99; + } + + if (vrf_id == 0) + { + errmsg + ("VRF ID should not be default. Should be distinct VRF for this purpose."); + return -99; + } + + if (vec_len (low_ports) == 0) + { + errmsg ("At least one port or port range required"); + return -99; + } + + M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, + ip_source_and_port_range_check_add_del); + + mp->is_add = is_add; + + if (is_ipv6) + { + mp->is_ipv6 = 1; + clib_memcpy (mp->address, &ip6_addr, sizeof (ip6_addr)); + } + else + { + mp->is_ipv6 = 0; + clib_memcpy (mp->address, &ip4_addr, sizeof (ip4_addr)); + } + + mp->mask_length = length; + mp->number_of_ranges = vec_len (low_ports); + + clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports)); + vec_free (low_ports); + + clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports)); + vec_free (high_ports); + + mp->vrf_id = ntohl (vrf_id); + + S; + W; + /* NOTREACHED */ + return 0; +} + +int +api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam) +{ + unformat_input_t *input = vam->input; + vl_api_ip_source_and_port_range_check_interface_add_del_t *mp; + f64 timeout; + u32 sw_if_index = ~0; + int vrf_set = 0; + u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0; + u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0; + u8 is_add = 1; + + while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) + { + if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index)) + ; + else if (unformat (input, "sw_if_index %d", &sw_if_index)) + ; + else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id)) + vrf_set = 1; + else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id)) + vrf_set = 1; + else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id)) + vrf_set = 1; + else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id)) + vrf_set = 1; + else if (unformat (input, "del")) + is_add = 0; + else + break; + } + + if (sw_if_index == ~0) + { + errmsg ("Interface required but not specified"); + return -99; + } + + if (vrf_set == 0) + { + errmsg ("VRF ID required but not specified"); + return -99; + } + + if (tcp_out_vrf_id == 0 + || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0) + { + errmsg + ("VRF ID should not be default. Should be distinct VRF for this purpose."); + return -99; + } + + /* Construct the API message */ + M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, + ip_source_and_port_range_check_interface_add_del); + + mp->sw_if_index = ntohl (sw_if_index); + mp->is_add = is_add; + mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id); + mp->udp_out_vrf_id = ntohl (udp_out_vrf_id); + mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id); + mp->udp_in_vrf_id = ntohl (udp_in_vrf_id); + + /* send it... */ + S; + + /* Wait for a reply... */ + W; +} + +static int +api_ipsec_gre_add_del_tunnel (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + vl_api_ipsec_gre_add_del_tunnel_t *mp; + f64 timeout; + u32 local_sa_id = 0; + u32 remote_sa_id = 0; + ip4_address_t src_address; + ip4_address_t dst_address; + u8 is_add = 1; + + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "local_sa %d", &local_sa_id)) + ; + else if (unformat (i, "remote_sa %d", &remote_sa_id)) + ; + else if (unformat (i, "src %U", unformat_ip4_address, &src_address)) + ; + else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address)) + ; + else if (unformat (i, "del")) + is_add = 0; + else + { + clib_warning ("parse error '%U'", format_unformat_error, i); + return -99; + } + } + + M (IPSEC_GRE_ADD_DEL_TUNNEL, ipsec_gre_add_del_tunnel); + + mp->local_sa_id = ntohl (local_sa_id); + mp->remote_sa_id = ntohl (remote_sa_id); + clib_memcpy (mp->src_address, &src_address, sizeof (src_address)); + clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address)); + mp->is_add = is_add; + + S; + W; + /* NOTREACHED */ + return 0; +} + +static int +api_punt (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + vl_api_punt_t *mp; + f64 timeout; + u32 ipv = ~0; + u32 protocol = ~0; + u32 port = ~0; + int is_add = 1; + + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "ip %d", &ipv)) + ; + else if (unformat (i, "protocol %d", &protocol)) + ; + else if (unformat (i, "port %d", &port)) + ; + else if (unformat (i, "del")) + is_add = 0; + else + { + clib_warning ("parse error '%U'", format_unformat_error, i); + return -99; + } + } + + M (PUNT, punt); + + mp->is_add = (u8) is_add; + mp->ipv = (u8) ipv; + mp->l4_protocol = (u8) protocol; + mp->l4_port = htons ((u16) port); + + S; + W; + /* NOTREACHED */ + return 0; +} + +static void vl_api_ipsec_gre_tunnel_details_t_handler + (vl_api_ipsec_gre_tunnel_details_t * mp) +{ + vat_main_t *vam = &vat_main; + + print (vam->ofp, "%11d%15U%15U%14d%14d", + ntohl (mp->sw_if_index), + format_ip4_address, &mp->src_address, + format_ip4_address, &mp->dst_address, + ntohl (mp->local_sa_id), ntohl (mp->remote_sa_id)); +} + +static void vl_api_ipsec_gre_tunnel_details_t_handler_json + (vl_api_ipsec_gre_tunnel_details_t * mp) +{ + vat_main_t *vam = &vat_main; + vat_json_node_t *node = NULL; + struct in_addr ip4; + + if (VAT_JSON_ARRAY != vam->json_tree.type) + { + ASSERT (VAT_JSON_NONE == vam->json_tree.type); + vat_json_init_array (&vam->json_tree); + } + node = vat_json_array_add (&vam->json_tree); + + vat_json_init_object (node); + vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index)); + clib_memcpy (&ip4, &mp->src_address, sizeof (ip4)); + vat_json_object_add_ip4 (node, "src_address", ip4); + clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4)); + vat_json_object_add_ip4 (node, "dst_address", ip4); + vat_json_object_add_uint (node, "local_sa_id", ntohl (mp->local_sa_id)); + vat_json_object_add_uint (node, "remote_sa_id", ntohl (mp->remote_sa_id)); +} + +static int +api_ipsec_gre_tunnel_dump (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + vl_api_ipsec_gre_tunnel_dump_t *mp; + f64 timeout; + u32 sw_if_index; + u8 sw_if_index_set = 0; + + /* Parse args required to build the message */ + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "sw_if_index %d", &sw_if_index)) + sw_if_index_set = 1; + else + break; + } + + if (sw_if_index_set == 0) + { + sw_if_index = ~0; + } + + if (!vam->json_output) + { + print (vam->ofp, "%11s%15s%15s%14s%14s", + "sw_if_index", "src_address", "dst_address", + "local_sa_id", "remote_sa_id"); + } + + /* Get list of gre-tunnel interfaces */ + M (IPSEC_GRE_TUNNEL_DUMP, ipsec_gre_tunnel_dump); + + mp->sw_if_index = htonl (sw_if_index); + + S; + + /* Use a control ping for synchronization */ + { + vl_api_control_ping_t *mp; + M (CONTROL_PING, control_ping); + S; + } + W; +} + +static int +api_delete_subif (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + vl_api_delete_subif_t *mp; + f64 timeout; + u32 sw_if_index = ~0; + + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index)) + ; + if (unformat (i, "sw_if_index %d", &sw_if_index)) + ; + else + break; + } + + if (sw_if_index == ~0) + { + errmsg ("missing sw_if_index"); + return -99; + } + + /* Construct the API message */ + M (DELETE_SUBIF, delete_subif); + mp->sw_if_index = ntohl (sw_if_index); + + S; + W; +} + +#define foreach_pbb_vtr_op \ +_("disable", L2_VTR_DISABLED) \ +_("pop", L2_VTR_POP_2) \ +_("push", L2_VTR_PUSH_2) + +static int +api_l2_interface_pbb_tag_rewrite (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + vl_api_l2_interface_pbb_tag_rewrite_t *mp; + f64 timeout; + u32 sw_if_index = ~0, vtr_op = ~0; + u16 outer_tag = ~0; + u8 dmac[6], smac[6]; + u8 dmac_set = 0, smac_set = 0; + u16 vlanid = 0; + u32 sid = ~0; + u32 tmp; + + /* Shut up coverity */ + memset (dmac, 0, sizeof (dmac)); + memset (smac, 0, sizeof (smac)); + + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index)) + ; + else if (unformat (i, "sw_if_index %d", &sw_if_index)) + ; + else if (unformat (i, "vtr_op %d", &vtr_op)) + ; +#define _(n,v) else if (unformat(i, n)) {vtr_op = v;} + foreach_pbb_vtr_op +#undef _ + else if (unformat (i, "translate_pbb_stag")) + { + if (unformat (i, "%d", &tmp)) + { + vtr_op = L2_VTR_TRANSLATE_2_1; + outer_tag = tmp; + } + else + { + errmsg + ("translate_pbb_stag operation requires outer tag definition"); + return -99; + } + } + else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac)) + dmac_set++; + else if (unformat (i, "smac %U", unformat_ethernet_address, smac)) + smac_set++; + else if (unformat (i, "sid %d", &sid)) + ; + else if (unformat (i, "vlanid %d", &tmp)) + vlanid = tmp; + else + { + clib_warning ("parse error '%U'", format_unformat_error, i); + return -99; + } + } + + if ((sw_if_index == ~0) || (vtr_op == ~0)) + { + errmsg ("missing sw_if_index or vtr operation"); + return -99; + } + if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2)) + && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0))) + { + errmsg + ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid"); + return -99; + } + + M (L2_INTERFACE_PBB_TAG_REWRITE, l2_interface_pbb_tag_rewrite); + mp->sw_if_index = ntohl (sw_if_index); + mp->vtr_op = ntohl (vtr_op); + mp->outer_tag = ntohs (outer_tag); + clib_memcpy (mp->b_dmac, dmac, sizeof (dmac)); + clib_memcpy (mp->b_smac, smac, sizeof (smac)); + mp->b_vlanid = ntohs (vlanid); + mp->i_sid = ntohl (sid); + + S; + W; + /* NOTREACHED */ + return 0; +} + +static int +api_flow_classify_set_interface (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + vl_api_flow_classify_set_interface_t *mp; + f64 timeout; + u32 sw_if_index; + int sw_if_index_set; + u32 ip4_table_index = ~0; + u32 ip6_table_index = ~0; + u8 is_add = 1; + + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index)) + sw_if_index_set = 1; + else if (unformat (i, "sw_if_index %d", &sw_if_index)) + sw_if_index_set = 1; + else if (unformat (i, "del")) + is_add = 0; + else if (unformat (i, "ip4-table %d", &ip4_table_index)) + ; + else if (unformat (i, "ip6-table %d", &ip6_table_index)) + ; + else + { + clib_warning ("parse error '%U'", format_unformat_error, i); + return -99; + } + } + + if (sw_if_index_set == 0) + { + errmsg ("missing interface name or sw_if_index"); + return -99; + } + + M (FLOW_CLASSIFY_SET_INTERFACE, flow_classify_set_interface); + + mp->sw_if_index = ntohl (sw_if_index); + mp->ip4_table_index = ntohl (ip4_table_index); + mp->ip6_table_index = ntohl (ip6_table_index); + mp->is_add = is_add; + + S; + W; + /* NOTREACHED */ + return 0; +} + +static int +api_flow_classify_dump (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + vl_api_flow_classify_dump_t *mp; + f64 timeout = ~0; + u8 type = FLOW_CLASSIFY_N_TABLES; + + if (unformat (i, "type %U", unformat_flow_classify_table_type, &type)) + ; + else + { + errmsg ("classify table type must be specified"); + return -99; + } + + if (!vam->json_output) + { + print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table"); + } + + M (FLOW_CLASSIFY_DUMP, flow_classify_dump); + mp->type = type; + /* send it... */ + S; + + /* Use a control ping for synchronization */ + { + vl_api_control_ping_t *mp; + M (CONTROL_PING, control_ping); + S; + } + /* Wait for a reply... */ + W; + + /* NOTREACHED */ + return 0; +} + +static int +api_feature_enable_disable (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + vl_api_feature_enable_disable_t *mp; + f64 timeout; + u8 *arc_name = 0; + u8 *feature_name = 0; + u32 sw_if_index = ~0; + u8 enable = 1; + + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "arc_name %s", &arc_name)) + ; + else if (unformat (i, "feature_name %s", &feature_name)) + ; + else + if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index)) + ; + else if (unformat (i, "sw_if_index %d", &sw_if_index)) + ; + else if (unformat (i, "disable")) + enable = 0; + else + break; + } + + if (arc_name == 0) + { + errmsg ("missing arc name"); + return -99; + } + if (vec_len (arc_name) > 63) + { + errmsg ("arc name too long"); + } + + if (feature_name == 0) + { + errmsg ("missing feature name"); + return -99; + } + if (vec_len (feature_name) > 63) + { + errmsg ("feature name too long"); + } + + if (sw_if_index == ~0) + { + errmsg ("missing interface name or sw_if_index"); + return -99; + } + + /* Construct the API message */ + M (FEATURE_ENABLE_DISABLE, feature_enable_disable); + mp->sw_if_index = ntohl (sw_if_index); + mp->enable = enable; + clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name)); + clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name)); + vec_free (arc_name); + vec_free (feature_name); + + S; + W; +} + +static int +api_sw_interface_tag_add_del (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + vl_api_sw_interface_tag_add_del_t *mp; + f64 timeout; + u32 sw_if_index = ~0; + u8 *tag = 0; + u8 enable = 1; + + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "tag %s", &tag)) + ; + if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index)) + ; + else if (unformat (i, "sw_if_index %d", &sw_if_index)) + ; + else if (unformat (i, "del")) + enable = 0; + else + break; + } + + if (sw_if_index == ~0) + { + errmsg ("missing interface name or sw_if_index"); + return -99; + } + + if (enable && (tag == 0)) + { + errmsg ("no tag specified"); + return -99; + } + + /* Construct the API message */ + M (SW_INTERFACE_TAG_ADD_DEL, sw_interface_tag_add_del); + mp->sw_if_index = ntohl (sw_if_index); + mp->is_add = enable; + if (enable) + strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1); + vec_free (tag); + + S; + W; +} + +static void vl_api_l2_xconnect_details_t_handler + (vl_api_l2_xconnect_details_t * mp) +{ + vat_main_t *vam = &vat_main; + + print (vam->ofp, "%15d%15d", + ntohl (mp->rx_sw_if_index), ntohl (mp->tx_sw_if_index)); +} + +static void vl_api_l2_xconnect_details_t_handler_json + (vl_api_l2_xconnect_details_t * mp) +{ + vat_main_t *vam = &vat_main; + vat_json_node_t *node = NULL; + + if (VAT_JSON_ARRAY != vam->json_tree.type) + { + ASSERT (VAT_JSON_NONE == vam->json_tree.type); + vat_json_init_array (&vam->json_tree); + } + node = vat_json_array_add (&vam->json_tree); + + vat_json_init_object (node); + vat_json_object_add_uint (node, "rx_sw_if_index", + ntohl (mp->rx_sw_if_index)); + vat_json_object_add_uint (node, "tx_sw_if_index", + ntohl (mp->tx_sw_if_index)); +} + +static int +api_l2_xconnect_dump (vat_main_t * vam) +{ + vl_api_l2_xconnect_dump_t *mp; + f64 timeout; + + if (!vam->json_output) + { + print (vam->ofp, "%15s%15s", "rx_sw_if_index", "tx_sw_if_index"); + } + + M (L2_XCONNECT_DUMP, l2_xconnect_dump); + + S; + + /* Use a control ping for synchronization */ + { + vl_api_control_ping_t *mp; + M (CONTROL_PING, control_ping); + S; + } + W; +} + +static int +api_sw_interface_set_mtu (vat_main_t * vam) +{ + unformat_input_t *i = vam->input; + vl_api_sw_interface_set_mtu_t *mp; + f64 timeout; + u32 sw_if_index = ~0; + u32 mtu = 0; + + while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + { + if (unformat (i, "mtu %d", &mtu)) + ; + if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index)) + ; + else if (unformat (i, "sw_if_index %d", &sw_if_index)) + ; + else + break; + } + + if (sw_if_index == ~0) + { + errmsg ("missing interface name or sw_if_index"); + return -99; + } + + if (mtu == 0) + { + errmsg ("no mtu specified"); + return -99; + } + + /* Construct the API message */ + M (SW_INTERFACE_SET_MTU, sw_interface_set_mtu); + mp->sw_if_index = ntohl (sw_if_index); + mp->mtu = ntohs ((u16) mtu); + + S; + W; +} + + +static int +q_or_quit (vat_main_t * vam) +{ + longjmp (vam->jump_buf, 1); + return 0; /* not so much */ +} + +static int +q (vat_main_t * vam) +{ + return q_or_quit (vam); +} + +static int +quit (vat_main_t * vam) +{ + return q_or_quit (vam); +} + +static int +comment (vat_main_t * vam) +{ + return 0; +} + +static int +cmd_cmp (void *a1, void *a2) +{ + u8 **c1 = a1; + u8 **c2 = a2; + + return strcmp ((char *) (c1[0]), (char *) (c2[0])); +} + +static int +help (vat_main_t * vam) +{ + u8 **cmds = 0; + u8 *name = 0; + hash_pair_t *p; + unformat_input_t *i = vam->input; + int j; + + if (unformat (i, "%s", &name)) + { + uword *hs; + + vec_add1 (name, 0); + + hs = hash_get_mem (vam->help_by_name, name); + if (hs) + print (vam->ofp, "usage: %s %s", name, hs[0]); + else + print (vam->ofp, "No such msg / command '%s'", name); + vec_free (name); + return 0; + } + + print (vam->ofp, "Help is available for the following:"); + + /* *INDENT-OFF* */ + hash_foreach_pair (p, vam->function_by_name, + ({ + vec_add1 (cmds, (u8 *)(p->key)); + })); + /* *INDENT-ON* */ + + vec_sort_with_function (cmds, cmd_cmp); + + for (j = 0; j < vec_len (cmds); j++) + print (vam->ofp, "%s", cmds[j]); + + vec_free (cmds); + return 0; +} + +static int +set (vat_main_t * vam) +{ + u8 *name = 0, *value = 0; + unformat_input_t *i = vam->input; + + if (unformat (i, "%s", &name)) + { + /* The input buffer is a vector, not a string. */ + value = vec_dup (i->buffer); + vec_delete (value, i->index, 0); + /* Almost certainly has a trailing newline */ + if (value[vec_len (value) - 1] == '\n') + value[vec_len (value) - 1] = 0; + /* Make sure it's a proper string, one way or the other */ + vec_add1 (value, 0); + (void) clib_macro_set_value (&vam->macro_main, + (char *) name, (char *) value); + } + else + errmsg ("usage: set "); + + vec_free (name); + vec_free (value); + return 0; +} + +static int +unset (vat_main_t * vam) +{ + u8 *name = 0; + + if (unformat (vam->input, "%s", &name)) + if (clib_macro_unset (&vam->macro_main, (char *) name) == 1) + errmsg ("unset: %s wasn't set", name); + vec_free (name); + return 0; +} + +typedef struct +{ + u8 *name; + u8 *value; +} macro_sort_t; + + +static int +macro_sort_cmp (void *a1, void *a2) +{ + macro_sort_t *s1 = a1; + macro_sort_t *s2 = a2; + + return strcmp ((char *) (s1->name), (char *) (s2->name)); +} + +static int +dump_macro_table (vat_main_t * vam) +{ + macro_sort_t *sort_me = 0, *sm; + int i; + hash_pair_t *p; + + /* *INDENT-OFF* */ + hash_foreach_pair (p, vam->macro_main.the_value_table_hash, + ({ + vec_add2 (sort_me, sm, 1); + sm->name = (u8 *)(p->key); + sm->value = (u8 *) (p->value[0]); + })); + /* *INDENT-ON* */ + + vec_sort_with_function (sort_me, macro_sort_cmp); + + if (vec_len (sort_me)) + print (vam->ofp, "%-15s%s", "Name", "Value"); + else + print (vam->ofp, "The macro table is empty..."); + + for (i = 0; i < vec_len (sort_me); i++) + print (vam->ofp, "%-15s%s", sort_me[i].name, sort_me[i].value); + return 0; +} + +static int +dump_node_table (vat_main_t * vam) +{ + int i, j; + vlib_node_t *node, *next_node; + + if (vec_len (vam->graph_nodes) == 0) + { + print (vam->ofp, "Node table empty, issue get_node_graph..."); + return 0; + } + + for (i = 0; i < vec_len (vam->graph_nodes); i++) + { + node = vam->graph_nodes[i]; + print (vam->ofp, "[%d] %s", i, node->name); + for (j = 0; j < vec_len (node->next_nodes); j++) + { + if (node->next_nodes[j] != ~0) + { + next_node = vam->graph_nodes[node->next_nodes[j]]; + print (vam->ofp, " [%d] %s", j, next_node->name); + } + } + } + return 0; +} + +static int +value_sort_cmp (void *a1, void *a2) +{ + name_sort_t *n1 = a1; + name_sort_t *n2 = a2; + + if (n1->value < n2->value) + return -1; + if (n1->value > n2->value) + return 1; + return 0; +} + + +static int +dump_msg_api_table (vat_main_t * vam) +{ + api_main_t *am = &api_main; + name_sort_t *nses = 0, *ns; + hash_pair_t *hp; + int i; + + /* *INDENT-OFF* */ + hash_foreach_pair (hp, am->msg_index_by_name_and_crc, + ({ + vec_add2 (nses, ns, 1); + ns->name = (u8 *)(hp->key); + ns->value = (u32) hp->value[0]; + })); + /* *INDENT-ON* */ + + vec_sort_with_function (nses, value_sort_cmp); + + for (i = 0; i < vec_len (nses); i++) + print (vam->ofp, " [%d]: %s", nses[i].value, nses[i].name); + vec_free (nses); + return 0; +} + +static int +get_msg_id (vat_main_t * vam) +{ + u8 *name_and_crc; + u32 message_index; + + if (unformat (vam->input, "%s", &name_and_crc)) + { + message_index = vl_api_get_msg_index (name_and_crc); + if (message_index == ~0) + { + print (vam->ofp, " '%s' not found", name_and_crc); + return 0; + } + print (vam->ofp, " '%s' has message index %d", + name_and_crc, message_index); + return 0; + } + errmsg ("name_and_crc required..."); + return 0; +} + +static int +search_node_table (vat_main_t * vam) +{ + unformat_input_t *line_input = vam->input; + u8 *node_to_find; + int j; + vlib_node_t *node, *next_node; + uword *p; + + if (vam->graph_node_index_by_name == 0) + { + print (vam->ofp, "Node table empty, issue get_node_graph..."); + return 0; + } + + while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) + { + if (unformat (line_input, "%s", &node_to_find)) + { + vec_add1 (node_to_find, 0); + p = hash_get_mem (vam->graph_node_index_by_name, node_to_find); + if (p == 0) + { + print (vam->ofp, "%s not found...", node_to_find); + goto out; + } + node = vam->graph_nodes[p[0]]; + print (vam->ofp, "[%d] %s", p[0], node->name); + for (j = 0; j < vec_len (node->next_nodes); j++) + { + if (node->next_nodes[j] != ~0) + { + next_node = vam->graph_nodes[node->next_nodes[j]]; + print (vam->ofp, " [%d] %s", j, next_node->name); + } + } + } + + else + { + clib_warning ("parse error '%U'", format_unformat_error, + line_input); + return -99; + } + + out: + vec_free (node_to_find); + + } + + return 0; +} + + +static int +script (vat_main_t * vam) +{ +#if (VPP_API_TEST_BUILTIN==0) + u8 *s = 0; + char *save_current_file; + unformat_input_t save_input; + jmp_buf save_jump_buf; + u32 save_line_number; + + FILE *new_fp, *save_ifp; + + if (unformat (vam->input, "%s", &s)) + { + new_fp = fopen ((char *) s, "r"); + if (new_fp == 0) + { + errmsg ("Couldn't open script file %s", s); + vec_free (s); + return -99; + } + } + else + { + errmsg ("Missing script name"); + return -99; + } + + clib_memcpy (&save_input, &vam->input, sizeof (save_input)); + clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf)); + save_ifp = vam->ifp; + save_line_number = vam->input_line_number; + save_current_file = (char *) vam->current_file; + + vam->input_line_number = 0; + vam->ifp = new_fp; + vam->current_file = s; + do_one_file (vam); + + clib_memcpy (&vam->input, &save_input, sizeof (vam->input)); + clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf)); + vam->ifp = save_ifp; + vam->input_line_number = save_line_number; + vam->current_file = (u8 *) save_current_file; + vec_free (s); + + return 0; +#else + clib_warning ("use the exec command..."); + return -99; +#endif +} + +static int +echo (vat_main_t * vam) +{ + print (vam->ofp, "%v", vam->input->buffer); + return 0; +} + +/* List of API message constructors, CLI names map to api_xxx */ +#define foreach_vpe_api_msg \ +_(create_loopback,"[mac ]") \ +_(sw_interface_dump,"") \ +_(sw_interface_set_flags, \ + " | sw_if_index admin-up | admin-down link-up | link down") \ +_(sw_interface_add_del_address, \ + " | sw_if_index | [del] [del-all] ") \ +_(sw_interface_set_table, \ + " | sw_if_index vrf [ipv6]") \ +_(sw_interface_set_mpls_enable, \ + " | sw_if_index [disable | dis]") \ +_(sw_interface_set_vpath, \ + " | sw_if_index enable | disable") \ +_(sw_interface_set_vxlan_bypass, \ + " | sw_if_index [ip4 | ip6] enable | disable") \ +_(sw_interface_set_l2_xconnect, \ + "rx | rx_sw_if_index tx | tx_sw_if_index \n" \ + "enable | disable") \ +_(sw_interface_set_l2_bridge, \ + " | sw_if_index bd_id \n" \ + "[shg ] [bvi]\n" \ + "enable | disable") \ +_(sw_interface_set_dpdk_hqos_pipe, \ + "rx | sw_if_index subport pipe \n" \ + "profile \n") \ +_(sw_interface_set_dpdk_hqos_subport, \ + "rx | sw_if_index subport [rate ]\n" \ + "[bktsize ] [tc0 ] [tc1 ] [tc2 ] [tc3 ] [period ]\n") \ +_(sw_interface_set_dpdk_hqos_tctbl, \ + "rx | sw_if_index entry tc queue \n") \ +_(bridge_domain_add_del, \ + "bd_id [flood 1|0] [uu-flood 1|0] [forward 1|0] [learn 1|0] [arp-term 1|0] [del]\n") \ +_(bridge_domain_dump, "[bd_id ]\n") \ +_(l2fib_add_del, \ + "mac bd_id [del] | sw_if | sw_if_index [static] [filter] [bvi] [count ]\n") \ +_(l2_flags, \ + "sw_if | sw_if_index [learn] [forward] [uu-flood] [flood]\n") \ +_(bridge_flags, \ + "bd_id [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \ +_(tap_connect, \ + "tapname mac | random-mac [tag ]") \ +_(tap_modify, \ + " | sw_if_index tapname mac | random-mac") \ +_(tap_delete, \ + " | sw_if_index ") \ +_(sw_interface_tap_dump, "") \ +_(ip_add_del_route, \ + "/ via [table-id ]\n" \ + "[ | sw_if_index ] [resolve-attempts ]\n" \ + "[weight ] [drop] [local] [classify ] [del]\n" \ + "[multipath] [count ]") \ +_(mpls_route_add_del, \ + "