]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
reverse e71421e748f660021b9af7bb6a25d4f3828dafd7 since it broke regressions
authorRuss Combs <rucombs@cisco.com>
Fri, 26 Feb 2016 20:34:41 +0000 (15:34 -0500)
committerRuss Combs <rucombs@cisco.com>
Fri, 26 Feb 2016 20:34:41 +0000 (15:34 -0500)
src/main/modules.cc
src/main/snort_module.cc
src/managers/module_manager.cc
src/managers/module_manager.h
src/managers/plugin_manager.cc
src/managers/plugin_manager.h
src/network_inspectors/perf_monitor/perf_module.cc
src/network_inspectors/perf_monitor/perf_module.h
src/utils/stats.cc
src/utils/stats.h

index ab6fd69023d7c32298451bd5870c9bcfc2524537..5693ecdfe577874024b9ea5b17a13ade77a47252 100644 (file)
@@ -97,7 +97,6 @@ public:
     DetectionModule() : Module("detection", detection_help, detection_params) { }
     bool set(const char*, Value&, SnortConfig*) override;
     const PegInfo* get_pegs() const override { return pc_names; }
-    PegCount* get_counts() const override { return (PegCount*) &pc; }
 };
 
 bool DetectionModule::set(const char*, Value& v, SnortConfig* sc)
@@ -946,7 +945,6 @@ public:
     DaqModule() : Module("daq", daq_help, daq_params) { }
     bool set(const char*, Value&, SnortConfig*) override;
     const PegInfo* get_pegs() const override { return daq_names; }
-    PegCount* get_counts() const override;
 };
 
 bool DaqModule::set(const char*, Value& v, SnortConfig* sc)
@@ -985,14 +983,6 @@ bool DaqModule::set(const char*, Value& v, SnortConfig* sc)
     return true;
 }
 
-PegCount* DaqModule::get_counts() const
-{
-    static THREAD_LOCAL DAQStats ds;
-
-    get_daq_stats(ds);
-    return (PegCount*) &ds;
-}
-
 //-------------------------------------------------------------------------
 // attribute_table module
 //-------------------------------------------------------------------------
index 1a9775f665e3b55db75d8e651def42dd118896e8..6809de72018ab3802b35ae95c83b21b2ab50dec2 100644 (file)
@@ -516,7 +516,6 @@ public:
 
     bool set(const char*, Value&, SnortConfig*) override;
     const PegInfo* get_pegs() const override { return proc_names; }
-    PegCount* get_counts() const override { return (PegCount*) &proc_stats; }
 };
 
 bool SnortModule::set(const char*, Value& v, SnortConfig* sc)
index 9b971a3073282a5be191362f1eff42a3f15cca48..0581d501b847e3008ed6e002e48a197f0aa7346b 100644 (file)
@@ -57,7 +57,7 @@ struct ModHook
     void init();
 };
 
-typedef std::list<ModHook*> ModuleList;
+typedef list<ModHook*> ModuleList;
 static ModuleList s_modules;
 static unsigned s_errors = 0;
 
@@ -811,16 +811,6 @@ Module* ModuleManager::get_default_module(const char* s, SnortConfig* sc)
 const char* ModuleManager::get_current_module()
 { return s_current.c_str(); }
 
-list<Module*> ModuleManager::get_all_modules()
-{
-    list<Module*> ret;
-
-    for ( auto& m : s_modules )
-       ret.push_back(m->mod);
-
-    return ret;
-}
-
 void ModuleManager::set_config(SnortConfig* sc)
 { s_config = sc; }
 
index 2b5c2142fd6b2afe54460fe6c83786d1201f3ac8..ff6fc68406b34d2f7bfa4ecc0dd8546afe88d5fd 100644 (file)
@@ -23,7 +23,6 @@
 // Factory for Modules, including all builtin and plugin modules.
 // Modules are strictly used during parse time.
 
-#include <list>
 #include <string>
 
 //-------------------------------------------------------------------------
@@ -40,7 +39,6 @@ public:
     static Module* get_module(const char*);
     static Module* get_default_module(const char*, SnortConfig*);
     static const char* get_current_module();
-    static std::list<Module*> get_all_modules();
 
     static void list_modules(const char* = nullptr);
     static void dump_modules();
index 0ac61357701b1eaf6b4a9849325f48a246e8de8e..1fee8e4c5c688522a20fdbf8a286be1645067c14 100644 (file)
@@ -573,3 +573,17 @@ const char* PluginManager::get_available_plugins(PlugType t)
     return s.c_str();
 }
 
+std::vector<std::string> PluginManager::get_all_available_plugins()
+{
+    std::vector<std::string> ret;
+
+    for ( auto it = plug_map.begin(); it != plug_map.end(); ++it )
+    {
+        const auto* api = it->second.api;
+
+        ret.push_back(api->name);
+    }
+
+    return ret;
+}
+
index 6cbb0b7dfab992f105d6e128b7a4663a2a156d28..6c7b4f71e427550f8467d65ff1e447852e1087a2 100644 (file)
@@ -63,6 +63,7 @@ public:
     static void instantiate(const BaseApi*, Module*, SnortConfig*, const char* name);
 
     static const char* get_available_plugins(PlugType);
