-dnl aclocal.m4 generated automatically by aclocal 1.4-p5
+dnl ./aclocal.m4 generated automatically by aclocal 1.4-p5
dnl Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
# This is just to silence aclocal about the macro not being used
ifelse([AC_DISABLE_FAST_INSTALL])
+# Define a conditional.
+
+AC_DEFUN([AM_CONDITIONAL],
+[AC_SUBST($1_TRUE)
+AC_SUBST($1_FALSE)
+if $2; then
+ $1_TRUE=
+ $1_FALSE='#'
+else
+ $1_TRUE='#'
+ $1_FALSE=
+fi])
+
dnl PKG_CHECK_MODULES(GSTUFF, gtk+-2.0 >= 1.3 glib = 1.3.4, action-if, action-not)
dnl defines GSTUFF_LIBS, GSTUFF_CFLAGS, see pkg-config man page
+dnl
+dnl AM_PATH_CPPUNIT(MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
+dnl
+AC_DEFUN(AM_PATH_CPPUNIT,
+[
+
+AC_ARG_WITH(cppunit-prefix,[ --with-cppunit-prefix=PFX Prefix where CppUnit is installed (optional)],
+ cppunit_config_prefix="$withval", cppunit_config_prefix="")
+AC_ARG_WITH(cppunit-exec-prefix,[ --with-cppunit-exec-prefix=PFX Exec prefix where CppUnit is installed (optional)],
+ cppunit_config_exec_prefix="$withval", cppunit_config_exec_prefix="")
+
+ if test x$cppunit_config_exec_prefix != x ; then
+ cppunit_config_args="$cppunit_config_args --exec-prefix=$cppunit_config_exec_prefix"
+ if test x${CPPUNIT_CONFIG+set} != xset ; then
+ CPPUNIT_CONFIG=$cppunit_config_exec_prefix/bin/cppunit-config
+ fi
+ fi
+ if test x$cppunit_config_prefix != x ; then
+ cppunit_config_args="$cppunit_config_args --prefix=$cppunit_config_prefix"
+ if test x${CPPUNIT_CONFIG+set} != xset ; then
+ CPPUNIT_CONFIG=$cppunit_config_prefix/bin/cppunit-config
+ fi
+ fi
+
+ AC_PATH_PROG(CPPUNIT_CONFIG, cppunit-config, no)
+ cppunit_version_min=$1
+
+ AC_MSG_CHECKING(for Cppunit - version >= $cppunit_version_min)
+ no_cppunit=""
+ if test "$CPPUNIT_CONFIG" = "no" ; then
+ no_cppunit=yes
+ else
+ CPPUNIT_CFLAGS=`$CPPUNIT_CONFIG --cflags`
+ CPPUNIT_LIBS=`$CPPUNIT_CONFIG --libs`
+ cppunit_version=`$CPPUNIT_CONFIG --version`
+
+ cppunit_major_version=`echo $cppunit_version | \
+ sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
+ cppunit_minor_version=`echo $cppunit_version | \
+ sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
+ cppunit_micro_version=`echo $cppunit_version | \
+ sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
+
+ cppunit_major_min=`echo $cppunit_version_min | \
+ sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
+ cppunit_minor_min=`echo $cppunit_version_min | \
+ sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
+ cppunit_micro_min=`echo $cppunit_version_min | \
+ sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
+
+ cppunit_version_proper=`expr \
+ $cppunit_major_version \> $cppunit_major_min \| \
+ $cppunit_major_version \= $cppunit_major_min \& \
+ $cppunit_minor_version \> $cppunit_minor_min \| \
+ $cppunit_major_version \= $cppunit_major_min \& \
+ $cppunit_minor_version \= $cppunit_minor_min \& \
+ $cppunit_micro_version \>= $cppunit_micro_min `
+
+ if test "$cppunit_version_proper" = "1" ; then
+ AC_MSG_RESULT([$cppunit_major_version.$cppunit_minor_version.$cppunit_micro_version])
+ else
+ AC_MSG_RESULT(no)
+ no_cppunit=yes
+ fi
+ fi
+
+ if test "x$no_cppunit" = x ; then
+ ifelse([$2], , :, [$2])
+ else
+ CPPUNIT_CFLAGS=""
+ CPPUNIT_LIBS=""
+ ifelse([$3], , :, [$3])
+ fi
+
+ AC_SUBST(CPPUNIT_CFLAGS)
+ AC_SUBST(CPPUNIT_LIBS)
+])
+
+
+
+
--- /dev/null
+/***************************************************************************
+ * Copyright (C) 2004 by Intra2net AG *
+ * info@intra2net.com *
+ * *
+ ***************************************************************************/
+
+#include <iostream>
+#include <string>
+#include <sstream>
+#include <stdexcept>
+
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/ui/text/TestRunner.h>
+#include <cppunit/extensions/HelperMacros.h>
+
+#include <ipfunc.hxx>
+
+using namespace std;
+using namespace CppUnit;
+
+class ip_range : public TestFixture
+{
+ CPPUNIT_TEST_SUITE(ip_range);
+
+ CPPUNIT_TEST(ConstructIP1);
+ CPPUNIT_TEST(ConstructIP2);
+ CPPUNIT_TEST(ConstructNet1);
+ CPPUNIT_TEST(ConstructNet2);
+ CPPUNIT_TEST(ConstructRange1);
+ CPPUNIT_TEST(ConstructRange2);
+ CPPUNIT_TEST(OverlapIP);
+ CPPUNIT_TEST(OverlapNet1);
+ CPPUNIT_TEST(OverlapNet2);
+ CPPUNIT_TEST(OverlapNet3);
+ CPPUNIT_TEST(OverlapNet4);
+ CPPUNIT_TEST(OverlapRange1);
+ CPPUNIT_TEST(OverlapRange2);
+ CPPUNIT_TEST(OverlapRange3);
+ CPPUNIT_TEST(OverlapRange4);
+ CPPUNIT_TEST(OverlapRange5);
+ CPPUNIT_TEST(OverlapRange6);
+ CPPUNIT_TEST(OverlapRange7);
+ CPPUNIT_TEST(WithinNet1);
+ CPPUNIT_TEST(WithinNet2);
+ CPPUNIT_TEST(WithinNet3);
+ CPPUNIT_TEST(WithinNet4);
+ CPPUNIT_TEST(WithinNet5);
+ CPPUNIT_TEST(WithinNet6);
+ CPPUNIT_TEST(WithinNet7);
+ CPPUNIT_TEST(WithinRange1);
+ CPPUNIT_TEST(WithinRange2);
+ CPPUNIT_TEST(WithinRange3);
+ CPPUNIT_TEST(WithinRange4);
+ CPPUNIT_TEST(WithinRange5);
+ CPPUNIT_TEST(WithinRange6);
+ CPPUNIT_TEST(WithinRange7);
+ CPPUNIT_TEST(WithinRange8);
+ CPPUNIT_TEST(WithinRange9);
+ CPPUNIT_TEST(WithinRange10);
+
+ CPPUNIT_TEST_SUITE_END();
+
+ public:
+ void setUp()
+ {
+ }
+
+ void tearDown()
+ {
+ }
+
+ void ConstructIP1()
+ {
+ IP_RANGE i("192.168.1.1");
+ CPPUNIT_ASSERT_EQUAL(string("192.168.1.1"),i.to_string());
+ }
+
+ void ConstructIP2()
+ {
+ IP_RANGE i(ip_type::IP,"192.168.1.1");
+ CPPUNIT_ASSERT_EQUAL(string("192.168.1.1"),i.to_string());
+ }
+
+ void ConstructNet1()
+ {
+ IP_RANGE i("192.168.1.1/255.255.255.0");
+ CPPUNIT_ASSERT_EQUAL(string("192.168.1.0/255.255.255.0"),i.to_string());
+ }
+
+ void ConstructNet2()
+ {
+ IP_RANGE i(ip_type::NETWORK,"192.168.1.1","255.255.255.0");
+ CPPUNIT_ASSERT_EQUAL(string("192.168.1.0/255.255.255.0"),i.to_string());
+ }
+
+ void ConstructRange1()
+ {
+ IP_RANGE i("192.168.1.5-192.168.3.1");
+ CPPUNIT_ASSERT_EQUAL(string("192.168.1.5-192.168.3.1"),i.to_string());
+ }
+
+ void ConstructRange2()
+ {
+ IP_RANGE i(ip_type::RANGE,"192.168.1.5","192.168.3.1");
+ CPPUNIT_ASSERT_EQUAL(string("192.168.1.5-192.168.3.1"),i.to_string());
+ }
+
+ void OverlapIP()
+ {
+ IP_RANGE a("192.168.1.5");
+ IP_RANGE b("192.168.1.5");
+
+ CPPUNIT_ASSERT_EQUAL(true,a.overlapping(b));
+ }
+
+ void OverlapNet1()
+ {
+ IP_RANGE a("192.168.1.5/255.255.255.0");
+ IP_RANGE b("192.168.1.6");
+
+ CPPUNIT_ASSERT_EQUAL(true,a.overlapping(b));
+ }
+
+ void OverlapNet2()
+ {
+ IP_RANGE a("192.168.1.5/255.255.255.0");
+ IP_RANGE b("192.168.1.44/255.255.255.248");
+
+ CPPUNIT_ASSERT_EQUAL(true,a.overlapping(b));
+ }
+
+ void OverlapNet3()
+ {
+ IP_RANGE a("192.168.1.5/255.255.255.0");
+ IP_RANGE b("192.168.0.0/255.255.0.0");
+
+ CPPUNIT_ASSERT_EQUAL(true,a.overlapping(b));
+ }
+
+ void OverlapNet4()
+ {
+ IP_RANGE a("192.169.1.5/255.255.255.0");
+ IP_RANGE b("192.168.0.0/255.255.0.0");
+
+ CPPUNIT_ASSERT_EQUAL(false,a.overlapping(b));
+ }
+
+ void OverlapRange1()
+ {
+ IP_RANGE a("192.168.1.5-192.168.1.50");
+ IP_RANGE b("192.168.1.6");
+
+ CPPUNIT_ASSERT_EQUAL(true,a.overlapping(b));
+ }
+
+ void OverlapRange2()
+ {
+ IP_RANGE a("192.168.1.5-192.168.1.50");
+ IP_RANGE b("192.168.1.0/255.255.255.128");
+
+ CPPUNIT_ASSERT_EQUAL(true,a.overlapping(b));
+ }
+
+ void OverlapRange3()
+ {
+ IP_RANGE a("192.168.1.5-192.168.1.50");
+ IP_RANGE b("192.168.0.0/255.255.0.0");
+
+ CPPUNIT_ASSERT_EQUAL(true,a.overlapping(b));
+ }
+
+ void OverlapRange4()
+ {
+ IP_RANGE a("192.168.1.5-192.168.1.50");
+ IP_RANGE b("192.168.1.1-192.168.1.5");
+
+ CPPUNIT_ASSERT_EQUAL(true,a.overlapping(b));
+ }
+
+ void OverlapRange5()
+ {
+ IP_RANGE a("192.168.1.5-192.168.1.50");
+ IP_RANGE b("192.168.1.1-192.168.1.4");
+
+ CPPUNIT_ASSERT_EQUAL(false,a.overlapping(b));
+ }
+
+ void OverlapRange6()
+ {
+ IP_RANGE a("192.168.1.5-192.168.1.50");
+ IP_RANGE b("192.168.1.1-192.168.2.4");
+
+ CPPUNIT_ASSERT_EQUAL(true,a.overlapping(b));
+ }
+
+ void OverlapRange7()
+ {
+ IP_RANGE a("192.168.1.5-192.168.1.50");
+ IP_RANGE b("192.168.1.6-192.168.1.7");
+
+ CPPUNIT_ASSERT_EQUAL(true,a.overlapping(b));
+ }
+
+ void WithinNet1()
+ {
+ IP_RANGE a("192.168.1.0/255.255.255.0");
+ IP_RANGE b("192.168.1.6");
+
+ CPPUNIT_ASSERT_EQUAL(false,a.is_within(b));
+ }
+
+ void WithinNet2()
+ {
+ IP_RANGE a("192.168.1.6");
+ IP_RANGE b("192.168.1.0/255.255.255.0");
+
+ CPPUNIT_ASSERT_EQUAL(true,a.is_within(b));
+ }
+
+ void WithinNet3()
+ {
+ IP_RANGE a("192.168.1.6/255.255.255.248");
+ IP_RANGE b("192.168.1.0/255.255.255.0");
+
+ CPPUNIT_ASSERT_EQUAL(true,a.is_within(b));
+ }
+
+ void WithinNet4()
+ {
+ IP_RANGE a("192.168.0.0/255.255.0.0");
+ IP_RANGE b("192.168.1.0/255.255.255.0");
+
+ CPPUNIT_ASSERT_EQUAL(false,a.is_within(b));
+ }
+
+ void WithinNet5()
+ {
+ IP_RANGE a("192.168.1.0/255.255.255.0");
+ IP_RANGE b("192.168.1.0/255.255.255.0");
+
+ CPPUNIT_ASSERT_EQUAL(true,a.is_within(b));
+ }
+
+ void WithinNet6()
+ {
+ IP_RANGE a("192.168.1.0/255.255.255.0");
+ IP_RANGE b("192.168.1.0/255.255.255.128");
+
+ CPPUNIT_ASSERT_EQUAL(false,a.is_within(b));
+ }
+
+ void WithinNet7()
+ {
+ IP_RANGE a("192.168.1.0/255.255.255.128");
+ IP_RANGE b("192.168.1.0/255.255.255.0");
+
+ CPPUNIT_ASSERT_EQUAL(true,a.is_within(b));
+ }
+
+ void WithinRange1()
+ {
+ IP_RANGE a("192.168.1.0/255.255.255.0");
+ IP_RANGE b("192.168.1.0-192.168.1.255");
+
+ CPPUNIT_ASSERT_EQUAL(true,a.is_within(b));
+ }
+
+ void WithinRange2()
+ {
+ IP_RANGE a("192.168.1.0");
+ IP_RANGE b("192.168.1.0-192.168.1.255");
+
+ CPPUNIT_ASSERT_EQUAL(true,a.is_within(b));
+ }
+
+ void WithinRange3()
+ {
+ IP_RANGE a("192.168.1.1-192.168.1.1");
+ IP_RANGE b("192.168.1.0-192.168.1.255");
+
+ CPPUNIT_ASSERT_EQUAL(true,a.is_within(b));
+ }
+
+ void WithinRange4()
+ {
+ IP_RANGE a("192.168.1.0-192.168.1.2");
+ IP_RANGE b("192.168.1.1-192.168.1.255");
+
+ CPPUNIT_ASSERT_EQUAL(false,a.is_within(b));
+ }
+
+ void WithinRange5()
+ {
+ IP_RANGE a("192.168.1.199-192.168.1.202");
+ IP_RANGE b("192.168.1.1-192.168.1.200");
+
+ CPPUNIT_ASSERT_EQUAL(false,a.is_within(b));
+ }
+
+ void WithinRange6()
+ {
+ IP_RANGE a("192.168.1.0-192.168.1.202");
+ IP_RANGE b("192.168.1.1-192.168.1.200");
+
+ CPPUNIT_ASSERT_EQUAL(false,a.is_within(b));
+ }
+
+ void WithinRange7()
+ {
+ IP_RANGE a("192.168.1.0-192.168.1.202");
+ IP_RANGE b("192.168.1.0/255.255.255.0");
+
+ CPPUNIT_ASSERT_EQUAL(true,a.is_within(b));
+ }
+
+ void WithinRange8()
+ {
+ IP_RANGE a("192.168.0.0-192.168.1.202");
+ IP_RANGE b("192.168.1.0/255.255.255.0");
+
+ CPPUNIT_ASSERT_EQUAL(false,a.is_within(b));
+ }
+
+ void WithinRange9()
+ {
+ IP_RANGE a("192.168.0.0-192.168.2.202");
+ IP_RANGE b("192.168.1.0/255.255.255.0");
+
+ CPPUNIT_ASSERT_EQUAL(false,a.is_within(b));
+ }
+
+ void WithinRange10()
+ {
+ IP_RANGE a("192.168.1.10-192.168.2.0");
+ IP_RANGE b("192.168.1.0/255.255.255.0");
+
+ CPPUNIT_ASSERT_EQUAL(false,a.is_within(b));
+ }
+};
+
+CPPUNIT_TEST_SUITE_REGISTRATION(ip_range);
--- /dev/null
+/***************************************************************************
+ * Copyright (C) 2004 by Intra2net AG *
+ * info@intra2net.com *
+ * *
+ ***************************************************************************/
+
+#include <iostream>
+#include <iomanip>
+#include <string>
+
+#include <time.h>
+#include <sys/timeb.h>
+
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/ui/text/TestRunner.h>
+#include <cppunit/TestListener.h>
+#include <cppunit/TestFailure.h>
+#include <cppunit/TestResult.h>
+#include <cppunit/CompilerOutputter.h>
+
+class VerboseTimingListener : public CppUnit::TestListener
+{
+ private:
+ double start_time;
+ std::string resultstr;
+
+ double get_time(void)
+ {
+ struct timeb tb;
+ ftime(&tb);
+ return tb.time+(static_cast<float>(tb.millitm)/1000);
+ }
+
+ public:
+
+ void startTest( CppUnit::Test *test )
+ {
+ resultstr="OK";
+ std::cout << test->getName() << ": ";
+ start_time=get_time();
+ }
+
+ void endTest( CppUnit::Test *test )
+ {
+ double timediff=get_time()-start_time;
+
+ // fix clock unpreciseness for small timespans
+ if (timediff < 0) timediff=0;
+
+ std::cout << resultstr << " ("
+ << std::fixed << std::setprecision(3)
+ << timediff << " sec)" << std::endl;
+ }
+
+ void addFailure(const CppUnit::TestFailure &failure)
+ {
+ if(failure.isError())
+ resultstr="ERROR";
+ else
+ resultstr="FAIL";
+ }
+};
+
+int main(int argc, char **argv)
+{
+ CppUnit::TextTestRunner runner;
+ CppUnit::TestFactoryRegistry ®istry = CppUnit::TestFactoryRegistry::getRegistry();
+
+ // set output format that KDevelop can catch errors
+ CppUnit::CompilerOutputter *op=CppUnit::CompilerOutputter::defaultOutputter(&runner.result(),std::cout);
+ op->setLocationFormat("%p:%l: error: ");
+ runner.setOutputter(op);
+
+ // show every test with timing
+ VerboseTimingListener listener;
+ runner.eventManager().addListener(&listener);
+
+ runner.addTest(registry.makeTest());
+
+ // run all tests in registry (not using the default progress listener)
+ bool wasSucessful = runner.run("",false,true,false);
+
+ return (wasSucessful ? 0 : 1);
+}