]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Merge pull request #384 in SNORT/snort3 from perf_s2l to master
authorRuss Combs (rucombs) <rucombs@cisco.com>
Thu, 31 Mar 2016 16:43:25 +0000 (12:43 -0400)
committerRuss Combs (rucombs) <rucombs@cisco.com>
Thu, 31 Mar 2016 16:43:25 +0000 (12:43 -0400)
Squashed commit of the following:

commit 0d97b9c329de9e0313b77dd99fdb7fd809fd624e
Author: Carter Waxman <cwaxman@cisco.com>
Date:   Thu Mar 31 11:38:52 2016 -0400

    fixed snort2lua to handle perfmon changes

commit b54f615e66d3948a13f461341c80fabe92babc0b
Author: Carter Waxman <cwaxman@cisco.com>
Date:   Thu Mar 31 10:16:22 2016 -0400

    fixed build warnings

src/network_inspectors/perf_monitor/event_tracker.cc
src/network_inspectors/perf_monitor/flow_ip_tracker.cc
src/network_inspectors/perf_monitor/flow_tracker.cc
src/network_inspectors/perf_monitor/perf_flow.h
src/network_inspectors/perf_monitor/perf_module.h
src/network_inspectors/perf_monitor/perf_monitor.cc
tools/snort2lua/preprocessor_states/pps_perfmonitor.cc

index 2b43371996498a76f782dc842b8cd80e91ab9c54..126289b625368975f60602a514ab77baaaa35f52 100644 (file)
@@ -40,7 +40,7 @@ void EventTracker::reset()
     }
 }
 
