]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Merge pull request #1736 in SNORT/snort3 from ~MIALTIZE/snort3:cppcheck to master
authorMichael Altizer (mialtize) <mialtize@cisco.com>
Sat, 7 Sep 2019 14:31:05 +0000 (10:31 -0400)
committerMichael Altizer (mialtize) <mialtize@cisco.com>
Sat, 7 Sep 2019 14:31:05 +0000 (10:31 -0400)
Squashed commit of the following:

commit dada26623785e41c11f66ce9fb24e0bffebba151
Author: Michael Altizer <mialtize@cisco.com>
Date:   Fri Sep 6 10:55:52 2019 -0400

    build: Address miscellaneous cppcheck warnings

commit 48e3dffc6605b916b555134c60fb12e5f131ee1f
Author: Michael Altizer <mialtize@cisco.com>
Date:   Fri Sep 6 10:34:46 2019 -0400

    build: Const-ify reference arguments as suggested by cppcheck

101 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/detection/detection_engine.cc
src/detection/detection_engine.h
src/detection/detection_options.cc
src/detection/detection_options.h
src/file_api/file_log.cc
src/flow/ha.cc
src/flow/stash_item.h
src/framework/lua_api.h
src/host_tracker/test/host_cache_module_test.cc
src/host_tracker/test/host_tracker_module_test.cc
src/host_tracker/test/host_tracker_test.cc
src/ips_options/ips_asn1.cc
src/ips_options/ips_file_type.cc
src/ips_options/ips_replace.cc
src/ips_options/ips_rpc.cc
src/ips_options/ips_sd_pattern.cc
src/ips_options/test/ips_regex_test.cc
src/loggers/alert_csv.cc
src/loggers/alert_fast.cc
src/loggers/alert_json.cc
src/main/control_mgmt.cc
src/main/request.cc
src/main/request.h
src/network_inspectors/appid/appid_api.cc
src/network_inspectors/appid/appid_api.h
src/network_inspectors/appid/appid_debug.h
src/network_inspectors/appid/appid_discovery.cc
src/network_inspectors/appid/appid_session_api.cc
src/network_inspectors/appid/appid_session_api.h
src/network_inspectors/appid/appid_stats.cc
src/network_inspectors/appid/appid_utils/sf_mlmp.cc
src/network_inspectors/appid/detector_plugins/test/detector_plugins_mock.h
src/network_inspectors/appid/service_plugins/service_detector.cc
src/network_inspectors/appid/service_plugins/service_detector.h
src/network_inspectors/appid/test/appid_http_event_test.cc
src/network_inspectors/appid/tp_appid_utils.cc
src/network_inspectors/arp_spoof/arp_spoof.cc
src/network_inspectors/packet_tracer/packet_tracer.h
src/packet_io/trough.cc
src/packet_io/trough.h
src/piglet/piglet_runner.cc
src/search_engines/bnfa_search.cc
src/service_inspectors/dce_rpc/dce_smb.cc
src/service_inspectors/dce_rpc/dce_tcp.cc
src/service_inspectors/dce_rpc/dce_udp.cc
src/service_inspectors/dce_rpc/ips_dce_opnum.cc
src/service_inspectors/dnp3/dnp3.cc
src/service_inspectors/dnp3/dnp3_map.cc
src/service_inspectors/dnp3/dnp3_module.cc
src/service_inspectors/dnp3/dnp3_module.h
src/service_inspectors/dnp3/dnp3_reassembly.cc
src/service_inspectors/dnp3/dnp3_reassembly.h
src/service_inspectors/ftp_telnet/ftp_module.cc
src/service_inspectors/ftp_telnet/ftp_module.h
src/service_inspectors/ftp_telnet/pp_ftp.cc
src/service_inspectors/ftp_telnet/pp_telnet.cc
src/service_inspectors/gtp/ips_gtp_info.cc
src/service_inspectors/http2_inspect/test/http2_flow_data_test.h
src/service_inspectors/http_inspect/http_msg_body.cc
src/service_inspectors/http_inspect/http_msg_body.h
src/service_inspectors/http_inspect/http_msg_section.cc
src/service_inspectors/http_inspect/http_stream_splitter_reassemble.cc
src/service_inspectors/http_inspect/http_uri.cc
src/service_inspectors/http_inspect/http_uri.h
src/service_inspectors/http_inspect/test/http_module_test.cc
src/service_inspectors/http_inspect/test/http_uri_norm_test.cc
src/service_inspectors/rpc_decode/rpc_decode.cc
src/service_inspectors/smtp/smtp.cc
src/service_inspectors/smtp/smtp_module.cc
src/service_inspectors/smtp/smtp_module.h
src/service_inspectors/smtp/smtp_util.cc
src/service_inspectors/wizard/wizard.cc
src/side_channel/test/side_channel_module_test.cc
src/stream/libtcp/tcp_stream_tracker.cc
src/stream/libtcp/tcp_stream_tracker.h
src/stream/paf.cc
src/stream/tcp/tcp_normalizers.cc
src/stream/tcp/tcp_reassembler.cc
src/stream/tcp/tcp_reassembler.h
src/stream/tcp/tcp_segment_node.cc
src/stream/tcp/tcp_segment_node.h
src/stream/tcp/tcp_session.cc
src/stream/tcp/tcp_session.h
src/stream/user/user_session.cc
src/time/packet_time.cc
src/utils/stats.cc
src/utils/stats.h
src/utils/util_ber.cc
src/utils/util_ber.h
src/utils/util_net.cc
src/utils/util_net.h
tools/snort2lua/data/data_types/dt_rule.cc
tools/snort2lua/data/data_types/dt_rule.h
tools/snort2lua/data/data_types/dt_rule_option.h
tools/snort2lua/data/dt_rule_api.cc
tools/snort2lua/data/dt_rule_api.h
tools/snort2lua/data/dt_table_api.h

index 39ee48396b669db0752559acff196d1965cc25d4..bf56116906dbf894b6ee531008f653707c510c34 100644 (file)
@@ -37,8 +37,7 @@ THREAD_LOCAL SimpleStats file_connector_stats;
 THREAD_LOCAL ProfileStats file_connector_perfstats;
 
 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*) { }
+void show_stats(PegCount*, const PegInfo*, const IndexVec&, const char*, FILE*) { }
 
 namespace snort
 {
index ecd6bd0262ab2a63c190fdc758db4a82797c8b0c..17e5f97bb3aeda24c9d0507051c167977d6dd1ec 100644 (file)
@@ -51,8 +51,7 @@ Connector* connector_tb;
 Connector* connector_rb;
 
 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*) { }
+void show_stats(PegCount*, const PegInfo*, const IndexVec&, const char*, FILE*) { }
 
 namespace snort
 {
index 2c4836a71f7a677199766e517666fef7e50a7fbe..510074e443a8efc30463e100a0f2583f5b65149f 100644 (file)
@@ -37,8 +37,7 @@ THREAD_LOCAL SimpleStats tcp_connector_stats;
 THREAD_LOCAL ProfileStats tcp_connector_perfstats;
 
 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*) { }
+void show_stats(PegCount*, const PegInfo*, const IndexVec&, const char*, FILE*) { }
 
 namespace snort
 {
index 2b727a078a9d0bef96a942169fcf9a59722b2e0d..1fa6d9cc33fead8aa6b85df9f963060bef70d407 100644 (file)
@@ -68,8 +68,7 @@ ConnectorCommon* connector_common;
 Connector* connector;
 
 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*) { }
+void show_stats(PegCount*, const PegInfo*, const IndexVec&, const char*, FILE*) { }
 
 namespace snort
 {
index d3afe492ecadfe549006ed1cd09557b7e9acfaf5..2b6ccfb14a0dc9d7afc0d6258046ecc0cf47429e 100644 (file)
@@ -469,7 +469,7 @@ void DetectionEngine::onload()
     }
 }
 
