From: Russ Combs (rucombs) Date: Thu, 31 Mar 2016 16:43:25 +0000 (-0400) Subject: Merge pull request #384 in SNORT/snort3 from perf_s2l to master X-Git-Tag: 3.0.0-233~491 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bececbe98d7c0d88fb42027b74cfef7ec46b0718;p=thirdparty%2Fsnort3.git Merge pull request #384 in SNORT/snort3 from perf_s2l to master Squashed commit of the following: commit 0d97b9c329de9e0313b77dd99fdb7fd809fd624e Author: Carter Waxman Date: Thu Mar 31 11:38:52 2016 -0400 fixed snort2lua to handle perfmon changes commit b54f615e66d3948a13f461341c80fabe92babc0b Author: Carter Waxman Date: Thu Mar 31 10:16:22 2016 -0400 fixed build warnings --- diff --git a/src/network_inspectors/perf_monitor/event_tracker.cc b/src/network_inspectors/perf_monitor/event_tracker.cc index 2b4337199..126289b62 100644 --- a/src/network_inspectors/perf_monitor/event_tracker.cc +++ b/src/network_inspectors/perf_monitor/event_tracker.cc @@ -40,7 +40,7 @@ void EventTracker::reset() } } -void EventTracker::process(bool summarize) +void EventTracker::process(bool) { if (config->format == PERF_TEXT) { diff --git a/src/network_inspectors/perf_monitor/flow_ip_tracker.cc b/src/network_inspectors/perf_monitor/flow_ip_tracker.cc index 8b0c32159..f50515474 100644 --- a/src/network_inspectors/perf_monitor/flow_ip_tracker.cc +++ b/src/network_inspectors/perf_monitor/flow_ip_tracker.cc @@ -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(); diff --git a/src/network_inspectors/perf_monitor/flow_tracker.cc b/src/network_inspectors/perf_monitor/flow_tracker.cc index 9d7263f07..f05f6c5b7 100644 --- a/src/network_inspectors/perf_monitor/flow_tracker.cc +++ b/src/network_inspectors/perf_monitor/flow_tracker.cc @@ -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); diff --git a/src/network_inspectors/perf_monitor/perf_flow.h b/src/network_inspectors/perf_monitor/perf_flow.h index 956e2cfd7..b6bcbae85 100644 --- a/src/network_inspectors/perf_monitor/perf_flow.h +++ b/src/network_inspectors/perf_monitor/perf_flow.h @@ -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; diff --git a/src/network_inspectors/perf_monitor/perf_module.h b/src/network_inspectors/perf_monitor/perf_module.h index 6bea5ffbc..b36c85829 100644 --- a/src/network_inspectors/perf_monitor/perf_module.h +++ b/src/network_inspectors/perf_monitor/perf_module.h @@ -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 { diff --git a/src/network_inspectors/perf_monitor/perf_monitor.cc b/src/network_inspectors/perf_monitor/perf_monitor.cc index 458e5f7f6..cae4d511f 100644 --- a/src/network_inspectors/perf_monitor/perf_monitor.cc +++ b/src/network_inspectors/perf_monitor/perf_monitor.cc @@ -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) { diff --git a/tools/snort2lua/preprocessor_states/pps_perfmonitor.cc b/tools/snort2lua/preprocessor_states/pps_perfmonitor.cc index 124338d3c..32438b37c 100644 --- a/tools/snort2lua/preprocessor_states/pps_perfmonitor.cc +++ b/tools/snort2lua/preprocessor_states/pps_perfmonitor.cc @@ -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")) {