From: Russ Combs Date: Fri, 7 Aug 2015 00:53:03 +0000 (-0400) Subject: Squashed commit of the following: X-Git-Tag: 3.0.0-233~888 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4d60cf2d3db007ce7ec307f97fc980334967a70a;p=thirdparty%2Fsnort3.git Squashed commit of the following: commit 9abf4418d24f8f1d0ef58f5e58b28d81f6565633 Author: Russ Combs Date: Wed Aug 5 14:56:14 2015 -0400 add range and default to command line args fix unit test build on osx --- diff --git a/configure.ac b/configure.ac index 4a7900f60..c27ab50d1 100644 --- a/configure.ac +++ b/configure.ac @@ -61,6 +61,8 @@ if test "x$CXX" = "xg++"; then fi fi +PKG_PROG_PKG_CONFIG + #-------------------------------------------------------------------------- # api options #-------------------------------------------------------------------------- @@ -471,7 +473,14 @@ fi AM_CONDITIONAL(BUILD_UNIT_TESTS, test "x$enable_unit_tests" = "xyes") if test "x$enable_unit_tests" = "xyes"; then - AC_CHECK_LIB(check,srunner_create) + PKG_CHECK_EXISTS([check], [ have_check_pkgconfig="yes" ], [ have_check_pkgconfig="no" ]) + + if test "${have_check_pkgconfig}" = "yes" ; then + CPPFLAGS="${CPPFLAGS} `pkg-config --cflags check 2>/dev/null`" + LIBS="${LIBS} `pkg-config --libs check 2>/dev/null`" + else + AC_CHECK_LIB(check,srunner_create) + fi fi #-------------------------------------------------------------------------- @@ -560,8 +569,6 @@ fi # luajit #-------------------------------------------------------------------------- -PKG_PROG_PKG_CONFIG - PKG_CHECK_EXISTS([luajit], [ have_luajit_pkgconfig="yes" ], [ have_luajit_pkgconfig="no" ]) if test "${have_luajit_pkgconfig}" = "yes" ; then diff --git a/src/Makefile.am b/src/Makefile.am index 054be8e63..792b9c028 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -117,12 +117,12 @@ time \ utils if BUILD_UNIT_TESTS -snort_LDADD += test/libtest.a -lcheck -lrt -lpthread SUBDIRS += test +snort_LDADD += test/libtest.a endif if BUILD_PIGLET -snort_LDADD += piglet/libpiglet.a piglet_plugins/libpiglet_plugins.a SUBDIRS += piglet piglet_plugins +snort_LDADD += piglet/libpiglet.a piglet_plugins/libpiglet_plugins.a endif diff --git a/src/framework/parameter.cc b/src/framework/parameter.cc index b6128cfb4..ca03785ea 100644 --- a/src/framework/parameter.cc +++ b/src/framework/parameter.cc @@ -132,9 +132,13 @@ static bool is_sep(char c) static const char* find(const char* r, const char* s) { - const char* t = strstr(r, s); unsigned n = strlen(s); + if ( !n ) + return nullptr; + + const char* t = strstr(r, s); + while ( t ) { if ( (t == r || is_sep(t[-1])) && is_sep(t[n]) ) diff --git a/src/framework/parameter.h b/src/framework/parameter.h index 0975f7b8a..a3c24742c 100644 --- a/src/framework/parameter.h +++ b/src/framework/parameter.h @@ -75,6 +75,9 @@ struct SO_PUBLIC Parameter bool is_quoted() const { return ( type > PT_PORT ); } + bool has_text_range() const + { return !is_table() and range != nullptr; } + bool get_bool() const; double get_number() const; const char* get_string() const; diff --git a/src/main/help.cc b/src/main/help.cc index d3a516461..ed2f4671e 100644 --- a/src/main/help.cc +++ b/src/main/help.cc @@ -95,12 +95,20 @@ void help_args(const char* pfx) if ( p->help && (!n || !strncasecmp(name, pfx, n)) ) { cout << Markup::item(); - cout << Markup::emphasis_on(); + cout << Markup::emphasis_on(); cout << Markup::escape(p->name); cout << Markup::emphasis_off(); cout << " " << Markup::escape(p->help); + + if ( p->has_text_range() ) + { + if ( *((char*)p->range) == '(' ) + cout << " " << (char*)p->range; + else + cout << " (" << (char*)p->range << ")"; + } cout << endl; } ++p; diff --git a/src/main/snort_module.cc b/src/main/snort_module.cc index b624c274e..d186cacfb 100644 --- a/src/main/snort_module.cc +++ b/src/main/snort_module.cc @@ -111,6 +111,10 @@ static void x2s(const char* s) //------------------------------------------------------------------------- // parameters +// +// users aren't used to seeing the standard help format for command line +// args so the few cases where there is a default, we include it in the +// help as well. //------------------------------------------------------------------------- static const Parameter s_params[] = @@ -163,7 +167,7 @@ static const Parameter s_params[] = #endif { "-k", Parameter::PT_ENUM, "all|noip|notcp|noudp|noicmp|none", "all", - " checksum mode (all,noip,notcp,noudp,noicmp,none)" }, + " checksum mode; default is all" }, { "-L", Parameter::PT_STRING, nullptr, nullptr, " logging mode (none, dump, pcap, or log_*)" }, @@ -199,7 +203,7 @@ static const Parameter s_params[] = " set config variable x equal to value v" }, { "-s", Parameter::PT_INT, "68:65535", "1514", - " (same as --snaplen)" }, + " (same as --snaplen); default is 1514" }, { "-T", Parameter::PT_IMPLIED, nullptr, nullptr, "test and report on the current Snort configuration" }, @@ -238,7 +242,7 @@ static const Parameter s_params[] = { "-z", Parameter::PT_INT, "0:", "1", " maximum number of packet threads (same as --max-packet-threads); " - "0 gets the number of CPU cores reported by the system" }, + "0 gets the number of CPU cores reported by the system; default is 1" }, { "--alert-before-pass", Parameter::PT_IMPLIED, nullptr, nullptr, "process alert, drop, sdrop, or reject before pass; " @@ -433,7 +437,8 @@ static const Parameter s_params[] = "use drop, sdrop, and reject rules to ignore session traffic when not inline" }, #ifdef UNIT_TEST - { "--unit-test", Parameter::PT_STRING, nullptr, nullptr, + { "--unit-test", Parameter::PT_SELECT, + "silent | minimal | normal | verbose | env (export CK_VERBOSITY)", nullptr, " run unit tests with given libcheck output mode" }, #endif { "--version", Parameter::PT_IMPLIED, nullptr, nullptr, diff --git a/src/test/unit_test.cc b/src/test/unit_test.cc index 4cac4299a..51fa2a56d 100644 --- a/src/test/unit_test.cc +++ b/src/test/unit_test.cc @@ -16,7 +16,7 @@ // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. //-------------------------------------------------------------------------- // unit_test.h author Russ Combs -// + #include "unit_test.h" #include