-void DetectionEngine::resume_ready_suspends(IpsContextChain& chain)
+void DetectionEngine::resume_ready_suspends(const IpsContextChain& chain)
 {
     while ( chain.front() and !chain.front()->packet->is_offloaded() )
     {
index b22683d0ccc27d38fca6102c5e9c74590b40b966..4dd5db3e55260377ea3a683eb9f42e62b0f80bd9 100644 (file)
@@ -110,7 +110,7 @@ private:
     static void offload_thread(IpsContext*);
     static void complete(snort::Packet*);
     static void resume(snort::Packet*);
-    static void resume_ready_suspends(IpsContextChain&);
+    static void resume_ready_suspends(const IpsContextChain&);
 
     static int log_events(Packet*);
     static void clear_events(Packet*);
index 8bad4a082d43348880fdf1b0706e4c8d4fca730a..2f8222483f2eb042dc688349c2c765eb15e20631 100644 (file)
@@ -343,7 +343,7 @@ void* add_detection_option_tree(SnortConfig* sc, detection_option_tree_node_t* o
 
 int detection_option_node_evaluate(
     detection_option_tree_node_t* node, detection_option_eval_data_t* eval_data,
-    Cursor& orig_cursor)
+    const Cursor& orig_cursor)
 {
     // need node->state to do perf profiling
     if ( !node )
index 9788c6d474f64ff63d375cfb2f3a561a5a21c4c8..dc742751db82f0bbb062d705551f3c7cb40e9035 100644 (file)
@@ -122,7 +122,7 @@ void* add_detection_option(struct snort::SnortConfig*, option_type_t, void*);
 void* add_detection_option_tree(struct snort::SnortConfig*, detection_option_tree_node_t*);
 
 int detection_option_node_evaluate(
-    detection_option_tree_node_t*, detection_option_eval_data_t*, class Cursor&);
+    detection_option_tree_node_t*, detection_option_eval_data_t*, const class Cursor&);
 
 void DetectionHashTableFree(snort::XHash*);
 void DetectionTreeHashTableFree(snort::XHash*);
index 5eb08341a44f4e57787cef5149e28f42c53d8e56..665f1ebb1107f324a415ec4ad98f31e83fad6566 100644 (file)
@@ -83,7 +83,7 @@ static void dl_tterm()
 class LogHandler : public DataHandler
 {
 public:
-    LogHandler(FileLogConfig& conf) : DataHandler(s_name)
+    LogHandler(const FileLogConfig& conf) : DataHandler(s_name)
     { config = conf; }
 
     void handle(DataEvent&, Flow*) override;
@@ -204,7 +204,7 @@ void LogHandler::handle(DataEvent&, Flow* f)
 class FileLog : public Inspector
 {
 public:
-    FileLog(FileLogConfig& conf) { config = conf; }
+    FileLog(const FileLogConfig& conf) { config = conf; }
 
     void show(SnortConfig*) override;
     void eval(Packet*) override { }
index 1bb8ed7b21cfc96a87560f4bd9224c9d0473c61b..7466b96fa5f32b5bbab12c128c0e052a7728b200 100644 (file)
@@ -230,7 +230,7 @@ FlowHAClient::FlowHAClient(uint8_t length, bool session_client)
 
 // Write the key type, key length, and key into the message.
 // Return the type of key written so it can be stored in the message header.
-static uint8_t write_flow_key(Flow& flow, HAMessage& msg)
+static uint8_t write_flow_key(const Flow& flow, HAMessage& msg)
 {
     const FlowKey* key = flow.key;
     assert(key);
@@ -332,7 +332,7 @@ static uint16_t calculate_update_msg_content_length(Flow& flow, bool full)
 
 // Write the HA header and key sections.  Position the cursor
 // at the beginning of the content section.
-static void write_msg_header(Flow& flow, HAEvent event, uint16_t content_length, HAMessage& msg)
+static void write_msg_header(const Flow& flow, HAEvent event, uint16_t content_length, HAMessage& msg)
 {
     HAMessageHeader* hdr = (HAMessageHeader*) msg.cursor;
     hdr->event = (uint8_t) event;
@@ -342,7 +342,7 @@ static void write_msg_header(Flow& flow, HAEvent event, uint16_t content_length,
     hdr->key_type = write_flow_key(flow, msg);
 }
 
-static uint16_t update_msg_header_length(HAMessage& msg)
+static uint16_t update_msg_header_length(const HAMessage& msg)
 {
     HAMessageHeader* hdr = (HAMessageHeader*) msg.buffer;
     hdr->total_length = msg.cursor_position();
index 52e7618de986dc75e5dde504293e9cb8de54d793..edb6cfb9492aa589623a57d143cb473a98c3e1d6 100644 (file)
@@ -38,7 +38,7 @@ public:
     {
 
     }
-    int get_object_type()
+    int get_object_type() const
     {
         return object_type;
     }
index 8cad6ad1a297c49a83219a6acedbfa368307a29f..83cb9d24d94ba0b8c125cb46e50211b201c76626 100644 (file)
@@ -39,7 +39,7 @@ public:
     std::string chunk;
 
 protected:
-    LuaApi(std::string& s, std::string& c)
+    LuaApi(const std::string& s, const std::string& c)
     {
         name = s;
         chunk = c;
index 501b94d0ccf785444df3fdb1fe842365a75393b9..88956b5876d2dafab437ad1b7782ef70324777b4 100644 (file)
@@ -65,11 +65,8 @@ extern "C"
 const char* luaL_optlstring(lua_State*, int, const char*, size_t*) { return nullptr; }
 }
 
-void show_stats(PegCount*, const PegInfo*, unsigned, const char*)
-{ }
-
-void show_stats(PegCount*, const PegInfo*, IndexVec&, const char*, FILE*)
-{ }
+void show_stats(PegCount*, const PegInfo*, unsigned, const char*) { }
+void show_stats(PegCount*, const PegInfo*, const IndexVec&, const char*, FILE*) { }
 
 TEST_GROUP(host_cache_module)
 {
index 8ba0b2c74f62bc02181545e9d6801faf433f76bd..9b60b8589913aba4652ccd3335e2930ceec9f3a0 100644 (file)
@@ -44,7 +44,7 @@ time_t packet_time() { return 0; }
 
 //  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*) { }
+void show_stats(PegCount*, const PegInfo*, const IndexVec&, const char*, FILE*) { }
 
 SfIp expected_addr;
 
index 5e4b4c25b7c69be043fbefc86119360d4c3a76e5..9ac2b1fe3c43cf38a7bb241cc0204bad4e0fcacb 100644 (file)
@@ -93,7 +93,7 @@ TEST(host_tracker, copy_data_test)
     CHECK(p_last_seen == 1562198400);
     CHECK(p_macs != nullptr);
     CHECK(p_macs->size() == 1);
-    auto& copied_data = p_macs->front();
+    const auto& copied_data = p_macs->front();
     CHECK(copied_data.ttl == 50);
     CHECK(copied_data.primary == 1);
     CHECK(copied_data.last_seen == 1562198400);
index 00b3cee2e507da8d8a4a2046c38adeda4c1504f0..cd15c5704af723e0a5286e8d095a826f77839ee3 100644 (file)
@@ -85,7 +85,7 @@ static THREAD_LOCAL ProfileStats asn1PerfStats;
 class Asn1Option : public IpsOption
 {
 public:
-    Asn1Option(ASN1_CTXT& c) : IpsOption(s_name, RULE_OPTION_TYPE_BUFFER_USE)
+    Asn1Option(const ASN1_CTXT& c) : IpsOption(s_name, RULE_OPTION_TYPE_BUFFER_USE)
     { config = c; }
 
     uint32_t hash() const override;
index 67ed7fa5611e9ca088421958d33a85b05a8b513a..3ca9aad20b53c9913e58bc24f7ae2a0a8c5666e5 100644 (file)
@@ -40,7 +40,7 @@ static THREAD_LOCAL ProfileStats fileTypePerfStats;
 class FileTypeOption : public IpsOption
 {
 public:
-    FileTypeOption(FileTypeBitSet&);
+    FileTypeOption(const FileTypeBitSet&);
 
     uint32_t hash() const override;
     bool operator==(const IpsOption& ips) const override;
@@ -57,7 +57,7 @@ public:
 // class methods
 //-------------------------------------------------------------------------
 
-FileTypeOption::FileTypeOption(FileTypeBitSet& t) : IpsOption(s_name)
+FileTypeOption::FileTypeOption(const FileTypeBitSet& t) : IpsOption(s_name)
 {
     types = t;
 }
index 712f6841b6aa0a0bca5f1ddd31d1da2e4fa65a29..3103bf9131d620d693724ed6e783902b161bf0ab 100644 (file)
@@ -77,7 +77,7 @@ static THREAD_LOCAL ProfileStats replacePerfStats;
 class ReplaceOption : public IpsOption
 {
 public:
-    ReplaceOption(string&);
+    ReplaceOption(const string&);
     ~ReplaceOption() override;
 
     EvalStatus eval(Cursor&, Packet*) override;
@@ -106,7 +106,7 @@ private:
     int* offset; /* >=0 is offset to start of replace */
 };
 
-ReplaceOption::ReplaceOption(string& s) : IpsOption(s_name)
+ReplaceOption::ReplaceOption(const string& s) : IpsOption(s_name)
 {
     unsigned n = ThreadConfig::get_instance_max();
     offset = new int[n];
index 4cf3f062bc144e7287972e3d6a23b4fd02721fff..7f878549884e834b1e2b72eb4c794da0706e2067 100644 (file)
@@ -251,7 +251,7 @@ public:
     ProfileStats* get_profile() const override
     { return &rpcCheckPerfStats; }
 
-    bool set(Value&, uint32_t& field, int flag);
+    bool set(const Value&, uint32_t& field, int flag);
 
     Usage get_usage() const override
     { return DETECT; }
@@ -283,7 +283,7 @@ bool RpcModule::set(const char*, Value& v, SnortConfig*)
     return true;
 }
 
-bool RpcModule::set(Value& v, uint32_t& field, int flag)
+bool RpcModule::set(const Value& v, uint32_t& field, int flag)
 {
     if ( flag and !strcmp(v.get_string(), "*") )
         return true;
index fd93c868cfbb94b76f6e730103b112f540e60545..41cb69156fd299a9eb8b446d5026cd6498846335 100644 (file)
@@ -126,7 +126,7 @@ public:
     EvalStatus eval(Cursor&, Packet* p) override;
 
 private:
-    unsigned SdSearch(Cursor&, Packet*);
+    unsigned SdSearch(const Cursor&, Packet*);
     SdPatternConfig config;
 };
 
@@ -243,7 +243,7 @@ static int hs_match(unsigned int /*id*/, unsigned long long from,
     return 0;
 }
 
-unsigned SdPatternOption::SdSearch(Cursor& c, Packet* p)
+unsigned SdPatternOption::SdSearch(const Cursor& c, Packet* p)
 {
     const uint8_t* const start = c.buffer();
     const uint8_t* buf = c.start();
index 8ea290f752c6662b3d26dd08c7a32f5ad3da59a5..ed5e9ed6cbf41b30d7c4237f230681eb1582e609 100644 (file)
@@ -101,7 +101,7 @@ 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*) { }
+void show_stats(PegCount*, const PegInfo*, const IndexVec&, const char*, FILE*) { }
 
 //-------------------------------------------------------------------------
 // helpers
index 92c4a2085664a5975922882b1a3dbb2a3ed00fee..0bd5578865b0c5385c7730e077f0132967bfd90d 100644 (file)
@@ -69,12 +69,12 @@ struct Args
     const Event& event;
 };
 
-static void ff_action(Args& a)
+static void ff_action(const Args& a)
 {
     TextLog_Puts(csv_log, a.pkt->active->get_action_string());
 }
 
-static void ff_class(Args& a)
+static void ff_class(const Args& a)
 {
     const char* cls = "none";
     if ( a.event.sig_info->class_type and a.event.sig_info->class_type->name )
@@ -82,7 +82,7 @@ static void ff_class(Args& a)
     TextLog_Puts(csv_log, cls);
 }
 
-static void ff_b64_data(Args& a)
+static void ff_b64_data(const Args& a)
 {
     const unsigned block_size = 2048;
     char out[2*block_size];
@@ -107,7 +107,7 @@ static void ff_b64_data(Args& a)
     TextLog_Putc(csv_log, '"');
 }
 
-static void ff_dir(Args& a)
+static void ff_dir(const Args& a)
 {
     const char* dir;
 
@@ -121,7 +121,7 @@ static void ff_dir(Args& a)
     TextLog_Puts(csv_log, dir);
 }
 
-static void ff_dst_addr(Args& a)
+static void ff_dst_addr(const Args& a)
 {
     if ( a.pkt->has_ip() or a.pkt->is_data() )
     {
@@ -130,7 +130,7 @@ static void ff_dst_addr(Args& a)
     }
 }
 
-static void ff_dst_ap(Args& a)
+static void ff_dst_ap(const Args& a)
 {
     SfIpString addr = "";
     unsigned port = 0;
@@ -144,13 +144,13 @@ static void ff_dst_ap(Args& a)
     TextLog_Print(csv_log, "%s:%u", addr, port);
 }
 
-static void ff_dst_port(Args& a)
+static void ff_dst_port(const Args& a)
 {
     if ( a.pkt->proto_bits & (PROTO_BIT__TCP|PROTO_BIT__UDP) )
         TextLog_Print(csv_log, "%u", a.pkt->ptrs.dp);
 }
 
-static void ff_eth_dst(Args& a)
+static void ff_eth_dst(const Args& a)
 {
     if ( !(a.pkt->proto_bits & PROTO_BIT__ETH) )
         return;
@@ -162,7 +162,7 @@ static void ff_eth_dst(Args& a)
         eh->ether_dst[4], eh->ether_dst[5]);
 }
 
-static void ff_eth_len(Args& a)
+static void ff_eth_len(const Args& a)
 {
     if ( !(a.pkt->proto_bits & PROTO_BIT__ETH) )
         return;
@@ -170,7 +170,7 @@ static void ff_eth_len(Args& a)
     TextLog_Print(csv_log, "%u", a.pkt->pkth->pktlen);
 }
 
-static void ff_eth_src(Args& a)
+static void ff_eth_src(const Args& a)
 {
     if ( !(a.pkt->proto_bits & PROTO_BIT__ETH) )
         return;
@@ -182,7 +182,7 @@ static void ff_eth_src(Args& a)
         eh->ether_src[4], eh->ether_src[5]);
 }
 
-static void ff_eth_type(Args& a)
+static void ff_eth_type(const Args& a)
 {
     if ( !(a.pkt->proto_bits & PROTO_BIT__ETH) )
         return;
@@ -191,58 +191,58 @@ static void ff_eth_type(Args& a)
     TextLog_Print(csv_log, "0x%X", ntohs(eh->ether_type));
 }
 
-static void ff_gid(Args& a)
+static void ff_gid(const Args& a)
 {
     TextLog_Print(csv_log, "%u",  a.event.sig_info->gid);
 }
 
-static void ff_icmp_code(Args& a)
+static void ff_icmp_code(const Args& a)
 {
     if (a.pkt->ptrs.icmph )
         TextLog_Print(csv_log, "%u", a.pkt->ptrs.icmph->code);
 }
 
-static void ff_icmp_id(Args& a)
+static void ff_icmp_id(const Args& a)
 {
     if (a.pkt->ptrs.icmph )
         TextLog_Print(csv_log, "%u", ntohs(a.pkt->ptrs.icmph->s_icmp_id));
 }
 
-static void ff_icmp_seq(Args& a)
+static void ff_icmp_seq(const Args& a)
 {
     if (a.pkt->ptrs.icmph )
         TextLog_Print(csv_log, "%u", ntohs(a.pkt->ptrs.icmph->s_icmp_seq));
 }
 
-static void ff_icmp_type(Args& a)
+static void ff_icmp_type(const Args& a)
 {
     if (a.pkt->ptrs.icmph )
         TextLog_Print(csv_log, "%u", a.pkt->ptrs.icmph->type);
 }
 
-static void ff_iface(Args&)
+static void ff_iface(const Args&)
 {
     TextLog_Print(csv_log, "%s", SFDAQ::get_input_spec());
 }
 
-static void ff_ip_id(Args& a)
+static void ff_ip_id(const Args& a)
 {
     if (a.pkt->has_ip())
         TextLog_Print(csv_log, "%u", a.pkt->ptrs.ip_api.id());
 }
 
-static void ff_ip_len(Args& a)
+static void ff_ip_len(const Args& a)
 {
     if (a.pkt->has_ip())
         TextLog_Print(csv_log, "%u", a.pkt->ptrs.ip_api.pay_len());
 }
 
-static void ff_msg(Args& a)
+static void ff_msg(const Args& a)
 {
     TextLog_Puts(csv_log, a.msg);
 }
 
-static void ff_mpls(Args& a)
+static void ff_mpls(const Args& a)
 {
     uint32_t mpls;
 
@@ -258,12 +258,12 @@ static void ff_mpls(Args& a)
     TextLog_Print(csv_log, "%u", ntohl(mpls));
 }
 
-static void ff_pkt_gen(Args& a)
+static void ff_pkt_gen(const Args& a)
 {
     TextLog_Puts(csv_log, a.pkt->get_pseudo_type());
 }
 
-static void ff_pkt_len(Args& a)
+static void ff_pkt_len(const Args& a)
 {
     if (a.pkt->has_ip())
         TextLog_Print(csv_log, "%u", a.pkt->ptrs.ip_api.dgram_len());
@@ -271,38 +271,38 @@ static void ff_pkt_len(Args& a)
         TextLog_Print(csv_log, "%u", a.pkt->dsize);
 }
 
-static void ff_pkt_num(Args& a)
+static void ff_pkt_num(const Args& a)
 {
     TextLog_Print(csv_log, STDu64, a.pkt->context->packet_number);
 }
 
-static void ff_priority(Args& a)
+static void ff_priority(const Args& a)
 {
     TextLog_Print(csv_log, "%u", a.event.sig_info->priority);
 }
 
-static void ff_proto(Args& a)
+static void ff_proto(const Args& a)
 {
     TextLog_Puts(csv_log, a.pkt->get_type());
 }
 
-static void ff_rev(Args& a)
+static void ff_rev(const Args& a)
 {
     TextLog_Print(csv_log, "%u",  a.event.sig_info->rev);
 }
 
-static void ff_rule(Args& a)
+static void ff_rule(const Args& a)
 {
     TextLog_Print(csv_log, "%u:%u:%u",
         a.event.sig_info->gid, a.event.sig_info->sid, a.event.sig_info->rev);
 }
 
-static void ff_seconds(Args& a)
+static void ff_seconds(const Args& a)
 {
     TextLog_Print(csv_log, "%u",  a.pkt->pkth->ts.tv_sec);
 }
 
-static void ff_service(Args& a)
+static void ff_service(const Args& a)
 {
     const char* svc = "unknown";
     if ( a.pkt->flow and a.pkt->flow->service )
@@ -310,12 +310,12 @@ static void ff_service(Args& a)
     TextLog_Puts(csv_log, svc);
 }
 
-static void ff_sid(Args& a)
+static void ff_sid(const Args& a)
 {
     TextLog_Print(csv_log, "%u",  a.event.sig_info->sid);
 }
 
-static void ff_src_addr(Args& a)
+static void ff_src_addr(const Args& a)
 {
     if ( a.pkt->has_ip() or a.pkt->is_data() )
     {
@@ -324,7 +324,7 @@ static void ff_src_addr(Args& a)
     }
 }
 
-static void ff_src_ap(Args& a)
+static void ff_src_ap(const Args& a)
 {
     SfIpString addr = "";
     unsigned port = 0;
@@ -338,13 +338,13 @@ static void ff_src_ap(Args& a)
     TextLog_Print(csv_log, "%s:%u", addr, port);
 }
 
-static void ff_src_port(Args& a)
+static void ff_src_port(const Args& a)
 {
     if ( a.pkt->proto_bits & (PROTO_BIT__TCP|PROTO_BIT__UDP) )
         TextLog_Print(csv_log, "%u", a.pkt->ptrs.sp);
 }
 
-static void ff_target(Args& a)
+static void ff_target(const Args& a)
 {
     SfIpString addr = "";
 
@@ -360,13 +360,13 @@ static void ff_target(Args& a)
     TextLog_Print(csv_log, "%s", addr);
 }
 
-static void ff_tcp_ack(Args& a)
+static void ff_tcp_ack(const Args& a)
 {
     if (a.pkt->ptrs.tcph )
         TextLog_Print(csv_log, "0x%lX", (u_long)ntohl(a.pkt->ptrs.tcph->th_ack));
 }
 
-static void ff_tcp_flags(Args& a)
+static void ff_tcp_flags(const Args& a)
 {
     if (a.pkt->ptrs.tcph )
     {
@@ -376,48 +376,48 @@ static void ff_tcp_flags(Args& a)
     }
 }
 
-static void ff_tcp_len(Args& a)
+static void ff_tcp_len(const Args& a)
 {
     if (a.pkt->ptrs.tcph )
         TextLog_Print(csv_log, "%u", (a.pkt->ptrs.tcph->off()));
 }
 
-static void ff_tcp_seq(Args& a)
+static void ff_tcp_seq(const Args& a)
 {
     if (a.pkt->ptrs.tcph )
         TextLog_Print(csv_log, "0x%lX", (u_long)ntohl(a.pkt->ptrs.tcph->th_seq));
 }
 
-static void ff_tcp_win(Args& a)
+static void ff_tcp_win(const Args& a)
 {
     if (a.pkt->ptrs.tcph )
         TextLog_Print(csv_log, "0x%X", ntohs(a.pkt->ptrs.tcph->th_win));
 }
 
-static void ff_timestamp(Args& a)
+static void ff_timestamp(const Args& a)
 {
     LogTimeStamp(csv_log, a.pkt);
 }
 
-static void ff_tos(Args& a)
+static void ff_tos(const Args& a)
 {
     if (a.pkt->has_ip())
         TextLog_Print(csv_log, "%u", a.pkt->ptrs.ip_api.tos());
 }
 
-static void ff_ttl(Args& a)
+static void ff_ttl(const Args& a)
 {
     if (a.pkt->has_ip())
         TextLog_Print(csv_log, "%u",a.pkt->ptrs.ip_api.ttl());
 }
 
-static void ff_udp_len(Args& a)
+static void ff_udp_len(const Args& a)
 {
     if (a.pkt->ptrs.udph )
         TextLog_Print(csv_log, "%u", ntohs(a.pkt->ptrs.udph->uh_len));
 }
 
-static void ff_vlan(Args& a)
+static void ff_vlan(const Args& a)
 {
     uint16_t vid;
 
@@ -437,7 +437,7 @@ static void ff_vlan(Args& a)
 // module stuff
 //-------------------------------------------------------------------------
 
-typedef void (*CsvFunc)(Args&);
+typedef void (*CsvFunc)(const Args&);
 
 static const CsvFunc csv_func[] =
 {
index 39da8279ea09d07add14c37fc71b85eda9ad5cfc..af2085241246eb50e043717e156516b97f920868 100644 (file)
@@ -135,7 +135,7 @@ bool FastModule::begin(const char*, int, SnortConfig*)
 // helper
 
 static void load_buf_ids(
-    Inspector* ins, std::vector<const char*>& keys, std::vector<unsigned>& ids)
+    Inspector* ins, const std::vector<const char*>& keys, std::vector<unsigned>& ids)
 {
     for ( auto key : keys )
     {
index b5cb461237e2d8c3c34bcb67f63767455333ee67..aeb24409b6800ab90bbf8b2d82b462bb9454f6e5 100644 (file)
@@ -71,7 +71,7 @@ struct Args
     bool comma;
 };
 
-static void print_label(Args& a, const char* label)
+static void print_label(const Args& a, const char* label)
 {
     if ( a.comma )
         TextLog_Print(json_log, ",");
@@ -79,14 +79,14 @@ static void print_label(Args& a, const char* label)
     TextLog_Print(json_log, " \"%s\" : ", label);
 }
 
-static bool ff_action(Args& a)
+static bool ff_action(const Args& a)
 {
     print_label(a, "action");
     TextLog_Quote(json_log, a.pkt->active->get_action_string());
     return true;
 }
 
-static bool ff_class(Args& a)
+static bool ff_class(const Args& a)
 {
     const char* cls = "none";
 
@@ -98,7 +98,7 @@ static bool ff_class(Args& a)
     return true;
 }
 
-static bool ff_b64_data(Args& a)
+static bool ff_b64_data(const Args& a)
 {
     if ( !a.pkt->dsize )
         return false;
@@ -128,7 +128,7 @@ static bool ff_b64_data(Args& a)
     return true;
 }
 
-static bool ff_dir(Args& a)
+static bool ff_dir(const Args& a)
 {
     const char* dir;
 
@@ -144,7 +144,7 @@ static bool ff_dir(Args& a)
     return true;
 }
 
-static bool ff_dst_addr(Args& a)
+static bool ff_dst_addr(const Args& a)
 {
     if ( a.pkt->has_ip() or a.pkt->is_data() )
     {
@@ -156,7 +156,7 @@ static bool ff_dst_addr(Args& a)
     return false;
 }
 
-static bool ff_dst_ap(Args& a)
+static bool ff_dst_ap(const Args& a)
 {
     SfIpString addr = "";
     unsigned port = 0;
@@ -172,7 +172,7 @@ static bool ff_dst_ap(Args& a)
     return true;
 }
 
-static bool ff_dst_port(Args& a)
+static bool ff_dst_port(const Args& a)
 {
     if ( a.pkt->proto_bits & (PROTO_BIT__TCP|PROTO_BIT__UDP) )
     {
@@ -183,7 +183,7 @@ static bool ff_dst_port(Args& a)
     return false;
 }
 
-static bool ff_eth_dst(Args& a)
+static bool ff_eth_dst(const Args& a)
 {
     if ( !(a.pkt->proto_bits & PROTO_BIT__ETH) )
         return false;
@@ -198,7 +198,7 @@ static bool ff_eth_dst(Args& a)
     return true;
 }
 
-static bool ff_eth_len(Args& a)
+static bool ff_eth_len(const Args& a)
 {
     if ( !(a.pkt->proto_bits & PROTO_BIT__ETH) )
         return false;
@@ -208,7 +208,7 @@ static bool ff_eth_len(Args& a)
     return true;
 }
 
-static bool ff_eth_src(Args& a)
+static bool ff_eth_src(const Args& a)
 {
     if ( !(a.pkt->proto_bits & PROTO_BIT__ETH) )
         return false;
@@ -222,7 +222,7 @@ static bool ff_eth_src(Args& a)
     return true;
 }
 
-static bool ff_eth_type(Args& a)
+static bool ff_eth_type(const Args& a)
 {
     if ( !(a.pkt->proto_bits & PROTO_BIT__ETH) )
         return false;
@@ -234,14 +234,14 @@ static bool ff_eth_type(Args& a)
     return true;
 }
 
-static bool ff_gid(Args& a)
+static bool ff_gid(const Args& a)
 {
     print_label(a, "gid");
     TextLog_Print(json_log, "%u",  a.event.sig_info->gid);
     return true;
 }
 
-static bool ff_icmp_code(Args& a)
+static bool ff_icmp_code(const Args& a)
 {
     if (a.pkt->ptrs.icmph )
     {
@@ -252,7 +252,7 @@ static bool ff_icmp_code(Args& a)
     return false;
 }
 
-static bool ff_icmp_id(Args& a)
+static bool ff_icmp_id(const Args& a)
 {
     if (a.pkt->ptrs.icmph )
     {
@@ -263,7 +263,7 @@ static bool ff_icmp_id(Args& a)
     return false;
 }
 
-static bool ff_icmp_seq(Args& a)
+static bool ff_icmp_seq(const Args& a)
 {
     if (a.pkt->ptrs.icmph )
     {
@@ -274,7 +274,7 @@ static bool ff_icmp_seq(Args& a)
     return false;
 }
 
-static bool ff_icmp_type(Args& a)
+static bool ff_icmp_type(const Args& a)
 {
     if (a.pkt->ptrs.icmph )
     {
@@ -285,14 +285,14 @@ static bool ff_icmp_type(Args& a)
     return false;
 }
 
-static bool ff_iface(Args& a)
+static bool ff_iface(const Args& a)
 {
     print_label(a, "iface");
     TextLog_Quote(json_log, SFDAQ::get_input_spec());
     return true;
 }
 
-static bool ff_ip_id(Args& a)
+static bool ff_ip_id(const Args& a)
 {
     if (a.pkt->has_ip())
     {
@@ -303,7 +303,7 @@ static bool ff_ip_id(Args& a)
     return false;
 }
 
-static bool ff_ip_len(Args& a)
+static bool ff_ip_len(const Args& a)
 {
     if (a.pkt->has_ip())
     {
@@ -314,14 +314,14 @@ static bool ff_ip_len(Args& a)
     return false;
 }
 
-static bool ff_msg(Args& a)
+static bool ff_msg(const Args& a)
 {
     print_label(a, "msg");
     TextLog_Puts(json_log, a.msg);
     return true;
 }
 
-static bool ff_mpls(Args& a)
+static bool ff_mpls(const Args& a)
 {
     uint32_t mpls;
 
@@ -339,14 +339,14 @@ static bool ff_mpls(Args& a)
     return true;
 }
 
-static bool ff_pkt_gen(Args& a)
+static bool ff_pkt_gen(const Args& a)
 {
     print_label(a, "pkt_gen");
     TextLog_Quote(json_log, a.pkt->get_pseudo_type());
     return true;
 }
 
-static bool ff_pkt_len(Args& a)
+static bool ff_pkt_len(const Args& a)
 {
     print_label(a, "pkt_len");
 
@@ -358,35 +358,35 @@ static bool ff_pkt_len(Args& a)
     return true;
 }
 
-static bool ff_pkt_num(Args& a)
+static bool ff_pkt_num(const Args& a)
 {
     print_label(a, "pkt_num");
     TextLog_Print(json_log, STDu64, a.pkt->context->packet_number);
     return true;
 }
 
-static bool ff_priority(Args& a)
+static bool ff_priority(const Args& a)
 {
     print_label(a, "priority");
     TextLog_Print(json_log, "%u", a.event.sig_info->priority);
     return true;
 }
 
-static bool ff_proto(Args& a)
+static bool ff_proto(const Args& a)
 {
     print_label(a, "proto");
     TextLog_Quote(json_log, a.pkt->get_type());
     return true;
 }
 
-static bool ff_rev(Args& a)
+static bool ff_rev(const Args& a)
 {
     print_label(a, "rev");
     TextLog_Print(json_log, "%u",  a.event.sig_info->rev);
     return true;
 }
 
-static bool ff_rule(Args& a)
+static bool ff_rule(const Args& a)
 {
     print_label(a, "rule");
 
@@ -396,14 +396,14 @@ static bool ff_rule(Args& a)
     return true;
 }
 
-static bool ff_seconds(Args& a)
+static bool ff_seconds(const Args& a)
 {
     print_label(a, "seconds");
     TextLog_Print(json_log, "%u",  a.pkt->pkth->ts.tv_sec);
     return true;
 }
 
-static bool ff_service(Args& a)
+static bool ff_service(const Args& a)
 {
     const char* svc = "unknown";
 
@@ -415,14 +415,14 @@ static bool ff_service(Args& a)
     return true;
 }
 
-static bool ff_sid(Args& a)
+static bool ff_sid(const Args& a)
 {
     print_label(a, "sid");
     TextLog_Print(json_log, "%u",  a.event.sig_info->sid);
     return true;
 }
 
-static bool ff_src_addr(Args& a)
+static bool ff_src_addr(const Args& a)
 {
     if ( a.pkt->has_ip() or a.pkt->is_data() )
     {
@@ -434,7 +434,7 @@ static bool ff_src_addr(Args& a)
     return false;
 }
 
-static bool ff_src_ap(Args& a)
+static bool ff_src_ap(const Args& a)
 {
     SfIpString addr = "";
     unsigned port = 0;
@@ -450,7 +450,7 @@ static bool ff_src_ap(Args& a)
     return true;
 }
 
-static bool ff_src_port(Args& a)
+static bool ff_src_port(const Args& a)
 {
     if ( a.pkt->proto_bits & (PROTO_BIT__TCP|PROTO_BIT__UDP) )
     {
@@ -461,7 +461,7 @@ static bool ff_src_port(Args& a)
     return false;
 }
 
-static bool ff_target(Args& a)
+static bool ff_target(const Args& a)
 {
     SfIpString addr = "";
 
@@ -479,7 +479,7 @@ static bool ff_target(Args& a)
     return true;
 }
 
-static bool ff_tcp_ack(Args& a)
+static bool ff_tcp_ack(const Args& a)
 {
     if (a.pkt->ptrs.tcph )
     {
@@ -490,7 +490,7 @@ static bool ff_tcp_ack(Args& a)
     return false;
 }
 
-static bool ff_tcp_flags(Args& a)
+static bool ff_tcp_flags(const Args& a)
 {
     if (a.pkt->ptrs.tcph )
     {
@@ -504,7 +504,7 @@ static bool ff_tcp_flags(Args& a)
     return false;
 }
 
-static bool ff_tcp_len(Args& a)
+static bool ff_tcp_len(const Args& a)
 {
     if (a.pkt->ptrs.tcph )
     {
@@ -515,7 +515,7 @@ static bool ff_tcp_len(Args& a)
     return false;
 }
 
-static bool ff_tcp_seq(Args& a)
+static bool ff_tcp_seq(const Args& a)
 {
     if (a.pkt->ptrs.tcph )
     {
@@ -526,7 +526,7 @@ static bool ff_tcp_seq(Args& a)
     return false;
 }
 
-static bool ff_tcp_win(Args& a)
+static bool ff_tcp_win(const Args& a)
 {
     if (a.pkt->ptrs.tcph )
     {
@@ -537,7 +537,7 @@ static bool ff_tcp_win(Args& a)
     return false;
 }
 
-static bool ff_timestamp(Args& a)
+static bool ff_timestamp(const Args& a)
 {
     print_label(a, "timestamp");
     TextLog_Putc(json_log, '"');
@@ -546,7 +546,7 @@ static bool ff_timestamp(Args& a)
     return true;
 }
 
-static bool ff_tos(Args& a)
+static bool ff_tos(const Args& a)
 {
     if (a.pkt->has_ip())
     {
@@ -557,7 +557,7 @@ static bool ff_tos(Args& a)
     return false;
 }
 
-static bool ff_ttl(Args& a)
+static bool ff_ttl(const Args& a)
 {
     if (a.pkt->has_ip())
     {
@@ -568,7 +568,7 @@ static bool ff_ttl(Args& a)
     return false;
 }
 
-static bool ff_udp_len(Args& a)
+static bool ff_udp_len(const Args& a)
 {
     if (a.pkt->ptrs.udph )
     {
@@ -579,7 +579,7 @@ static bool ff_udp_len(Args& a)
     return false;
 }
 
-static bool ff_vlan(Args& a)
+static bool ff_vlan(const Args& a)
 {
     uint16_t vid;
 
@@ -601,7 +601,7 @@ static bool ff_vlan(Args& a)
 // module stuff
 //-------------------------------------------------------------------------
 
-typedef bool (*JsonFunc)(Args&);
+typedef bool (*JsonFunc)(const Args&);
 
 static const JsonFunc json_func[] =
 {
index fd28396aa6a83c6cde86ce1f3fb5aa7d99d1f8cb..47c21843b32d5484e0ff123fdd98c85099123cd9 100644 (file)
@@ -181,26 +181,25 @@ int ControlMgmt::socket_term()
 
 bool ControlMgmt::process_control_commands(int& current_fd, Request*& current_request, int evnt_fd)
 {
-    bool ret = false;
     auto control_conn = controls.find(evnt_fd);
 
     if (control_conn == controls.end())
-        return ret;
+        return false;
 
     Request* old_request = current_request;
     int fd = control_conn->second->shell_execute(current_fd, current_request);
     current_fd = -1;
     current_request = old_request;
 
-    if (fd >= 0)
-    {
-        if (control_conn->second->is_local_control())
-             proc_stats.local_commands++;
-        else
-             proc_stats.remote_commands++;
-        ret = true;
-    }
-    return ret;
+    if (fd < 0)
+        return false;
+
+    if (control_conn->second->is_local_control())
+        proc_stats.local_commands++;
+    else
+        proc_stats.remote_commands++;
+
+    return true;
 }
 
 bool ControlMgmt::service_users(int& current_fd, Request*& current_request)
index b6f7fa389901e7482c014404d290f756b4c8ec81..fb3fecee8a0b474c6a3de6d4435f8a8e3c5e343c 100644 (file)
@@ -36,7 +36,7 @@ Request::Request(int f)
     bytes_read = 0;
 }
 
-bool Request::read(int& f)
+bool Request::read(const int& f)
 {
     bool newline_found = false;
     char buf;
index 1d83f1e09ae00a2cd8c2d0e5121f17a9a6701415..7a191ce33e21c699cf872901d2670033767eb852 100644 (file)
@@ -29,7 +29,7 @@ class Request
 public:
     Request(int f = -1);
 
-    bool read(int&);
+    bool read(const int&);
     const char* get() { return read_buf; }
     bool write_response(const char* s) const;
     void respond(const char* s, bool queue_response = false, bool remote_only = false);
index b4d3629b8eb5dc5c1a0aef851952fbcc131c098e..ea43658f4af04f4b9eb8256cb3ece25cc4561182 100644 (file)
@@ -44,7 +44,7 @@ namespace snort
 AppIdApi appid_api;
 }
 
-AppIdSession* AppIdApi::get_appid_session(Flow& flow)
+AppIdSession* AppIdApi::get_appid_session(const Flow& flow)
 {
     AppIdSession* asd = (AppIdSession*)flow.get_flow_data(AppIdSession::inspector_id);
 
@@ -56,7 +56,7 @@ const char* AppIdApi::get_application_name(AppId app_id)
     return AppInfoManager::get_instance().get_app_name(app_id);
 }
 
-const char* AppIdApi::get_application_name(Flow& flow, bool from_client)
+const char* AppIdApi::get_application_name(const Flow& flow, bool from_client)
 {
     const char* app_name = nullptr;
     AppId appid = APP_ID_NONE;
@@ -95,7 +95,7 @@ AppId AppIdApi::get_application_id(const char* appName)
 #define APPID_HA_FLAGS_SVC_DONE ( 1 << 2 )
 #define APPID_HA_FLAGS_HTTP ( 1 << 3 )
 
-uint32_t AppIdApi::produce_ha_state(Flow& flow, uint8_t* buf)
+uint32_t AppIdApi::produce_ha_state(const Flow& flow, uint8_t* buf)
 {
     assert(buf);
     AppIdSessionHA* appHA = (AppIdSessionHA*)buf;
@@ -223,7 +223,7 @@ bool AppIdApi::ssl_app_group_id_lookup(Flow* flow, const char* server_name, cons
     return false;
 }
 
-AppIdSessionApi* AppIdApi::create_appid_session_api(Flow& flow)
+AppIdSessionApi* AppIdApi::create_appid_session_api(const Flow& flow)
 {
     AppIdSession* asd = (AppIdSession*)flow.get_flow_data(AppIdSession::inspector_id);
 
index e5b6aa1f7eef0044f9d1423b9b945f8e16133e00..d883645ee6b67972a0bbf8f23688279d00f7723f 100644 (file)
@@ -51,15 +51,15 @@ class SO_PUBLIC AppIdApi
 public:
     SO_PRIVATE AppIdApi() = default;
 
-    AppIdSession* get_appid_session(Flow& flow);
+    AppIdSession* get_appid_session(const Flow& flow);
     const char* get_application_name(AppId app_id);
-    const char* get_application_name(Flow& flow, bool from_client);
+    const char* get_application_name(const Flow& flow, bool from_client);
     AppId get_application_id(const char* appName);
-    uint32_t produce_ha_state(Flow& flow, uint8_t* buf);
+    uint32_t produce_ha_state(const Flow& flow, uint8_t* buf);
     uint32_t consume_ha_state(Flow& flow, const uint8_t* buf, uint8_t length, IpProtocol,
         SfIp*, uint16_t initiatorPort);
     bool ssl_app_group_id_lookup(Flow* flow, const char*, const char*, AppId& service_id, AppId& client_id, AppId& payload_id);
-    AppIdSessionApi* create_appid_session_api(Flow& flow);
+    AppIdSessionApi* create_appid_session_api(const Flow& flow);
     void free_appid_session_api(AppIdSessionApi* api);
 };
 
index 4163e163f966200264282502631377c7dc6e5f8a..c33c9a86b5f163e41781886bf540f0b7abad7b71 100644 (file)
@@ -48,15 +48,15 @@ struct AppIdDebugSessionConstraints
     uint16_t sport;
     uint16_t dport;
     IpProtocol protocol = IpProtocol::PROTO_NOT_SET;
-    bool proto_match(IpProtocol& proto)
+    bool proto_match(IpProtocol proto) const
     {
         return (protocol == IpProtocol::PROTO_NOT_SET or protocol == proto);
     }
-    bool port_match(uint16_t p1, uint16_t p2)
+    bool port_match(uint16_t p1, uint16_t p2) const
     {
         return (!sport or sport == p1) and (!dport or dport == p2);
     }
-    bool ip_match(const uint32_t* ip1, const uint32_t* ip2)
+    bool ip_match(const uint32_t* ip1, const uint32_t* ip2) const
     {
         return
             ((!sip_flag or !memcmp(sip.get_ip6_ptr(), ip1, sizeof(snort::ip::snort_in6_addr))) and
index 79dbfff1277405c26c55a98fa5769c01b85dc975..fb0d0d378d15a58aa71fc7df594e1e0b7bc7bece 100644 (file)
@@ -408,7 +408,7 @@ static bool is_packet_ignored(AppIdSession* asd, Packet* p, AppidSessionDirectio
     return false;
 }
 
-static uint64_t is_session_monitored(AppIdSession& asd, const Packet* p, AppidSessionDirection dir,
+static uint64_t is_session_monitored(const AppIdSession& asd, const Packet* p, AppidSessionDirection dir,
     AppIdInspector& inspector)
 {
     uint64_t flags;
index ed29050ea1debd8442bfc85c09334d9b976c2a4c..5215d2185a5e0c78fa290f9aa52fee1590156925 100644 (file)
@@ -33,7 +33,7 @@
 
 using namespace snort;
 
-bool AppIdSessionApi::refresh(Flow& flow)
+bool AppIdSessionApi::refresh(const Flow& flow)
 {
     AppIdSession* new_asd = (AppIdSession*)flow.get_flow_data(AppIdSession::inspector_id);
 
index 4b374502bf17fb53c7b7d56fec0607d23e486ac3..fa28960e4bc4e8791cec497a820131c24bf0e471 100644 (file)
@@ -155,7 +155,7 @@ class SO_PUBLIC AppIdSessionApi
 {
 public:
     AppIdSessionApi(AppIdSession* asd) : asd(asd) {}
-    bool refresh(Flow& flow);
+    bool refresh(const Flow& flow);
     AppId get_service_app_id();
     AppId get_port_service_app_id();
     AppId get_only_service_app_id();
index e96704d9005894c86e04924e0dba75e225530d31..91c9664cd0586bbb4a033f750e49376c8e0b829f 100644 (file)
@@ -229,7 +229,7 @@ AppIdStatistics* AppIdStatistics::get_stats_manager()
 void AppIdStatistics::cleanup()
 { delete appid_stats_manager; }
 
-static void update_stats(AppIdSession& asd, AppId app_id, StatsBucket* bucket)
+static void update_stats(const AppIdSession& asd, AppId app_id, StatsBucket* bucket)
 {
     AppIdStatRecord* record = (AppIdStatRecord*)(fwAvlLookup(app_id, bucket->appsTree));
     if ( !record )
index 9551932e4b99c18d5b08c16270cc9d1bc0533cd5..a6f0e6dd27153a4ebf79085122068b54666a75ef 100644 (file)
@@ -440,7 +440,7 @@ static int addPatternRecursively(tMlmpTree* rootNode, const tMlmpPattern* inputP
     tPatternNode* newNode;
     tPatternPrimaryNode* prevPrimaryPatternNode = nullptr;
     tPatternPrimaryNode* primaryNode = nullptr;
-    const tMlmpPattern* patterns = inputPatternList;
+    const tMlmpPattern* patterns;
     uint32_t partTotal = 0;
     uint32_t i;
 
index 3ee0f460aab3b31a53fe576a7d2cb69860b16064..0c3bb6f17d3318bf72a265bfaad0a4374854d9fa 100644 (file)
@@ -84,8 +84,7 @@ char* snort_strdup(const char* str)
 }
 
 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*) { }
+void show_stats(PegCount*, const PegInfo*, const IndexVec&, const char*, FILE*) { }
 
 class AppIdInspector : public snort::Inspector
 {
index d7c7266d3466a9a9aa6c6559d15bace4d292f183..4e25521efa29525eb7c30ca04ba0762be8d5dac2 100644 (file)
@@ -176,7 +176,7 @@ int ServiceDetector::fail_service(AppIdSession& asd, const Packet* pkt, AppidSes
     return static_cast<ServiceDiscovery*>(handler)->fail_service(asd, pkt, dir, this);
 }
 
-void ServiceDetector::initialize_expected_session(AppIdSession& parent, AppIdSession& expected,
+void ServiceDetector::initialize_expected_session(const AppIdSession& parent, AppIdSession& expected,
     uint64_t flags, AppidSessionDirection dir)
 {
     if (dir == APP_ID_FROM_INITIATOR)
index 24490622ee62b52e0341713c6931d09f00e68364..47eef7fad03a329ab86ed6421e795c80fadd690f 100644 (file)
@@ -59,7 +59,7 @@ public:
         asd.misc_app_id = miscId;
     }
 
-    void initialize_expected_session(AppIdSession&, AppIdSession&, uint64_t flags, AppidSessionDirection dir);
+    void initialize_expected_session(const AppIdSession&, AppIdSession&, uint64_t flags, AppidSessionDirection dir);
 
 private:
     int update_service_data(AppIdSession&, const snort::Packet*, AppidSessionDirection dir, AppId,
index 171d44a0497d9c8b20bc73a3c823f083eb4b9176..e6d1fa5390c07777d1842438ed00174c523b6166 100644 (file)
@@ -175,7 +175,7 @@ bool HttpEvent::contains_webdav_method()
 Flow* flow = nullptr;
 AppIdSession* mock_session = nullptr;
 
-AppIdSession* AppIdApi::get_appid_session(Flow&)
+AppIdSession* AppIdApi::get_appid_session(const Flow&)
 {
     mock().actualCall("get_appid_session");
     return mock_session;
index 4914a7880cdb16c3e32ce4876794957fee932553..d2e97068b0b4939ada9ad4673deb42d4ce8a48bd 100644 (file)
@@ -558,7 +558,7 @@ static inline void process_ftp_control(AppIdSession& asd,
 }
 
 static inline void process_third_party_results(AppIdSession& asd, int confidence,
-    vector<AppId>& proto_list, ThirdPartyAppIDAttributeData& attribute_data,
+    const vector<AppId>& proto_list, ThirdPartyAppIDAttributeData& attribute_data,
     AppidChangeBits& change_bits)
 {
     if ( asd.payload.get_id() == APP_ID_NONE and contains(proto_list, APP_ID_EXCHANGE) )
index 053e5b752745dbcec8f138a0eae86fd763f4d4ae..ecf8b28158623b61c0889f09b9d73b7d72928d2e 100644 (file)
@@ -93,8 +93,7 @@ THREAD_LOCAL ProfileStats arpPerfStats;
 // implementation stuff
 //-------------------------------------------------------------------------
 
-static IPMacEntry* LookupIPMacEntryByIP(
-    IPMacEntryList& ipmel, uint32_t ipv4_addr)
+static const IPMacEntry* LookupIPMacEntryByIP(const IPMacEntryList& ipmel, uint32_t ipv4_addr)
 {
     for ( auto& p : ipmel )
     {
@@ -222,7 +221,7 @@ void ArpSpoof::eval(Packet* p)
     if (!config->check_overwrite)
         return;
 
-    IPMacEntry* ipme = LookupIPMacEntryByIP(config->ipmel, ah->arp_spa32);
+    const IPMacEntry* ipme = LookupIPMacEntryByIP(config->ipmel, ah->arp_spa32);
     if ( ipme )
     {
         auto cmp_ether_src = memcmp(src_mac_addr, ipme->mac_addr, 6);
index df8bdbdf9efe3d487afd40f72a15dd8b6eae34f0..a5247a40e3cf8b31a328bc95b42960cde5398b2e 100644 (file)
@@ -46,15 +46,15 @@ struct PTSessionConstraints
     uint16_t dport;
     IpProtocol protocol = IpProtocol::PROTO_NOT_SET;
 
-    bool proto_match(IpProtocol& proto)
+    bool proto_match(const IpProtocol& proto) const
     {
         return (protocol == IpProtocol::PROTO_NOT_SET or protocol == proto);
     }
-    bool port_match(uint16_t p1, uint16_t p2)
+    bool port_match(uint16_t p1, uint16_t p2) const
     {
         return (!sport or sport == p1) and (!dport or dport == p2);
     }
-    bool ip_match(const uint32_t* ip1, const uint32_t* ip2)
+    bool ip_match(const uint32_t* ip1, const uint32_t* ip2) const
     {
         return
             ((!sip_flag or !memcmp(sip.get_ip6_ptr(), ip1, sizeof(snort::ip::snort_in6_addr))) and
index 9db030b79c28b0e7109715b5e985674b5ad4d0cc..41f065aa1c3715b6b3ae6bd83b5b4f083d13958a 100644 (file)
@@ -165,7 +165,7 @@ bool Trough::add_pcaps_list(const std::string& list)
     return true;
 }
 
-bool Trough::get_pcaps(std::vector<struct PcapReadObject> &pol)
+bool Trough::get_pcaps(const std::vector<struct PcapReadObject> &pol)
 {
     for (const PcapReadObject &pro : pol)
     {
index c25abf7b78d7cd4de93c9307d605b07aaec9f0e4..2c72f41717ccb2e420ebb2312c2ead95e703827b 100644 (file)
@@ -68,7 +68,7 @@ private:
     static bool add_pcaps_dir(const std::string& dirname, const std::string& filter);
     static bool add_pcaps_list_file(const std::string& list_filename, const std::string& filter);
     static bool add_pcaps_list(const std::string& list);
-    static bool get_pcaps(std::vector<struct PcapReadObject> &pol);
+    static bool get_pcaps(const std::vector<struct PcapReadObject> &pol);
 
     static std::vector<struct PcapReadObject> pcap_object_list;
     static std::vector<std::string> pcap_queue;
index 34241dd69f32caacee4a58931f5af5a36e0b24ce..54c3aff976ae5b7c51979ee17a437cb79d67309c 100644 (file)
@@ -46,7 +46,7 @@ static inline bool load_chunk(lua_State* L, const Chunk& chunk)
         L, chunk.buffer.c_str(), chunk.buffer.size(), chunk.filename.c_str());
 }
 
-static bool setup_globals(lua_State* L, Test& t)
+static bool setup_globals(lua_State* L, const Test& t)
 {
     // Add script_dir env var
     Lua::set_script_dir(L, SCRIPT_DIR_VARNAME, t.chunk->filename);
index 7528d447be79675a90532fbfaf604573e48f71ca..34791135a14f37eddd3d494d90b0a321eb70fe3a 100644 (file)
@@ -1184,8 +1184,6 @@ bnfa_struct_t* bnfaNew(const MpseAgent* agent)
 {
     int bnfa_memory=0;
     bnfa_struct_t* p = (bnfa_struct_t*)BNFA_MALLOC(sizeof(bnfa_struct_t),bnfa_memory);
-    if (!p)
-        return nullptr;
 
     if ( p )
     {
index d1202b602706ae17a04e63f3972426fc9db12cb0..41ed7764806b206119aedb62abe817e3354dc956 100644 (file)
@@ -317,7 +317,7 @@ const char* get_smb_com_string(uint8_t b)
 class Dce2Smb : public snort::Inspector
 {
 public:
-    Dce2Smb(dce2SmbProtoConf&);
+    Dce2Smb(const dce2SmbProtoConf&);
     ~Dce2Smb() override;
 
     void show(snort::SnortConfig*) override;
@@ -332,7 +332,7 @@ private:
     dce2SmbProtoConf config;
 };
 
-Dce2Smb::Dce2Smb(dce2SmbProtoConf& pc)
+Dce2Smb::Dce2Smb(const dce2SmbProtoConf& pc)
 {
     config = pc;
     if ((config.smb_file_inspection == DCE2_SMB_FILE_INSPECTION_ONLY)
index 369f33691c04654838626dfdaf16f7569375808e..388648f8acdd1a0fa1a36983bd32c9d501335a64 100644 (file)
@@ -108,7 +108,7 @@ static DCE2_TcpSsnData* dce2_handle_tcp_session(Packet* p, dce2TcpProtoConf* con
 class Dce2Tcp : public Inspector
 {
 public:
-    Dce2Tcp(dce2TcpProtoConf&);
+    Dce2Tcp(const dce2TcpProtoConf&);
 
     void show(SnortConfig*) override;
     void eval(Packet*) override;
@@ -122,7 +122,7 @@ private:
     dce2TcpProtoConf config;
 };
 
-Dce2Tcp::Dce2Tcp(dce2TcpProtoConf& pc)
+Dce2Tcp::Dce2Tcp(const dce2TcpProtoConf& pc)
 {
     config = pc;
 }
index 4aa322954246314def0ce35ca9ea3b1f39ae8dcc..2e836f8408b8d40539a27976710f89e9351048da 100644 (file)
@@ -108,7 +108,7 @@ static DCE2_UdpSsnData* dce2_handle_udp_session(Packet* p, dce2UdpProtoConf* con
 class Dce2Udp : public Inspector
 {
 public:
-    Dce2Udp(dce2UdpProtoConf&);
+    Dce2Udp(const dce2UdpProtoConf&);
     void show(SnortConfig*) override;
     void eval(Packet*) override;
     void clear(Packet*) override;
@@ -117,7 +117,7 @@ private:
     dce2UdpProtoConf config;
 };
 
-Dce2Udp::Dce2Udp(dce2UdpProtoConf& pc)
+Dce2Udp::Dce2Udp(const dce2UdpProtoConf& pc)
 {
     config = pc;
 }
index 5faa20c803397b1c6fd479ee24ddf61d09e100ac..6d0f211f72a0fce81f6df5d259ff4b3d647dfa8b 100644 (file)
@@ -342,7 +342,7 @@ static DCE2_Ret DCE2_OpnumParse(char* args, DCE2_Opnum* opnum)
 class Dce2OpnumOption : public IpsOption
 {
 public:
-    Dce2OpnumOption(DCE2_Opnum& src_opnum) : IpsOption(s_name)
+    Dce2OpnumOption(const DCE2_Opnum& src_opnum) : IpsOption(s_name)
     { opnum = src_opnum; }
     uint32_t hash() const override;
     bool operator==(const IpsOption&) const override;
index deb8584da01c92395ecf07b354c8d6b13a17ac0f..f3e3cd48ddabea790653b6fb2227e313a23902eb 100644 (file)
@@ -106,7 +106,7 @@ static void dnp3_reset_alt_buffer(const Packet* p)
     }
 }
 
-static bool dnp3_process_udp(dnp3ProtoConf& config, dnp3_session_data_t* dnp3_sess, Packet* p)
+static bool dnp3_process_udp(const dnp3ProtoConf& config, dnp3_session_data_t* dnp3_sess, Packet* p)
 {
     /* Possibly multiple PDUs in this UDP payload.
        Split up and process individually. */
@@ -161,7 +161,7 @@ static bool dnp3_process_udp(dnp3ProtoConf& config, dnp3_session_data_t* dnp3_se
 
 /* Main runtime entry point */
 
-static void process_dnp3(dnp3ProtoConf& config, Packet* p)
+static void process_dnp3(const dnp3ProtoConf& config, Packet* p)
 {
     if ( p->has_tcp_data() && !p->is_full_pdu() )
     {
@@ -216,7 +216,7 @@ static void process_dnp3(dnp3ProtoConf& config, Packet* p)
 class Dnp3 : public Inspector
 {
 public:
-    Dnp3(dnp3ProtoConf&);
+    Dnp3(const dnp3ProtoConf&);
 
     void show(SnortConfig*) override;
     void eval(Packet*) override;
@@ -232,7 +232,7 @@ private:
     dnp3ProtoConf config;
 };
 
-Dnp3::Dnp3(dnp3ProtoConf& pc)
+Dnp3::Dnp3(const dnp3ProtoConf& pc)
 {
     config.check_crc = pc.check_crc;
 }
index 83a93dda2b4b49b54889cb3186914e017e2746ed..7c50190a7fd13aa954cef6b5a13dd7033d340ae6 100644 (file)
@@ -103,25 +103,22 @@ static dnp3_map_t indication_map[] =
 bool dnp3_func_is_defined(uint16_t code)
 {
     size_t num_funcs = sizeof(func_map) / sizeof(func_map[0]);
-    size_t i;
-    int func_is_defined = false;
 
     /* Check to see if code is higher than all codes in func map */
-    if (code > func_map[num_funcs-1].value)
-        return func_is_defined;
+    if (code > func_map[num_funcs - 1].value)
+        return false;
 
-    for (i = 0; i < num_funcs-1; i++)
+    for (size_t i = 0; i < num_funcs - 1; i++)
     {
         /* This short-circuit check assumes that the function map remains
            in-order. */
-        if (code <= func_map[i].value)
+        if (code < func_map[i].value)
             break;
+        if (code == func_map[i].value)
+            return true;
     }
 
-    if (code == func_map[i].value)
-        func_is_defined = true;
-
-    return func_is_defined;
+    return false;
 }
 
 int dnp3_func_str_to_code(const char* name)
index 3fb2324cb99a1108bb4d6b7602c83987da8666ee..754c6eec3f4014b0b99bbdd6a748a18be4ed4cbc 100644 (file)
@@ -102,7 +102,7 @@ void Dnp3Module::get_data(dnp3ProtoConf& dnp3_config)
     dnp3_config.check_crc = config.check_crc;
 }
 
-void print_dnp3_conf(dnp3ProtoConf& config)
+void print_dnp3_conf(const dnp3ProtoConf& config)
 {
     LogMessage("DNP3 config: \n");
     LogMessage("    Check CRC: %s\n",
index a4ce910cfa00d46bd05e3279df9a532d1a428363..120e49bdddf88d79d0a4ccfa348abcdd1d456e09 100644 (file)
@@ -58,7 +58,7 @@ private:
     dnp3ProtoConf config;
 };
 
-void print_dnp3_conf(dnp3ProtoConf& config);
+void print_dnp3_conf(const dnp3ProtoConf& config);
 
 #endif
 
index 725e935b82630b23ba40d50617226a5c096ff9dc..368b050c1c9bfa0e7e428acdb7eef97a78a21546 100644 (file)
@@ -282,7 +282,7 @@ static bool dnp3_check_crc(const unsigned char* buf, uint16_t buflen)
 }
 
 /* Check CRCs in a Link-Layer Frame, then fill a buffer containing just the user data  */
-static bool dnp3_check_remove_crc(dnp3ProtoConf& config, const uint8_t* pdu_start,
+static bool dnp3_check_remove_crc(const dnp3ProtoConf& config, const uint8_t* pdu_start,
     uint16_t pdu_length, char* buf, uint16_t* buflen)
 {
     const char* cursor;
@@ -354,7 +354,7 @@ static bool dnp3_check_reserved_addrs(const dnp3_link_header_t* link)
 }
 
 /* Main DNP3 Reassembly function. */
-bool dnp3_full_reassembly(dnp3ProtoConf& config, dnp3_session_data_t* session, Packet* packet,
+bool dnp3_full_reassembly(const dnp3ProtoConf& config, dnp3_session_data_t* session, Packet* packet,
     const uint8_t* pdu_start, uint16_t pdu_length)
 {
     char buf[DNP3_TPDU_MAX];
index e043745a66bf91c1297e26351eaa3991bfacdf26..17b799bb749c1e22f8f524f117e8c61fc2efd518 100644 (file)
@@ -25,7 +25,7 @@
 #include "dnp3_module.h"
 #include "dnp3.h"
 
-bool dnp3_full_reassembly(dnp3ProtoConf& config, dnp3_session_data_t* session, snort::Packet* p,
+bool dnp3_full_reassembly(const dnp3ProtoConf& config, dnp3_session_data_t* session, snort::Packet* p,
     const uint8_t* pdu_start, uint16_t pdu_length);
 void dnp3_reassembly_reset(dnp3_reassembly_data_t* rdata);
 
index f900133b8b6eea133e5ec45cb6f4dede5463fa8d..b18ff45933d02da7fecaaed116a32180c63293a7 100644 (file)
@@ -124,7 +124,7 @@ bool FtpClientModule::set(const char*, Value& v, SnortConfig*)
     return true;
 }
 
-BounceTo::BounceTo(string& a, Port l, Port h)
+BounceTo::BounceTo(const string& a, Port l, Port h)
 {
     address = a;
     low = l;
@@ -190,14 +190,14 @@ bool FtpClientModule::end(const char* fqn, int idx, SnortConfig*)
 // server stuff
 //-------------------------------------------------------------------------
 
-FtpCmd::FtpCmd(std::string& key, uint32_t flg, int num)
+FtpCmd::FtpCmd(const std::string& key, uint32_t flg, int num)
 {
     name = key;
     flags = flg;
     number = num;
 }
 
-FtpCmd::FtpCmd(std::string& key, std::string& fmt, int num)
+FtpCmd::FtpCmd(const std::string& key, const std::string& fmt, int num)
 {
     name = key;
     format = fmt;
index 78cab4b09a52488370b47feb9337e54ce335e8d4..c1f7099fd3c9d717953fe09870f816e070fd667b 100644 (file)
@@ -51,7 +51,7 @@ struct BounceTo
     Port low;
     Port high;
 
-    BounceTo(std::string& address, Port lo, Port hi);
+    BounceTo(const std::string& address, Port lo, Port hi);
 };
 
 class FtpClientModule : public snort::Module
@@ -101,8 +101,8 @@ struct FtpCmd
     uint32_t flags;
     unsigned number;
 
-    FtpCmd(std::string&, uint32_t, int);
-    FtpCmd(std::string&, std::string&, int);
+    FtpCmd(const std::string&, uint32_t, int);
+    FtpCmd(const std::string&, const std::string&, int);
 };
 
 class FtpServerModule : public snort::Module
index 4a21d77ff2eb407ea391214ef28c1ee426b71558..762ebcf43ba94a0679274b412b591bd4fa090c11 100644 (file)
@@ -1310,7 +1310,7 @@ int check_ftp(FTP_SESSION* ftpssn, Packet* p, int iMode)
 
     const unsigned char* end = p->data + p->dsize;
 
-    DataBuffer& buf = DetectionEngine::get_alt_buffer(p);
+    const DataBuffer& buf = DetectionEngine::get_alt_buffer(p);
     if ( buf.len )
         end = buf.data + buf.len;
 
index bea408517cf1c98cedc423168dff9cfcd9d65105..ba5ea68f8e9719ae6901db582889cc71d120d002 100644 (file)
@@ -74,7 +74,7 @@ void reset_telnet_buffer(Packet* p)
 
 const uint8_t* get_telnet_buffer(Packet* p, unsigned& len)
 {
-    DataBuffer& buf = DetectionEngine::get_alt_buffer(p);
+    const DataBuffer& buf = DetectionEngine::get_alt_buffer(p);
     len = buf.len;
     return len ? buf.data : nullptr;
 }
index 20481122af444a66af191307b3f886586e6640b9..60b6cae930f28708555d1b5abb7ffeb9d82f9993 100644 (file)
@@ -109,7 +109,7 @@ IpsOption::EvalStatus GtpInfoOption::eval(Cursor& c, Packet* p)
     if ( !gfd or !gfd->ropts.gtp_infoElements )
         return NO_MATCH;
 
-    GTP_Roptions& ropts = gfd->ropts;
+    const GTP_Roptions& ropts = gfd->ropts;
 
     // match the status code
     uint8_t ieType = types[ropts.gtp_version];
index b971fda3a478aa535283e7fd08da523401924f13..443e8ff65496900588f600c9b10a1d2412f2897c 100644 (file)
@@ -31,8 +31,7 @@ snort::FlowData::FlowData(unsigned u, Inspector* ph) : next(nullptr), prev(nullp
 snort::FlowData::~FlowData() = default;
 unsigned snort::FlowData::flow_data_id = 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 show_stats(PegCount*, const PegInfo*, const IndexVec&, const char*, FILE*) { }
 
 class Http2FlowDataTest : public Http2FlowData
 {
index 187d58cdea180e721c4e4162f254f1c8755f7907..18edcb2e9943df537bf09c379d0f9a095646831c 100644 (file)
@@ -198,7 +198,7 @@ void HttpMsgBody::do_js_normalization(const Field& input, Field& output)
         transaction->get_infractions(source_id), transaction->get_events(source_id));
 }
 
-void HttpMsgBody::do_file_processing(Field& file_data)
+void HttpMsgBody::do_file_processing(const Field& file_data)
 {
     // Using the trick that cutter is deleted when regular or chunked body is complete
     Packet* p = DetectionEngine::get_current_packet();
index 3bde7ca33645b8e1e711cf23e7e154cdcd541a5b..9074a979c02d84844d70cb0199e5aff431ec3892 100644 (file)
@@ -54,7 +54,7 @@ protected:
 #endif
 
 private:
-    void do_file_processing(Field& file_data);
+    void do_file_processing(const Field& file_data);
     void do_utf_decoding(const Field& input, Field& output);
     void do_file_decompression(const Field& input, Field& output);
     void do_js_normalization(const Field& input, Field& output);
index daf50069c6466afbe1891d1f4e6b25724cc12d2f..b6fbaba6a37e773fdd6a15191cbc47139b9d8369 100644 (file)
@@ -69,8 +69,8 @@ void HttpMsgSection::create_event(int sid)
 
 void HttpMsgSection::update_depth() const
 {
-    int64_t& file_depth_remaining = session_data->file_depth_remaining[source_id];
-    int64_t& detect_depth_remaining = session_data->detect_depth_remaining[source_id];
+    const int64_t& file_depth_remaining = session_data->file_depth_remaining[source_id];
+    const int64_t& detect_depth_remaining = session_data->detect_depth_remaining[source_id];
 
     if ((detect_depth_remaining <= 0) &&
         (session_data->detection_status[source_id] == DET_ON))
index 8cc0518622f9eef46a268bbc05d295c011d412ef..6a3d13fdd329613fa052b01b2cd58f17a0e980d4 100644 (file)
@@ -35,7 +35,7 @@ void HttpStreamSplitter::chunk_spray(HttpFlowData* session_data, uint8_t* buffer
 {
     ChunkState& curr_state = session_data->chunk_state[source_id];
     uint32_t& expected = session_data->chunk_expected_length[source_id];
-    bool& is_broken_chunk = session_data->is_broken_chunk[source_id];
+    const bool& is_broken_chunk = session_data->is_broken_chunk[source_id];
     uint32_t& num_good_chunks = session_data->num_good_chunks[source_id];
 
     if (is_broken_chunk && (num_good_chunks == 0))
index 9959c21e747e6f55fa18d6a3d9f79a252532cffd..1355a9023504e037bbb5bbb6a0ec3b8c001639f9 100644 (file)
@@ -147,7 +147,7 @@ void HttpUri::parse_abs_path()
     }
 }
 
-void HttpUri::check_oversize_dir(Field& uri_field)
+void HttpUri::check_oversize_dir(const Field& uri_field)
 {
     const uint8_t* last_dir = nullptr;
     const uint8_t* cur;
index 2834baa40da07fbd5716747848dae93410fb9181..f40e8d41c2bbc2718516d0c8fdd72de678c425bc 100644 (file)
@@ -86,7 +86,7 @@ private:
     void parse_authority();
     void parse_abs_path();
 
-    void check_oversize_dir(Field&);
+    void check_oversize_dir(const Field&);
 };
 
 #endif
index 11fcd9dd67aee605670b8ae8401020dd40d4e796..1916024453247d9d1ff472be1d17c96a9d103e1e 100644 (file)
@@ -48,8 +48,7 @@ int DetectionEngine::queue_event(unsigned int, unsigned int, Actions::Type) { re
 }
 
 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 show_stats(PegCount*, const PegInfo*, const IndexVec&, const char*, FILE*) { }
 
 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; }
index acdb5cc88d955562e486a79a6e6d164f08c3fad7..bce1064cce0187cdcfa8c109dbc211bec6bdf6fc 100644 (file)
@@ -43,8 +43,7 @@ int DetectionEngine::queue_event(unsigned int, unsigned int, Actions::Type) { re
 }
 
 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 show_stats(PegCount*, const PegInfo*, const IndexVec&, const char*, FILE*) { }
 
 HttpJsNorm::HttpJsNorm(int, const HttpParaList::UriParam& uri_param_) :
     max_javascript_whitespaces(0), uri_param(uri_param_), javascript_search_mpse(nullptr),
index 37869c0735c6e823bfb4efee96459f4bb0dbae04..80bf8ce5aa699581dd137a71a96c2bec5395eb63 100644 (file)
@@ -881,7 +881,7 @@ bool RpcDecode::get_buf(InspectionBuffer::Type ibt, Packet* p, InspectionBuffer&
     if ( ibt != InspectionBuffer::IBT_ALT )
         return false;
 
-    DataBuffer& buf = DetectionEngine::get_alt_buffer(p);
+    const DataBuffer& buf = DetectionEngine::get_alt_buffer(p);
     b.len = buf.len;
     b.data = (b.len > 0) ? buf.data : nullptr;
 
index 8af8455fc3dca41e1d31da76c73cc089c206e8cc..ff189989f67b23f10787fed5f2a7af64fcfe76c3 100644 (file)
@@ -604,8 +604,6 @@ static bool SMTP_IsAuthCtxIgnored(const uint8_t* start, int length)
 static bool SMTP_IsAuthChanged(SMTPData* smtp_ssn, const uint8_t* start_ptr, const
     uint8_t* end_ptr)
 {
-    int length;
-    bool auth_changed = false;
     const uint8_t* start = start_ptr;
     const uint8_t* end = end_ptr;
 
@@ -615,17 +613,18 @@ static bool SMTP_IsAuthChanged(SMTPData* smtp_ssn, const uint8_t* start_ptr, con
         end--;
 
     if (start >= end)
-        return auth_changed;
+        return false;
 
-    length = end - start;
+    int length = end - start;
 
     if (length > MAX_AUTH_NAME_LEN)
-        return auth_changed;
+        return false;
 
     if (SMTP_IsAuthCtxIgnored(start, length))
-        return auth_changed;
+        return false;
 
     /* if authentication mechanism is set, compare it with current one*/
+    bool auth_changed = false;
     if (smtp_ssn->auth_name)
     {
         if (smtp_ssn->auth_name->length != length)
index 444de65fbd5ae090ed8a98e368456595ddb3073e..a7eb4ba60e9fc52260865178375f1188813a2195 100644 (file)
 using namespace snort;
 using namespace std;
 
-SmtpCmd::SmtpCmd(std::string& key, uint32_t flg, int num)
+SmtpCmd::SmtpCmd(const std::string& key, uint32_t flg, int num)
 {
     name = key;
     flags = flg;
     number = num;
 }
 
-SmtpCmd::SmtpCmd(std::string& key, int num)
+SmtpCmd::SmtpCmd(const std::string& key, int num)
 {
     name = key;
 
index 303e911d958da82d78983a54420e0ac13643eb6a..dda33d2e8aff3f0b0f57149f6bac78f4c7c51d9f 100644 (file)
@@ -71,8 +71,8 @@ struct SmtpCmd
     uint32_t flags;
     unsigned number;
 
-    SmtpCmd(std::string&, uint32_t, int);
-    SmtpCmd(std::string&, int);
+    SmtpCmd(const std::string&, uint32_t, int);
+    SmtpCmd(const std::string&, int);
 };
 
 class SmtpModule : public snort::Module
index 086a5d65a2a1bd4858de7d367ffb72fd7a937adc..f35a555be8d4c7e4765542317a9b3008002275e4 100644 (file)
@@ -77,7 +77,7 @@ void SMTP_ResetAltBuffer(Packet* p)
 
 const uint8_t* SMTP_GetAltBuffer(Packet* p, unsigned& len)
 {
-    DataBuffer& buf = DetectionEngine::get_alt_buffer(p);
+    const DataBuffer& buf = DetectionEngine::get_alt_buffer(p);
     len = buf.len;
     return len ? buf.data : nullptr;
 }
index 2465d7c5c04ec5562eff7cee42187f4406ed5fad..6039be1a172f67b4b30bf4b6f203036f364d76f5 100644 (file)
@@ -128,7 +128,7 @@ public:
     bool finished(Wand&);
     bool cast_spell(Wand&, Flow*, const uint8_t*, unsigned);
     bool spellbind(const MagicPage*&, Flow*, const uint8_t*, unsigned);
-    bool cursebind(vector<CurseServiceTracker>&, Flow*, const uint8_t*, unsigned);
+    bool cursebind(const vector<CurseServiceTracker>&, Flow*, const uint8_t*, unsigned);
 
 public:
     MagicBook* c2s_hexes;
@@ -264,7 +264,7 @@ bool Wizard::spellbind(
     return ( f->service != nullptr );
 }
 
-bool Wizard::cursebind(vector<CurseServiceTracker>& curse_tracker, Flow* f,
+bool Wizard::cursebind(const vector<CurseServiceTracker>& curse_tracker, Flow* f,
         const uint8_t* data, unsigned len)
 {
     for (const CurseServiceTracker& cst : curse_tracker)
index 54161e373183f06de5b34c209bca6fe50884c005..da48aa9a2007f7c658aa593004b0f3eb49ae5268 100644 (file)
@@ -57,8 +57,7 @@ void SideChannelManager::instantiate(const SCConnectors*, const PortBitSet* port
 }
 
 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*) { }
+void show_stats(PegCount*, const PegInfo*, const IndexVec&, const char*, FILE*) { }
 
 namespace snort
 {
index 548a2d33505352c4c1f65b6b809d787ec226c7c9..8e852b37e070b9b8be3adfda2347a8152068766c 100644 (file)
@@ -64,7 +64,7 @@ TcpStreamTracker::TcpStreamTracker(bool client) :
 TcpStreamTracker::~TcpStreamTracker()
 { delete splitter; }
 
-TcpStreamTracker::TcpEvent TcpStreamTracker::set_tcp_event(TcpSegmentDescriptor& tsd)
+TcpStreamTracker::TcpEvent TcpStreamTracker::set_tcp_event(const TcpSegmentDescriptor& tsd)
 {
     bool talker;
     const tcp::TCPHdr* tcph = tsd.get_tcph();
@@ -159,7 +159,7 @@ bool TcpStreamTracker::compare_mac_addresses(const uint8_t eth_addr[])
     return true;
 }
 
-void TcpStreamTracker::cache_mac_address(TcpSegmentDescriptor& tsd, uint8_t direction)
+void TcpStreamTracker::cache_mac_address(const TcpSegmentDescriptor& tsd, uint8_t direction)
 {
     /* Not Ethernet based, nothing to do */
     if ( tsd.get_pkt()->is_eth() )
index f9db25f46322e8a8ced1a309b8bab312f89aa582..50104c60816de94fb67ec1f1903e5c1b5e0f77dd 100644 (file)
@@ -112,7 +112,7 @@ public:
     TcpEvent get_tcp_event() const
     { return tcp_event; }
 
-    TcpEvent set_tcp_event(TcpSegmentDescriptor&);
+    TcpEvent set_tcp_event(const TcpSegmentDescriptor&);
 
     void set_tcp_event(TcpEvent tcp_event)
     { this->tcp_event = tcp_event; }
@@ -209,7 +209,7 @@ public:
     }
 
     // ack number must ack syn
-    bool is_rst_valid_in_syn_sent(TcpSegmentDescriptor& tsd)
+    bool is_rst_valid_in_syn_sent(const TcpSegmentDescriptor& tsd) const
     { return tsd.get_seg_ack() == snd_una; }
 
     uint32_t get_ts_last() const
@@ -245,7 +245,7 @@ public:
     void set_tcp_options_len(uint8_t tcp_options_len)
     { this->tcp_options_len = tcp_options_len; }
 
-    void cache_mac_address(TcpSegmentDescriptor&, uint8_t direction);
+    void cache_mac_address(const TcpSegmentDescriptor&, uint8_t direction);
     bool compare_mac_addresses(const uint8_t eth_addr[]);
 
     bool is_rst_pkt_sent() const
index 455f98a21417759c4b0a4ae3cea1d768860ebe7c..203561e706b041297608505238ccb5d5e0f03f20 100644 (file)
@@ -61,7 +61,7 @@ THREAD_LOCAL snort::ProfileStats pafPerfStats;
 
 //--------------------------------------------------------------------
 
-static uint32_t paf_flush (PAF_State* ps, PafAux& px, uint32_t* flags)
+static uint32_t paf_flush (PAF_State* ps, const PafAux& px, uint32_t* flags)
 {
     uint32_t at = 0;
     *flags &= ~(PKT_PDU_HEAD | PKT_PDU_TAIL);
index 4946eae9a545461a3adabad9fdb94b1c5838ca3e..cf19465058df3ef8a4e0c9577a9819d6ab3ea887 100644 (file)
@@ -181,7 +181,7 @@ public:
 
 static inline int handle_repeated_syn_mswin(
     TcpStreamTracker* talker, TcpStreamTracker* listener,
-    TcpSegmentDescriptor& tsd, TcpStreamSession* session)
+    const TcpSegmentDescriptor& tsd, TcpStreamSession* session)
 {
     /* Windows has some strange behavior here.  If the sequence of the reset is the
      * next expected sequence, it Resets.  Otherwise it ignores the 2nd SYN.
@@ -200,7 +200,7 @@ static inline int handle_repeated_syn_mswin(
 }
 
 static inline int handle_repeated_syn_bsd(
-    TcpStreamTracker* talker, TcpSegmentDescriptor& tsd, TcpStreamSession* session)
+    TcpStreamTracker* talker, const TcpSegmentDescriptor& tsd, TcpStreamSession* session)
 {
     /* If its not a retransmission of the actual SYN... RESET */
     if (!SEQ_EQ(tsd.get_seg_seq(), talker->get_iss()))
@@ -234,7 +234,7 @@ static inline bool paws_3whs_zero_ts_not_supported(
 
 // Older Linux ( <= 2.2 kernel ), Win32 (non 2K3) allow the 3whs to use a 0 timestamp.
 static inline bool paws_3whs_zero_ts_supported(
-    TcpStreamTracker* talker, TcpStreamTracker* listener, TcpSegmentDescriptor& tsd)
+    TcpStreamTracker* talker, TcpStreamTracker* listener, const TcpSegmentDescriptor& tsd)
 {
     bool check_ts = true;
 
index b902eda1876d65f7d8686eb2762cdba30af8355e..77d3d198c1b593236e6b09792570f24903592549 100644 (file)
@@ -133,12 +133,12 @@ bool TcpReassembler::flush_data_ready(TcpReassemblerState& trs)
     return ( get_pending_segment_count(trs, 2) > 1 );  // FIXIT-L return false?
 }
 
-bool TcpReassembler::next_no_gap(TcpSegmentNode& tsn)
+bool TcpReassembler::next_no_gap(const TcpSegmentNode& tsn)
 {
     return tsn.next and (tsn.next->i_seq == tsn.i_seq + tsn.i_len);
 }
 
-void TcpReassembler::update_next(TcpReassemblerState& trs, TcpSegmentNode& tsn)
+void TcpReassembler::update_next(TcpReassemblerState& trs, const TcpSegmentNode& tsn)
 {
     trs.sos.seglist.cur_rseg = next_no_gap(tsn) ?  tsn.next : nullptr;
     if ( trs.sos.seglist.cur_rseg )
@@ -190,7 +190,7 @@ void TcpReassembler::queue_reassembly_segment(
 }
 
 bool TcpReassembler::is_segment_fasttrack(
-    TcpReassemblerState&, TcpSegmentNode* tail, TcpSegmentDescriptor& tsd)
+    TcpReassemblerState&, TcpSegmentNode* tail, const TcpSegmentDescriptor& tsd)
 {
     if ( SEQ_EQ(tsd.get_seg_seq(), tail->i_seq + tail->i_len) )
         return true;
index 6bf9b60fb30328c87928ee1371917e138ee76d37..3a10387da82d95e5344a4013efe2b941e23233c6 100644 (file)
@@ -61,7 +61,7 @@ protected:
     int trim_delete_reassembly_segment(TcpReassemblerState&, TcpSegmentNode*, uint32_t flush_seq);
     void queue_reassembly_segment(TcpReassemblerState&, TcpSegmentNode* prev, TcpSegmentNode*);
     void init_overlap_editor(TcpReassemblerState&, TcpSegmentDescriptor&);
-    bool is_segment_fasttrack(TcpReassemblerState&, TcpSegmentNode* tail, TcpSegmentDescriptor&);
+    bool is_segment_fasttrack(TcpReassemblerState&, TcpSegmentNode* tail, const TcpSegmentDescriptor&);
     void show_rebuilt_packet(TcpReassemblerState&, snort::Packet*);
     uint32_t get_flush_data_len(
         TcpReassemblerState&, TcpSegmentNode*, uint32_t to_seq, unsigned max);
@@ -86,8 +86,8 @@ protected:
     int32_t flush_pdu_ackd(TcpReassemblerState&, uint32_t* flags, snort::Packet*);
     void purge_to_seq(TcpReassemblerState&, uint32_t flush_seq);
 
-    bool next_no_gap(TcpSegmentNode&);
-    void update_next(TcpReassemblerState&, TcpSegmentNode&);
+    bool next_no_gap(const TcpSegmentNode&);
+    void update_next(TcpReassemblerState&, const TcpSegmentNode&);
 };
 
 #endif
index ed1d3bed276b87b1ca0988031af5f8b274ed9175..b67c22c6b941921580ec336ad26e0a3f5631db53 100644 (file)
@@ -102,7 +102,7 @@ TcpSegmentNode* TcpSegmentNode::create(
     return tsn;
 }
 
-TcpSegmentNode* TcpSegmentNode::init(TcpSegmentDescriptor& tsd)
+TcpSegmentNode* TcpSegmentNode::init(const TcpSegmentDescriptor& tsd)
 {
     return create(tsd.get_pkt()->pkth->ts, tsd.get_pkt()->data, tsd.get_seg_len());
 }
index 885548d20cbbdd29145fece88d609a258e158d3a..bb4b47337ec01686330121a3df22b4889fdf70f1 100644 (file)
@@ -41,7 +41,7 @@ private:
     static TcpSegmentNode* create(const struct timeval& tv, const uint8_t* segment, uint16_t len);
 
 public:
-    static TcpSegmentNode* init(TcpSegmentDescriptor&);
+    static TcpSegmentNode* init(const TcpSegmentDescriptor&);
     static TcpSegmentNode* init(TcpSegmentNode&);
 
     void term();
index ba46c5f013ed24401d4b8a79ec054f1072749333..bf02529cf27f0cf95d3fda59026bf3fb26d716fa 100644 (file)
@@ -279,7 +279,7 @@ void TcpSession::update_perf_base_state(char newState)
         DataBus::publish(FLOW_STATE_EVENT, nullptr, flow);
 }
 
-bool TcpSession::flow_exceeds_config_thresholds(TcpSegmentDescriptor& tsd)
+bool TcpSession::flow_exceeds_config_thresholds(const TcpSegmentDescriptor& tsd)
 {
     if ( listener->flush_policy == STREAM_FLPOLICY_IGNORE )
     {
@@ -341,7 +341,7 @@ void TcpSession::process_tcp_stream(TcpSegmentDescriptor& tsd)
     }
 }
 
-void TcpSession::update_stream_order(TcpSegmentDescriptor& tsd, bool aligned)
+void TcpSession::update_stream_order(const TcpSegmentDescriptor& tsd, bool aligned)
 {
     switch ( listener->order )
     {
@@ -886,7 +886,7 @@ void TcpSession::set_extra_data(Packet* p, uint32_t xid)
     st.reassembler.set_xtradata_mask(st.reassembler.get_xtradata_mask() | BIT(xid));
 }
 
-static inline void set_window_scale(TcpStreamTracker& talker, TcpStreamTracker& listener,
+static inline void set_window_scale(const TcpStreamTracker& talker, const TcpStreamTracker& listener,
     TcpSegmentDescriptor& tsd)
 {
     // scale the window.  Only if BOTH client and server specified wscale option as part
index ba247867b6bd9cf5468f7c22fff09f32b56d9945..56de3672c54edb6ff2b9786a89eb6d980e75f3d1 100644 (file)
@@ -71,8 +71,8 @@ public:
 
 private:
     void set_os_policy() override;
-    bool flow_exceeds_config_thresholds(TcpSegmentDescriptor&);
-    void update_stream_order(TcpSegmentDescriptor&, bool aligned);
+    bool flow_exceeds_config_thresholds(const TcpSegmentDescriptor&);
+    void update_stream_order(const TcpSegmentDescriptor&, bool aligned);
     void process_tcp_stream(TcpSegmentDescriptor&);
     int process_tcp_data(TcpSegmentDescriptor&);
     void swap_trackers();
index ce58802bc436f6229da229bc7d43540aea48b392..8fc38a1f91c397621cd29875034b8877bc06cba4 100644 (file)
@@ -210,7 +210,6 @@ int UserTracker::scan(Packet* p, uint32_t& flags)
 void UserTracker::flush(Packet* p, unsigned flush_amt, uint32_t flags)
 {
     unsigned bytes_flushed = 0;
-    StreamBuffer sb = { nullptr, 0 };
     trace_logf(stream_user, "flush[%d]\n", flush_amt);
     uint32_t rflags = flags & ~PKT_PDU_TAIL;
     Packet* up = DetectionEngine::set_next_packet(p);
@@ -232,7 +231,7 @@ void UserTracker::flush(Packet* p, unsigned flush_amt, uint32_t flags)
         }
 
         trace_logf(stream_user, "reassemble[%d]\n", len);
-        sb = splitter->reassemble(
+        StreamBuffer sb = splitter->reassemble(
             p->flow, flush_amt, bytes_flushed, data, len, rflags, bytes_copied);
 
         bytes_flushed += bytes_copied;
@@ -471,7 +470,7 @@ void UserSession::set_splitter(bool c2s, StreamSplitter* ss)
 
 StreamSplitter* UserSession::get_splitter(bool c2s)
 {
-    UserTracker& ut = c2s ? server : client;
+    const UserTracker& ut = c2s ? server : client;
     return ut.splitter;
 }
 
index b6607d4182477a670014c9c3daaf33ec3f0e77d0..13e56bc4e373d95f29d4968619fd7f5e3c380fa4 100644 (file)
 #include "config.h"
 #endif
 
+#include "packet_time.h"
+
 #include "main/thread.h"
 #include "time/timersub.h"
 
-#include "packet_time.h"
-
 static THREAD_LOCAL struct timeval s_recent_packet = { 0, 0 };
 static THREAD_LOCAL uint32_t s_first_packet = 0;
 
@@ -64,7 +64,7 @@ int64_t timersub_ms(const struct timeval* end, const struct timeval* start)
 
 void packet_time_update(const struct timeval* cur_tv)
 {
-    if (timercmp(cur_tv, &s_recent_packet, >))
+    if (timercmp(&s_recent_packet, cur_tv, <))
     {
         if ( !s_first_packet )
             s_first_packet = cur_tv->tv_sec;
index 5f8b0ca1dff4102ed2e2939ee1d14859de2d5d75..5501bfaade50b14462a5b48f7cea41274bd02167 100644 (file)
@@ -305,7 +305,7 @@ void show_stats(
 
 void show_stats(
     PegCount* pegs, const PegInfo* info,
-    IndexVec& peg_idxs, const char* module_name, FILE* fh)
+    const IndexVec& peg_idxs, const char* module_name, FILE* fh)
 {
     bool head = false;
 
index 6d7895a9360755ec3bdfa9a1b7142e29277bc759..8d70bfc87851388fe3eda5fc3162b79c5aeedfef 100644 (file)
@@ -115,7 +115,7 @@ 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);
 void show_stats(PegCount*, const PegInfo*, unsigned n, const char* module_name = nullptr);
-void show_stats(PegCount*, const PegInfo*, IndexVec&, const char* module_name, FILE*);
+void show_stats(PegCount*, const PegInfo*, const IndexVec&, const char* module_name, FILE*);
 void show_percent_stats(PegCount*, const char*[], unsigned n, const char* module_name = nullptr);
 
 void sum_stats(SimpleStats* sums, SimpleStats* counts);
index 0c339e4c1526172f3688cda30e52444b99b5c08d..9b79157b8cca29b2c678b5f83dfdd7f16c07f757 100644 (file)
@@ -165,7 +165,7 @@ bool BerReader::read(const uint8_t* c, BerElement& e)
     return true;
 }
 
-bool BerReader::convert(BerElement& e, uint32_t& intval)
+bool BerReader::convert(const BerElement& e, uint32_t& intval)
 {
     if ( e.type != BerType::INTEGER )
         return false;
index 6b77c6b9f937cf57e8297f0d15ce16047d9724d7..ccd9b9de3739c6661e033bf5773ac7314a296604 100644 (file)
@@ -45,7 +45,7 @@ struct BerElement
 class SO_PUBLIC BerReader
 {
 public:
-    BerReader(Cursor& c)
+    BerReader(const Cursor& c)
     {
         beg = c.buffer();
         end = c.endo();
@@ -53,7 +53,7 @@ public:
 
     bool read(const uint8_t* c, BerElement& e);
 
-    bool convert(BerElement& e, uint32_t& intval);
+    bool convert(const BerElement& e, uint32_t& intval);
     bool extract(const uint8_t*& c, uint32_t& intval);
 
     bool skip(const uint8_t*& c, uint32_t type);
index 9e97ff8f2b67ba26d58bcf5f98ce9b52e61a35f7..cf5a9eca2566089c9e61b4ce9c7dc5779e3bb7e1 100644 (file)
@@ -28,7 +28,7 @@
 
 namespace snort
 {
-char* ObfuscateIpToText(const SfIp* ip, SfCidr& homenet, SfCidr& obfunet, InetBuf& ab)
+char* ObfuscateIpToText(const SfIp* ip, const SfCidr& homenet, SfCidr& obfunet, InetBuf& ab)
 {
     ab[0] = 0;
 
index f99ecaf9d4457c48ba591660128cd233f7f54d01..470313af82697257cbe3ed60e451dcf49fe1dcba 100644 (file)
@@ -29,7 +29,7 @@ struct SfCidr;
 typedef char InetBuf[INET6_ADDRSTRLEN];
 
 SO_PUBLIC char* ObfuscateIpToText(
-    const struct SfIp*, SfCidr& homenet, SfCidr& obfuscate_net, InetBuf&);
+    const struct SfIp*, const SfCidr& homenet, SfCidr& obfuscate_net, InetBuf&);
 }
 #endif
 
index 0e6af65a66a90959f98ba544d96392fd31e40742..b18790727e5eaa8af77ea237a1ba5e4055b09af1 100644 (file)
@@ -96,7 +96,7 @@ std::string Rule::get_option(const std::string& keyword)
     return std::string();
 }
 
-void Rule::update_option(const std::string& keyword, std::string& val)
+void Rule::update_option(const std::string& keyword, const std::string& val)
 {
     for (auto option : options)
     {
@@ -232,7 +232,7 @@ void Rule::resolve_pcre_buffer_options()
             {
                 curr_sticky_buffer = new_buffer;
                 RuleOption* new_opt = new RuleOption(new_buffer);
-                options.insert(iter, new_opt);
+                iter = options.insert(iter, new_opt);
                 ++iter;
             }
         }
index bbcc5906e17aa02d324ddbc1230af5d70ae1c8e8..fa2cf8f017c94e0ffa9cd4af5e78a21d3141fe95 100644 (file)
@@ -37,7 +37,7 @@ public:
     void add_option(const std::string& keyword);
     void add_option(const std::string& keyword, const std::string& data);
     std::string get_option(const std::string& keyword);
-    void update_option(const std::string& keyword, std::string& val);
+    void update_option(const std::string& keyword, const std::string& val);
     void add_suboption(const std::string& keyword);
     void add_suboption(const std::string& keyword, const std::string& val);
     void set_curr_options_buffer(const std::string& buffer, bool add_option);
index 1ca5324f5040415e163b5e1c56d2d6a2379c8cb5..1dca8ca51ae74e221e8deb3293a20057ab0c9eb2 100644 (file)
@@ -35,7 +35,7 @@ public:
 
     inline const std::string& get_name() { return name; }
     inline const std::string& get_value() { return value; }
-    inline void update_value(std::string& new_value) { value = new_value; }
+    inline void update_value(const std::string& new_value) { value = new_value; }
 
     bool add_suboption(const std::string& name);
     bool add_suboption(const std::string& name, const std::string& val);
index dd592b503854a3cc50fef8273222d0e3c71667be..807c892ecd14fcac6e55f61ec0ffd11c75ba9a0f 100644 (file)
@@ -207,7 +207,7 @@ std::string RuleApi::get_option(const std::string& keyword)
     return curr_rule->get_option(keyword);
 }
 
-void RuleApi::update_option(const std::string& keyword, std::string& val)
+void RuleApi::update_option(const std::string& keyword, const std::string& val)
 {
     if (!curr_rule)
         return;
index 3c5248f6be3215592315f13b7a3fd008def055df..5c6747d8d3ce6575693996e6cf9746a995a20b5b 100644 (file)
@@ -68,7 +68,7 @@ public:
     void add_option(const std::string& keyword);
     void add_option(const std::string& keyword, const std::string& val);
     std::string get_option(const std::string& keyword);
-    void update_option(const std::string& keyword, std::string& val);
+    void update_option(const std::string& keyword, const std::string& val);
     void add_suboption(const std::string& keyword);
     void add_suboption(const std::string& keyword, const std::string& val);
     void set_curr_options_buffer(const std::string& buffer, bool add_option=false);
index a7c6dbe716a4f02c6a92a3439e614246157a9688..23c0ecae046edb911a793cb04965a58fe805e2a3 100644 (file)
@@ -58,7 +58,7 @@ class TableApi
 {
 public:
     TableApi() = default;
-    TableApi(TableApi* d, TableDelegation& td) : delegate(d), delegations(td) {}
+    TableApi(TableApi* d, const TableDelegation& td) : delegate(d), delegations(td) {}
     virtual ~TableApi();
 
     void reset_state();