]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Merge pull request #1260 in SNORT/snort3 from snort_namespace_sweep to master
authorTom Peters (thopeter) <thopeter@cisco.com>
Tue, 12 Jun 2018 18:29:39 +0000 (14:29 -0400)
committerTom Peters (thopeter) <thopeter@cisco.com>
Tue, 12 Jun 2018 18:29:39 +0000 (14:29 -0400)
Squashed commit of the following:

commit dbcef856c2243ded126485e50515f964c2d61b48
Author: davis mcpherson <davmcphe.cisco.com>
Date:   Fri Mar 16 06:55:42 2018 -0400

    snort: wrap snort SO_PUBLIC symbols in the snort namespace

211 files changed:
src/connectors/file_connector/test/file_connector_module_test.cc
src/connectors/file_connector/test/file_connector_test.cc
src/connectors/tcp_connector/test/tcp_connector_module_test.cc
src/connectors/tcp_connector/test/tcp_connector_test.cc
src/decompress/file_decomp.cc
src/decompress/file_decomp.h
src/decompress/file_decomp_pdf.cc
src/decompress/file_decomp_swf.cc
src/detection/detection_options.h
src/detection/fp_create.cc
src/detection/service_map.h
src/detection/signature.h
src/detection/treenodes.cc
src/detection/treenodes.h
src/file_api/file_cache.cc
src/file_api/file_cache.h
src/file_api/file_identifier.cc
src/file_api/file_identifier.h
src/file_api/file_mempool.cc
src/file_api/file_stats.cc
src/filters/detection_filter.cc
src/filters/rate_filter.cc
src/filters/sfrf.cc
src/filters/sfrf.h
src/filters/sfthd.cc
src/filters/sfthd.h
src/filters/sfthd_test.cc
src/flow/ha_module.h
src/flow/test/ha_module_test.cc
src/flow/test/ha_test.cc
src/framework/counts.h
src/framework/endianness.h
src/framework/module.cc
src/framework/range.cc
src/framework/range.h
src/hash/ghash.cc
src/hash/ghash.h
src/hash/hashes.cc
src/hash/hashes.h
src/hash/hashfcn.cc
src/hash/hashfcn.h
src/hash/xhash.cc
src/hash/xhash.h
src/helpers/base64_encoder.cc
src/helpers/base64_encoder.h
src/helpers/chunk.cc
src/helpers/process.cc
src/host_tracker/test/host_cache_module_test.cc
src/host_tracker/test/host_cache_test.cc
src/host_tracker/test/host_tracker_module_test.cc
src/host_tracker/test/host_tracker_test.cc
src/ips_options/asn1_detect.cc
src/ips_options/extract.cc
src/ips_options/extract.h
src/ips_options/ips_content.cc
src/ips_options/test/ips_regex_test.cc
src/log/messages.cc
src/log/messages.h
src/log/obfuscator.cc
src/log/obfuscator.h
src/log/test/obfuscator_test.cc
src/log/text_log.cc
src/log/text_log.h
src/lua/lua.cc
src/main/analyzer_command.cc
src/main/control_mgmt.cc
src/main/modules.cc
src/main/policy.h
src/main/request.cc
src/main/snort_config.h
src/main/snort_debug.cc
src/main/thread.cc
src/main/thread.h
src/main/thread_config.cc
src/managers/so_manager.cc
src/memory/memory_cap.cc
src/mime/decode_b64.cc
src/mime/decode_b64.h
src/mime/decode_qp.cc
src/mime/decode_uu.cc
src/mime/file_mime_config.cc
src/mime/file_mime_config.h
src/mime/file_mime_decode.cc
src/mime/file_mime_decode.h
src/mime/file_mime_paf.cc
src/mime/file_mime_paf.h
src/network_inspectors/appid/app_forecast.cc
src/network_inspectors/appid/app_info_table.cc
src/network_inspectors/appid/appid_config.cc
src/network_inspectors/appid/appid_http_session.cc
src/network_inspectors/appid/appid_peg_counts.cc
src/network_inspectors/appid/appid_peg_counts.h
src/network_inspectors/appid/appid_session.h
src/network_inspectors/appid/appid_stats.cc
src/network_inspectors/appid/client_plugins/client_detector.cc
src/network_inspectors/appid/detector_plugins/detector_kerberos.cc
src/network_inspectors/appid/detector_plugins/detector_pattern.cc
src/network_inspectors/appid/detector_plugins/detector_pop3.cc
src/network_inspectors/appid/detector_plugins/http_url_patterns.cc
src/network_inspectors/appid/detector_plugins/http_url_patterns.h
src/network_inspectors/appid/detector_plugins/test/detector_plugins_mock.h
src/network_inspectors/appid/length_app_cache.cc
src/network_inspectors/appid/lua_detector_module.cc
src/network_inspectors/appid/service_plugins/service_rshell.cc
src/network_inspectors/appid/service_plugins/service_snmp.cc
src/network_inspectors/appid/service_plugins/service_tftp.cc
src/network_inspectors/appid/test/appid_debug_test.cc
src/network_inspectors/appid/test/appid_mock_definitions.h
src/network_inspectors/appid/test/log_message_mock.h
src/network_inspectors/appid/test/service_state_test.cc
src/network_inspectors/arp_spoof/arp_module.cc
src/network_inspectors/perf_monitor/cpu_tracker.cc
src/network_inspectors/perf_monitor/flow_ip_tracker.h
src/network_inspectors/perf_monitor/perf_module.cc
src/network_inspectors/perf_monitor/perf_tracker.cc
src/network_inspectors/perf_monitor/text_formatter.cc
src/network_inspectors/port_scan/ps_module.cc
src/network_inspectors/reputation/reputation_parse.cc
src/packet_io/intf.cc
src/packet_io/trough.cc
src/parser/config_file.cc
src/parser/mstring.cc
src/parser/mstring.h
src/parser/parse_ip.cc
src/parser/parse_ports.cc
src/parser/parse_stream.cc
src/parser/parse_utils.cc
src/piglet/piglet_api.h
src/piglet/piglet_manager.h
src/piglet/piglet_runner.cc
src/piglet/piglet_runner.h
src/ports/port_item.cc
src/ports/port_object.cc
src/ports/port_object2.cc
src/ports/port_object2.h
src/ports/port_table.cc
src/ports/port_table.h
src/ports/port_utils.cc
src/ports/port_var_table.cc
src/ports/port_var_table.h
src/ports/rule_port_tables.cc
src/profiler/memory_defs.h
src/profiler/profiler_printer.h
src/profiler/time_profiler_defs.h
src/protocols/packet.h
src/protocols/ssl.cc
src/protocols/ssl.h
src/pub_sub/http_events.cc
src/pub_sub/http_events.h
src/search_engines/acsmx2.cc
src/search_engines/bnfa_search.cc
src/search_engines/pat_stats.h
src/search_engines/test/hyperscan_test.cc
src/search_engines/test/search_tool_test.cc
src/service_inspectors/back_orifice/back_orifice.cc
src/service_inspectors/dce_rpc/dce_common.h
src/service_inspectors/dce_rpc/dce_smb.cc
src/service_inspectors/dce_rpc/dce_smb_commands.cc
src/service_inspectors/dce_rpc/dce_smb_transaction.cc
src/service_inspectors/ftp_telnet/ft_main.cc
src/service_inspectors/ftp_telnet/ftp_bounce_lookup.cc
src/service_inspectors/ftp_telnet/ftp_cmd_lookup.cc
src/service_inspectors/ftp_telnet/ftp_data.cc
src/service_inspectors/ftp_telnet/ftp_parse.cc
src/service_inspectors/ftp_telnet/ftp_print.cc
src/service_inspectors/gtp/gtp_parser.cc
src/service_inspectors/http2_inspect/http2_inspect.h
src/service_inspectors/http_inspect/http_event_gen.h
src/service_inspectors/http_inspect/http_flow_data.cc
src/service_inspectors/http_inspect/http_flow_data.h
src/service_inspectors/http_inspect/http_inspect.h
src/service_inspectors/http_inspect/http_js_norm.cc
src/service_inspectors/http_inspect/http_msg_body.cc
src/service_inspectors/http_inspect/http_msg_header.h
src/service_inspectors/http_inspect/http_uri.cc
src/service_inspectors/http_inspect/http_uri_norm.cc
src/service_inspectors/http_inspect/test/http_module_test.cc
src/service_inspectors/http_inspect/test/http_transaction_test.cc
src/service_inspectors/http_inspect/test/http_uri_norm_test.cc
src/service_inspectors/imap/imap_config.h
src/service_inspectors/pop/pop_config.h
src/service_inspectors/sip/sip_config.cc
src/service_inspectors/smtp/smtp_config.h
src/sfip/sf_ip.h
src/sfip/sf_vartable.cc
src/side_channel/side_channel_module.h
src/side_channel/test/side_channel_module_test.cc
src/stream/tcp/segment_overlap_editor.cc
src/stream/tcp/tcp_debug_trace.h
src/stream/tcp/tcp_stream_config.cc
src/target_based/snort_protocols.h
src/time/packet_time.cc
src/time/packet_time.h
src/utils/boyer_moore.cc
src/utils/boyer_moore.h
src/utils/kmap.cc
src/utils/kmap.h
src/utils/sflsq.cc
src/utils/sflsq.h
src/utils/stats.cc
src/utils/stats.h
src/utils/util.cc
src/utils/util.h
src/utils/util_cstring.cc
src/utils/util_cstring.h
src/utils/util_jsnorm.cc
src/utils/util_jsnorm.h
src/utils/util_unfold.cc
src/utils/util_unfold.h
src/utils/util_utf.cc
src/utils/util_utf.h

index 08301667a5108afb9c5610f0fe3af4af057f21bc..3be5aa45972f49ff486ec0f8488634aecc75220d 100644 (file)
@@ -40,8 +40,11 @@ void show_stats(PegCount*, const PegInfo*, unsigned, const char*) { }
 void show_stats(PegCount*, const PegInfo*, IndexVec&, const char*) { }
 void show_stats(PegCount*, const PegInfo*, IndexVec&, const char*, FILE*) { }
 
+namespace snort
+{
 char* snort_strdup(const char* s)
 { return strdup(s); }
+}
 
 TEST_GROUP(file_connector_module)
 {
index 0fd7170e7caa7f12990a05837e5bf1ac085f8541..b4415f46524e8ac0a24b8209f780a85e9b8152a7 100644 (file)
@@ -54,8 +54,11 @@ void show_stats(PegCount*, const PegInfo*, unsigned, const char*) { }
 void show_stats(PegCount*, const PegInfo*, IndexVec&, const char*) { }
 void show_stats(PegCount*, const PegInfo*, IndexVec&, const char*, FILE*) { }
 
+namespace snort
+{
 const char* get_instance_file(std::string& file, const char* name)
 { file += name; return nullptr; }
+}
 
 FileConnectorModule::FileConnectorModule() :
     Module("FC", "FC Help", nullptr)
index 4d356e80077e66b3c381174728ca5d7fb86bc4c2..5d873bfac19982dad5a0a86960102e9f698f6cb0 100644 (file)
@@ -40,8 +40,11 @@ void show_stats(PegCount*, const PegInfo*, unsigned, const char*) { }
 void show_stats(PegCount*, const PegInfo*, IndexVec&, const char*) { }
 void show_stats(PegCount*, const PegInfo*, IndexVec&, const char*, FILE*) { }
 
+namespace snort
+{
 char* snort_strdup(const char* s)
 { return strdup(s); }
+}
 
 TEST_GROUP(tcp_connector_module)
 {
index c99a0af644a611cd438aabfb5de4e391b717dbdb..4691219a22f4ea09bcb78519e1c876ddc11bd3b6 100644 (file)
@@ -71,11 +71,14 @@ void show_stats(PegCount*, const PegInfo*, unsigned, const char*) { }
 void show_stats(PegCount*, const PegInfo*, IndexVec&, const char*) { }
 void show_stats(PegCount*, const PegInfo*, IndexVec&, const char*, FILE*) { }
 
+namespace snort
+{
 unsigned get_instance_id()
 { return s_instance; }
 
 void ErrorMessage(const char*, ...) { }
 void LogMessage(const char*, ...) { }
+}
 
 int connect (int, const struct sockaddr*, socklen_t) { return s_connect_return; } 
 ssize_t send (int, const void*, size_t n, int)
index 57c12d494117b723cfd7a694244e0be68ed178ff..51dc0202024132e1d4e8d249581be2811bed8548 100644 (file)
@@ -36,6 +36,8 @@
 #include "catch/snort_catch.h"
 #endif
 
+using namespace snort;
+
 static const char PDF_Sig[5] = { '%', 'P', 'D', 'F', '-' };
 static const char SWF_ZLIB_Sig[3] = { 'C', 'W', 'S' };
 #ifdef HAVE_LZMA
@@ -229,6 +231,8 @@ static fd_status_t Process_Decompression(fd_session_t* SessionPtr)
     return( Ret_Code );
 }
 
+namespace snort
+{
 /* The caller provides Compr_Depth, Decompr_Depth and Modes in the session object.
    Based on the requested Modes, gear=up to initialize the potential decompressors. */
 fd_status_t File_Decomp_Init(fd_session_t* SessionPtr)
@@ -390,6 +394,8 @@ void File_Decomp_Alert(fd_session_t* SessionPtr, int Event)
         (SessionPtr->Alert_Callback)(SessionPtr->Alert_Context, Event);
 }
 
+} // namespace snort
+
 //--------------------------------------------------------------------------
 // unit tests 
 //--------------------------------------------------------------------------
index 032dc9c5e23cc07339f209fef11fca12d5cf1207..0b9e01e9b73cb1f4a9c41c9db4ffb6406541e4b1 100644 (file)
@@ -271,7 +271,8 @@ inline bool Move_N(fd_session_t* SessionPtr, uint16_t N)
 }
 
 /* API Functions */
-
+namespace snort
+{
 /* Create a new decompression session object */
 SO_PUBLIC fd_session_t* File_Decomp_New();
 
@@ -295,5 +296,6 @@ SO_PUBLIC void File_Decomp_Free(fd_session_t*);
 
 /* Call the error alerting call-back function */
 SO_PUBLIC void File_Decomp_Alert(fd_session_t*, int Event);
+}
 #endif
 
index 5ae26b1168de1fc2ba09ebb67353f24e9a389282..5be86a9609d68bf2765ac3264c1880f53cb157c3 100644 (file)
@@ -33,6 +33,8 @@
 #include "catch/snort_catch.h"
 #endif
 
+using namespace snort;
+
 /* Define characters and tokens in PDF grammar */
 #define TOK_STRM_OPEN      "stream"
 #define TOK_STRM_CLOSE     "endstream"
index 99f9b3d1deea55ad6d00c2b0f8dd93cdb8e3bfa0..245fabac75ac8b957d70ae2b54c6adb70d8bf373 100644 (file)
@@ -30,6 +30,8 @@
 #include "catch/snort_catch.h"
 #endif
 
+using namespace snort;
+
 #ifdef HAVE_LZMA
 #define LZMA_HEADER_LEN  (13)
 #define LZMA_PRP_OFFSET  (0)
index 1f6d4ade26d6826b0d41c9c9e1d2aa9133d797c1..0aec198b7bead28120327e842542441045e3bbfc 100644 (file)
@@ -43,9 +43,9 @@ namespace snort
 {
 struct Packet;
 struct SnortConfig;
+struct XHash;
 }
 struct RuleLatencyState;
-struct XHash;
 
 typedef int (* eval_func_t)(void* option_data, class Cursor&, snort::Packet*);
 
