From: Russ Combs (rucombs) Date: Fri, 23 Sep 2016 20:48:52 +0000 (-0400) Subject: Merge pull request #635 in SNORT/snort3 from ~MIALTIZE/snort3:os-cleanup to master X-Git-Tag: 3.0.0-233~261 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fe2d9c006dfded584cf206303c1c2a7fdf3ffca1;p=thirdparty%2Fsnort3.git Merge pull request #635 in SNORT/snort3 from ~MIALTIZE/snort3:os-cleanup to master Squashed commit of the following: commit c9776312bc8fe2b0320f2e79a068bef2e30d9dae Author: Michael Altizer Date: Fri Sep 23 16:02:19 2016 -0400 doc: Update style guide for 'using' statements and underscores commit f8a541ce2ca3c349976f6f03d28ebed3d4e723fc Author: Michael Altizer Date: Fri Sep 23 13:08:24 2016 -0400 build: Fix 32-bit compiler warnings commit c3692c6d4c2cafead8a65235b7eb37cb31790ae9 Author: Michael Altizer Date: Fri Sep 23 12:33:25 2016 -0400 build: Fix illumos/OpenSolaris build and remove SOLARIS/SUNOS defines commit 6315aaf73aeda470b3e698f994282762f2774652 Author: Michael Altizer Date: Fri Sep 23 11:21:56 2016 -0400 packet_capture: Include top-level pcap.h for backward compatibility commit e2446819cb97c0c3ea5ad38d4c1fdb77a5aa0c16 Author: Michael Altizer Date: Fri Sep 23 11:15:58 2016 -0400 lua: Fix conflict with _L macro from ctype.h on OpenBSD commit 1c4ac1695457446de11d8d2ad09e5b838514d7b1 Author: Michael Altizer Date: Fri Sep 23 02:41:38 2016 -0400 cmake: Clean dead variables out of config.cmake.h commit d0ff9dc6e9733e430f207f90ff289053837510fb Author: Michael Altizer Date: Fri Sep 23 02:33:35 2016 -0400 build: Remove superfluous LINUX and MACOS definitions They were only used in C/C++ code and can be replaced with the standard C preprocessor macros defined by platform compilers. commit 368f216086edb97866d3e73939e18cc7c9af86a5 Author: Michael Altizer Date: Fri Sep 23 01:54:08 2016 -0400 build: Remove superfluous OPENBSD and FREEBSD definitions They were only used in C/C++ code and can be replaced with the standard C preprocessor macros defined by platform compilers. commit 7f2d77cebcb660f2d515f2fbd963049f838ced28 Author: Michael Altizer Date: Fri Sep 23 01:44:36 2016 -0400 build: Entering 'std' namespace should be after all headers are included Otherwise, things get weird. Especially on illumos. commit b6265ea5a8af4bd9a8c1dbfa9f8a316b068fd848 Author: Michael Altizer Date: Fri Sep 23 01:21:44 2016 -0400 build: Clean up u_int*_t usage commit b82a09c460d5c27fd3c827ea65ce32a296d7a0b6 Author: Michael Altizer Date: Fri Sep 23 01:10:57 2016 -0400 build: Remove SPARC support Sorry, but it probably didn't work anyway and we have nothing to test it on. If anyone really wants it, they are free to test it and add it again. commit 33d61442742c136b7c644e55d96aa875adb87dd4 Author: Michael Altizer Date: Mon Sep 12 15:39:18 2016 -0400 main: Remove unused -w commandline option commit cdf3b6f62e1cce4816fb7ac5ff6148eeb77d80df Author: Michael Altizer Date: Mon Sep 12 13:50:39 2016 -0400 Clean up some DAQ header inclusion creep. --- diff --git a/cmake/platforms.cmake b/cmake/platforms.cmake index 6be50a1ae..172c6944d 100644 --- a/cmake/platforms.cmake +++ b/cmake/platforms.cmake @@ -4,35 +4,8 @@ # -# TODO: Either make a macro or a of platforms and loop over them. - -if (${CMAKE_SYSTEM_NAME} MATCHES "openbsd") - set(OPENBSD "1") -endif () - -if (${CMAKE_SYSTEM_NAME} MATCHES "solaris") - set(SOLARIS "1") -endif () - -if (${CMAKE_SYSTEM_NAME} MATCHES "sunos") - set(SUNOS "1") -endif () - -if (${CMAKE_SYSTEM_NAME} MATCHES "linux") - set(LINUX "1") -endif () - -if("${CMAKE_SYSTEM_NAME}" MATCHES "Linux") - set(LINUX "1") -endif() - -if (${CMAKE_SYSTEM_NAME} MATCHES "freebsd") - set(FREEBSD "1") -endif () - # APPLE is defined by Cmake if (APPLE) - set(MACOS 1) set(CMAKE_MACOSX_RPATH OFF) endif() diff --git a/config.cmake.h.in b/config.cmake.h.in index 9649829e8..9909c5ae7 100644 --- a/config.cmake.h.in +++ b/config.cmake.h.in @@ -45,12 +45,6 @@ /* include internal decoders in binary */ #cmakedefine STATIC_CODECS 1 -/* enable proc stats */ -#cmakedefine LINUX_SMP 1 - -/* pass packet during initialization */ -#cmakedefine INLINE_FAILOPEN 1 - /* enalbe debug messages */ #cmakedefine DEBUG_MSGS 1 @@ -63,9 +57,6 @@ /* enable profiling */ #cmakedefine PROFILE 1 -/* enable sourcefire tweaks */ -#cmakedefine SOURCEFIRE 1 - /* do not generate a core file on segfault etc */ #cmakedefine NOCOREFILE 1 @@ -104,48 +95,8 @@ #cmakedefine USE_TSC_CLOCK 1 -/* platforms */ - - - -/* Define if OpenBSD */ -#cmakedefine OPENBSD 1 - -/* Define if Irix */ -#cmakedefine IRIX 1 - -/* Define if Solaris */ -#cmakedefine SOLARIS 1 - -/* Define if SunOS */ -#cmakedefine SUNOS 1 - -/* Define if Linux */ -#cmakedefine LINUX 1 - -/* Define if HP-UX */ -#cmakedefine HPUX 1 - -/* Define if FreeBSD */ -#cmakedefine FREEBSD 1 - -/* Define if BSDi */ -#cmakedefine BSDI 1 - -/* Define if AIX */ -#cmakedefine AIX 1 - -/* Define if Tru64 or OSF*/ -#cmakedefine OSF1 1 - -/* Define if MacOS */ -#cmakedefine MACOS 1 - - - /* Print available system types and their sizes */ - /* Define to 1 if the system has the type `int16_t'. */ #cmakedefine HAVE_INT16_T 1 @@ -170,18 +121,6 @@ /* Define to 1 if the system has the type `uint8_t'. */ #cmakedefine HAVE_UINT8_T 1 -/* Define to 1 if the system has the type `u_int16_t'. */ -#cmakedefine HAVE_U_INT16_T 1 - -/* Define to 1 if the system has the type `u_int32_t'. */ -#cmakedefine HAVE_U_INT32_T 1 - -/* Define to 1 if the system has the type `u_int64_t'. */ -#cmakedefine HAVE_U_INT64_T 1 - -/* Define to 1 if the system has the type `u_int8_t'. */ -#cmakedefine HAVE_U_INT8_T 1 - /* The size of `char', as computed by sizeof. */ #cmakedefine SIZEOF_CHAR @SIZEOF_CHAR@ @@ -224,10 +163,6 @@ /* Define if words are big endian */ #cmakedefine WORDS_BIGENDIAN 1 -/* Define if words must align */ -#cmakedefine WORDS_MUSTALIGN 1 - - /* Header file definitions */ @@ -289,7 +224,6 @@ #cmakedefine HAVE_DUMBNET_H 1 - /* Available libraries */ /* hyperscan available */ @@ -305,9 +239,6 @@ /* Library specific functions */ -/* Can cleanup lex buffer stack created by pcap bpf filter */ -#cmakedefine HAVE_PCAP_LEX_DESTROY 1 - /* Can output the library version. */ #cmakedefine HAVE_PCAP_LIB_VERSION 1 @@ -317,9 +248,6 @@ /* Define if the compiler supports visibility declarations. */ #cmakedefine HAVE_VISIBILITY 1 -/* Define whether linuxthreads is being used */ -#cmakedefine HAVE_LINUXTHREADS 1 - /* Define if `thread_local` keyword should be used */ #cmakedefine USE_THREAD_LOCAL 1 diff --git a/configure.ac b/configure.ac index c50576c77..6d74b5b61 100644 --- a/configure.ac +++ b/configure.ac @@ -82,25 +82,11 @@ linux="no" macos="no" case "$host" in - *-openbsd*) - AC_DEFINE([OPENBSD],[1],[Define if OpenBSD]) - ;; - *-solaris*) - AC_DEFINE([SOLARIS],[1],[Define if Solaris]) - ;; - *-sunos*) - AC_DEFINE([SUNOS],[1],[Define if SunOS]) - ;; *-linux*) linux="yes" - AC_DEFINE([LINUX],[1],[Define if Linux]) - ;; - *-freebsd*) - AC_DEFINE([FREEBSD],[1],[Define if FreeBSD]) ;; *-apple*) macos="yes" - AC_DEFINE([MACOS],[1],[Define if MacOS]) esac #-------------------------------------------------------------------------- @@ -119,19 +105,6 @@ AC_CHECK_PROG(have_w3m,w3m,yes,no) AM_CONDITIONAL(MAKE_TEXT_DOC, [test "x$have_w3m" = "xyes" -a "x$have_asciidoc" = "xyes"]) -AC_MSG_CHECKING(for sparc) -if eval "echo $host_cpu|grep -i sparc >/dev/null"; then - AC_DEFINE([WORDS_MUSTALIGN],[1],[Define if words must align]) - AC_MSG_RESULT(yes) - - # gcc, sparc and optimization not so good - if test -n "$GCC"; then - NO_OPTIMIZE="yes" - fi -else - AC_MSG_RESULT(no) -fi - #-------------------------------------------------------------------------- # visibility foo #-------------------------------------------------------------------------- diff --git a/doc/style.txt b/doc/style.txt index dc7b10663..6cf6b41c4 100644 --- a/doc/style.txt +++ b/doc/style.txt @@ -56,6 +56,9 @@ yet firm so feedback is welcome to get something we can live with. shouldn't have to sift through implementation details to see what is available to the client. +* Any using statements in source files should be added only after all + includes have been declared. + === Naming * Use camel case for namespaces, classes, and types like WhizBangPdfChecker. @@ -63,6 +66,9 @@ yet firm so feedback is welcome to get something we can live with. * Use lower case identifiers with underscore separators, e.g. some_function() and my_var. +* Do not start or end variable names with an underscore. This has a good + chance of conflicting with macro and/or system definitions. + * Use lower case filenames with underscores. === Comments diff --git a/extra/src/inspectors/http_server/ips_http_header.cc b/extra/src/inspectors/http_server/ips_http_header.cc index a2eb4149c..f5f1b020a 100644 --- a/extra/src/inspectors/http_server/ips_http_header.cc +++ b/extra/src/inspectors/http_server/ips_http_header.cc @@ -22,7 +22,6 @@ #endif #include -using namespace std; #include "main/snort_types.h" #include "main/snort_debug.h" @@ -35,6 +34,8 @@ using namespace std; #include "framework/module.h" #include "protocols/packet.h" +using namespace std; + #define s_name "http_header" static THREAD_LOCAL ProfileStats httpHeaderPerfStats; diff --git a/extra/src/loggers/alert_ex/alert_ex.cc b/extra/src/loggers/alert_ex/alert_ex.cc index b5eaafcaf..8f6e6dfa3 100644 --- a/extra/src/loggers/alert_ex/alert_ex.cc +++ b/extra/src/loggers/alert_ex/alert_ex.cc @@ -28,7 +28,6 @@ #include #include -using namespace std; #include "main/snort_types.h" #include "framework/logger.h" @@ -36,6 +35,8 @@ using namespace std; #include "protocols/packet.h" #include "detection/signature.h" +using namespace std; + static const char* s_name = "alert_ex"; static const char* s_help = "output gid:sid:rev for alerts"; diff --git a/extra/src/loggers/alert_unixsock/alert_unixsock.cc b/extra/src/loggers/alert_unixsock/alert_unixsock.cc index 03d4df446..4dea4db77 100644 --- a/extra/src/loggers/alert_unixsock/alert_unixsock.cc +++ b/extra/src/loggers/alert_unixsock/alert_unixsock.cc @@ -216,7 +216,7 @@ static void OpenAlertSock() if ( (us.socket = socket(AF_UNIX, SOCK_DGRAM, 0)) < 0 ) FatalError("socket() call failed: %s", get_error(errno)); -#ifdef FREEBSD +#ifdef __FreeBSD__ int buflen=sizeof(us.alert); if ( setsockopt(us.socket, SOL_SOCKET, SO_SNDBUF, (char*)&buflen, sizeof(int)) < 0 ) diff --git a/src/codecs/link/cd_ppp_encap.cc b/src/codecs/link/cd_ppp_encap.cc index 679884960..cd2576d39 100644 --- a/src/codecs/link/cd_ppp_encap.cc +++ b/src/codecs/link/cd_ppp_encap.cc @@ -58,15 +58,6 @@ bool PppEncap::decode(const RawData& raw, CodecData& codec, DecodeData&) DebugMessage(DEBUG_DECODE, "PPP Packet!\n"); -#ifdef WORDS_MUSTALIGN - DebugMessage(DEBUG_DECODE, "Packet with PPP header. " - "PPP is only 1 or 2 bytes and will throw off " - "alignment on this architecture when decoding IP, " - "causing a bus error - stop decoding packet.\n"); - return true; - -#endif /* WORDS_MUSTALIGN */ - if (raw.len < 2) return false; diff --git a/src/codecs/root/cd_eth.cc b/src/codecs/root/cd_eth.cc index 0f090a077..76c47cd22 100644 --- a/src/codecs/root/cd_eth.cc +++ b/src/codecs/root/cd_eth.cc @@ -161,15 +161,6 @@ bool EthCodec::encode(const uint8_t* const raw_in, const uint16_t /*raw_len*/, // not raw ip -> encode layer 2 bool raw = ( enc.flags & ENC_FLAG_RAW ); - if ( !raw && (buf.size() == 0) ) - { - // for alignment - if (!buf.allocate(SPARC_TWIDDLE)) - return false; - - buf.off = SPARC_TWIDDLE; - } - if ( !raw || (buf.size() != 0) ) { // we get here for outer-most layer when not raw ip diff --git a/src/connectors/tcp_connector/test/tcp_connector_test.cc b/src/connectors/tcp_connector/test/tcp_connector_test.cc index 25148bbbd..d4f02a7d1 100644 --- a/src/connectors/tcp_connector/test/tcp_connector_test.cc +++ b/src/connectors/tcp_connector/test/tcp_connector_test.cc @@ -31,7 +31,7 @@ #include #include -#ifdef MACOS +#if defined(__APPLE__) #define __THROW #define __SOCKADDR_ARG struct sockaddr* #define __CONST_SOCKADDR_ARG const struct sockaddr* diff --git a/src/flow/flow_key.cc b/src/flow/flow_key.cc index d7f6a8f92..91d3e8d99 100644 --- a/src/flow/flow_key.cc +++ b/src/flow/flow_key.cc @@ -291,7 +291,6 @@ uint32_t FlowKey::hash(SFHASHFCN*, unsigned char* d, int) int FlowKey::compare(const void* s1, const void* s2, size_t) { -#ifndef SPARCV9 /* ie, everything else, use 64bit comparisons */ uint64_t* a,* b; a = (uint64_t*)s1; @@ -326,62 +325,6 @@ int FlowKey::compare(const void* s1, const void* s2, size_t) if (*a - *b) return 1; /* Compares MPLS label, AddressSpace ID and 16bit pad */ -#else /* SPARCV9 */ - uint32_t* a,* b; - - a = (uint32_t*)s1; - b = (uint32_t*)s2; - if ((*a - *b) || (*(a+1) - *(b+1))) - return 1; /* Compares IPv4 lo/hi */ - /* Compares IPv6 low[0,1] */ - - a+=2; - b+=2; - if ((*a - *b) || (*(a+1) - *(b+1))) - return 1; /* Compares port lo/hi, vlan, protocol, - version */ - /* Compares IPv6 low[2,3] */ - - a+=2; - b+=2; - if ((*a - *b) || (*(a+1) - *(b+1))) - return 1; /* Compares IPv6 hi[0,1] */ - - a+=2; - b+=2; - if ((*a - *b) || (*(a+1) - *(b+1))) - return 1; /* Compares IPv6 hi[2,3] */ - - a+=2; - b+=2; - if ((*a - *b) || (*(a+1) - *(b+1))) - return 1; /* Compares port lo/hi, vlan, protocol, - version */ - - a+=2; - b+=2; - { - uint32_t* x, * y; - x = (uint32_t*)a; - y = (uint32_t*)b; - // x++; - // y++; - if (*x - *y) - return 1; /* Compares mpls label */ - } - a++; - b++; - { - uint16_t* x, * y; - x = (uint16_t*)a; - y = (uint16_t*)b; - // x++; - // y++; - if (*x - *y) - return 1; /* Compares addressSpaceID, no pad */ - } -#endif /* SPARCV9 */ - return 0; } diff --git a/src/framework/mpse.cc b/src/framework/mpse.cc index 85928060c..356f1f2ed 100644 --- a/src/framework/mpse.cc +++ b/src/framework/mpse.cc @@ -22,12 +22,13 @@ #ifdef HAVE_CONFIG_H #include "config.h" #endif -using namespace std; #include "main/snort_debug.h" #include "main/snort_types.h" #include "profiler/profiler.h" +using namespace std; + // this is accumulated only for fast pattern // searches for the detection engine static THREAD_LOCAL uint64_t s_bcnt=0; diff --git a/src/framework/parameter.cc b/src/framework/parameter.cc index 75f14b852..f48c5c007 100644 --- a/src/framework/parameter.cc +++ b/src/framework/parameter.cc @@ -27,11 +27,12 @@ #include #include #include -using namespace std; #include "value.h" #include "utils/dnet_header.h" +using namespace std; + static bool valid_bool(Value& v, const char*) { return v.get_type() == Value::VT_BOOL; diff --git a/src/framework/range.cc b/src/framework/range.cc index d0ad2ea3f..6cfbbfffc 100644 --- a/src/framework/range.cc +++ b/src/framework/range.cc @@ -24,12 +24,13 @@ #include #include -using namespace std; #ifdef UNIT_TEST #include "catch/catch.hpp" #endif +using namespace std; + //-------------------------------------------------------------------------- // private parsing methods //-------------------------------------------------------------------------- diff --git a/src/framework/value.cc b/src/framework/value.cc index 0884a5fb3..c8b70ea29 100644 --- a/src/framework/value.cc +++ b/src/framework/value.cc @@ -27,12 +27,12 @@ #include "sfip/sfip_t.h" #include "sfip/sf_ip.h" -using namespace std; - #ifdef UNIT_TEST #include "catch/catch.hpp" #endif +using namespace std; + Value::~Value() { if ( ss ) diff --git a/src/hash/sfxhash.cc b/src/hash/sfxhash.cc index bf349acb3..6f8b5a1a4 100644 --- a/src/hash/sfxhash.cc +++ b/src/hash/sfxhash.cc @@ -221,12 +221,7 @@ SFXHASH* sfxhash_new(int nrows, int keysize, int datasize, unsigned long maxmem, h->usrfree = usrfree; h->keysize = keysize; -#ifdef WORDS_MUSTALIGN - if ((h->keysize) & 7) - h->pad = (8 - ((h->keysize) & 7)); -#else h->pad = 0; -#endif h->datasize = datasize; h->nrows = nrows; h->max_nodes = 0; diff --git a/src/helpers/process.cc b/src/helpers/process.cc index 20fcf1abd..c2a3ae0c8 100644 --- a/src/helpers/process.cc +++ b/src/helpers/process.cc @@ -36,7 +36,6 @@ #endif #include -using namespace std; #include "main.h" #include "main/thread.h" @@ -48,6 +47,8 @@ using namespace std; #include "helpers/ring.h" #include "parser/parser.h" +using namespace std; + #ifndef SIGNAL_SNORT_RELOAD #define SIGNAL_SNORT_RELOAD SIGHUP #endif @@ -223,16 +224,11 @@ static int add_signal(int sig, sighandler_t signal_handler, int check_needed) void init_signals() { -#if defined(LINUX) || defined(FREEBSD) || defined(OPENBSD) || \ - defined(SOLARIS) || defined(BSD) || defined(MACOS) sigset_t set; sigemptyset(&set); // FIXIT-L this is undefined for multithreaded apps sigprocmask(SIG_SETMASK, &set, NULL); -#else - sigsetmask(0); -#endif /* Make this prog behave nicely when signals come along. * Windows doesn't like all of these signals, and will diff --git a/src/ips_options/ips_byte_jump.cc b/src/ips_options/ips_byte_jump.cc index f66054f4d..30fd50e1e 100644 --- a/src/ips_options/ips_byte_jump.cc +++ b/src/ips_options/ips_byte_jump.cc @@ -90,10 +90,11 @@ #include "framework/parameter.h" #include "framework/module.h" +using namespace std; + static THREAD_LOCAL ProfileStats byteJumpPerfStats; #define s_name "byte_jump" -using namespace std; typedef struct _ByteJumpData { diff --git a/src/ips_options/ips_byte_test.cc b/src/ips_options/ips_byte_test.cc index f1673aebd..508e3f147 100644 --- a/src/ips_options/ips_byte_test.cc +++ b/src/ips_options/ips_byte_test.cc @@ -92,7 +92,6 @@ #include #include -using namespace std; #include "extract.h" #include "ips_byte_extract.h" @@ -111,6 +110,8 @@ using namespace std; #include "framework/parameter.h" #include "framework/module.h" +using namespace std; + #define PARSELEN 10 #define TEXTLEN (PARSELEN + 2) diff --git a/src/ips_options/ips_flowbits.cc b/src/ips_options/ips_flowbits.cc index 1cbe2c285..45fff5098 100644 --- a/src/ips_options/ips_flowbits.cc +++ b/src/ips_options/ips_flowbits.cc @@ -48,7 +48,6 @@ #include #include -using namespace std; #include "main/snort_types.h" #include "main/snort_debug.h" @@ -68,6 +67,8 @@ using namespace std; #include "framework/parameter.h" #include "framework/module.h" +using namespace std; + #define s_name "flowbits" static THREAD_LOCAL ProfileStats flowBitsPerfStats; diff --git a/src/ips_options/ips_metadata.cc b/src/ips_options/ips_metadata.cc index fa4fb5606..a66f5253f 100644 --- a/src/ips_options/ips_metadata.cc +++ b/src/ips_options/ips_metadata.cc @@ -23,7 +23,6 @@ #include #include -using namespace std; #include "main/snort_types.h" #include "main/snort_debug.h" @@ -35,6 +34,8 @@ using namespace std; #include "parser/parse_conf.h" #include "parser/parser.h" +using namespace std; + #define s_name "metadata" //------------------------------------------------------------------------- diff --git a/src/ips_options/ips_replace.cc b/src/ips_options/ips_replace.cc index 507b47b41..54f7c7ba5 100644 --- a/src/ips_options/ips_replace.cc +++ b/src/ips_options/ips_replace.cc @@ -24,7 +24,6 @@ #include #include -using namespace std; #include "main/snort_config.h" #include "main/snort_types.h" @@ -43,6 +42,8 @@ using namespace std; #include "hash/sfhashfcn.h" #include "profiler/profiler.h" +using namespace std; + static void replace_parse(const char* args, string& s) { bool negated; diff --git a/src/ips_options/ips_so.cc b/src/ips_options/ips_so.cc index cc9ae1f8d..9cc900105 100644 --- a/src/ips_options/ips_so.cc +++ b/src/ips_options/ips_so.cc @@ -24,7 +24,6 @@ #endif #include -using namespace std; #include "framework/parameter.h" #include "framework/module.h" @@ -35,6 +34,8 @@ using namespace std; #include "detection/treenodes.h" #include "profiler/profiler.h" +using namespace std; + #define s_name "so" static THREAD_LOCAL ProfileStats soPerfStats; diff --git a/src/log/log.cc b/src/log/log.cc index d78bba0b1..166241514 100644 --- a/src/log/log.cc +++ b/src/log/log.cc @@ -32,7 +32,6 @@ #include #include -using namespace std; #include "log_text.h" #include "main/snort_debug.h" @@ -130,7 +129,7 @@ int RollAlertFile(const char* filearg) // default logger stuff //-------------------------------------------------------------------- -static mutex log_mutex; +static std::mutex log_mutex; static TextLog* text_log = NULL; diff --git a/src/log/log_text.cc b/src/log/log_text.cc index ff0172261..69755e396 100644 --- a/src/log/log_text.cc +++ b/src/log/log_text.cc @@ -32,6 +32,10 @@ #include #include +extern "C" { +#include +} + #include "log.h" #include "text_log.h" #include "obfuscator.h" diff --git a/src/log/unified2.h b/src/log/unified2.h index aa944e48f..4fb0e3b5a 100644 --- a/src/log/unified2.h +++ b/src/log/unified2.h @@ -26,7 +26,7 @@ #endif #include -#ifdef LINUX +#if defined(__linux__) #include #endif #include diff --git a/src/loggers/CMakeLists.txt b/src/loggers/CMakeLists.txt index 431e9dc62..c2cbf464c 100644 --- a/src/loggers/CMakeLists.txt +++ b/src/loggers/CMakeLists.txt @@ -16,7 +16,7 @@ set (PLUGIN_LIST unified2.cc ) -if (LINUX) +if("${CMAKE_SYSTEM_NAME}" MATCHES "Linux") set ( LOGGER_SOURCES ${LOGGER_SOURCES} alert_sf_socket.cc diff --git a/src/loggers/alert_csv.cc b/src/loggers/alert_csv.cc index c6cfc2e6b..6f6123bce 100644 --- a/src/loggers/alert_csv.cc +++ b/src/loggers/alert_csv.cc @@ -54,6 +54,8 @@ #include "packet_io/active.h" #include "packet_io/sfdaq.h" +using namespace std; + #define LOG_BUFFER (4*K_BYTES) static THREAD_LOCAL TextLog* csv_log; @@ -61,8 +63,6 @@ static THREAD_LOCAL TextLog* csv_log; #define S_NAME "alert_csv" #define F_NAME S_NAME ".txt" -using namespace std; - //------------------------------------------------------------------------- // field formatting functions //------------------------------------------------------------------------- diff --git a/src/loggers/alert_fast.cc b/src/loggers/alert_fast.cc index bfa5e6991..e57735c07 100644 --- a/src/loggers/alert_fast.cc +++ b/src/loggers/alert_fast.cc @@ -58,6 +58,8 @@ #include "packet_io/intf.h" #include "events/event.h" +using namespace std; + /* full buf was chosen to allow printing max size packets * in hex/ascii mode: * each byte => 2 nibbles + space + ascii + overhead @@ -67,8 +69,6 @@ static THREAD_LOCAL TextLog* fast_log = nullptr; -using namespace std; - #define S_NAME "alert_fast" #define F_NAME S_NAME ".txt" diff --git a/src/loggers/alert_full.cc b/src/loggers/alert_full.cc index 55c1e102c..cb2ab821a 100644 --- a/src/loggers/alert_full.cc +++ b/src/loggers/alert_full.cc @@ -56,12 +56,12 @@ #include "packet_io/sfdaq.h" #include "packet_io/intf.h" +using namespace std; + static THREAD_LOCAL TextLog* full_log = nullptr; #define LOG_BUFFER (4*K_BYTES) -using namespace std; - #define S_NAME "alert_full" #define F_NAME S_NAME ".txt" diff --git a/src/loggers/alert_sf_socket.cc b/src/loggers/alert_sf_socket.cc index 088624769..b07d1180b 100644 --- a/src/loggers/alert_sf_socket.cc +++ b/src/loggers/alert_sf_socket.cc @@ -26,7 +26,7 @@ #include "config.h" #endif -#ifdef LINUX +#if defined(__linux__) #include #include @@ -47,6 +47,8 @@ #include "target_based/snort_protocols.h" #include "utils/util.h" +using namespace std; + struct SfSock { int connected; @@ -62,7 +64,6 @@ struct RuleId static THREAD_LOCAL SfSock context; -using namespace std; typedef vector RuleVector; #define s_name "alert_sfsocket" @@ -415,5 +416,5 @@ static LogApi sf_sock_api const BaseApi* alert_sf_socket = &sf_sock_api.base; -#endif /* LINUX */ +#endif /* __linux__ */ diff --git a/src/loggers/alert_syslog.cc b/src/loggers/alert_syslog.cc index 650669ee4..99430be05 100644 --- a/src/loggers/alert_syslog.cc +++ b/src/loggers/alert_syslog.cc @@ -43,12 +43,12 @@ #include "packet_io/sfdaq.h" #include "packet_io/intf.h" +using namespace std; + #ifndef LOG_AUTHPRIV #define LOG_AUTHPRIV LOG_AUTH #endif -using namespace std; - #define s_name "alert_syslog" //------------------------------------------------------------------------- @@ -112,8 +112,10 @@ static int get_options(const char* s) if ( strstr(s, "ndelay") ) opts |= LOG_NDELAY; +#ifdef LOG_PERROR if ( strstr(s, "perror") ) opts |= LOG_PERROR; +#endif if ( strstr(s, "pid") ) opts |= LOG_PID; diff --git a/src/loggers/log_hext.cc b/src/loggers/log_hext.cc index e179c6330..cd8c63b68 100644 --- a/src/loggers/log_hext.cc +++ b/src/loggers/log_hext.cc @@ -28,7 +28,6 @@ #include #include #include -using namespace std; #include "main/snort_types.h" #include "framework/logger.h" @@ -37,6 +36,8 @@ using namespace std; #include "log/text_log.h" #include "sfip/sf_ip.h" +using namespace std; + #define S_NAME "log_hext" #define F_NAME S_NAME ".txt" diff --git a/src/loggers/log_pcap.cc b/src/loggers/log_pcap.cc index 89aab1acc..7165d63d3 100644 --- a/src/loggers/log_pcap.cc +++ b/src/loggers/log_pcap.cc @@ -48,6 +48,8 @@ extern "C" { #include "utils/util.h" #include "utils/stats.h" +using namespace std; + /* * ::= [ ]* * on 64 bit systems, some fields in the are 8 bytes @@ -59,8 +61,6 @@ extern "C" { #define PCAP_FILE_HDR_SZ (24) #define PCAP_PKT_HDR_SZ (16) -using namespace std; - struct LtdConfig { string file; diff --git a/src/loggers/loggers.cc b/src/loggers/loggers.cc index 549ac804a..6deb62d5c 100644 --- a/src/loggers/loggers.cc +++ b/src/loggers/loggers.cc @@ -28,7 +28,7 @@ // to ensure PacketManager::log_protocols() is built into Snort++ extern const BaseApi* log_codecs; -#ifdef LINUX +#if defined(__linux__) extern const BaseApi* alert_sf_socket; #endif @@ -47,7 +47,7 @@ const BaseApi* loggers[] = // loggers log_codecs, -#ifdef LINUX +#if defined(__linux__) alert_sf_socket, #endif diff --git a/src/lua/lua_arg.h b/src/lua/lua_arg.h index 6dec84bf5..bd418fc4e 100644 --- a/src/lua/lua_arg.h +++ b/src/lua/lua_arg.h @@ -32,7 +32,7 @@ public: template using ArgCallback = void (*)(lua_State*, int, T& ud); - Args(lua_State* _L) : L { _L }, count { lua_gettop(L) } { } + Args(lua_State* state) : L { state }, count { lua_gettop(L) } { } private: lua_State* L; @@ -40,8 +40,8 @@ private: struct ArgRef { public: - ArgRef(lua_State* _L, int ct, int i) : - L { _L }, count { ct }, index { i } { } + ArgRef(lua_State* state, int ct, int i) : + L { state }, count { ct }, index { i } { } // We treat nil as !exists inline bool exists() diff --git a/src/main.cc b/src/main.cc index 74dafa8fa..bd7ebe683 100644 --- a/src/main.cc +++ b/src/main.cc @@ -39,7 +39,6 @@ #include #include -using namespace std; #include "main/analyzer.h" #include "main/shell.h" @@ -75,6 +74,8 @@ using namespace std; #include "piglet/piglet.h" #endif +using namespace std; + //------------------------------------------------------------------------- static Swapper* swapper = NULL; diff --git a/src/main/analyzer.cc b/src/main/analyzer.cc index 85b5ede57..98f678976 100644 --- a/src/main/analyzer.cc +++ b/src/main/analyzer.cc @@ -22,7 +22,6 @@ #include #include -using namespace std; #include "snort.h" #include "snort_debug.h" @@ -32,6 +31,8 @@ using namespace std; #include "memory/memory_cap.h" #include "packet_io/sfdaq.h" +using namespace std; + typedef DAQ_Verdict (* PacketCallback)(void*, const DAQ_PktHdr_t*, const uint8_t*); diff --git a/src/main/help.cc b/src/main/help.cc index b19236a66..17a2db05e 100644 --- a/src/main/help.cc +++ b/src/main/help.cc @@ -26,7 +26,6 @@ #include #include #include -using namespace std; #include "main.h" #include "main/snort_config.h" @@ -46,6 +45,8 @@ using namespace std; #include "utils/util.h" #include "helpers/markup.h" +using namespace std; + #define snort_help \ "\n" \ "Snort has several options to get more help:\n" \ diff --git a/src/main/snort.h b/src/main/snort.h index b9f214452..2b0613e41 100644 --- a/src/main/snort.h +++ b/src/main/snort.h @@ -28,7 +28,7 @@ #include extern "C" { -#include +#include } class Flow; diff --git a/src/main/snort_config.h b/src/main/snort_config.h index 45e13ce09..651d57b84 100644 --- a/src/main/snort_config.h +++ b/src/main/snort_config.h @@ -90,15 +90,14 @@ enum OutputFlag OUTPUT_FLAG__APP_DATA = 0x00000008, /* -d */ OUTPUT_FLAG__SHOW_DATA_LINK = 0x00000010, /* -e */ - OUTPUT_FLAG__SHOW_WIFI_MGMT = 0x00000020, /* -w */ - OUTPUT_FLAG__USE_UTC = 0x00000040, /* -U */ - OUTPUT_FLAG__INCLUDE_YEAR = 0x00000080, /* -y */ - + OUTPUT_FLAG__USE_UTC = 0x00000020, /* -U */ + OUTPUT_FLAG__INCLUDE_YEAR = 0x00000040, /* -y */ /* Note using this alters the packet - can't be used inline */ - OUTPUT_FLAG__OBFUSCATE = 0x00000100, /* -B */ - OUTPUT_FLAG__ALERT_IFACE = 0x00000200, /* -I */ - OUTPUT_FLAG__NO_TIMESTAMP = 0x00000400, /* --nostamps */ - OUTPUT_FLAG__ALERTS = 0x00000800, /* -A */ + OUTPUT_FLAG__OBFUSCATE = 0x00000080, /* -B */ + + OUTPUT_FLAG__ALERT_IFACE = 0x00000100, /* -I */ + OUTPUT_FLAG__NO_TIMESTAMP = 0x00000200, /* --nostamps */ + OUTPUT_FLAG__ALERTS = 0x00000400, /* -A */ }; enum LoggingFlag @@ -496,9 +495,6 @@ public: static bool line_buffered_logging() { return snort_conf->output_flags & OUTPUT_FLAG__LINE_BUFFER; } - static bool output_wifi_mgmt() - { return snort_conf->output_flags & OUTPUT_FLAG__SHOW_WIFI_MGMT; } - // run flags static bool no_lock_pid_file() { return snort_conf->run_flags & RUN_FLAG__NO_LOCK_PID_FILE; } diff --git a/src/main/snort_module.cc b/src/main/snort_module.cc index e32299086..baad5c562 100644 --- a/src/main/snort_module.cc +++ b/src/main/snort_module.cc @@ -28,7 +28,6 @@ #include #include -using namespace std; #include "main.h" #include "snort_config.h" @@ -53,6 +52,8 @@ using namespace std; #include "catch/unit_test.h" #endif +using namespace std; + //------------------------------------------------------------------------- // commands //------------------------------------------------------------------------- @@ -235,11 +236,6 @@ static const Parameter s_params[] = { "-W", Parameter::PT_IMPLIED, nullptr, nullptr, "lists available interfaces" }, -#if defined(DLT_IEEE802_11) - { "-w", Parameter::PT_IMPLIED, nullptr, nullptr, - "dump 802.11 management and control frames" }, -#endif - { "-X", Parameter::PT_IMPLIED, nullptr, nullptr, "dump the raw packet data starting at the link layer" }, @@ -646,11 +642,6 @@ bool SnortModule::set(const char*, Value& v, SnortConfig* sc) else if ( v.is("-W") ) list_interfaces(sc); -#if defined(DLT_IEEE802_11) - else if ( v.is("-w") ) - sc->output_flags |= OUTPUT_FLAG__SHOW_WIFI_MGMT; -#endif - else if ( v.is("-X") ) ConfigDumpPayloadVerbose(sc, v.get_string()); diff --git a/src/managers/action_manager.cc b/src/managers/action_manager.cc index 86c53fdcb..9a94a95c2 100644 --- a/src/managers/action_manager.cc +++ b/src/managers/action_manager.cc @@ -22,7 +22,6 @@ #include #include -using namespace std; #include "main/snort_types.h" #include "main/snort_config.h" @@ -35,6 +34,8 @@ using namespace std; #include "actions/act_replace.h" #include "packet_io/active.h" +using namespace std; + struct Actor { const ActionApi* api; diff --git a/src/managers/event_manager.cc b/src/managers/event_manager.cc index 827bf4530..30cad9063 100644 --- a/src/managers/event_manager.cc +++ b/src/managers/event_manager.cc @@ -28,7 +28,6 @@ #include #include -using namespace std; #include "plugin_manager.h" #include "module_manager.h" @@ -43,6 +42,8 @@ using namespace std; #include "parser/parser.h" #include "log/messages.h" +using namespace std; + struct Output { const LogApi* api; diff --git a/src/managers/ips_manager.cc b/src/managers/ips_manager.cc index c026b8bf0..f564aa1df 100644 --- a/src/managers/ips_manager.cc +++ b/src/managers/ips_manager.cc @@ -30,7 +30,6 @@ #include #include -using namespace std; #include "plugin_manager.h" #include "main/snort_types.h" @@ -46,6 +45,8 @@ using namespace std; #include "parser/parser.h" #include "log/messages.h" +using namespace std; + struct Option { const IpsApi* api; diff --git a/src/managers/module_manager.cc b/src/managers/module_manager.cc index e37bb3aa5..547ad8eb4 100644 --- a/src/managers/module_manager.cc +++ b/src/managers/module_manager.cc @@ -1242,7 +1242,7 @@ void ModuleManager::dump_stats(SnortConfig*, const char* skip) void ModuleManager::accumulate(SnortConfig*) { - static mutex stats_mutex; + static std::mutex stats_mutex; stats_mutex.lock(); for ( auto p : s_modules ) diff --git a/src/managers/mpse_manager.cc b/src/managers/mpse_manager.cc index 8f5738923..398d28813 100644 --- a/src/managers/mpse_manager.cc +++ b/src/managers/mpse_manager.cc @@ -20,7 +20,6 @@ #include "mpse_manager.h" #include -using namespace std; #include "module_manager.h" #include "main/snort_types.h" @@ -32,6 +31,8 @@ using namespace std; #include "log/messages.h" #include "search_engines/search_common.h" +using namespace std; + typedef list EngineList; static EngineList s_engines; diff --git a/src/managers/plugin_manager.cc b/src/managers/plugin_manager.cc index d3f88b96b..957561a29 100644 --- a/src/managers/plugin_manager.cc +++ b/src/managers/plugin_manager.cc @@ -30,7 +30,6 @@ #include #include #include -using namespace std; #include "action_manager.h" #include "event_manager.h" @@ -73,7 +72,9 @@ using namespace std; #include "parser/parser.h" #include "file_api/file_service.h" -#if defined(LINUX) +using namespace std; + +#if defined(__linux__) #define lib_pattern "*.so" #else #define lib_pattern "*.dylib" @@ -157,7 +158,7 @@ struct Plugin { source.clear(); key.clear(); api = nullptr; handle = nullptr; } }; -typedef map PlugMap; +typedef std::map PlugMap; static PlugMap plug_map; struct RefCount @@ -169,7 +170,7 @@ struct RefCount //~RefCount() { assert(!count); }; // FIXIT-L fails on fatal error }; -typedef map RefMap; +typedef std::map RefMap; static RefMap ref_map; static void set_key(string& key, Symbol* sym, const char* name) diff --git a/src/managers/script_manager.cc b/src/managers/script_manager.cc index eebff89dc..9446c9035 100644 --- a/src/managers/script_manager.cc +++ b/src/managers/script_manager.cc @@ -40,6 +40,8 @@ #include "piglet/piglet_manager.h" #endif +using namespace std; + // FIXIT-P this approach results in N * K lua states where // N ::= number of instances of script + args and // K ::= number of threads @@ -48,7 +50,6 @@ // ultimately should look into changing detection engine to // keep just one copy of rule option + args -using namespace std; #define script_pattern "*.lua" //------------------------------------------------------------------------- diff --git a/src/managers/so_manager.cc b/src/managers/so_manager.cc index 4a0e6094d..3c2988562 100644 --- a/src/managers/so_manager.cc +++ b/src/managers/so_manager.cc @@ -36,7 +36,6 @@ #include #include #include -using namespace std; #include "plugin_manager.h" #include "main/snort_types.h" @@ -48,6 +47,8 @@ using namespace std; #include "parser/parser.h" #include "log/messages.h" +using namespace std; + static list s_rules; //------------------------------------------------------------------------- diff --git a/src/network_inspectors/appid/appid_session.cc b/src/network_inspectors/appid/appid_session.cc index 973b4ed0b..38c91fe30 100644 --- a/src/network_inspectors/appid/appid_session.cc +++ b/src/network_inspectors/appid/appid_session.cc @@ -1449,7 +1449,7 @@ bool AppIdSession::do_service_discovery(IpProtocol protocol, int direction, AppI && dsession && dsession->host) { size_t size = dsession->host_len; - dns_host_scan_hostname((const u_int8_t*) (dsession->host), size, &ClientAppId, &payloadAppId, + dns_host_scan_hostname((const uint8_t*) (dsession->host), size, &ClientAppId, &payloadAppId, &pConfig->serviceDnsConfig); set_client_app_id_data(ClientAppId, nullptr); } @@ -1898,7 +1898,7 @@ void AppIdSession::do_application_discovery(Packet* p) session->dsession && session->dsession->host ) { size_t size = session->dsession->host_len; - dns_host_scan_hostname((const u_int8_t*)session->dsession->host, size, &ClientAppId, + dns_host_scan_hostname((const uint8_t*)session->dsession->host, size, &ClientAppId, &payloadAppId, &pConfig->serviceDnsConfig); session->set_client_app_id_data(ClientAppId, nullptr); } @@ -2498,7 +2498,7 @@ void AppIdSession::examine_ssl_metadata(Packet* p, AppIdConfig* pConfig) if ((scan_flags & SCAN_SSL_HOST_FLAG) && tsession->tls_host) { size = strlen(tsession->tls_host); - if ((ret = ssl_scan_hostname((const u_int8_t*)tsession->tls_host, size, + if ((ret = ssl_scan_hostname((const uint8_t*)tsession->tls_host, size, &clientAppId, &payload_app_id, &pConfig->serviceSslConfig))) { set_client_app_id_data(clientAppId, nullptr); @@ -2510,7 +2510,7 @@ void AppIdSession::examine_ssl_metadata(Packet* p, AppIdConfig* pConfig) if (tsession->tls_cname) { size = strlen(tsession->tls_cname); - if ((ret = ssl_scan_cname((const u_int8_t*)tsession->tls_cname, size, + if ((ret = ssl_scan_cname((const uint8_t*)tsession->tls_cname, size, &clientAppId, &payload_app_id, &pConfig->serviceSslConfig))) { set_client_app_id_data(clientAppId, nullptr); @@ -2523,7 +2523,7 @@ void AppIdSession::examine_ssl_metadata(Packet* p, AppIdConfig* pConfig) if (tsession->tls_orgUnit) { size = strlen(tsession->tls_orgUnit); - if ((ret = ssl_scan_cname((const u_int8_t*)tsession->tls_orgUnit, size, + if ((ret = ssl_scan_cname((const uint8_t*)tsession->tls_orgUnit, size, &clientAppId, &payload_app_id, &pConfig->serviceSslConfig))) { set_client_app_id_data(clientAppId, nullptr); diff --git a/src/network_inspectors/appid/appid_utils/sf_mlmp.cc b/src/network_inspectors/appid/appid_utils/sf_mlmp.cc index f69b01ff6..8b0be2d64 100644 --- a/src/network_inspectors/appid/appid_utils/sf_mlmp.cc +++ b/src/network_inspectors/appid/appid_utils/sf_mlmp.cc @@ -298,7 +298,7 @@ static void dumpTreesRecursively(tMlmpTree* rootNode) ddPatternNode->partNum, ddPatternNode->partTotal, (char*)ddPatternNode->pattern.pattern, - (u_int32_t)ddPatternNode->pattern.patternSize); + (uint32_t)ddPatternNode->pattern.patternSize); } if (primaryPatternNode->nextLevelMatcher) @@ -344,7 +344,7 @@ static tPatternNode* patternSelector(const tMatchedPatternList* patternMatchList "\t\tid %d, Pattern %s, size %u, partNum %u, partTotal %u, userData %p\n", ddPatternNode->patternId, ddPatternNode->pattern.pattern, - (u_int32_t)ddPatternNode->pattern.patternSize, + (uint32_t)ddPatternNode->pattern.patternSize, ddPatternNode->partNum, ddPatternNode->partTotal, ddPatternNode->userData); @@ -402,7 +402,7 @@ static tPatternNode* patternSelector(const tMatchedPatternList* patternMatchList "\t\tSELECTED Id %d, pattern %s, size %u, partNum %u, partTotal %u, userData %p\n", ddPatternNode->patternId, ddPatternNode->pattern.pattern, - (u_int32_t)ddPatternNode->pattern.patternSize, + (uint32_t)ddPatternNode->pattern.patternSize, ddPatternNode->partNum, ddPatternNode->partTotal, ddPatternNode->userData); @@ -441,7 +441,7 @@ static int patternMatcherCallback(void* id, void*, int index, void* data, void*) "\tCallback id %d, Pattern %s, size %u, partNum %u, partTotal %u, userData %p\n", target->patternId, target->pattern.pattern, - (u_int32_t)target->pattern.patternSize, + (uint32_t)target->pattern.patternSize, target->partNum, target->partTotal, target->userData); diff --git a/src/network_inspectors/appid/appid_utils/sf_multi_mpse.cc b/src/network_inspectors/appid/appid_utils/sf_multi_mpse.cc index 23620ad86..db6b75c45 100644 --- a/src/network_inspectors/appid/appid_utils/sf_multi_mpse.cc +++ b/src/network_inspectors/appid/appid_utils/sf_multi_mpse.cc @@ -245,7 +245,7 @@ static void dumpTreesRecursively(void* root, int level) { printf("%sPattern %s, size %u, userData %p\n", offset, (char*)patternNode->pattern.pattern, - (u_int32_t)patternNode->pattern.patternSize, + (uint32_t)patternNode->pattern.patternSize, patternNode->userData); /*recursion into next lower level */ diff --git a/src/network_inspectors/appid/client_plugins/client_app_bit.cc b/src/network_inspectors/appid/client_plugins/client_app_bit.cc index c79710534..f02ec5446 100644 --- a/src/network_inspectors/appid/client_plugins/client_app_bit.cc +++ b/src/network_inspectors/appid/client_plugins/client_app_bit.cc @@ -94,7 +94,7 @@ SO_PUBLIC RNAClientAppModule bit_client_mod = struct Client_App_Pattern { - const u_int8_t* pattern; + const uint8_t* pattern; unsigned length; int index; unsigned appId; diff --git a/src/network_inspectors/appid/client_plugins/client_app_bit_tracker.cc b/src/network_inspectors/appid/client_plugins/client_app_bit_tracker.cc index 50384cbbb..4327736fd 100644 --- a/src/network_inspectors/appid/client_plugins/client_app_bit_tracker.cc +++ b/src/network_inspectors/appid/client_plugins/client_app_bit_tracker.cc @@ -92,7 +92,7 @@ SO_PUBLIC RNAClientAppModule bit_tracker_client_mod = struct Client_App_Pattern { - const u_int8_t* pattern; + const uint8_t* pattern; unsigned length; int index; unsigned appId; diff --git a/src/network_inspectors/appid/client_plugins/client_app_msn.cc b/src/network_inspectors/appid/client_plugins/client_app_msn.cc index 18afbb969..de17a8f67 100644 --- a/src/network_inspectors/appid/client_plugins/client_app_msn.cc +++ b/src/network_inspectors/appid/client_plugins/client_app_msn.cc @@ -115,10 +115,10 @@ static CLIENT_APP_RETCODE msn_init(const IniClientAppAPI* const init_api, SF_LIS static CLIENT_APP_RETCODE msn_validate(const uint8_t* data, uint16_t size, const int dir, AppIdSession* flowp, Packet* pkt, struct Detector*, const AppIdConfig*) { - const u_int8_t* end; - u_int8_t version[MAX_VERSION_SIZE]; - u_int8_t* v; - u_int8_t* v_end; + const uint8_t* end; + uint8_t version[MAX_VERSION_SIZE]; + uint8_t* v; + uint8_t* v_end; uint32_t product_id; product_id = APP_ID_MSN_MESSENGER; diff --git a/src/network_inspectors/appid/client_plugins/client_app_rtp.cc b/src/network_inspectors/appid/client_plugins/client_app_rtp.cc index b707663f2..445ef45a8 100644 --- a/src/network_inspectors/appid/client_plugins/client_app_rtp.cc +++ b/src/network_inspectors/appid/client_plugins/client_app_rtp.cc @@ -103,7 +103,7 @@ SO_PUBLIC RNAClientAppModule rtp_client_mod = struct Client_App_Pattern { - const u_int8_t* pattern; + const uint8_t* pattern; unsigned length; int index; unsigned appId; diff --git a/src/network_inspectors/appid/client_plugins/client_app_smtp.cc b/src/network_inspectors/appid/client_plugins/client_app_smtp.cc index dff622845..7cb159cc5 100644 --- a/src/network_inspectors/appid/client_plugins/client_app_smtp.cc +++ b/src/network_inspectors/appid/client_plugins/client_app_smtp.cc @@ -113,7 +113,7 @@ SO_PUBLIC RNAClientAppModule smtp_client_mod = struct Client_App_Pattern { - const u_int8_t* pattern; + const uint8_t* pattern; unsigned length; int index; unsigned appId; @@ -245,9 +245,9 @@ static int extract_version_and_add_client_app(ApplicationId clientId, ClientSMTPData* const client_data, AppIdSession* flowp, AppId appId, PegCount *stat_counter) { - const u_int8_t* p; - u_int8_t* v; - u_int8_t* v_end; + const uint8_t* p; + uint8_t* v; + uint8_t* v_end; v_end = client_data->version; v_end += MAX_VERSION_SIZE - 1; @@ -276,9 +276,9 @@ static int extract_version_and_add_client_app(ApplicationId clientId, static int IdentifyClientVersion(ClientSMTPData* const fd, const uint8_t* product, const uint8_t* data_end, AppIdSession* flowp, Packet*) { - const u_int8_t* p; - u_int8_t* v; - u_int8_t* v_end; + const uint8_t* p; + uint8_t* v; + uint8_t* v_end; unsigned len; unsigned sublen; AppId appId = (fd->flags & CLIENT_FLAG_SMTPS) ? APP_ID_SMTPS : APP_ID_SMTP; diff --git a/src/network_inspectors/appid/client_plugins/client_app_ssh.cc b/src/network_inspectors/appid/client_plugins/client_app_ssh.cc index 9da0adcfa..a5b2ebafb 100644 --- a/src/network_inspectors/appid/client_plugins/client_app_ssh.cc +++ b/src/network_inspectors/appid/client_plugins/client_app_ssh.cc @@ -176,7 +176,7 @@ SO_PUBLIC RNAClientAppModule ssh_client_mod = struct Client_App_Pattern { - const u_int8_t* pattern; + const uint8_t* pattern; unsigned length; int index; unsigned appId; diff --git a/src/network_inspectors/appid/client_plugins/client_app_timbuktu.cc b/src/network_inspectors/appid/client_plugins/client_app_timbuktu.cc index 622ba9b93..11165a53c 100644 --- a/src/network_inspectors/appid/client_plugins/client_app_timbuktu.cc +++ b/src/network_inspectors/appid/client_plugins/client_app_timbuktu.cc @@ -90,7 +90,7 @@ SO_PUBLIC RNAClientAppModule timbuktu_client_mod = struct Client_App_Pattern { - const u_int8_t* pattern; + const uint8_t* pattern; unsigned length; int index; unsigned appId; diff --git a/src/network_inspectors/appid/client_plugins/client_app_tns.cc b/src/network_inspectors/appid/client_plugins/client_app_tns.cc index 0a4467f2c..a1f0e998b 100644 --- a/src/network_inspectors/appid/client_plugins/client_app_tns.cc +++ b/src/network_inspectors/appid/client_plugins/client_app_tns.cc @@ -150,7 +150,7 @@ SO_PUBLIC RNAClientAppModule tns_client_mod = struct Client_App_Pattern { - const u_int8_t* pattern; + const uint8_t* pattern; unsigned length; int index; unsigned appId; diff --git a/src/network_inspectors/appid/client_plugins/client_app_vnc.cc b/src/network_inspectors/appid/client_plugins/client_app_vnc.cc index a54a37dab..f3cc2a59b 100644 --- a/src/network_inspectors/appid/client_plugins/client_app_vnc.cc +++ b/src/network_inspectors/appid/client_plugins/client_app_vnc.cc @@ -77,7 +77,7 @@ SO_PUBLIC RNAClientAppModule vnc_client_mod = struct Client_App_Pattern { - const u_int8_t* pattern; + const uint8_t* pattern; unsigned length; int index; unsigned appId; diff --git a/src/network_inspectors/appid/client_plugins/client_app_ym.cc b/src/network_inspectors/appid/client_plugins/client_app_ym.cc index 51d26f746..f46c8bd51 100644 --- a/src/network_inspectors/appid/client_plugins/client_app_ym.cc +++ b/src/network_inspectors/appid/client_plugins/client_app_ym.cc @@ -60,7 +60,7 @@ RNAClientAppModule ym_client_mod = struct Client_App_Pattern { - const u_int8_t* pattern; + const uint8_t* pattern; unsigned length; int index; unsigned appId; diff --git a/src/network_inspectors/appid/detector_plugins/detector_dns.cc b/src/network_inspectors/appid/detector_plugins/detector_dns.cc index 7bf157ee5..e5f472444 100644 --- a/src/network_inspectors/appid/detector_plugins/detector_dns.cc +++ b/src/network_inspectors/appid/detector_plugins/detector_dns.cc @@ -778,7 +778,7 @@ inprocess: return SERVICE_INPROCESS; } -static int dns_host_scan_patterns(SearchTool* matcher, const u_int8_t* pattern, size_t size, +static int dns_host_scan_patterns(SearchTool* matcher, const uint8_t* pattern, size_t size, AppId* ClientAppId, AppId* payloadId) { MatchedDNSPatterns* mp = nullptr; @@ -826,7 +826,7 @@ static int dns_host_scan_patterns(SearchTool* matcher, const u_int8_t* pattern, return 1; } -int dns_host_scan_hostname(const u_int8_t* pattern, size_t size, AppId* ClientAppId, +int dns_host_scan_hostname(const uint8_t* pattern, size_t size, AppId* ClientAppId, AppId* payloadId, const ServiceDnsConfig* pDnsConfig) { return dns_host_scan_patterns(pDnsConfig->dns_host_host_matcher, pattern, size, ClientAppId, diff --git a/src/network_inspectors/appid/detector_plugins/detector_dns.h b/src/network_inspectors/appid/detector_plugins/detector_dns.h index 5cc24c8ef..b262de8eb 100644 --- a/src/network_inspectors/appid/detector_plugins/detector_dns.h +++ b/src/network_inspectors/appid/detector_plugins/detector_dns.h @@ -32,7 +32,7 @@ extern struct RNAServiceValidationModule dns_service_mod; extern struct RNAClientAppModule dns_udp_client_mod; extern struct RNAClientAppModule dns_tcp_client_mod; -int dns_host_scan_hostname(const u_int8_t*, size_t, AppId*, AppId*, const ServiceDnsConfig*); +int dns_host_scan_hostname(const uint8_t*, size_t, AppId*, AppId*, const ServiceDnsConfig*); void service_dns_host_clean(ServiceDnsConfig* pConfig); int dns_host_detector_process_patterns(ServiceDnsConfig* pConfig); int dns_add_host_pattern(uint8_t*, size_t, uint8_t, AppId, ServiceDnsConfig*); diff --git a/src/network_inspectors/appid/detector_plugins/detector_http.h b/src/network_inspectors/appid/detector_plugins/detector_http.h index 066f4b50c..135cd7155 100644 --- a/src/network_inspectors/appid/detector_plugins/detector_http.h +++ b/src/network_inspectors/appid/detector_plugins/detector_http.h @@ -129,7 +129,7 @@ struct HeaderMatchedPatterns -int geAppidByViaPattern(const u_int8_t*, unsigned, char**, const DetectorHttpConfig*); +int geAppidByViaPattern(const uint8_t*, unsigned, char**, const DetectorHttpConfig*); int getHTTPHeaderLocation(const uint8_t*, unsigned, HttpId, int*, int*, HeaderMatchedPatterns*, const DetectorHttpConfig*); inline void FreeMatchedCHPActions(MatchedCHPAction* ma) @@ -152,7 +152,7 @@ AppId getAppIdFromUrl(char*, char*, char**, char*, AppId*, AppId*, AppId*, AppId const DetectorHttpConfig*); AppId geAppidByContentType(const uint8_t*, int, const DetectorHttpConfig*); AppId scan_header_x_working_with(const uint8_t*, uint32_t, char**); -void identifyUserAgent(const u_int8_t*, int, AppId*, AppId*, char**, const DetectorHttpConfig*); +void identifyUserAgent(const uint8_t*, int, AppId*, AppId*, char**, const DetectorHttpConfig*); void getServerVendorVersion(const uint8_t*, int, char**, char**, RNAServiceSubtype**); int webdav_found(HeaderMatchedPatterns*); int http_detector_finalize(AppIdConfig*); diff --git a/src/network_inspectors/appid/detector_plugins/http_url_patterns.h b/src/network_inspectors/appid/detector_plugins/http_url_patterns.h index 3a880f13e..69aa4e72c 100644 --- a/src/network_inspectors/appid/detector_plugins/http_url_patterns.h +++ b/src/network_inspectors/appid/detector_plugins/http_url_patterns.h @@ -39,7 +39,7 @@ int matchQueryElements(tMlpPattern* packetData, char* appVersion, size_t appVersionSize); -uint32_t parseMultipleHTTPPatterns(const char* pattern, tMlmpPattern* parts, u_int32_t +uint32_t parseMultipleHTTPPatterns(const char* pattern, tMlmpPattern* parts, uint32_t numPartLimit, int level); void destroyHosUrlPatternList(HosUrlPatternsList** pHosUrlPatternsList); diff --git a/src/network_inspectors/appid/fw_appid.cc b/src/network_inspectors/appid/fw_appid.cc index 52dd5d84b..6928f42b8 100644 --- a/src/network_inspectors/appid/fw_appid.cc +++ b/src/network_inspectors/appid/fw_appid.cc @@ -51,11 +51,11 @@ void dump_appid_stats() { LogMessage("Application Identification Preprocessor:\n"); - LogMessage(" Total packets received : %lu\n", appid_stats.packets); - LogMessage(" Total packets processed : %lu\n", appid_stats.processed_packets); + LogMessage(" Total packets received : %" PRIu64 "\n", appid_stats.packets); + LogMessage(" Total packets processed : %" PRIu64 "\n", appid_stats.processed_packets); if (thirdparty_appid_module) thirdparty_appid_module->print_stats(); - LogMessage(" Total packets ignored : %lu\n", appid_stats.ignored_packets); + LogMessage(" Total packets ignored : %" PRIu64 "\n", appid_stats.ignored_packets); AppIdServiceStateDumpStats(); RNAPndDumpLuaStats(); } diff --git a/src/network_inspectors/appid/lua_detector_api.cc b/src/network_inspectors/appid/lua_detector_api.cc index b6ae7f6dc..b79a08cf0 100644 --- a/src/network_inspectors/appid/lua_detector_api.cc +++ b/src/network_inspectors/appid/lua_detector_api.cc @@ -1985,8 +1985,8 @@ static int Detector_portOnlyService(lua_State* L) } AppId appId = lua_tointeger(L, index++); - u_int16_t port = lua_tointeger(L, index++); - u_int8_t protocol = lua_tointeger(L, index++); + uint16_t port = lua_tointeger(L, index++); + uint8_t protocol = lua_tointeger(L, index++); if (port == 0) ud->pAppidNewConfig->ip_protocol[protocol] = appId; @@ -2163,11 +2163,11 @@ static int Detector_addAppUrl(lua_State* L) return 0; } - u_int32_t service_id = lua_tointeger(L, index++); - u_int32_t client_app = lua_tointeger(L, index++); - /*u_int32_t client_app_type =*/ lua_tointeger(L, index++); - u_int32_t payload = lua_tointeger(L, index++); - /*u_int32_t payload_type =*/ lua_tointeger(L, index++); + uint32_t service_id = lua_tointeger(L, index++); + uint32_t client_app = lua_tointeger(L, index++); + /*uint32_t client_app_type =*/ lua_tointeger(L, index++); + uint32_t payload = lua_tointeger(L, index++); + /*uint32_t payload_type =*/ lua_tointeger(L, index++); if (ud->validateParams.pkt) { @@ -2179,7 +2179,7 @@ static int Detector_addAppUrl(lua_State* L) /* Verify that host pattern is a valid string */ size_t hostPatternSize = 0; - u_int8_t* hostPattern = nullptr; + uint8_t* hostPattern = nullptr; tmpString = lua_tolstring(L, index++, &hostPatternSize); if (!tmpString || !hostPatternSize) { @@ -2187,11 +2187,11 @@ static int Detector_addAppUrl(lua_State* L) return 0; } else - hostPattern = (u_int8_t*)snort_strdup(tmpString); + hostPattern = (uint8_t*)snort_strdup(tmpString); /* Verify that path pattern is a valid string */ size_t pathPatternSize = 0; - u_int8_t* pathPattern = nullptr; + uint8_t* pathPattern = nullptr; tmpString = lua_tolstring(L, index++, &pathPatternSize); if (!tmpString || !pathPatternSize ) { @@ -2200,11 +2200,11 @@ static int Detector_addAppUrl(lua_State* L) return 0; } else - pathPattern = (u_int8_t*)snort_strdup(tmpString); + pathPattern = (uint8_t*)snort_strdup(tmpString); /* Verify that scheme pattern is a valid string */ size_t schemePatternSize; - u_int8_t* schemePattern = nullptr; + uint8_t* schemePattern = nullptr; tmpString = lua_tolstring(L, index++, &schemePatternSize); if (!tmpString || !schemePatternSize ) { @@ -2214,16 +2214,16 @@ static int Detector_addAppUrl(lua_State* L) return 0; } else - schemePattern = (u_int8_t*)snort_strdup(tmpString); + schemePattern = (uint8_t*)snort_strdup(tmpString); /* Verify that query pattern is a valid string */ size_t queryPatternSize; - u_int8_t* queryPattern = nullptr; + uint8_t* queryPattern = nullptr; tmpString = lua_tolstring(L, index++, &queryPatternSize); if (tmpString && queryPatternSize) - queryPattern = (u_int8_t*)snort_strdup(tmpString); + queryPattern = (uint8_t*)snort_strdup(tmpString); - u_int32_t appId = lua_tointeger(L, index++); + uint32_t appId = lua_tointeger(L, index++); /* Allocate memory for data structures */ DetectorAppUrlPattern* pattern = @@ -2287,11 +2287,11 @@ static int Detector_addRTMPUrl(lua_State* L) return 0; } - u_int32_t service_id = lua_tointeger(L, index++); - u_int32_t client_app = lua_tointeger(L, index++); - /*u_int32_t client_app_type =*/ lua_tointeger(L, index++); - u_int32_t payload = lua_tointeger(L, index++); - /*u_int32_t payload_type =*/ lua_tointeger(L, index++); + uint32_t service_id = lua_tointeger(L, index++); + uint32_t client_app = lua_tointeger(L, index++); + /*uint32_t client_app_type =*/ lua_tointeger(L, index++); + uint32_t payload = lua_tointeger(L, index++); + /*uint32_t payload_type =*/ lua_tointeger(L, index++); if (ud->validateParams.pkt) { @@ -2303,10 +2303,10 @@ static int Detector_addRTMPUrl(lua_State* L) /* Verify that host pattern is a valid string */ size_t hostPatternSize = 0; - u_int8_t* hostPattern = nullptr; + uint8_t* hostPattern = nullptr; tmpString = lua_tolstring(L, index++, &hostPatternSize); // FIXIT-L: recode all this to something elegant since snort_strdup can't fail (just like Rudy) - if (!tmpString || !hostPatternSize || !(hostPattern = (u_int8_t*)snort_strdup(tmpString))) + if (!tmpString || !hostPatternSize || !(hostPattern = (uint8_t*)snort_strdup(tmpString))) { ErrorMessage("Invalid host pattern string."); return 0; @@ -2314,10 +2314,10 @@ static int Detector_addRTMPUrl(lua_State* L) /* Verify that path pattern is a valid string */ size_t pathPatternSize = 0; - u_int8_t* pathPattern = nullptr; + uint8_t* pathPattern = nullptr; tmpString = lua_tolstring(L, index++, &pathPatternSize); // FIXIT-L: recode all this to something elegant since snort_strdup can't fail (just like Rudy) - if (!tmpString || !pathPatternSize || !(pathPattern = (u_int8_t*)snort_strdup(tmpString))) + if (!tmpString || !pathPatternSize || !(pathPattern = (uint8_t*)snort_strdup(tmpString))) { ErrorMessage("Invalid path pattern string."); snort_free(hostPattern); @@ -2326,10 +2326,10 @@ static int Detector_addRTMPUrl(lua_State* L) /* Verify that scheme pattern is a valid string */ size_t schemePatternSize; - u_int8_t* schemePattern = nullptr; + uint8_t* schemePattern = nullptr; tmpString = lua_tolstring(L, index++, &schemePatternSize); // FIXIT-L: recode all this to something elegant since snort_strdup can't fail (just like Rudy) - if (!tmpString || !schemePatternSize || !(schemePattern = (u_int8_t*)snort_strdup(tmpString))) + if (!tmpString || !schemePatternSize || !(schemePattern = (uint8_t*)snort_strdup(tmpString))) { ErrorMessage("Invalid scheme pattern string."); snort_free(pathPattern); @@ -2339,12 +2339,12 @@ static int Detector_addRTMPUrl(lua_State* L) /* Verify that query pattern is a valid string */ size_t queryPatternSize; - u_int8_t* queryPattern = nullptr; + uint8_t* queryPattern = nullptr; tmpString = lua_tolstring(L, index++, &queryPatternSize); if (tmpString && queryPatternSize) - queryPattern = (u_int8_t*)snort_strdup(tmpString); + queryPattern = (uint8_t*)snort_strdup(tmpString); - u_int32_t appId = lua_tointeger(L, index++); + uint32_t appId = lua_tointeger(L, index++); /* Allocate memory for data structures */ DetectorAppUrlPattern* pattern = (DetectorAppUrlPattern*)snort_calloc( @@ -2404,7 +2404,7 @@ static int Detector_addSipUserAgent(lua_State* L) /* Verify detector user data and that we are not in packet context */ auto& ud = *UserData::check(L, DETECTOR, index++); - u_int32_t client_app = lua_tointeger(L, index++); + uint32_t client_app = lua_tointeger(L, index++); const char* clientVersion = lua_tostring(L, index++); if (!clientVersion ) { @@ -2656,9 +2656,9 @@ static int openAddUrlPattern(lua_State* L) } AppIdConfig* pConfig = ud->pAppidNewConfig; - u_int32_t serviceAppId = lua_tointeger(L, index++); - u_int32_t clienAppId = lua_tointeger(L, index++); - u_int32_t payloadAppId = lua_tointeger(L, index++); + uint32_t serviceAppId = lua_tointeger(L, index++); + uint32_t clienAppId = lua_tointeger(L, index++); + uint32_t payloadAppId = lua_tointeger(L, index++); if (ud->validateParams.pkt) { @@ -2670,9 +2670,9 @@ static int openAddUrlPattern(lua_State* L) /* Verify that host pattern is a valid string */ size_t hostPatternSize = 0; - u_int8_t* hostPattern = nullptr; + uint8_t* hostPattern = nullptr; tmpString = lua_tolstring(L, index++, &hostPatternSize); - if (!tmpString || !hostPatternSize || !(hostPattern = (u_int8_t* )snort_strdup(tmpString))) + if (!tmpString || !hostPatternSize || !(hostPattern = (uint8_t* )snort_strdup(tmpString))) { ErrorMessage("Invalid host pattern string."); return 0; @@ -2680,9 +2680,9 @@ static int openAddUrlPattern(lua_State* L) /* Verify that path pattern is a valid string */ size_t pathPatternSize = 0; - u_int8_t* pathPattern = nullptr; + uint8_t* pathPattern = nullptr; tmpString = lua_tolstring(L, index++, &pathPatternSize); - if (!tmpString || !pathPatternSize || !(pathPattern = (u_int8_t*)snort_strdup(tmpString))) + if (!tmpString || !pathPatternSize || !(pathPattern = (uint8_t*)snort_strdup(tmpString))) { ErrorMessage("Invalid path pattern string."); snort_free(hostPattern); @@ -2691,9 +2691,9 @@ static int openAddUrlPattern(lua_State* L) /* Verify that scheme pattern is a valid string */ size_t schemePatternSize; - u_int8_t* schemePattern = nullptr; + uint8_t* schemePattern = nullptr; tmpString = lua_tolstring(L, index++, &schemePatternSize); - if (!tmpString || !schemePatternSize || !(schemePattern = (u_int8_t*)snort_strdup(tmpString))) + if (!tmpString || !schemePatternSize || !(schemePattern = (uint8_t*)snort_strdup(tmpString))) { ErrorMessage("Invalid scheme pattern string."); snort_free(pathPattern); @@ -2960,7 +2960,7 @@ static int Detector_addSipServer(lua_State* L) /* Verify detector user data and that we are not in packet context */ auto& ud = *UserData::check(L, DETECTOR, index++); - u_int32_t client_app = lua_tointeger(L, index++); + uint32_t client_app = lua_tointeger(L, index++); const char* clientVersion = lua_tostring(L, index++); if (!clientVersion ) { diff --git a/src/network_inspectors/appid/lua_detector_module.cc b/src/network_inspectors/appid/lua_detector_module.cc index fcd05f30e..24053a2a3 100644 --- a/src/network_inspectors/appid/lua_detector_module.cc +++ b/src/network_inspectors/appid/lua_detector_module.cc @@ -498,9 +498,9 @@ void LuaDetectorModuleManager::luaModuleInit() #define LUA_TRACKERS_MAX 10000 #define LUA_TRACKER_AVG_MEM_BYTES 740 -static inline uint32_t calculateLuaTrackerSize(u_int64_t rnaMemory, uint32_t numDetectors) +static inline uint32_t calculateLuaTrackerSize(uint64_t rnaMemory, uint32_t numDetectors) { - u_int64_t detectorMemory = (rnaMemory/8); + uint64_t detectorMemory = (rnaMemory/8); unsigned numTrackers; if (!numDetectors) numDetectors = 1; diff --git a/src/network_inspectors/appid/service_plugins/service_rpc.cc b/src/network_inspectors/appid/service_plugins/service_rpc.cc index 310bc0eca..fe7d4dc8f 100644 --- a/src/network_inspectors/appid/service_plugins/service_rpc.cc +++ b/src/network_inspectors/appid/service_plugins/service_rpc.cc @@ -27,8 +27,10 @@ #include -#if defined(FREEBSD) || defined(OPENBSD) +#if defined(__FreeBSD__) || defined(__OpenBSD__) #include +#elif defined(__sun) +#include #endif #include "service_api.h" diff --git a/src/network_inspectors/appid/service_plugins/service_ssl.cc b/src/network_inspectors/appid/service_plugins/service_ssl.cc index 7db3eca1f..10354c4da 100644 --- a/src/network_inspectors/appid/service_plugins/service_ssl.cc +++ b/src/network_inspectors/appid/service_plugins/service_ssl.cc @@ -1003,7 +1003,7 @@ bool isSslServiceAppId(AppId appId) return false; } -static int ssl_scan_patterns(SearchTool* matcher, const u_int8_t* pattern, size_t size, +static int ssl_scan_patterns(SearchTool* matcher, const uint8_t* pattern, size_t size, AppId* ClientAppId, AppId* payloadId) { MatchedSSLPatterns* mp = nullptr; @@ -1057,13 +1057,13 @@ static int ssl_scan_patterns(SearchTool* matcher, const u_int8_t* pattern, size_ return 1; } -int ssl_scan_hostname(const u_int8_t* pattern, size_t size, AppId* ClientAppId, AppId* payloadId, +int ssl_scan_hostname(const uint8_t* pattern, size_t size, AppId* ClientAppId, AppId* payloadId, ServiceSslConfig* pSslConfig) { return ssl_scan_patterns(pSslConfig->ssl_host_matcher, pattern, size, ClientAppId, payloadId); } -int ssl_scan_cname(const u_int8_t* pattern, size_t size, AppId* ClientAppId, AppId* payloadId, +int ssl_scan_cname(const uint8_t* pattern, size_t size, AppId* ClientAppId, AppId* payloadId, ServiceSslConfig* pSslConfig) { return ssl_scan_patterns(pSslConfig->ssl_cname_matcher, pattern, size, ClientAppId, payloadId); diff --git a/src/network_inspectors/appid/service_plugins/service_ssl.h b/src/network_inspectors/appid/service_plugins/service_ssl.h index 83aa62ba4..1b8c45c89 100644 --- a/src/network_inspectors/appid/service_plugins/service_ssl.h +++ b/src/network_inspectors/appid/service_plugins/service_ssl.h @@ -30,8 +30,8 @@ AppId getSslServiceAppId(short srcPort); bool isSslServiceAppId(AppId); void service_ssl_clean(ServiceSslConfig*); int ssl_detector_process_patterns(ServiceSslConfig*); -int ssl_scan_hostname(const u_int8_t*, size_t, AppId*, AppId*, ServiceSslConfig*); -int ssl_scan_cname(const u_int8_t*, size_t, AppId*, AppId*, ServiceSslConfig*); +int ssl_scan_hostname(const uint8_t*, size_t, AppId*, AppId*, ServiceSslConfig*); +int ssl_scan_cname(const uint8_t*, size_t, AppId*, AppId*, ServiceSslConfig*); int ssl_add_cert_pattern(uint8_t*, size_t, uint8_t, AppId, ServiceSslConfig*); int ssl_add_cname_pattern(uint8_t*, size_t, uint8_t, AppId, ServiceSslConfig*); void ssl_detector_free_patterns(ServiceSslConfig*); diff --git a/src/network_inspectors/appid/service_plugins/service_timbuktu.cc b/src/network_inspectors/appid/service_plugins/service_timbuktu.cc index 10fedd7f7..8a2efccd7 100644 --- a/src/network_inspectors/appid/service_plugins/service_timbuktu.cc +++ b/src/network_inspectors/appid/service_plugins/service_timbuktu.cc @@ -101,7 +101,7 @@ static const AppRegistryEntry appIdRegistry[] = static int timbuktu_init(const IniServiceAPI* const init_api) { init_api->RegisterPattern(&timbuktu_validate, IpProtocol::TCP, (const - u_int8_t*)TIMBUKTU_BANNER, + uint8_t*)TIMBUKTU_BANNER, sizeof(TIMBUKTU_BANNER)-1, 0, svc_name, init_api->pAppidConfig); for (unsigned i=0; i < sizeof(appIdRegistry)/sizeof(*appIdRegistry); i++) { diff --git a/src/network_inspectors/arp_spoof/arp_spoof.cc b/src/network_inspectors/arp_spoof/arp_spoof.cc index 5d2a7d364..4981a5f05 100644 --- a/src/network_inspectors/arp_spoof/arp_spoof.cc +++ b/src/network_inspectors/arp_spoof/arp_spoof.cc @@ -119,7 +119,7 @@ static void PrintIPMacEntryList(IPMacEntryList& ipmel) return; LogMessage("Arpspoof IPMacEntry List"); - LogMessage(" Size: %ld\n", ipmel.size()); + LogMessage(" Size: %zu\n", ipmel.size()); for ( auto p : ipmel ) { diff --git a/src/network_inspectors/binder/bind_module.cc b/src/network_inspectors/binder/bind_module.cc index 77924686b..591b44e6f 100644 --- a/src/network_inspectors/binder/bind_module.cc +++ b/src/network_inspectors/binder/bind_module.cc @@ -24,7 +24,6 @@ #include #include -using namespace std; #include "binding.h" #include "protocols/packet.h" @@ -35,6 +34,8 @@ using namespace std; #include "managers/module_manager.h" #include "parser/parser.h" +using namespace std; + #define FILE_KEY ".file" THREAD_LOCAL BindStats bstats; diff --git a/src/network_inspectors/binder/binder.cc b/src/network_inspectors/binder/binder.cc index 06685b034..31ab2899b 100644 --- a/src/network_inspectors/binder/binder.cc +++ b/src/network_inspectors/binder/binder.cc @@ -20,7 +20,6 @@ #include "binder.h" #include -using namespace std; #include "binding.h" #include "bind_module.h" @@ -44,6 +43,8 @@ using namespace std; #include "target_based/sftarget_reader.h" #include "packet_io/active.h" +using namespace std; + THREAD_LOCAL ProfileStats bindPerfStats; // FIXIT-P these lookups should be optimized when the dust settles diff --git a/src/network_inspectors/packet_capture/packet_capture.cc b/src/network_inspectors/packet_capture/packet_capture.cc index 23b058680..0eadb954f 100644 --- a/src/network_inspectors/packet_capture/packet_capture.cc +++ b/src/network_inspectors/packet_capture/packet_capture.cc @@ -24,7 +24,7 @@ #include "packet_capture.h" -#include +#include #include #include @@ -38,11 +38,11 @@ #include "catch/catch.hpp" #endif +using namespace std; + #define FILE_NAME "packet_capture.pcap" #define SNAP_LEN 65535 -using namespace std; - static CaptureConfig config; static THREAD_LOCAL pcap_t* pcap = nullptr; diff --git a/src/network_inspectors/perf_monitor/base_tracker.cc b/src/network_inspectors/perf_monitor/base_tracker.cc index e2149e478..8aefd9e0c 100644 --- a/src/network_inspectors/perf_monitor/base_tracker.cc +++ b/src/network_inspectors/perf_monitor/base_tracker.cc @@ -28,10 +28,10 @@ #include "utils/util.h" #endif -#define BASE_FILE (PERF_NAME ".csv") - using namespace std; +#define BASE_FILE (PERF_NAME ".csv") + BaseTracker::BaseTracker(PerfConfig* perf) : PerfTracker(perf, perf->output == PERF_FILE ? BASE_FILE : nullptr) { diff --git a/src/network_inspectors/perf_monitor/cpu_tracker.cc b/src/network_inspectors/perf_monitor/cpu_tracker.cc index 72594d754..da4e77e29 100644 --- a/src/network_inspectors/perf_monitor/cpu_tracker.cc +++ b/src/network_inspectors/perf_monitor/cpu_tracker.cc @@ -67,7 +67,11 @@ void CPUTracker::get_clocks(struct timeval& user_time, sys_time.tv_usec = thi->system_time.microseconds; #else struct rusage usage; +#ifdef RUSAGE_LWP + getrusage(RUSAGE_LWP, &usage); +#else getrusage(RUSAGE_THREAD, &usage); +#endif user_time = usage.ru_utime; sys_time = usage.ru_stime; #endif diff --git a/src/packet_io/sfdaq.cc b/src/packet_io/sfdaq.cc index 3f7a3a61a..1c00e682b 100644 --- a/src/packet_io/sfdaq.cc +++ b/src/packet_io/sfdaq.cc @@ -419,7 +419,7 @@ bool SFDAQInstance::can_whitelist() bool SFDAQInstance::set_filter(const char* bpf) { int err = 0; - static mutex bpf_gate; + static std::mutex bpf_gate; // doesn't look like the bpf flex scanner is reentrant bpf_gate.lock(); diff --git a/src/packet_io/sfdaq.h b/src/packet_io/sfdaq.h index ee0e8d77f..7bee63cea 100644 --- a/src/packet_io/sfdaq.h +++ b/src/packet_io/sfdaq.h @@ -23,7 +23,7 @@ #define SFDAQ_H extern "C" { -#include +#include } #include diff --git a/src/parser/cmd_line.cc b/src/parser/cmd_line.cc index c8a975086..b0a8f11e5 100644 --- a/src/parser/cmd_line.cc +++ b/src/parser/cmd_line.cc @@ -24,7 +24,6 @@ #endif #include -using namespace std; #include "main/help.h" #include "main/snort_module.h" @@ -36,6 +35,8 @@ using namespace std; #include "parser/parser.h" #include "utils/util.h" +using namespace std; + //------------------------------------------------------------------------- static void check_flags(SnortConfig* sc) diff --git a/src/parser/parse_stream.cc b/src/parser/parse_stream.cc index 55ed4b668..1e1d0497c 100644 --- a/src/parser/parse_stream.cc +++ b/src/parser/parse_stream.cc @@ -26,7 +26,6 @@ #include #include #include -using namespace std; #include "parser.h" #include "parse_conf.h" @@ -35,6 +34,8 @@ using namespace std; #include "log/messages.h" #include "managers/ips_manager.h" +using namespace std; + static unsigned chars = 0, tokens = 0; static unsigned lines = 1, comments = 0; static unsigned keys = 0, rules = 0; diff --git a/src/piglet/piglet_manager.cc b/src/piglet/piglet_manager.cc index b78c2dba9..1a1532e46 100644 --- a/src/piglet/piglet_manager.cc +++ b/src/piglet/piglet_manager.cc @@ -43,7 +43,7 @@ using namespace std; // Manager State // ----------------------------------------------------------------------------- -map plugins; +std::map plugins; vector chunks; // ----------------------------------------------------------------------------- diff --git a/src/piglet/piglet_output.cc b/src/piglet/piglet_output.cc index bb07d5b5a..0c3b5d484 100644 --- a/src/piglet/piglet_output.cc +++ b/src/piglet/piglet_output.cc @@ -80,7 +80,7 @@ namespace Piglet const struct Output unit_test_output = { [](const std::vector& chunks) -> void - { printf("Running suite: piglet (%lu tests)\n", chunks.size()); }, + { printf("Running suite: piglet (%zu tests)\n", chunks.size()); }, [](const Summary& sum) -> void { @@ -179,7 +179,7 @@ const struct Output verbose_output = if ( chunks.size() == 1 ) printf("=== PIGLET (1 test)\n"); else - printf("=== PIGLET (%lu tests)\n", chunks.size()); + printf("=== PIGLET (%zu tests)\n", chunks.size()); }, [](const Summary& sum) -> void diff --git a/src/piglet_plugins/pp_daq_pkthdr_iface.cc b/src/piglet_plugins/pp_daq_pkthdr_iface.cc index 7964ccbb3..94993f960 100644 --- a/src/piglet_plugins/pp_daq_pkthdr_iface.cc +++ b/src/piglet_plugins/pp_daq_pkthdr_iface.cc @@ -27,7 +27,7 @@ #include extern "C" { -#include +#include } #include "lua/lua_arg.h" diff --git a/src/protocols/packet.cc b/src/protocols/packet.cc index 936d12ed8..7a127f568 100644 --- a/src/protocols/packet.cc +++ b/src/protocols/packet.cc @@ -39,10 +39,9 @@ Packet::Packet(bool packet_data) } else { - uint8_t* b = new uint8_t[sizeof(*pkth) + Codec::PKT_MAX + SPARC_TWIDDLE]; + uint8_t* b = new uint8_t[sizeof(*pkth) + Codec::PKT_MAX]; pkth = (DAQ_PktHdr_t*)b; b += sizeof(*pkth); - b += SPARC_TWIDDLE; pkt = b; } diff --git a/src/protocols/packet.h b/src/protocols/packet.h index ef5123446..43516ec39 100644 --- a/src/protocols/packet.h +++ b/src/protocols/packet.h @@ -31,8 +31,7 @@ #include extern "C" { -#include -#include +#include } #include "main/snort_types.h" @@ -100,16 +99,6 @@ enum PseudoPacketType PSEUDO_PKT_MAX }; -/* We must twiddle to align the offset the ethernet header and align - * the IP header on solaris -- maybe this will work on HPUX too. - */ -#if defined (SOLARIS) || defined (SUNOS) || defined (__sparc__) || defined(__sparc64__) || \ - defined (HPUX) -#define SPARC_TWIDDLE 2 -#else -#define SPARC_TWIDDLE 0 -#endif - /* default mpls flags */ #define DEFAULT_MPLS_PAYLOADTYPE MPLS_PAYLOADTYPE_IPV4 #define DEFAULT_LABELCHAIN_LENGTH -1 @@ -295,21 +284,6 @@ inline void SetExtraData(Packet* p, const uint32_t xid) inline uint16_t extract_16bits(const uint8_t* const p) { return ntohs(*(uint16_t*)(p)); } -#ifdef WORDS_MUSTALIGN - -#ifdef __GNUC__ -/* force word-aligned ntohl parameter */ -inline uint32_t extract_32bits(const uint8_t* p) -{ - uint32_t tmp; - memmove(&tmp, p, sizeof(uint32_t)); - return ntohl(tmp); -} -#endif - -#else - -/* allows unaligned ntohl parameter - dies w/SIGBUS on SPARCs */ inline uint32_t extract_32bits(const uint8_t* p) { assert(p); @@ -317,8 +291,6 @@ inline uint32_t extract_32bits(const uint8_t* p) return ntohl(*(uint32_t*)p); } -#endif - inline uint16_t alignedNtohs(const uint16_t* ptr) { uint16_t value; @@ -326,11 +298,7 @@ inline uint16_t alignedNtohs(const uint16_t* ptr) if (ptr == nullptr) return 0; -#ifdef WORDS_MUSTALIGN - value = *((uint8_t*)ptr) << 8 | *((uint8_t*)ptr + 1); -#else value = *ptr; -#endif #ifdef WORDS_BIGENDIAN return ((value & 0xff00) >> 8) | ((value & 0x00ff) << 8); @@ -346,12 +314,7 @@ inline uint32_t alignedNtohl(const uint32_t* ptr) if (ptr == nullptr) return 0; -#ifdef WORDS_MUSTALIGN - value = *((uint8_t*)ptr) << 24 | *((uint8_t*)ptr + 1) << 16 | - *((uint8_t*)ptr + 2) << 8 | *((uint8_t*)ptr + 3); -#else value = *ptr; -#endif #ifdef WORDS_BIGENDIAN return ((value & 0xff000000) >> 24) | ((value & 0x00ff0000) >> 8) | @@ -368,14 +331,7 @@ inline uint64_t alignedNtohq(const uint64_t* ptr) if (ptr == NULL) return 0; -#ifdef WORDS_MUSTALIGN - value = *((uint8_t*)ptr) << 56 | *((uint8_t*)ptr + 1) << 48 | - *((uint8_t*)ptr + 2) << 40 | *((uint8_t*)ptr + 3) << 32 | - *((uint8_t*)ptr + 4) << 24 | *((uint8_t*)ptr + 5) << 16 | - *((uint8_t*)ptr + 6) << 8 | *((uint8_t*)ptr + 7); -#else value = *ptr; -#endif #ifdef WORDS_BIGENDIAN return ((value & 0xff00000000000000) >> 56) | ((value & 0x00ff000000000000) >> 40) | diff --git a/src/protocols/packet_manager.cc b/src/protocols/packet_manager.cc index bb562d40d..5a6e26d94 100644 --- a/src/protocols/packet_manager.cc +++ b/src/protocols/packet_manager.cc @@ -311,7 +311,6 @@ void PacketManager::decode( // - don't include original options // - inner layer differs from original (eg tcp data segment becomes rst) // - must ensure proper ttl/hop limit for reverse direction -// - sparc twiddle must be factored in packet start for transmission // // iterate over decoded layers and encode the response packet. actually // make nested calls. on the way in we setup invariant stuff and as we diff --git a/src/service_inspectors/dce_rpc/dce_smb2.cc b/src/service_inspectors/dce_rpc/dce_smb2.cc index 980d13242..098f76612 100644 --- a/src/service_inspectors/dce_rpc/dce_smb2.cc +++ b/src/service_inspectors/dce_rpc/dce_smb2.cc @@ -379,7 +379,7 @@ static void DCE2_Smb2CreateResponse(DCE2_SmbSsnData* ssd, const Smb2Hdr*, if (smb_create_hdr->end_of_file) { file_size = alignedNtohq((const uint64_t*)(&(smb_create_hdr->end_of_file))); - DebugFormat(DEBUG_DCE_SMB, "Get file size %lu!\n", file_size); + DebugFormat(DEBUG_DCE_SMB, "Get file size %" PRIu64 "!\n", file_size); ssd->ftracker.tracker.file.file_size = file_size; } @@ -498,7 +498,7 @@ static void DCE2_Smb2SetInfo(DCE2_SmbSsnData* ssd, const Smb2Hdr*, if (smb_set_info_hdr->file_info_class == SMB2_FILE_ENDOFFILE_INFO) { uint64_t file_size = alignedNtohq((const uint64_t*)file_data); - DebugFormat(DEBUG_DCE_SMB, "Get file size %lu!\n", file_size); + DebugFormat(DEBUG_DCE_SMB, "Get file size %" PRIu64 "!\n", file_size); ssd->ftracker.tracker.file.file_size = file_size; uint64_t fileId_persistent = alignedNtohq(&(smb_set_info_hdr->fileId_persistent)); FileContext* file = get_file_context(ssd, fileId_persistent); diff --git a/src/service_inspectors/dce_rpc/dce_smb_utils.cc b/src/service_inspectors/dce_rpc/dce_smb_utils.cc index e4bd70e35..d2145ba54 100644 --- a/src/service_inspectors/dce_rpc/dce_smb_utils.cc +++ b/src/service_inspectors/dce_rpc/dce_smb_utils.cc @@ -1795,7 +1795,7 @@ void DCE2_SmbProcessFileData(DCE2_SmbSsnData* ssd, Profile profile(dce2_smb_pstat_smb_file); DebugFormat(DEBUG_DCE_SMB, - "File size: %lu, File offset: %lu, Bytes processed: %lu, " + "File size: %" PRIu64 ", File offset: %" PRIu64 ", Bytes processed: %" PRIu64 ", " "Data len: %u\n", ftracker->ff_file_size, ftracker->ff_file_offset, ftracker->ff_bytes_processed, data_len); @@ -1875,8 +1875,8 @@ void DCE2_SmbProcessFileData(DCE2_SmbSsnData* ssd, } else if (ftracker->ff_file_offset < ftracker->ff_bytes_processed) { - DebugFormat(DEBUG_DCE_SMB, "File offset %lu is " - "less than bytes processed %lu - aborting.\n", + DebugFormat(DEBUG_DCE_SMB, "File offset %" PRIu64 " is " + "less than bytes processed %" PRIu64 " - aborting.\n", ftracker->ff_file_offset, ftracker->ff_bytes_processed); DCE2_SmbAbortFileAPI(ssd); @@ -1918,8 +1918,8 @@ void DCE2_SmbProcessFileData(DCE2_SmbSsnData* ssd, || ((file_data_depth != 0) && (ftracker->ff_bytes_processed >= (uint64_t)file_data_depth))) { - DebugFormat(DEBUG_DCE_SMB, "Bytes processed %lu " - "is at or beyond file data depth %lu - finished.\n", + DebugFormat(DEBUG_DCE_SMB, "Bytes processed %" PRIu64 + "is at or beyond file data depth %" PRIi64 " - finished.\n", ftracker->ff_bytes_processed, file_data_depth); DCE2_SmbRemoveFileTracker(ssd, ftracker); diff --git a/src/service_inspectors/dce_rpc/dce_utils.h b/src/service_inspectors/dce_rpc/dce_utils.h index e47d75136..e821c23f5 100644 --- a/src/service_inspectors/dce_rpc/dce_utils.h +++ b/src/service_inspectors/dce_rpc/dce_utils.h @@ -293,11 +293,7 @@ inline uint16_t DceRpcNtohs(const uint16_t* ptr, const DceRpcBoFlag bo_flag) if (ptr == nullptr) return 0; -#ifdef WORDS_MUSTALIGN - value = *((uint8_t*)ptr) << 8 | *((uint8_t*)ptr + 1); -#else value = *ptr; -#endif /* WORDS_MUSTALIGN */ if (bo_flag == DCERPC_BO_FLAG__NONE) return value; @@ -324,12 +320,7 @@ inline uint32_t DceRpcNtohl(const uint32_t* ptr, const DceRpcBoFlag bo_flag) if (ptr == nullptr) return 0; -#ifdef WORDS_MUSTALIGN - value = *((uint8_t*)ptr) << 24 | *((uint8_t*)ptr + 1) << 16 | - *((uint8_t*)ptr + 2) << 8 | *((uint8_t*)ptr + 3); -#else value = *ptr; -#endif /* WORDS_MUSTALIGN */ if (bo_flag == DCERPC_BO_FLAG__NONE) return value; diff --git a/src/service_inspectors/rpc_decode/rpc_decode.cc b/src/service_inspectors/rpc_decode/rpc_decode.cc index 110c7daf7..0d03ed638 100644 --- a/src/service_inspectors/rpc_decode/rpc_decode.cc +++ b/src/service_inspectors/rpc_decode/rpc_decode.cc @@ -61,14 +61,14 @@ #include "rpc_module.h" +using namespace std; + #define RPC_MAX_BUF_SIZE 256 #define RPC_FRAG_HDR_SIZE sizeof(uint32_t) #define RPC_FRAG_LEN(ptr) (ntohl(*((uint32_t*)ptr)) & 0x7FFFFFFF) static THREAD_LOCAL DataBuffer DecodeBuffer; -using namespace std; - struct RpcDecodeConfig { int dummy; diff --git a/src/service_inspectors/sip/sip_parser.cc b/src/service_inspectors/sip/sip_parser.cc index aa496f088..e1abe93c6 100644 --- a/src/service_inspectors/sip/sip_parser.cc +++ b/src/service_inspectors/sip/sip_parser.cc @@ -898,7 +898,7 @@ static int sip_parse_cseq(SIPMsg* msg, const char* start, const char* end, SIP_P msg->cseqNameLen = end - msg->cseqName; method = SIP_FindMethod (config->methods, msg->cseqName, msg->cseqNameLen); } - DebugFormat(DEBUG_SIP, "CSeq number: %lu, CSeqName: %.*s\n", + DebugFormat(DEBUG_SIP, "CSeq number: %" PRIu64 ", CSeqName: %.*s\n", msg->cseqnum, msg->cseqNameLen, msg->cseqName); if (NULL == method) diff --git a/src/service_inspectors/wizard/wiz_module.cc b/src/service_inspectors/wizard/wiz_module.cc index b03130b02..413df4a63 100644 --- a/src/service_inspectors/wizard/wiz_module.cc +++ b/src/service_inspectors/wizard/wiz_module.cc @@ -24,10 +24,11 @@ #include #include -using namespace std; #include "magic.h" +using namespace std; + //------------------------------------------------------------------------- // wizard module //------------------------------------------------------------------------- diff --git a/src/service_inspectors/wizard/wizard.cc b/src/service_inspectors/wizard/wizard.cc index 23d22d1fb..43b972db5 100644 --- a/src/service_inspectors/wizard/wizard.cc +++ b/src/service_inspectors/wizard/wizard.cc @@ -18,7 +18,6 @@ // wizard.cc author Russ Combs #include -using namespace std; #include "flow/flow.h" #include "framework/inspector.h" @@ -33,6 +32,8 @@ using namespace std; #include "magic.h" #include "wiz_module.h" +using namespace std; + THREAD_LOCAL ProfileStats wizPerfStats; struct WizStats diff --git a/src/sfip/sf_ip.h b/src/sfip/sf_ip.h index 7a3e694d0..cd56fcba4 100644 --- a/src/sfip/sf_ip.h +++ b/src/sfip/sf_ip.h @@ -102,7 +102,7 @@ inline unsigned int sfip_size(const sfip_t* ipt) { if ( ipt->family == AF_INET6 ) return sizeof(*ipt); - return (unsigned int)((ipt->ip8+4) - (u_int8_t*)ipt); + return (unsigned int)((ipt->ip8+4) - (uint8_t*)ipt); } /* Member-access *******************************************************/ @@ -209,10 +209,10 @@ inline int sfip_is_loopback(const sfip_t* ip) int sfip_ismapped(const sfip_t* ip); /* Support function for sfip_compare */ -inline SFIP_RET _ip4_cmp(u_int32_t ip1, u_int32_t ip2) +inline SFIP_RET _ip4_cmp(uint32_t ip1, uint32_t ip2) { - u_int32_t hip1 = htonl(ip1); - u_int32_t hip2 = htonl(ip2); + uint32_t hip1 = htonl(ip1); + uint32_t hip2 = htonl(ip2); if (hip1 < hip2) return SFIP_LESSER; if (hip1 > hip2) @@ -224,7 +224,7 @@ inline SFIP_RET _ip4_cmp(u_int32_t ip1, u_int32_t ip2) inline SFIP_RET _ip6_cmp(const sfip_t* ip1, const sfip_t* ip2) { SFIP_RET ret; - const u_int32_t* p1, * p2; + const uint32_t* p1, * p2; /* XXX * Argument are assumed trusted! @@ -363,7 +363,7 @@ inline int sfip_fast_eq4(const sfip_t* const ip1, const sfip_t* const ip2) inline int sfip_fast_lt6(const sfip_t* const ip1, const sfip_t* const ip2) { - const u_int32_t* p1, * p2; + const uint32_t* p1, * p2; p1 = ip1->ip32; p2 = ip2->ip32; @@ -393,7 +393,7 @@ inline int sfip_fast_lt6(const sfip_t* const ip1, const sfip_t* const ip2) inline int sfip_fast_gt6(const sfip_t* const ip1, const sfip_t* const ip2) { - const u_int32_t* p1, * p2; + const uint32_t* p1, * p2; p1 = ip1->ip32; p2 = ip2->ip32; @@ -423,7 +423,7 @@ inline int sfip_fast_gt6(const sfip_t* const ip1, const sfip_t* const ip2) inline int sfip_fast_eq6(const sfip_t* ip1, const sfip_t* ip2) { - const u_int32_t* p1, * p2; + const uint32_t* p1, * p2; p1 = ip1->ip32; p2 = ip2->ip32; @@ -443,8 +443,8 @@ inline int sfip_fast_eq6(const sfip_t* ip1, const sfip_t* ip2) /* Checks if ip2 is equal to ip1 or contained within the CIDR ip1 */ inline bool sfip_fast_cont4(const sfip_t* ip1, const sfip_t* ip2) { - u_int32_t shift = 32 - sfip_bits(ip1); - u_int32_t ip = ntohl(*ip2->ip32); + uint32_t shift = 32 - sfip_bits(ip1); + uint32_t ip = ntohl(*ip2->ip32); ip >>= shift; ip <<= shift; @@ -455,7 +455,7 @@ inline bool sfip_fast_cont4(const sfip_t* ip1, const sfip_t* ip2) /* Checks if ip2 is equal to ip1 or contained within the CIDR ip1 */ inline int sfip_fast_cont6(const sfip_t* ip1, const sfip_t* ip2) { - u_int32_t ip; + uint32_t ip; int i, bits = sfip_bits(ip1); int words = bits / 32; bits = 32 - (bits % 32); diff --git a/src/stream/file/file_module.cc b/src/stream/file/file_module.cc index f55b24061..9de2ba204 100644 --- a/src/stream/file/file_module.cc +++ b/src/stream/file/file_module.cc @@ -20,11 +20,12 @@ #include "file_module.h" #include -using namespace std; #include "stream_file.h" #include "main/snort_config.h" +using namespace std; + //------------------------------------------------------------------------- // stream_file module //------------------------------------------------------------------------- diff --git a/src/stream/icmp/icmp_module.cc b/src/stream/icmp/icmp_module.cc index 9d9205e0b..a470b23aa 100644 --- a/src/stream/icmp/icmp_module.cc +++ b/src/stream/icmp/icmp_module.cc @@ -21,10 +21,11 @@ #include "icmp_module.h" #include -using namespace std; #include "stream_icmp.h" +using namespace std; + //------------------------------------------------------------------------- // stream_icmp module //------------------------------------------------------------------------- diff --git a/src/stream/ip/ip_defrag.cc b/src/stream/ip/ip_defrag.cc index 01a04b493..f115786a1 100644 --- a/src/stream/ip/ip_defrag.cc +++ b/src/stream/ip/ip_defrag.cc @@ -209,7 +209,7 @@ static void FragPrintEngineConfig(FragEngine* engine) LogMessage(" Min fragment Length: %d\n", engine->min_fragment_length); #ifdef REG_TEST - LogMessage(" FragTracker Size: %lu\n",sizeof(FragTracker)); + LogMessage(" FragTracker Size: %zu\n", sizeof(FragTracker)); #endif } diff --git a/src/stream/ip/ip_module.cc b/src/stream/ip/ip_module.cc index 352d63abd..fc1096c29 100644 --- a/src/stream/ip/ip_module.cc +++ b/src/stream/ip/ip_module.cc @@ -21,12 +21,13 @@ #include "ip_module.h" #include -using namespace std; #include "stream_ip.h" #include "ip_defrag.h" #include "stream/stream.h" +using namespace std; + #define DEFRAG_IPOPTIONS_STR \ "inconsistent IP options on fragmented packets" diff --git a/src/stream/libtcp/tcp_state_handler.cc b/src/stream/libtcp/tcp_state_handler.cc index 64ef7b2e4..63be0961a 100644 --- a/src/stream/libtcp/tcp_state_handler.cc +++ b/src/stream/libtcp/tcp_state_handler.cc @@ -20,7 +20,6 @@ // Created on: Jun 24, 2015 #include -using namespace std; #include "main/snort_debug.h" @@ -32,6 +31,8 @@ using namespace std; #include "stream_tcp_unit_test.h" #endif +using namespace std; + TcpStateHandler::TcpStateHandler(TcpStreamTracker::TcpState state, TcpStateMachine& tsm) : tsm(&tsm), tcp_state(state) { diff --git a/src/stream/tcp/tcp_state_close_wait.cc b/src/stream/tcp/tcp_state_close_wait.cc index 96eb85f0f..15d17df5d 100644 --- a/src/stream/tcp/tcp_state_close_wait.cc +++ b/src/stream/tcp/tcp_state_close_wait.cc @@ -20,7 +20,6 @@ // Created on: Aug 5, 2015 #include -using namespace std; #include "tcp_module.h" #include "tcp_tracker.h" @@ -32,6 +31,8 @@ using namespace std; #include "catch/catch.hpp" #endif +using namespace std; + TcpStateCloseWait::TcpStateCloseWait(TcpStateMachine& tsm) : TcpStateHandler(TcpStreamTracker::TCP_CLOSE_WAIT, tsm) { diff --git a/src/stream/tcp/tcp_state_closing.cc b/src/stream/tcp/tcp_state_closing.cc index ab8020a94..9a86024cc 100644 --- a/src/stream/tcp/tcp_state_closing.cc +++ b/src/stream/tcp/tcp_state_closing.cc @@ -20,7 +20,6 @@ // Created on: Aug 5, 2015 #include -using namespace std; #include "tcp_module.h" #include "tcp_tracker.h" @@ -32,6 +31,8 @@ using namespace std; #include "catch/catch.hpp" #endif +using namespace std; + TcpStateClosing::TcpStateClosing(TcpStateMachine& tsm) : TcpStateHandler(TcpStreamTracker::TCP_CLOSING, tsm) { diff --git a/src/stream/tcp/tcp_state_fin_wait1.cc b/src/stream/tcp/tcp_state_fin_wait1.cc index eb4d1f4e9..e40665e8c 100644 --- a/src/stream/tcp/tcp_state_fin_wait1.cc +++ b/src/stream/tcp/tcp_state_fin_wait1.cc @@ -20,7 +20,6 @@ // Created on: Aug 5, 2015 #include -using namespace std; #include "tcp_module.h" #include "tcp_tracker.h" @@ -32,6 +31,8 @@ using namespace std; #include "catch/catch.hpp" #endif +using namespace std; + TcpStateFinWait1::TcpStateFinWait1(TcpStateMachine& tsm) : TcpStateHandler(TcpStreamTracker::TCP_FIN_WAIT1, tsm) { diff --git a/src/stream/tcp/tcp_state_fin_wait2.cc b/src/stream/tcp/tcp_state_fin_wait2.cc index cb75a85c2..a9e4415a2 100644 --- a/src/stream/tcp/tcp_state_fin_wait2.cc +++ b/src/stream/tcp/tcp_state_fin_wait2.cc @@ -20,7 +20,6 @@ // Created on: Aug 5, 2015 #include -using namespace std; #include "tcp_module.h" #include "tcp_tracker.h" @@ -32,6 +31,8 @@ using namespace std; #include "catch/catch.hpp" #endif +using namespace std; + TcpStateFinWait2::TcpStateFinWait2(TcpStateMachine& tsm) : TcpStateHandler(TcpStreamTracker::TCP_FIN_WAIT2, tsm) { diff --git a/src/stream/tcp/tcp_state_last_ack.cc b/src/stream/tcp/tcp_state_last_ack.cc index e047ae168..59559ed20 100644 --- a/src/stream/tcp/tcp_state_last_ack.cc +++ b/src/stream/tcp/tcp_state_last_ack.cc @@ -20,7 +20,6 @@ // Created on: Aug 5, 2015 #include -using namespace std; #include "tcp_module.h" #include "tcp_tracker.h" @@ -32,6 +31,8 @@ using namespace std; #include "catch/catch.hpp" #endif +using namespace std; + TcpStateLastAck::TcpStateLastAck(TcpStateMachine& tsm) : TcpStateHandler(TcpStreamTracker::TCP_LAST_ACK, tsm) { diff --git a/src/stream/tcp/tcp_state_syn_recv.cc b/src/stream/tcp/tcp_state_syn_recv.cc index badae22d1..8480d7c71 100644 --- a/src/stream/tcp/tcp_state_syn_recv.cc +++ b/src/stream/tcp/tcp_state_syn_recv.cc @@ -20,7 +20,6 @@ // Created on: Aug 5, 2015 #include -using namespace std; #include "tcp_module.h" #include "tcp_tracker.h" @@ -28,6 +27,8 @@ using namespace std; #include "tcp_normalizer.h" #include "tcp_state_syn_recv.h" +using namespace std; + TcpStateSynRecv::TcpStateSynRecv(TcpStateMachine& tsm) : TcpStateHandler(TcpStreamTracker::TCP_SYN_RECV, tsm) { diff --git a/src/stream/tcp/tcp_state_syn_sent.cc b/src/stream/tcp/tcp_state_syn_sent.cc index 7e1c75412..881e8b0e3 100644 --- a/src/stream/tcp/tcp_state_syn_sent.cc +++ b/src/stream/tcp/tcp_state_syn_sent.cc @@ -20,7 +20,6 @@ // Created on: Aug 5, 2015 #include -using namespace std; #include "tcp_module.h" #include "tcp_tracker.h" @@ -32,6 +31,8 @@ using namespace std; #include "catch/catch.hpp" #endif +using namespace std; + TcpStateSynSent::TcpStateSynSent(TcpStateMachine& tsm) : TcpStateHandler(TcpStreamTracker::TCP_SYN_SENT, tsm) { diff --git a/src/stream/tcp/tcp_state_time_wait.cc b/src/stream/tcp/tcp_state_time_wait.cc index 02b10538d..0900b7fe0 100644 --- a/src/stream/tcp/tcp_state_time_wait.cc +++ b/src/stream/tcp/tcp_state_time_wait.cc @@ -20,7 +20,6 @@ // Created on: Aug 5, 2015 #include -using namespace std; #include "tcp_module.h" #include "tcp_tracker.h" @@ -32,6 +31,8 @@ using namespace std; #include "catch/catch.hpp" #endif +using namespace std; + TcpStateTimeWait::TcpStateTimeWait(TcpStateMachine& tsm) : TcpStateHandler(TcpStreamTracker::TCP_TIME_WAIT, tsm) { diff --git a/src/stream/udp/stream_udp.cc b/src/stream/udp/stream_udp.cc index e2757ff76..0020bef19 100644 --- a/src/stream/udp/stream_udp.cc +++ b/src/stream/udp/stream_udp.cc @@ -48,7 +48,7 @@ static void udp_show(StreamUdpConfig* pc) LogMessage(" Ignore Any -> Any Rules: %s\n", opt); #ifdef REG_TEST - LogMessage(" UDP Session Size: %lu\n",sizeof(UdpSession)); + LogMessage(" UDP Session Size: %zu\n", sizeof(UdpSession)); #endif } diff --git a/src/stream/udp/udp_module.cc b/src/stream/udp/udp_module.cc index f8062ad71..939fb0281 100644 --- a/src/stream/udp/udp_module.cc +++ b/src/stream/udp/udp_module.cc @@ -21,10 +21,11 @@ #include "udp_module.h" #include -using namespace std; #include "stream_udp.h" +using namespace std; + //------------------------------------------------------------------------- // stream_udp module //------------------------------------------------------------------------- diff --git a/src/stream/user/user_module.cc b/src/stream/user/user_module.cc index a2afce61d..6726df9ea 100644 --- a/src/stream/user/user_module.cc +++ b/src/stream/user/user_module.cc @@ -20,11 +20,12 @@ #include "user_module.h" #include -using namespace std; #include "stream_user.h" #include "main/snort_config.h" +using namespace std; + //------------------------------------------------------------------------- // stream_user module //------------------------------------------------------------------------- diff --git a/src/target_based/snort_protocols.cc b/src/target_based/snort_protocols.cc index 9bdde5a6b..1a7b1cb04 100644 --- a/src/target_based/snort_protocols.cc +++ b/src/target_based/snort_protocols.cc @@ -24,7 +24,6 @@ #include #include #include -using namespace std; #include "hash/sfghash.h" #include "main/snort_debug.h" @@ -35,6 +34,8 @@ using namespace std; #include "sftarget_hostentry.h" #include "sftarget_data.h" +using namespace std; + struct SFTargetProtocolReference { char name[SFAT_BUFSZ]; diff --git a/src/utils/util.h b/src/utils/util.h index c0c5d8bb9..10265c471 100644 --- a/src/utils/util.h +++ b/src/utils/util.h @@ -40,7 +40,7 @@ #include #include -#ifdef LINUX +#if defined(__linux__) #include #endif @@ -211,7 +211,7 @@ inline int SnortStrToU32(const char* buffer, char** endptr, inline pid_t gettid() { -#if defined(LINUX) && defined(SYS_gettid) +#if defined(__linux__) && defined(SYS_gettid) return syscall(SYS_gettid); #else return getpid();