-void EventTracker::process(bool summarize)
+void EventTracker::process(bool)
 {
     if (config->format == PERF_TEXT)
     {
index 8b0c321596e0debf2f2338254a5db16982435a8f..f5051547453343ae4f5336a1ee2845698e6e907f 100644 (file)
@@ -206,7 +206,7 @@ void FlowIPTracker::write_stats()
     fflush(fh);
 }
 
-void FlowIPTracker::process(bool summarize)
+void FlowIPTracker::process(bool)
 {
     if (config->format == PERF_CSV)
         write_stats();
index 9d7263f07f2cad8cea1924fa62364283f11e4e0c..f05f6c5b798d4021411a7a97ef9054b298f5dcce 100644 (file)
@@ -113,7 +113,7 @@ void FlowTracker::update(Packet* p)
         update_flow_stats(&stats, p);
 }
 
-void FlowTracker::process(bool summarize)
+void FlowTracker::process(bool)
 {
     process_flow_stats(&stats, fh, config->format, cur_time);
 
index 956e2cfd7aedb31a4966e7c2880b11d8bd0b9512..b6bcbae854a04ab9d583e80668a783dc08c8aba8 100644 (file)
@@ -107,7 +107,7 @@ struct FlowStats
     int port_flow_tcp_count;
 
     PortFlow port_flow_udp;
-    double port_flow_high_udp;;
+    double port_flow_high_udp;
     int port_flow_udp_count;
 
     IcmpFlow flow_icmp;
index 6bea5ffbc5e8e3c0977a2a8203fd3610bf705aa3..b36c85829f7c476dce277932e8d1907a8689283b 100644 (file)
@@ -46,10 +46,9 @@ enum PerfOutput
 #define PERF_FLOW           0x00000002
 #define PERF_EVENT          0x00000004
 #define PERF_BASE_MAX       0x00000008
-#define PERF_CONSOLE        0x00000010
-#define PERF_FLOWIP         0x00000020
-#define PERF_TIME_COUNT     0x00000040
-#define PERF_SUMMARY        0x00000080
+#define PERF_FLOWIP         0x00000010
+#define PERF_TIME_COUNT     0x00000020
+#define PERF_SUMMARY        0x00000040
 
 struct PerfConfig
 {
index 458e5f7f6ed28be911228c8c7ee78faef156e7de..cae4d511f0a55896ca061dfae125c0dea8c59bb5 100644 (file)
@@ -103,17 +103,17 @@ void PerfMonitor::show(SnortConfig*)
     LogMessage("  Max File Size:    " STDu64 "\n", config.max_file_size);
     LogMessage("  Summary Mode:     %s\n",
         config.perf_flags & PERF_SUMMARY ? "ACTIVE" : "INACTIVE");
-    LogMessage("  Base Stats:       %s%s\n",
+    LogMessage("  Base Stats:       %s\n",
         config.perf_flags & PERF_BASE ? "ACTIVE" : "INACTIVE");
-    LogMessage("  Flow Stats:       %s%s\n",
+    LogMessage("  Flow Stats:       %s\n",
         config.perf_flags & PERF_FLOW ? "ACTIVE" : "INACTIVE");
     if (config.perf_flags & PERF_FLOW)
     {
         LogMessage("    Max Flow Port:    %u\n", config.flow_max_port_to_track);
     }
-    LogMessage("  Event Stats:      %s%s\n",
+    LogMessage("  Event Stats:      %s\n",
         config.perf_flags & PERF_EVENT ? "ACTIVE" : "INACTIVE");
-    LogMessage("  Flow IP Stats:    %s%s\n",
+    LogMessage("  Flow IP Stats:    %s\n",
         config.perf_flags & PERF_FLOWIP ? "ACTIVE" : "INACTIVE");
     if (config.perf_flags & PERF_FLOWIP)
     {
index 124338d3c5e14f6e6f46be69959171aa8315f294..32438b37c1b61f83ff2c956dc14caefeef245c9c 100644 (file)
@@ -37,6 +37,8 @@ public:
     virtual bool convert(std::istringstream& data_stream);
 
 private:
+    bool output_set = false;
+
     bool parse_file_option(std::istringstream& data_stream,
         std::string orig_name,
         std::string option_name,
@@ -75,16 +77,25 @@ bool PerfMonitor::convert(std::istringstream& data_stream)
             tmpval = table_api.add_option("flow", true);
 
         else if (!keyword.compare("max"))
-            tmpval = table_api.add_option("max", true);
+            table_api.add_deleted_comment("max");
 
         else if (!keyword.compare("events"))
             tmpval = table_api.add_option("events", true);
 
         else if (!keyword.compare("console"))
-            tmpval = table_api.add_option("console", true);
+        {
+            table_api.add_diff_option_comment("console", "output = 'console'");
+            table_api.add_diff_option_comment("console", "format = 'text'");
+            if (!output_set)
+            {
+                tmpval = table_api.add_option("output", "console");
+                tmpval &= table_api.add_option("format", "text");
+                output_set = true;
+            }
+        }
 
         else if (!keyword.compare("reset"))
-            tmpval = table_api.add_option("reset", true);
+            table_api.add_deleted_comment("atexitonly: reset");
 
         else if (!keyword.compare("atexitonly"))
             table_api.add_deleted_comment("atexitonly");
@@ -105,31 +116,57 @@ bool PerfMonitor::convert(std::istringstream& data_stream)
             tmpval = parse_int_option("max_file_size", data_stream, false);
 
         else if (!keyword.compare("file"))
-            parse_file_option(data_stream, "file",
-                "file", "perf_monitor.csv");
+        {
+            table_api.add_diff_option_comment("file", "output = 'file'");
+            table_api.add_diff_option_comment("file", "format = 'csv'");
+            if (!output_set)
+            {
+                tmpval = table_api.add_option("output", "file");
+                tmpval &= table_api.add_option("format", "csv");
+                output_set = true;
+            }
+            eat_option(data_stream);
+        }
 
         else if (!keyword.compare("snortfile"))
         {
-            table_api.add_diff_option_comment("snortfile", "file = true");
-            parse_file_option(data_stream, "snortfile",
-                "file", "perf_monitor.csv");
+            table_api.add_diff_option_comment("snortfile", "output = 'file'");
+            table_api.add_diff_option_comment("snortfile", "format = 'csv'");
+            if (!output_set)
+            {
+                tmpval = table_api.add_option("output", "file");
+                tmpval &= table_api.add_option("format", "csv");
+                output_set = true;
+            }
+            eat_option(data_stream);
         }
         else if (!keyword.compare("flow-file"))
         {
-            table_api.add_diff_option_comment("flow-file", "flow_file = true");
-            parse_file_option(data_stream, "flow-file",
-                "flow_file", "perf_monitor_flow.csv");
+            table_api.add_diff_option_comment("flow-file", "output = 'file'");
+            table_api.add_diff_option_comment("flow-file", "format = 'csv'");
+            if (!output_set)
+            {
+                tmpval = table_api.add_option("output", "file");
+                tmpval &= table_api.add_option("format", "csv");
+                output_set = true;
+            }
+            eat_option(data_stream);
         }
         else if (!keyword.compare("flow-ip-file"))
         {
-            table_api.add_diff_option_comment("flow-ip-file", "flow_ip_file = true");
-            parse_file_option(data_stream, "flow-ip-file",
-                "flow_ip_file", "perf_monitor_flow_ip.csv");
+            table_api.add_diff_option_comment("flow-ip-file", "output = 'file'");
+            table_api.add_diff_option_comment("flow-ip-file", "format = 'csv'");
+            if (!output_set)
+            {
+                tmpval = table_api.add_option("output", "file");
+                tmpval &= table_api.add_option("format", "csv");
+                output_set = true;
+            }
+            eat_option(data_stream);
         }
         else if (!keyword.compare("accumulate"))
         {
-            table_api.add_diff_option_comment("accumulate", "reset = false");
-            tmpval = table_api.add_option("reset", false);
+            table_api.add_deleted_comment("accumulate");
         }
         else if (!keyword.compare("flow-ip"))
         {