@@ -124,11 +124,11 @@ void* add_detection_option_tree(struct snort::SnortConfig*, detection_option_tre
 int detection_option_node_evaluate(
     detection_option_tree_node_t*, detection_option_eval_data_t*, class Cursor&);
 
-void DetectionHashTableFree(XHash*);
-void DetectionTreeHashTableFree(XHash*);
+void DetectionHashTableFree(snort::XHash*);
+void DetectionTreeHashTableFree(snort::XHash*);
 
 void print_option_tree(detection_option_tree_node_t*, int level);
-void detection_option_tree_update_otn_stats(XHash*);
+void detection_option_tree_update_otn_stats(snort::XHash*);
 
 detection_option_tree_root_t* new_root(OptTreeNode*);
 void free_detection_option_root(void** existing_tree);
index 1ad01c0152b4585634ed27ea415f5a2e45544c4c..fcceb20146933107f389533eb865d9c8ae50467a 100644 (file)
@@ -650,7 +650,7 @@ static int fpCreateInitRuleMap(
     /* Process src PORT groups */
     if ( src )
     {
-        for ( GHashNode* node=ghash_findfirst(src->pt_mpxo_hash);
+        for ( GHashNode* node = ghash_findfirst(src->pt_mpxo_hash);
             node;
             node=ghash_findnext(src->pt_mpxo_hash) )
         {
index 60394982f8285b3ec1f32ace37dd1cd123f44859..3840f02cc3d006fec42af3e1e60ce8ad9c292716 100644 (file)
 namespace snort
 {
 struct SnortConfig;
+struct GHash;
 }
 struct PortGroup;
-struct GHash;
 
 //  Service Rule Map Master Table
 struct srmm_table_t
 {
-    GHash* to_srv[SNORT_PROTO_MAX];
-    GHash* to_cli[SNORT_PROTO_MAX];
+    snort::GHash* to_srv[SNORT_PROTO_MAX];
+    snort::GHash* to_cli[SNORT_PROTO_MAX];
 };
 
 srmm_table_t* ServiceMapNew();
index afe453f2d757387a80bda53a8d86a0f40b0e3d54..0bb7acfe5262f1c632226685ad99721f739057d3 100644 (file)
 
 namespace snort
 {
+struct GHash;
 struct SnortConfig;
 }
 
 struct OptTreeNode;
-struct GHash;
 
 /* this contains a list of the URLs for various reference systems */
 struct ReferenceSystemNode
@@ -107,11 +107,11 @@ struct SigInfo
     Target target;
 };
 
-GHash* OtnLookupNew();
-void OtnLookupAdd(GHash*, OptTreeNode*);
-OptTreeNode* OtnLookup(GHash*, uint32_t gid, uint32_t sid);
-void OtnLookupFree(GHash*);
-void OtnRemove(GHash*, OptTreeNode*);
+snort::GHash* OtnLookupNew();
+void OtnLookupAdd(snort::GHash*, OptTreeNode*);
+OptTreeNode* OtnLookup(snort::GHash*, uint32_t gid, uint32_t sid);
+void OtnLookupFree(snort::GHash*);
+void OtnRemove(snort::GHash*, OptTreeNode*);
 
 void OtnDeleteData(void* data);
 void OtnFree(void* data);
index a514e5370745c96bb7a93f75d3692489d536ced9..060f422189fc23dd03fa4228398a5100be7591d5 100644 (file)
@@ -84,6 +84,8 @@ void* get_rule_type_data(OptTreeNode* otn, const char* name)
     return nullptr;
 }
 
+namespace snort
+{
 bool otn_has_plugin(OptTreeNode* otn, const char* name)
 {
     OptFpList* fpl = otn->opt_func;
@@ -100,4 +102,4 @@ bool otn_has_plugin(OptTreeNode* otn, const char* name)
     }
     return false;
 }
-
+}
index ab9484dc5ae40fe3122872675b1ff6671dff6b72..1d766fea0167fe7712799225704386d685baf665 100644 (file)
@@ -164,7 +164,10 @@ OptFpList* AddOptFuncToList(RuleOptEvalFunc, OptTreeNode*);
 
 void* get_rule_type_data(OptTreeNode*, const char* name);
 
+namespace snort
+{
 SO_PUBLIC bool otn_has_plugin(OptTreeNode* otn, const char* name);
+}
 
 inline bool otn_has_plugin(OptTreeNode* otn, int id)
 { return (otn->plugins & (0x1 << id)) != 0; }
index 6b9aabd0df73d0ee6bcacc840f722971e8280a2f..4880b511aaf55ec262ca2bbeaa0c0d0afb0a6f2e 100644 (file)
@@ -119,7 +119,7 @@ FileContext* FileCache::add(const FileHashKey& hashKey, int64_t timeout)
      * after that anyway because the file that
      * caused this will be gone.
      */
-    time_t now = packet_time();
+    time_t now = snort::packet_time();
     new_node.expires = now + timeout;
     new_node.file = new FileContext;
 
index 50f66f0e2852ec7169604be813a6c60df0f027ca..a7cbc7b3f9262127421a324f3713dbde6a18bec8 100644 (file)
 
 #include "file_config.h"
 
+namespace snort
+{
 struct XHash;
 struct XHashNode;
+}
 
 class FileCache
 {
@@ -72,7 +75,7 @@ private:
     int store_verdict(snort::Flow*, snort::FileInfo*, int64_t timeout);
 
     /* The hash table of expected files */
-    XHash* fileHash = nullptr;
+    snort::XHash* fileHash = nullptr;
     int64_t block_timeout = DEFAULT_FILE_BLOCK_TIMEOUT;
     int64_t lookup_timeout = DEFAULT_FILE_LOOKUP_TIMEOUT;
     int64_t max_files = DEFAULT_MAX_FILES_CACHED;
index 5f2f7ae640c511beab84d3eb5ee4fb2a07e36b71..3e3e56817fbc91e4e9a83cb493c90a26fecf893e 100644 (file)
@@ -39,6 +39,8 @@
 #include "catch/snort_catch.h"
 #endif
 
+using namespace snort;
+
 struct MergeNode
 {
     IdentifierNode* shared_node;  /*the node that is shared*/
@@ -66,7 +68,7 @@ void FileMagicRule::clear()
 
 void FileIdentifier::init_merge_hash()
 {
-    identifier_merge_hash = ghash_new(1000, sizeof(MergeNode), 0, nullptr);
+    identifier_merge_hash = snort::ghash_new(1000, sizeof(MergeNode), 0, nullptr);
     assert(identifier_merge_hash);
 }
 
index fe7152f38ac1f476600288e9749e000878c23650..ef454279bacd8502b14c7f2e4f28e9e005daa4e3 100644 (file)
@@ -103,7 +103,7 @@ private:
     /*properties*/
     IdentifierNode* identifier_root = nullptr; /*Root of magic tries*/
     uint32_t memory_used = 0; /*Track memory usage*/
-    GHash* identifier_merge_hash = nullptr;
+    snort::GHash* identifier_merge_hash = nullptr;
     FileMagicRule file_magic_rules[FILE_ID_MAX + 1];
     IDMemoryBlocks id_memory_blocks;
 };
index ec8867c96fe51007387417a05e10e97bd245332e..543608551f014bc33d1e4af2b2de903aa61cb2a7 100644 (file)
@@ -34,6 +34,8 @@
 #include "log/messages.h"
 #include "utils/util.h"
 
+using namespace snort;
+
 /*This magic is used for double free detection*/
 
 #define FREE_MAGIC    0x2525252525252525
index 6552b9e86dbf129ece93dcae3c7bf67a52630d60..325cb14b34d4df9c436ebc48a1a12aa7f22bcd14 100644 (file)
@@ -36,6 +36,8 @@
 
 #include "file_capture.h"
 
+using namespace snort;
+
 THREAD_LOCAL FileCounts file_counts;
 THREAD_LOCAL FileStats* file_stats = nullptr;
 
index 0f0ac0c96a659d8a72dd9ab318333f48db444ef1..ad693add926fd225afb6413c7b2c89ce1acba2fa 100644 (file)
@@ -30,6 +30,8 @@
 
 #include "sfthd.h"
 
+using namespace snort;
+
 static THREAD_LOCAL XHash* detection_filter_hash = nullptr;
 
 DetectionFilterConfig* DetectionFilterConfigNew()
@@ -96,7 +98,7 @@ void detection_filter_term()
     if ( !detection_filter_hash )
         return;
 
-    xhash_delete(detection_filter_hash);
+    snort::xhash_delete(detection_filter_hash);
     detection_filter_hash = nullptr;
 }
 
index 10ba4311b4dcd45b1af6676b67ab5ea747e8eefe..63c556a211ea89b9fded74130c703f9464b0bf38 100644 (file)
@@ -35,6 +35,8 @@
 
 #include "sfrf.h"
 
+using namespace snort;
+
 //static int _printThresholdContext(RateFilterConfig*);
 
 RateFilterConfig* RateFilter_ConfigNew()
index 50bce1e1544811ef06fe327654e1e2e73b757fb2..f147092c2be456ec031eca1b0501c1a21850cb24 100644 (file)
@@ -35,6 +35,8 @@
 #include "utils/sflsq.h"
 #include "utils/util.h"
 
+using namespace snort;
+
 // Number of hash rows for gid 1 (rules)
 #define SFRF_GEN_ID_1_ROWS 4096
 // Number of hash rows for non-zero gid
index 0ca545efa79b7131c4f287db69a6aab49385e135..444d132851b49ba6f90cf6dbdd706b262b2b7607 100644 (file)
@@ -137,7 +137,7 @@ struct RateFilterConfig
     /* Array of hash, indexed by gid. Each array element is a hash, which
      * is keyed on sid/policyId and data is a tSFRFSidNode node.
      */
-    struct GHash* genHash [SFRF_MAX_GENID];
+    struct snort::GHash* genHash [SFRF_MAX_GENID];
 
     // Number of DOS thresholds added.
     int count;
index e7bb1565470562b6845eeec13a78c224c62b1bf4..d9f8ccaaeb75f6ebb8f4f80154ea1636053169a6 100644 (file)
@@ -42,6 +42,8 @@
 #include "utils/sflsq.h"
 #include "utils/util.h"
 
+using namespace snort;
+
 //  Debug Printing
 //#define THD_DEBUG
 
index 08cced0477e2a59fe1f6eb6f651d6535875e1b9e..1f9b5d29c51911442e195e8c1c949dc5246930c1 100644 (file)
 
 namespace snort
 {
-struct SnortConfig;
-}
 struct GHash;
 struct XHash;
+struct SnortConfig;
+}
+
 typedef struct sf_list SF_LIST;
 
 /*!
@@ -185,14 +186,14 @@ struct tThdItemKey
  */
 struct THD_STRUCT
 {
-    XHash* ip_nodes;   /* Global hash of active IP's key=THD_IP_NODE_KEY, data=THD_IP_NODE */
-    XHash* ip_gnodes;  /* Global hash of active IP's key=THD_IP_GNODE_KEY, data=THD_IP_GNODE */
+    snort::XHash* ip_nodes;   /* Global hash of active IP's key=THD_IP_NODE_KEY, data=THD_IP_NODE */
+    snort::XHash* ip_gnodes;  /* Global hash of active IP's key=THD_IP_GNODE_KEY, data=THD_IP_GNODE */
 };
 
 struct ThresholdObjects
 {
     int count;  /* Total number of thresholding/suppression objects */
-    GHash* sfthd_array[THD_MAX_GENID];    /* Local Hash of THD_ITEM nodes,  lookup by key=sig_id
+    snort::GHash* sfthd_array[THD_MAX_GENID];    /* Local Hash of THD_ITEM nodes,  lookup by key=sig_id
                                               */
 
     /* Double array of THD_NODE pointers. First index is policyId and therefore variable length.
@@ -212,13 +213,13 @@ struct ThresholdObjects
 // lbytes = local threshold memcap
 // gbytes = global threshold memcap (0 to disable global)
 THD_STRUCT* sfthd_new(unsigned lbytes, unsigned gbytes);
-XHash* sfthd_local_new(unsigned bytes);
-XHash* sfthd_global_new(unsigned bytes);
+snort::XHash* sfthd_local_new(unsigned bytes);
+snort::XHash* sfthd_global_new(unsigned bytes);
 void sfthd_free(THD_STRUCT*);
 ThresholdObjects* sfthd_objs_new();
 void sfthd_objs_free(ThresholdObjects*);
 
-int sfthd_test_rule(XHash* rule_hash, THD_NODE* sfthd_node,
+int sfthd_test_rule(snort::XHash* rule_hash, THD_NODE* sfthd_node,
     const snort::SfIp* sip, const snort::SfIp* dip, long curtime);
 
 THD_NODE* sfthd_create_rule_threshold(
@@ -240,9 +241,9 @@ int sfthd_create_threshold(snort::SnortConfig*, ThresholdObjects*, unsigned gen_
 int sfthd_test_threshold(ThresholdObjects*, THD_STRUCT*, unsigned gen_id, unsigned sig_id,
     const snort::SfIp* sip, const snort::SfIp* dip, long curtime);
 
-XHash* sfthd_new_hash(unsigned, size_t, size_t);
+snort::XHash* sfthd_new_hash(unsigned, size_t, size_t);
 
-int sfthd_test_local(XHash* local_hash, THD_NODE* sfthd_node, const snort::SfIp* sip,
+int sfthd_test_local(snort::XHash* local_hash, THD_NODE* sfthd_node, const snort::SfIp* sip,
     const snort::SfIp* dip, time_t curtime);
 
 #ifdef THD_DEBUG
index bc99caf1a45c27bf9a2f521a64f63b1c10d75e6a..d10b87d16ac59aa9a7d06c1c6b36f6ea14b4f176 100644 (file)
@@ -29,6 +29,8 @@
 
 #include "sfthd.h"
 
+using namespace snort;
+
 //---------------------------------------------------------------
 
 #define IP_ANY   nullptr          // used to get "unset"
index 2e38066f36fbc9849d9c662b24d2cf578d8f550e..9bf35fe4aaf36b66190dba9a1b2bb1b673941a55 100644 (file)
@@ -55,7 +55,7 @@ public:
     { return (PegCount*)&ha_stats; }
 
     const PegInfo* get_pegs() const override
-    { return simple_pegs; }
+    { return snort::simple_pegs; }
 
     snort::ProfileStats* get_profile() const override;
 
index 68cf340df1b785a50b8123509d1167fa44ddebbe..71eebbc6ce824eb25aecc39b6f82916ee608966c 100644 (file)
@@ -35,8 +35,6 @@
 
 using namespace snort;
 
-void LogMessage(const char*,...) { }
-
 THREAD_LOCAL SimpleStats ha_stats;
 THREAD_LOCAL ProfileStats ha_perf_stats;
 
@@ -44,9 +42,12 @@ void show_stats(PegCount*, const PegInfo*, unsigned, const char*) { }
 void show_stats(PegCount*, const PegInfo*, IndexVec&, const char*) { }
 void show_stats(PegCount*, const PegInfo*, IndexVec&, const char*, FILE*) { }
 
+namespace snort
+{
+void LogMessage(const char*,...) { }
 void ParseWarning(WarningGroup, const char*, ...) { }
-
 char* snort_strdup(const char* str) { return strdup(str); }
+}
 
 static bool s_port_1_set = false;
 static bool s_use_daq = false;
index 5fd264458506d80d4008b3a3178a5f1d8c7ec8c5..f522f5ef1be02de70a493ad003052772f3d7e41c 100644 (file)
@@ -152,8 +152,11 @@ void Stream::delete_flow(const FlowKey* flowkey)
     s_delete_session_called = true;
 }
 
+namespace snort
+{
 void ErrorMessage(const char*,...) { }
 void LogMessage(const char*,...) { }
+}
 
 void packet_gettimeofday(struct timeval* tv)
 { *tv = s_packet_time; }
index fc109f326e410b040f5a7fc43d00fd574996f8c6..b52a9992648b74d9a4f5e540df76f45b91edac9f 100644 (file)
@@ -49,7 +49,11 @@ struct PegInfo
     const char* help;
 };
 
+
+namespace snort
+{
 SO_PUBLIC extern const struct PegInfo simple_pegs[];
+} // namespace snort
 
 #define array_size(a) (sizeof(a)/sizeof((a)[0]))
 
index 72c9a6b38b59a1cf5e4879906a840b71c0b8f3b8..59442d7fbb02b2841d7b3a3f4181577bc1c3b111 100644 (file)
@@ -23,6 +23,8 @@
 
 #include "main/snort_types.h"
 
+namespace snort
+{
 class SO_PUBLIC Endianness
 {
 public:
@@ -30,6 +32,6 @@ public:
     virtual ~Endianness() = default;
     virtual bool get_offset_endianness(int32_t offset, uint8_t& endian) = 0;
 };
-
+}
 #endif
 
index 5138007fefccae2584ad29e879952a082a57d34d..c2cf7cdf0b8c1e414c2b9979a80302b169645269 100644 (file)
@@ -196,15 +196,17 @@ bool Module::verified_end(const char* fqn, int idx, SnortConfig* c)
     return end(fqn, idx, c);
 }
 
-const PegInfo simple_pegs[] =
-{
-    { CountType::SUM, "packets", "total packets" },
-    { CountType::END, nullptr, nullptr }
-};
-
 void Module::enable_trace()
 {
     if ( trace )
         *trace = 1;
 }
 
+namespace snort
+{
+const PegInfo simple_pegs[] =
+{
+    { CountType::SUM, "packets", "total packets" },
+    { CountType::END, nullptr, nullptr }
+};
+}
index a47696b4c1fea2eba85677501307f307678a9f83..c65f7d5f1e56fbd5e00ca0a6c9611182a9619391 100644 (file)
@@ -32,6 +32,7 @@
 #include "catch/snort_catch.h"
 #endif
 
+using namespace snort;
 using namespace std;
 
 //--------------------------------------------------------------------------
index 01b9d23a9371e7ae8b0760ba0f26ff246ae15eed..fa324fab36697815e3ccf1194543247d9d78b49b 100644 (file)
@@ -32,6 +32,8 @@
 // <=> for dsize style and >< for icode style so rule options
 // can coerce <> if needed for backwards compatibility
 
+namespace snort
+{
 class SO_PUBLIC RangeCheck
 {
 public:
@@ -56,6 +58,6 @@ public:
     bool eval(long) const;
     bool validate(const char* s, const char* r);
 };
-
+}
 #endif
 
index be3b7aa41b0b2b41178801f18f3c6a24e47d3fc2..20e259ed0a2a0ad16357fcf88ff6d080b2fcf38c 100644 (file)
@@ -65,6 +65,8 @@
 #include "hashfcn.h"
 #include "primetable.h"
 
+namespace snort
+{
 /*
 *
 *    Create a new hash table
@@ -506,3 +508,4 @@ int ghash_set_keyops(GHash* h,
 
     return hashfcn_set_keyops(h->hashfcn, hash_fcn, keycmp_fcn);
 }
+}
index e85a2ec75512a65ede237e8522849373fb1f9d97..b0ef52772aa2846c179f8fce7ac5758b8e15486c 100644 (file)
@@ -28,6 +28,9 @@
 
 struct HashFnc;
 
+namespace snort
+{
+
 #define GHASH_NOMEM    (-2)
 #define GHASH_ERR      (-1)
 #define GHASH_OK        0
@@ -74,6 +77,6 @@ SO_PUBLIC GHashNode* ghash_findnext(GHash*);
 SO_PUBLIC int ghash_set_keyops(GHash*,
 unsigned (* hash_fcn)(HashFnc* p, const unsigned char* d, int n),
 int (* keycmp_fcn)(const void* s1, const void* s2, size_t n));
-
+}
 #endif
 
index 9910f15229cab3e61daa2ad28e64b0763f341c43..28b3cf036e093b61a03984d8dbc49aea74a8718a 100644 (file)
@@ -26,6 +26,8 @@
 #include <openssl/md5.h>
 #include <openssl/sha.h>
 
+namespace snort
+{
 void sha256(const unsigned char* data, size_t size, unsigned char* digest)
 {
     SHA256_CTX c;
@@ -50,3 +52,4 @@ void md5(const unsigned char* data, size_t size, unsigned char* digest)
     MD5_Final(digest, &c);
 }
 
+}
index cbabf305477b8d254f4368d1b75d55e4b09d83ae..9dba5bdbf06c4651934a8cf1f2ffb60797407d0c 100644 (file)
@@ -22,6 +22,8 @@
 
 #include "main/snort_types.h"
 
+namespace snort
+{
 #define MD5_HASH_SIZE    16
 #define SHA256_HASH_SIZE 32
 #define SHA512_HASH_SIZE 64
@@ -31,6 +33,6 @@
 SO_PUBLIC void md5(const unsigned char* data, size_t size, unsigned char* digest);
 SO_PUBLIC void sha256(const unsigned char* data, size_t size, unsigned char* digest);
 SO_PUBLIC void sha512(const unsigned char* data, size_t size, unsigned char* digest);
-
+}
 #endif
 
index 3316793521738278097d4f6ec70e87244be4f981..65b5b4935cc20034f827f0de985e2b1d23e32ac2 100644 (file)
@@ -114,6 +114,8 @@ int hashfcn_set_keyops(HashFnc* h,
     return -1;
 }
 
+namespace snort
+{
 void mix_str(
     uint32_t& a, uint32_t& b, uint32_t& c,
     const char* s, unsigned n)
@@ -204,4 +206,4 @@ size_t str_to_hash(const uint8_t *str, int length )
     finalize(a,b,c);
     return c;
 }
-
+} //namespace snort
index 6c2729a913427d7d58e52aa8b71634f45cfe445f..f88776b21ac354e452b941f85dc857d301b407f0 100644 (file)
     (c) ^= (b); (c) -= rot(b,24); \
 }
 
+namespace snort
+{
 SO_PUBLIC void mix_str(
     uint32_t& a, uint32_t& b, uint32_t& c,
     // n == 0 => strlen(s)
     const char* s, unsigned n = 0);
 
 SO_PUBLIC size_t str_to_hash(const uint8_t *str, int length);
+}
 
 struct HashFnc
 {
index cad27dd8768fc882515656f70aacdb17d555c020..91860376d14d84213de45ca81d037a9ddf96206e 100644 (file)
@@ -97,6 +97,8 @@
 #include "utils/util.h"
 #include "hashfcn.h"
 
+using namespace snort;
+
 /*
  * Implements XHash as specialized hash container
  */
@@ -124,6 +126,8 @@ static int xhash_nearest_powerof2(int nrows)
     return nrows;
 }
 
+namespace snort
+{
 /*
  * Create a new hash table
  *
@@ -1023,6 +1027,7 @@ void xhash_set_keyops(XHash* h, hash_func hash_fcn, keycmp_func keycmp_fcn)
     assert(h and hash_fcn and keycmp_fcn);
     hashfcn_set_keyops(h->hashfcn, hash_fcn, keycmp_fcn);
 }
+} // namespace snort
 
 /*
  * -----------------------------------------------------------------------------------------
index 67c1d8c1f104d175a7abb914465395a7dec421fb..6a3583d32dd643974365b87c6fa8e62b061a02ea 100644 (file)
@@ -30,6 +30,8 @@
 
 struct HashFnc;
 
+namespace snort
+{
 #define XHASH_NOMEM    (-2)
 #define XHASH_ERR      (-1)
 #define XHASH_OK        0
@@ -155,6 +157,6 @@ SO_PUBLIC void xhash_set_keyops(XHash* h, hash_func, keycmp_func);
 
 SO_PUBLIC XHashNode* xhash_gfindfirst(XHash* t);
 SO_PUBLIC XHashNode* xhash_gfindnext(XHash* t);
-
+} // namespace snort
 #endif
 
index 0b8ce6ddd91724e7865c4194718694579d9d5def..ca427fb063b30250b0157eaf2557e9a85385a3e7 100644 (file)
@@ -34,6 +34,8 @@
 #include "catch/snort_catch.h"
 #endif
 
+using namespace snort;
+
 static inline char b64(uint8_t idx)
 {
     static const char* encoding =
index 78a414f071937b782e00a866e57aaf5553c5f220..1e7abf194cb22990ffa45a057064cef209e09fbe 100644 (file)
@@ -30,6 +30,8 @@
 #include <cstdint>
 #include "main/snort_types.h"
 
+namespace snort
+{
 class SO_PUBLIC Base64Encoder
 {
 public:
@@ -47,6 +49,6 @@ private:
     Steps step;
     uint8_t state;
 };
-
+}
 #endif
 
index dced8fb615c68a12d30c5a8f046b40e97ab5ddf7..33d2f52d9b8886e868b21bfba2a5899361fd2446 100644 (file)
@@ -45,21 +45,21 @@ bool init_chunk(
 
     if ( luaL_loadbuffer(L, chunk.c_str(), chunk.size(), name) )
     {
-        ParseError("%s luajit failed to load chunk %s", name, lua_tostring(L, -1));
+        snort::ParseError("%s luajit failed to load chunk %s", name, lua_tostring(L, -1));
         return false;
     }
 
     // now exec the chunk to define functions etc in L
     if ( lua_pcall(L, 0, 0, 0) )
     {
-        ParseError("%s luajit failed to init chunk %s", name, lua_tostring(L, -1));
+        snort::ParseError("%s luajit failed to init chunk %s", name, lua_tostring(L, -1));
         return false;
     }
 
     // load the args table
     if ( luaL_dostring(L, args.c_str()) )
     {
-        ParseError("%s luajit failed to init args %s", name, lua_tostring(L, -1));
+        snort::ParseError("%s luajit failed to init args %s", name, lua_tostring(L, -1));
         return false;
     }
 
@@ -71,10 +71,10 @@ bool init_chunk(
         return true;
 
     if ( lua_pcall(L, 0, 1, 0) || lua_type(L, -1) == LUA_TSTRING )
-        ParseError("%s %s", name, lua_tostring(L, -1));
+        snort::ParseError("%s %s", name, lua_tostring(L, -1));
 
     else if ( !lua_toboolean(L, -1) )
-        ParseError("%s init() returned false", name);
+        snort::ParseError("%s init() returned false", name);
 
     else
         return true;
index cd253379d3a99caec282cb0a27726c79c0d40fa2..69fdd04d7812333ae36f014c231788e80cd2a588 100644 (file)
@@ -41,6 +41,7 @@
 #include "markup.h"
 #include "ring.h"
 
+using namespace snort;
 using namespace std;
 
 #ifndef SIGNAL_SNORT_RELOAD
index e1e2c03bb46ea85402992ed32aef29ca9718be0c..213c137578dcea6e467d576cf88422cf33a7e4d3 100644 (file)
 
 using namespace snort;
 
+namespace snort
+{
 //  Fakes to avoid bringing in a ton of dependencies.
 SnortProtocolId ProtocolReference::add(char const*) { return 0; }
 SnortProtocolId ProtocolReference::find(char const*) { return 0; }
 SnortConfig* SnortConfig::get_conf() { return nullptr; }
+char* snort_strdup(const char* s)
+{ return strdup(s); }
+}
 
 void show_stats(PegCount*, const PegInfo*, unsigned, const char*)
 { }
@@ -45,9 +50,6 @@ void show_stats(PegCount*, const PegInfo*, unsigned, const char*)
 void show_stats(PegCount*, const PegInfo*, IndexVec&, const char*, FILE*)
 { }
 
-char* snort_strdup(const char* s)
-{ return strdup(s); }
-
 #define FRAG_POLICY 33
 #define STREAM_POLICY 100
 
index 18ab342398b3d0ab1b32caa45ae965c576ff3ed1..d147f5388b4eaba2a64e9302ba76da2f1c9dacad 100644 (file)
 
 using namespace snort;
 
+namespace snort
+{
 SnortConfig s_conf;
 THREAD_LOCAL SnortConfig* snort_conf = &s_conf;
-
 SnortConfig::SnortConfig(const SnortConfig* const) { }
-
 SnortConfig::~SnortConfig() = default;
-
 SnortConfig* SnortConfig::get_conf()
 { return snort_conf; }
 
 SnortProtocolId ProtocolReference::find(char const*) { return 0; }
-
 SnortProtocolId ProtocolReference::add(const char* protocol)
 {
     if (!strcmp("servicename", protocol))
@@ -57,6 +55,7 @@ char* snort_strdup(const char* str)
 {
     return strdup(str);
 }
+}
 
 TEST_GROUP(host_cache)
 {
index 905520c5bbacfe68f6a2c250118ec22665c20b96..9660f2773c66b8ad4be62594287ed4503ce88f09 100644 (file)
 
 using namespace snort;
 
+namespace snort
+{
 SnortConfig* SnortConfig::get_conf() { return nullptr; }
-
 SnortProtocolId ProtocolReference::find(char const*) { return 0; }
-
 SnortProtocolId ProtocolReference::add(const char* protocol)
 {
     if (!strcmp("servicename", protocol))
@@ -46,15 +46,13 @@ SnortProtocolId ProtocolReference::add(const char* protocol)
     return 1;
 }
 
-//  Fake show_stats to avoid bringing in a ton of dependencies.
-void show_stats(PegCount*, const PegInfo*, unsigned, const char*)
-{ }
-
-void show_stats(PegCount*, const PegInfo*, IndexVec&, const char*, FILE*)
-{ }
-
 char* snort_strdup(const char* s)
 { return strdup(s); }
+}
+
+//  Fake show_stats to avoid bringing in a ton of dependencies.
+void show_stats(PegCount*, const PegInfo*, unsigned, const char*) { }
+void show_stats(PegCount*, const PegInfo*, IndexVec&, const char*, FILE*) { }
 
 #define FRAG_POLICY 33
 #define STREAM_POLICY 100
index 67fb15807d399dd0ed3e9329f62eed6dba13b7a0..2a73c02516b6741bb7ac3e60ded2345e9cd1b279 100644 (file)
 
 using namespace snort;
 
+namespace snort
+{
 // Fake snort_strdup() because sfutil dependencies suck
 char* snort_strdup(const char* str)
-{
-    return strdup(str);
+{ return strdup(str); }
 }
 
 TEST_GROUP(host_tracker)
index 0819d5f4b6b823b75941b3b435ae8e6152e072da..fb7519640834df0d04b40577ed7d3ff217af0c76 100644 (file)
@@ -325,9 +325,7 @@ int Asn1DoDetect(const uint8_t* data, uint16_t dsize, ASN1_CTXT* ctxt, const uin
     {
     case REL_OFFSET:
         if (!rel_ptr)
-        {
             return 0;
-        }
 
         /*
         **  Check that it is in bounds first.
@@ -336,16 +334,12 @@ int Asn1DoDetect(const uint8_t* data, uint16_t dsize, ASN1_CTXT* ctxt, const uin
         **  Bound checked also after offset is applied
         */
         if (!inBounds(start, end + 1, rel_ptr))
-        {
             return 0;
-        }
 
         offset = rel_ptr+ctxt->offset;
 
         if (!inBounds(start, end, offset))
-        {
             return 0;
-        }
 
         break;
 
@@ -354,9 +348,7 @@ int Asn1DoDetect(const uint8_t* data, uint16_t dsize, ASN1_CTXT* ctxt, const uin
         offset = start+ctxt->offset;
 
         if (!inBounds(start, end, offset))
-        {
             return 0;
-        }
 
         break;
     }
@@ -369,9 +361,7 @@ int Asn1DoDetect(const uint8_t* data, uint16_t dsize, ASN1_CTXT* ctxt, const uin
 
     iRet = asn1_decode(offset, size, &asn1);
     if (iRet && !asn1)
-    {
         return 0;
-    }
 
     /*
     **  Let's do detection now.
index 541cad150bb54a48021154aa3ce0249a62ee3009..abd20544cb0b20239fabe954ecd244f21ba4c243 100644 (file)
@@ -36,6 +36,7 @@
 #include "catch/snort_catch.h"
 #endif
 
+using namespace snort;
 using namespace std;
 
 /* Storage for extracted variables */
@@ -43,6 +44,8 @@ static string variable_names[NUM_IPS_OPTIONS_VARS];
 static THREAD_LOCAL uint32_t extracted_values[NUM_IPS_OPTIONS_VARS];
 static THREAD_LOCAL uint8_t extracted_values_cnt = 0;
 
+namespace snort
+{
 /* Given a variable name, retrieve its index.*/
 int8_t GetVarByName(const char* name)
 {
@@ -296,6 +299,8 @@ uint8_t numBytesInBitmask(uint32_t bitmask_value)
     return num_bytes;
 }
 
+} // namespace snort
+
 #ifdef UNIT_TEST
 TEST_CASE("ips options bitmask utils")
 {
index a200642291376389481e55be87c11016750fe596..9539026654557d1ea67dd0d044b59aef848d4e24 100644 (file)
@@ -34,6 +34,8 @@
 #define IPS_OPTIONS_NO_VAR (-1)
 #define INVALID_VAR_ERR_STR "%s uses an undefined rule option variable (%s)"
 
+namespace snort
+{
 SO_PUBLIC int string_extract(
     int bytes_to_grab, int base, const uint8_t* ptr,
     const uint8_t* start, const uint8_t* end, uint32_t* value);
@@ -55,6 +57,6 @@ SO_PUBLIC void ClearIpsOptionsVars();
 // Used during eval
 SO_PUBLIC int GetVarValueByIndex(uint32_t* dst, uint8_t var_number);
 SO_PUBLIC int SetVarValueByIndex(uint32_t value, uint8_t var_number);
-
+}
 #endif
 
index e45a83a6fbbb1c61818c171c88a96dd47f194397..3c2bbbfc8f620d9f37319870819a715ed0a21e99 100644 (file)
@@ -75,7 +75,7 @@ void ContentData::init()
 
 void ContentData::setup_bm()
 {
-    skip_stride = make_skip(pmd.pattern_buf, pmd.pattern_size);
+    skip_stride = snort::make_skip(pmd.pattern_buf, pmd.pattern_size);
     shift_stride = make_shift(pmd.pattern_buf, pmd.pattern_size);
 }
 
index 87c3a70ea79e2c9a806caceb1615ba7da6a28fb1..24ac001a73b9204dcab9db8a71c72986749c6e52 100644 (file)
@@ -41,15 +41,12 @@ using namespace snort;
 // stubs, spies, etc.
 //-------------------------------------------------------------------------
 
-extern const BaseApi* ips_regex;
-
-void show_stats(PegCount*, const PegInfo*, unsigned, const char*) { }
+namespace snort
+{
 
 void mix_str(uint32_t& a, uint32_t&, uint32_t&, const char* s, unsigned)
 { a += strlen(s); }
 
-namespace snort
-{
 SnortConfig s_conf;
 THREAD_LOCAL SnortConfig* snort_conf = &s_conf;
 
@@ -80,10 +77,6 @@ SnortConfig* SnortConfig::get_conf()
 
 Packet::Packet(bool) { }
 Packet::~Packet() = default;
-}
-
-Cursor::Cursor(Packet* p)
-{ set("pkt_data", p->data, p->dsize); }
 
 static unsigned s_parse_errors = 0;
 
@@ -93,13 +86,20 @@ void ParseError(const char*, ...)
 unsigned get_instance_id()
 { return 0; }
 
+char* snort_strdup(const char* s)
+{ return strdup(s); }
+
 MemoryContext::MemoryContext(MemoryTracker&) { }
 MemoryContext::~MemoryContext() = default;
+}
 
-void show_stats(PegCount*, const PegInfo*, IndexVec&, const char*, FILE*) { }
+extern const BaseApi* ips_regex;
 
-char* snort_strdup(const char* s)
-{ return strdup(s); }
+Cursor::Cursor(Packet* p)
+{ set("pkt_data", p->data, p->dsize); }
+
+void show_stats(PegCount*, const PegInfo*, unsigned, const char*) { }
+void show_stats(PegCount*, const PegInfo*, IndexVec&, const char*, FILE*) { }
 
 //-------------------------------------------------------------------------
 // helpers
@@ -275,8 +275,6 @@ TEST_GROUP(ips_regex_option)
 
     void setup() override
     {
-        // FIXIT-L cpputest hangs or crashes in the leak detector
-        MemoryLeakWarningPlugin::turnOffNewDeleteOverloads();
         opt = get_option(" foo ");
         scratch_setup(snort_conf);
     }
@@ -286,7 +284,6 @@ TEST_GROUP(ips_regex_option)
         api->dtor(opt);
         scratch_cleanup(snort_conf);
         api->pterm(snort_conf);
-        MemoryLeakWarningPlugin::turnOnNewDeleteOverloads();
     }
 };
 
@@ -349,8 +346,6 @@ TEST_GROUP(ips_regex_option_relative)
 
     void setup() override
     {
-        // FIXIT-L cpputest hangs or crashes in the leak detector
-        MemoryLeakWarningPlugin::turnOffNewDeleteOverloads();
         opt = get_option("\\bfoo", true);
         scratch_setup(snort_conf);
     }
@@ -359,7 +354,6 @@ TEST_GROUP(ips_regex_option_relative)
         IpsApi* api = (IpsApi*)ips_regex;
         api->dtor(opt);
         scratch_cleanup(snort_conf);
-        MemoryLeakWarningPlugin::turnOnNewDeleteOverloads();
     }
 };
 