+    static std::vector<std::string> get_all_available_plugins();
 };
 
 #endif
index 73044a531ff79f2635433f68a20c738496527359..c257bf26d5bc0f4e462823dc036b7a3081494de3 100644 (file)
@@ -24,6 +24,9 @@
 #include "managers/plugin_manager.h"
 #include "utils/util.h"
 
+static std::string mod_pegs;
+static std::string mod_name;
+
 //-------------------------------------------------------------------------
 // perf attributes
 //-------------------------------------------------------------------------
@@ -248,10 +251,11 @@ bool PerfMonModule::end(const char* fqn, int idx, SnortConfig*)
     {
         if ( !config.modules.size() )
         {
-            auto modules = ModuleManager::get_all_modules();
-            for ( auto& mod : modules )
+            auto modules = PluginManager::get_all_available_plugins();
+            for ( auto& mod_name : modules )
             {
-                if ( !add_module(config, mod, std::string()) )
+                Module* mod = ModuleManager::get_module(mod_name.c_str());
+                if ( mod && !add_module(config, mod, std::string()) )
                     return false;
             }
         }
index a0f3248adea8a747d6a2b1a766f834060f76cfba..c4ba01d3001c798bfafc6fe6b1dffd5159f65043 100644 (file)
@@ -48,9 +48,6 @@ public:
 
 private:
     SFPERF config;
-
-     std::string mod_pegs;
-     std::string mod_name;
 };
 
 #define BASE_FILE "perf_monitor.csv"
index a3541b456bb642e9953385f66943760b4984d57f..e76b74a1da9026fc5874de2d6475dbc678be73ba 100644 (file)
@@ -157,6 +157,31 @@ static void timing_stats()
     LogMessage("%25.25s: " STDu64 "\n", "pkts/sec", pps);
 }
 
+//-------------------------------------------------------------------------
+// FIXIT-L 2.0.4 introduces the retry verdict
+// no way to reliably optionally leverage this with dynamic loaded daqs
+
+// FIXIT-L daq stats should be moved to sfdaq
+
+#define MAX_SFDAQ_VERDICT 6
+
+struct DAQStats
+{
+    PegCount pcaps;
+    PegCount received;
+    PegCount analyzed;
+    PegCount dropped;
+    PegCount filtered;
+    PegCount outstanding;
+    PegCount injected;
+    PegCount verdicts[MAX_SFDAQ_VERDICT];
+    PegCount internal_blacklist;
+    PegCount internal_whitelist;
+    PegCount skipped;
+    PegCount fail_open;
+    PegCount idle;
+};
+
 //-------------------------------------------------------------------------
 // FIXIT-L need better encapsulation of these counts by their modules
 
@@ -245,7 +270,7 @@ void pc_sum()
 
 //-------------------------------------------------------------------------
 
-void get_daq_stats(DAQStats& daq_stats)
+static void get_daq_stats(DAQStats& daq_stats)
 {
     uint64_t pkts_recv = g_daq_stats.hw_packets_received;
     uint64_t pkts_drop = g_daq_stats.hw_packets_dropped;
index 71c1da267e4119b53c76c0e5397bb3567b01a9aa..8d39c02c43dade6435a3767bb6512baa15d6e956 100644 (file)
@@ -79,31 +79,6 @@ struct AuxCount
     PegCount idle;
 };
 
-//-------------------------------------------------------------------------
-// FIXIT-L 2.0.4 introduces the retry verdict
-// no way to reliably optionally leverage this with dynamic loaded daqs
-
-// FIXIT-L daq stats should be moved to sfdaq
-
-#define MAX_SFDAQ_VERDICT 6
-
-struct DAQStats
-{
-    PegCount pcaps;
-    PegCount received;
-    PegCount analyzed;
-    PegCount dropped;
-    PegCount filtered;
-    PegCount outstanding;
-    PegCount injected;
-    PegCount verdicts[MAX_SFDAQ_VERDICT];
-    PegCount internal_blacklist;
-    PegCount internal_whitelist;
-    PegCount skipped;
-    PegCount fail_open;
-    PegCount idle;
-};
-
 extern ProcessCount proc_stats;
 extern THREAD_LOCAL AuxCount aux_counts;
 extern SO_PUBLIC THREAD_LOCAL PacketCount pc;
@@ -121,8 +96,6 @@ SO_PUBLIC void LogCount(const char*, uint64_t);
 SO_PUBLIC void LogStat(const char*, uint64_t n, uint64_t tot);
 SO_PUBLIC void LogStat(const char*, double);
 
-void get_daq_stats(DAQStats& daq_stats);
-
 void sum_stats(PegCount* sums, PegCount* counts, unsigned n);
 void show_stats(PegCount*, const PegInfo*, unsigned n,
     const char* module_name = nullptr);