From: Sebastian Harl Date: Sun, 6 Sep 2009 12:52:15 +0000 (+0000) Subject: Merged branch 'sh/collectd-4.6' into sh/collectd-4.7. X-Git-Tag: collectd-4.7.3~2 X-Git-Url: https://git.octo.it/?p=collectd.git;a=commitdiff_plain;h=658c85755ef1f4284228d1e5edbc4452a31bd944 Merged branch 'sh/collectd-4.6' into sh/collectd-4.7. Conflicts: src/iptables.c To resolve the conflict, the changes to the iptables plugin have been updated to support ip6tc as well. --- 658c85755ef1f4284228d1e5edbc4452a31bd944 diff --cc configure.in index 3f3012bd,9b08ef9a..3db4db36 --- a/configure.in +++ b/configure.in @@@ -1489,197 -1304,24 +1489,215 @@@ if test "x$with_own_libiptc" = "xyes then AC_DEFINE(OWN_LIBIPTC, 1, [Define to 1 if we use the shipped iptc library.]) fi + if test "x$with_libiptc" = "xyes" + then + SAVE_CFLAGS=$CFLAGS + CFLAGS="$CFLAGS $KERNEL_CFLAGS" + - AC_CHECK_TYPES([iptc_handle_t], [], [], ++ AC_CHECK_TYPES([iptc_handle_t, ip6tc_handle_t], [], [], + [ + #if OWN_LIBIPTC + # include "$srcdir/src/owniptc/libiptc.h" ++# include "$srcdir/src/owniptc/libip6tc.h" + #else + # include ++# include + #endif + ]) + + CFLAGS=$SAVE_CFLAGS + fi # }}} +# --with-java {{{ +with_java_home="$JAVA_HOME" +with_java_vmtype="client" +with_java_cflags="" +with_java_libs="" +JAVAC="$JAVAC" +AC_ARG_WITH(java, [AS_HELP_STRING([--with-java@<:@=PREFIX@:>@], [Path to Java home.])], +[ + if test "x$withval" = "xno" + then + with_java="no" + else if test "x$withval" = "xyes" + then + with_java="yes" + else + with_java_home="$withval" + with_java="yes" + fi; fi +], +[with_java="yes"]) +if test "x$with_java" = "xyes" +then + if test -d "$with_java_home" + then + AC_MSG_CHECKING([for jni.h]) + TMPDIR=`find -L "$with_java_home" -name jni.h -type f -exec 'dirname' '{}' ';' | head -n 1` + if test "x$TMPDIR" != "x" + then + AC_MSG_RESULT([found in $TMPDIR]) + JAVA_CPPFLAGS="$JAVA_CPPFLAGS -I$TMPDIR" + else + AC_MSG_RESULT([not found]) + fi + + AC_MSG_CHECKING([for jni_md.h]) + TMPDIR=`find -L "$with_java_home" -name jni_md.h -type f -exec 'dirname' '{}' ';' | head -n 1` + if test "x$TMPDIR" != "x" + then + AC_MSG_RESULT([found in $TMPDIR]) + JAVA_CPPFLAGS="$JAVA_CPPFLAGS -I$TMPDIR" + else + AC_MSG_RESULT([not found]) + fi + + AC_MSG_CHECKING([for libjvm.so]) + TMPDIR=`find -L "$with_java_home" -name libjvm.so -type f -exec 'dirname' '{}' ';' | head -n 1` + if test "x$TMPDIR" != "x" + then + AC_MSG_RESULT([found in $TMPDIR]) + JAVA_LDFLAGS="$JAVA_LDFLAGS -L$TMPDIR -Wl,-rpath -Wl,$TMPDIR" + else + AC_MSG_RESULT([not found]) + fi + + if test "x$JAVAC" = "x" + then + AC_MSG_CHECKING([for javac]) + TMPDIR=`find -L "$with_java_home" -name javac -type f | head -n 1` + if test "x$TMPDIR" != "x" + then + JAVAC="$TMPDIR" + AC_MSG_RESULT([$JAVAC]) + else + AC_MSG_RESULT([not found]) + fi + fi + else if test "x$with_java_home" != "x" + then + AC_MSG_WARN([JAVA_HOME: No such directory: $with_java_home]) + fi; fi +fi + +if test "x$JAVA_CPPFLAGS" != "x" +then + AC_MSG_NOTICE([Building with JAVA_CPPFLAGS set to: $JAVA_CPPFLAGS]) +fi +if test "x$JAVA_CFLAGS" != "x" +then + AC_MSG_NOTICE([Building with JAVA_CFLAGS set to: $JAVA_CFLAGS]) +fi +if test "x$JAVA_LDFLAGS" != "x" +then + AC_MSG_NOTICE([Building with JAVA_LDFLAGS set to: $JAVA_LDFLAGS]) +fi +if test "x$JAVAC" = "x" +then + with_javac_path="$PATH" + if test "x$with_java_home" != "x" + then + with_javac_path="$with_java_home:with_javac_path" + if test -d "$with_java_home/bin" + then + with_javac_path="$with_java_home/bin:with_javac_path" + fi + fi + + AC_PATH_PROG(JAVAC, javac, [], "$with_javac_path") +fi +if test "x$JAVAC" = "x" +then + with_java="no (javac not found)" +fi + +SAVE_CPPFLAGS="$CPPFLAGS" +SAVE_CFLAGS="$CFLAGS" +SAVE_LDFLAGS="$LDFLAGS" +CPPFLAGS="$CPPFLAGS $JAVA_CPPFLAGS" +CFLAGS="$CFLAGS $JAVA_CFLAGS" +LDFLAGS="$LDFLAGS $JAVA_LDFLAGS" + +if test "x$with_java" = "xyes" +then + AC_CHECK_HEADERS(jni.h, [], [with_java="no (jni.h not found)"]) +fi +if test "x$with_java" = "xyes" +then + AC_CHECK_LIB(jvm, JNI_CreateJavaVM, + [with_java="yes"], + [with_java="no (libjvm not found)"], + [$JAVA_LIBS]) +fi +if test "x$with_java" = "xyes" +then + JAVA_LIBS="$JAVA_LIBS -ljvm" + AC_MSG_NOTICE([Building with JAVA_LIBS set to: $JAVA_LIBS]) +fi + +CPPFLAGS="$SAVE_CPPFLAGS" +CFLAGS="$SAVE_CFLAGS" +LDFLAGS="$SAVE_LDFLAGS" + +AC_SUBST(JAVA_CPPFLAGS) +AC_SUBST(JAVA_CFLAGS) +AC_SUBST(JAVA_LDFLAGS) +AC_SUBST(JAVA_LIBS) +AM_CONDITIONAL(BUILD_WITH_JAVA, test "x$with_java" = "xyes") +# }}} + +# --with-libmemcached {{{ +with_libmemcached_cppflags="" +with_libmemcached_ldflags="" +AC_ARG_WITH(libmemcached, [AS_HELP_STRING([--with-libmemcached@<:@=PREFIX@:>@], [Path to libmemcached.])], +[ + if test "x$withval" != "xno" && test "x$withval" != "xyes" + then + with_libmemcached_cppflags="-I$withval/include" + with_libmemcached_ldflags="-L$withval/lib" + with_libmemcached="yes" + else + with_libmemcached="$withval" + fi +], +[ + with_libmemcached="yes" +]) +if test "x$with_libmemcached" = "xyes" +then + SAVE_CPPFLAGS="$CPPFLAGS" + CPPFLAGS="$CPPFLAGS $with_libmemcached_cppflags" + + AC_CHECK_HEADERS(libmemcached/memcached.h, [with_libmemcached="yes"], [with_libmemcached="no (libmemcached/memcached.h not found)"]) + + CPPFLAGS="$SAVE_CPPFLAGS" +fi +if test "x$with_libmemcached" = "xyes" +then + SAVE_CPPFLAGS="$CPPFLAGS" + SAVE_LDFLAGS="$LDFLAGS" + CPPFLAGS="$CPPFLAGS $with_libmemcached_cppflags" + LDFLAGS="$LDFLAGS $with_libmemcached_ldflags" + + AC_CHECK_LIB(memcached, memcached_create, [with_libmemcached="yes"], [with_libmemcached="no (Symbol 'memcached_create' not found)"]) + + CPPFLAGS="$SAVE_CPPFLAGS" + LDFLAGS="$SAVE_LDFLAGS" +fi +if test "x$with_libmemcached" = "xyes" +then + BUILD_WITH_LIBMEMCACHED_CPPFLAGS="$with_libmemcached_cppflags" + BUILD_WITH_LIBMEMCACHED_LDFLAGS="$with_libmemcached_ldflags" + BUILD_WITH_LIBMEMCACHED_LIBS="-lmemcached" + AC_SUBST(BUILD_WITH_LIBMEMCACHED_CPPFLAGS) + AC_SUBST(BUILD_WITH_LIBMEMCACHED_LDFLAGS) + AC_SUBST(BUILD_WITH_LIBMEMCACHED_LIBS) + AC_DEFINE(HAVE_LIBMEMCACHED, 1, [Define if libmemcached is present and usable.]) +fi +AM_CONDITIONAL(BUILD_WITH_LIBMEMCACHED, test "x$with_libmemcached" = "xyes") +# }}} + # --with-libmysql {{{ with_mysql_config="mysql_config" with_mysql_cflags="" diff --cc src/iptables.c index 534a8c2a,a81dfd7e..69cd39c4 --- a/src/iptables.c +++ b/src/iptables.c @@@ -40,6 -34,22 +40,25 @@@ #endif /* + * iptc_handle_t was available before libiptc was officially available as a + * shared library. Note, that when the shared lib was introduced, the API and + * ABI have changed slightly: + * 'iptc_handle_t' used to be 'struct iptc_handle *' and most functions used + * 'iptc_handle_t *' as an argument. Now, most functions use 'struct + * iptc_handle *' (thus removing one level of pointer indirection). + * + * HAVE_IPTC_HANDLE_T is used to determine which API ought to be used. While + * this is somewhat hacky, I didn't find better way to solve that :-/ + * -tokkee + */ + #ifndef HAVE_IPTC_HANDLE_T + typedef struct iptc_handle iptc_handle_t; + #endif ++#ifndef HAVE_IP6TC_HANDLE_T ++typedef struct ip6tc_handle ip6tc_handle_t; ++#endif + + /* * (Module-)Global variables */ @@@ -427,40 -322,21 +446,54 @@@ static int iptables_read (void continue; } + if ( chain->ip_version == IPV4 ) + { - iptc_handle_t handle; + #ifdef HAVE_IPTC_HANDLE_T - *handle = iptc_init (chain->table); ++ iptc_handle_t _handle; ++ iptc_handle_t *handle = &_handle; ++ ++ *handle = iptc_init (chain->table); + #else - handle = iptc_init (chain->table); ++ iptc_handle_t *handle; + handle = iptc_init (chain->table); + #endif - if (!handle) - { - ERROR ("iptables plugin: iptc_init (%s) failed: %s", - chain->table, iptc_strerror (errno)); - num_failures++; - continue; - } - submit_chain (handle, chain); - iptc_free (handle); + if (!handle) + { + ERROR ("iptables plugin: iptc_init (%s) failed: %s", + chain->table, iptc_strerror (errno)); + num_failures++; + continue; + } + - submit_chain (&handle, chain); - iptc_free (&handle); ++ submit_chain (handle, chain); ++ iptc_free (handle); + } + else if ( chain->ip_version == IPV6 ) + { - ip6tc_handle_t handle; ++#ifdef HAVE_IP6TC_HANDLE_T ++ ip6tc_handle_t _handle; ++ ip6tc_handle_t *handle = &_handle; ++ ++ *handle = ip6tc_init (chain->table); ++#else ++ ip6tc_handle_t *handle; + handle = ip6tc_init (chain->table); ++#endif + + if (!handle) + { + ERROR ("iptables plugin: ip6tc_init (%s) failed: %s", + chain->table, ip6tc_strerror (errno)); + num_failures++; + continue; + } + - submit6_chain (&handle, chain); - ip6tc_free (&handle); ++ submit6_chain (handle, chain); ++ ip6tc_free (handle); + } + else num_failures++; + } /* for (i = 0 .. chain_num) */ return ((num_failures < chain_num) ? 0 : -1);