@@ -383,6 +377,8 @@ TEST(ips_regex_option_relative, no_match)
 
 int main(int argc, char** argv)
 {
+    // FIXIT-L cpputest hangs or crashes in the leak detector
+    MemoryLeakWarningPlugin::turnOffNewDeleteOverloads();
     return CommandLineTestRunner::RunAllTests(argc, argv);
 }
 
index f244f66ab94890d254bacbc3a65f14ef89a15375..cc97271cd9a7bf06dd6f8d0d77b5cf7aff6bae8a 100644 (file)
@@ -61,11 +61,13 @@ static void log_message(FILE* file, const char* type, const char* msg)
     get_parse_location(file_name, file_line);
 
     if ( file_line )
-        LogMessage(file, "%s: %s:%d %s\n", type, file_name, file_line, msg);
+        snort::LogMessage(file, "%s: %s:%d %s\n", type, file_name, file_line, msg);
     else
-        LogMessage(file, "%s: %s\n", type, msg);
+        snort::LogMessage(file, "%s: %s\n", type, msg);
 }
 
+namespace snort
+{
 void ParseMessage(const char* format, ...)
 {
     char buf[STD_BUF+1];
@@ -311,4 +313,5 @@ NORETURN_ASSERT void log_safec_error(const char* msg, void*, int e)
 
     assert(false);
 }
+} //namespace snort
 
index 6b304cdee3a0379dd688ec2a3db2519ed814291d..8df6155fc5ccace9be0a0bed561e46708f5fda63 100644 (file)
@@ -48,6 +48,8 @@ enum WarningGroup
 unsigned get_parse_errors();
 unsigned get_parse_warnings();
 
+namespace snort
+{
 SO_PUBLIC void ParseMessage(const char*, ...) __attribute__((format (printf, 1, 2)));
 SO_PUBLIC void ParseWarning(WarningGroup, const char*, ...) __attribute__((format (printf, 2, 3)));
 SO_PUBLIC void ParseError(const char*, ...) __attribute__((format (printf, 1, 2)));
@@ -94,6 +96,7 @@ private:
     unsigned max;
     unsigned idx;
 };
+}
 
 #endif
 
index 1f62a922b7f0908e68c4760df770e9cd1a62ba9f..b9062266f72a810e94c0112d69cbfe2c716ccf1a 100644 (file)
@@ -24,6 +24,8 @@
 
 #include "obfuscator.h"
 
+using namespace snort;
+
 bool Obfuscator::first(ObfuscatorBlock &b)
 {
     if ( blocks.empty() )
index f93e2e9efd4e6e748c4435336609f77a630aa6f5..edc3e686087ea8a4c40e4d2f1befa998c8c6bdb7 100644 (file)
@@ -27,6 +27,8 @@
 
 #include "main/snort_types.h"
 
+namespace snort
+{
 struct ObfuscatorBlock
 {
     // Only used by `class Obfuscator`
@@ -74,6 +76,7 @@ private:
     iterator it;
     static const char mask_char = 'X';
 };
+}
 
 #endif
 
index 4cf7fa5ba9c49df95253072632a086b657ca7af0..594d6443ecd502b01b68520ce8d60eaf6a784523 100644 (file)
@@ -29,6 +29,8 @@
 #include <CppUTest/CommandLineTestRunner.h>
 #include <CppUTest/TestHarness.h>
 
+using namespace snort;
+
 TEST_GROUP(ObfuscatorTests)
 { };
 
index 1fcccb8dfbd602678cd29f3c3adf9ef45f5b5a1b..b37c48df1f56cee537882f43cc78d15a5d7b67d8 100644 (file)
@@ -39,6 +39,8 @@
 
 #include "log.h"
 
+using namespace snort;
+
 /* a reasonable minimum */
 #define MIN_BUF  (4* K_BYTES)
 #define STDLOG_FILENO 3
@@ -99,6 +101,8 @@ int TextLog_Tell(TextLog* const txt)
     return txt->pos;
 }
 
+namespace snort
+{
 int TextLog_Avail(TextLog* const txt)
 {
     return txt->maxBuf - txt->pos - 1;
@@ -306,4 +310,4 @@ bool TextLog_Quote(TextLog* const txt, const char* qs)
 
     return true;
 }
-
+} // namespace snort
index 76ab7a5e719778e256aaa57f2733416899b9ca29..94ba3dfad6a5c428d92c22f67e80f4d31a47ed37 100644 (file)
@@ -46,6 +46,8 @@
 // or some such to get stdout or syslog
 struct TextLog;
 
+namespace snort
+{
 SO_PUBLIC TextLog* TextLog_Init(
     const char* name, unsigned int maxBuf = 0, size_t maxFile = 0);
 SO_PUBLIC void TextLog_Term(TextLog*);
@@ -59,6 +61,7 @@ SO_PUBLIC bool TextLog_Flush(TextLog* const);
 SO_PUBLIC int TextLog_Tell(TextLog* const);
 SO_PUBLIC int TextLog_Avail(TextLog* const);
 SO_PUBLIC void TextLog_Reset(TextLog* const);
+} // namespace snort
 
 /*-------------------------------------------------------------------
   * helper functions
@@ -66,12 +69,12 @@ SO_PUBLIC void TextLog_Reset(TextLog* const);
   */
 inline bool TextLog_NewLine(TextLog* const txt)
 {
-    return TextLog_Putc(txt, '\n');
+    return snort::TextLog_Putc(txt, '\n');
 }
 
 inline bool TextLog_Puts(TextLog* const txt, const char* str)
 {
-    return TextLog_Write(txt, str, strlen(str));
+    return snort::TextLog_Write(txt, str, strlen(str));
 }
 
 #endif
index 6825367761f4a169e7127b46078441668e180011..da8be5ec7c69017cb50dfbca35f2d94631bd014b 100644 (file)
@@ -35,7 +35,7 @@ State::State(bool openlibs)
     state = luaL_newstate();
 
     if ( !state )
-        FatalError("Lua state instantiation failed\n");
+        snort::FatalError("Lua state instantiation failed\n");
 
     if ( openlibs )
         luaL_openlibs(state);
index e50f022c0380a001a326808519f94ea6c0a84154..06ce4d30e755457a582a646494694424616c71b7 100644 (file)
@@ -96,7 +96,7 @@ ACSwap::~ACSwap()
 {
     delete ps;
     Swapper::set_reload_in_progress(false);
-    LogMessage("== reload complete\n");
+    snort::LogMessage("== reload complete\n");
 }
 
 void ACDAQSwap::execute(Analyzer& analyzer)
@@ -106,6 +106,6 @@ void ACDAQSwap::execute(Analyzer& analyzer)
 
 ACDAQSwap::~ACDAQSwap()
 {
-    LogMessage("== daq module reload complete\n");
+    snort::LogMessage("== daq module reload complete\n");
 }
 
index 76819be9eb33c2d2443c9f2439a5939a708a6965..62a90eb0cc48da0a956b61d740d5ab70b21b4fb3 100644 (file)
@@ -34,6 +34,7 @@
 #include "request.h"
 #include "snort_config.h"
 
+using namespace snort;
 using namespace std;
 
 static int listener = -1;
@@ -108,25 +109,25 @@ void ControlMgmt::delete_controls()
 int ControlMgmt::setup_socket_family()
 {
     int family = AF_UNSPEC;
-    if ( snort::SnortConfig::get_conf()->remote_control_port )
+    if ( SnortConfig::get_conf()->remote_control_port )
     {
         memset(&in_addr, 0, sizeof(in_addr));
 
         in_addr.sin_family = AF_INET;
         in_addr.sin_addr.s_addr = htonl(0x7F000001);
-        in_addr.sin_port = htons(snort::SnortConfig::get_conf()->remote_control_port);
+        in_addr.sin_port = htons(SnortConfig::get_conf()->remote_control_port);
         sock_addr = (struct sockaddr*)&in_addr;
         sock_addr_size = sizeof(in_addr);
         family = AF_INET;
     }
-    else if ( !snort::SnortConfig::get_conf()->remote_control_socket.empty() )
+    else if ( !SnortConfig::get_conf()->remote_control_socket.empty() )
     {
         std::string fullpath;
-        const char* path_sep = strrchr(snort::SnortConfig::get_conf()->remote_control_socket.c_str(), '/');
+        const char* path_sep = strrchr(SnortConfig::get_conf()->remote_control_socket.c_str(), '/');
         if (path_sep != nullptr)
-            fullpath = snort::SnortConfig::get_conf()->remote_control_socket;
+            fullpath = SnortConfig::get_conf()->remote_control_socket;
         else
-            get_instance_file(fullpath, snort::SnortConfig::get_conf()->remote_control_socket.c_str());
+            get_instance_file(fullpath, SnortConfig::get_conf()->remote_control_socket.c_str());
 
         memset(&unix_addr, 0, sizeof(unix_addr));
         unix_addr.sun_family = AF_UNIX;
index 7f06a5e6687e5bde3d15e3e7d94cc8930bfb22c0..4cdad1d9fcaab15e6ca41968cb4145ce767bcc8a 100644 (file)
@@ -266,7 +266,10 @@ static const Parameter search_engine_params[] =
 #define search_engine_help \
     "configure fast pattern matcher"
 
+namespace snort
+{
 THREAD_LOCAL PatMatQStat pmqs;
+}
 
 const PegInfo mpse_pegs[] =
 {
index c9be172e596d473000464a58453f83e263ce3563..cc7d9718ce89599ade31b36e85ac8579685fc9fe 100644 (file)
@@ -37,12 +37,17 @@ typedef unsigned char uuid_t[16];
 
 #include "framework/data_bus.h"
 
+namespace snort
+{
+struct GHash;
+}
+
 struct PortTable;
 struct vartable_t;
 struct sfip_var_t;
 
 typedef unsigned int PolicyId;
-typedef struct GHash PortVarTable;
+typedef struct snort::GHash PortVarTable;
 
 enum PolicyMode
 {
index 887c095641f45f6bfc91045096f090dc805b1985..efed766da906a14c8e21381b8e84313f238923ec 100644 (file)
@@ -88,7 +88,7 @@ void Request::respond(const char* s, bool queue_response)
 {
     if ( fd < 1 )
     {
-        LogMessage("%s", s);
+        snort::LogMessage("%s", s);
         return;
     }
 
index 6546d9e83d2b19056e35740af3642b9877f6a2e4..8c0388e796fee4623485d65976583dd661adaa9f 100644 (file)
@@ -119,8 +119,7 @@ enum TunnelFlags
 struct ClassType;
 struct srmm_table_t;
 struct sopg_table_t;
-struct GHash;
-struct XHash;
+
 struct MemoryConfig;
 struct LatencyConfig;
 struct PORT_RULE_MAP;
@@ -136,13 +135,15 @@ struct RateFilterConfig;
 struct SFDAQConfig;
 class ThreadConfig;
 struct ReferenceSystemNode;
-class ProtocolReference;
 struct VarNode;
 struct _IntelPmHandles;
 
 namespace snort
 {
 struct ProfilerConfig;
+class ProtocolReference;
+struct GHash;
+struct XHash;
 
 struct SnortConfig;
 typedef void (* ScScratchFunc)(SnortConfig* sc);
index 41274c7d601b8e339c85ee958f2d1d8c1ba6494b..2c82a0eaf1460ae65bd81362b7aaab90605a6e25 100644 (file)
@@ -33,6 +33,8 @@
 
 #include "snort_config.h"
 
+using namespace snort;
+
 bool trace_enabled(Trace mask, Trace flags)
 { return mask & flags; }
 
index 8f7a31cbf9296fb25f3a189668dff63e5be46cdf..4b736486263be030350fac649343f395a3abb256 100644 (file)
@@ -47,15 +47,9 @@ uint16_t get_run_num()
 void set_instance_id(unsigned id)
 { instance_id = id; }
 
-unsigned get_instance_id()
-{ return instance_id; }
-
 void set_thread_type(SThreadType type)
 { thread_type = type; }
 
-SThreadType get_thread_type()
-{ return thread_type; }
-
 //-------------------------------------------------------------------------
 // union rules - breaks are mandatory and must be taken in daq thread
 //-------------------------------------------------------------------------
@@ -75,6 +69,15 @@ bool break_time()
     return true;
 }
 
+namespace snort
+{
+unsigned get_instance_id()
+{ return instance_id; }
+
+SThreadType get_thread_type()
+{ return thread_type; }
+
+
 //-------------------------------------------------------------------------
 // format is:
 //     <logdir>/[<run_prefix>][<id#>][<X>]<name>
@@ -124,3 +127,4 @@ const char* get_instance_file(std::string& file, const char* name)
 
     return file.c_str();
 }
+}
index 539b2e2f0025acae43a6702305e9380bb93172ec..eca181d975fabdbbaef9f41dc713cc961fbc326f 100644 (file)
@@ -49,6 +49,8 @@ void set_thread_type(SThreadType);
 void set_run_num(uint16_t);
 uint16_t get_run_num();
 
+namespace snort
+{
 SO_PUBLIC unsigned get_instance_id();
 SO_PUBLIC SThreadType get_thread_type();
 SO_PUBLIC inline bool is_packet_thread()
@@ -60,6 +62,7 @@ SO_PUBLIC inline bool is_packet_thread()
 // get a packet thread specific path.  name should be the module name or
 // derived therefrom.
 SO_PUBLIC const char* get_instance_file(std::string&, const char* name);
+}
 
 void take_break();
 bool break_time();
index 7e8d13523524eb3d4a68f547a2f26116e4b0d560..0e343939cd1a129cc403058df8e1cd52d65c3798 100644 (file)
@@ -136,7 +136,7 @@ void ThreadConfig::set_thread_affinity(SThreadType type, unsigned id, CpuSet* cp
         thread_affinity[key] = cpuset;
     }
     else
-        ParseWarning(WARN_CONF, "This platform does not support setting thread affinity.\n");
+        snort::ParseWarning(WARN_CONF, "This platform does not support setting thread affinity.\n");
 }
 
 void ThreadConfig::implement_thread_affinity(SThreadType type, unsigned id)
@@ -158,13 +158,13 @@ void ThreadConfig::implement_thread_affinity(SThreadType type, unsigned id)
     current_cpuset = hwloc_bitmap_alloc();
     hwloc_get_cpubind(topology, current_cpuset, HWLOC_CPUBIND_THREAD);
     if (!hwloc_bitmap_isequal(current_cpuset, desired_cpuset))
-        LogMessage("Binding thread %u (type %u) to %s.\n", id, type, s);
+        snort::LogMessage("Binding thread %u (type %u) to %s.\n", id, type, s);
     hwloc_bitmap_free(current_cpuset);
 
     if (hwloc_set_cpubind(topology, desired_cpuset, HWLOC_CPUBIND_THREAD))
     {
-        FatalError("Failed to pin thread %u (type %u) to %s: %s (%d)\n",
-                id, type, s, get_error(errno), errno);
+        snort::FatalError("Failed to pin thread %u (type %u) to %s: %s (%d)\n",
+                id, type, s, snort::get_error(errno), errno);
     }
 
     free(s);
index 5415feb44a08676bf58bea28b6638c7bc827c423..bf4c90cf1972b7751c517be5c15c95520c09e239 100644 (file)
@@ -55,7 +55,7 @@ void SoManager::release_plugins()
 
 void SoManager::dump_plugins()
 {
-    Dumper d("SO Rules");
+    snort::Dumper d("SO Rules");
 
     for ( auto* p : s_rules )
         d.dump(p->base.name, p->base.version);
index 8021051423709330bb11107bffd58365345353f1..ec8ca29d913dbfac6d7e09edbfa2cf9f5676f350 100644 (file)
@@ -40,6 +40,8 @@
 #include "catch/snort_catch.h"
 #endif
 
+using namespace snort;
+
 namespace memory
 {
 
index 51b1ed8254a17171d561cd8ef779904222a4cbc9..f4b92b625f1d19fe08ff9a9733d728b7fbef2a0d 100644 (file)
@@ -47,7 +47,7 @@ DecodeResult B64Decode::decode_data(const uint8_t* start, const uint8_t* end)
 
     uint32_t encode_avail = buffer->get_encode_avail() - buffer->get_prev_encoded_bytes();
 
-    if (sf_strip_CRLF(start, (end-start), buffer->get_encode_buff() + buffer->get_prev_encoded_bytes(),
+    if (snort::sf_strip_CRLF(start, (end-start), buffer->get_encode_buff() + buffer->get_prev_encoded_bytes(),
         encode_avail, &act_encode_size) != 0)
     {
         reset_decode_state();
@@ -68,7 +68,7 @@ DecodeResult B64Decode::decode_data(const uint8_t* start, const uint8_t* end)
     else
         buffer->reset_saved();
 
-    if (sf_base64decode(buffer->get_encode_buff(), act_encode_size,
+    if (snort::sf_base64decode(buffer->get_encode_buff(), act_encode_size,
         buffer->get_decode_buff(), buffer->get_decode_avail(), &act_decode_size) != 0)
     {
         reset_decode_state();
@@ -118,6 +118,8 @@ uint8_t sf_decode64tab[256] =
     100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100
 };
 
+namespace snort
+{
 /* base64decode assumes the input data terminates with '=' and/or at the end of the input buffer
  * at inbuf_size.  If extra characters exist within inbuf before inbuf_size is reached, it will
  * happily decode what it can and skip over what it can't.  This is consistent with other decoders
@@ -212,4 +214,5 @@ int sf_base64decode(uint8_t* inbuf, uint32_t inbuf_size, uint8_t* outbuf, uint32
     else
         return(0);
 }
+} // namespace snort
 
index d0802f9c314f31573d8712cc8c516c2d4bce927b..2415f4ff89bc61e0836b15a411705442032dda7f 100644 (file)
@@ -40,12 +40,14 @@ private:
     class DecodeBuffer* buffer = nullptr;
 };
 
+namespace snort
+{
 // FIXIT-L inbuf should probably be const uint8_t*
 SO_PUBLIC int sf_base64decode(
     uint8_t* inbuf, uint32_t inbuf_size,
     uint8_t* outbuf, uint32_t outbuf_size,
     uint32_t* bytes_written
     );
-
+}
 #endif
 
index 7e261c7650d0e6b8dc7c0f335f7ef675045ade88..8daf8968bb11978599e3d4085384a426fd382787 100644 (file)
@@ -49,7 +49,7 @@ DecodeResult QPDecode::decode_data(const uint8_t* start, const uint8_t* end)
 
     uint32_t encode_avail = buffer->get_encode_avail() - buffer->get_prev_encoded_bytes();
 
-    if (sf_strip_LWS(start, (end-start), buffer->get_encode_buff() + buffer->get_prev_encoded_bytes(),
+    if (snort::sf_strip_LWS(start, (end-start), buffer->get_encode_buff() + buffer->get_prev_encoded_bytes(),
         encode_avail, &act_encode_size) != 0)
     {
         reset_decode_state();
index 2f89fe06319cd9b7de79fbe93374c4584276287e..d4fdecf7e358659fe53422536cc6f3003bebf2c8 100644 (file)
@@ -149,13 +149,13 @@ int sf_uudecode(uint8_t* src, uint32_t slen, uint8_t* dst, uint32_t dlen, uint32
         }
         else
         {
-            const uint8_t* sod = (const uint8_t*)SnortStrnStr((const char*)src, 5, "begin");
+            const uint8_t* sod = (const uint8_t*)snort::SnortStrnStr((const char*)src, 5, "begin");
 
             if (sod)
             {
                 *begin_found = true;
                 /*begin str found. Move to the actual data*/
-                ptr = (const uint8_t*)SnortStrnStr((const char*)(sod), (end - sod), "\n");
+                ptr = (const uint8_t*)snort::SnortStrnStr((const char*)(sod), (end - sod), "\n");
                 if ( !ptr )
                 {
                     *bytes_read = slen;
index c05d9e238e509f55dbf4edbbe98ea27de8c9eee6..2df9f89941f2fd4212b830439b241b91a2b0db52 100644 (file)
@@ -29,6 +29,8 @@
 #include "log/messages.h"
 #include "file_api/file_service.h"
 
+using namespace snort;
+
 void DecodeConfig::set_ignore_data(bool ignored)
 {
     ignore_data = ignored;
index d103559c37217a3d2c7d700da3faa5734d3d0825..5a641fb28ea807f3e08a9332fa36f7528bed85a4 100644 (file)
@@ -33,6 +33,8 @@
 #define MAX_DEPTH                     65535
 #define MIN_DEPTH                     (-1)
 
+namespace snort
+{
 class SO_PUBLIC DecodeConfig
 {
 public:
@@ -66,6 +68,6 @@ private:
     int64_t file_depth = MIN_DEPTH;
     bool decode_enabled = true;
 };
-
+}
 #endif
 
index 6f3f87283fc57b867e2513e99315d7c0f9095ffc..17afe3e0ccbb0b6cc71e368d4e6f2522c1d9e142 100644 (file)
@@ -31,6 +31,8 @@
 #include "decode_qp.h"
 #include "decode_uu.h"
 
+using namespace snort;
+
 void MimeDecode::reset_decoded_bytes()
 {
     if (decoder)
@@ -131,7 +133,7 @@ DecodeType MimeDecode::get_decode_type()
     return decode_type;
 }
 
-MimeDecode::MimeDecode(DecodeConfig* conf)
+MimeDecode::MimeDecode(snort::DecodeConfig* conf)
 {
     config = conf;
 }
index dcb4725df5053032cea52ef2933f2c15cc13091a..6aece520e90d4ea058ce990e92101945b1f7114d 100644 (file)
@@ -51,7 +51,7 @@ struct MimeStats
 class MimeDecode
 {
 public:
-    MimeDecode(DecodeConfig* conf);
+    MimeDecode(snort::DecodeConfig* conf);
     ~MimeDecode();
 
     // get the decode type from buffer
@@ -73,7 +73,7 @@ public:
 
 private:
     DecodeType decode_type = DECODE_NONE;
-    DecodeConfig* config;
+    snort::DecodeConfig* config;
     DataDecode* decoder = nullptr;
 };
 
index 69416d79a87a01cf4e0aaa0cca7fbf61cee63011..4dad8e82539a43e6eef6ca78ee827bb2135eb4a3 100644 (file)
@@ -30,6 +30,8 @@
 
 #include "main/snort_debug.h"
 
+using namespace snort;
+
 static const char* boundary_str = "boundary=";
 
 /* Save the boundary string into paf state*/
@@ -138,6 +140,8 @@ static inline bool check_boundary(MimeDataPafInfo* data_info,  uint8_t data)
     return false;
 }
 
+namespace snort
+{
 void reset_mime_paf_state(MimeDataPafInfo* data_info)
 {
     data_info->boundary_search = nullptr;
@@ -219,4 +223,4 @@ bool check_data_end(void* data_end_state,  uint8_t val)
     *((DataEndState*)data_end_state) = state;
     return false;
 }
-
+} // namespace snort
index 6a007f2ff82ff360508d13321bd8c586ad903639..a6f8426742b1c053ad3bcd37e37d3418c39fe995 100644 (file)
@@ -76,11 +76,14 @@ inline bool scanning_boundary(MimeDataPafInfo* mime_info, uint32_t boundary_star
     return false;
 }
 
+namespace snort
+{
 SO_PUBLIC void reset_mime_paf_state(MimeDataPafInfo*);
 
 /*  Process data boundary and flush each file based on boundary*/
 SO_PUBLIC bool process_mime_paf_data(MimeDataPafInfo*,  uint8_t val);
 SO_PUBLIC bool check_data_end(void* end_state,  uint8_t val);
+}
 
 #endif
 
index 987fe156d625d8075d8ca64be6184a8674c744e1..8b755c0dfa66a176d46a79e0ea74ff1decc847cd 100644 (file)
@@ -110,7 +110,7 @@ void check_session_for_AF_indicator(Packet* p, AppidSessionDirection dir, AppId
     AFActVal* test_active_value;
     if ((test_active_value = (AFActVal*)xhash_find(AF_actives, &master_key)))
     {
-        test_active_value->last = packet_time();
+        test_active_value->last = snort::packet_time();
         test_active_value->target = ind_element->target;
         return;
     }
index b020cab0e4268faa078c7b98a051a52ba709d2b6..b920485df92b1bedf3d2722a8202cf675edab319 100644 (file)
@@ -38,6 +38,8 @@
 #include "target_based/snort_protocols.h"
 #include "utils/util_cstring.h"
 
+using namespace snort;
+
 static AppInfoTable app_info_table;
 static AppInfoTable app_info_service_table;
 static AppInfoTable app_info_client_table;
index 4297b71acd1014702557c52afcdd06dcf7810e64..d1effb2b7d952da58b2c776e905b2084938fe8e1 100644 (file)
@@ -42,6 +42,8 @@
 #include "tp_lib_handler.h"
 #endif
 
+using namespace snort;
+
 #define ODP_PORT_DETECTORS "odp/port/*"
 #define CUSTOM_PORT_DETECTORS "custom/port/*"
 #define MAX_DISPLAY_SIZE   65536
index db32a328ca8e91107c83a151eeaad5bf95abd6f9..aa69ef037d91dcad798b8f1936284526f194989a 100644 (file)
@@ -37,6 +37,8 @@
 #include "tp_lib_handler.h"
 #endif
 
+using namespace snort;
+
 static const char* httpFieldName[ MAX_HTTP_FIELD_ID ] = // for use in debug messages
 {
     "useragent",
index e78a0d0e8f12ea5db0a1e768dd5c98253489b370..5e1539c6a06d5ff99f199c57db1fb2d0f32880cd 100644 (file)
@@ -135,7 +135,7 @@ void AppIdPegCounts::print()
     if (!print && unknown_pegs->all_zeros())
         return;
 
-    LogLabel("Appid dynamic stats:");
+    snort::LogLabel("Appid dynamic stats:");
 
     for (unsigned i = 0; i < app_num; i++)
     {
@@ -144,14 +144,14 @@ void AppIdPegCounts::print()
             continue;
 
         std::string app_name = AppIdPegCounts::appid_detectors_info[i];
-        LogMessage("%s: ", app_name.c_str());
+        snort::LogMessage("%s: ", app_name.c_str());
         pegs->print();
     }
 
     // Print unknown app stats
     if (!unknown_pegs->all_zeros())
     {
-        LogMessage("unknown_app: flows: %" PRIu64 ", clients: %" PRIu64 ", users: %" PRIu64 ", payloads %"
+        snort::LogMessage("unknown_app: flows: %" PRIu64 ", clients: %" PRIu64 ", users: %" PRIu64 ", payloads %"
             PRIu64 ", misc: %" PRIu64 "\n",
             unknown_pegs->stats[0], unknown_pegs->stats[1], unknown_pegs->stats[2],
             unknown_pegs->stats[3], unknown_pegs->stats[4]);
index c8c1c0691f8e2625b8805123f9975e792d72e66b..f4246efbaae22ec48931e64f3781cd43261cfc91 100644 (file)
@@ -70,7 +70,7 @@ public:
 
         void print()
         {
-            LogMessage("flows: %" PRIu64 ", clients: %" PRIu64 ", users: %" PRIu64 ", payloads %" PRIu64
+            snort::LogMessage("flows: %" PRIu64 ", clients: %" PRIu64 ", users: %" PRIu64 ", payloads %" PRIu64
                 ", misc: %" PRIu64 ", incompatible: %" PRIu64 ", failed: %" PRIu64 "\n",
                 stats[0], stats[1], stats[2], stats[3], stats[4], stats[5], stats[6]);
         }
index bcd005cea90bcccdced092c6d9f653465e5d01f5..0f0f417478ff70f6f18d0b2a053d9d15ce3e9c41 100644 (file)
@@ -136,22 +136,22 @@ struct TlsSession
     void set_tls_host(const char* new_tls_host, uint32_t len)
     {
         if (tls_host) snort_free(tls_host);
-        tls_host=snort_strndup(new_tls_host,len);
-        tls_host_strlen=len;
+        tls_host = snort::snort_strndup(new_tls_host,len);
+        tls_host_strlen = len;
     }
 
     void set_tls_cname(const char* new_tls_cname, uint32_t len)
     {
         if (tls_cname) snort_free(tls_cname);
-        tls_cname=snort_strndup(new_tls_cname,len);
-        tls_cname_strlen=len;
+        tls_cname = snort::snort_strndup(new_tls_cname,len);
+        tls_cname_strlen = len;
     }
 
     void set_tls_org_unit(const char* new_tls_org_unit, uint32_t len)
     {
         if (tls_orgUnit) snort_free(tls_orgUnit);
-        tls_orgUnit=snort_strndup(new_tls_org_unit,len);
-        tls_orgUnit_strlen=len;
+        tls_orgUnit = snort::snort_strndup(new_tls_org_unit,len);
+        tls_orgUnit_strlen = len;
     }
 };
 
index 22f2dad6d27df8b71ed7b6b3b7b2a9bc866f15a4..ec63de7c560111f6bcde42dbbcc599a77dac54a1 100644 (file)
@@ -33,6 +33,8 @@
 #include "app_info_table.h"
 #include "appid_session.h"
 
+using namespace snort;
+
 #define URLCATBUCKETS   100
 #define URLREPBUCKETS   5
 
@@ -245,7 +247,7 @@ static void update_stats(AppIdSession& asd, AppId app_id, StatsBucket* bucket)
         }
         else
         {
-            WarningMessage("Error saving statistics record for app id: %d", app_id);
+            snort::WarningMessage("Error saving statistics record for app id: %d", app_id);
             snort_free(record);
             record = nullptr;
         }
index b12d049159eac1262cf83ed7afba7e75ca8a066a..0622c83dac7e73277b9d65c7e0b37ef7df99ed4e 100644 (file)
@@ -47,7 +47,7 @@ void ClientDetector::register_appid(AppId appId, unsigned extractsInfo)
     {
         if ( AppInfoManager::get_instance().configured() )
         {
-            ParseWarning(WARN_RULES,
+            snort::ParseWarning(WARN_RULES,
                 "appid: no entry for %d in appMapping.data; no rule support for this ID.",
                 appId);
         }
@@ -55,9 +55,7 @@ void ClientDetector::register_appid(AppId appId, unsigned extractsInfo)
     }
     extractsInfo &= (APPINFO_FLAG_CLIENT_ADDITIONAL | APPINFO_FLAG_CLIENT_USER);
     if (!extractsInfo)
-    {
         return;
-    }
 
     pEntry->client_detector = this;
     pEntry->flags |= extractsInfo;
index 8bd6d092380199d1eb63d46033a5edd7546f4c22..2172ae92adaff5f117d219b57feb3b664794ed9d 100644 (file)
@@ -30,6 +30,8 @@
 
 #include "protocols/packet.h"
 
+using namespace snort;
+
 enum KerberosState
 {
     KRB_STATE_TCP_LENGTH,
index 84f2bdf2aa651f42bd6dbe230caac770f6f4231e..b70f872e0cfbe028639532c5d7e5936b847f4989 100644 (file)
@@ -30,6 +30,7 @@
 #include "protocols/packet.h"
 #include "search_engines/search_tool.h"
 
+using namespace snort;
 
 static THREAD_LOCAL PatternServiceDetector* service_pattern_detector;
 static THREAD_LOCAL PatternClientDetector* client_pattern_detector;
@@ -125,7 +126,7 @@ static void register_pattern(snort::SearchTool** patterns, Pattern* pattern)
         *patterns = new snort::SearchTool("ac_full", true);
         if (!*patterns)
         {
-            ErrorMessage("Error initializing the pattern table\n");
+            snort::ErrorMessage("Error initializing the pattern table\n");
             return;
         }
     }
index 5ab1628f789eee2ad34ae59887b875381f6c5987..2e1b0f0c68e7e951de79da0ebc8a1f5ac464fd4a 100644 (file)
@@ -29,6 +29,8 @@
 
 #include "app_info_table.h"
 
+using namespace snort;
+
 enum POP3ClientState
 {
     POP3_CLIENT_STATE_AUTH,     // POP3 - AUTHORIZATION state
index e3cb5898a7a2232b40c49ab2caba3f98b185ac2a..2545027aa9e45108ac22f869b619dc603d8d774f 100644 (file)
@@ -33,6 +33,8 @@
 #include "log/messages.h"
 #include "protocols/packet.h"
 
+using namespace snort;
+
 static const char* const FP_OPERATION_AND = "%&%";
 static const unsigned PATTERN_PART_MAX = 10;
 
@@ -1840,7 +1842,7 @@ uint32_t HttpPatternMatchers::parse_multiple_http_patterns(const char* pattern,
             for (unsigned i = 0; i <= partNum; i++)
                 snort_free((void*)parts[i].pattern);
 
-            ErrorMessage("Failed to allocate memory");
+            snort::ErrorMessage("Failed to allocate memory");
             return 0;
         }
         partNum++;
index 28c760cdc53e1094fbbf2c52d12aef683cc7e63b..5c636ac9c630d8624f3a51c078b08d6aa142522d 100644 (file)
@@ -94,18 +94,18 @@ struct DetectorHTTPPattern
     {
         if( !pat )
         {
-            ErrorMessage("HTTP pattern string is NULL.");
+            snort::ErrorMessage("HTTP pattern string is NULL.");
             return false;
         }
 
         if (seq < SINGLE || seq > USER_AGENT_HEADER)
         {
-            ErrorMessage("Invalid HTTP DHP Sequence.");
+            snort::ErrorMessage("Invalid HTTP DHP Sequence.");
             return false;
         }
 
         pattern_size = len;
-        pattern = (const uint8_t*)snort_strdup((const char*)pat);
+        pattern = (const uint8_t*)snort::snort_strdup((const char*)pat);
         sequence = seq;
         service_id = service;
         client_id = client;
@@ -255,7 +255,7 @@ class HostUrlDetectorPattern
 public:
     HostUrlDetectorPattern(const uint8_t* host_pattern, unsigned length)
     {
-        host.pattern = (const uint8_t*)snort_strdup((const char*)host_pattern);
+        host.pattern = (const uint8_t*)snort::snort_strdup((const char*)host_pattern);
         host.patternSize = length;
     }
 
index 4db9ba5ccbd534187728486490df11c929c1609a..0050405ca6d8fe4e15ad6132845b1bf32ddd7112 100644 (file)
 #ifndef DETECTOR_PLUGINS_MOCK_H
 #define DETECTOR_PLUGINS_MOCK_H
 
+namespace snort
+{
 // Stubs for messages
 void ErrorMessage(const char*,...) {}
 void WarningMessage(const char*,...) {}
 void LogMessage(const char*,...) {}
 void ParseWarning(WarningGroup, const char*, ...) {}
 
-namespace snort
-{
+// Stubs for appid sessions
+FlowData::FlowData(unsigned, Inspector*) {}
+FlowData::~FlowData() = default;
+
 // Stubs for packet
 Packet::Packet(bool) { }
 Packet::~Packet() = default;
@@ -37,8 +41,51 @@ Inspector::~Inspector() = default;
 bool Inspector::likes(Packet*) { return true; }
 bool Inspector::get_buf(const char*, Packet*, InspectionBuffer&) { return true; }
 class StreamSplitter* Inspector::get_splitter(bool) { return nullptr; }
+
+// Stubs for search_tool.cc
+SearchTool::SearchTool(const char*, bool) {}
+SearchTool::~SearchTool() = default;
+void SearchTool::add(const char*, unsigned, int, bool) {}
+void SearchTool::add(const char*, unsigned, void*, bool) {}
+void SearchTool::add(const uint8_t*, unsigned, int, bool) {}
+void SearchTool::add(const uint8_t*, unsigned, void*, bool) {}
+void SearchTool::prep() {}
+static bool test_find_all_done = false;
+static bool test_find_all_enabled = false;
+static MatchedPatterns* mock_mp = nullptr;
+int SearchTool::find_all(const char*, unsigned, MpseMatch, bool, void* mp_arg)
+{
+    test_find_all_done = true;
+    if (test_find_all_enabled)
+        memcpy(mp_arg, &mock_mp, sizeof(MatchedPatterns*));
+    return 0;
 }
 
+// Stubs for util.cc
+char* snort_strndup(const char* src, size_t dst_size)
+{
+    char* dup = (char*)snort_calloc(dst_size + 1);
+    if ( SnortStrncpy(dup, src, dst_size + 1) == SNORT_STRNCPY_ERROR )
+    {
+        snort_free(dup);
+        return nullptr;
+    }
+    return dup;
+}
+char* snort_strdup(const char* str)
+{
+    assert(str);
+    size_t n = strlen(str) + 1;
+    char* p = (char*)snort_alloc(n);
+    memcpy(p, str, n);
+    return p;
+}
+}
+
+void show_stats(PegCount*, const PegInfo*, unsigned, const char*) {}
+void show_stats(PegCount*, const PegInfo*, IndexVec&, const char*) {}
+void show_stats(PegCount*, const PegInfo*, IndexVec&, const char*, FILE*) {}
+
 class AppIdInspector : public snort::Inspector
 {
 public:
@@ -85,13 +132,6 @@ snort::ProfileStats* AppIdModule::get_profile() const
 {
     return nullptr;
 }
-void show_stats(PegCount*, const PegInfo*, unsigned, const char*) {}
-void show_stats(PegCount*, const PegInfo*, IndexVec&, const char*) {}
-void show_stats(PegCount*, const PegInfo*, IndexVec&, const char*, FILE*) {}
-
-// Stubs for appid sessions
-snort::FlowData::FlowData(unsigned, Inspector*) {}
-snort::FlowData::~FlowData() = default;
 
 // Stubs for inspectors
 unsigned AppIdSession::inspector_id = 0;
@@ -112,28 +152,6 @@ THREAD_LOCAL AppIdStats appid_stats;
 void AppIdModule::sum_stats(bool) {}
 void AppIdModule::show_dynamic_stats() {}
 
-namespace snort
-{
-// Stubs for search_tool.cc
-SearchTool::SearchTool(const char*, bool) {}
-SearchTool::~SearchTool() = default;
-void SearchTool::add(const char*, unsigned, int, bool) {}
-void SearchTool::add(const char*, unsigned, void*, bool) {}
-void SearchTool::add(const uint8_t*, unsigned, int, bool) {}
-void SearchTool::add(const uint8_t*, unsigned, void*, bool) {}
-void SearchTool::prep() {}
-static bool test_find_all_done = false;
-static bool test_find_all_enabled = false;
-static MatchedPatterns* mock_mp = nullptr;
-int SearchTool::find_all(const char*, unsigned, MpseMatch, bool, void* mp_arg)
-{
-    test_find_all_done = true;
-    if (test_find_all_enabled)
-        memcpy(mp_arg, &mock_mp, sizeof(MatchedPatterns*));
-    return 0;
-}
-}
-
 // Stubs for appid_session.cc
 static bool test_service_strstr_enabled = false;
 const uint8_t* service_strstr(const uint8_t* p, unsigned,
@@ -162,25 +180,5 @@ AppInfoTableEntry* AppInfoManager::get_app_info_entry(AppId, const AppInfoTable&
     return nullptr;
 }
 
-// Stubs for util.cc
-char* snort_strndup(const char* src, size_t dst_size)
-{
-    char* dup = (char*)snort_calloc(dst_size + 1);
-    if ( SnortStrncpy(dup, src, dst_size + 1) == SNORT_STRNCPY_ERROR )
-    {
-        snort_free(dup);
-        return nullptr;
-    }
-    return dup;
-}
-char* snort_strdup(const char* str)
-{
-    assert(str);
-    size_t n = strlen(str) + 1;
-    char* p = (char*)snort_alloc(n);
-    memcpy(p, str, n);
-    return p;
-}
-
 #endif
 
index b67aa9c8e0beac073b784fc0acf846faadad24c2..16a3965a55eba9b98e18057cc724e3459678077f 100644 (file)
@@ -30,6 +30,8 @@
 #include "log/messages.h"
 #include "main/thread.h"
 
+using namespace snort;
+
 #define HASH_NUM_ROWS (1024)
 
 static THREAD_LOCAL XHash* lengthCache = nullptr;
index 889634c89f273591f943c96ae779e8282909b496..3395dcc751d05028964b42d7eb7c8ea9244106a6 100644 (file)
@@ -39,6 +39,8 @@
 #include "utils/sflsq.h"
 #include "log/messages.h"
 
+using namespace snort;
+
 #define MAX_LUA_DETECTOR_FILENAME_LEN 1024
 #define MAX_DEFAULT_NUM_LUA_TRACKERS  10000
 #define AVG_LUA_TRACKER_SIZE_IN_BYTES 740
index 1abbc5786614fbc4d6adc45f6cd2b9fa70e7dc5f..8b83e6c2012202e391acef8e651657102dbb0ffc 100644 (file)
@@ -113,7 +113,7 @@ int RshellServiceDetector::validate(AppIdDiscoveryArgs& args)
     }
 
     if (appidDebug->is_active())
-        LogMessage("AppIdDbg %s RSHELL state %d\n", appidDebug->get_debug_session(), rd->state);
+        snort::LogMessage("AppIdDbg %s RSHELL state %d\n", appidDebug->get_debug_session(), rd->state);
 
     switch (rd->state)
     {
index 8af0a4b3430e26ece00ef345d9cae38b34e52379..3f99f1a4fa0bfae758b573fcc1b722f9eada2d50 100644 (file)
@@ -421,7 +421,7 @@ int SnmpServiceDetector::validate(AppIdDiscoveryArgs& args)
     if (snmp_verify_packet(&data, data+size, &pdu, &version))
     {
         if (appidDebug->is_active())
-            LogMessage("AppIdDbg %s SNMP payload verify failed\n", appidDebug->get_debug_session());
+            snort::LogMessage("AppIdDbg %s SNMP payload verify failed\n", appidDebug->get_debug_session());
         if (args.asd.get_session_flags(APPID_SESSION_UDP_REVERSED))
         {
             if (args.dir == APP_ID_FROM_RESPONDER)
@@ -439,7 +439,7 @@ int SnmpServiceDetector::validate(AppIdDiscoveryArgs& args)
     }
 
     if (appidDebug->is_active())
-        LogMessage("AppIdDbg %s SNMP state %d\n", appidDebug->get_debug_session(), sd->state);
+        snort::LogMessage("AppIdDbg %s SNMP state %d\n", appidDebug->get_debug_session(), sd->state);
 
     switch (sd->state)
     {
index c99ff17324a58c466bfd8d186c1291bd8be73bbc..70e1d0027e562bb7281474d443e0bd6db09e416d 100644 (file)
@@ -31,6 +31,8 @@
 #include "appid_debug.h"
 #include "appid_inspector.h"
 
+using namespace snort;
+
 #define TFTP_PORT   69
 #define TFTP_COUNT_THRESHOLD 1
 #define TFTP_MAX_PACKET_SIZE 512
index db1d4ef0a24578c149100b7b717198a5a782f20d..a5b56a977a9dd65a3116bf1853aacf6da41d5c17 100644 (file)
 
 // Mocks
 
+namespace snort
+{
 unsigned get_instance_id() { return 3; }
 
+FlowData::FlowData(unsigned, Inspector*) { }
+FlowData::~FlowData() = default;
+}
+
 class AppIdInspector
 {
 public:
     AppIdInspector() = default;
 };
 
-FlowData::FlowData(unsigned, Inspector*) { }
-FlowData::~FlowData() = default;
-
 AppIdSession::AppIdSession(IpProtocol, const SfIp*, uint16_t, AppIdInspector& inspector)
     : FlowData(0), inspector(inspector) { }
 AppIdSession::~AppIdSession() = default;
index c4f72c744910fb3ae861defc0b3f1e72f09d6376..c51260d7a3cc8c3680dea0e3ebea090201a5d9bc 100644 (file)
@@ -29,6 +29,8 @@ struct ThirdPartyAppIDModule;
 AppIdConfig* pAppidActiveConfig = nullptr;
 ThirdPartyAppIDModule* tp_appid_module = nullptr;
 
+namespace snort
+{
 char* snort_strndup(const char* src, size_t dst_size)
 {
     return strndup(src, dst_size);
@@ -43,6 +45,14 @@ char* snort_strdup(const char* str)
     return p;
 }
 
+void ErrorMessage(const char*,...) { }
+void WarningMessage(const char*,...) { }
+void LogMessage(const char*,...) { }
+void ParseWarning(WarningGroup, const char*, ...) { }
+
+void LogLabel(const char*, FILE*) {}
+}
+
 void Field::set(int32_t length, const uint8_t* start, bool own_the_buffer_)
 {
     strt = start;
@@ -52,12 +62,6 @@ void Field::set(int32_t length, const uint8_t* start, bool own_the_buffer_)
 
 Field global_field;
 
-void ErrorMessage(const char*,...) { }
-void WarningMessage(const char*,...) { }
-void LogMessage(const char*,...) { }
-void ParseWarning(WarningGroup, const char*, ...) { }
-
-void LogLabel(const char*, FILE*) {}
 
 int ServiceDiscovery::add_ftp_service_state(AppIdSession&)
 {
index 57c114b5bb57b0d746dfc89f22564343ca447fa8..a1327b656f01ebe814dbd49df6e672479b383566 100644 (file)
@@ -9,6 +9,8 @@
 
 using namespace std;
 
+namespace snort
+{
 // Note: without SO_PUBLIC this is not being exported so tp_mock.so won't
 // load because of undefined symbol error. 
 SO_PUBLIC void ErrorMessage(const char* format,...)
@@ -41,6 +43,6 @@ SO_PUBLIC void LogMessage(const char* format,...)
     vfprintf(stdout, format, ap);
     va_end(ap);
 }
-
+}
 #endif
 
index 49fb85725e1f55d8a038e88b476899b312529b4c..68b25918d403a15f03d55feab693518c7d0ec537 100644 (file)
 #include <CppUTest/CommandLineTestRunner.h>
 #include <CppUTest/TestHarness.h>
 
-// Stubs for AppIdDebug
-THREAD_LOCAL AppIdDebug* appidDebug = nullptr;
-void AppIdDebug::activate(const Flow*, const AppIdSession*, bool) { active = true; }
-
+namespace snort
+{
 // Stubs for logs
 char test_log[256];
 void LogMessage(const char* format,...)
@@ -41,7 +39,6 @@ void LogMessage(const char* format,...)
 }
 void ErrorMessage(const char*,...) {}
 void LogLabel(const char*, FILE*) {}
-THREAD_LOCAL AppIdStats appid_stats;
 
 // Stubs for utils
 char* snort_strdup(const char* str)
@@ -53,6 +50,7 @@ char* snort_strdup(const char* str)
     return p;
 }
 time_t packet_time() { return std::time(0); }
+}
 
 // Stubs for AppInfoManager
 AppInfoTableEntry* AppInfoManager::get_app_info_entry(AppId)
@@ -64,6 +62,13 @@ AppInfoTableEntry* AppInfoManager::get_app_info_entry(AppId)
 class AppIdInspector{};
 FlowData::FlowData(unsigned, Inspector*) {}
 FlowData::~FlowData() = default;
+
+// Stubs for AppIdDebug
+THREAD_LOCAL AppIdDebug* appidDebug = nullptr;
+THREAD_LOCAL AppIdStats appid_stats;
+
+void AppIdDebug::activate(const Flow*, const AppIdSession*, bool) { active = true; }
+
 AppIdSession::AppIdSession(IpProtocol, const SfIp*, uint16_t, AppIdInspector& inspector)
     : FlowData(0), inspector(inspector) {}
 AppIdSession::~AppIdSession() = default;
index 41eea07d994f5938698a522fe93e08b023a3aeb9..bf5b273521d8981dd74cc38c87c82285dcfbfc3c 100644 (file)
@@ -135,7 +135,7 @@ bool ArpSpoofModule::end(const char*, int idx, SnortConfig*)
 }
 
 const PegInfo* ArpSpoofModule::get_pegs() const
-{ return simple_pegs; }
+{ return snort::simple_pegs; }
 
 PegCount* ArpSpoofModule::get_counts() const
 { return (PegCount*)&asstats; }
index 55b908168074a30ff2a5fdd37c7aed97c06a79cb..cd8b7dbf9f7a57948a45f3e762ed01995210dade 100644 (file)
@@ -47,7 +47,7 @@ static inline uint64_t get_microseconds(struct timeval t)
 
 CPUTracker::CPUTracker(PerfConfig *perf) : PerfTracker(perf, TRACKER_NAME)
 {
-    formatter->register_section("thread_" + to_string(get_instance_id()));
+    formatter->register_section("thread_" + to_string(snort::get_instance_id()));
     formatter->register_field("cpu_user", &user_stat);
     formatter->register_field("cpu_system", &system_stat);
     formatter->register_field("cpu_wall", &wall_stat);
index 5e6e546724b51948bd50f72d57f9e59d0866a20e..eaccf2cbf4e60e0d262e4e2023b379c2af56d3bc 100644 (file)
@@ -71,7 +71,7 @@ public:
 
 private:
     FlowStateValue stats;
-    XHash* ip_map;
+    snort::XHash* ip_map;
     char ip_a[41], ip_b[41];
 
     FlowStateValue* find_stats(const snort::SfIp* src_addr, const snort::SfIp* dst_addr, int* swapped);
index 0fa271029432a5b5a6b31288ca75bc41de1ca0de..6a3eb6dcc230cc126e268e13c4ea272a20e5e130 100644 (file)
@@ -202,7 +202,7 @@ PerfConfig& PerfMonModule::get_config()
 { return config; }
 
 const PegInfo* PerfMonModule::get_pegs() const
-{ return simple_pegs; }
+{ return snort::simple_pegs; }
 
 PegCount* PerfMonModule::get_counts() const
 { return (PegCount*)&pmstats; }
index eeda5d17cc83e87fe16262089576e8049ab9924f..2d2b44f798dbe1879d6bc397c13d3345844abd70 100644 (file)
@@ -41,6 +41,7 @@
 #include "json_formatter.h"
 #include "text_formatter.h"
 
+using namespace snort;
 using namespace std;
 
 static inline bool check_file_size(FILE* fh, uint64_t max_file_size)
index 0328528c199a830c56ac1a7e0f5b24d5a5b53e9e..697dccab4d1b4e533906ca2f8b41406cae94c9a7 100644 (file)
@@ -36,6 +36,7 @@
 #include "utils/util.h"
 #endif
 
+using namespace snort;
 using namespace std;
 
 void TextFormatter::write(FILE* fh, time_t)
index e37b468ab9ab066d238dacbb44292df24d0b6ddc..8b2a3885e6df88b26d5d2f71f681452ffbe97fc3 100644 (file)
@@ -198,7 +198,7 @@ ProfileStats* PortScanModule::get_profile() const
 { return &psPerfStats; }
 
 const PegInfo* PortScanModule::get_pegs() const
-{ return simple_pegs; }
+{ return snort::simple_pegs; }
 
 PegCount* PortScanModule::get_counts() const
 { return (PegCount*)&spstats; }
index 0043665b583e9057fb197e8f227c8e355fdb2ff9..0351aa80b26bd856cd48cf76dadd034b0a4916c6 100644 (file)
@@ -36,6 +36,7 @@
 #include "utils/util.h"
 #include "utils/util_cstring.h"
 
+using namespace snort;
 using namespace std;
 
 enum
index 14e0977434452c82b87dfd5a70ba522a8e8e5aab..a77ffe20c9d53226f53c91a1f439efa850e2234d 100644 (file)
@@ -41,7 +41,7 @@ void PrintAllInterfaces()
     int j = 1;
 
     if (pcap_findalldevs(&alldevs, errorbuf) == -1)
-        FatalError("Could not get device list: %s.", errorbuf);
+        snort::FatalError("Could not get device list: %s.", errorbuf);
 
     printf("Index\tDevice\tPhysical Address\tIP Address\tDescription\n");
     printf("-----\t------\t----------------\t----------\t-----------\n");
index 4dc9b5eefdcaaf2249d0e5cb83bc10011ec94f82..375c54317c4650fab2c34ae1edf9b2ec5f562f90 100644 (file)
@@ -35,6 +35,8 @@
 #include "main/snort_config.h"
 #include "utils/util.h"
 
+using namespace snort;
+
 std::vector<struct Trough::PcapReadObject> Trough::pcap_object_list;
 std::vector<std::string> Trough::pcap_queue;
 std::string Trough::pcap_filter;
index f0da3777ff3304cd4de92a6d75e312da30f3a7c2..107b707ea919eb730137e35583eb1e6f8fbd8827 100644 (file)
@@ -67,7 +67,7 @@ static int GetChecksumFlags(const char* args)
     if (args == nullptr)
         return CHECKSUM_FLAG__ALL;
 
-    toks = mSplit(args, " \t", 10, &num_toks, 0);
+    toks = snort::mSplit(args, " \t", 10, &num_toks, 0);
     for (i = 0; i < num_toks; i++)
     {
         if (strcasecmp(toks[i], CHECKSUM_MODE_OPT__ALL) == 0)
@@ -132,7 +132,7 @@ static int GetChecksumFlags(const char* args)
         }
         else
         {
-            ParseError("unknown command line checksum option: %s.", toks[i]);
+            snort::ParseError("unknown command line checksum option: %s.", toks[i]);
             return ret_flags;
         }
     }
@@ -160,7 +160,7 @@ static int GetChecksumFlags(const char* args)
         ret_flags = negative_flags;
     }
 
-    mSplitFree(&toks, num_toks);
+    snort::mSplitFree(&toks, num_toks);
     return ret_flags;
 }
 
index e5976724dc2a80e45b3ce8c3d4db57a2c73aadd2..8b3452ab604b449cda44d647bedc5044de895eec 100644 (file)
@@ -28,6 +28,8 @@
 
 #include "utils/util.h"
 
+namespace snort
+{
 static char* mSplitAddTok(const char*, const int, const char*, const char);
 
 /****************************************************************
@@ -422,4 +424,4 @@ void mSplitFree(char*** pbuf, int num_toks)
     snort_free(buf);
     *pbuf = nullptr;
 }
-
+} // namespace snort
index fd6c86d16dcfe50a4e0eb76f808e25e27fe915c0..14bda7ebc97c94973065876bc1d7f63ce60154df 100644 (file)
 
 #define TOKS_BUF_SIZE   100
 
+namespace snort
+{
 SO_PUBLIC char** mSplit(const char*, const char*, const int, int*, const char);
 SO_PUBLIC void mSplitFree(char*** toks, int numtoks);
-
+}
 #endif
 
index d0cc3db2629e0aadbb6fc513d25698b4de24496c..08b91d19ca0b8d3f64d60c8c37d69d3f24b8c34d 100644 (file)
@@ -42,19 +42,19 @@ sfip_var_t* sfip_var_from_string(const char* addr)
     {
         if (ret_code == SFIP_LOOKUP_FAILURE)
         {
-            ParseError("Undefined variable in the string: %s", addr);
+            snort::ParseError("Undefined variable in the string: %s", addr);
             return ret;
         }
         else if (ret_code == SFIP_CONFLICT)
         {
-            ParseError("Negated IP ranges that equal to or are"
+            snort::ParseError("Negated IP ranges that equal to or are"
                 " more-specific than non-negated ranges are not allowed."
                 " Consider inverting the logic: %s.", addr);
             return ret;
         }
         else
         {
-            ParseError("Unable to process the IP address: %s", addr);
+            snort::ParseError("Unable to process the IP address: %s", addr);
             return ret;
         }
     }
index 3242143e33a8bd50659039feb677dd8f53e9fbbf..f453aa211aa3dfca55e3c7c01b8641a510fe10d6 100644 (file)
@@ -26,6 +26,8 @@
 #include "protocols/packet.h"
 #include "utils/util.h"
 
+using namespace snort;
+
 static int POParserInit(POParser* pop, const char* s, PortVarTable* pvTable)
 {
     memset(pop,0,sizeof(POParser));
@@ -172,7 +174,7 @@ static char* POParserName(POParser* pop)
 }
 
 /*
-*   Read an unsigned short (a port)
+*   read an unsigned short (a port)
 */
 static uint16_t POParserGetShort(POParser* pop)
 {
index e07ecb4410b480022c2a88a9e2f978962a843b4a..eeeb52deb155eb94d69959ca7da7b3550bd564fc 100644 (file)
@@ -32,6 +32,7 @@
 #include "parse_conf.h"
 #include "parse_rule.h"
 
+using namespace snort;
 using namespace std;
 
 static unsigned chars = 0, tokens = 0;
index 227417911427775ee85b39727e8dbe59b7befeb0..dadd9ad8566ca62e27fa407a15a88f11f337277b 100644 (file)
@@ -29,6 +29,7 @@
 #include "log/messages.h"
 #include "utils/util_cstring.h"
 
+using namespace snort;
 using namespace std;
 
 static inline int xton(int c)
index e1e8a02f690a775c199e9c8912185902fc0d2dde..e90a1e5a478e3d61cec4e4ce22b9ea9bd8daa6c3 100644 (file)
@@ -34,7 +34,7 @@ namespace snort
 {
 class Module;
 struct SnortConfig;
-}
+} // namespace snort
 
 #define PIGLET_API_VERSION 1
 
@@ -108,7 +108,7 @@ inline void error(std::string fmt, Args&&... args)
 {
     fmt.insert(0, "piglet: ");
     fmt.append("\n");
-    ErrorMessage(fmt.c_str(), std::forward<Args>(args)...);
+    snort::ErrorMessage(fmt.c_str(), std::forward<Args>(args)...);
 }
 
 } // namespace Piglet
index d46598e832a1d3124960ecd44bbc615873a31f4b..aafcec30f30cb7a7b97cc207d977354fc399a8bd 100644 (file)
@@ -35,10 +35,7 @@ namespace Piglet
 struct Chunk;
 struct Api;
 class BasePlugin;
-}
 
-namespace Piglet
-{
 class Manager
 {
 public:
index ec06ba9a3d36e1cdd5f560b208e581ea1e09e7b8..17f7eba7a56b238b606c8ecb48ec05ad9e215ddd 100644 (file)
@@ -34,6 +34,8 @@
 #include "piglet_output.h"
 #include "piglet_utils.h"
 
+using namespace snort;
+
 namespace Piglet
 {
 using namespace std;
index b1488794580d2de05bf4134cb367eb3bb41fb240..940bad3eb905a0c7f618f3dce1bf51f4f9f5ee7b 100644 (file)
@@ -29,10 +29,7 @@ namespace Piglet
 struct Chunk;
 struct Test;
 struct Output;
-}
 
-namespace Piglet
-{
 struct Summary
 {
     unsigned passed = 0;
index caa2a390d2349a7eaca4f0cdff765b38b619ea76..4606f3a80b389b4b62d06ae0cd4c41125c77aa7a 100644 (file)
@@ -28,6 +28,8 @@
 #include "utils/util.h"
 #include "utils/util_cstring.h"
 
+using namespace snort;
+
 /*
  * Create a new PortObjectItem
  */
index ea59de9e4e3b630d37b51abc26f9bdcabd2d7382..cb4d851b2fc05ae252b8a0d2fac663c805c80b0e 100644 (file)
@@ -34,6 +34,8 @@
 #include "port_item.h"
 #include "port_utils.h"
 
+using namespace snort;
+
 //-------------------------------------------------------------------------
 // PortObject - public
 //-------------------------------------------------------------------------
@@ -115,7 +117,7 @@ int PortObjectAddItem(PortObject* po, PortObjectItem* poi, int* errflag)
         p=(PortObjectItem*)sflist_next(&pos) )
     {
         if ((p->lport == poi->lport) && (p->hport == poi->hport))
-            ParseWarning(WARN_RULES, "duplicate ports in list");
+            snort::ParseWarning(WARN_RULES, "duplicate ports in list");
     }
 
     sflist_add_tail(po->item_list, poi);
@@ -551,7 +553,7 @@ void PortObjectPrintPortsRaw(PortObject* po)
 
     SnortSnprintfAppend(buf, bufsize, " ]");
 
-    LogMessage("%s", buf);
+    snort::LogMessage("%s", buf);
 
     snort_free(buf);
 }
@@ -638,7 +640,7 @@ void PortObjectPrintEx(PortObject* po, po_print_f print_index_map)
     }
     SnortSnprintfAppend(po_print_buf, bufsize, "  ]\n }\n");
 
-    LogMessage("%s", po_print_buf);
+    snort::LogMessage("%s", po_print_buf);
     snort_free(rlist);
 }
 
index d83b3795bcac56300b28acde9805f202001d1937..435b1631b5bde382fbf828165d27d6f3e4c9f415 100644 (file)
@@ -34,6 +34,8 @@
 #include "port_object.h"
 #include "port_utils.h"
 
+using namespace snort;
+
 #define PO_EXTRA_RULE_CNT 25
 
 //-------------------------------------------------------------------------
index a83558f77ab2281b6666403981777289d3163ce4..22c946d53ecf297551097dd22fccfe830bcf9a7b 100644 (file)
@@ -30,6 +30,7 @@
 // PortObject2 is similar to PortObject
 //-------------------------------------------------------------------------
 
+
 struct PortObject;
 
 struct PortObject2
@@ -40,7 +41,7 @@ struct PortObject2
     int id;                     /* internal tracking - compiling sets this value */
 
     SF_LIST* item_list;         /* list of port and port-range items */
-    GHash* rule_hash;         /* hash of rule (rule-indexes) in use */
+    snort::GHash* rule_hash;         /* hash of rule (rule-indexes) in use */
 
     PortBitSet* port_list;      /* for collecting ports that use this object */
     struct PortGroup* group;    /* PortGroup based on rule_hash  */
index 39a919de65ac5c33fd4e61bd2edce267605fef06..27a3e9d073235b1a9eba0439e1c57b944f4c147a 100644 (file)
@@ -33,6 +33,8 @@
 
 #include "port_utils.h"
 
+using namespace snort;
+
 #define PTBL_LRC_DEFAULT 10
 #define PO_INIT_ID 1000000
 #define PO_HASH_TBL_ROWS 10000
index 89600ae4d73f97bc0fe7da8916cef60171ea743f..24f02a6ba582d0c4f091d32657c6218d9589024e 100644 (file)
@@ -49,8 +49,8 @@ struct PortTable
     int pt_poid;
 
     /* Compiled / merged port object hash table */
-    GHash* pt_mpo_hash;
-    GHash* pt_mpxo_hash;
+    snort::GHash* pt_mpo_hash;
+    snort::GHash* pt_mpxo_hash;
 
     /*
     * Final Port/Rule Groupings, one port object per port, or null
index d606f218fc2fc1e6349f378d7b5d52126b9d0b1f..77a14cccddc706754b764aaf31d4f0b18d484d90 100644 (file)
@@ -28,6 +28,8 @@
 #include "port_item.h"
 #include "port_object.h"
 
+using namespace snort;
+
 //-------------------------------------------------------------------------
 // bitset conversions
 //-------------------------------------------------------------------------
index f123b056320f2be1c8c13bbdd58911e90e21256d..807e244dd31e4cfdd68ebba03274bc6deda82617 100644 (file)
@@ -23,6 +23,8 @@
 
 #include "port_var_table.h"
 
+using namespace snort;
+
 //-------------------------------------------------------------------------
 // PortVarTable
 //-------------------------------------------------------------------------
index d5b7f3a43e18d3b1ea9c6573af3b9381b32559f1..46331d9013f49bd85e9990f15ef750922187a5cb 100644 (file)
@@ -32,7 +32,7 @@
 // PortVars are internally stored in PortObjects
 //-------------------------------------------------------------------------
 
-typedef GHash PortVarTable;
+typedef snort::GHash PortVarTable;
 
 PortVarTable* PortVarTableCreate();
 int PortVarTableFree(PortVarTable* pvt);
index fed8034ff3d5c46744b04d89631328c1c3376eea..a7bc90fbfe645982de2d49062718d1cf16e963ac 100644 (file)
@@ -39,7 +39,7 @@ PortProto::PortProto()
     nfp = PortObjectNew();
 
     if ( !src or !dst or !any or !nfp )
-        ParseAbort("can't allocate port structs");
+        snort::ParseAbort("can't allocate port structs");
 
    // someday these could be read from snort.conf, something like...
    // 'config portlist: large-rule-count <val>'
@@ -70,7 +70,7 @@ RulePortTables* PortTablesNew()
     RulePortTables* rpt = new RulePortTables;
 
     if ( !(rpt->svc_any = PortObjectNew()) )
-        ParseAbort("ParseRulesFile udp any-any PortObjectNew() failed");
+        snort::ParseAbort("ParseRulesFile udp any-any PortObjectNew() failed");
 
     PortObjectAddPortAny(rpt->svc_any);
 
index 34c7f285429af19e8079e1c7e0e63468f3940694..8e225356af652b6ac0e3be3f48e0c5ba1b506728 100644 (file)
@@ -113,7 +113,7 @@ struct CombinedMemoryStats
 
 inline void CombinedMemoryStats::update_allocs(size_t n)
 {
-    if ( is_packet_thread() )
+    if ( snort::is_packet_thread() )
         runtime.update_allocs(n);
     else
         startup.update_allocs(n);
@@ -121,7 +121,7 @@ inline void CombinedMemoryStats::update_allocs(size_t n)
 
 inline void CombinedMemoryStats::update_deallocs(size_t n)
 {
-    if ( is_packet_thread() )
+    if ( snort::is_packet_thread() )
         runtime.update_deallocs(n);
     else
         startup.update_deallocs(n);
index e8bbf3befed80141ac72fe5a359f173655708cd6..b888e8492678d3cf449f86c1bdd536fe37dcf2dd 100644 (file)
@@ -91,7 +91,7 @@ public:
             table << StatsTable::HEADER;
         }
 
-        LogMessage("%s", ss.str().c_str());
+        snort::LogMessage("%s", ss.str().c_str());
 
         print_recursive(root, root, 1, count, max_depth);
         print_row(root, root, 0, 0);
@@ -159,7 +159,7 @@ public:
                 table << cur.view.pct_caller() << cur.view.pct_of(root.view.get_stats());
         }
 
-        LogMessage("%s", ss.str().c_str());
+        snort::LogMessage("%s", ss.str().c_str());
     }
 
 private:
index d51da3b6823a21b04f5aa45fd43a1f2d27a26693..fbb506d44212e1164a9ccf25b7c2ca43415558ad 100644 (file)
@@ -40,6 +40,8 @@ struct TimeProfilerConfig
     int max_depth = -1;
 };
 
+namespace snort
+{
 struct SO_PUBLIC TimeProfilerStats
 {
     hr_duration elapsed;
@@ -138,4 +140,5 @@ private:
     TimeContext ctx;
 };
 
+} // namespace snort
 #endif
index b57199195dc7cf0a7eac095ed266b73dd968af6f..4f5769db916d6db92cb0e712ccdcc89dc1cceccc 100644 (file)
 #include "main/snort_types.h"
 #include "target_based/snort_protocols.h"
 
-class Endianness;
-class Obfuscator;
 
 namespace snort
 {
+class Endianness;
 class Flow;
 class IpsContext;
+class Obfuscator;
 
 /* packet status flags */
 #define PKT_REBUILT_FRAG     0x00000001  /* is a rebuilt fragment */
index bd1904a1eec1df18f5d1e92afc12ffe9df7d5b1c..e62616edfda19b63e629474069a41dd61db13310 100644 (file)
 #define SSL2_CHELLO_BYTE 0x01
 #define SSL2_SHELLO_BYTE 0x04
 
-/* very simplistic - just enough to say this is binary data - the rules will make a final
-* judgement.  Should maybe add an option to the imap configuration to enable the
-* continuing of command inspection like ftptelnet. */
-bool IsTlsClientHello(const uint8_t* ptr, const uint8_t* end)
-{
-    /* at least 3 bytes of data - see below */
-    if ((end - ptr) < 3)
-        return false;
-
-    if ((ptr[0] == SSL3_FIRST_BYTE) && (ptr[1] == SSL3_SECOND_BYTE))
-    {
-        /* TLS v1 or SSLv3 */
-        return true;
-    }
-    else if ((ptr[2] == SSL2_CHELLO_BYTE) || (ptr[3] == SSL2_CHELLO_BYTE))
-    {
-        /* SSLv2 */
-        return true;
-    }
-
-    return false;
-}
-
-/* this may at least tell us whether the server accepted the client hello by the presence
- * of binary data */
-
-bool IsTlsServerHello(const uint8_t* ptr, const uint8_t* end)
-{
-    /* at least 3 bytes of data - see below */
-    if ((end - ptr) < 3)
-        return false;
-
-    if ((ptr[0] == SSL3_FIRST_BYTE) && (ptr[1] == SSL3_SECOND_BYTE))
-    {
-        /* TLS v1 or SSLv3 */
-        return true;
-    }
-    else if (ptr[2] == SSL2_SHELLO_BYTE)
-    {
-        /* SSLv2 */
-        return true;
-    }
-
-    return false;
-}
-
-bool IsSSL(const uint8_t* ptr, int len, int pkt_flags)
-{
-    uint32_t ssl_flags = SSL_decode(ptr, len, pkt_flags, 0, nullptr, nullptr, 0);
-
-    if ((ssl_flags != SSL_ARG_ERROR_FLAG) &&
-        !(ssl_flags & SSL_ERROR_FLAGS))
-    {
-        return true;
-    }
-
-    return false;
-}
-
 static uint32_t SSL_decode_version_v3(uint8_t major, uint8_t minor)
 {
     /* Should only be called internally and by functions which have previously
@@ -480,6 +421,8 @@ static uint32_t SSL_decode_v2(const uint8_t* pkt, int size, uint32_t pkt_flags)
     return retval | SSL_VER_SSLV2_FLAG;
 }
 
+namespace snort
+{
 uint32_t SSL_decode(
     const uint8_t* pkt, int size, uint32_t pkt_flags, uint32_t prev_flags,
     uint8_t* alert_flags, uint16_t* partial_rec_len, int max_hb_len)
@@ -553,3 +496,63 @@ uint32_t SSL_decode(
     return SSL_decode_v3(pkt, size, pkt_flags, alert_flags, partial_rec_len, max_hb_len);
 }
 
+/* very simplistic - just enough to say this is binary data - the rules will make a final
+* judgement.  Should maybe add an option to the imap configuration to enable the
+* continuing of command inspection like ftptelnet. */
+bool IsTlsClientHello(const uint8_t* ptr, const uint8_t* end)
+{
+    /* at least 3 bytes of data - see below */
+    if ((end - ptr) < 3)
+        return false;
+
+    if ((ptr[0] == SSL3_FIRST_BYTE) && (ptr[1] == SSL3_SECOND_BYTE))
+    {
+        /* TLS v1 or SSLv3 */
+        return true;
+    }
+    else if ((ptr[2] == SSL2_CHELLO_BYTE) || (ptr[3] == SSL2_CHELLO_BYTE))
+    {
+        /* SSLv2 */
+        return true;
+    }
+
+    return false;
+}
+
+/* this may at least tell us whether the server accepted the client hello by the presence
+ * of binary data */
+
+bool IsTlsServerHello(const uint8_t* ptr, const uint8_t* end)
+{
+    /* at least 3 bytes of data - see below */
+    if ((end - ptr) < 3)
+        return false;
+
+    if ((ptr[0] == SSL3_FIRST_BYTE) && (ptr[1] == SSL3_SECOND_BYTE))
+    {
+        /* TLS v1 or SSLv3 */
+        return true;
+    }
+    else if (ptr[2] == SSL2_SHELLO_BYTE)
+    {
+        /* SSLv2 */
+        return true;
+    }
+
+    return false;
+}
+
+bool IsSSL(const uint8_t* ptr, int len, int pkt_flags)
+{
+    uint32_t ssl_flags = SSL_decode(ptr, len, pkt_flags, 0, nullptr, nullptr, 0);
+
+    if ((ssl_flags != SSL_ARG_ERROR_FLAG) &&
+        !(ssl_flags & SSL_ERROR_FLAGS))
+    {
+        return true;
+    }
+
+    return false;
+}
+
+} // namespace snort
index 5bb29c3c10a16fbf9a799ff743aceb1cb18e4d30..7df10a20ac63682a8ac0d518965582cd9ff259b9 100644 (file)
@@ -213,6 +213,8 @@ struct SSLv2_shello_t
 #define SSL_HEARTBLEED_RESPONSE 0x02
 #define SSL_HEARTBLEED_UNKNOWN  0x04
 
+namespace snort
+{
 SO_PUBLIC uint32_t SSL_decode(
     const uint8_t* pkt, int size, uint32_t pktflags, uint32_t prevflags,
     uint8_t* alert_flags, uint16_t* partial_rec_len, int hblen);
@@ -220,6 +222,6 @@ SO_PUBLIC uint32_t SSL_decode(
 SO_PUBLIC bool IsTlsClientHello(const uint8_t* ptr, const uint8_t* end);
 SO_PUBLIC bool IsTlsServerHello(const uint8_t* ptr, const uint8_t* end);
 SO_PUBLIC bool IsSSL(const uint8_t* ptr, int len, int pkt_flags);
-
+}
 #endif
 
index 4c6daefa62387979f39c0ae53f60369c7e988147..63e894ad391a25e81f2816a3f4f8d3a568a865b5 100644 (file)
@@ -29,6 +29,8 @@
 #include "service_inspectors/http_inspect/http_msg_header.h"
 #include "service_inspectors/http_inspect/http_msg_request.h"
 
+using namespace snort;
+
 const uint8_t* HttpEvent::get_header(unsigned id, uint64_t sub_id, int32_t& length)
 {
     const Field& field = http_msg_header->get_classic_buffer(id, sub_id, 0);
index e6327c1a3c2c72c88ff5f0369af4f6d21867d973..bc5ff1a1bce5832af77c81ac23b7366e81d60fac 100644 (file)
@@ -31,6 +31,8 @@
 
 class HttpMsgHeader;
 
+namespace snort
+{
 class SO_PUBLIC HttpEvent : public snort::DataEvent
 {
 public:
@@ -59,6 +61,6 @@ private:
     const uint8_t* get_header(unsigned, uint64_t, int32_t&);
 
 };
-
+}
 #endif
 
index 84d42e12b39fe9da55afe4ae5dd15db01928d101..3f29fc5540afe557b2dadb66163781573d17352d 100644 (file)
 #include "utils/stats.h"
 #include "utils/util.h"
 
+using namespace snort;
+
 #define printf LogMessage
 
-#define MEMASSERT(p,s) if (!(p)) { FatalError("ACSM-No Memory: %s\n",s); }
+#define MEMASSERT(p,s) if (!(p)) { snort::FatalError("ACSM-No Memory: %s\n",s); }
 
 static int acsm2_total_memory = 0;
 static int acsm2_pattern_memory = 0;
index c31c01e202af5290890960091c767d6eec2f11a4..193cab2d158241d1a5b1a9917c395fcb040ed5b6 100644 (file)
 #include "utils/stats.h"
 #include "utils/util.h"
 
+using namespace snort;
+
 /*
  * Used to initialize last state, states are limited to 0-16M
  * so this will not conflict.
index 84209bc0ee92b90839d4ac2dff102ded86eeeeb0..0d8fcc9b5546f373d79e5ef73a8af2a8dd79d384 100644 (file)
@@ -37,7 +37,9 @@ struct PatMatQStat
     PegCount matched_bytes;
 };
 
+namespace snort
+{
 SO_PUBLIC extern THREAD_LOCAL PatMatQStat pmqs;
-
+}
 #endif
 
index b32c503eebf4a75988d7db34b55fd4b7c5922857..c2cb7e2a45d7c1924c8a3812e6d9594666e32106 100644 (file)
@@ -83,6 +83,16 @@ int SnortConfig::request_scratch(ScScratchFunc setup, ScScratchFunc cleanup)
 SnortConfig* SnortConfig::get_conf()
 { return snort_conf; }
 
+static unsigned parse_errors = 0;
+void ParseError(const char*, ...)
+{ parse_errors++; }
+
+void LogCount(char const*, uint64_t, FILE*)
+{ }
+
+unsigned get_instance_id()
+{ return 0; }
+
 }
 //-------------------------------------------------------------------------
 // stubs, spies, etc.
@@ -91,22 +101,11 @@ SnortConfig* SnortConfig::get_conf()
 extern const BaseApi* se_hyperscan;
 
 static unsigned hits = 0;
-static unsigned parse_errors = 0;
-
-void ParseError(const char*, ...)
-{ parse_errors++; }
-
-void LogCount(char const*, uint64_t, FILE*)
-{ }
 
 static int match(
     void* /*user*/, void* /*tree*/, int /*index*/, void* /*context*/, void* /*list*/)
 { ++hits; return 0; }
 
-
-unsigned get_instance_id()
-{ return 0; }
-
 static void* s_user = (void*)"user";
 static void* s_tree = (void*)"tree";
 static void* s_list = (void*)"list";
index 0bf7084b38f91203a66df83b92d2074ab841cbc8..c886ca74bbc3fbd0a47e0257a84dfeff619a3b90 100644 (file)
@@ -64,34 +64,18 @@ SnortConfig::~SnortConfig() = default;
 SnortConfig* SnortConfig::get_conf()
 { return snort_conf; }
 
-}
 unsigned get_instance_id()
 { return 0; }
 
-void LogValue(const char*, const char*, FILE*)
-{
-}
-
-SO_PUBLIC void LogMessage(const char*, ...)
-{
-}
-
-[[noreturn]] void FatalError(const char*,...)
-{
-    exit(1);
-}
-
-void LogCount(char const*, uint64_t, FILE*)
-{ }
-
-void LogStat(const char*, double, FILE*)
-{}
+void LogValue(const char*, const char*, FILE*) { }
+SO_PUBLIC void LogMessage(const char*, ...) { }
+[[noreturn]] void FatalError(const char*,...) { exit(1); }
+void LogCount(char const*, uint64_t, FILE*) { }
+void LogStat(const char*, double, FILE*) { }
 
 static void* s_tree = (void*)"tree";
 static void* s_list = (void*)"list";
 
-namespace snort
-{
 static MpseAgent s_agent =
 {
     [](struct SnortConfig* sc, void*, void** ppt)
index 7bfbb83a83823e2a408883e1ade43aca8e3b42a4..c374a168f737858c9d1868a8fd711f8051613ebb 100644 (file)
@@ -198,7 +198,7 @@ public:
 };
 
 const PegInfo* BoModule::get_pegs() const
-{ return simple_pegs; }
+{ return snort::simple_pegs; }
 
 PegCount* BoModule::get_counts() const
 { return (PegCount*)&bostats; }
index 616ce004adf00eeb4ddc127efde3f192eea7ad83..8cb5454e5bb9fd7425ea76eea888ffce4eed9dc5 100644 (file)
@@ -210,7 +210,7 @@ struct DCE2_SsnData
     uint32_t srv_nseq;
 };
 
-class DceEndianness : public Endianness
+class DceEndianness : public snort::Endianness
 {
 public:
     int hdr_byte_order;   /* Set to sentinel if not applicable */
index bd332c4c3dc115b54d786a639a7467a9146ea215..cd8ae025bd19a3eeb0c436d7c3288a2a84d25774 100644 (file)
@@ -384,9 +384,7 @@ void Dce2Smb::eval(snort::Packet* p)
     assert(p->flow);
 
     if (p->flow->get_session_flags() & SSNFLAG_MIDSTREAM)
-    {
         return;
-    }
 
     dce2_smb_sess = dce2_handle_smb_session(p, &config);
 
@@ -395,7 +393,7 @@ void Dce2Smb::eval(snort::Packet* p)
         p->packet_flags |= PKT_ALLOW_MULTIPLE_DETECT;
         dce2_detected = 0;
 
-        p->endianness = (Endianness*)new DceEndianness();
+        p->endianness = (snort::Endianness*)new DceEndianness();
 
         DCE2_SmbProcess(dce2_smb_sess);
 
index 46eb12410058c18d6c20709e15070c8808313234..c6ea3f37901c1f942807f706fd4e16ce4daecde7 100644 (file)
@@ -32,6 +32,8 @@
 #include "dce_smb_module.h"
 #include "dce_smb_transaction_utils.h"
 
+using namespace snort;
+
 #define SMB_DIALECT_NT_LM_012       "NT LM 0.12"  // NT LAN Manager
 
 #define SERVICE_0     (0)                // IPC start
index 5edafdc5a66e11c2c07a83d3dbdfcc19da84bc80..68f13997d30714757faccaf1e46554509e8a3139 100644 (file)
@@ -30,6 +30,8 @@
 #include "dce_smb_module.h"
 #include "dce_smb_transaction_utils.h"
 
+using namespace snort;
+
 #define DCE2_SMB_TRANS__NONE    0x00
 #define DCE2_SMB_TRANS__DATA    0x01
 #define DCE2_SMB_TRANS__PARAMS  0x02
index 709b6b0bfaf74708428a1bf72e8867a18658b48d..eb30e5fd0cf17dd5043d25ecc010853f00dcec5f 100644 (file)
@@ -125,7 +125,7 @@ static int CheckFTPCmdOptions(FTP_SERVER_PROTO_CONF* serverConf)
 
         if ( cmdConf->check_validity && !len )
         {
-            ErrorMessage("FTPConfigCheck() configuration for server, "
+            snort::ErrorMessage("FTPConfigCheck() configuration for server, "
                 "command '%s' has max length of 0 and parameters to validate\n",
                 cmdConf->cmd_name);
             config_error = 1;
@@ -150,7 +150,7 @@ int CheckFTPServerConfigs(snort::SnortConfig*, FTP_SERVER_PROTO_CONF* serverConf
 {
     if (CheckFTPCmdOptions(serverConf))
     {
-        ErrorMessage("FTPConfigCheck(): invalid configuration for FTP commands\n");
+        snort::ErrorMessage("FTPConfigCheck(): invalid configuration for FTP commands\n");
         return -1;
     }
     return 0;
@@ -163,7 +163,7 @@ int FTPCheckConfigs(snort::SnortConfig* sc, void* pData)
 
     if ( !config )
     {
-        ErrorMessage("FTP configuration requires "
+        snort::ErrorMessage("FTP configuration requires "
             "default client and default server configurations.\n");
         return -1;
     }
@@ -175,13 +175,13 @@ int FTPCheckConfigs(snort::SnortConfig* sc, void* pData)
     //  Verify that FTP client and FTP data inspectors are initialized.
     if(!snort::InspectorManager::get_inspector(FTP_CLIENT_NAME, false))
     {
-        ParseError("ftp_server requires that %s also be configured.", FTP_CLIENT_NAME);
+        snort::ParseError("ftp_server requires that %s also be configured.", FTP_CLIENT_NAME);
         return -1;
     }
 
     if(!snort::InspectorManager::get_inspector(FTP_DATA_NAME, false))
     {
-        ParseError("ftp_server requires that %s also be configured.", FTP_DATA_NAME);
+        snort::ParseError("ftp_server requires that %s also be configured.", FTP_DATA_NAME);
         return -1;
     }
 
index f1212aefcc79b015ae459e97050fb717c885db6b..b4658802e53120a3823e8031f6aa9975ef97cf7b 100644 (file)
@@ -44,6 +44,8 @@
 #include "ft_main.h"
 #include "ftpp_return_codes.h"
 
+using namespace snort;
+
 /*
  * Function: ftp_bounce_lookup_init(BOUNCE_LOOKUP **BounceLookup)
  *
index 8589a59f7b35d3b0bf17780c413027ed71c51047..4d05bf28bc5718610b2d2fef4ccb96be84ba5fe7 100644 (file)
@@ -43,6 +43,8 @@
 #include "ft_main.h"
 #include "ftpp_return_codes.h"
 
+using namespace snort;
+
 /*
  * Function: ftp_cmd_lookup_init(CMD_LOOKUP **CmdLookup)
  *
index a631f38ba4b72435ae887493b2ae28e2de89426a..b8aeeb744cccf84763dbe1e351fd46501aa888f3 100644 (file)
@@ -251,7 +251,7 @@ public:
 };
 
 const PegInfo* FtpDataModule::get_pegs() const
-{ return simple_pegs; }
+{ return snort::simple_pegs; }
 
 PegCount* FtpDataModule::get_counts() const
 { return (PegCount*)&fdstats; }
index 83d7e50e2a8af87efea4bf574c917a99c597ad64..94c8bac89eed51be5b0fd554a983187a2a18fe55 100644 (file)
@@ -413,7 +413,7 @@ static int DoNextFormat(FTP_PARAM_FMT* ThisFmt, int allocated,
             {
                 /* explicit check that we have enough room for copy */
                 if (numChoices <= ThisFmt->numChoices)
-                    ParseError("Can't do memcpy - index out of range ");
+                    snort::ParseError("Can't do memcpy - index out of range ");
 
                 memcpy(tmpChoices, ThisFmt->choices,
                     sizeof(FTP_PARAM_FMT*) * ThisFmt->numChoices);
@@ -646,7 +646,7 @@ int ProcessFTPAllowBounce(
 
     if (iRet)
     {
-        ParseError("Failed to add configuration for Bounce object '%s'.", ALLOW_BOUNCE);
+        snort::ParseError("Failed to add configuration for Bounce object '%s'.", ALLOW_BOUNCE);
         snort_free(newBounce);
         return FTPP_FATAL_ERR;
     }
index 4d2fd71c3e61f6bb7b3f3e112019dc771e4ac954..02af001ed482af70ab3d367993e96330cd7c0117 100644 (file)
@@ -40,6 +40,8 @@
 #include "ftp_parse.h"
 #include "ftpp_return_codes.h"
 
+using namespace snort;
+
 int PrintConfOpt(bool on, const char* Option)
 {
     LogMessage("    %s: %s\n", Option, on ? "ON" : "OFF");
index f1476a4f49070f12e16cb0f61de5b84669d3d207..f0c87812132df50dd12e718dceee9c2afb1b1366 100644 (file)
@@ -37,6 +37,8 @@
 #include "gtp_inspect.h"
 #include "gtp_module.h"
 
+using namespace snort;
+
 #pragma pack(1)
 static inline void alert(int sid)
 {
index ae0a9de14d405a01fc38fe14372ab3ecd30d5497..4d9601f4f358eb4e05e93a9f4bab3081038a0c26 100644 (file)
@@ -44,7 +44,7 @@ public:
     bool get_fp_buf(snort::InspectionBuffer::Type ibt, snort::Packet* p,
         snort::InspectionBuffer& b) override;
     bool configure(snort::SnortConfig*) override;
-    void show(snort::SnortConfig*) override { LogMessage("Http2Inspect\n"); }
+    void show(snort::SnortConfig*) override { snort::LogMessage("Http2Inspect\n"); }
     void eval(snort::Packet* p) override;
     void clear(snort::Packet* p) override;
     void tinit() override { }
index 168813683fac40b69e52947d952ccc7d65b15dcf..7005538e863ed47399f71c3512a81d526225f4fc 100644 (file)
@@ -52,7 +52,7 @@ public:
 
     void generate_misformatted_http(const uint8_t* buffer, uint32_t length)
     {
-        if ( SnortStrnStr((const char*)buffer, length, "HTTP/") != nullptr )
+        if ( snort::SnortStrnStr((const char*)buffer, length, "HTTP/") != nullptr )
             create_event(HttpEnums::EVENT_MISFORMATTED_HTTP);
         else
             create_event(HttpEnums::EVENT_LOSS_OF_SYNC);
index 6da55d977068bfa18c216f1dd0effc2242c5a668..00e2160401c05909318bec2b74917385b425142d 100644 (file)
@@ -29,6 +29,7 @@
 #include "http_test_manager.h"
 #include "http_transaction.h"
 
+using namespace snort;
 using namespace HttpEnums;
 
 unsigned HttpFlowData::inspector_id = 0;
index dde8cbc3b76cf38cf91791c67b0d56acccc213f9..19f8a272300afa4e945d780731679596705ce902 100644 (file)
@@ -131,7 +131,7 @@ private:
     int64_t detect_depth_remaining[2] = { HttpEnums::STAT_NOT_PRESENT,
         HttpEnums::STAT_NOT_PRESENT };
     snort::MimeSession* mime_state[2] = { nullptr, nullptr };
-    UtfDecodeSession* utf_state = nullptr; // SRC_SERVER only
+    snort::UtfDecodeSession* utf_state = nullptr; // SRC_SERVER only
     fd_session_t* fd_state = nullptr; // SRC_SERVER only
     struct FdCallbackContext
     {
index 69250ba52c4748d508211710a8e62959f559953c..7c1204f91322cda2f0e622da2eeaa11700cc7db3 100644 (file)
@@ -46,7 +46,7 @@ public:
         snort::InspectionBuffer& b);
     bool get_fp_buf(snort::InspectionBuffer::Type ibt, snort::Packet* p, snort::InspectionBuffer& b) override;
     bool configure(snort::SnortConfig*) override;
-    void show(snort::SnortConfig*) override { LogMessage("HttpInspect\n"); }
+    void show(snort::SnortConfig*) override { snort::LogMessage("HttpInspect\n"); }
     void eval(snort::Packet* p) override;
     void clear(snort::Packet* p) override;
     void tinit() override { }
index 787d8bfe31d4a6dbe0a9bec92c3869fe6c7de7ec..7ed3d54418199d1fe490b55a6941a6c3e2f7c5ea 100644 (file)
@@ -27,6 +27,7 @@
 #include "utils/safec.h"
 
 using namespace HttpEnums;
+using namespace snort;
 
 HttpJsNorm::HttpJsNorm(int max_javascript_whitespaces_, const HttpParaList::UriParam& uri_param_) :
     max_javascript_whitespaces(max_javascript_whitespaces_), uri_param(uri_param_),
index 9d3b3c7d638e67e22dc76220d2ecb949cfbb1134..a654c4d6fa5a4e4e568c76b558e1134472ac50d6 100644 (file)
@@ -29,6 +29,7 @@
 #include "http_js_norm.h"
 #include "http_msg_request.h"
 
+using namespace snort;
 using namespace HttpEnums;
 
 HttpMsgBody::HttpMsgBody(const uint8_t* buffer, const uint16_t buf_size,
index 7265e1cafefaba2702906c5f0bb99aca44243885..28daf2a5c3bbded7292e6d71ee6e3c81d566acec 100644 (file)
@@ -47,7 +47,7 @@ public:
 private:
     // Dummy configurations to support MIME processing
     MailLogConfig mime_conf;
-    DecodeConfig decode_conf;
+    snort::DecodeConfig decode_conf;
 
     void prepare_body();
     void setup_file_processing();
index 6bc2e91f9ced249b3c1922ae5da579361e854759..c56b0c1aae7f445984b06e3fd7daa55941ed25d8 100644 (file)
@@ -317,7 +317,7 @@ size_t HttpUri::get_file_proc_hash()
 
     if (abs_path.length() > 0 )
     {
-        abs_path_hash = str_to_hash(abs_path.start(), abs_path.length());
+        abs_path_hash = snort::str_to_hash(abs_path.start(), abs_path.length());
     }
 
     return abs_path_hash;
index d3f72baf3514b63ab7b5d4427377d24d9dee5053..068169fdb493c74dfa24e8d2df7bed6a32ddb91f 100644 (file)
@@ -633,21 +633,21 @@ void UriNormalizer::load_unicode_map(uint8_t map[65536], const char* filename, i
     FILE* file = fopen(filename, "r");
     if (file == nullptr)
     {
-        ParseError("Cannot open unicode map file %s", filename);
+        snort::ParseError("Cannot open unicode map file %s", filename);
         return;
     }
 
     // Advance file to the desired code page
     if (!advance_to_code_page(file, code_page))
     {
-        ParseError("Did not find code page %d in unicode map file %s", code_page, filename);
+        snort::ParseError("Did not find code page %d in unicode map file %s", code_page, filename);
         fclose(file);
         return;
     }
 
     if (!map_code_points(file, map))
     {
-        ParseError("Error while reading code page %d in unicode map file %s", code_page, filename);
+        snort::ParseError("Error while reading code page %d in unicode map file %s", code_page, filename);
         fclose(file);
         return;
     }
index 3a76f46329eefc17f2d2c132e5caddedf8b3c279..b4e8c96d11ecec671ba1e6abd226e3571216fca5 100644 (file)
 using namespace snort;
 using namespace HttpEnums;
 
+namespace snort
+{
 // Stubs whose sole purpose is to make the test code link
 void ParseWarning(WarningGroup, const char*, ...) {}
 void ParseError(const char*, ...) {}
 
+void Value::get_bits(std::bitset<256ul>&) const {}
+int DetectionEngine::queue_event(unsigned int, unsigned int, Actions::Type) { return 0; }
+}
+
 void show_stats(PegCount*, const PegInfo*, unsigned, const char*) { }
 void show_stats(PegCount*, const PegInfo*, IndexVec&, const char*, FILE*) { }
 void show_stats(SimpleStats*, const char*) { }
 
-void Value::get_bits(std::bitset<256ul>&) const {}
-int DetectionEngine::queue_event(unsigned int, unsigned int, Actions::Type) { return 0; }
-
 int32_t str_to_code(const uint8_t*, const int32_t, const StrCode []) { return 0; }
 int32_t substr_to_code(const uint8_t*, const int32_t, const StrCode []) { return 0; }
 long HttpTestManager::print_amount {};
index 1a37de231e49d49004c923713f8100edbdcff315..fd0942324ec54a5f527e6808380e7f75627e7943 100644 (file)
 using namespace snort;
 using namespace HttpEnums;
 
+namespace snort
+{
 // Stubs whose sole purpose is to make the test code link
 unsigned FlowData::flow_data_id = 0;
 FlowData::FlowData(unsigned, Inspector*) {}
 FlowData::~FlowData() = default;
 int DetectionEngine::queue_event(unsigned int, unsigned int, Actions::Type) { return 0; }
-THREAD_LOCAL PegCount HttpModule::peg_counts[1];
 fd_status_t File_Decomp_StopFree(fd_session_t*) { return File_Decomp_OK; }
+}
+
+THREAD_LOCAL PegCount HttpModule::peg_counts[1];
 
 class HttpUnitTestSetup
 {
index ed00b1d1ee1c283e76ef5bf2053d18a42835cc73..472ffab1992de2c10328062223a4d51e38533de0 100644 (file)
 
 using namespace snort;
 
+namespace snort
+{
 // Stubs whose sole purpose is to make the test code link
 void ParseWarning(WarningGroup, const char*, ...) {}
 void ParseError(const char*, ...) {}
+void Value::get_bits(std::bitset<256ul>&) const {}
+int DetectionEngine::queue_event(unsigned int, unsigned int, Actions::Type) { return 0; }
+}
 
 void show_stats(PegCount*, const PegInfo*, unsigned, const char*) { }
 void show_stats( PegCount*, const PegInfo*, IndexVec&, const char*, FILE*) { }
 void show_stats(SimpleStats*, const char*) { }
 
-void Value::get_bits(std::bitset<256ul>&) const {}
-int DetectionEngine::queue_event(unsigned int, unsigned int, Actions::Type) { return 0; }
-
 HttpJsNorm::HttpJsNorm(int, const HttpParaList::UriParam& uri_param_) :
     max_javascript_whitespaces(0), uri_param(uri_param_), javascript_search_mpse(nullptr),
     htmltype_search_mpse(nullptr) {}
index 0a00fecb80262a85eef2f3d2c34fdd194b84d300..1f5d1e08e008a3d30c9d7a83a8d64efcb5b63995 100644 (file)
@@ -25,7 +25,7 @@
 
 struct IMAP_PROTO_CONF
 {
-    DecodeConfig decode_conf;
+    snort::DecodeConfig decode_conf;
     MailLogConfig log_config;
 };
 
index 042c00e3608f52ea2fa9d5005ea0644a4c8f2bb6..133c9a705028af6c0e6c7750abdc4944cabd7bed 100644 (file)
@@ -25,7 +25,7 @@
 
 struct POP_PROTO_CONF
 {
-    DecodeConfig decode_conf;
+    snort::DecodeConfig decode_conf;
     MailLogConfig log_config;
 };
 
index 9d536c2b08d45b5d720b6b37af126fcab54ceab2..bffaae5e86b2e83cb2e9f211e86e8fae835b9370 100644 (file)
@@ -29,6 +29,8 @@
 #include "main/snort_debug.h"
 #include "utils/util.h"
 
+using namespace snort;
+
 #define SIP_SEPERATORS       "()<>@,;:\\/[]?={}\" "
 
 static SIPMethodNode* SIP_AddMethodToList(
index 25a33ab9067376821ed5ac317c5832e1f57fdf31..b579553a2f3fcf40dbe8f61d35b86fb95630bc87 100644 (file)
@@ -130,7 +130,7 @@ struct SMTP_PROTO_CONF
     int max_response_line_len = 0;
     int xlink2state;
     MailLogConfig log_config;
-    DecodeConfig decode_conf;
+    snort::DecodeConfig decode_conf;
 
     uint32_t xtra_filename_id;
     uint32_t xtra_mfrom_id;
index d7a370adc649d7da90895fc9fb17e6c861e368c0..00f0bad2ad3bbb8175406f27a2c5839f5a39db58 100644 (file)
@@ -471,6 +471,6 @@ inline std::ostream& operator<<(std::ostream& os, const SfIp* addr)
 
 // FIXIT-L X This should be in utils_net if anywhere, but that makes it way harder to link into unit tests
 SO_PUBLIC const char* snort_inet_ntop(int family, const void* ip_raw, char* buf, int bufsize);
-}
+} // namespace snort
 #endif
 
index a942997fa1c2e2c63a06fdae938b30490ec9dc09..e156f125d923dda4c30273893bf37c16aa87b436 100644 (file)
@@ -39,6 +39,8 @@
 #include "catch/snort_catch.h"
 #endif
 
+using namespace snort;
+
 vartable_t* sfvt_alloc_table()
 {
     vartable_t* table = (vartable_t*)snort_calloc(sizeof(vartable_t));
@@ -193,7 +195,7 @@ SfIpRet sfvt_define(vartable_t* table, const char* name, const char* value)
 
     len = strlen(name) + strlen(value) + 2;
     buf = (char*)snort_alloc(len);
-    SnortSnprintf(buf, len, "%s %s", name, value);
+    snort::SnortSnprintf(buf, len, "%s %s", name, value);
 
     ret = sfvt_add_str(table, buf, &ipret);
     if ((ret == SFIP_SUCCESS) || (ret == SFIP_DUPLICATE))
index a57927286ab60cfc419e9dfbdb51e0ef45b56612..73267516f8cb175b8fe63679a75a4fde97c4edb2 100644 (file)
@@ -49,7 +49,7 @@ public:
     { return (PegCount*)&sc_stats; }
 
     const PegInfo* get_pegs() const override
-    { return simple_pegs; }
+    { return snort::simple_pegs; }
 
     snort::ProfileStats* get_profile() const override;
 
index 3984cf9e429661a23cb967e4c2ff861dc00d1e7f..02fef73653a0b7c2d10029d01cea19a44305803b 100644 (file)
@@ -60,10 +60,13 @@ void show_stats(PegCount*, const PegInfo*, unsigned, const char*) { }
 void show_stats(PegCount*, const PegInfo*, IndexVec&, const char*) { }
 void show_stats(PegCount*, const PegInfo*, IndexVec&, const char*, FILE*) { }
 
+namespace snort
+{
 void ParseWarning(WarningGroup, const char*, ...) { }
 
 char* snort_strdup(const char* s)
 { return strdup(s); }
+}
 
 TEST_GROUP(side_channel_module)
 { };
index 71902e9e42ec54071d4202641e15d1a316babbc5..0918acb3a2e5ffd26abf06e86a985f26d06067d9 100644 (file)
@@ -488,12 +488,12 @@ int SegmentOverlapEditor::full_right_overlap_os5(TcpReassemblerState& trs)
 
 void SegmentOverlapEditor::print(TcpReassemblerState& trs)
 {
-    LogMessage("    seglist_base_seq:   %X\n", trs.sos.seglist_base_seq);
-    LogMessage("    seglist head:       %p\n", (void*)trs.sos.seglist.head);
-    LogMessage("    seglist tail:       %p\n", (void*)trs.sos.seglist.tail);
-    LogMessage("    seglist next:       %p\n", (void*)trs.sos.seglist.next);
-    LogMessage("    seg_count:          %d\n", trs.sos.seg_count);
-    LogMessage("    seg_bytes_total:    %d\n", trs.sos.seg_bytes_total);
-    LogMessage("    seg_bytes_logical:  %d\n", trs.sos.seg_bytes_logical);
+    snort::LogMessage("    seglist_base_seq:   %X\n", trs.sos.seglist_base_seq);
+    snort::LogMessage("    seglist head:       %p\n", (void*)trs.sos.seglist.head);
+    snort::LogMessage("    seglist tail:       %p\n", (void*)trs.sos.seglist.tail);
+    snort::LogMessage("    seglist next:       %p\n", (void*)trs.sos.seglist.next);
+    snort::LogMessage("    seg_count:          %d\n", trs.sos.seg_count);
+    snort::LogMessage("    seg_bytes_total:    %d\n", trs.sos.seg_bytes_total);
+    snort::LogMessage("    seg_bytes_logical:  %d\n", trs.sos.seg_bytes_logical);
 }
 
index 15eaebef2b1b4a334f24f9af96f1153150450b1f..665c16da6b1e1f4636c98c9d43488998f932cf7c 100644 (file)
@@ -70,7 +70,7 @@ inline void TraceEvent(
     uint32_t rack = ( rxd ) ? h->ack() - rxd : h->ack();
     fprintf(stdout, "\n" FMTu64("-3") " %s=0x%02x Seq=%-4u Ack=%-4u Win=%-4hu Len=%-4hu%s\n",
         //"\n" FMTu64("-3") " %s=0x%02x Seq=%-4u Ack=%-4u Win=%-4u Len=%-4u End=%-4u%s\n",
-        get_packet_number(), flags, h->th_flags, rseq, rack, h->win(), p->dsize, order);
+        snort::get_packet_number(), flags, h->th_flags, rseq, rack, h->win(), p->dsize, order);
 }
 
 inline void TraceSession(const snort::Flow* lws)
index 7c0cab21f6c09409c61d56b4b47c59b7981f5dd7..cb0b45a08f0a981ae3ec40b6cfd3f3250e31466c 100644 (file)
@@ -27,6 +27,8 @@
 
 #include "log/messages.h"
 
+using namespace snort;
+
 static const char* const reassembly_policy_names[] =
 { "no policy", "first", "last", "linux", "old_linux", "bsd", "macos", "solaris", "irix",
   "hpux11", "hpux10", "windows", "win_2003", "vista", "proxy" };
index 2d7b460f954005f385721d8c49163de813fba86c..56696106efdf6d907f55f8455530cb9518eb9dc0 100644 (file)
@@ -58,6 +58,8 @@ inline bool is_service_protocol(SnortProtocolId proto)
 { return proto > SNORT_PROTO_UDP; }
 
 // A mapping between names and IDs.
+namespace snort
+{
 class SO_PUBLIC ProtocolReference
 {
 public:
@@ -88,6 +90,6 @@ private:
 
     void init(ProtocolReference* old_proto_ref);
 };
-
+}
 #endif
 
index 844e9d76118a99e6a68ba27f6ca1315dff80b7bf..826721f6957311128ce07b9d7f73320f6b1a5eff 100644 (file)
 static THREAD_LOCAL struct timeval s_recent_packet = { 0, 0 };
 static THREAD_LOCAL uint32_t s_first_packet = 0;
 
+namespace snort
+{
+time_t packet_time()
+{
+    return s_recent_packet.tv_sec;
+}
+}
+
 void packet_time_update(const struct timeval* cur_tv)
 {
     if ( !s_first_packet )
@@ -53,11 +61,6 @@ uint32_t packet_first_time()
     return s_first_packet;
 }
 
-time_t packet_time()
-{
-    return s_recent_packet.tv_sec;
-}
-
 void packet_gettimeofday(struct timeval* tv)
 {
     *tv = s_recent_packet;
index 135f35c4a556ab5f983a27e260a6c1fbec693ca2..67b0bdc3bac3cf29aa1855bb7f1179ae4fcac815 100644 (file)
 
 #include "main/snort_types.h"
 
-void packet_time_update(const struct timeval* cur_tv);
+namespace snort
+{
 SO_PUBLIC time_t packet_time();
+}
+
+void packet_time_update(const struct timeval* cur_tv);
 uint32_t packet_first_time();
 void packet_gettimeofday(struct timeval* tv);
 
index c676e1aff3c1891642f381f74c3c4229b2376f72..6312f2ae41b0ef34b4a4d48cc9a7d943c0a90663 100644 (file)
@@ -49,6 +49,8 @@
 
 #include "util.h"
 
+namespace snort
+{
 /****************************************************************
  *
  *  Function: make_skip(char *, int)
@@ -218,4 +220,4 @@ int mSearchCI(
 
     return -1;
 }
-
+}
index 7d5cecb75b43e2929a94c821d3a70fcbd09bdb36..54e16f3fb4391d4afa804abf649101459522a1d2 100644 (file)
 
 #include "main/snort_types.h"
 
+namespace snort
+{
 // FIXIT-M no associated resource destructor for make_skip & make_shift :(
 SO_PUBLIC int* make_skip(const char*, int);
 SO_PUBLIC int* make_shift(const char*, int);
 
 SO_PUBLIC int mSearch(const char*, int, const char*, int, const int*, const int*);
 SO_PUBLIC int mSearchCI(const char*, int, const char*, int, const int*, const int*);
-
+}
 #endif
 
index ba440255bdfb7c79c801077fada9710fef56b876..c5f65e353cbc7fea91d184e7f3871757a942b902 100644 (file)
@@ -31,6 +31,8 @@
 
 #include "util.h"
 
+namespace snort
+{
 KMAP* KMapNew(KMapUserFreeFunc userfree)
 {
     KMAP* km = (KMAP*)snort_calloc(sizeof(KMAP));
@@ -404,10 +406,13 @@ void* KMapFindNext(KMAP* km)
     return km->keynext->userdata;
 }
 
+} //namespace snort
+
 #ifdef KMAP_MAIN
 /*
 *
 */
+using namespace snort;
 int main(int argc, char** argv)
 {
     int i,n=10;
index 364152e880e85f89e4c3a395861165194148a10f..07729b05dceacedb33697b51a3e07a64c34e5ce3 100644 (file)
@@ -72,6 +72,8 @@ typedef struct _kmap
     int nocase;
 } KMAP;
 
+namespace snort
+{
 SO_PUBLIC KMAP* KMapNew(KMapUserFreeFunc userfree);
 SO_PUBLIC void KMapDelete(KMAP* km);
 
@@ -81,6 +83,6 @@ SO_PUBLIC int KMapAdd(KMAP* km, void* key, int ksize, void* userdata);
 SO_PUBLIC void* KMapFind(KMAP* km, void* key, int ksize);
 SO_PUBLIC void* KMapFindFirst(KMAP* km);
 SO_PUBLIC void* KMapFindNext(KMAP* km);
-
+}
 #endif
 
index f42e12ad9d524bb7ab2531b21a84a8902f7b5039..741d52f4184b09292cc9072dd40f0b64558d3ef4 100644 (file)
@@ -37,9 +37,7 @@
 
 #include "util.h"
 
-/*
-*  private alloc
-*/
+// private alloc
 static void* s_alloc(size_t n)
 {
     return snort_calloc(n);
@@ -54,18 +52,8 @@ static void s_free(void* p)
         snort_free(p);
 }
 
-/*
-*   INIT - called by the NEW functions
-*/
-void sflist_init(SF_LIST* s)
+namespace snort
 {
-    s->count=0;
-    s->head = s->tail = nullptr;
-}
-
-/*
-*    NEW
-*/
 SF_LIST* sflist_new()
 {
     SF_LIST* s;
@@ -74,14 +62,12 @@ SF_LIST* sflist_new()
     return s;
 }
 
-SF_QUEUE* sfqueue_new()
+void sflist_init(SF_LIST* s)
 {
-    return (SF_QUEUE*)sflist_new();
+    s->count=0;
+    s->head = s->tail = nullptr;
 }
 
-/*
-*  Add-before Item
-*/
 void sflist_add_before(SF_LIST* s, SF_LNODE* lnode, NODE_DATA ndata)
 {
     SF_LNODE* q;
@@ -104,12 +90,6 @@ void sflist_add_before(SF_LIST* s, SF_LNODE* lnode, NODE_DATA ndata)
     }
 }
 
-/*
-*     ADD to List/Queue/Dictionary
-*/
-/*
-*  Add-Head Item
-*/
 void sflist_add_head(SF_LIST* s, NODE_DATA ndata)
 {
     SF_LNODE* q;
@@ -132,9 +112,6 @@ void sflist_add_head(SF_LIST* s, NODE_DATA ndata)
     s->count++;
 }
 
-/*
-*  Add-Tail Item
-*/
 void sflist_add_tail(SF_LIST* s, NODE_DATA ndata)
 {
     SF_LNODE* q;
@@ -157,14 +134,6 @@ void sflist_add_tail(SF_LIST* s, NODE_DATA ndata)
     s->count++;
 }
 
-void sfqueue_add(SF_QUEUE* s, NODE_DATA ndata)
-{
-    sflist_add_tail (s, ndata);
-}
-
-/*
-*   List walk - First/Next - return the node data or NULL
-*/
 NODE_DATA sflist_first(SF_LIST* s, SF_LNODE** v)
 {
     if ( !s )
@@ -191,9 +160,6 @@ NODE_DATA sflist_next(SF_LNODE** v)
     return nullptr;
 }
 
-/*
-*  Remove Head Item from list
-*/
 NODE_DATA sflist_remove_head(SF_LIST* s)
 {
     NODE_DATA ndata = nullptr;
@@ -215,9 +181,6 @@ NODE_DATA sflist_remove_head(SF_LIST* s)
     return (NODE_DATA)ndata;
 }
 
-/*
-*  Remove tail Item from list
-*/
 NODE_DATA sflist_remove_tail(SF_LIST* s)
 {
     NODE_DATA ndata = nullptr;
@@ -287,34 +250,22 @@ void sflist_remove_node(SF_LIST* s, SF_LNODE* n)
     }
 }
 
-/*
-*  Remove Head Item from queue
-*/
-NODE_DATA sfqueue_remove(SF_QUEUE* s)
-{
-    return (NODE_DATA)sflist_remove_head(s);
-}
-
-/*
-*  COUNT
-*/
-int sfqueue_count(SF_QUEUE* s)
+int sflist_count(SF_LIST* s)
 {
     if (!s)
         return 0;
     return s->count;
 }
 
-int sflist_count(SF_LIST* s)
+void sflist_free(SF_LIST* s)
 {
-    if (!s)
-        return 0;
-    return s->count;
+    while ( sflist_count(s) )
+    {
+        sflist_remove_head(s);
+    }
+    s_free(s);
 }
 
-/*
-*   Free List + Free it's data nodes using 'nfree'
-*/
 void sflist_free_all(SF_LIST* s, void (* nfree)(void*) )
 {
     if (!s)
@@ -330,11 +281,6 @@ void sflist_free_all(SF_LIST* s, void (* nfree)(void*) )
     s_free(s);
 }
 
-void sfqueue_free_all(SF_QUEUE* s,void (* nfree)(void*) )
-{
-    sflist_free_all(s, nfree);
-}
-
 void sflist_static_free_all(SF_LIST* s, void (* nfree)(void*) )
 {
     if (!s)
@@ -349,17 +295,38 @@ void sflist_static_free_all(SF_LIST* s, void (* nfree)(void*) )
     }
 }
 
-/*
-*  FREE List/Queue/Dictionary
-*
-*  This does not free a nodes data
-*/
-void sflist_free(SF_LIST* s)
+}
+
+// ----- queue methods -----
+
+using namespace snort;
+
+SF_QUEUE* sfqueue_new()
 {
-    while ( sflist_count(s) )
-    {
-        sflist_remove_head(s);
-    }
-    s_free(s);
+    return (SF_QUEUE*)sflist_new();
 }
 
+void sfqueue_add(SF_QUEUE* s, NODE_DATA ndata)
+{
+    sflist_add_tail (s, ndata);
+}
+
+
+NODE_DATA sfqueue_remove(SF_QUEUE* s)
+{
+    return (NODE_DATA)sflist_remove_head(s);
+}
+
+int sfqueue_count(SF_QUEUE* s)
+{
+    if (!s)
+        return 0;
+    return s->count;
+}
+
+void sfqueue_free_all(SF_QUEUE* s,void (* nfree)(void*) )
+{
+    sflist_free_all(s, nfree);
+}
+
+
index 977ab4ae5419c88b89a4bf573a5e18b4f610ecba..8ac145864cc7d8d10229d62bf5e9eed0ec2666dd 100644 (file)
@@ -74,6 +74,8 @@ typedef sf_list SF_LIST;
 // -----------------------------------------------------------------------------
 // Linked List Interface
 // -----------------------------------------------------------------------------
+namespace snort
+{
 SO_PUBLIC SF_LIST* sflist_new();
 SO_PUBLIC void sflist_init(SF_LIST*);
 SO_PUBLIC void sflist_add_tail(SF_LIST*, NODE_DATA);
@@ -88,6 +90,7 @@ SO_PUBLIC NODE_DATA sflist_next(SF_LNODE**);
 SO_PUBLIC void sflist_free(SF_LIST*);
 SO_PUBLIC void sflist_free_all(SF_LIST*, void (* free)(void*) );
 SO_PUBLIC void sflist_static_free_all(SF_LIST*, void (* nfree)(void*));
+}
 
 // -----------------------------------------------------------------------------
 //  Queue Interface ( FIFO - First in, First out )
index b89a02f728d791d330b8164196fafa9263af939c..50d085b3ade3011bdbcd890152a9b6c44f21be5c 100644 (file)
 
 #include "util.h"
 
-using namespace snort;
-
 #define STATS_SEPARATOR \
     "--------------------------------------------------"
 
 THREAD_LOCAL AuxCount aux_counts;
-THREAD_LOCAL PacketCount pc;
 ProcessCount proc_stats;
 
-PegCount get_packet_number()
-{ return pc.total_from_daq; }
-
-//-------------------------------------------------------------------------
-
-double CalcPct(uint64_t cnt, uint64_t total)
+namespace snort
 {
-    double pct = 0.0;
 
-    if (total == 0.0)
-    {
-        pct = (double)cnt;
-    }
-    else
-    {
-        pct = (double)cnt / (double)total;
-    }
-
-    pct *= 100.0;
+THREAD_LOCAL PacketCount pc;
 
-    return pct;
-}
+PegCount get_packet_number()
+{ return pc.total_from_daq; }
 
 //-------------------------------------------------------------------------
 
@@ -114,6 +96,29 @@ void LogStat(const char* s, double d, FILE* fh)
     if ( d )
         LogMessage(fh, "%25.25s: %g\n", s, d);
 }
+}
+
+using namespace snort;
+
+//-------------------------------------------------------------------------
+
+double CalcPct(uint64_t cnt, uint64_t total)
+{
+    double pct = 0.0;
+
+    if (total == 0.0)
+    {
+        pct = (double)cnt;
+    }
+    else
+    {
+        pct = (double)cnt / (double)total;
+    }
+
+    pct *= 100.0;
+
+    return pct;
+}
 
 //-------------------------------------------------------------------------
 
@@ -324,4 +329,3 @@ void show_percent_stats(
         LogStat(s, c, pegs[0], stdout);
     }
 }
-
index 41127e3c5c419489bf708c55bf9edb7eb09e9bac..3509c8d2870fefceda1868478a498500257c9d43 100644 (file)
@@ -79,12 +79,15 @@ struct AuxCount
 
 extern ProcessCount proc_stats;
 extern THREAD_LOCAL AuxCount aux_counts;
-extern SO_PUBLIC THREAD_LOCAL PacketCount pc;
 
 extern const PegInfo daq_names[];
 extern const PegInfo pc_names[];
 extern const PegInfo proc_names[];
 
+namespace snort
+{
+extern SO_PUBLIC THREAD_LOCAL PacketCount pc;
+
 SO_PUBLIC PegCount get_packet_number();
 
 SO_PUBLIC void LogLabel(const char*, FILE* = stdout);
@@ -93,6 +96,7 @@ SO_PUBLIC void LogCount(const char*, uint64_t, FILE* = stdout);
 
 SO_PUBLIC void LogStat(const char*, uint64_t n, uint64_t tot, FILE* = stdout);
 SO_PUBLIC void LogStat(const char*, double, FILE* = stdout);
+}
 
 void sum_stats(PegCount* sums, PegCount* counts, unsigned n);
 void show_stats(PegCount*, const PegInfo*, const char* module_name = nullptr);
index e47af72e82cdc13d3c556df49cccfbf4034f9883..a26f0a2d1f4b46baf5237676451eb0000d3be496 100644 (file)
@@ -65,8 +65,6 @@ extern "C" {
 
 using namespace snort;
 
-char** protocol_names = nullptr;
-
 /****************************************************************************
  * Store interesting data in memory that would not otherwise be visible
  * in a CORE(5) file
@@ -496,28 +494,6 @@ std::string read_infile(const char* key, const char* fname)
     return line;
 }
 
-char* snort_strndup(const char* src, size_t dst_size)
-{
-    char* dup = (char*)snort_calloc(dst_size + 1);
-
-    if ( SnortStrncpy(dup, src, dst_size + 1) == SNORT_STRNCPY_ERROR )
-    {
-        snort_free(dup);
-        return nullptr;
-    }
-
-    return dup;
-}
-
-char* snort_strdup(const char* str)
-{
-    assert(str);
-    size_t n = strlen(str) + 1;
-    char* p = (char*)snort_alloc(n);
-    memcpy(p, str, n);
-    return p;
-}
-
 typedef char PathBuf[PATH_MAX+1];
 
 static const char* CurrentWorkingDir(PathBuf& buf)
@@ -621,6 +597,10 @@ void SetNoCores()
 }
 #endif
 
+namespace snort
+{
+char** protocol_names = nullptr;
+
 const char* get_error(int errnum)
 {
     static THREAD_LOCAL char buf[128];
@@ -634,3 +614,28 @@ const char* get_error(int errnum)
 #endif
 }
 
+char* snort_strndup(const char* src, size_t dst_size)
+{
+    char* dup = (char*)snort_calloc(dst_size + 1);
+
+    if ( SnortStrncpy(dup, src, dst_size + 1) == SNORT_STRNCPY_ERROR )
+    {
+        snort_free(dup);
+        return nullptr;
+    }
+
+    return dup;
+}
+
+char* snort_strdup(const char* str)
+{
+    assert(str);
+    size_t n = strlen(str) + 1;
+    char* p = (char*)snort_alloc(n);
+    memcpy(p, str, n);
+    return p;
+}
+
+}
+
+
index 79b1d1a359e6e50a5e84886db38366709d80a7d5..2361220fcd035547455a0b3a60d171bbfd5cae08 100644 (file)
@@ -51,9 +51,6 @@
     (x)[8] = (y)[8]; (x)[9] = (y)[9]; (x)[10] = (y)[10]; (x)[11] = (y)[11]; \
     (x)[12] = (y)[12]; (x)[13] = (y)[13]; (x)[14] = (y)[14]; (x)[15] = (y)[15];
 
-// FIXIT-M provide getter function to for standardized access into the protocol_names array
-SO_PUBLIC extern char** protocol_names;
-
 void StoreSnortInfoStrings();
 int DisplayBanner();
 int gmt2local(time_t);
@@ -71,9 +68,6 @@ void InitProtoNames();
 void SetNoCores();
 #endif
 
-SO_PUBLIC char* snort_strdup(const char*);
-SO_PUBLIC char* snort_strndup(const char*, size_t);
-
 inline void* snort_alloc(size_t sz)
 { return new uint8_t[sz]; }
 
@@ -103,7 +97,15 @@ inline pid_t gettid()
 #endif
 }
 
+namespace snort
+{
+// FIXIT-M provide getter function to for standardized access into the protocol_names array
+SO_PUBLIC extern char** protocol_names;
+
 SO_PUBLIC const char* get_error(int errnum);
+SO_PUBLIC char* snort_strdup(const char*);
+SO_PUBLIC char* snort_strndup(const char*, size_t);
+}
 
 #endif
 
index f652e2a4aa34a758813db35d2cfd63a107bba278..f97661adead673e8b685f72681c624347e39fe81 100644 (file)
@@ -29,6 +29,8 @@
 #include <cstdio>
 #include <cstring>
 
+namespace snort
+{
 /* Guaranteed to be '\0' terminated even if truncation occurs.
  *
  * returns  SNORT_SNPRINTF_SUCCESS if successful
@@ -346,3 +348,5 @@ int safe_snprintf(char* s, size_t n, const char* format, ... )
     return len;
 }
 
+}
+
index 488b08889d0d75ec50feb77cf5a274445adf5825..6f03493459c708c3cc93dc860860588f43e100b5 100644 (file)
@@ -29,6 +29,8 @@
 
 #include "main/snort_types.h"
 
+namespace snort
+{
 #define SNORT_SNPRINTF_SUCCESS 0
 #define SNORT_SNPRINTF_TRUNCATION 1
 #define SNORT_SNPRINTF_ERROR (-1)
@@ -131,6 +133,6 @@ inline int SnortStrToU32(const char* buffer, char** endptr,
 
     return 0;
 }
-
+}
 #endif
 
index 21f99c55d5416dced280708d33c09e714d97f456..50ddbd09fc6c95e90396fc2339758f1705f6a12e 100644 (file)
@@ -29,6 +29,8 @@
 
 #include "main/thread.h"
 
+namespace snort
+{
 #define INVALID_HEX_VAL (-1)
 #define MAX_BUF 8
 #define NON_ASCII_CHAR 0xff
@@ -1330,3 +1332,4 @@ int main(int argc, char *argv[])
 
 }*/
 
+}
index 7578c123d3cd14f5931087b90972fdc153893ac9..3a86acacdbab3169372edbf49b4b6fafbc1fba77 100644 (file)
@@ -25,6 +25,8 @@
 
 #include "main/snort_types.h"
 
+namespace snort
+{
 #define ALERT_SPACES_EXCEEDED   0x1
 #define ALERT_LEVELS_EXCEEDED   0x2
 #define ALERT_MIXED_ENCODINGS   0x4
@@ -40,6 +42,6 @@ struct JSState
 
 SO_PUBLIC int JSNormalizeDecode(
     const char*, uint16_t, char*, uint16_t destlen, const char**, int*, JSState*, uint8_t*);
-
+}
 #endif
 
index 3c3d29e43d5c0adef4e01036ac6bc4800126518e..ec1663d0191ffb6a432ae9308f4aed2138015d8f 100644 (file)
@@ -24,6 +24,8 @@
 
 #include "util_unfold.h"
 
+namespace snort
+{
 /* Given a string, removes header folding (\r\n followed by linear whitespace)
  * and exits when the end of a header is found, defined as \n followed by a
  * non-whitespace.  This is especially helpful for HTML.
@@ -187,3 +189,5 @@ int sf_strip_LWS(const uint8_t* inbuf, uint32_t inbuf_size, uint8_t* outbuf,
     return(0);
 }
 
+}
+
index 7890df20cc732ad553d85e9634c094220632ab4b..daee328136c251f16431cd232fcb989134bc7f0c 100644 (file)
 
 #include "main/snort_types.h"
 
+namespace snort
+{
 SO_PUBLIC int sf_unfold_header(const uint8_t*, uint32_t, uint8_t*, uint32_t, uint32_t*, int, int*);
 SO_PUBLIC int sf_strip_CRLF(const uint8_t*, uint32_t, uint8_t*, uint32_t, uint32_t*);
 SO_PUBLIC int sf_strip_LWS(const uint8_t*, uint32_t, uint8_t*, uint32_t, uint32_t*);
-
+}
 #endif
 
index c3ff1d07b7a952a185aa4d02c6cf128fa3cbf740..e89721d67108b590f936c620926e248ba538d31b 100644 (file)
@@ -37,6 +37,8 @@
 #define DSTATE_THIRD 2
 #define DSTATE_FOURTH 3
 
+using namespace snort;
+
 UtfDecodeSession::UtfDecodeSession()
 {
     init_decode_utf_state();
index 01afb019fd99fc3ef45da150a04241658e50abb4..9ac11e2119e39a81ce0217fe7eeed8134ddb6873 100644 (file)
@@ -47,6 +47,8 @@ struct decode_utf_state_t
     CharsetCode charset;
 };
 
+namespace snort
+{
 class SO_PUBLIC UtfDecodeSession
 {
 public:
@@ -69,4 +71,6 @@ private:
     bool DecodeUTF32BE(const uint8_t* src, unsigned int src_len, uint8_t* dst, unsigned int dst_len, int* bytes_copied);
     void determine_charset(const uint8_t** src, unsigned int* src_len);
 };
+}
+
 #endif