]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Merge pull request #1906 in SNORT/snort3 from ~MIALTIZE/snort3:f31_warnings to master
authorMichael Altizer (mialtize) <mialtize@cisco.com>
Wed, 25 Dec 2019 14:35:11 +0000 (14:35 +0000)
committerMichael Altizer (mialtize) <mialtize@cisco.com>
Wed, 25 Dec 2019 14:35:11 +0000 (14:35 +0000)
Squashed commit of the following:

commit a5cd61e97b73d70e9f38b136405c1a55238b0b87
Author: Michael Altizer <mialtize@cisco.com>
Date:   Fri Dec 20 13:36:37 2019 -0500

    codecs: Use unions for checksum pseudoheaders

    This helps clear up static analysis confusion.

commit ddcefc137ecd5229e1eca815a245346c8b539879
Author: Michael Altizer <mialtize@cisco.com>
Date:   Mon Dec 16 16:01:52 2019 -0500

    build: Clean up accumulated tabs and trailing whitespace in the code

commit 0c3a7f4f53af3bcee1b56962d06c61a039f69990
Author: Michael Altizer <mialtize@cisco.com>
Date:   Mon Dec 16 15:28:51 2019 -0500

    build: Rename parameters that shadow class members (compiler warnings)

commit 9f8664ec859c10ee2668a5cdb4a289b0c58ca1ed
Author: Michael Altizer <mialtize@cisco.com>
Date:   Mon Dec 16 14:17:10 2019 -0500

    build: Remove some extraneous semicolons (compiler warnings)

165 files changed:
src/codecs/ip/cd_icmp6.cc
src/codecs/ip/cd_mobility.cc
src/codecs/ip/cd_tcp.cc
src/codecs/ip/cd_udp.cc
src/codecs/ip/checksum.h
src/codecs/link/cd_mpls.cc
src/codecs/misc/cd_llc.cc
src/connectors/tcp_connector/tcp_connector.cc
src/connectors/tcp_connector/test/tcp_connector_test.cc
src/decompress/file_decomp.cc
src/decompress/file_decomp_pdf.cc
src/decompress/file_decomp_swf.cc
src/detection/context_switcher.cc
src/detection/detection_engine.cc
src/detection/detection_engine.h
src/detection/fp_detect.cc
src/detection/ips_context.cc
src/detection/ips_context.h
src/detection/ips_context_chain.cc
src/detection/ips_context_data.cc
src/events/event_queue.cc
src/flow/expect_cache.cc
src/flow/flow.cc
src/flow/flow_cache.cc
src/flow/flow_cache.h
src/flow/flow_control.h
src/flow/ha.cc
src/flow/test/flow_cache_test.cc
src/flow/test/flow_control_test.cc
src/flow/test/flow_test.cc
src/framework/codec.cc
src/framework/range.cc
src/hash/hashfcn.cc
src/hash/hashfcn.h
src/hash/test/ghash_test.cc
src/hash/test/lru_cache_shared_test.cc
src/hash/test/xhash_test.cc
src/ips_options/ips_byte_jump.cc
src/ips_options/ips_byte_test.cc
src/loggers/alert_fast.cc
src/main.cc
src/main/analyzer_command.cc
src/main/request.cc
src/main/snort_debug.cc
src/managers/inspector_manager.cc
src/managers/module_manager.h
src/managers/plugin_manager.cc
src/network_inspectors/appid/appid_config.cc
src/network_inspectors/appid/appid_discovery.cc
src/network_inspectors/appid/appid_discovery.h
src/network_inspectors/appid/appid_dns_session.h
src/network_inspectors/appid/appid_inspector.cc
src/network_inspectors/appid/appid_session.cc
src/network_inspectors/appid/appid_types.h
src/network_inspectors/appid/detector_plugins/detector_sip.cc
src/network_inspectors/appid/detector_plugins/detector_sip.h
src/network_inspectors/appid/detector_plugins/detector_smtp.cc
src/network_inspectors/appid/http_xff_fields.h
src/network_inspectors/appid/lua_detector_api.h
src/network_inspectors/appid/lua_detector_module.cc
src/network_inspectors/appid/service_plugins/service_ftp.cc
src/network_inspectors/appid/service_plugins/service_ftp.h
src/network_inspectors/appid/service_plugins/service_mdns.cc
src/network_inspectors/appid/service_plugins/service_rexec.cc
src/network_inspectors/appid/service_plugins/service_rshell.cc
src/network_inspectors/appid/service_plugins/service_ssl.cc
src/network_inspectors/appid/test/appid_http_session_test.cc
src/network_inspectors/appid/test/log_message_mock.h
src/network_inspectors/appid/tp_appid_utils.cc
src/network_inspectors/binder/binder.cc
src/network_inspectors/normalize/norm_module.cc
src/network_inspectors/packet_capture/capture_module.cc
src/network_inspectors/packet_capture/packet_capture.cc
src/network_inspectors/packet_tracer/packet_tracer.cc
src/network_inspectors/packet_tracer/packet_tracer.h
src/network_inspectors/packet_tracer/packet_tracer_module.cc
src/network_inspectors/perf_monitor/json_formatter.cc
src/network_inspectors/port_scan/ipobj.cc
src/network_inspectors/port_scan/ipobj.h
src/network_inspectors/port_scan/port_scan.cc
src/packet_io/sfdaq_module.cc
src/parser/vars.cc
src/profiler/profiler_nodes.cc
src/protocols/packet_manager.cc
src/protocols/ssl.h
src/search_engines/acsmx.cc
src/search_engines/acsmx2.cc
src/service_inspectors/dce_rpc/dce_co.cc
src/service_inspectors/dce_rpc/dce_common.cc
src/service_inspectors/dce_rpc/dce_context_data.cc
src/service_inspectors/dce_rpc/dce_list.cc
src/service_inspectors/dce_rpc/dce_smb2.cc
src/service_inspectors/dce_rpc/dce_smb_paf.cc
src/service_inspectors/dce_rpc/dce_smb_paf.h
src/service_inspectors/dce_rpc/dce_smb_transaction.cc
src/service_inspectors/dce_rpc/dce_smb_utils.cc
src/service_inspectors/dce_rpc/dce_tcp_paf.cc
src/service_inspectors/dns/dns.h
src/service_inspectors/ftp_telnet/ftpdata_splitter.cc
src/service_inspectors/gtp/gtp_parser.cc
src/service_inspectors/gtp/ips_gtp_info.cc
src/service_inspectors/gtp/ips_gtp_type.cc
src/service_inspectors/http2_inspect/http2_enum.h
src/service_inspectors/http2_inspect/http2_flow_data.h
src/service_inspectors/http2_inspect/http2_frame.cc
src/service_inspectors/http2_inspect/http2_frame.h
src/service_inspectors/http2_inspect/http2_headers_frame.cc
src/service_inspectors/http2_inspect/http2_headers_frame.h
src/service_inspectors/http2_inspect/http2_hpack_string_decode.cc
src/service_inspectors/http2_inspect/http2_hpack_string_decode.h
src/service_inspectors/http2_inspect/http2_hpack_table.cc
src/service_inspectors/http2_inspect/http2_huffman_state_machine.cc
src/service_inspectors/http2_inspect/http2_request_line.h
src/service_inspectors/http2_inspect/http2_settings_frame.cc
src/service_inspectors/http2_inspect/http2_settings_frame.h
src/service_inspectors/http2_inspect/http2_status_line.cc
src/service_inspectors/http2_inspect/http2_status_line.h
src/service_inspectors/http2_inspect/http2_stream_splitter_impl.cc
src/service_inspectors/http2_inspect/test/http2_hpack_string_decode_test.cc
src/service_inspectors/http_inspect/http_inspect.cc
src/service_inspectors/http_inspect/http_msg_request.h
src/service_inspectors/http_inspect/http_stream_splitter_reassemble.cc
src/service_inspectors/pop/pop.h
src/service_inspectors/sip/ips_sip_method.cc
src/service_inspectors/sip/sip_dialog.cc
src/service_inspectors/sip/test/sip_splitter_scan_test.cc
src/service_inspectors/sip/test/sip_splitter_test.cc
src/service_inspectors/sip/test/sip_splitter_test.h
src/service_inspectors/smtp/smtp.h
src/service_inspectors/smtp/smtp_config.h
src/service_inspectors/ssh/ssh.cc
src/service_inspectors/ssl/ssl_splitter.cc
src/service_inspectors/ssl/ssl_splitter.h
src/sfip/sf_vartable.cc
src/stream/base/stream_base.cc
src/stream/base/stream_module.cc
src/stream/base/stream_module.h
src/stream/file/file_session.cc
src/stream/icmp/icmp_session.cc
src/stream/ip/ip_session.cc
src/stream/stream.cc
src/stream/tcp/ips_stream_size.cc
src/stream/tcp/tcp_session.cc
src/stream/tcp/tcp_stream_session.cc
src/stream/udp/udp_session.cc
src/stream/user/user_session.cc
src/target_based/test/proto_ref_test.cc
src/utils/primed_allocator.h
src/utils/util.cc
src/utils/util.h
tools/snort2lua/data/data_types/dt_table.cc
tools/snort2lua/data/data_types/dt_var.h
tools/snort2lua/data/dt_table_api.h
tools/snort2lua/helpers/parse_cmd_line.cc
tools/snort2lua/helpers/util_binder.cc
tools/snort2lua/helpers/util_binder.h
tools/snort2lua/keyword_states/kws_file.cc
tools/snort2lua/preprocessor_states/pps_dns.cc
tools/snort2lua/preprocessor_states/pps_imap.cc
tools/snort2lua/preprocessor_states/pps_nap_selector.cc
tools/snort2lua/preprocessor_states/pps_smtp.cc
tools/snort2lua/preprocessor_states/pps_stream5_global.cc
tools/snort2lua/preprocessor_states/pps_stream5_ha.cc
tools/snort2lua/preprocessor_states/pps_stream5_tcp.cc
tools/snort2lua/rule_states/rule_gid_sid.cc

index bd681ee50c9161e22c8c0871aa8a05a1a2e277f1..06e9bb5ba8723926458dc0c300b32855aae4aea0 100644 (file)
@@ -152,13 +152,13 @@ bool Icmp6Codec::decode(const RawData& raw, CodecData& codec, DecodeData& snort)
     if ( SnortConfig::icmp_checksums() && !valid_checksum_from_daq(raw))
     {
         checksum::Pseudoheader6 ph6;
-        COPY4(ph6.sip, snort.ip_api.get_src()->get_ip6_ptr());
-        COPY4(ph6.dip, snort.ip_api.get_dst()->get_ip6_ptr());
-        ph6.zero = 0;
-        ph6.protocol = codec.ip6_csum_proto;
-        ph6.len = htons((unsigned short)raw.len);
+        COPY4(ph6.hdr.sip, snort.ip_api.get_src()->get_ip6_ptr());
+        COPY4(ph6.hdr.dip, snort.ip_api.get_dst()->get_ip6_ptr());
+        ph6.hdr.zero = 0;
+        ph6.hdr.protocol = codec.ip6_csum_proto;
+        ph6.hdr.len = htons((uint16_t)raw.len);
 
-        uint16_t csum = checksum::icmp_cksum((const uint16_t*)(icmp6h), raw.len, &ph6);
+        uint16_t csum = checksum::icmp_cksum((const uint16_t*)(icmp6h), raw.len, ph6);
 
         if (csum && !codec.is_cooked())
         {
@@ -365,12 +365,12 @@ void Icmp6Codec::update(const ip::IpApi& api, const EncodeFlags flags,
         checksum::Pseudoheader6 ps6;
         h->cksum = 0;
 
-        memcpy(ps6.sip, api.get_src()->get_ip6_ptr(), sizeof(ps6.sip));
-        memcpy(ps6.dip, api.get_dst()->get_ip6_ptr(), sizeof(ps6.dip));
-        ps6.zero = 0;
-        ps6.protocol = IpProtocol::ICMPV6;
-        ps6.len = htons((uint16_t)updated_len);
-        h->cksum = checksum::icmp_cksum((uint16_t*)h, updated_len, &ps6);
+        memcpy(ps6.hdr.sip, api.get_src()->get_ip6_ptr(), sizeof(ps6.hdr.sip));
+        memcpy(ps6.hdr.dip, api.get_dst()->get_ip6_ptr(), sizeof(ps6.hdr.dip));
+        ps6.hdr.zero = 0;
+        ps6.hdr.protocol = IpProtocol::ICMPV6;
+        ps6.hdr.len = htons((uint16_t)updated_len);
+        h->cksum = checksum::icmp_cksum((uint16_t*)h, updated_len, ps6);
     }
 }
 
index ef2827e71695dfbce673bd99a02579cb0714e0da..5d67abf3df829451ee86fb0ea59ae326be451d5e 100644 (file)
@@ -85,7 +85,7 @@ bool MobilityCodec::decode(const RawData& raw, CodecData& codec, DecodeData&)
     // must be called AFTER setting next_prot_id
     // Mobility Header must always be the last header in the header chain of an IPv6 packet
     CheckIPv6ExtensionOrder(codec, IpProtocol::MOBILITY_IPV6);
-    
+
     return true;
 }
 
index 9db2b947714f3aa61fe3f793d91ea6e51f42ba79..1b0be61400987f04159f121c5f4a58ccb3faba0a 100644 (file)
@@ -172,13 +172,13 @@ bool TcpCodec::valid_checksum4(const RawData& raw, DecodeData& snort)
     const ip::IP4Hdr* ip4h = snort.ip_api.get_ip4h();
 
     checksum::Pseudoheader ph;
-    ph.sip = ip4h->get_src();
-    ph.dip = ip4h->get_dst();
-    ph.zero = 0;
-    ph.protocol = ip4h->proto();
-    ph.len = htons((uint16_t) raw.len);
+    ph.hdr.sip = ip4h->get_src();
+    ph.hdr.dip = ip4h->get_dst();
+    ph.hdr.zero = 0;
+    ph.hdr.protocol = ip4h->proto();
+    ph.hdr.len = htons((uint16_t) raw.len);
 
-    return (checksum::tcp_cksum((const uint16_t*) raw.data, raw.len, &ph) == 0);
+    return (checksum::tcp_cksum((const uint16_t*) raw.data, raw.len, ph) == 0);
 }
 
 bool TcpCodec::valid_checksum6(const RawData& raw, const CodecData& codec, DecodeData& snort)
@@ -186,13 +186,13 @@ bool TcpCodec::valid_checksum6(const RawData& raw, const CodecData& codec, Decod
     const ip::IP6Hdr* const ip6h = snort.ip_api.get_ip6h();
 
     checksum::Pseudoheader6 ph6;
-    COPY4(ph6.sip, ip6h->get_src()->u6_addr32);
-    COPY4(ph6.dip, ip6h->get_dst()->u6_addr32);
-    ph6.zero = 0;
-    ph6.protocol = codec.ip6_csum_proto;
-    ph6.len = htons((uint16_t) raw.len);
+    COPY4(ph6.hdr.sip, ip6h->get_src()->u6_addr32);
+    COPY4(ph6.hdr.dip, ip6h->get_dst()->u6_addr32);
+    ph6.hdr.zero = 0;
+    ph6.hdr.protocol = codec.ip6_csum_proto;
+    ph6.hdr.len = htons((uint16_t) raw.len);
 
-    return (checksum::tcp_cksum((const uint16_t*) raw.data, raw.len, &ph6) == 0);
+    return (checksum::tcp_cksum((const uint16_t*) raw.data, raw.len, ph6) == 0);
 }
 
 bool TcpCodec::decode(const RawData& raw, CodecData& codec, DecodeData& snort)
@@ -675,12 +675,12 @@ bool TcpCodec::encode(const uint8_t* const raw_in, const uint16_t /*raw_len*/,
         int len = buf.size();
 
         const ip::IP4Hdr* const ip4h = ip_api.get_ip4h();
-        ps.sip = ip4h->get_src();
-        ps.dip = ip4h->get_dst();
-        ps.zero = 0;
-        ps.protocol = IpProtocol::TCP;
-        ps.len = htons((uint16_t)len);
-        tcph_out->th_sum = checksum::tcp_cksum((uint16_t*)tcph_out, len, &ps);
+        ps.hdr.sip = ip4h->get_src();
+        ps.hdr.dip = ip4h->get_dst();
+        ps.hdr.zero = 0;
+        ps.hdr.protocol = IpProtocol::TCP;
+        ps.hdr.len = htons((uint16_t)len);
+        tcph_out->th_sum = checksum::tcp_cksum((uint16_t*)tcph_out, len, ps);
     }
     else if (ip_api.is_ip6())
     {
@@ -688,12 +688,12 @@ bool TcpCodec::encode(const uint8_t* const raw_in, const uint16_t /*raw_len*/,
         int len = buf.size();
 
         const ip::IP6Hdr* const ip6h = ip_api.get_ip6h();
-        memcpy(&ps6.sip, ip6h->get_src()->u6_addr8, sizeof(ps6.sip));
-        memcpy(&ps6.dip, ip6h->get_dst()->u6_addr8, sizeof(ps6.dip));
-        ps6.zero = 0;
-        ps6.protocol = IpProtocol::TCP;
-        ps6.len = htons((uint16_t)len);
-        tcph_out->th_sum = checksum::tcp_cksum((uint16_t*)tcph_out, len, &ps6);
+        memcpy(&ps6.hdr.sip, ip6h->get_src()->u6_addr8, sizeof(ps6.hdr.sip));
+        memcpy(&ps6.hdr.dip, ip6h->get_dst()->u6_addr8, sizeof(ps6.hdr.dip));
+        ps6.hdr.zero = 0;
+        ps6.hdr.protocol = IpProtocol::TCP;
+        ps6.hdr.len = htons((uint16_t)len);
+        tcph_out->th_sum = checksum::tcp_cksum((uint16_t*)tcph_out, len, ps6);
     }
 
     return true;
@@ -714,23 +714,23 @@ void TcpCodec::update(const ip::IpApi& api, const EncodeFlags flags, uint8_t* ra
         {
             checksum::Pseudoheader ps;
             const ip::IP4Hdr* const ip4h = api.get_ip4h();
-            ps.sip = ip4h->get_src();
-            ps.dip = ip4h->get_dst();
-            ps.zero = 0;
-            ps.protocol = IpProtocol::TCP;
-            ps.len = htons((uint16_t)updated_len);
-            h->th_sum = checksum::tcp_cksum((uint16_t*)h, updated_len, &ps);
+            ps.hdr.sip = ip4h->get_src();
+            ps.hdr.dip = ip4h->get_dst();
+            ps.hdr.zero = 0;
+            ps.hdr.protocol = IpProtocol::TCP;
+            ps.hdr.len = htons((uint16_t)updated_len);
+            h->th_sum = checksum::tcp_cksum((uint16_t*)h, updated_len, ps);
         }
         else
         {
             checksum::Pseudoheader6 ps6;
             const ip::IP6Hdr* const ip6h = api.get_ip6h();
-            memcpy(ps6.sip, ip6h->get_src()->u6_addr32, sizeof(ps6.sip));
-            memcpy(ps6.dip, ip6h->get_dst()->u6_addr32, sizeof(ps6.dip));
-            ps6.zero = 0;
-            ps6.protocol = IpProtocol::TCP;
-            ps6.len = htons((uint16_t)updated_len);
-            h->th_sum = checksum::tcp_cksum((uint16_t*)h, updated_len, &ps6);
+            memcpy(ps6.hdr.sip, ip6h->get_src()->u6_addr32, sizeof(ps6.hdr.sip));
+            memcpy(ps6.hdr.dip, ip6h->get_dst()->u6_addr32, sizeof(ps6.hdr.dip));
+            ps6.hdr.zero = 0;
+            ps6.hdr.protocol = IpProtocol::TCP;
+            ps6.hdr.len = htons((uint16_t)updated_len);
+            h->th_sum = checksum::tcp_cksum((uint16_t*)h, updated_len, ps6);
         }
     }
 }
index 9af2959e217b84fa78b78c9f2be231b48b5b174c..d4e6ff977e9d448243f6ba9eb672d44b52e2e5cb 100644 (file)
@@ -182,13 +182,13 @@ bool UdpCodec::valid_checksum4(const RawData& raw, const DecodeData& snort)
     const ip::IP4Hdr* const ip4h = snort.ip_api.get_ip4h();
 
     checksum::Pseudoheader ph;
-    ph.sip = ip4h->get_src();
-    ph.dip = ip4h->get_dst();
-    ph.zero = 0;
-    ph.protocol = ip4h->proto();
-    ph.len = htons((uint16_t) raw.len);
+    ph.hdr.sip = ip4h->get_src();
+    ph.hdr.dip = ip4h->get_dst();
+    ph.hdr.zero = 0;
+    ph.hdr.protocol = ip4h->proto();
+    ph.hdr.len = htons((uint16_t) raw.len);
 
-    return (checksum::udp_cksum((const uint16_t*) raw.data, raw.len, &ph) == 0);
+    return (checksum::udp_cksum((const uint16_t*) raw.data, raw.len, ph) == 0);
 }
 
 bool UdpCodec::valid_checksum6(const RawData& raw, const CodecData& codec, const DecodeData& snort)
@@ -196,13 +196,13 @@ bool UdpCodec::valid_checksum6(const RawData& raw, const CodecData& codec, const
     const ip::IP6Hdr* const ip6h = snort.ip_api.get_ip6h();
 
     checksum::Pseudoheader6 ph6;
-    COPY4(ph6.sip, ip6h->ip6_src.u6_addr32);
-    COPY4(ph6.dip, ip6h->ip6_dst.u6_addr32);
-    ph6.zero = 0;
-    ph6.protocol = codec.ip6_csum_proto;
-    ph6.len = htons((uint16_t) raw.len);
+    COPY4(ph6.hdr.sip, ip6h->get_src()->u6_addr32);
+    COPY4(ph6.hdr.dip, ip6h->get_dst()->u6_addr32);
+    ph6.hdr.zero = 0;
+    ph6.hdr.protocol = codec.ip6_csum_proto;
+    ph6.hdr.len = htons((uint16_t) raw.len);
 
-    return (checksum::udp_cksum((const uint16_t*) raw.data, raw.len, &ph6) == 0);
+    return (checksum::udp_cksum((const uint16_t*) raw.data, raw.len, ph6) == 0);
 }
 
 void UdpCodec::get_protocol_ids(std::vector<ProtocolId>& v)
@@ -411,23 +411,23 @@ bool UdpCodec::encode(const uint8_t* const raw_in, const uint16_t /*raw_len*/,
     {
         checksum::Pseudoheader ps;
         const ip::IP4Hdr* const ip4h = ip_api.get_ip4h();
-        ps.sip = ip4h->get_src();
-        ps.dip = ip4h->get_dst();
-        ps.zero = 0;
-        ps.protocol = IpProtocol::UDP;
-        ps.len = udph_out->uh_len;
-        udph_out->uh_chk = checksum::udp_cksum((uint16_t*)udph_out, len, &ps);
+        ps.hdr.sip = ip4h->get_src();
+        ps.hdr.dip = ip4h->get_dst();
+        ps.hdr.zero = 0;
+        ps.hdr.protocol = IpProtocol::UDP;
+        ps.hdr.len = udph_out->uh_len;
+        udph_out->uh_chk = checksum::udp_cksum((uint16_t*)udph_out, len, ps);
     }
     else if (ip_api.is_ip6())
     {
         checksum::Pseudoheader6 ps6;
         const ip::IP6Hdr* const ip6h = ip_api.get_ip6h();
-        memcpy(ps6.sip, ip6h->get_src()->u6_addr8, sizeof(ps6.sip));
-        memcpy(ps6.dip, ip6h->get_dst()->u6_addr8, sizeof(ps6.dip));
-        ps6.zero = 0;
-        ps6.protocol = IpProtocol::UDP;
-        ps6.len = udph_out->uh_len;
-        udph_out->uh_chk = checksum::udp_cksum((uint16_t*)udph_out, len, &ps6);
+        memcpy(ps6.hdr.sip, ip6h->get_src()->u6_addr8, sizeof(ps6.hdr.sip));
+        memcpy(ps6.hdr.dip, ip6h->get_dst()->u6_addr8, sizeof(ps6.hdr.dip));
+        ps6.hdr.zero = 0;
+        ps6.hdr.protocol = IpProtocol::UDP;
+        ps6.hdr.len = udph_out->uh_len;
+        udph_out->uh_chk = checksum::udp_cksum((uint16_t*)udph_out, len, ps6);
     }
 
     enc.next_proto = IpProtocol::UDP;
@@ -451,23 +451,23 @@ void UdpCodec::update(const ip::IpApi& ip_api, const EncodeFlags flags,
         {
             checksum::Pseudoheader ps;
             const ip::IP4Hdr* const ip4h = ip_api.get_ip4h();
-            ps.sip = ip4h->get_src();
-            ps.dip = ip4h->get_dst();
-            ps.zero = 0;
-            ps.protocol = IpProtocol::UDP;
-            ps.len = htons((uint16_t)updated_len);
-            h->uh_chk = checksum::udp_cksum((uint16_t*)h, updated_len, &ps);
+            ps.hdr.sip = ip4h->get_src();
+            ps.hdr.dip = ip4h->get_dst();
+            ps.hdr.zero = 0;
+            ps.hdr.protocol = IpProtocol::UDP;
+            ps.hdr.len = htons((uint16_t)updated_len);
+            h->uh_chk = checksum::udp_cksum((uint16_t*)h, updated_len, ps);
         }
         else if (ip_api.is_ip6())
         {
             checksum::Pseudoheader6 ps6;
             const ip::IP6Hdr* const ip6h = ip_api.get_ip6h();
-            memcpy(ps6.sip, ip6h->ip6_src.u6_addr32, sizeof(ps6.sip));
-            memcpy(ps6.dip, ip6h->ip6_dst.u6_addr32, sizeof(ps6.dip));
-            ps6.zero = 0;
-            ps6.protocol = IpProtocol::UDP;
-            ps6.len = htons((uint16_t)updated_len);
-            h->uh_chk = checksum::udp_cksum((uint16_t*)h, updated_len, &ps6);
+            memcpy(ps6.hdr.sip, ip6h->get_src()->u6_addr32, sizeof(ps6.hdr.sip));
+            memcpy(ps6.hdr.dip, ip6h->get_dst()->u6_addr32, sizeof(ps6.hdr.dip));
+            ps6.hdr.zero = 0;
+            ps6.hdr.protocol = IpProtocol::UDP;
+            ps6.hdr.len = htons((uint16_t)updated_len);
+            h->uh_chk = checksum::udp_cksum((uint16_t*)h, updated_len, ps6);
         }
     }
 }
index 53e303d5ce62e5cb3fa1c01fd04f2d19db1ffaca..e7c0d8d8d673c7c066211b43e8f5a2042394855c 100644 (file)
 
 namespace checksum
 {
-struct Pseudoheader6
+union Pseudoheader
 {
-    uint32_t sip[4];
-    uint32_t dip[4];
-    uint8_t zero;
-    IpProtocol protocol;
-    uint16_t len;
+    struct
+    {
+        uint32_t sip;
+        uint32_t dip;
+        uint8_t zero;
+        IpProtocol protocol;
+        uint16_t len;
+    } hdr;
+    uint16_t arr[6];
+    static_assert(sizeof(hdr) == sizeof(arr), "IPv4 pseudoheader must be 12 bytes");
 };
 
-struct Pseudoheader
+union Pseudoheader6
 {
-    uint32_t sip;
-    uint32_t dip;
-    uint8_t zero;
-    IpProtocol protocol;
-    uint16_t len;
+    struct
+    {
+        uint32_t sip[4];
+        uint32_t dip[4];
+        uint8_t zero;
+        IpProtocol protocol;
+        uint16_t len;
+    } hdr;
+    uint16_t arr[18];
+    static_assert(sizeof(hdr) == sizeof(arr), "IPv6 pseudoheader must be 36 bytes");
 };
 
 //  calculate the checksum for this general case.
 static uint16_t cksum_add(const uint16_t* buf, std::size_t buf_len);
-inline uint16_t tcp_cksum(const uint16_t* buf, std::size_t len, const Pseudoheader* const);
-inline uint16_t tcp_cksum(const uint16_t* buf, std::size_t len, const Pseudoheader6* const);
-inline uint16_t udp_cksum(const uint16_t* buf, std::size_t len, const Pseudoheader* const);
-inline uint16_t udp_cksum(const uint16_t* buf, std::size_t len, const Pseudoheader6* const);
-inline uint16_t icmp_cksum(const uint16_t* buf, std::size_t len, const Pseudoheader6* const);
+inline uint16_t tcp_cksum(const uint16_t* buf, std::size_t len, const Pseudoheader&);
+inline uint16_t tcp_cksum(const uint16_t* buf, std::size_t len, const Pseudoheader6&);
+inline uint16_t udp_cksum(const uint16_t* buf, std::size_t len, const Pseudoheader&);
+inline uint16_t udp_cksum(const uint16_t* buf, std::size_t len, const Pseudoheader6&);
+inline uint16_t icmp_cksum(const uint16_t* buf, std::size_t len, const Pseudoheader6&);
 inline uint16_t icmp_cksum(const uint16_t* buf, std::size_t len);
 inline uint16_t ip_cksum(const uint16_t* buf, std::size_t len);
 
@@ -69,24 +79,6 @@ inline uint16_t ip_cksum(const uint16_t* buf, std::size_t len);
  */
 namespace detail
 {
-struct PsuedoheaderUnion
-{
-    union
-    {
-        Pseudoheader ph4;
-        uint16_t ph4_arr[12];
-    };
-};
-
-struct Psuedoheader6Union
-{
-    union
-    {
-        Pseudoheader ph6;
-        uint16_t ph6_arr[18];
-    };
-};
-
 inline uint16_t cksum_add(const uint16_t* buf, std::size_t len, uint32_t cksum)
 {
     const uint16_t* sp = buf;
@@ -177,16 +169,9 @@ inline uint16_t cksum_add(const uint16_t* buf, std::size_t len, uint32_t cksum)
     return (uint16_t)(~cksum);
 }
 
-inline void add_ipv4_pseudoheader(const Pseudoheader* const ph4,
-    uint32_t& cksum)
+inline void add_ipv4_pseudoheader(const Pseudoheader& ph4, uint32_t& cksum)
 {
-    /*
-     * This mess is necessary to make static analyzers happy.
-     * Otherwise they assume we are reading garbage values
-     */
-    const PsuedoheaderUnion* const ph4_u = reinterpret_cast
-        <const PsuedoheaderUnion*>(ph4);
-    const uint16_t* const h = ph4_u->ph4_arr;
+    const uint16_t* h = ph4.arr;
 
     /* ipv4 pseudo header must have 12 bytes */
     cksum += h[0];
@@ -197,16 +182,9 @@ inline void add_ipv4_pseudoheader(const Pseudoheader* const ph4,
     cksum += h[5];
 }
 
-inline void add_ipv6_pseudoheader(const Pseudoheader6* const ph6,
-    uint32_t& cksum)
+inline void add_ipv6_pseudoheader(const Pseudoheader6& ph6, uint32_t& cksum)
 {
-    /*
-     * This mess is necessary to make static analyzers happy.
-     * Otherwise they assume we are reading garbage values
-     */
-    const Psuedoheader6Union* const ph6_u = reinterpret_cast
-        <const Psuedoheader6Union*>(ph6);
-    const uint16_t* const h = ph6_u->ph6_arr;
+    const uint16_t* h = ph6.arr;
 
     /* PseudoHeader must have 36 bytes */
     cksum += h[0];
@@ -283,7 +261,7 @@ inline void add_ip_header(const uint16_t*& d,
 
 inline uint16_t icmp_cksum(const uint16_t* buf,
     std::size_t len,
-    const Pseudoheader6* const ph)
+    const Pseudoheader6& ph)
 {
     uint32_t cksum = 0;
 
@@ -298,7 +276,7 @@ inline uint16_t icmp_cksum(const uint16_t* buf, size_t len)
 
 inline uint16_t tcp_cksum(const uint16_t* h,
     std::size_t len,
-    const Pseudoheader* const ph)
+    const Pseudoheader& ph)
 {
     uint32_t cksum = 0;
 
@@ -309,7 +287,7 @@ inline uint16_t tcp_cksum(const uint16_t* h,
 
 inline uint16_t tcp_cksum(const uint16_t* buf,
     std::size_t len,
-    const Pseudoheader6* const ph)
+    const Pseudoheader6& ph)
 {
     uint32_t cksum = 0;
 
@@ -320,7 +298,7 @@ inline uint16_t tcp_cksum(const uint16_t* buf,
 
 inline uint16_t udp_cksum(const uint16_t* buf,
     std::size_t len,
-    const Pseudoheader* const ph)
+    const Pseudoheader& ph)
 {
     uint32_t cksum = 0;
 
@@ -331,7 +309,7 @@ inline uint16_t udp_cksum(const uint16_t* buf,
 
 inline uint16_t udp_cksum(const uint16_t* buf,
     std::size_t len,
-    const Pseudoheader6* const ph)
+    const Pseudoheader6& ph)
 {
     uint32_t cksum = 0;
 
index 556b96b95fd90ed4e4313c3f4d1904ae2cf803bf..49d49b47238b2164144d31ac76a2aa4fb8000dea 100644 (file)
@@ -290,13 +290,13 @@ int MplsCodec::checkMplsHdr(const CodecData& codec, uint32_t label, uint8_t bos)
             break;
         }
         //if bos is false we are believed to NOT be at the bottom of the stack
-        //and if we arent at the bottom of the stack then we should NOT see 
+        //and if we arent at the bottom of the stack then we should NOT see
         //label 0 or 2 (according to RFC 3032)
-        else 
+        else
         {
              if ( label == 0 )
                     codec_event(codec, DECODE_BAD_MPLS_LABEL0);
-            //it MUST be label 2 
+            //it MUST be label 2
              else
                     codec_event(codec, DECODE_BAD_MPLS_LABEL2);
         }
index 12a7d4e630e9252bb41e7f8c0620b64ecbe1891b..d68660022e3f6de40b2bcc451eb4fb36ff921172 100644 (file)
@@ -119,7 +119,7 @@ bool LlcCodec::decode(const RawData& raw, CodecData& codec, DecodeData&)
 
         const EthLlcOther* ehllcother = reinterpret_cast<const EthLlcOther*>(raw.data +
             sizeof(EthLlc));
-        
+
         if (ehllcother->org_code[0] == 0 &&
             ehllcother->org_code[1] == 0 &&
             ehllcother->org_code[2] == 0)
index 4a61801d32cef179e6e31bbbf04acdd3d0ebd93a..c975c42a7285bbc6505221cd9ff7e3d32404f674 100644 (file)
@@ -167,7 +167,7 @@ void TcpConnector::process_receive()
     {
         if (errno != EINTR)
         {
-            
+
             char error_msg[1024] = {0};
             if (strerror_r(errno, error_msg, sizeof(error_msg)) == 0)
                 ErrorMessage("TcpC Input Thread: Error polling on socket %d: %s\n", pfds[0].fd, error_msg);
@@ -413,7 +413,7 @@ static TcpConnector* tcp_connector_tinit_answer(TcpConnectorConfig* cfg, const c
         if (strerror_r(errno, error_msg, sizeof(error_msg)) == 0)
             ErrorMessage("accept() failure: %s\n", error_msg);
         else
-            ErrorMessage("accept() failure: %d\n", errno); 
+            ErrorMessage("accept() failure: %d\n", errno);
         return nullptr;
     }
 
index 1fa6d9cc33fead8aa6b85df9f963060bef70d407..b844907ceb19c08b98b7f8f33f384a2a9df66a49 100644 (file)
@@ -79,7 +79,7 @@ void ErrorMessage(const char*, ...) { }
 void LogMessage(const char*, ...) { }
 }
 
-int connect (int, const struct sockaddr*, socklen_t) { return s_connect_return; } 
+int connect (int, const struct sockaddr*, socklen_t) { return s_connect_return; }
 ssize_t send (int, const void*, size_t n, int)
 {
     if ( n == sizeof(TcpConnectorMsgHdr) )
index 3749b6e7e45b0eba1e525790e37bdbc7ad5c8b1f..45e7c194a962d13ded4cc390b1610832df6b8946 100644 (file)
@@ -420,7 +420,7 @@ void File_Decomp_Alert(fd_session_t* SessionPtr, int Event)
 } // namespace snort
 
 //--------------------------------------------------------------------------
-// unit tests 
+// unit tests
 //--------------------------------------------------------------------------
 
 #ifdef UNIT_TEST
index e19e152c962fb5e99c3a3a0232317dd216195984..5012723801eaf146409903a349997b3caa295ebe 100644 (file)
@@ -1144,7 +1144,7 @@ fd_status_t File_Decomp_PDF(fd_session_t* SessionPtr)
 }
 
 //--------------------------------------------------------------------------
-// unit tests 
+// unit tests
 //--------------------------------------------------------------------------
 
 #ifdef UNIT_TEST
index 466da4392f181e8c4853435926735a269c0352c3..cfcdbf1854b75afb49a4c63ac26029a8a4c30327 100644 (file)
@@ -333,7 +333,7 @@ fd_status_t File_Decomp_SWF(fd_session_t* SessionPtr)
 }
 
 //--------------------------------------------------------------------------
-// unit tests 
+// unit tests
 //--------------------------------------------------------------------------
 
 #ifdef UNIT_TEST
index 46b53c0ab136ffc74c4d5d600c77a56f2f2f49aa..3c2f9c949cf2cf4e7fe183d334b693e86c84ff31 100644 (file)
@@ -70,7 +70,7 @@ void ContextSwitcher::start()
     IpsContext* c = idle.back();
     assert(c->state == IpsContext::IDLE);
     assert(!c->has_callbacks());
-    
+
     c->context_num = ++global_context_num;
     trace_logf(detection, TRACE_DETECTION_ENGINE, "(wire) %" PRIu64 " cs::start %" PRIu64 " (i=%zu, b=%zu)\n",
         get_packet_number(), c->context_num, idle.size(), busy.size());
@@ -79,7 +79,7 @@ void ContextSwitcher::start()
 
     c->packet->active = c->packet->active_inst;
     c->packet->active->reset();
-    c->packet->action = &c->packet->action_inst; 
+    c->packet->action = &c->packet->action_inst;
     c->state = IpsContext::BUSY;
 
     busy.emplace_back(c);
@@ -130,7 +130,7 @@ void ContextSwitcher::abort()
 
         if ( c->packet->flow )
             c->packet->flow->context_chain.abort();
-        
+
         c->abort();
         c->state = IpsContext::IDLE;
         c->clear_callbacks();
@@ -176,7 +176,7 @@ IpsContext* ContextSwitcher::complete()
     c->clear_context_data();
     c->state = IpsContext::IDLE;
     idle.emplace_back(c);
-    
+
     if ( busy.empty() )
         return nullptr;
 
@@ -189,7 +189,7 @@ void ContextSwitcher::suspend()
 
     IpsContext* c = busy.back();
     assert(c->state == IpsContext::BUSY);
-    
+
     trace_logf(detection, TRACE_DETECTION_ENGINE, "%" PRIu64 " cs::suspend %" PRIu64 " (i=%zu, b=%zu, wh=%zu)\n",
         c->packet_number, c->context_num, idle.size(), busy.size(), contexts.size() - idle.size() - busy.size());
 
@@ -271,7 +271,7 @@ TEST_CASE("ContextSwitcher single wire", "[ContextSwitcher]")
         _2_   _3_
        / | \ / | \
       *4*5 6 7 8 9
-      
+
        6 2 7 8 9 3 1
     */
 
@@ -291,7 +291,7 @@ TEST_CASE("ContextSwitcher single wire", "[ContextSwitcher]")
     CHECK(c5->state == IpsContext::BUSY);
     mgr.complete();
     CHECK(c5->state == IpsContext::IDLE);
-    
+
     c6 = mgr.interrupt();
     CHECK(c6->state == IpsContext::BUSY);
     c6->packet->set_offloaded();
@@ -333,7 +333,7 @@ TEST_CASE("ContextSwitcher single wire", "[ContextSwitcher]")
     CHECK(c1->state == IpsContext::SUSPENDED);
 
     std::vector<IpsContext*> expected = { c6, c2, c7, c8, c9, c3, c1 };
-    
+
     for ( auto& e : expected )
     {
         mgr.resume(e);
@@ -361,7 +361,7 @@ TEST_CASE("ContextSwitcher multi wire", "[ContextSwitcher]")
         c->packet->flow = new Flow;
         mgr.push(c);
     }
-    
+
     mgr.start();
     c1 = mgr.get_context();
     mgr.suspend();
index 040c09c1b49b38ffc728b4d8880f4c037d58feba..cb4bb57f1ef9756c151b5b4f91083536aa573e10 100644 (file)
@@ -176,7 +176,7 @@ Packet* DetectionEngine::set_next_packet(Packet* parent)
         p->active = parent->active;
         p->action = parent->action;
     }
-    
+
     // processing but parent is already gone (flow cache flush etc..)
     else if ( Analyzer::get_switcher()->get_context() )
     {
@@ -185,7 +185,7 @@ Packet* DetectionEngine::set_next_packet(Packet* parent)
         p->active = get_current_packet()->active;
         p->action = get_current_packet()->action;
     }
-    
+
     // shutdown, so use a dummy so null checking is not needed everywhere
     else
     {
@@ -227,7 +227,7 @@ void DetectionEngine::finish_inspect(Packet* p, bool inspected)
     // this also handles block pending state
     Stream::check_flow_closed(p);
 
-    if ( inspected and !p->context->next() ) 
+    if ( inspected and !p->context->next() )
         InspectorManager::clear(p);
 
     clear_events(p);
@@ -296,16 +296,16 @@ IpsContextData* DetectionEngine::get_data(unsigned id, IpsContext* context)
 }
 
 void DetectionEngine::add_replacement(const std::string& s, unsigned off)
-{ 
+{
     Replacement r;
 
     r.data = s;
     r.offset = off;
-    Analyzer::get_switcher()->get_context()->rpl.emplace_back(r); 
+    Analyzer::get_switcher()->get_context()->rpl.emplace_back(r);
 }
 
 bool DetectionEngine::get_replacement(std::string& s, unsigned& off)
-{ 
+{
     if ( Analyzer::get_switcher()->get_context()->rpl.empty() )
         return false;
 
@@ -459,12 +459,12 @@ void DetectionEngine::onload()
         trace_logf(detection, TRACE_DETECTION_ENGINE,
             "%" PRIu64 " de::onload %" PRIu64 " (r=%d)\n",
             p->context->packet_number, p->context->context_num, offloader->count());
-        
+
         p->clear_offloaded();
-        
+
         IpsContextChain& chain = p->flow ? p->flow->context_chain :
             Analyzer::get_switcher()->non_flow_chain;
-        
+
         resume_ready_suspends(chain);
     }
 }
@@ -488,8 +488,8 @@ void DetectionEngine::complete(Packet* p)
 
     ContextSwitcher* sw = Analyzer::get_switcher();
     sw->resume(p->context);
-   
-    if ( p->is_detection_enabled(p->packet_flags & PKT_FROM_CLIENT) ) 
+
+    if ( p->is_detection_enabled(p->packet_flags & PKT_FROM_CLIENT) )
         fp_complete(p);
 }
 
index 4dd5db3e55260377ea3a683eb9f42e62b0f80bd9..5edf575f2db7200fff7953a7a358b4bd58032bd3 100644 (file)
@@ -88,7 +88,7 @@ public:
 
     static int queue_event(const struct OptTreeNode*);
     static int queue_event(unsigned gid, unsigned sid, Actions::Type = Actions::NONE);
-    
+
     static void disable_all(Packet*);
     static bool all_disabled(Packet*);
 
index 7985f9254040353fb4416fd41b743f739ad85203..b7ac4fc2988915585b7ff61a35342a50ab581765 100644 (file)
@@ -115,7 +115,7 @@ static inline void fpLogOther(
             otn->sigInfo.gid, otn->sigInfo.sid,
             otn->sigInfo.rev, Actions::get_string((Actions::Type)action));
     }
-    
+
     // rule option actions are queued here (eg replace)
     otn_trigger_actions(otn, p);
 
index 1d6e0b29da85ac2949d7ff2b03e92fa9b2fafd96..15196214e4811205e6135475d221e68dff3c9bee 100644 (file)
@@ -204,7 +204,7 @@ TEST_CASE("IpsContext post detection", "[IpsContext]")
 TEST_CASE("IpsContext Link", "[IpsContext]")
 {
     IpsContext c0, c1, c2;
-    
+
     CHECK(c0.dependencies() == nullptr);
     CHECK(c0.next() == nullptr);
 
@@ -256,7 +256,7 @@ TEST_CASE("IpsContext Abort, [IpsContext]")
     c0.link(&c1);
     c1.link(&c2);
     c2.link(&c3);
-    
+
     // mid list
     // c0 <- c1 <- c2 <- c3
     // c0 <- c2 <- c3
@@ -289,7 +289,7 @@ TEST_CASE("IpsContext Abort, [IpsContext]")
     CHECK(c2.next() == nullptr);
     CHECK(c3.dependencies() == nullptr);
     CHECK(c3.next() == nullptr);
-    
+
     // only
     c2.abort();
     CHECK(c2.dependencies() == nullptr);
index 17ec32ab37f11ddb4167cad179ce0837d135b93e..00c7734934d26fb8ae9feb1cd227c58de632a96d 100644 (file)
@@ -126,7 +126,7 @@ public:
             next_to_process->depends_on = depends_on;
 
         if ( depends_on )
-            depends_on->next_to_process = next_to_process; 
+            depends_on->next_to_process = next_to_process;
 
         depends_on = next_to_process = nullptr;
     }
@@ -153,7 +153,7 @@ public:
     uint64_t context_num;
     uint64_t packet_number;
     ActiveRules active_rules;
-    State state; 
+    State state;
     bool check_tags;
     bool clear_inspectors;
 
index 96e247030291ce392254cf7f8a6414f9328d808c..a7de53c3e0c76e2be9b1e1f43765a26415d024eb 100644 (file)
@@ -49,7 +49,7 @@ void IpsContextChain::push_back(IpsContext* new_back)
     else
     {
         assert(!_front);
-        _front = _back = new_back;        
+        _front = _back = new_back;
     }
 }
 
@@ -85,7 +85,7 @@ TEST_CASE("IpsContextChain pop", "[IpsContextChain]")
 {
     IpsContextChain chain;
     IpsContext a, b, c;
-    
+
     chain.push_back(&a);
     chain.push_back(&b);
     chain.push_back(&c);
@@ -107,7 +107,7 @@ TEST_CASE("IpsContextChain abort", "[IpsContextChain]")
 {
     IpsContextChain chain;
     IpsContext a, b;
-    
+
     chain.push_back(&a);
     chain.push_back(&b);
     chain.abort();
index d4c92d82ea71ee73200a5c680db696aa09249472..3b673034b16d759f342681c14f538fb15f95ee83 100644 (file)
@@ -40,10 +40,10 @@ using namespace snort;
 unsigned IpsContextData::ips_id = 0;
 
 unsigned IpsContextData::get_ips_id()
-{ 
+{
     ++ips_id;
     assert(ips_id < IpsContext::max_ips_id);
-    return ips_id; 
+    return ips_id;
 }
 
 void IpsContextData::clear_ips_id()
index caa53f757de9f52b614dcfa9397be6e20a44ddb0..a8a27189372da6d1a8e4bfb3c0158892519d6cd7 100644 (file)
@@ -35,7 +35,7 @@
 **           event (gid,sid pair).  This is now required to get events
 **           to be logged. The decoders and preprocessors are still
 **           configured independently, which allows them to inspect and
-**           call the alerting functions DetectionEngine::queue_event. 
+**           call the alerting functions DetectionEngine::queue_event.
 **
 **           Any event that has no otn associated with it's gid,sid pair
 **           will/should not alert, even if the preprocessor or decoder is
index c2c8831a9771afbd3cc9ba18195b88a42869a3da..ae5425539adc477f7c7a0bf1a25e68bd162520cd 100644 (file)
@@ -397,8 +397,7 @@ int ExpectCache::add_flow(const Packet *ctrlPkt, PktType type, IpProtocol ip_pro
         node->count = 0;
         last = nullptr;
         /* Only add TCP and UDP expected flows for now via the DAQ module. */
-        if ((ip_proto == IpProtocol::TCP || ip_proto == IpProtocol::UDP) 
-                && ctrlPkt->daq_instance)
+        if ((ip_proto == IpProtocol::TCP || ip_proto == IpProtocol::UDP) && ctrlPkt->daq_instance)
             ctrlPkt->daq_instance->add_expected(ctrlPkt, cliIP, cliPort, srvIP, srvPort,
                     ip_proto, 1000, 0);
     }
index c04fb0a45bcf0fc67ffb34b64ce701f74383ba41..272b1e02d93fc133f94f14fddb3fc13572202c8c 100644 (file)
@@ -139,7 +139,7 @@ void Flow::term()
 
     if (assistant_gadget)
         assistant_gadget->rem_ref();
-    
+
     if ( ha_state )
         delete ha_state;
 
@@ -530,7 +530,7 @@ bool Flow::is_pdu_inorder(uint8_t dir)
 }
 
 void Flow::set_service(Packet* pkt, const char* new_service)
-{   
+{
     service = new_service;
     DataBus::publish(FLOW_SERVICE_CHANGE_EVENT, pkt);
-}   
+}
index 9ff56697bcab1845d381ad49f379ec1bfc688123..c31376a286617f89370a136d964254b88f236394 100644 (file)
@@ -358,38 +358,38 @@ unsigned FlowCache::timeout(unsigned num_flows, time_t thetime)
 unsigned FlowCache::delete_active_flows(unsigned mode, unsigned num_to_delete, unsigned &deleted)
 {
     unsigned flows_to_check = hash_table->get_count();
-       while ( num_to_delete && flows_to_check-- )
-       {
-               auto flow = static_cast<Flow*>(hash_table->first());
-               assert(flow);
-               if ( (mode == ALLOWED_FLOWS_ONLY and (flow->was_blocked() || flow->is_suspended()))
-                   or (mode == OFFLOADED_FLOWS_TOO and flow->was_blocked()) )
-               {
-                       if (!hash_table->touch())
-                               break;
-
-                       continue;
-               }
-
-               // we have a winner...
-               hash_table->remove(flow->key);
-               if ( flow->next )
-                   unlink_uni(flow);
-
-               if ( flow->was_blocked() )
-                   delete_stats.update(FlowDeleteState::BLOCKED);
-               else if ( flow->is_suspended() )
+    while ( num_to_delete && flows_to_check-- )
+    {
+        auto flow = static_cast<Flow*>(hash_table->first());
+        assert(flow);
+        if ( (mode == ALLOWED_FLOWS_ONLY and (flow->was_blocked() || flow->is_suspended()))
+            or (mode == OFFLOADED_FLOWS_TOO and flow->was_blocked()) )
+        {
+            if (!hash_table->touch())
+                break;
+
+            continue;
+        }
+
+        // we have a winner...
+        hash_table->remove(flow->key);
+        if ( flow->next )
+            unlink_uni(flow);
+
+        if ( flow->was_blocked() )
+            delete_stats.update(FlowDeleteState::BLOCKED);
+        else if ( flow->is_suspended() )
             delete_stats.update(FlowDeleteState::OFFLOADED);
-               else
+        else
             delete_stats.update(FlowDeleteState::ALLOWED);
 
-               delete flow;
-               --flows_allocated;
-               ++deleted;
-               --num_to_delete;
-       }
+        delete flow;
+        --flows_allocated;
+        ++deleted;
+        --num_to_delete;
+    }
 
-       return num_to_delete;
+    return num_to_delete;
 }
 
 unsigned FlowCache::delete_flows(unsigned num_to_delete)
index 91be91ebc687a5a0386f104534b58225506ed56b..394a0bb86e623ec639455d2f8c4be1ad337e3e11 100644 (file)
@@ -94,9 +94,8 @@ public:
     const FlowCacheConfig& get_flow_cache_config() const
     { return config; }
 
-       unsigned get_flows_allocated() const
-       { return flows_allocated; }
-
+    unsigned get_flows_allocated() const
+    { return flows_allocated; }
 
 private:
     void push(snort::Flow*);
@@ -104,8 +103,8 @@ private:
     void remove(snort::Flow*);
     void retire(snort::Flow*);
     unsigned prune_unis(PktType);
-       unsigned delete_active_flows
-               (unsigned mode, unsigned num_to_delete, unsigned &deleted);
+    unsigned delete_active_flows
+        (unsigned mode, unsigned num_to_delete, unsigned &deleted);
 
 private:
     static const unsigned cleanup_flows = 1;
index a80ea4213645918a4e1620777a3b69f737c3db83..7e2ede91f118b012c5687f15c16adf7d772589b5 100644 (file)
@@ -74,7 +74,7 @@ public:
     int add_expected(
         const snort::Packet* ctrlPkt, PktType, IpProtocol,
         const snort::SfIp *srcIP, uint16_t srcPort,
-               const snort::SfIp *dstIP, uint16_t dstPort,
+        const snort::SfIp *dstIP, uint16_t dstPort,
         char direction, snort::FlowData*);
 
     int add_expected(
index 93708ec99d66ca6b7584ab488a036fc89fb04b99..248f940bff4a34a7e91701c3eed81cc4c3c7113e 100644 (file)
@@ -660,8 +660,8 @@ Flow* HighAvailability::process_daq_import(Packet& p, FlowKey& key)
             {
                 if (FlowKey::compare(&key, flow->key, 0) == 0)
                 {
-                    if (flow->flow_state == Flow::FlowState::BLOCK) 
-                    {   
+                    if (flow->flow_state == Flow::FlowState::BLOCK)
+                    {
                         flow->disable_inspection();
                         p.disable_inspect = true;
                     }
index afcc5e5486d2d6cd678930840ce229890d79ef78..c263a40175eac1226db87c2bba964e51be0683c6 100644 (file)
@@ -115,8 +115,8 @@ void Stream::stop_inspection(Flow*, Packet*, char, int32_t, int) { }
 
 int ExpectCache::add_flow(const Packet*, PktType, IpProtocol, const SfIp*, uint16_t,
     const SfIp*, uint16_t, char, FlowData*, SnortProtocolId)
-{ 
-    return 1; 
+{
+    return 1;
 }
 
 TEST_GROUP(flow_prune) { };
@@ -136,7 +136,7 @@ TEST(flow_prune, empty_cache_prune_flows)
 
 // Do not delete blocked flow
 TEST(flow_prune, blocked_flow_prune_flows)
-{   
+{
     FlowCacheConfig fcg;
     fcg.max_flows = 2;
     FlowCache *cache = new FlowCache(fcg);
@@ -148,7 +148,7 @@ TEST(flow_prune, blocked_flow_prune_flows)
     FlowKey flow_key;
     memset(&flow_key, 0, sizeof(FlowKey));
     flow_key.pkt_type = PktType::TCP;
-    
+
     flow_key.port_l = first_port;
     cache->allocate(&flow_key);
 
@@ -165,7 +165,7 @@ TEST(flow_prune, blocked_flow_prune_flows)
     flow_key.port_l = first_port;
     CHECK(cache->find(&flow_key) != nullptr);
 
-    // Prune one flow. This should delete the MRU flow, since 
+    // Prune one flow. This should delete the MRU flow, since
     // LRU flow is blocked
     CHECK(cache->delete_flows(1) == 1);
 
@@ -255,4 +255,4 @@ TEST(flow_prune, prune_all_blocked_flows)
 int main(int argc, char** argv)
 {
     return CommandLineTestRunner::RunAllTests(argc, argv);
-} 
+}
index 0a9bf5a8eb2f78b91e2281b171c46b4821ae0eb9..b6518acc642fe083d7c25d834a8e0b5c16f2f950 100644 (file)
@@ -73,10 +73,10 @@ Flow* FlowCache::find(const FlowKey*) { return nullptr; }
 Flow* FlowCache::allocate(const FlowKey*) { return nullptr; }
 void FlowCache::push(Flow*) { }
 bool FlowCache::prune_one(PruneReason, bool) { return true; }
-unsigned FlowCache::delete_flows(unsigned) { return 0; } 
+unsigned FlowCache::delete_flows(unsigned) { return 0; }
 unsigned FlowCache::timeout(unsigned, time_t) { return 1; }
 void Flow::init(PktType) { }
-void set_network_policy(SnortConfig*, unsigned) { } 
+void set_network_policy(SnortConfig*, unsigned) { }
 void DataBus::publish(const char*, const uint8_t*, unsigned, Flow*) { }
 void DataBus::publish(const char*, Packet*, Flow*) { }
 SnortConfig* SnortConfig::get_conf() { return nullptr; }
index f1080fbf0c10794fc5b8f14fba3b70c3b05dc6bb..6dc767d8f988ce7a15a6cec36b79d1d32c86c5df 100644 (file)
@@ -106,10 +106,10 @@ TEST(nondefault_timeout, hard_expiration)
     flow->set_default_session_timeout(validate, true);
     flow->set_hard_expiration();
     flow->set_expire(&pkt, validate);
-    
+
     CHECK( flow->is_hard_expiration() == true);
     CHECK( flow->expire_time == validate );
-    
+
     delete flow;
 }
 
index 2c83030df883027d03747df4ce0ca437c8727b3b..10456512ffa1a73c04b8b7774f66ffdfcfcec7b3 100644 (file)
@@ -217,7 +217,7 @@ TEST_CASE("clear", "[buffer]")
     Buffer buf(raw_buf, 1);
     buf.allocate(1);
     buf.clear();
-    
+
     CHECK( buf.data() == &raw_buf[1] ); // 1 past the "known" buffer
     CHECK( buf.size() == 0 );
 }
index aaf0c3b19e111a5192c8df5cbf389ec691942d62..69c7b8f51ee9413a1780ade02ab4719ed2b14199 100644 (file)
@@ -611,7 +611,7 @@ TEST_CASE("validate", "[RangeCheck]")
     CHECK(rc.validate("2<>4", ":8"));
     // in hex
     CHECK(rc.validate("2<>4", "0x1:0x0A"));
-    
+
     // invalid low
     CHECK(!rc.validate("2<>4", "3:"));
     // invalid hi
index 56f6964ba8159ba436e286078284fd1d47b2f40f..b8efc25b1847928bf133b348c87421b6790584c3 100644 (file)
@@ -77,9 +77,7 @@ HashFnc* hashfcn_new(int m)
 void hashfcn_free(HashFnc* p)
 {
     if ( p )
-    {
         snort_free(p);
-    }
 }
 
 unsigned hashfcn_hash(HashFnc* p, const unsigned char* d, int n)
@@ -167,22 +165,20 @@ void mix_str(
     }
 }
 
-size_t str_to_hash(const uint8_t *str, int length )
+uint32_t str_to_hash(const uint8_t *str, size_t length)
 {
-    size_t a = 0, b = 0, c = 0;
+    uint32_t a = 0, b = 0, c = 0;
 
-    for (int i = 0, j = 0; i < length; i += 4)
+    for (size_t i = 0, j = 0; i < length; i += 4)
     {
-        size_t tmp = 0;
-        int k = length - i;
+        uint32_t tmp = 0;
+        size_t k = length - i;
 
         if (k > 4)
-            k=4;
+            k = 4;
 
-        for (int m = 0; m < k; m++)
-        {
-            tmp |= *(str + i + m) << m*8;
-        }
+        for (size_t m = 0; m < k; m++)
+            tmp |= *(str + i + m) << m * 8;
 
         switch (j)
         {
@@ -200,12 +196,12 @@ size_t str_to_hash(const uint8_t *str, int length )
 
         if (j == 3)
         {
-            mix(a,b,c);
+            mix(a, b, c);
             j = 0;
         }
     }
 
-    finalize(a,b,c);
+    finalize(a, b, c);
     return c;
 }
 } //namespace snort
index eb7742868672f8b31f9da1dccad8f728476f1483..706f45c0cee67271dcd9265fc6ee98c6466751c1 100644 (file)
 // 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 //--------------------------------------------------------------------------
 
-#ifndef HashFnc_H
-#define HashFnc_H
+#ifndef HASHFCN_H
+#define HASHFCN_H
 
 #include "main/snort_types.h"
 
-#define rot(x,k) (((x)<<(k)) | ((x)>>(32-(k))))
-
-#define mix(a,b,c) \
-{ \
-    (a) -= (c);  (a) ^= rot(c, 4);  (c) += (b); \
-    (b) -= (a);  (b) ^= rot(a, 6);  (a) += (c); \
-    (c) -= (b);  (c) ^= rot(b, 8);  (b) += (a); \
-    (a) -= (c);  (a) ^= rot(c,16);  (c) += (b); \
-    (b) -= (a);  (b) ^= rot(a,19);  (a) += (c); \
-    (c) -= (b);  (c) ^= rot(b, 4);  (b) += (a); \
-}
-
-#define finalize(a,b,c) \
-{ \
-    (c) ^= (b); (c) -= rot(b,14); \
-    (a) ^= (c); (a) -= rot(c,11); \
-    (b) ^= (a); (b) -= rot(a,25); \
-    (c) ^= (b); (c) -= rot(b,16); \
-    (a) ^= (c); (a) -= rot(c,4);  \
-    (b) ^= (a); (b) -= rot(a,14); \
-    (c) ^= (b); (c) -= rot(b,24); \
+namespace
+{
+    inline uint32_t rot(uint32_t x, unsigned k) { return (x << k) | (x >> (32 - k)); }
+    inline void mix(uint32_t& a, uint32_t& b, uint32_t& c)
+    {
+        a -= c; a ^= rot(c, 4); c += b;
+        b -= a; b ^= rot(a, 6); a += c;
+        c -= b; c ^= rot(b, 8); b += a;
+        a -= c; a ^= rot(c,16); c += b;
+        b -= a; b ^= rot(a,19); a += c;
+        c -= b; c ^= rot(b, 4); b += a;
+    }
+    inline void finalize(uint32_t& a, uint32_t& b, uint32_t& c)
+    {
+        c ^= b; c -= rot(b,14);
+        a ^= c; a -= rot(c,11);
+        b ^= a; b -= rot(a,25);
+        c ^= b; c -= rot(b,16);
+        a ^= c; a -= rot(c,4);
+        b ^= a; b -= rot(a,14);
+        c ^= b; c -= rot(b,24);
+    }
 }
 
 namespace snort
@@ -52,7 +53,7 @@ SO_PUBLIC void mix_str(
     // n == 0 => strlen(s)
     const char* s, unsigned n = 0);
 
-SO_PUBLIC size_t str_to_hash(const uint8_t *str, int length);
+SO_PUBLIC uint32_t str_to_hash(const uint8_t *str, size_t length);
 }
 
 struct HashFnc
@@ -74,7 +75,7 @@ int hashfcn_set_keyops(
     HashFnc*,
     // FIXIT-H use types for these callbacks
     unsigned (* hash_fcn)(HashFnc* p, const unsigned char* d, int n),
-    int (* keycmp_fcn)(const void* s1, const void* s2, size_t n) );
+    int (* keycmp_fcn)(const void* s1, const void* s2, size_t n));
 
 #endif
 
index 4033b5cedebdcfa200a74f073c44b6d57b0b4a9a..23ea06246b53dc49ac2d69cf5ef4e40e0f31afac 100644 (file)
@@ -190,7 +190,7 @@ TEST(ghash, userfree_test)
 
     // it should not be found
     CHECK(ghash_find(t, str) == nullptr);
-    
+
     // try to remove a node that is not in the table
     CHECK(ghash_remove(t, str) == GHASH_ERR);
 
index 3993a6cd49d8aa77545d10f328f6a9cccd6f72ec..9ec09967685ea49d68ce49e784d4510a03eb99ea 100644 (file)
@@ -149,10 +149,10 @@ TEST(lru_cache_shared, find_else_insert)
     std::shared_ptr<std::string> data(new std::string("12345"));
     LruCacheShared<int, std::string, std::hash<int> > lru_cache(1);
 
-    CHECK(false == lru_cache.find_else_insert(1,data)); 
+    CHECK(false == lru_cache.find_else_insert(1,data));
     CHECK(1 == lru_cache.size());
 
-    CHECK(true == lru_cache.find_else_insert(1,data)); 
+    CHECK(true == lru_cache.find_else_insert(1,data));
     CHECK(1 == lru_cache.size());
 }
 
index 709573c98d32f6dc0169d254bbcadb134f05ecfb..4ee2daeb1c02227abeeba72579d8f6f98e566dc0 100644 (file)
@@ -66,10 +66,10 @@ TEST(xhash, create_xhash_test)
 TEST(xhash, free_anr_lru_invalid_test)
 {
     int ret = xhash_free_anr_lru(nullptr);
-    CHECK(ret == XHASH_ERR); 
+    CHECK(ret == XHASH_ERR);
 }
 
-// Create a free node in xhash and verifies if xhash_free_anr_lru() deletes it 
+// Create a free node in xhash and verifies if xhash_free_anr_lru() deletes it
 TEST(xhash, free_anr_lru_delete_free_node_test)
 {
     XHash* test_table = xhash_new(3, sizeof(struct xhash_test_key),
@@ -86,7 +86,7 @@ TEST(xhash, free_anr_lru_delete_free_node_test)
     CHECK(ret == XHASH_OK);
 
     ret = xhash_free_anr_lru(test_table);
-    CHECK(ret == XHASH_OK); 
+    CHECK(ret == XHASH_OK);
 
     XHashNode* xhnode = xhash_find_node(test_table, &xtk);
     CHECK(xhnode == nullptr);
@@ -179,7 +179,7 @@ TEST(xhash, xhash_change_memcap_less_than_used_test)
 
     unsigned max_work = 0;
     unsigned new_memcap = test_table->mc.memused-1;
-    ret = xhash_change_memcap(test_table, new_memcap, &max_work);  
+    ret = xhash_change_memcap(test_table, new_memcap, &max_work);
     CHECK(ret == XHASH_OK);
     CHECK(test_table->mc.memcap == new_memcap);
     xhash_delete(test_table);
index 87ecab86d272b4aa4e444daae172b9cc60f7e367..8083d1d0d5cee686d0117b680d1b27eea01aebc6 100644 (file)
@@ -523,7 +523,7 @@ bool ByteJumpModule::set(const char*, Value& v, SnortConfig*)
 
     else if ( v.is("bitmask") )
         data.bitmask_val = v.get_uint32();
-    
+
     else
         return false;
 
index 905d47f6fe16ed78910bd67daba92b826acb7d3c..bf66ae0aecb0cd4c32433889404c16bc0510f958 100644 (file)
@@ -78,7 +78,7 @@
  *      msg: "got DEADBEEF!";)
  *
  * alert tcp any any -> any any \
- *      (byte_test:2, =, 568, 0, bitmask 0x3FF0;         \
+ *      (byte_test:2, =, 568, 0, bitmask 0x3FF0;      \
  *      msg:"got 568 after applying bitmask 0x3FF0 on 2 bytes extracted";)
  *
  * Effect:
index af2085241246eb50e043717e156516b97f920868..04b564adfd0b415a975cb4e2abe06b424b3e3256 100644 (file)
@@ -183,7 +183,7 @@ FastLogger::FastLogger(FastModule* m)
     // could be configurable; and should be should be shared with u2
 
     Inspector* ins = InspectorManager::get_inspector("http_inspect");
-    
+
     if ( !ins )
         return;
 
index 717d426c256b9cef1eed678fca5510b8f04807eb..89affe47a842b150372e0febab28d32d0c438332 100644 (file)
@@ -343,9 +343,9 @@ int main_reload_config(lua_State* L)
     if ( !sc )
     {
         if (get_reload_errors())
-         current_request->respond("== reload failed - restart required\n");
+            current_request->respond("== reload failed - restart required\n");
         else
-          current_request->respond("== reload failed - bad config\n");
+            current_request->respond("== reload failed - bad config\n");
 
         SnortConfig::set_parser_conf(nullptr);
         return 0;
index 8bad70d9b5803f21267c8292f30ff80de500cbf3..c1b32a6035686d0f7a7051730ce65871db4abc15 100644 (file)
@@ -180,7 +180,7 @@ ACDAQSwap::~ACDAQSwap()
     LogMessage("== daq module reload complete\n");
 }
 
-SFDAQInstance* AnalyzerCommand::get_daq_instance(Analyzer& analyzer) 
+SFDAQInstance* AnalyzerCommand::get_daq_instance(Analyzer& analyzer)
 {
     return analyzer.get_daq_instance();
 }
index a028d09534034cb5feb486071b1a3f9f4f2e5305..8d7a0d192c7a9c9bb80d4e9ee7c6ec8d329ea2ad 100644 (file)
@@ -47,9 +47,9 @@ bool Request::read(const int& f)
     fd = f;
     while ( (bytes_read < sizeof(read_buf)) and ((n = ::read(fd, &buf, 1)) > 0) )
     {
-        read_buf[bytes_read++] = buf; 
+        read_buf[bytes_read++] = buf;
 
-        if (buf == '\n') 
+        if (buf == '\n')
         {
             newline_found = true;
             break;
@@ -87,7 +87,7 @@ void Request::respond(const char* s, bool queue_response, bool remote_only)
 {
     if (remote_only && (fd == STDOUT_FILENO))
         return;
+
     if ( fd < 1 )
     {
         if (!remote_only)
index 03ac19db53cd687ed197a5ace4051930326cf157..a6ed56a78f94e6b2d0a64599b3af7f2a7e490bc0 100644 (file)
@@ -54,7 +54,7 @@ static inline void trace_vprintf(const char* name, Trace mask, const char* file,
     int size;
 
     if (name)
-    {   
+    {
         size = snprintf(buf, buf_len, "%s: ", name);
         if ( size >= buf_len )
             size = buf_len - 1;
index 25aac0e861e4bf67802472f48bcf6a16484433f9..ec700d209c103983c5e5c3a4616c0212d95287ae 100644 (file)
@@ -518,7 +518,7 @@ bool InspectorManager::inspector_exists_in_any_policy(const char* key, SnortConf
         const InspectionPolicy* const pi = pm->get_inspection_policy(i);
 
         if ( !pi || !pi->framework_policy )
-            continue; 
+            continue;
 
         const PHInstance* const p = get_instance(pi->framework_policy, key);
 
index a8c153d411ef62f38f6b43d9716394abbfb33955..a7fc56904ada1f17548382a8d4c924b06c1a102f 100644 (file)
@@ -83,7 +83,7 @@ public:
     static unsigned get_errors();
 
     static void dump_stats(SnortConfig*, const char* skip = nullptr, bool dynamic = false);
+
     static void accumulate(SnortConfig*);
     static void accumulate_offload(const char* name);
     static void reset_stats(SnortConfig*);
index 68b0a04923c40f16c3072ed703d1245b86084085..418c02750ec1ea74c95d39c26dfce2bd940366c3 100644 (file)
@@ -294,7 +294,7 @@ static void add_plugin(Plugin& p)
 
     case PT_INSPECTOR:
         // probes must always be global. they run regardless of selected policy.
-        assert( (m && ((const InspectApi*)p.api)->type == IT_PROBE) ? 
+        assert( (m && ((const InspectApi*)p.api)->type == IT_PROBE) ?
                 m->get_usage() == Module::GLOBAL :
                 true );
 
index 1c6082d81e93730c57839eea9d08cae69ea4382a..98ad1d64c65fa3835729525be1cc3f2d6d81f1c0 100644 (file)
@@ -246,7 +246,7 @@ bool AppIdConfig::init_appid(SnortConfig* sc)
     // Handle the if condition in AppIdConfig::init_appid
     static bool once = false;
     if (!once)
-    {   
+    {
         AppIdConfig::app_info_mgr.init_appid_info_table(mod_config, sc);
         HostPortCache::initialize();
         HttpPatternMatchers* http_matchers = HttpPatternMatchers::get_instance();
index 91c747af1509faa0f7913c02a7528e01642782d2..a13dd59216ebc24efb4b75c12a538cd6f56df6a9 100644 (file)
@@ -737,7 +737,7 @@ bool AppIdDiscovery::do_host_port_based_discovery(Packet* p, AppIdSession& asd,
     uint16_t port;
     const SfIp* ip;
     AppIdHttpSession* hsession = asd.get_http_session();
-    
+
     const TunnelDest* tun_dest = hsession->get_tun_dest();
     if(tun_dest)
     {
@@ -921,7 +921,7 @@ bool AppIdDiscovery::do_discovery(Packet* p, AppIdSession& asd, IpProtocol proto
 
     payload_id = asd.pick_payload_app_id();
     client_id = asd.pick_client_app_id();
-    misc_id =  asd.pick_misc_app_id();;
+    misc_id =  asd.pick_misc_app_id();
 
     bool is_http_tunnel = ((asd.payload.get_id() == APP_ID_HTTP_TUNNEL) || (asd.payload.get_id() == APP_ID_HTTP_SSL_TUNNEL)) ? true:false;
     if (is_check_host_cache_valid(asd, service_id, client_id, payload_id, misc_id) or (is_http_tunnel))
index bd0354bf07bdfd1de930ee8254ae859b5b0e88b1..b89b26771198d1edea7332db3dcc83844fcf6a3b 100644 (file)
@@ -55,7 +55,7 @@ struct Packet;
 #define SCAN_HTTP_VENDOR_FLAG       (1<<6)
 #define SCAN_HTTP_XWORKINGWITH_FLAG (1<<7)
 #define SCAN_HTTP_CONTENT_TYPE_FLAG (1<<8)
-#define SCAN_HTTP_URI_FLAG         (1<<9)
+#define SCAN_HTTP_URI_FLAG          (1<<9)
 
 class AppIdPatternMatchNode
 {
index d13682fb58f3ad922da51731a2d2a623ec7c77db..207d481b8a9035e02c9544181a0f4682db5bdbe3 100644 (file)
@@ -34,7 +34,7 @@ public:
 
     void reset()
     {
-        host.clear();;
+        host.clear();
         state = 0;
         response_type = 0;
         id = 0;
index 8436d6ee54ec1e9ed6100120ab23eb15f90485b8..18428ac41251af7beed2b77502dd4d1e10c37970 100644 (file)
@@ -178,7 +178,7 @@ void AppIdInspector::eval(Packet* p)
 {
     Profile profile(appid_perf_stats);
     appid_stats.packets++;
-    
+
     if (p->flow)
     {
         AppIdDiscovery::do_application_discovery(p, *this);
index 8b08e9ced02ca269c51af77c0ccebe4e63459c80..868f8e4c4b466659c7a0cb5ff9d7160712aa172a 100644 (file)
@@ -775,7 +775,7 @@ AppId AppIdSession::pick_payload_app_id()
 
     if (tp_payload_app_id_deferred)
         return tp_payload_app_id;
-    
+
     if (payload.get_id() > APP_ID_NONE)
         return payload.get_id();
 
index a085a32e4f62b030e664d743ee27cb1eea426975..71ff249d7a5edb457edca035fd373c9fa2724eb1 100644 (file)
@@ -26,7 +26,7 @@ enum AppidSessionDirection
 {
     APP_ID_FROM_INITIATOR,
     APP_ID_FROM_RESPONDER,
-    APP_ID_APPID_SESSION_DIRECTION_MAX 
+    APP_ID_APPID_SESSION_DIRECTION_MAX
 };
 
 #endif
index 372888cc60c422d9c856115cdc1c9ec4af48d9b2..c64f5e9056d8e72651f875ba5f9606385d5726f6 100644 (file)
@@ -329,14 +329,14 @@ static int get_sip_client_app(void* patternMatcher, const char* pattern, uint32_
 }
 
 void SipServiceDetector::createRtpFlow(AppIdSession& asd, const Packet* pkt, const SfIp* cliIp,
-    uint16_t cliPort, const SfIp* srvIp, uint16_t srvPort, IpProtocol proto, int16_t app_id)
+    uint16_t cliPort, const SfIp* srvIp, uint16_t srvPort, IpProtocol protocol, int16_t app_id)
 {
     //  FIXIT-RC: Passing app_id instead of SnortProtocolId to
     //  create_future_session is incorrect. We need to look up
     //  snort_protocol_id.
 
     AppIdSession* fp = AppIdSession::create_future_session(
-        pkt, cliIp, cliPort, srvIp, srvPort, proto, app_id,
+        pkt, cliIp, cliPort, srvIp, srvPort, protocol, app_id,
         APPID_EARLY_SESSION_FLAG_FW_RULE);
 
     if ( fp )
@@ -356,7 +356,7 @@ void SipServiceDetector::createRtpFlow(AppIdSession& asd, const Packet* pkt, con
     // create an RTCP flow as well
 
     AppIdSession* fp2 = AppIdSession::create_future_session(
-        pkt, cliIp, cliPort + 1, srvIp, srvPort + 1, proto, app_id,
+        pkt, cliIp, cliPort + 1, srvIp, srvPort + 1, protocol, app_id,
         APPID_EARLY_SESSION_FLAG_FW_RULE);
 
     if ( fp2 )
index 626c9fb68490a7f43131a997cbb8f4945cc6dfef..3b4f72b1254ea813523e349f4dd914f2b3a649ce 100644 (file)
@@ -100,7 +100,7 @@ public:
 
     static void set_client(SipUdpClientDetector* cd) { SipEventHandler::client = cd; }
     static void set_service(SipServiceDetector* sd) { SipEventHandler::service = sd; }
-  
+
     void subscribe(snort::SnortConfig* sc)
     { snort::DataBus::subscribe_global(SIP_EVENT_TYPE_SIP_DIALOG_KEY, this, sc); }
 
index 007a78e38df3976ea6f617e0a52825e5d6ce2a2e..4b159e2278341239fe10afb682f2407695ed85bb 100644 (file)
@@ -594,7 +594,7 @@ done:
     if(args.asd.get_session_flags(APPID_SESSION_SERVICE_DETECTED))
         args.asd.clear_session_flags(APPID_SESSION_CONTINUE | APPID_SESSION_CLIENT_GETS_SERVER_PACKETS);
     else
-        args.asd.clear_session_flags(APPID_SESSION_CLIENT_GETS_SERVER_PACKETS); 
+        args.asd.clear_session_flags(APPID_SESSION_CLIENT_GETS_SERVER_PACKETS);
     args.asd.set_client_detected();
     return APPID_SUCCESS;
 }
index ac098e00d8eb3f214f33589e6919deab3e0acb21..073dec62292fcd1abaeeb68c06c5ba9e2441c467 100644 (file)
@@ -16,9 +16,9 @@
 // with this program; if not, write to the Free Software Foundation, Inc.,
 // 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 //--------------------------------------------------------------------------
-                                                                            
-// http_xff_fields.h author Sourcefire Inc.                                
+
+// http_xff_fields.h author Sourcefire Inc.
+
 #ifndef HTTP_XFF_FIELDS_H
 #define HTTP_XFF_FIELDS_H
 
index 82548da0692715f1bdfbc41cfdfb767b1f9eb816..c613d73b1927806dc091eead8597a131b458190b 100644 (file)
@@ -107,7 +107,7 @@ public:
 
 // FIXIT-M: RELOAD - Don't use this class, required now to store LSD objects
 class LuaObject {
-   
+
 public:
     LuaObject() = default;
     virtual ~LuaObject() = default;
@@ -136,7 +136,7 @@ private:
 };
 
 class LuaServiceObject: public LuaObject
-{ 
+{
 public:
     ServiceDetector* sd;
     LuaServiceObject(AppIdDiscovery* sdm, const std::string& detector_name,
@@ -146,7 +146,7 @@ public:
 };
 
 class LuaClientObject : public LuaObject
-{ 
+{
 public:
     ClientDetector* cd;
     LuaClientObject(AppIdDiscovery* cdm, const std::string& detector_name,
index 7ec4470682e35c24b95a3e8c9f231c82fe1c8c99..81c341b248af139a0c288c1579bfbf258334c6f8 100644 (file)
@@ -90,7 +90,7 @@ bool get_lua_field(lua_State* L, int table, const char* field, IpProtocol& out)
 
 inline void set_control(lua_State* L, int is_control)
 {
-    lua_pushboolean (L, is_control); // push flag to stack 
+    lua_pushboolean (L, is_control); // push flag to stack
     lua_setglobal(L, "is_control"); // create global key to store value
     lua_pop(L, 1);
 }
index 011806cf37074ba05ec7faab96ace490765ab3e1..ccc282311722f8f332b207fd41aadf614960486f 100644 (file)
@@ -81,7 +81,7 @@ struct ServiceFTPData
     uint16_t port;
     int part_code_resp = 0;
     int part_code_len;
-    
+
 };
 
 #pragma pack(1)
@@ -307,7 +307,7 @@ static int CheckVendorVersion(const uint8_t* data, uint16_t init_offset,
     return 0;
 }
 
-static FtpEolReturn ftp_parse_response(const uint8_t* data, uint16_t& offset, 
+static FtpEolReturn ftp_parse_response(const uint8_t* data, uint16_t& offset,
     uint16_t size, ServiceFTPData& fd, FTPReplyState rstate)
 {
     for (; offset < size; ++offset)
@@ -347,26 +347,26 @@ static bool check_ret_digit_code(const uint8_t* code_raw, int start_digit_place,
                 code += (code_raw[index] - '0') * 100;
             else
                 ret = false;
-            break;    
+            break;
         case 2:
             if (ret and fd.rstate == FTP_REPLY_BEGIN and  code_raw[index ] >='0' and code_raw[index] <= '5')
                 code += (code_raw[index] - '0') * 10;
             else if (ret and fd.rstate != FTP_REPLY_BEGIN and  code_raw[index ] >='1' and code_raw[index] <= '5')
                 code += (code_raw[index] - '0') * 10;
-            else 
+            else
                 ret = false;
-            break;  
-        case 1:     
+            break;
+        case 1:
             if (ret and isdigit(code_raw[index ]))
                 code += (code_raw[index] - '0') ;
-            else 
+            else
                 ret = false;
             break;
         default:
             break;
         }
     }
-    
+
     return ret;
 }
 
@@ -397,9 +397,9 @@ static int ftp_validate_reply(const uint8_t* data, uint16_t& offset,
 
             fd.code = 0;
             ret_code = check_ret_digit_code(code_hdr->code, 3,1, fd.code, fd );
-            
+
             if(!ret_code)
-                return -1; 
+                return -1;
 
             if (code_hdr->sp == '-')
                 fd.rstate = FTP_REPLY_MULTI;
@@ -465,12 +465,12 @@ static int ftp_validate_reply(const uint8_t* data, uint16_t& offset,
             }
 
             fd.rstate = FTP_REPLY_MID;
-            
+
             if ( ftp_parse_response(data, offset, size, fd, tmp_state ) == FTP_INCORRECT_EOL)
                 return -1;
             if (fd.rstate == FTP_REPLY_MID)
                 fd.rstate = FTP_REPLY_LONG;
-                 
+
             break;
         case FTP_REPLY_MULTI:
             if (size - offset < (int)sizeof(ServiceFTPCode))
@@ -491,7 +491,7 @@ static int ftp_validate_reply(const uint8_t* data, uint16_t& offset,
 
                 if (fd.rstate == FTP_REPLY_MID)
                     fd.rstate = FTP_REPLY_LONG;
-                    
+
             }
             else
             {
@@ -551,7 +551,7 @@ static int ftp_validate_reply(const uint8_t* data, uint16_t& offset,
                     if(!ret_code)
                         return -1;
                     fd.code = tmp + fd.part_code_resp;
-                    fd.part_code_resp = 0; 
+                    fd.part_code_resp = 0;
                     if (ftp_parse_response(data, offset, size, fd, FTP_REPLY_LONG)  == FTP_INCORRECT_EOL)
                         return -1;
 
@@ -877,7 +877,7 @@ static inline void WatchForCommandResult(ServiceFTPData* fd, AppIdSession& asd,
 }
 
 void FtpServiceDetector::create_expected_session(AppIdSession& asd, const Packet* pkt, const SfIp* cliIp,
-    uint16_t cliPort, const SfIp* srvIp, uint16_t srvPort, IpProtocol proto,
+    uint16_t cliPort, const SfIp* srvIp, uint16_t srvPort, IpProtocol protocol,
     int flags, AppidSessionDirection dir)
 {
     // FIXIT-M - Avoid thread locals
@@ -886,7 +886,7 @@ void FtpServiceDetector::create_expected_session(AppIdSession& asd, const Packet
         ftp_data_snort_protocol_id = SnortConfig::get_conf()->proto_ref->find("ftp-data");
 
     AppIdSession* fp = AppIdSession::create_future_session(pkt, cliIp, cliPort, srvIp, srvPort,
-        proto, ftp_data_snort_protocol_id, flags);
+        protocol, ftp_data_snort_protocol_id, flags);
 
     if (fp) // initialize data session
     {
index 6f70d2f6b7aa21312433e81c84cf0eff04899b7c..cab73037c08f9512d17e22d5a2575eead66cfa44 100644 (file)
@@ -34,9 +34,9 @@ public:
     int validate(AppIdDiscoveryArgs&) override;
 
 private:
-    void create_expected_session(AppIdSession& asd,const snort::Packet* pkt,
+    void create_expected_session(AppIdSession&, const snort::Packet*,
         const snort::SfIp* cliIp, uint16_t cliPort, const snort::SfIp* srvIp,
-        uint16_t srvPort, IpProtocol proto, int flags, AppidSessionDirection dir);
+        uint16_t srvPort, IpProtocol, int flags, AppidSessionDirection);
 };
 #endif
 
index 435bb46684a52b1d4f98afcf0a3cc917ef26c243..88e3fc20c23e46df0dd758695b90fa79677afcc8 100644 (file)
@@ -121,7 +121,7 @@ MdnsServiceDetector::~MdnsServiceDetector()
 }
 
 void MdnsServiceDetector::release_thread_resources()
-{   
+{
     MatchedPatterns* node;
 
     destroy_match_list();
index b13d7104b38ef76a0602e8273c0adc58fc1a9c88..9fc83852e0bcd2cd7cccf435d055507a78edbd36 100644 (file)
@@ -105,7 +105,7 @@ static void rexec_free_state(void* data)
 
 void RexecServiceDetector::rexec_bail(ServiceREXECData* rd)
 {
-    if (!rd) 
+    if (!rd)
         return;
     rd->state = REXEC_STATE_BAIL;
     if(rd->child)
@@ -292,7 +292,7 @@ int RexecServiceDetector::validate(AppIdDiscoveryArgs& args)
         }
         goto bail;
     case REXEC_STATE_STDERR_WAIT:
-        if(!size) 
+        if(!size)
             break;
         goto bail;
     case REXEC_STATE_STDERR_DONE:
index 88302f27f25d1687b0b18bd836d0bdacf9add2ac..75e12b46038640d89eadae1efa3e07295c25eea7 100644 (file)
@@ -267,7 +267,7 @@ int RshellServiceDetector::validate(AppIdDiscoveryArgs& args)
             goto fail;
         if (size == 1 || *data == 0x01)
         {
-            if(size !=1) 
+            if(size !=1)
             {
                 data++;
                 size--;
@@ -278,12 +278,12 @@ int RshellServiceDetector::validate(AppIdDiscoveryArgs& args)
                 }
             }
             if(rd->child)
-            { 
+            {
                 if(rd->child->state == RSHELL_STATE_STDERR_WAIT)
                     rd->child->state = RSHELL_STATE_STDERR_DONE;
                 else
                     goto fail;
-            } 
+            }
             args.asd.clear_session_flags(APPID_SESSION_CONTINUE);
             goto success;
         }
index f97446254a7a4f499355f4e347d7022f2774e966..69ea7bff582654ad407597f7ceb493f9dc39ed95 100644 (file)
@@ -495,7 +495,7 @@ static bool parse_certificates(ServiceSSLData* ss)
                     {
                         if ((start = strstr(cert_name, COMMON_NAME_STR)))
                         {
-                                                       int length;
+                            int length;
                             start += strlen(COMMON_NAME_STR);
                             length = strlen(start);
                             if (length > 2 and *start == '*' and *(start+1) == '.')
index cb2e4c8965055cc3ab6dfea26f0279609d86628f..f5e9e7dc1709c15a9cac2213b13c6ff8205e9d94 100644 (file)
@@ -255,7 +255,7 @@ TEST(appid_http_session, set_tun_dest)
     AppidChangeBits change_bits;
     hsession.set_field(REQ_URI_FID, new std::string("[2001:db8:85a3::8a2e:370:7334]:51413"), change_bits);
     hsession.set_tun_dest();
-    tun_dest = hsession.get_tun_dest(); 
+    tun_dest = hsession.get_tun_dest();
     CHECK(tun_dest != nullptr);
     CHECK_EQUAL(tun_dest->port, 51413);
     CHECK_EQUAL((ipv6 == tun_dest->ip), true);
index e869af5b5738ce4767505e6d017360ba09b26d87..329c21477ec0956234541d7c25a3dd622688ab33 100644 (file)
@@ -12,7 +12,7 @@ using namespace std;
 namespace snort
 {
 // Note: without SO_PUBLIC this is not being exported so tp_mock.so won't
-// load because of undefined symbol error. 
+// load because of undefined symbol error.
 SO_PUBLIC void ErrorMessage(const char* format,...)
 {
     va_list ap;
index 8b0b53f58e2766ef60eaf332e1b83f2a525a7fc0..9b1b9460f9b33e4a39cfd316e718f3057f86c105 100644 (file)
@@ -210,7 +210,7 @@ static inline void process_http_session(AppIdSession& asd,
             hsession->set_offset(REQ_URI_FID,
                 attribute_data.http_request_uri_begin(),
                 attribute_data.http_request_uri_end());
-            asd.scan_flags |= SCAN_HTTP_URI_FLAG; 
+            asd.scan_flags |= SCAN_HTTP_URI_FLAG;
             if (appidDebug->is_active())
                 LogMessage("AppIdDbg %s URI (%u-%u) is %s\n", appidDebug->get_debug_session(),
                     attribute_data.http_request_uri_begin(),
@@ -447,28 +447,28 @@ static inline void process_rtmp(AppIdSession& asd,
             asd.scan_flags |= SCAN_HTTP_USER_AGENT_FLAG;
         }
     }
-    
-    if ( ( asd.scan_flags & SCAN_HTTP_USER_AGENT_FLAG ) and 
+
+    if ( ( asd.scan_flags & SCAN_HTTP_USER_AGENT_FLAG ) and
          asd.client.get_id() <= APP_ID_NONE and
-         ( field = hsession->get_field(REQ_AGENT_FID) ) and 
+         ( field = hsession->get_field(REQ_AGENT_FID) ) and
          ( size = attribute_data.http_request_user_agent_end() -
            attribute_data.http_request_user_agent_begin() ) > 0 )
     {
         char *version = nullptr;
         HttpPatternMatchers* http_matchers = HttpPatternMatchers::get_instance();
-       
-        http_matchers->identify_user_agent(field->c_str(), size, service_id, 
+
+        http_matchers->identify_user_agent(field->c_str(), size, service_id,
         client_id, &version);
-        
+
         asd.set_client_appid_data(client_id, change_bits, version);
-        
+
         // do not overwrite a previously-set service
         if ( service_id <= APP_ID_NONE )
             asd.set_service_appid_data(service_id, change_bits);
-        
+
         asd.scan_flags |= ~SCAN_HTTP_USER_AGENT_FLAG;
         snort_free(version);
-    }     
+    }
 
     if ( hsession->get_field(MISC_URL_FID) || (confidence == 100 &&
         asd.session_packet_count > asd.config->mod_config->rtmp_max_packets) )
index aff1f41cdfb11327d7c469edbd98177a341af3ba..f28b563f77779660643561cdcc994870302b8cd1 100644 (file)
@@ -274,7 +274,7 @@ inline Binding::DirResult Binding::check_split_addr(
 
     if ( !when.src_nets && !when.dst_nets )
         return dr;
-    
+
     const SfIp* src_ip;
     const SfIp* dst_ip;
 
@@ -299,14 +299,14 @@ inline Binding::DirResult Binding::check_split_port(
 {
     if ( !when.split_ports )
         return dr;
-    
+
     uint16_t src_port;
     uint16_t dst_port;
 
     if ( !p )
     {
-        src_port = flow->client_port; 
-        dst_port = flow->server_port; 
+        src_port = flow->client_port;
+        dst_port = flow->server_port;
     }
     else if ( p->is_tcp() or p->is_udp() )
     {
@@ -399,7 +399,7 @@ bool Binding::check_all(const Flow* flow, Packet* p, const char* service) const
     {
         if (!check_service(service))
             return false;
-    } 
+    }
     else if ( !check_service(flow) )
         return false;
 
@@ -710,7 +710,7 @@ public:
     {
         Binder* binder = InspectorManager::get_binder();
         AssistantGadgetEvent* assistant_event = (AssistantGadgetEvent*)&event;
-       
+
         if (binder)
             binder->handle_assistant_gadget(assistant_event->get_service(),
                 assistant_event->get_packet());
@@ -878,7 +878,7 @@ void Binder::handle_assistant_gadget(const char* service, Packet* p)
     Profile profile(bindPerfStats);
     Stuff stuff;
     Flow* flow = p->flow;
-    
+
     get_bindings(flow, stuff, p, service);
     apply_assistant(flow, stuff, service);
 }
index 6f170c774f2d2bd5ede6c7e2c453b3c8b84c1816..cb894040f9f4848289ce4d2c1ed8493825c0210d 100644 (file)
@@ -191,7 +191,7 @@ static const Parameter s_params[] =
 //-------------------------------------------------------------------------
 
 // using string* instead of string because clang++ 5.1
-// vector::back() does not seem to return a reference 
+// vector::back() does not seem to return a reference
 //
 // FIXIT-L these are static since get_pegs() is const
 // consider making that non-const
index e37f2834e81bd7cf8ec679ff4f5c4cc438d7842a..fefed5ed7a9ac729e5a9b0d534424bda2213c6e7 100644 (file)
@@ -104,7 +104,7 @@ PacketCaptureDebug::PacketCaptureDebug(const char* f)
     {
         filter = f;
         enable = true;
-    } 
+    }
 }
 
 bool PacketCaptureDebug::execute(Analyzer&, void**)
index f5b45e89298d76df340d3b9a179be6eab3dda38b..60ce2a272f35db9623416d8428f6f38a756d6e4d 100644 (file)
@@ -204,7 +204,7 @@ void PacketCapture::eval(Packet* p)
         if ( !capture_initialized() )
             if ( !capture_init() )
                 return;
-                
+
         if ( p->is_cooked() )
             return;
 
index 222fc00afa0c72b5fb8687f8eb5715178aa822ae..6b8a57f390f729f38fe5f215ed086fb47c192002 100644 (file)
@@ -173,7 +173,7 @@ void PacketTracer::set_constraints(const PTSessionConstraints* constraints)
         LogMessage("Debugging packet tracer disabled\n");
         s_pkt_trace->shell_enabled = false;
     }
-    else 
+    else
         s_pkt_trace->update_constraints(constraints);
 }
 
@@ -210,7 +210,7 @@ void PacketTracer::activate(const Packet& p)
 
     if ( p.pkth->flags &  DAQ_PKT_FLAG_TRACE_ENABLED )
         s_pkt_trace->daq_activated = true;
-    else 
+    else
         s_pkt_trace->daq_activated = false;
 
     if (s_pkt_trace->daq_activated or s_pkt_trace->user_enabled or s_pkt_trace->shell_enabled)
@@ -270,12 +270,12 @@ PacketTracer::~PacketTracer()
 }
 
 void PacketTracer::log(const char* format, va_list ap)
-{       
+{
     // FIXIT-L Need to find way to add 'PktTracerDbg' string as part of format string.
     std::string dbg_str;
     if (shell_enabled) // only add debug string during shell execution
     {
-        dbg_str = "PktTracerDbg "; 
+        dbg_str = "PktTracerDbg ";
         if (strcmp(format, "\n") != 0)
             dbg_str += get_debug_session();
         dbg_str += format;
@@ -301,7 +301,7 @@ void PacketTracer::add_ip_header_info(const Packet& p)
 
     const SfIp* actual_sip = p.ptrs.ip_api.get_src();
     const SfIp* actual_dip = p.ptrs.ip_api.get_dst();
-    
+
     IpProtocol proto = p.get_ip_proto_next();
 
     actual_sip->ntop(sipstr, sizeof(sipstr));
@@ -570,7 +570,7 @@ TEST_CASE("enable", "[PacketTracer]")
     CHECK(!TestPacketTracer::is_daq_enabled());
     // user configuration remain enabled
     CHECK(TestPacketTracer::is_user_enabled());
-    
+
     TestPacketTracer::thread_term();
 }
 
@@ -617,14 +617,14 @@ TEST_CASE("reasons", "[PacketTracer]")
     TestPacketTracer::register_verdict_reason(low1, PacketTracer::PRIORITY_LOW);
     TestPacketTracer::register_verdict_reason(low2, PacketTracer::PRIORITY_LOW);
     TestPacketTracer::register_verdict_reason(high, PacketTracer::PRIORITY_HIGH);
-    
+
     // Init
     CHECK((TestPacketTracer::get_reason() == VERDICT_REASON_NO_BLOCK));
-    
+
     // Update
     TestPacketTracer::set_reason(low1);
     CHECK((TestPacketTracer::get_reason() == low1));
-    
+
     // Don't update if already set
     TestPacketTracer::set_reason(VERDICT_REASON_NO_BLOCK);
     CHECK((TestPacketTracer::get_reason() == low1));
@@ -669,7 +669,7 @@ TEST_CASE("verbosity", "[PacketTracer]")
     TestPacketTracer::log(mute_2, "this should also log\n");
     val = TestPacketTracer::get_buff();
     CHECK((val == expected));
-       
+
     TestPacketTracer::thread_term();
 }
 
index d70e04df1061cd5b8f5f1947bef378f689001eec..e8d28a60a74b601d6c831ba78f3bee2330d7098c 100644 (file)
@@ -95,7 +95,7 @@ public:
     typedef uint8_t TracerMute;
     static const int max_buff_size = 2048;
 
-    // static functions 
+    // static functions
     static void set_log_file(const std::string&);
     static void thread_init();
     static void thread_term();
@@ -106,12 +106,12 @@ public:
     static void configure(bool status, const std::string& file_name);
     static void set_constraints(const PTSessionConstraints* constraints);
     static void activate(const snort::Packet&);
-    
+
     static SO_PUBLIC void pause();
     static SO_PUBLIC void unpause();
     static SO_PUBLIC bool is_paused();
     static SO_PUBLIC bool is_active();
-    
+
     static SO_PUBLIC TracerMute get_mute();
 
     static SO_PUBLIC void register_verdict_reason(uint8_t reason_code, uint8_t priority);
@@ -137,7 +137,7 @@ protected:
 
     char debug_session[PT_DEBUG_SESSION_ID_SIZE];
     PTSessionConstraints info;
-    
+
     // static functions
     template<typename T = PacketTracer> static void _thread_init();
 
@@ -157,9 +157,9 @@ protected:
 
 SO_PUBLIC extern THREAD_LOCAL PacketTracer* s_pkt_trace;
 
-inline bool PacketTracer::is_active() 
+inline bool PacketTracer::is_active()
 { return s_pkt_trace ? s_pkt_trace->active : false; }
 
 }
-  
+
 #endif
index 9f7ab449f6a07f3ebd61169670569d36943769cf..c891623937f9a48f12f0997a6856702dea752921 100644 (file)
@@ -92,7 +92,7 @@ bool PacketTracerDebug::execute(Analyzer&, void**)
 {
     if (enable)
         PacketTracer::set_constraints(&constraints);
-    else 
+    else
         PacketTracer::set_constraints(nullptr);
 
     return true;
@@ -196,7 +196,7 @@ bool PacketTracerModule::begin(const char*, int, SnortConfig*)
 }
 bool PacketTracerModule::end(const char*, int, SnortConfig*)
 {
-    if (config != nullptr) 
+    if (config != nullptr)
     {
         PacketTracer::configure(config->enabled, config->file);
         delete config;
index 320532a35b21c40c1a3246217045e7291ce0b0ce..3b4d30f9205cf53f89e26af9cdb59dc7bf7c94b6 100644 (file)
@@ -48,7 +48,7 @@ void JSONFormatter::write(FILE* fh, time_t cur_time)
     for( unsigned i = 0; i < values.size(); i++ )
     {
         bool head = false;
-        
+
         for( unsigned j = 0; j < values[i].size(); j++ )
         {
             switch( types[i][j] )
@@ -56,7 +56,7 @@ void JSONFormatter::write(FILE* fh, time_t cur_time)
                 case FT_PEG_COUNT:
                     if( *values[i][j].pc != 0 )
                     {
-                        if( !head ) 
+                        if( !head )
                         {
                             ss << ",\"" << section_names[i] << "\":{";
                             head = true;
@@ -159,7 +159,7 @@ TEST_CASE("json output", "[JSONFormatter]")
     kvp.emplace_back(50);
     kvp.emplace_back(0);
     kvp.emplace_back(70);
-    
+
     f.write(fh, (time_t)1234567890);
 
     one = 0;
index 20549decf746d2933050afd9c05a2e605c76b761..f3d4636cbda8b8e93ca9ef430589ecf0cb2a8b1e 100644 (file)
@@ -36,9 +36,9 @@ using namespace snort;
 
    Snort Accepts:
 
-   IP-Address          192.168.1.1
-   IP-Address/MaskBits 192.168.1.0/24
-   IP-Address/Mask             192.168.1.0/255.255.255.0
+   IP-Address           192.168.1.1
+   IP-Address/MaskBits  192.168.1.0/24
+   IP-Address/Mask      192.168.1.0/255.255.255.0
 
    These can all be handled via the CIDR block notation : IP/MaskBits
 
index 6717fdfeae915e4a1c5630de8015dd72c66c431c..5e6c6a65509bb198404d0f7c726f2f33605266bf 100644 (file)
@@ -62,9 +62,9 @@ struct IPSET
 
    Snort Accepts:
 
-    IP-Address         192.168.1.1
-    IP-Address/MaskBits        192.168.1.0/24
-    IP-Address/Mask            192.168.1.0/255.255.255.0
+    IP-Address          192.168.1.1
+    IP-Address/MaskBits 192.168.1.0/24
+    IP-Address/Mask     192.168.1.0/255.255.255.0
 
    These can all be handled via the CIDR block notation : IP/MaskBits
 
index 4f96d9e6d2140348fa1cd53b0d3de46f442eaf49..bd3f4de69cf8d306775e98b7ac6428aac8ca1d66 100644 (file)
@@ -102,7 +102,7 @@ static void make_open_port_info(Packet* p, PS_PROTO* proto)
 static void make_open_port_info(Packet* p, uint16_t port)
 {
     DataBuffer& buf = DetectionEngine::get_alt_buffer(p);
-    
+
     SfIpString ip_str;
 
     buf.len = safe_snprintf((char*)buf.data, sizeof(buf.data),
index ee3bbeabf21f3fedc34c4f52afc661bb8afdd33f..d0d52cc58086da6e92d740c7addaf74ab7d56704 100644 (file)
@@ -49,7 +49,7 @@ static const Parameter daqvar_list_param[] =
     { nullptr, Parameter::PT_MAX, nullptr, nullptr, nullptr }
 };
 
-static const Parameter daq_module_param[] = 
+static const Parameter daq_module_param[] =
 {
     { "name", Parameter::PT_STRING, nullptr, nullptr, "DAQ module name (required)" },
     { "mode", Parameter::PT_ENUM, "passive | inline | read-file", "passive", "DAQ module mode" },
index 5daab05e4a8ce04b93ec0d999f0598b81487efb9..cd07d540ab50572c2488fd79909d1df611ff2b45 100644 (file)
@@ -819,7 +819,7 @@ void AddVarToTable(SnortConfig* sc, const char* name, const char* value)
 }
 
 //--------------------------------------------------------------------------
-// unit tests 
+// unit tests
 //--------------------------------------------------------------------------
 
 #ifdef UNIT_TEST
index efb770ec941ea16f617bde942f6b59e558714350..dec20d2d3c5b8e9ecacdb7b7af8cb287f21aa6eb 100644 (file)
@@ -53,8 +53,8 @@ struct GetProfileFunctor
 
 struct GetProfileFromModule : public GetProfileFunctor
 {
-    GetProfileFromModule(const std::string& name, Module* m) :
-        GetProfileFunctor(name), m(m) { }
+    GetProfileFromModule(const std::string& pn, Module* m) :
+        GetProfileFunctor(pn), m(m) { }
 
     const ProfileStats* operator()() override
     {
@@ -76,8 +76,8 @@ struct GetProfileFromModule : public GetProfileFunctor
 
 struct GetProfileFromFunction : public GetProfileFunctor
 {
-    GetProfileFromFunction(const std::string& name, get_profile_stats_fn fn) :
-        GetProfileFunctor(name), fn(fn) { }
+    GetProfileFromFunction(const std::string& pn, get_profile_stats_fn fn) :
+        GetProfileFunctor(pn), fn(fn) { }
 
     const ProfileStats* operator()() override
     { return fn(name.c_str()); }
index e729c31a4ac7ca4afaf209a522230ed0a49b69ed..0fd3fb50d89e7f57b3bb827c17f12da900558768 100644 (file)
@@ -590,13 +590,13 @@ const uint8_t* PacketManager::encode_reject(UnreachResponse type,
 
         checksum::Pseudoheader6 ps6;
         const int ip_len = buf.size();
-        memcpy(ps6.sip, ip6h->get_src()->u6_addr8, sizeof(ps6.sip));
-        memcpy(ps6.dip, ip6h->get_dst()->u6_addr8, sizeof(ps6.dip));
-        ps6.zero = 0;
-        ps6.protocol = IpProtocol::ICMPV6;
-        ps6.len = htons((uint16_t)(ip_len));
+        memcpy(ps6.hdr.sip, ip6h->get_src()->u6_addr8, sizeof(ps6.hdr.sip));
+        memcpy(ps6.hdr.dip, ip6h->get_dst()->u6_addr8, sizeof(ps6.hdr.dip));
+        ps6.hdr.zero = 0;
+        ps6.hdr.protocol = IpProtocol::ICMPV6;
+        ps6.hdr.len = htons((uint16_t)(ip_len));
 
-        icmph->csum = checksum::icmp_cksum((uint16_t*)buf.data(), ip_len, &ps6);
+        icmph->csum = checksum::icmp_cksum((uint16_t*)buf.data(), ip_len, ps6);
 
         if (encode(p, flags, inner_ip_index, IpProtocol::ICMPV6, buf))
         {
index 6a0ebf155ab031cf71286ee531da282aeaba7808..10d79a7b57828f3bc19dc567897900383c967c64 100644 (file)
@@ -201,7 +201,7 @@ struct SSLv2_shello_t
 #define SSL_IS_CKEYX(x) ((x) & SSL_CLIENT_KEYX_FLAG)
 #define SSL_IS_APP(x) (((x) & SSL_SAPP_FLAG) || ((x) & SSL_CAPP_FLAG))
 #define SSL_IS_ALERT(x) ((x) & SSL_ALERT_FLAG)
-#define SSL_CLEAR_TEMPORARY_FLAGS(x) x &= ~SSL_STATEFLAGS;
+#define SSL_CLEAR_TEMPORARY_FLAGS(x) (x) &= ~SSL_STATEFLAGS
 
 /* Verifies that the error flags haven't been triggered */
 #define SSL_IS_CLEAN(x) \
index 87291d0ef613e939f580266dbf4392c6a8cdcd3e..77df5f64182a5177ff2ea1b128a2f9e6a325c5d6 100644 (file)
@@ -62,8 +62,6 @@
 
 using namespace snort;
 
-#define MEMASSERT(p,s) if (!(p)) { fprintf(stderr,"ACSM-No Memory: %s\n",s); exit(0); }
-
 static int max_memory = 0;
 
 static void* AC_MALLOC(int n)
@@ -115,7 +113,6 @@ static ACSM_PATTERN* CopyMatchListEntry(ACSM_PATTERN* px)
 {
     ACSM_PATTERN* p;
     p = (ACSM_PATTERN*)AC_MALLOC(sizeof(ACSM_PATTERN));
-    MEMASSERT(p, "CopyMatchListEntry");
     memcpy(p, px, sizeof (ACSM_PATTERN));
     px->udata->ref_count++;
     p->next = nullptr;
@@ -130,7 +127,6 @@ static void AddMatchListEntry(ACSM_STRUCT* acsm, int state, ACSM_PATTERN* px)
 {
     ACSM_PATTERN* p;
     p = (ACSM_PATTERN*)AC_MALLOC(sizeof(ACSM_PATTERN));
-    MEMASSERT(p, "AddMatchListEntry");
     memcpy(p, px, sizeof (ACSM_PATTERN));
     p->next = acsm->acsmStateTable[state].MatchList;
     acsm->acsmStateTable[state].MatchList = p;
@@ -279,7 +275,6 @@ static void Convert_NFA_To_DFA(ACSM_STRUCT* acsm)
 ACSM_STRUCT* acsmNew(const MpseAgent* agent)
 {
     ACSM_STRUCT* p = (ACSM_STRUCT*)AC_MALLOC (sizeof (ACSM_STRUCT));
-    MEMASSERT(p, "acsmNew");
 
     if (p)
     {
@@ -297,14 +292,12 @@ int acsmAddPattern(
 {
     ACSM_PATTERN* plist;
     plist = (ACSM_PATTERN*)AC_MALLOC (sizeof (ACSM_PATTERN));
-    MEMASSERT(plist, "acsmAddPattern");
     plist->patrn = (uint8_t*)AC_MALLOC (n);
     ConvertCaseEx (plist->patrn, pat, n);
     plist->casepatrn = (uint8_t*)AC_MALLOC (n);
     memcpy(plist->casepatrn, pat, n);
 
     plist->udata = (ACSM_USERDATA*)AC_MALLOC(sizeof(ACSM_USERDATA));
-    MEMASSERT(plist->udata, "acsmAddPattern");
     plist->udata->ref_count = 1;
     plist->udata->id = user;
 
@@ -366,7 +359,6 @@ static inline int _acsmCompile(ACSM_STRUCT* acsm)
     }
     acsm->acsmStateTable =
         (ACSM_STATETABLE*)AC_MALLOC (sizeof (ACSM_STATETABLE) * acsm->acsmMaxStates);
-    MEMASSERT(acsm->acsmStateTable, "_acsmCompile");
 
     /* Initialize state zero as a branch */
     acsm->acsmNumStates = 0;
index e5a3829b2651cfc1501064cd2c3038262d80b89e..23036464fcaf60ea4c2c577618b14f4e521f27e1 100644 (file)
@@ -128,8 +128,6 @@ using namespace snort;
 
 #define printf LogMessage
 
-#define MEMASSERT(p,s) if (!(p)) { FatalError("ACSM-No Memory: %s\n",s); }
-
 static int acsm2_total_memory = 0;
 static int acsm2_pattern_memory = 0;
 static int acsm2_matchlist_memory = 0;
@@ -550,7 +548,6 @@ static ACSM_PATTERN2* CopyMatchListEntry(ACSM_PATTERN2* px)
     ACSM_PATTERN2* p;
 
     p = (ACSM_PATTERN2*)AC_MALLOC(sizeof (ACSM_PATTERN2), ACSM2_MEMORY_TYPE__MATCHLIST);
-    MEMASSERT(p, "CopyMatchListEntry");
 
     memcpy(p, px, sizeof (ACSM_PATTERN2));
 
@@ -587,7 +584,6 @@ static void AddMatchListEntry(ACSM_STRUCT2* acsm, int state, ACSM_PATTERN2* px)
     ACSM_PATTERN2* p;
 
     p = (ACSM_PATTERN2*)AC_MALLOC(sizeof (ACSM_PATTERN2), ACSM2_MEMORY_TYPE__MATCHLIST);
-    MEMASSERT(p, "AddMatchListEntry");
 
     memcpy(p, px, sizeof (ACSM_PATTERN2));
     p->next = acsm->acsmMatchList[state];
@@ -1104,7 +1100,6 @@ static int Conv_Full_DFA_To_SparseBands(ACSM_STRUCT2* acsm)
 ACSM_STRUCT2* acsmNew2(const MpseAgent* agent, int format)
 {
     ACSM_STRUCT2* p = (ACSM_STRUCT2*)AC_MALLOC(sizeof (ACSM_STRUCT2), ACSM2_MEMORY_TYPE__NONE);
-    MEMASSERT(p, "acsmNew");
 
     if (p)
     {
@@ -1133,17 +1128,14 @@ int acsmAddPattern2(
 
     plist = (ACSM_PATTERN2*)
         AC_MALLOC(sizeof (ACSM_PATTERN2), ACSM2_MEMORY_TYPE__PATTERN);
-    MEMASSERT(plist, "acsmAddPattern");
 
     plist->patrn =
         (uint8_t*)AC_MALLOC(n, ACSM2_MEMORY_TYPE__PATTERN);
-    MEMASSERT(plist->patrn, "acsmAddPattern");
 
     ConvertCaseEx(plist->patrn, pat, n);
 
     plist->casepatrn =
         (uint8_t*)AC_MALLOC(n, ACSM2_MEMORY_TYPE__PATTERN);
-    MEMASSERT(plist->casepatrn, "acsmAddPattern");
 
     memcpy(plist->casepatrn, pat, n);
 
@@ -1250,13 +1242,11 @@ static inline int _acsmCompile2(ACSM_STRUCT2* acsm)
     acsm->acsmTransTable =
         (trans_node_t**)AC_MALLOC(sizeof(trans_node_t*) * acsm->acsmMaxStates,
             ACSM2_MEMORY_TYPE__TRANSTABLE);
-    MEMASSERT(acsm->acsmTransTable, "_acsmCompile2");
 
     /* Alloc a MatchList table - this has a list of pattern matches for each state, if any */
     acsm->acsmMatchList =
         (ACSM_PATTERN2**)AC_MALLOC(sizeof(ACSM_PATTERN2*) * acsm->acsmMaxStates,
             ACSM2_MEMORY_TYPE__MATCHLIST);
-    MEMASSERT(acsm->acsmMatchList, "_acsmCompile2");
 
     /* Initialize state zero as a branch */
     acsm->acsmNumStates = 0;
@@ -1300,15 +1290,11 @@ static inline int _acsmCompile2(ACSM_STRUCT2* acsm)
         (acstate_t*)AC_MALLOC(sizeof(acstate_t) * acsm->acsmNumStates,
             ACSM2_MEMORY_TYPE__FAILSTATE);
 
-    MEMASSERT(acsm->acsmFailState, "_acsmCompile2");
-
     /* Alloc a separate state transition table == in state 's' due to event 'k', transition to
       'next' state */
     acsm->acsmNextState =
         (acstate_t**)AC_MALLOC_DFA(acsm->acsmNumStates * sizeof(acstate_t*), acsm->sizeofstate);
 
-    MEMASSERT(acsm->acsmNextState, "_acsmCompile2-NextState");
-
     /* Build the NFA */
     Build_NFA(acsm);
 
@@ -1690,21 +1676,21 @@ int acsm_search_dfa_full(
     {
         uint8_t* ps;
         uint8_t** NextState = (uint8_t**)acsm->acsmNextState;
-        AC_SEARCH;
+        AC_SEARCH
     }
     break;
     case 2:
     {
         uint16_t* ps;
         uint16_t** NextState = (uint16_t**)acsm->acsmNextState;
-        AC_SEARCH;
+        AC_SEARCH
     }
     break;
     default:
     {
         acstate_t* ps;
         acstate_t** NextState = acsm->acsmNextState;
-        AC_SEARCH;
+        AC_SEARCH
     }
     break;
     }
@@ -1790,21 +1776,21 @@ int acsm_search_dfa_full_all(
     {
         uint8_t* ps;
         uint8_t** NextState = (uint8_t**)acsm->acsmNextState;
-        AC_SEARCH_ALL;
+        AC_SEARCH_ALL
     }
     break;
     case 2:
     {
         uint16_t* ps;
         uint16_t** NextState = (uint16_t**)acsm->acsmNextState;
-        AC_SEARCH_ALL;
+        AC_SEARCH_ALL
     }
     break;
     default:
     {
         acstate_t* ps;
         acstate_t** NextState = acsm->acsmNextState;
-        AC_SEARCH_ALL;
+        AC_SEARCH_ALL
     }
     break;
     }
index f1e6bdc9f27df24ed6ad6bd3aa08c534b3dad9f0..13cd6a23f67b9ac6cc956db2b14dc279f28dcb51 100644 (file)
@@ -2044,7 +2044,7 @@ static void DCE2_CoSegDecode(DCE2_SsnData* sd, DCE2_CoTracker* cot, DCE2_CoSeg*
     uint16_t frag_len = 0;
     dce2CommonStats* dce_common_stats = dce_get_proto_stats_ptr(sd);
     int smb_hdr_len;
-    
+
     if ( DetectionEngine::get_current_packet()->is_from_client() )
     {
         smb_hdr_len = DCE2_MOCK_HDR_LEN__SMB_CLI;
index f9c501cdeafebccf44ed242dc5ba9a0eccc3f8f9..cca435826ae3ee96e6c72fc5b87b4f885df9b975 100644 (file)
@@ -233,7 +233,7 @@ bool DceEndianness::get_offset_endianness(int32_t offset, uint8_t& endian)
     }
 
     endian = (byte_order == DCERPC_BO_FLAG__BIG_ENDIAN) ? ENDIAN_BIG : ENDIAN_LITTLE;
+
     return true;
 }
 
index 2bd93c67627e6bbc539c4289df75d06d1a7f197d..fe4424a941f7c84087c4c8e7d444643f46d8cfc8 100644 (file)
@@ -43,7 +43,7 @@ unsigned DceContextData::get_ips_id(DCE2_TransType trans)
 {
     switch(trans)
     {
-        case DCE2_TRANS_TYPE__SMB: 
+        case DCE2_TRANS_TYPE__SMB:
             return DceContextData::smb_ips_id;
         case DCE2_TRANS_TYPE__TCP:
             return DceContextData::tcp_ips_id;
@@ -59,7 +59,7 @@ void DceContextData::set_ips_id(DCE2_TransType trans, unsigned id)
 {
     switch(trans)
     {
-        case DCE2_TRANS_TYPE__SMB: 
+        case DCE2_TRANS_TYPE__SMB:
             DceContextData::smb_ips_id = id;
             break;
         case DCE2_TRANS_TYPE__TCP:
index 2580448a8756fb45bb9fc3141439074493bc5d36..4cea50354dfb9d1b4fdc3170a05b7ab87f914b67 100644 (file)
@@ -143,7 +143,7 @@ static void DCE2_ListInsertTail(DCE2_List* list, DCE2_ListNode* n)
 static void DCE2_ListInsertHead(DCE2_List* list, DCE2_ListNode* n)
 {
     if ((list == nullptr) || (n == nullptr))
-        return;   
+        return;
 
     if (list->head == nullptr)
     {
index afdd977dd5b57a66fd04c5332c29e82eaeb58602..dc48e29e54a52eb3a3680b94944b77e525040505 100644 (file)
@@ -724,7 +724,7 @@ void DCE2_Smb2Process(DCE2_SmbSsnData* ssd)
         uint32_t next_command_offset;
         /* SMB protocol allows multiple smb commands to be grouped in a single packet.
            So loop through to parse all the smb commands.
-                  Reference: https://msdn.microsoft.com/en-us/library/cc246614.aspx
+           Reference: https://msdn.microsoft.com/en-us/library/cc246614.aspx
            "A nonzero value for the NextCommand field in the SMB2 header indicates a compound
            request. NextCommand in the SMB2 header of a request specifies an offset, in bytes,
            from the beginning of the SMB2 header under consideration to the start of the 8-byte
index bf13b077ab4ac056a9015f2a8aa9d8ecd76fa58f..f8c30ce31bde8f064fa957ce72ba006499e2b306 100644 (file)
 
 #include "dce_smb.h"
 
+namespace
+{
+inline void DCE2_SMB_PAF_SHIFT(uint64_t& x64, const uint8_t& x8)
+{
+    x64 <<= 8;
+    x64 |= (uint64_t) x8;
+}
+}
+
 using namespace snort;
 
 /*********************************************************************
@@ -115,7 +124,7 @@ static StreamSplitter::Status dce2_smb_paf(DCE2_PafSmbData* ss, Flow* flow, cons
                 ss->paf_state = DCE2_PAF_SMB_STATES__0;
                 return StreamSplitter::FLUSH;
             }
-          
+
             ss->paf_state = (DCE2_PafSmbStates)(((int)ss->paf_state) + 1);
             break;
         case DCE2_PAF_SMB_STATES__7:
@@ -135,7 +144,7 @@ static StreamSplitter::Status dce2_smb_paf(DCE2_PafSmbData* ss, Flow* flow, cons
             nb_len = NbssLen((const NbssHdr*)&nb_hdr);
             *fp = (nb_len + sizeof(NbssHdr) + n) - ss->paf_state;
             ss->paf_state = DCE2_PAF_SMB_STATES__0;
-   
+
             return StreamSplitter::FLUSH;
         default:
             DCE2_SMB_PAF_SHIFT(ss->nb_hdr, data[n]);
index a1dc2c087ca6b087e84593e6ed01a21f90716d9b..0e0ba5871a43e6e3f7bc069696dce900f4820732 100644 (file)
@@ -24,8 +24,6 @@
 
 #include "stream/stream_splitter.h"
 
-#define DCE2_SMB_PAF_SHIFT(x64, x8) { (x64) <<= 8; (x64) |= (uint64_t)(x8); }
-
 // Enumerations for PAF states
 enum DCE2_PafSmbStates
 {
index 7b1a1d4e97ab7b875d7ef6828ed1622f0c544c53..e408a84d3db6b0f6a32346126d8dc815565c0831 100644 (file)
@@ -1546,7 +1546,7 @@ DCE2_Ret DCE2_SmbNtTransact(DCE2_SmbSsnData* ssd, const SmbNtHdr* smb_hdr,
         if (ftracker == nullptr)
             return DCE2_RET__ERROR;
 
-               DCE2_Update_Ftracker_from_ReqTracker(ftracker, ssd->cur_rtracker);
+        DCE2_Update_Ftracker_from_ReqTracker(ftracker, ssd->cur_rtracker);
 
         if (!ftracker->is_ipc)
         {
@@ -1595,7 +1595,7 @@ DCE2_Ret DCE2_SmbTransactionSecondary(DCE2_SmbSsnData* ssd, const SmbNtHdr* smb_
         Packet* rpkt = DCE2_SmbGetRpkt(ssd, &data_ptr, &data_len, DCE2_RPKT_TYPE__SMB_TRANS);
 
         if (rpkt == nullptr)
-            return DCE2_RET__ERROR;    
+            return DCE2_RET__ERROR;
 
         status = DCE2_SmbTransactionReq(ssd, ttracker, data_ptr, data_len,
             DCE2_BufferData(ttracker->pbuf), DCE2_BufferLength(ttracker->pbuf));
index 80087c71e2966992b22b7e26aa6d206050042bd7..0916dc7fb9bf0c121060a4618ff46b6592522a47 100644 (file)
@@ -1824,7 +1824,7 @@ void DCE2_SmbProcessFileData(DCE2_SmbSsnData* ssd,
             || ((file_data_depth != 0)
             && (ftracker->ff_bytes_processed >= (uint64_t)file_data_depth)))
         {
-           // Bytes processed is at or beyond file data depth - finished.
+            // Bytes processed is at or beyond file data depth - finished.
             DCE2_SmbRemoveFileTracker(ssd, ftracker);
             return;
         }
index 876524c299a001ef075489743527b8b0a645de63..f4061e2e44b8d5a1a814f33776de5b795cdbad68 100644 (file)
@@ -121,7 +121,7 @@ static StreamSplitter::Status dce2_tcp_paf(DCE2_PafTcpData* ds, Flow* flow, cons
              * flush just before it */
             if ((num_requests == 1) || (n <= len))
                 tmp_fp += ds->frag_len;
-          
+
             ds->paf_state = DCE2_PAF_TCP_STATES__0;
             continue;      // we incremented n already
         default:
index 884dde9f7e2164cca814ec81d8acae9a02249661..d49b8cef4cb017a88281847a81c2018f76649fee 100644 (file)
@@ -83,7 +83,7 @@ struct DNSNameState
 #define DNS_RR_TYPE_A                       0x0001
 #define DNS_RR_TYPE_NS                      0x0002
 #define DNS_RR_TYPE_MD                      0x0003 // obsolete
-#define DNS_RR_TYPE_MF                      0x0004 // obsolete 
+#define DNS_RR_TYPE_MF                      0x0004 // obsolete
 #define DNS_RR_TYPE_CNAME                   0x0005
 #define DNS_RR_TYPE_SOA                     0x0006
 #define DNS_RR_TYPE_MB                      0x0007 // experimental
index bb88737f0cfdc1c7216a8118314dc4117ac86ef2..108c765111653043cde8e3402b6139042d2883a8 100644 (file)
@@ -114,7 +114,7 @@ bool FtpDataSplitter::finish(Flow* flow)
             FileFlows* file_flows = FileFlows::get_file_flows(flow);
             if ( file_flows )
             {
-                file_flows->file_process(DetectionEngine::get_current_packet(), 
+                file_flows->file_process(DetectionEngine::get_current_packet(),
                     nullptr, 0, SNORT_FILE_END, to_server(), fdfd->session.path_hash);
             }
         }
index 50b491deb108d63bf41a9e4d3bf3ec1836ccfd14..3c7cef60246a6005490cdcde94eddb89328f221d 100644 (file)
@@ -422,7 +422,7 @@ int gtp_parse(const GTPConfig& config, GTPMsg* msg, const uint8_t* buff, uint16_
 
     if (msg->version > MAX_GTP_VERSION_CODE)
         return false;
-    
+
     /*Check whether this is GTP or GTP', Exit if GTP'*/
     if (!(hdr->flag & 0x10))
         return false;
index 60b6cae930f28708555d1b5abb7ffeb9d82f9993..a88d55b0953ecd74c9584d4dd09b7aef10786db5 100644 (file)
@@ -58,7 +58,7 @@ public:
     EvalStatus eval(Cursor&, Packet*) override;
 
 public:
-    // byte n is for version n (named types can have 
+    // byte n is for version n (named types can have
     // different codes in different versions)
     uint8_t types[MAX_GTP_VERSION_CODE + 1];
 };
index efb1338bb1426d46f2bba6e8b661796ece3c2d1e..36445d4f44af7fcdaf97ad342e2da168db2657ec 100644 (file)
@@ -57,7 +57,7 @@ public:
     EvalStatus eval(Cursor&, Packet*) override;
 
 public:
-    // set n is for version n (named types can have 
+    // set n is for version n (named types can have
     // different codes in different versions)
     ByteBitSet types[MAX_GTP_VERSION_CODE + 1];
 };
index c7e0166bd976ae12d46e090b86cf83150e90500c..37c822c7f3ae43fb9d673b33f331304b8ce4da63 100644 (file)
@@ -37,7 +37,7 @@ enum FrameType : uint8_t { FT_DATA=0, FT_HEADERS=1, FT_PRIORITY=2, FT_RST_STREAM
 
 // Message buffers available to clients
 // This enum must remain synchronized with Http2Api::classic_buffer_names[]
-enum HTTP2_BUFFER { HTTP2_BUFFER_FRAME_HEADER = 1, HTTP2_BUFFER_FRAME_DATA, HTTP2_BUFFER_DECODED_HEADER, 
+enum HTTP2_BUFFER { HTTP2_BUFFER_FRAME_HEADER = 1, HTTP2_BUFFER_FRAME_DATA, HTTP2_BUFFER_DECODED_HEADER,
     HTTP2_BUFFER_MAX };
 
 // Peg counts
@@ -90,7 +90,7 @@ enum Infraction
     INF__MAX_VALUE
 };
 
-enum HeaderFrameFlags 
+enum HeaderFrameFlags
 {
     END_STREAM = 0x1,
     END_HEADERS = 0x4,
@@ -113,7 +113,7 @@ enum PseudoHeaders
 enum SettingsFrameIds
 {
     HEADER_TABLE_SIZE = 1,
-    ENABLE_PUSH, 
+    ENABLE_PUSH,
     MAX_CONCURRENT_STREAMS,
     INITIAL_WINDOW_SIZE,
     MAX_FRAME_SIZE,
index ff488ecc5021d3cf1b67d044b4a39cd3b85593e6..669319249433ad3936e97521d0d9bd57b3abc88c 100644 (file)
@@ -98,7 +98,7 @@ protected:
 
     // Used by scan, reassemble and eval to communicate
     uint8_t frame_type[2] = { Http2Enums::FT__NONE, Http2Enums::FT__NONE };
-    
+
     // Internal to reassemble()
     uint32_t frame_header_offset[2] = { 0, 0 };
     uint32_t frame_data_offset[2] = { 0, 0 };
index ee0ea9c69d6b17d69814da0abccc74ed9251f17f..bde7796fb78ad4e2ed7739f89c2147353930ace0 100644 (file)
@@ -93,7 +93,7 @@ uint32_t Http2Frame::get_stream_id()
 
     const uint8_t* header_start = header.start();
     return ((header_start[stream_id_index] & 0x7f) << 24) +
-        (header_start[stream_id_index + 1] << 16) + 
+        (header_start[stream_id_index + 1] << 16) +
         (header_start[stream_id_index + 2] << 8) +
         header_start[stream_id_index + 3];
 }
index e0d3a565e996c59fed51ceef13e9fad2a8981255..5fe1f5d4d0102dc4f2d796c535acc231048f9d1a 100644 (file)
@@ -59,7 +59,7 @@ protected:
     HttpCommon::SourceId source_id;
 
     const static uint8_t flags_index = 4;
-    const static uint8_t stream_id_index = 5; 
+    const static uint8_t stream_id_index = 5;
     const static uint32_t INVALID_STREAM_ID = 0xFFFFFFFF;
 };
 #endif
index be115eee6631579a109a9ce53a5b106f83b8e555..4b8e23850524e4e5552b081aa6b5515fbd634d85 100644 (file)
@@ -32,9 +32,9 @@ using namespace HttpCommon;
 using namespace Http2Enums;
 
 Http2HeadersFrame::Http2HeadersFrame(const uint8_t* header_buffer, const int32_t header_len,
-    const uint8_t* data_buffer, const int32_t data_len, Http2FlowData* session_data,
-    HttpCommon::SourceId source_id) : Http2Frame(header_buffer, header_len, data_buffer, data_len,
-    session_data, source_id)
+    const uint8_t* data_buffer, const int32_t data_len, Http2FlowData* ssn_data,
+    HttpCommon::SourceId src_id) : Http2Frame(header_buffer, header_len, data_buffer, data_len,
+    ssn_data, src_id)
 {
     uint8_t hpack_headers_offset = 0;
 
@@ -48,7 +48,7 @@ Http2HeadersFrame::Http2HeadersFrame(const uint8_t* header_buffer, const int32_t
     // Allocate stuff
     decoded_headers = new uint8_t[MAX_OCTETS];
     decoded_headers_size = 0;
-    
+
     start_line_generator = Http2StartLine::new_start_line_generator(source_id,
         session_data->events[source_id], session_data->infractions[source_id]);
 
index e9ca1110c802f193a9af5f268d0fbeef81554f77..2c67822d24281c00ef3b61810ab13aa2904b8426 100644 (file)
@@ -31,7 +31,7 @@ class Http2HeadersFrame : public Http2Frame
 {
 public:
     ~Http2HeadersFrame() override;
-    
+
     const Field& get_buf(unsigned id) override;
 
     friend Http2Frame* Http2Frame::new_frame(const uint8_t* header_buffer, const int32_t header_len,
@@ -44,8 +44,8 @@ public:
 
 private:
     Http2HeadersFrame(const uint8_t* header_buffer, const int32_t header_len,
-        const uint8_t* data_buffer, const int32_t data_len, Http2FlowData* session_data,
-        HttpCommon::SourceId source_id);
+        const uint8_t* data_buffer, const int32_t data_len, Http2FlowData* ssn_data,
+        HttpCommon::SourceId src_id);
 
     Http2StartLine* start_line_generator = nullptr;
     uint8_t* decoded_headers = nullptr; // working buffer to store decoded headers
index ffc4313362e44e1dc262645a06c784d2fe8e75fd..d772154475f3e9573ac63abcd08dafa0836a96eb 100644 (file)
@@ -68,7 +68,7 @@ bool Http2HpackStringDecode::translate(const uint8_t* in_buff, const uint32_t in
         return true;
 
     if (!isHuffman)
-        return get_string(in_buff, encoded_len, bytes_consumed, out_buff, out_len, bytes_written, 
+        return get_string(in_buff, encoded_len, bytes_consumed, out_buff, out_len, bytes_written,
                 events, infractions);
 
     return get_huffman_string(in_buff, encoded_len, bytes_consumed, out_buff, out_len,
@@ -195,7 +195,7 @@ bool Http2HpackStringDecode::get_huffman_string(const uint8_t* in_buff, const ui
             break;
 
         default:
-            break;         
+            break;
         }
     }
 
index e45168a90296735a7e7955aaf86becfcee1fc2c6..881931c49d37bd509e5eb45a5a259c52cf1ffa80 100644 (file)
@@ -40,12 +40,12 @@ private:
         uint8_t* out_buff, const uint32_t out_len, uint32_t& bytes_written, Http2EventGen* events,
         Http2Infractions* infractions) const;
     bool get_huffman_string(const uint8_t* in_buff, const uint32_t encoded_len,
-        uint32_t& bytes_consumed, uint8_t* out_buff, const uint32_t out_len, uint32_t& 
+        uint32_t& bytes_consumed, uint8_t* out_buff, const uint32_t out_len, uint32_t&
         bytes_written, Http2EventGen* events, Http2Infractions* infractions) const;
     bool get_next_byte(const uint8_t* in_buff, const uint32_t last_byte,
         uint32_t& bytes_consumed, uint8_t& cur_bit, uint8_t match_len, uint8_t& byte,
         bool& another_search) const;
-  
+
     const Http2HpackIntDecode decode7;
 };
 
index 253e2c39750203e7650fa4b12fe53d8d66627a9f..7f9838889a46769b7efffb7c058507227964d059 100644 (file)
@@ -102,7 +102,7 @@ const HpackTableEntry HpackIndexTable::static_table[STATIC_MAX_INDEX + 1] =
 };
 
 const HpackTableEntry* HpackIndexTable::lookup(uint64_t index) const
-{ 
+{
     if (index <= STATIC_MAX_INDEX)
         return &static_table[index];
     else
index d4cd7738338589fd6ce82eed05c9937d64a14a72..35b030cfe37395c53ea97374d820b9f98192f9ec 100644 (file)
@@ -330,7 +330,7 @@ const HuffmanEntry huffman_decode[HUFFMAN_LOOKUP_MAX+1] [UINT8_MAX+1] =
         // 00000
         {5, (char)176, HUFFMAN_MATCH}, {5, (char)176, HUFFMAN_MATCH}, {5, (char)176, HUFFMAN_MATCH}, {5, (char)176, HUFFMAN_MATCH},
         {5, (char)176, HUFFMAN_MATCH}, {5, (char)176, HUFFMAN_MATCH}, {5, (char)176, HUFFMAN_MATCH}, {5, (char)176, HUFFMAN_MATCH},
-        // 00001 
+        // 00001
         {5, (char)177, HUFFMAN_MATCH}, {5, (char)177, HUFFMAN_MATCH}, {5, (char)177, HUFFMAN_MATCH}, {5, (char)177, HUFFMAN_MATCH},
         {5, (char)177, HUFFMAN_MATCH}, {5, (char)177, HUFFMAN_MATCH}, {5, (char)177, HUFFMAN_MATCH}, {5, (char)177, HUFFMAN_MATCH},
         // 00010
index 280b78afb44904cb1c6da112f848162a955c7d43..53cf99038c819144963fb5c20750614c3b070e89 100644 (file)
@@ -37,8 +37,7 @@ public:
         Http2EventGen* events, Http2Infractions* infractions);
 
 private:
-    Http2RequestLine(Http2EventGen* events, Http2Infractions* infractions) : Http2StartLine(events,
-        infractions) { }
+    Http2RequestLine(Http2EventGen* evs, Http2Infractions* infrs) : Http2StartLine(evs, infrs) { }
 
     Field method;
     Field path;
index b7a9a16603daeeb32b05eaef5410606b15e1994a..db2a7e9fdee2e9ec0cc9983ca55c137fe38f73cb 100644 (file)
@@ -38,7 +38,7 @@ static uint16_t get_parameter_id(const uint8_t* data_buffer)
 }
 
 static uint32_t get_parameter_value(const uint8_t* data_buffer)
-{      
+{
     static const uint8_t frame_value_index = 2;
     return (data_buffer[frame_value_index]  << 24) +
         (data_buffer[frame_value_index + 1] << 16) +
@@ -47,9 +47,9 @@ static uint32_t get_parameter_value(const uint8_t* data_buffer)
 }
 
 Http2SettingsFrame::Http2SettingsFrame(const uint8_t* header_buffer, const int32_t header_len,
-       const uint8_t* data_buffer, const int32_t data_len, Http2FlowData* session_data,
-    HttpCommon::SourceId source_id) : Http2Frame(header_buffer, header_len, data_buffer, data_len,
-    session_data, source_id)
+    const uint8_t* data_buffer, const int32_t data_len, Http2FlowData* ssn_data,
+    HttpCommon::SourceId src_id) : Http2Frame(header_buffer, header_len, data_buffer, data_len,
+    ssn_data, src_id)
 {
     if (!sanity_check())
     {
@@ -60,13 +60,13 @@ Http2SettingsFrame::Http2SettingsFrame(const uint8_t* header_buffer, const int32
 
     if (SfAck & get_flags())
         return;
-    
+
     parse_settings_frame();
 }
 
 void Http2SettingsFrame::parse_settings_frame()
 {
-       int32_t data_pos = 0;
+    int32_t data_pos = 0;
 
     while (data_pos < data.length())
     {
@@ -82,7 +82,7 @@ void Http2SettingsFrame::parse_settings_frame()
             continue;
         }
 
-        session_data->connection_settings[source_id].set_param(parameter_id, parameter_value);  
+        session_data->connection_settings[source_id].set_param(parameter_id, parameter_value);
     }
 }
 
@@ -96,7 +96,7 @@ bool Http2SettingsFrame::sanity_check()
         bad_frame = true;
     else if (ack and data.length() > 0)
         bad_frame = true;
-    
+
     return !(bad_frame);
 }
 
@@ -118,18 +118,18 @@ void Http2SettingsFrame::print_frame(FILE* output)
 }
 #endif
 
-uint32_t Http2ConnectionSettings::get_param(uint16_t id) 
-{ 
+uint32_t Http2ConnectionSettings::get_param(uint16_t id)
+{
     assert(id >= HEADER_TABLE_SIZE);
     assert(id <= MAX_HEADER_LIST_SIZE);
 
-    return parameters[id - 1]; 
+    return parameters[id - 1];
 }
 
-void Http2ConnectionSettings::set_param(uint16_t id, uint32_t value) 
-{ 
+void Http2ConnectionSettings::set_param(uint16_t id, uint32_t value)
+{
     assert(id >= HEADER_TABLE_SIZE);
     assert(id <= MAX_HEADER_LIST_SIZE);
 
-    parameters[id - 1] = value; 
+    parameters[id - 1] = value;
 }
index a5d9e41bbc031bb314f3391411e16012cc85bd4d..3fc2858713f4ba1ac2b41a92a2a3dc31cd1456af 100644 (file)
@@ -39,8 +39,8 @@ public:
 
 private:
     Http2SettingsFrame(const uint8_t* header_buffer, const int32_t header_len,
-        const uint8_t* data_buffer, const int32_t data_len, Http2FlowData* session_data,
-        HttpCommon::SourceId source_id);
+        const uint8_t* data_buffer, const int32_t data_len, Http2FlowData* ssn_data,
+        HttpCommon::SourceId src_id);
 
     void parse_settings_frame();
     bool sanity_check();
@@ -52,13 +52,13 @@ private:
 class Http2ConnectionSettings
 {
 public:
-       uint32_t get_param(uint16_t id);
-       void set_param(uint16_t id, uint32_t value);
+    uint32_t get_param(uint16_t id);
+    void set_param(uint16_t id, uint32_t value);
 
 private:
     void validate_param_id(uint16_t id);
 
-    static const uint16_t PARAMETER_COUNT = 6; 
+    static const uint16_t PARAMETER_COUNT = 6;
     uint32_t parameters[PARAMETER_COUNT] = {
              4096, // Header table size
                 1, // Push promise
index 28e4b8500274a16423aae94ba2f2b2d87f0b753b..013e7da9e60f62894ea56fde5d590c1fd03f2d45 100644 (file)
@@ -64,7 +64,7 @@ void Http2StatusLine::process_pseudo_header_value(const uint8_t* const& value, c
 bool Http2StatusLine::generate_start_line()
 {
     uint32_t bytes_written = 0;
-    
+
     // Account for one space and trailing crlf
     static const uint8_t NUM_RESPONSE_LINE_EXTRA_CHARS = 3;
 
index 76e24e959b05e783910fff6786056925bae7c453..5543eb9c17e18a6051ee18a02eb61dc901c3bdfa 100644 (file)
@@ -36,8 +36,7 @@ public:
         Http2EventGen* events, Http2Infractions* infractions);
 
 private:
-    Http2StatusLine(Http2EventGen* events, Http2Infractions* infractions) : Http2StartLine(events,
-        infractions) { }
+    Http2StatusLine(Http2EventGen* evs, Http2Infractions* infrs) : Http2StartLine(evs, infrs) { }
 
     Field status;
 
index c842295197d7328211955694ce9e009d92b5bc44..ff210c5c1d75f14dd1a3e15889605bbfba618ebc 100644 (file)
@@ -89,7 +89,7 @@ StreamSplitter::Status implement_scan(Http2FlowData* session_data, const uint8_t
     {
         // Continuation of ongoing data frame
         session_data->num_frame_headers[source_id] = 0;
+
         // If this is a new frame section, update next frame section length
         if (session_data->scan_remaining_frame_octets[source_id] == 0)
         {
@@ -107,7 +107,7 @@ StreamSplitter::Status implement_scan(Http2FlowData* session_data, const uint8_t
             session_data->scan_remaining_frame_octets[source_id] -= length;
             session_data->total_bytes_in_split[source_id] += length;
             return status = StreamSplitter::SEARCH;
-        } 
+        }
 
         // Have full frame section, flush and update leftover
         session_data->total_bytes_in_split[source_id] +=
@@ -244,7 +244,7 @@ StreamSplitter::Status implement_scan(Http2FlowData* session_data, const uint8_t
     return status;
 }
 
-// FIXIT-M If there are any errors in header decoding, this currently tells stream not to send 
+// FIXIT-M If there are any errors in header decoding, this currently tells stream not to send
 // headers to detection. This behavior may need to be changed.
 const StreamBuffer implement_reassemble(Http2FlowData* session_data, unsigned total,
     unsigned offset, const uint8_t* data, unsigned len, uint32_t flags,
@@ -356,7 +356,7 @@ const StreamBuffer implement_reassemble(Http2FlowData* session_data, unsigned to
         session_data->num_frame_headers[source_id] = 0;
         session_data->scan_octets_seen[source_id] = 0;
 
-        // Return 0-length non-null buffer to stream which signals detection required, but don't 
+        // Return 0-length non-null buffer to stream which signals detection required, but don't
         // create pkt_data buffer
         frame_buf.data = (const uint8_t*)"";
     }
@@ -365,7 +365,7 @@ const StreamBuffer implement_reassemble(Http2FlowData* session_data, unsigned to
     return frame_buf;
 }
 
-ValidationResult validate_preface(const uint8_t* data, const uint32_t length, 
+ValidationResult validate_preface(const uint8_t* data, const uint32_t length,
     const uint32_t octets_seen)
 {
     const uint32_t preface_length = 24;
@@ -383,6 +383,6 @@ ValidationResult validate_preface(const uint8_t* data, const uint32_t length,
 
     if ((octets_seen + length) < preface_length)
         return V_TBD;
-    
+
     return V_GOOD;
 }
index a6b5867ca15c1721917216ae771468d55d04e660..083b15dd3c586ceb87cd790af3c30d2d72bb2078 100644 (file)
@@ -189,7 +189,7 @@ TEST(http2_hpack_string_decode_success, huffman_1_byte_star)
 
 TEST(http2_hpack_string_decode_success, huffman_2_bytes_aligned)
 {
-    // prepare buf to decode - Huffman "&&" 
+    // prepare buf to decode - Huffman "&&"
     uint8_t buf[3] = {0x82, 0xf8, 0xf8};
     // decode
     uint32_t bytes_processed = 0, bytes_written = 0;
@@ -204,7 +204,7 @@ TEST(http2_hpack_string_decode_success, huffman_2_bytes_aligned)
 
 TEST(http2_hpack_string_decode_success, huffman_2_bytes_unaligned)
 {
-    // prepare buf to decode - Huffman "%%" 
+    // prepare buf to decode - Huffman "%%"
     uint8_t buf[3] = {0x82, 0x55, 0x5f};
     // decode
     uint32_t bytes_processed = 0, bytes_written = 0;
@@ -219,7 +219,7 @@ TEST(http2_hpack_string_decode_success, huffman_2_bytes_unaligned)
 
 TEST(http2_hpack_string_decode_success, huffman_rfc_example1)
 {
-    // prepare buf to decode - Huffman "www.example.com" , RFC c.4.1 
+    // prepare buf to decode - Huffman "www.example.com" , RFC c.4.1
     uint8_t buf[13] = {0x8c, 0xf1, 0xe3, 0xc2, 0xe5, 0xf2, 0x3a, 0x6b, 0xa0, 0xab, 0x90, 0xf4, 0xff};
     // decode
     uint32_t bytes_processed = 0, bytes_written = 0;
@@ -281,7 +281,7 @@ TEST(http2_hpack_string_decode_success, huffman_rfc_example5)
 {
     // prepare buf to decode - Huffman "Mon, 21 Oct 2013 20:13:21 GMT" , RFC c.6.1
     uint8_t buf[23] = {0x96, 0xd0, 0x7a, 0xbe, 0x94, 0x10, 0x54, 0xd4, 0x44, 0xa8, 0x20,
-                    0x05, 0x95, 0x04, 0x0b, 0x81, 0x66, 0xe0, 0x82, 0xa6, 0x2d, 0x1b, 0xff};
+        0x05, 0x95, 0x04, 0x0b, 0x81, 0x66, 0xe0, 0x82, 0xa6, 0x2d, 0x1b, 0xff};
     // decode
     uint32_t bytes_processed = 0, bytes_written = 0;
     uint8_t res[35];
@@ -297,9 +297,9 @@ TEST(http2_hpack_string_decode_success, huffman_rfc_example6)
 {
     // prepare buf to decode - Huffman "foo=ASDJKHQKBZXOQWEOPIUAXQWEOIU; max-age=3600; version=1" , RFC c.6.3
     uint8_t buf[46] = {0xad, 0x94, 0xe7, 0x82, 0x1d, 0xd7, 0xf2, 0xe6, 0xc7, 0xb3, 0x35, 0xdf,
-                    0xdf, 0xcd, 0x5b, 0x39, 0x60, 0xd5, 0xaf, 0x27, 0x08, 0x7f, 0x36, 0x72,
-                    0xc1, 0xab, 0x27, 0x0f, 0xb5, 0x29, 0x1f, 0x95, 0x87, 0x31, 0x60, 0x65,
-                    0xc0, 0x03, 0xed, 0x4e, 0xe5, 0xb1, 0x06, 0x3d, 0x50, 0x07};
+        0xdf, 0xcd, 0x5b, 0x39, 0x60, 0xd5, 0xaf, 0x27, 0x08, 0x7f, 0x36, 0x72,
+        0xc1, 0xab, 0x27, 0x0f, 0xb5, 0x29, 0x1f, 0x95, 0x87, 0x31, 0x60, 0x65,
+        0xc0, 0x03, 0xed, 0x4e, 0xe5, 0xb1, 0x06, 0x3d, 0x50, 0x07};
     // decode
     uint32_t bytes_processed = 0, bytes_written = 0;
     uint8_t res[73];
@@ -330,7 +330,7 @@ TEST(http2_hpack_string_decode_success, huffman_decoding_all_possible_symbols_1)
 {
     // prepare buf to decode - "abcdefghijklmnopqrstuvwxyz"
     uint8_t buf[21] = {0x94, 0x1c, 0x64, 0x90, 0xb2, 0xcd, 0x39, 0xba, 0x75, 0xa2, 0x9a, 0x8f, 0x5f, 0x6b,
-            0x10, 0x9b, 0x7b, 0xf8, 0xf3, 0xeb, 0xdf};
+        0x10, 0x9b, 0x7b, 0xf8, 0xf3, 0xeb, 0xdf};
     // decode
     uint32_t bytes_processed = 0, bytes_written = 0;
     uint8_t res[32];
@@ -346,7 +346,7 @@ TEST(http2_hpack_string_decode_success, huffman_decoding_all_possible_symbols_2)
 {
     // prepare buf to decode - "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
     uint8_t buf[24] = {0x97, 0x86, 0xed, 0xeb, 0xf8, 0x30, 0xe2, 0xc7, 0x93, 0x2e, 0x6c, 0xfa, 0x34, 0xea,
-              0xd7, 0xb3, 0x6e, 0xed, 0xfc, 0x38, 0xf2, 0xfc, 0xe7, 0xfb};
+        0xd7, 0xb3, 0x6e, 0xed, 0xfc, 0x38, 0xf2, 0xfc, 0xe7, 0xfb};
     // decode
     uint32_t bytes_processed = 0, bytes_written = 0;
     uint8_t res[36];
@@ -376,7 +376,9 @@ TEST(http2_hpack_string_decode_success, huffman_decoding_all_possible_symbols_3)
 TEST(http2_hpack_string_decode_success, huffman_decoding_all_possible_symbols_4)
 {
     // prepare buf to decode - ' !"#$%&\'()*+,-./:;<=>?@[\]^_`{|}~'
-  uint8_t buf[45] = {0xAC, 0x53, 0xF8, 0xFE, 0x7F, 0xEB, 0xFF, 0x2A, 0xFC, 0X7F, 0xAF, 0xEB, 0xFB, 0xF9, 0xFF, 0x7F, 0x4B, 0x2E, 0xC5, 0xCF, 0xBF, 0xFF, 0x90, 0x7F, 0xDF, 0xF9, 0xFF, 0xAF, 0xFD, 0xFF, 0xFF, 0x0F, 0xFE, 0x7F, 0xF9, 0x17, 0xFF, 0xDF, 0xFF, 0xDF, 0xF3, 0xFF, 0xDF, 0xFE, 0xFF};
+  uint8_t buf[45] = {0xAC, 0x53, 0xF8, 0xFE, 0x7F, 0xEB, 0xFF, 0x2A, 0xFC, 0X7F, 0xAF, 0xEB, 0xFB, 0xF9,
+      0xFF, 0x7F, 0x4B, 0x2E, 0xC5, 0xCF, 0xBF, 0xFF, 0x90, 0x7F, 0xDF, 0xF9, 0xFF, 0xAF, 0xFD, 0xFF, 0xFF,
+      0x0F, 0xFE, 0x7F, 0xF9, 0x17, 0xFF, 0xDF, 0xFF, 0xDF, 0xF3, 0xFF, 0xDF, 0xFE, 0xFF};
     // decode
     uint32_t bytes_processed = 0, bytes_written = 0;
     uint8_t res[70];
@@ -391,7 +393,10 @@ TEST(http2_hpack_string_decode_success, huffman_decoding_all_possible_symbols_4)
 TEST(http2_hpack_string_decode_success, huffman_decoding_all_possible_symbols_hex_00_0F)
 {
     // prepare buf to decode - encoded 0x00-0x0F
-  uint8_t buf[55] = {0xB6, 0xFF, 0xC7, 0xFF, 0xFD, 0x8F, 0xFF, 0xFF, 0xE2, 0xFF, 0xFF, 0xFE, 0x3F, 0xFF, 0xFF, 0xE4, 0xFF, 0xFF, 0xFE, 0x5F, 0xFF, 0xFF, 0xE6, 0xFF, 0xFF, 0xFE, 0x7F, 0xFF, 0xFF, 0xE8, 0xFF, 0xFF, 0xEA, 0xFF, 0xFF, 0xFF, 0xF3, 0xFF, 0xFF, 0xFA, 0x7F, 0xFF, 0xFF, 0xAB, 0xFF, 0xFF, 0xFF, 0xDF, 0xFF, 0xFF, 0xEB, 0xFF, 0xFF, 0xFE, 0xCF};
+  uint8_t buf[55] = {0xB6, 0xFF, 0xC7, 0xFF, 0xFD, 0x8F, 0xFF, 0xFF, 0xE2, 0xFF, 0xFF, 0xFE, 0x3F, 0xFF,
+      0xFF, 0xE4, 0xFF, 0xFF, 0xFE, 0x5F, 0xFF, 0xFF, 0xE6, 0xFF, 0xFF, 0xFE, 0x7F, 0xFF, 0xFF, 0xE8, 0xFF,
+      0xFF, 0xEA, 0xFF, 0xFF, 0xFF, 0xF3, 0xFF, 0xFF, 0xFA, 0x7F, 0xFF, 0xFF, 0xAB, 0xFF, 0xFF, 0xFF, 0xDF,
+      0xFF, 0xFF, 0xEB, 0xFF, 0xFF, 0xFE, 0xCF};
     // decode
     uint32_t bytes_processed = 0, bytes_written = 0;
     uint8_t res[88];
@@ -407,7 +412,10 @@ TEST(http2_hpack_string_decode_success, huffman_decoding_all_possible_symbols_he
 TEST(http2_hpack_string_decode_success, huffman_decoding_all_possible_symbols_hex_10_1F)
 {
     // prepare buf to decode - encoded 0x10-0x1F
-  uint8_t buf[58] = {0xB9, 0xFF, 0xFF, 0xFE, 0xDF, 0xFF, 0xFF, 0xEE, 0xFF, 0xFF, 0xFE, 0xFF, 0xFF, 0xFF, 0xF0, 0xFF, 0xFF, 0xFF, 0x1F, 0xFF, 0xFF, 0xF2, 0xFF, 0xFF, 0xFF, 0xFB, 0xFF, 0xFF, 0xFC, 0xFF, 0xFF, 0xFF, 0xD3, 0xFF, 0xFF, 0xFD, 0x7F, 0xFF, 0xFF, 0xDB, 0xFF, 0xFF, 0xFD, 0xFF, 0xFF, 0xFF, 0xE3, 0xFF, 0xFF, 0xFE, 0x7F, 0xFF, 0xFF, 0xEB, 0xFF, 0xFF, 0xFE, 0xFF};
+  uint8_t buf[58] = {0xB9, 0xFF, 0xFF, 0xFE, 0xDF, 0xFF, 0xFF, 0xEE, 0xFF, 0xFF, 0xFE, 0xFF, 0xFF, 0xFF,
+      0xF0, 0xFF, 0xFF, 0xFF, 0x1F, 0xFF, 0xFF, 0xF2, 0xFF, 0xFF, 0xFF, 0xFB, 0xFF, 0xFF, 0xFC, 0xFF, 0xFF,
+      0xFF, 0xD3, 0xFF, 0xFF, 0xFD, 0x7F, 0xFF, 0xFF, 0xDB, 0xFF, 0xFF, 0xFD, 0xFF, 0xFF, 0xFF, 0xE3, 0xFF,
+      0xFF, 0xFE, 0x7F, 0xFF, 0xFF, 0xEB, 0xFF, 0xFF, 0xFE, 0xFF};
     // decode
     uint32_t bytes_processed = 0, bytes_written = 0;
     uint8_t res[93];
@@ -423,7 +431,10 @@ TEST(http2_hpack_string_decode_success, huffman_decoding_all_possible_symbols_he
 TEST(http2_hpack_string_decode_success, huffman_decoding_all_possible_symbols_hex_7F_8F)
 {
     // prepare buf to decode - encoded 0x7F-0x8F
-  uint8_t buf[49] = {0xB0, 0xFF, 0xFF, 0xFF, 0xCF, 0xFF, 0xE6, 0xFF, 0xFF, 0x4B, 0xFF, 0xF9, 0xFF, 0xFF, 0xA3, 0xFF, 0xFD, 0x3F, 0xFF, 0xF5, 0x3F, 0xFF, 0xD5, 0xFF, 0xFF, 0xB3, 0xFF, 0xFE, 0xB7, 0xFF, 0xFD, 0xAF, 0xFF, 0xFB, 0x7F, 0xFF, 0xF7, 0x3F, 0xFF, 0xEE, 0xFF, 0xFF, 0xDE, 0xFF, 0xFF, 0xEB, 0xFF, 0xFF, 0xBF};
+  uint8_t buf[49] = {0xB0, 0xFF, 0xFF, 0xFF, 0xCF, 0xFF, 0xE6, 0xFF, 0xFF, 0x4B, 0xFF, 0xF9, 0xFF, 0xFF,
+      0xA3, 0xFF, 0xFD, 0x3F, 0xFF, 0xF5, 0x3F, 0xFF, 0xD5, 0xFF, 0xFF, 0xB3, 0xFF, 0xFE, 0xB7, 0xFF, 0xFD,
+      0xAF, 0xFF, 0xFB, 0x7F, 0xFF, 0xF7, 0x3F, 0xFF, 0xEE, 0xFF, 0xFF, 0xDE, 0xFF, 0xFF, 0xEB, 0xFF, 0xFF,
+      0xBF};
     // decode
     uint32_t bytes_processed = 0, bytes_written = 0;
     uint8_t res[79];
@@ -439,7 +450,9 @@ TEST(http2_hpack_string_decode_success, huffman_decoding_all_possible_symbols_he
 TEST(http2_hpack_string_decode_success, huffman_decoding_all_possible_symbols_hex_90_9F)
 {
     // prepare buf to decode - encoded 0x90-0x9F
-  uint8_t buf[47] = {0xAE, 0xFF, 0xFF, 0xEC, 0xFF, 0xFF, 0xED, 0xFF, 0xFF, 0x5F, 0xFF, 0xFF, 0x07, 0xFF, 0xFF, 0x77, 0xFF, 0xFE, 0x1F, 0xFF, 0xFC, 0x5F, 0xFF, 0xF8, 0xFF, 0xFF, 0xF2, 0x7F, 0xFF, 0x73, 0xFF, 0xFD, 0x8F, 0xFF, 0xFC, 0xBF, 0xFF, 0xEC, 0xFF, 0xFF, 0xE6, 0xFF, 0xFF, 0xCF, 0xFF, 0xFF, 0xDF};
+  uint8_t buf[47] = {0xAE, 0xFF, 0xFF, 0xEC, 0xFF, 0xFF, 0xED, 0xFF, 0xFF, 0x5F, 0xFF, 0xFF, 0x07, 0xFF,
+      0xFF, 0x77, 0xFF, 0xFE, 0x1F, 0xFF, 0xFC, 0x5F, 0xFF, 0xF8, 0xFF, 0xFF, 0xF2, 0x7F, 0xFF, 0x73, 0xFF,
+      0xFD, 0x8F, 0xFF, 0xFC, 0xBF, 0xFF, 0xEC, 0xFF, 0xFF, 0xE6, 0xFF, 0xFF, 0xCF, 0xFF, 0xFF, 0xDF};
 
     // decode
     uint32_t bytes_processed = 0, bytes_written = 0;
@@ -455,7 +468,9 @@ TEST(http2_hpack_string_decode_success, huffman_decoding_all_possible_symbols_he
 TEST(http2_hpack_string_decode_success, huffman_decoding_all_possible_symbols_hex_A0_AF)
 {
     // prepare buf to decode - encoded 0xA0-0xAF
-  uint8_t buf[46] = {0xAD, 0xFF, 0xFF, 0x6B, 0xFF, 0xFB, 0xBF, 0xFF, 0xD3, 0xFF, 0xFE, 0xDF, 0xFF, 0xFB, 0x9F, 0xFF, 0xFA, 0x3F, 0xFF, 0xF4, 0xFF, 0xFF, 0x7B, 0xFF, 0xFF, 0x57, 0xFF, 0xFB, 0xBF, 0xFF, 0xEF, 0x7F, 0xFF, 0xF8, 0x7F, 0xFF, 0x7F, 0xFF, 0xFD, 0xFF, 0xFF, 0xFD, 0x7F, 0xFF, 0xFB, 0x3F};
+  uint8_t buf[46] = {0xAD, 0xFF, 0xFF, 0x6B, 0xFF, 0xFB, 0xBF, 0xFF, 0xD3, 0xFF, 0xFE, 0xDF, 0xFF, 0xFB,
+      0x9F, 0xFF, 0xFA, 0x3F, 0xFF, 0xF4, 0xFF, 0xFF, 0x7B, 0xFF, 0xFF, 0x57, 0xFF, 0xFB, 0xBF, 0xFF, 0xEF,
+      0x7F, 0xFF, 0xF8, 0x7F, 0xFF, 0x7F, 0xFF, 0xFD, 0xFF, 0xFF, 0xFD, 0x7F, 0xFF, 0xFB, 0x3F};
 
     // decode
     uint32_t bytes_processed = 0, bytes_written = 0;
@@ -472,7 +487,9 @@ TEST(http2_hpack_string_decode_success, huffman_decoding_all_possible_symbols_he
 TEST(http2_hpack_string_decode_success, huffman_decoding_all_possible_symbols_hex_B0_BF)
 {
     // prepare buf to decode - encoded 0xB0-0xBF
-  uint8_t buf[45] = {0xAC, 0xFF, 0xFF, 0x07, 0xFF, 0xF8, 0x7F, 0xFF, 0xE0, 0xFF, 0xFF, 0x17, 0xFF, 0xFE, 0xDF, 0xFF, 0xF8, 0x7F, 0xFF, 0xF7, 0x7F, 0xFF, 0xEF, 0xFF, 0xFE, 0xAF, 0xFF, 0xF8, 0xBF, 0xFF, 0xE3, 0xFF, 0xFF, 0x93, 0xFF, 0xFF, 0x87, 0xFF, 0xFC, 0xBF, 0xFF, 0xF3, 0x7F, 0xFF, 0xF1};
+  uint8_t buf[45] = {0xAC, 0xFF, 0xFF, 0x07, 0xFF, 0xF8, 0x7F, 0xFF, 0xE0, 0xFF, 0xFF, 0x17, 0xFF, 0xFE,
+      0xDF, 0xFF, 0xF8, 0x7F, 0xFF, 0xF7, 0x7F, 0xFF, 0xEF, 0xFF, 0xFE, 0xAF, 0xFF, 0xF8, 0xBF, 0xFF, 0xE3,
+      0xFF, 0xFF, 0x93, 0xFF, 0xFF, 0x87, 0xFF, 0xFC, 0xBF, 0xFF, 0xF3, 0x7F, 0xFF, 0xF1};
 
     // decode
     uint32_t bytes_processed = 0, bytes_written = 0;
@@ -489,7 +506,10 @@ TEST(http2_hpack_string_decode_success, huffman_decoding_all_possible_symbols_he
 TEST(http2_hpack_string_decode_success, huffman_decoding_all_possible_symbols_hex_C0_CF)
 {
     // prepare buf to decode - encoded 0xC0-0xCF
-  uint8_t buf[50] = {0xB1, 0xFF, 0xFF, 0xF8, 0x3F, 0xFF, 0xFE, 0x1F, 0xFF, 0xEB, 0xFF, 0xFE, 0x3F, 0xFF, 0xF3, 0xFF, 0xFF, 0xF2, 0xFF, 0xFF, 0xA3, 0xFF, 0xFF, 0xD9, 0xFF, 0xFF, 0xF1, 0x7F, 0xFF, 0xFC, 0x7F, 0xFF, 0xFF, 0x27, 0xFF, 0xFF, 0xDE, 0xFF, 0xFF, 0xFB, 0xFF, 0xFF, 0xFF, 0x2F, 0xFF, 0xFF, 0x8F, 0xFF, 0xFF, 0xB7};
+  uint8_t buf[50] = {0xB1, 0xFF, 0xFF, 0xF8, 0x3F, 0xFF, 0xFE, 0x1F, 0xFF, 0xEB, 0xFF, 0xFE, 0x3F, 0xFF,
+      0xF3, 0xFF, 0xFF, 0xF2, 0xFF, 0xFF, 0xA3, 0xFF, 0xFF, 0xD9, 0xFF, 0xFF, 0xF1, 0x7F, 0xFF, 0xFC, 0x7F,
+      0xFF, 0xFF, 0x27, 0xFF, 0xFF, 0xDE, 0xFF, 0xFF, 0xFB, 0xFF, 0xFF, 0xFF, 0x2F, 0xFF, 0xFF, 0x8F, 0xFF,
+      0xFF, 0xB7};
 
     // decode
     uint32_t bytes_processed = 0, bytes_written = 0;
@@ -506,7 +526,10 @@ TEST(http2_hpack_string_decode_success, huffman_decoding_all_possible_symbols_he
 TEST(http2_hpack_string_decode_success, huffman_decoding_all_possible_symbols_hex_D0_DF)
 {
     // prepare buf to decode - encoded 0xD0-0xDF
-  uint8_t buf[51] = {0xB2, 0xFF, 0xFE, 0x5F, 0xFF, 0xE3, 0xFF, 0xFF, 0xF9, 0xBF, 0xFF, 0xFF, 0x07, 0xFF, 0xFF, 0xE1, 0xFF, 0xFF, 0xF9, 0xFF, 0xFF, 0xFF, 0x17, 0xFF, 0xFF, 0x97, 0xFF, 0xF9, 0x3F, 0xFF, 0xCB, 0xFF, 0xFF, 0xF4, 0x7F, 0xFF, 0xFD, 0x3F, 0xFF, 0xFF, 0xFB, 0xFF, 0xFF, 0xF8, 0xFF, 0xFF, 0xFF, 0x27, 0xFF, 0xFF, 0xE5};
+  uint8_t buf[51] = {0xB2, 0xFF, 0xFE, 0x5F, 0xFF, 0xE3, 0xFF, 0xFF, 0xF9, 0xBF, 0xFF, 0xFF, 0x07, 0xFF,
+      0xFF, 0xE1, 0xFF, 0xFF, 0xF9, 0xFF, 0xFF, 0xFF, 0x17, 0xFF, 0xFF, 0x97, 0xFF, 0xF9, 0x3F, 0xFF, 0xCB,
+      0xFF, 0xFF, 0xF4, 0x7F, 0xFF, 0xFD, 0x3F, 0xFF, 0xFF, 0xFB, 0xFF, 0xFF, 0xF8, 0xFF, 0xFF, 0xFF, 0x27,
+      0xFF, 0xFF, 0xE5};
 
     // decode
     uint32_t bytes_processed = 0, bytes_written = 0;
@@ -523,7 +546,9 @@ TEST(http2_hpack_string_decode_success, huffman_decoding_all_possible_symbols_he
 TEST(http2_hpack_string_decode_success, huffman_decoding_all_possible_symbols_hex_E0_EF)
 {
     // prepare buf to decode - encoded 0xE0-0xEF
-  uint8_t buf[47] = {0xAE, 0xFF, 0xFE, 0xCF, 0xFF, 0xFF, 0x3F, 0xFF, 0xED, 0xFF, 0xFF, 0x37, 0xFF, 0xFD, 0x3F, 0xFF, 0xE7, 0xFF, 0xFF, 0x47, 0xFF, 0xFF, 0x3F, 0xFF, 0xFA, 0xBF, 0xFF, 0xEB, 0xFF, 0xFF, 0xF7, 0x7F, 0xFF, 0xFB, 0xFF, 0xFF, 0xFD, 0x3F, 0xFF, 0xFD, 0x7F, 0xFF, 0xFE, 0xAF, 0xFF, 0xFE, 0x9F};
+  uint8_t buf[47] = {0xAE, 0xFF, 0xFE, 0xCF, 0xFF, 0xFF, 0x3F, 0xFF, 0xED, 0xFF, 0xFF, 0x37, 0xFF, 0xFD,
+      0x3F, 0xFF, 0xE7, 0xFF, 0xFF, 0x47, 0xFF, 0xFF, 0x3F, 0xFF, 0xFA, 0xBF, 0xFF, 0xEB, 0xFF, 0xFF, 0xF7,
+      0x7F, 0xFF, 0xFB, 0xFF, 0xFF, 0xFD, 0x3F, 0xFF, 0xFD, 0x7F, 0xFF, 0xFE, 0xAF, 0xFF, 0xFE, 0x9F};
 
     // decode
     uint32_t bytes_processed = 0, bytes_written = 0;
@@ -540,7 +565,10 @@ TEST(http2_hpack_string_decode_success, huffman_decoding_all_possible_symbols_he
 TEST(http2_hpack_string_decode_success, huffman_decoding_all_possible_symbols_hex_F0_FF)
 {
     // prepare buf to decode - encoded 0xF0-0xFF
-  uint8_t buf[55] = {0xB6, 0xFF, 0xFF, 0xFA, 0xFF, 0xFF, 0xFF, 0x37, 0xFF, 0xFF, 0xD9, 0xFF, 0xFF, 0xF6, 0xFF, 0xFF, 0xFE, 0x7F, 0xFF, 0xFF, 0xD1, 0xFF, 0xFF, 0xFA, 0x7F, 0xFF, 0xFF, 0x57, 0xFF, 0xFF, 0xEB, 0xFF, 0xFF, 0xFF, 0xEF, 0xFF, 0xFF, 0xD9, 0xFF, 0xFF, 0xFB, 0x7F, 0xFF, 0xFF, 0x77, 0xFF, 0xFF, 0xEF, 0xFF, 0xFF, 0xFE, 0x1F, 0xFF, 0xFF, 0x77};
+  uint8_t buf[55] = {0xB6, 0xFF, 0xFF, 0xFA, 0xFF, 0xFF, 0xFF, 0x37, 0xFF, 0xFF, 0xD9, 0xFF, 0xFF, 0xF6,
+      0xFF, 0xFF, 0xFE, 0x7F, 0xFF, 0xFF, 0xD1, 0xFF, 0xFF, 0xFA, 0x7F, 0xFF, 0xFF, 0x57, 0xFF, 0xFF, 0xEB,
+      0xFF, 0xFF, 0xFF, 0xEF, 0xFF, 0xFF, 0xD9, 0xFF, 0xFF, 0xFB, 0x7F, 0xFF, 0xFF, 0x77, 0xFF, 0xFF, 0xEF,
+      0xFF, 0xFF, 0xFE, 0x1F, 0xFF, 0xFF, 0x77};
 
     // decode
     uint32_t bytes_processed = 0, bytes_written = 0;
index ef1df958c50eceab84accedb8f1465994a312c5e..71d2946f9b55c235c316734495a227a1511160e7 100644 (file)
@@ -471,7 +471,7 @@ void HttpInspect::clear(Packet* p)
     const SourceId source_id = current_section->get_source_id();
 
     //FIXIT-M This check may not apply to the transaction attached to the packet
-    //in case of offload. 
+    //in case of offload.
     if (session_data->detection_status[source_id] == DET_DEACTIVATING)
     {
         if (source_id == SRC_CLIENT)
index 9f8a432b9eff1556e8fb018564c8033816f685ac..d5bdd14486aed449869d13ab921d4e5532e528b9 100644 (file)
@@ -47,7 +47,7 @@ public:
 
     static bool is_webdav(HttpEnums::MethodId method)
     {
-        if(method > HttpEnums::MethodId::METH__WEBDAV_LOW and 
+        if(method > HttpEnums::MethodId::METH__WEBDAV_LOW and
            method < HttpEnums::MethodId::METH__WEBDAV_HIGH)
         {
             return true;
index 5cc775191cabcafce3f42f49fa3972449d53407b..6b1880de8120a79d446171e4f634fab7b31a0f92 100644 (file)
@@ -311,10 +311,10 @@ const StreamBuffer HttpStreamSplitter::reassemble(Flow* flow, unsigned total,
         else
         {
 #ifdef REG_TEST
-           // FIXIT-M: known case: if session clears w/o a flush point,
-           // stream_tcp will flush to paf max which could be well below what
-           // has been scanned so far.  since no flush point was specified,
-           // NHI should just deal with what it gets.
+            // FIXIT-M: known case: if session clears w/o a flush point,
+            // stream_tcp will flush to paf max which could be well below what
+            // has been scanned so far.  since no flush point was specified,
+            // NHI should just deal with what it gets.
             //assert(false);
 #endif
             return http_buf;
index d69655a26f39a4985cdec7be9c5d52ac729ba4d5..1d92440d2953ea40fccc8fac7fb33869efb6b984 100644 (file)
@@ -32,7 +32,7 @@
 #define POP_PKT_FROM_CLIENT   1
 #define POP_PKT_FROM_SERVER   2
 
-#define STATE_DATA             0    // Data state 
+#define STATE_DATA             0    // Data state
 #define STATE_TLS_CLIENT_PEND  1    // Got STARTTLS
 #define STATE_TLS_SERVER_PEND  2    // Got STARTTLS
 #define STATE_TLS_DATA         3    // Successful handshake, TLS encrypted data
index f68a2bea1091f8c32c930570db90813ba90cd263..ff50b3e412f56d92d819e67d9980e44905364b45 100644 (file)
@@ -127,7 +127,7 @@ IpsOption::EvalStatus SipMethodOption::eval(Cursor&, Packet* p)
         std::transform(method.begin(), method.end(), method.begin(), ::toupper);
 
         bool negated = methods.begin()->second;
-        bool match = methods.find(method) != methods.cend(); 
+        bool match = methods.find(method) != methods.cend();
 
         if ( negated ^ match )
             return MATCH;
index 25fb5180e4d50550f153201f26f5f2db262261db..15aecb6b3f16759f2268a3539622adc68e844642 100644 (file)
@@ -464,7 +464,7 @@ static void SIP_updateMedias(SIP_MediaSession* mSession, SIP_MediaList* dList)
 
     if (nullptr == mSession)
         return;
-  
+
     mSession->savedFlag = SIP_SESSION_SAVED;
     // Find out the media session based on session id
     currSession = *dList;
@@ -472,7 +472,7 @@ static void SIP_updateMedias(SIP_MediaSession* mSession, SIP_MediaList* dList)
     {
         if (currSession->sessionID == mSession->sessionID)
             break;
-        
+
         preSession = currSession;
         currSession = currSession->nextS;
     }
@@ -621,7 +621,7 @@ int SIP_updateDialog(SIPMsg* sipMsg, SIP_DialogList* dList, Packet* p, SIP_PROTO
     {
         if (sipMsg->dlgID.callIdHash == dialog->dlgID.callIdHash)
             break;
-        
+
         oldDialog = dialog;
         dialog = dialog->nextD;
     }
index 3fb0d127ce9e68de86a932827f017845c657f2cf..d6752f149da46d012e6b2ca9e0d0ffdf7854c12a 100644 (file)
@@ -107,7 +107,7 @@ TEST(sip_splitter_scan_test, scan_search_body_test)
     CHECK_EQUAL(ret, StreamSplitter::SEARCH);
     CHECK_EQUAL(ssut.splitter_get_paf_state(), SIP_PAF_FLUSH_STATE);
     CHECK_EQUAL(fp, 0);
-    
+
     ssut.splitter_reset_states();
 
     ssut.splitter_set_paf_state(SIP_PAF_BODY_SEARCH);
@@ -129,7 +129,7 @@ TEST(sip_splitter_scan_test, scan_flush_test)
     CHECK_EQUAL(ret, StreamSplitter::FLUSH);
     CHECK_TRUE(ssut.is_init());
     CHECK_EQUAL(fp, 7);
-    
+
     ssut.splitter_reset_states();
     // Whole Sip body is not in one buffer
     fp = 0;
index 592cc80c2edfde647195585fef573be3c63e2442..89d7974623e373a36c2a4b55de8472656fa742b0 100644 (file)
@@ -108,7 +108,7 @@ TEST(sip_splitter_test, get_length_overflow_test)
 }
 
 TEST(sip_splitter_test, get_length_finish_test)
-{   
+{
     for(auto ch : spaces)
     {
         ssut.splitter_set_content_length(201);
@@ -123,7 +123,7 @@ TEST(sip_splitter_test, process_command_skip_leading_spaces_test)
     for(auto ch : spaces)
     {
         ssut.splitter_process_command(ch);
-        CHECK_TRUE(ssut.is_init());        
+        CHECK_TRUE(ssut.is_init());
     }
 }
 
@@ -137,7 +137,6 @@ TEST(sip_splitter_test, process_command_set_next_test)
     ssut.splitter_process_command('l');
     CHECK_EQUAL(*ssut.splitter_get_next_letter(), '\0');
 
-        
     ssut.splitter_reset_states();
     for(int i = 0; content_len_key[i] != '\0'; i++) {
         ssut.splitter_process_command(content_len_key[i]);
@@ -148,7 +147,7 @@ TEST(sip_splitter_test, process_command_set_next_test)
 TEST(sip_splitter_test, process_command_invalid_input_test)
 {
     ssut.splitter_process_command('O');
-    CHECK_TRUE(ssut.is_init());        
+    CHECK_TRUE(ssut.is_init());
 }
 
 TEST(sip_splitter_test, process_command_len_convert_test)
@@ -164,7 +163,7 @@ TEST(sip_splitter_test, process_command_skip_blanks_len_convert_test)
     for(auto ch : blanks)
     {
         ssut.splitter_process_command(ch);
-        CHECK_FALSE(ssut.is_init()); 
+        CHECK_FALSE(ssut.is_init());
     }
 }
 
@@ -172,7 +171,7 @@ TEST(sip_splitter_test, process_command_invalid_blanks_len_convert_test)
 {
     ssut.splitter_set_next_letter_last();
     ssut.splitter_process_command('\r');
-    CHECK_TRUE(ssut.is_init()); 
+    CHECK_TRUE(ssut.is_init());
 }
 
 int main(int argc, char** argv)
index c94cf8d78b8d849e20ebc199ad0ceacb7d80decc..076b047e22d914cf854b1f1c853bdb8d4a7dc90d 100644 (file)
@@ -45,22 +45,22 @@ public:
     SipSplitterUT(const SipSplitter& ss) : ss(ss) { };
 
     bool splitter_is_paf()
-    { 
+    {
         return ss.is_paf();
     }
 
     void splitter_reset_states()
-    { 
+    {
         ss.reset_states();
     }
 
     SipPafStates splitter_get_paf_state()
-    { 
-        return ss.paf_state; 
+    {
+        return ss.paf_state;
     }
 
     SipPafBodyStatus splitter_get_body_state()
-    { 
+    {
         return ss.body_state;
     }
 
index 6cb9289934c384a2c4325d9a2bedd773e60e78b5..39b29fc686533d566edf10759f9aa7caeb0181c2 100644 (file)
@@ -50,7 +50,7 @@
 #define STATE_BDATA            3    // Binary data state
 #define STATE_TLS_CLIENT_PEND  4    // Got STARTTLS
 #define STATE_TLS_SERVER_PEND  5    // Got STARTTLS
-#define STATE_TLS_DATA         6    // Successful handshake, TLS encrypted data 
+#define STATE_TLS_DATA         6    // Successful handshake, TLS encrypted data
 #define STATE_AUTH             7
 #define STATE_XEXCH50          8
 #define STATE_UNKNOWN          9
@@ -143,15 +143,15 @@ class SmtpMime : public snort::MimeSession
 public:
     using snort::MimeSession::MimeSession;
     SMTP_PROTO_CONF* config;
-#ifndef UNIT_TEST  
+#ifndef UNIT_TEST
 private:
-#endif  
+#endif
     int handle_header_line(const uint8_t* ptr, const uint8_t* eol,
         int max_header_len, snort::Packet* p) override;
     int normalize_data(const uint8_t* ptr, const uint8_t* data_end, snort::Packet* p) override;
 #ifdef UNIT_TEST
 private:
-#endif  
+#endif
     void decode_alert() override;
     void decompress_alert() override;
     void reset_state(snort::Flow* ssn) override;
index 3a0d1632019f55171ffd77a46bd5f8bee9a1f6b8..8c8c269e780d095a53bfc115a2956d97e30faeb0 100644 (file)
@@ -102,7 +102,7 @@ enum SMTPCmdTypeEnum
 struct SMTPCmdConfig
 {
     bool alert;
-    bool normalize;     //  1 if we should normalize this command 
+    bool normalize;     //  1 if we should normalize this command
     int max_line_len;   //  Max length of this particular command
 };
 
index d6d0daa61b06e2d6e9400f828fe8662c42fe654b..bd8907dcf019ca0c5d833a278ec0c4f069a57fbd 100644 (file)
@@ -205,7 +205,7 @@ static void snort_ssh(SSH_PROTO_CONF* config, Packet* p)
         {
             offset = ProcessSSHProtocolVersionExchange(config, sessp, p, direction);
             if (!offset)
-                // Error processing protovers exchange msg 
+                // Error processing protovers exchange msg
                 return;
 
             // found protocol version.
@@ -357,11 +357,11 @@ static unsigned int ProcessSSHProtocolVersionExchange(SSH_PROTO_CONF* config, SS
     }
     else
     {
-        /* unknown version */ 
+        /* unknown version */
         sessionp->version =  SSH_VERSION_UNKNOWN;
 
         DetectionEngine::queue_event(GID_SSH, SSH_EVENT_VERSION);
-        
+
         return 0;
     }
 
index 340299956b67aafcec2e5f443c4e445031743e71..c3aceb0e59cfe15dbc322460493b8bd62c101cd5 100644 (file)
@@ -58,7 +58,7 @@ StreamSplitter::Status SslSplitter::scan(
                 is_sslv2 = true;
                 paf_state = SSL_PAF_STATES_LEN2_V2;
             }
-            else 
+            else
             {
                 // unknown
                 if (last_fp > 0)
index 5c8e09e5a03413ec10315bdf25a658ed45062269..f0b1efc804f9cda238aa2383ebcdcaff7c26b224 100644 (file)
@@ -23,8 +23,8 @@
 
 // Protocol aware flushing for SSL
 // TLSPlaintext records are flushed when end-of-record meets end-of segment
-// The splitter supports both sslv2 and sslv3 record format, 
-// it starts by checking the first byte, if it is a valid sslv3 content type, 
+// The splitter supports both sslv2 and sslv3 record format,
+// it starts by checking the first byte, if it is a valid sslv3 content type,
 // mark the session as sslv3; else if the MSB bit was set, marks it as sslv2,
 // if this bit is not set, yet the session was marked sslv2 from prior detection,
 // continue as sslv2
@@ -41,7 +41,7 @@ enum SslPafStates
     SSL_PAF_STATES_LEN2,    // length byte-1
     SSL_PAF_STATES_DATA,    // fragment
     SSL_PAF_STATES_LEN2_V2, // sslv2, length byte-1
-    SSL_PAF_STATES_PAD_V2,  // sslv2, padding byte if needed 
+    SSL_PAF_STATES_PAD_V2,  // sslv2, padding byte if needed
 };
 
 class SslSplitter : public snort::StreamSplitter
index bac6498b0b231544d94d0b166f31ebb3af87a221..9dfbfb24685a2f589300d2810b33cc4cd40168ad 100644 (file)
@@ -293,7 +293,7 @@ SfIpRet sfvt_add_str(vartable_t* table, const char* str, sfip_var_t** ipret)
 
 /* Adds the variable described by "src" to the variable "dst",
  * using the vartable for looking variables used within "src".
- * If vartable is null variables are not supported. 
+ * If vartable is null variables are not supported.
  */
 SfIpRet sfvt_add_to_var(vartable_t* table, sfip_var_t* dst, const char* src)
 {
index 7bc89e1931ff1c810e64a6c7782d1e106935fb79..eda0ef0f53008168c30a5c853495e474f9e957a3 100644 (file)
@@ -191,7 +191,7 @@ void StreamBase::tinit()
 
     if ( config.flow_cache_cfg.max_flows > 0 )
         flow_con->init_exp(config.flow_cache_cfg.max_flows);
+
     FlushBucket::set(config.footprint);
 }
 
@@ -270,7 +270,7 @@ void StreamBase::eval(Packet* p)
 
     case PktType::MAX:
         break;
-    };
+    }
 }
 
 //-------------------------------------------------------------------------
index fc0d0f7d54eb4d50c289f9a0256c9c747ecb479f..5f7e48707f8db4248c8e43e4ff972b44226f8813 100644 (file)
@@ -198,22 +198,22 @@ void StreamModule::reset_stats()
 // Stream handler to adjust allocated resources as needed on a config reload
 bool StreamReloadResourceManager::initialize(const StreamModuleConfig& config_)
 {
-       // FIXIT-L - saving config here to check footprint change is a bit of a hack,
-       if ( Snort::is_reloading() )
-       {
-               if ( config.footprint != config_.footprint )
-               {
+    // FIXIT-L - saving config here to check footprint change is a bit of a hack,
+    if ( Snort::is_reloading() )
+    {
+        if ( config.footprint != config_.footprint )
+        {
             // FIXIT-M - reinit FlushBucket...
             ReloadError("Changing of stream.footprint requires a restart\n");
             return false;
-               }
+        }
 
-               config = config_;
-               return true;
-       }
+        config = config_;
+        return true;
+    }
 
-       config = config_;
-       return false;
+    config = config_;
+    return false;
 }
 
 bool StreamReloadResourceManager::tinit()
@@ -250,17 +250,17 @@ bool StreamReloadResourceManager::tune_idle_context()
 
 bool StreamReloadResourceManager::tune_resources(unsigned work_limit)
 {
-       // we are done if new max is > currently allocated flow objects
-       if ( flow_con->get_flows_allocated() <= config.flow_cache_cfg.max_flows )
-               return true;
-
-       unsigned flows_to_delete =
-           flow_con->get_flows_allocated() - config.flow_cache_cfg.max_flows;
-       if ( flows_to_delete > work_limit )
-           flows_to_delete -= flow_con->delete_flows(work_limit);
-       else
-           flows_to_delete -= flow_con->delete_flows(flows_to_delete);
-
-       return ( flows_to_delete ) ? false : true;
+    // we are done if new max is > currently allocated flow objects
+    if ( flow_con->get_flows_allocated() <= config.flow_cache_cfg.max_flows )
+        return true;
+
+    unsigned flows_to_delete =
+        flow_con->get_flows_allocated() - config.flow_cache_cfg.max_flows;
+    if ( flows_to_delete > work_limit )
+        flows_to_delete -= flow_con->delete_flows(work_limit);
+    else
+        flows_to_delete -= flow_con->delete_flows(flows_to_delete);
+
+    return ( flows_to_delete ) ? false : true;
 }
 
index ab8a366a786232db522ba499e56c44eb671528d6..2faf966e2c52d33a595f6f5d4957825ee6a70a55 100644 (file)
@@ -80,7 +80,7 @@ struct StreamModuleConfig
 class StreamReloadResourceManager : public snort::ReloadResourceTuner
 {
 public:
-       StreamReloadResourceManager() {}
+    StreamReloadResourceManager() {}
 
     bool tinit() override;
     bool tune_packet_context() override;
index c096feb7c7b9febdc902497f3d24338996d7838c..35fd0cba3e353a2ee7edebb751039255461f8797 100644 (file)
@@ -43,7 +43,7 @@ static THREAD_LOCAL ProfileStats file_ssn_stats;
 // FileSession methods
 //-------------------------------------------------------------------------
 
-FileSession::FileSession(Flow* flow) : Session(flow)
+FileSession::FileSession(Flow* f) : Session(f)
 { memory::MemoryCap::update_allocations(sizeof(*this)); }
 
 FileSession::~FileSession()
index 48d3d5a86aacd793c3d07cfb5ef0f39f22a7915f..887f8e47492648e467f12107205450022cb43973 100644 (file)
@@ -177,7 +177,7 @@ static int ProcessIcmpUnreach(Packet* p)
 // IcmpSession methods
 //-------------------------------------------------------------------------
 
-IcmpSession::IcmpSession(Flow* flow) : Session(flow)
+IcmpSession::IcmpSession(Flow* f) : Session(f)
 { memory::MemoryCap::update_allocations(sizeof(*this)); }
 
 IcmpSession::~IcmpSession()
@@ -189,8 +189,8 @@ bool IcmpSession::setup(Packet*)
     ssn_time.tv_sec = 0;
     ssn_time.tv_usec = 0;
     flow->ssn_state.session_flags |= SSNFLAG_SEEN_SENDER;
-    SESSION_STATS_ADD(icmpStats);
-    
+    SESSION_STATS_ADD(icmpStats)
+
     StreamIcmpConfig* pc = get_icmp_cfg(flow->ssn_server);
     flow->set_default_session_timeout(pc->session_timeout, false);
 
@@ -206,7 +206,7 @@ void IcmpSession::clear()
 int IcmpSession::process(Packet* p)
 {
     int status;
-    
+
     flow->set_expire(p, flow->default_session_timeout);
 
     if (!(flow->ssn_state.session_flags & SSNFLAG_ESTABLISHED) and !(p->is_from_client()))
index abe35a574d78ad37d94fed3284a72b28d4445ae0..9389a28c88104973a17bfee64f29abecac5eea94 100644 (file)
@@ -128,7 +128,7 @@ static inline void update_session(Packet* p, Flow* lws)
 // IpSession methods
 //-------------------------------------------------------------------------
 
-IpSession::IpSession(Flow* flow) : Session(flow)
+IpSession::IpSession(Flow* f) : Session(f)
 { memory::MemoryCap::update_allocations(sizeof(*this)); }
 
 IpSession::~IpSession()
@@ -149,7 +149,7 @@ void IpSession::clear()
 
 bool IpSession::setup(Packet* p)
 {
-    SESSION_STATS_ADD(ip_stats);
+    SESSION_STATS_ADD(ip_stats)
     memset(&tracker, 0, sizeof(tracker));
 
     StreamIpConfig* pc = get_ip_cfg(flow->ssn_server);
index 9926ed7aa006602022b8e97843570b2fe3c06f92..e2ebc67e1e84b5a5a73d3f142cd4e41c06006db0 100644 (file)
@@ -158,7 +158,7 @@ void Stream::check_flow_closed(Packet* p)
     if (flow->session_state & STREAM_STATE_CLOSED)
     {
         assert(flow_con);
-        
+
         // this will get called on each onload
         // eventually all onloads will occur and delete will be called
         if ( not flow->is_suspended() )
@@ -214,8 +214,8 @@ void Stream::stop_inspection(
     assert(flow && flow->session);
 
     trace_logf(stream, "stop inspection on flow, dir %s \n",
-              dir == SSN_DIR_BOTH ? "BOTH": 
-              ((dir == SSN_DIR_FROM_CLIENT) ? "FROM_CLIENT" : "FROM_SERVER"));
+        dir == SSN_DIR_BOTH ? "BOTH" :
+        ((dir == SSN_DIR_FROM_CLIENT) ? "FROM_CLIENT" : "FROM_SERVER"));
 
     switch (dir)
     {
index c6d3ac65e27a54666547797b1f26ba3f0c007928..5ec433851cdd193a2abd36a23bae668c5d74e07b 100644 (file)
@@ -210,7 +210,7 @@ bool SizeModule::set(const char*, Value& v, SnortConfig*)
 
     else
         return false;
-    
+
     return true;
 }
 
index 682a3937e694ba0ee16dd7e43671b85f6398dad0..9fc12f666571d195b7cd631b464424e7256402c2 100644 (file)
@@ -72,8 +72,7 @@ void TcpSession::sinit()
 void TcpSession::sterm()
 { TcpSegmentNode::clear(); }
 
-TcpSession::TcpSession(Flow* flow)
-    : TcpStreamSession(flow)
+TcpSession::TcpSession(Flow* f) : TcpStreamSession(f)
 {
     tsm = TcpStateMachine::get_instance();
     splitter_init = false;
@@ -99,7 +98,7 @@ bool TcpSession::setup(Packet* p)
     const TcpStreamConfig* cfg = get_tcp_cfg(flow->ssn_server);
     flow->set_default_session_timeout(cfg->session_timeout, false);
 
-    SESSION_STATS_ADD(tcpStats);
+    SESSION_STATS_ADD(tcpStats)
     tcpStats.setups++;
     return true;
 }
index 820dfb5a00a44e4072759bcc5974c4ffa5c51f6d..b8787f8a71f07c092cefcb0bacdc636d2c7498a0 100644 (file)
@@ -54,7 +54,7 @@ void TcpStreamSession::init_new_tcp_session(TcpSegmentDescriptor& tsd)
     /* New session, previous was marked as reset.  Clear the reset flag. */
     flow->clear_session_flags(SSNFLAG_RESET);
 
-    flow->set_expire(tsd.get_pkt(), flow->default_session_timeout); 
+    flow->set_expire(tsd.get_pkt(), flow->default_session_timeout);
 
     update_perf_base_state(TcpStreamTracker::TCP_SYN_SENT);
 
index cb81e4064ac17a8c73b78f7d17fa2eb97ddbf104..f071a46a3e029c0e0df28df33dc86e13536eb958 100644 (file)
@@ -103,7 +103,7 @@ static int ProcessUdp(
 // UdpSession methods
 //-------------------------------------------------------------------------
 
-UdpSession::UdpSession(Flow* flow) : Session(flow)
+UdpSession::UdpSession(Flow* f) : Session(f)
 { memory::MemoryCap::update_allocations(sizeof(*this)); }
 
 UdpSession::~UdpSession()
@@ -122,7 +122,7 @@ bool UdpSession::setup(Packet* p)
     StreamUdpConfig* pc = get_udp_cfg(flow->ssn_server);
     flow->set_default_session_timeout(pc->session_timeout, false);
 
-    SESSION_STATS_ADD(udpStats);
+    SESSION_STATS_ADD(udpStats)
 
     DataBus::publish(FLOW_STATE_EVENT, p);
 
@@ -193,7 +193,7 @@ int UdpSession::process(Packet* p)
 
     ProcessUdp(flow, p, pc, nullptr);
     flow->markup_packet_flags(p);
-    
+
     flow->set_expire(p, flow->default_session_timeout);
 
     return 0;
index 96e432a0a0023cd281f5a90e876dd3d4921779dc..852d961c6598330a5b97cb50108e14a9ab56c584 100644 (file)
@@ -305,12 +305,12 @@ void UserTracker::add_data(Packet* p)
 // may need additional refactoring
 //-------------------------------------------------------------------------
 
-void UserSession::start(Packet* p, Flow* flow)
+void UserSession::start(Packet* p, Flow* f)
 {
-    Inspector* ins = flow->gadget;
+    Inspector* ins = f->gadget;
 
     if ( !ins )
-        ins = flow->clouseau;
+        ins = f->clouseau;
 
     if ( ins )
     {
@@ -324,46 +324,46 @@ void UserSession::start(Packet* p, Flow* flow)
     }
 
     {
-        flow->pkt_type = p->type();
-        flow->ip_proto = (uint8_t)p->get_ip_proto_next();
+        f->pkt_type = p->type();
+        f->ip_proto = (uint8_t)p->get_ip_proto_next();
 
-        if (flow->ssn_state.session_flags & SSNFLAG_RESET)
-            flow->ssn_state.session_flags &= ~SSNFLAG_RESET;
+        if (f->ssn_state.session_flags & SSNFLAG_RESET)
+            f->ssn_state.session_flags &= ~SSNFLAG_RESET;
 
-        if ( (flow->ssn_state.session_flags & SSNFLAG_CLIENT_SWAP) &&
-            !(flow->ssn_state.session_flags & SSNFLAG_CLIENT_SWAPPED) )
+        if ( (f->ssn_state.session_flags & SSNFLAG_CLIENT_SWAP) &&
+            !(f->ssn_state.session_flags & SSNFLAG_CLIENT_SWAPPED) )
         {
-            SfIp ip = flow->client_ip;
-            uint16_t port = flow->client_port;
+            SfIp ip = f->client_ip;
+            uint16_t port = f->client_port;
 
-            flow->client_ip = flow->server_ip;
-            flow->server_ip = ip;
+            f->client_ip = f->server_ip;
+            f->server_ip = ip;
 
-            flow->client_port = flow->server_port;
-            flow->server_port = port;
+            f->client_port = f->server_port;
+            f->server_port = port;
 
-            if ( !flow->two_way_traffic() )
+            if ( !f->two_way_traffic() )
             {
-                if ( flow->ssn_state.session_flags & SSNFLAG_SEEN_CLIENT )
+                if ( f->ssn_state.session_flags & SSNFLAG_SEEN_CLIENT )
                 {
-                    flow->ssn_state.session_flags ^= SSNFLAG_SEEN_CLIENT;
-                    flow->ssn_state.session_flags |= SSNFLAG_SEEN_SERVER;
+                    f->ssn_state.session_flags ^= SSNFLAG_SEEN_CLIENT;
+                    f->ssn_state.session_flags |= SSNFLAG_SEEN_SERVER;
                 }
-                else if ( flow->ssn_state.session_flags & SSNFLAG_SEEN_SERVER )
+                else if ( f->ssn_state.session_flags & SSNFLAG_SEEN_SERVER )
                 {
-                    flow->ssn_state.session_flags ^= SSNFLAG_SEEN_SERVER;
-                    flow->ssn_state.session_flags |= SSNFLAG_SEEN_CLIENT;
+                    f->ssn_state.session_flags ^= SSNFLAG_SEEN_SERVER;
+                    f->ssn_state.session_flags |= SSNFLAG_SEEN_CLIENT;
                 }
             }
-            flow->ssn_state.session_flags |= SSNFLAG_CLIENT_SWAPPED;
+            f->ssn_state.session_flags |= SSNFLAG_CLIENT_SWAPPED;
         }
 #if 0
         // FIXIT-M implement stream_user perf stats
-        //flow->set_expire(p, dstPolicy->session_timeout);
+        //f->set_expire(p, dstPolicy->session_timeout);
 
         // add user flavor to perf stats?
         AddStreamSession(
-            &sfBase, flow->session_state & STREAM_STATE_MIDSTREAM ? SSNFLAG_MIDSTREAM : 0);
+            &sfBase, f->session_state & STREAM_STATE_MIDSTREAM ? SSNFLAG_MIDSTREAM : 0);
 
         StreamUpdatePerfBaseState(&sfBase, tmp->flow, TCP_STATE_SYN_SENT);
 
@@ -381,30 +381,30 @@ void UserSession::end(Packet*, Flow*)
     server.splitter = nullptr;
 }
 
-void UserSession::update(Packet* p, Flow* flow)
+void UserSession::update(Packet* p, Flow* f)
 {
     if ( p->ptrs.sp and p->ptrs.dp )
         p->packet_flags |= PKT_STREAM_EST;
     else
         p->packet_flags |= PKT_STREAM_UNEST_UNI;
 
-    if ( !(flow->ssn_state.session_flags & SSNFLAG_ESTABLISHED) )
+    if ( !(f->ssn_state.session_flags & SSNFLAG_ESTABLISHED) )
     {
         if ( p->is_from_client() )
-            flow->ssn_state.session_flags |= SSNFLAG_SEEN_CLIENT;
+            f->ssn_state.session_flags |= SSNFLAG_SEEN_CLIENT;
         else
-            flow->ssn_state.session_flags |= SSNFLAG_SEEN_SERVER;
+            f->ssn_state.session_flags |= SSNFLAG_SEEN_SERVER;
 
-        if ( (flow->ssn_state.session_flags & SSNFLAG_SEEN_CLIENT) &&
-            (flow->ssn_state.session_flags & SSNFLAG_SEEN_SERVER) )
+        if ( (f->ssn_state.session_flags & SSNFLAG_SEEN_CLIENT) &&
+            (f->ssn_state.session_flags & SSNFLAG_SEEN_SERVER) )
         {
-            flow->ssn_state.session_flags |= SSNFLAG_ESTABLISHED;
+            f->ssn_state.session_flags |= SSNFLAG_ESTABLISHED;
 
-            flow->set_ttl(p, false);
+            f->set_ttl(p, false);
         }
     }
 
-    flow->set_expire(p, flow->default_session_timeout);
+    f->set_expire(p, f->default_session_timeout);
 }
 
 void UserSession::restart(Packet* p)
@@ -428,7 +428,7 @@ void UserSession::restart(Packet* p)
 // UserSession methods
 //-------------------------------------------------------------------------
 
-UserSession::UserSession(Flow* flow) : Session(flow)
+UserSession::UserSession(Flow* f) : Session(f)
 { memory::MemoryCap::update_allocations(sizeof(*this)); }
 
 UserSession::~UserSession()
index 7e9a3e46c3526727c0fe8d5c0994bd0401e14fdc..ebf4ee2f9f9f0d32bbc1165db20d199c1ef7db37 100644 (file)
@@ -86,7 +86,7 @@ TEST(protocol_reference, service_protocols)
 //     * is_network_protocol()
 //     * is_builtin_protocol()
 //     * is_service_protocol()
-TEST(protocol_reference, builtin_protocols) 
+TEST(protocol_reference, builtin_protocols)
 {
     ProtocolReference refs;
 
index 4a0306aa5fe6dd1b7d1902b887adbf97471b74a7..67b8ef921a1fd6682a3c0b1e19d960ac3997b1d5 100644 (file)
@@ -33,7 +33,7 @@ namespace snort
 template<typename T>
 class PrimedAllocator
 {
-public: 
+public:
     struct Node
     {
         Node* next;
@@ -85,7 +85,7 @@ public:
 
         if ( !this->state->ref_count )
             delete state;
-        
+
         this->state = state;
         state->ref_count++;
     }
@@ -103,7 +103,7 @@ public:
         }
         return reinterpret_cast<T*>(operator new(sizeof(T)));
     }
-        
+
     void deallocate(pointer p, size_type) noexcept
     {
         Node* node = reinterpret_cast<Node*>(p);
index 1dd8c47922d35927dd7899b6d32a9d4de0aca639..8b6077d3e223dacb822b4937826c1bae41335021 100644 (file)
@@ -485,7 +485,7 @@ std::string read_infile(const char* key, const char* fname)
     {
         ParseError("can't open file %s = %s: %s", key, fname, get_error(errno));
         close(fd);
-        return "";  
+        return "";
     }
     close(fd);
     return line;
index abf302b6ec1b042e10142a9c9a142c0cc9c9e2ff..7d327c2e6a53b3eda51bb0f5b2b7fd6a23cc3ad0 100644 (file)
 #define SECONDS_PER_HOUR  3600  /* number of seconds in a hour */
 #define SECONDS_PER_MIN     60     /* number of seconds in a minute */
 
-#define COPY4(x, y) \
-    x[0] = (y)[0]; (x)[1] = (y)[1]; (x)[2] = (y)[2]; (x)[3] = (y)[3];
-
-#define COPY16(x,y) \
-    x[0] = (y)[0]; (x)[1] = (y)[1]; (x)[2] = (y)[2]; (x)[3] = (y)[3]; \
-    (x)[4] = (y)[4]; (x)[5] = (y)[5]; (x)[6] = (y)[6]; (x)[7] = (y)[7]; \
-    (x)[8] = (y)[8]; (x)[9] = (y)[9]; (x)[10] = (y)[10]; (x)[11] = (y)[11]; \
-    (x)[12] = (y)[12]; (x)[13] = (y)[13]; (x)[14] = (y)[14]; (x)[15] = (y)[15];
-
 void StoreSnortInfoStrings();
 int DisplayBanner();
 int gmt2local(time_t);
@@ -68,6 +59,17 @@ void InitProtoNames();
 void SetNoCores();
 #endif
 
+namespace
+{
+inline void COPY4(uint32_t* dst, const uint32_t* src)
+{
+    dst[0] = src[0];
+    dst[1] = src[1];
+    dst[2] = src[2];
+    dst[3] = src[3];
+}
+}
+
 inline void* snort_alloc(size_t sz)
 { return new uint8_t[sz]; }
 
index 327cc87a020463da35a95d3746ead55e20065986..98dcc40fa48b2aa6e30ed1209607caeb37409fcf 100644 (file)
@@ -264,7 +264,7 @@ std::ostream& operator<<(std::ostream& out, const Table& t)
 
         if ( !t.key.empty() )
             out << "[\"" << t.key << "\"]";
-        
+
         out << (t.one_line ? " = " : " =\n");
     }
 
index e68888c3fd69d8105be9ccfdf3d14727d069b0c0..a26a265b442e96c4526bfdf83ce01a50d7e27dc2 100644 (file)
@@ -36,7 +36,7 @@ public:
     std::string get_value(DataApi*);
     bool add_value(std::string);
     void set_value(const std::string&, bool quoted);
-    
+
     void set_print_whitespace(bool w)
     { print_whitespace = w; }
 
index 23c0ecae046edb911a793cb04965a58fe805e2a3..b717e9abcbd8df6cdec5c4818a6ae9701bb2b777 100644 (file)
@@ -150,7 +150,7 @@ private:
     template<typename T>
     bool do_add_option(const std::string& opt_name, const T val, const std::string& s_val);
 
-    template<typename T> 
+    template<typename T>
     void do_append_option(const std::string& opt_name, const T val, const std::string& s_val);
 
     void create_append_data(std::string& fqn, Table*& t);
index 1d3e3ae608d814c3f626e293e37104073f949711..d6d3250f0d8621b3bd52fba5c92fcaaf65ea9c48 100644 (file)
@@ -255,7 +255,7 @@ static void bind_wizard(const char* /*key*/, const char* /*val*/)
 { Converter::set_bind_wizard(true); }
 
 static void bind_port(const char* /*key*/, const char* /*val*/)
-{ 
+{
     Converter::set_bind_port(true);
     Converter::set_bind_wizard(false);
 }
index fa6806bed399fa9dcf80d9d09bd61258a24a4179..b7f78695d373bc22cc3803811b0bb40150f96d46 100644 (file)
@@ -121,7 +121,7 @@ void Binder::add_to_configuration()
             case IT_NETWORK:
                 opt_name = "network_policy";
                 break;
-            
+
             default:
                 // This should always be set explicitly if a file name exists.
                 assert(false);
@@ -250,27 +250,27 @@ bool operator<(const shared_ptr<Binder>& left, const shared_ptr<Binder>& right)
     }
 
     // By predetermined order
-    FIRST_IF_LT(left->get_priority(), right->get_priority());
+    FIRST_IF_LT(left->get_priority(), right->get_priority())
 
     // By priorities of options
     FIRST_IF_GT(left->has_ips_policy_id(), right->has_ips_policy_id())
-    
+
     auto left_zone_specs = left->has_src_zone() + left->has_dst_zone();
     auto right_zone_specs = right->has_src_zone() + right->has_dst_zone();
-    FIRST_IF_GT(left_zone_specs, right_zone_specs);
+    FIRST_IF_GT(left_zone_specs, right_zone_specs)
 
     FIRST_IF_GT(left->has_vlans(), right->has_vlans())
     FIRST_IF_GT(left->has_service(), right->has_service())
 
     auto left_net_specs = left->has_src_nets() + left->has_dst_nets();
     auto right_net_specs = right->has_src_nets() + right->has_dst_nets();
-    FIRST_IF_GT(left_net_specs, right_net_specs);
+    FIRST_IF_GT(left_net_specs, right_net_specs)
 
     FIRST_IF_GT(left->has_nets(), right->has_nets())
 
     auto left_port_specs = left->has_src_ports() + left->has_dst_ports();
     auto right_port_specs = right->has_src_ports() + right->has_dst_ports();
-    FIRST_IF_GT(left_port_specs, right_port_specs);
+    FIRST_IF_GT(left_port_specs, right_port_specs)
 
     FIRST_IF_GT(left->has_ports(), right->has_ports())
     FIRST_IF_GT(left->has_proto(), right->has_proto())
@@ -310,7 +310,7 @@ bool operator<(const shared_ptr<Binder>& left, const shared_ptr<Binder>& right)
 
 void print_binder_priorities()
 {
-    static unsigned const num_combos = 2 << 12; 
+    static unsigned const num_combos = 2 << 12;
     vector<shared_ptr<Binder>> binders;
     TableApi t;
 
index 73263eb8b8bc00ffd05cc4efd1735330dbbff51d..5778bd3113c891183df54d71390849b188de9bf6 100644 (file)
@@ -141,7 +141,7 @@ private:
                           // by either the destructor or user
 
     unsigned priority = PRIORITY_LAST;
-    
+
     int when_ips_policy_id = -1;
     std::string when_service;
     std::string when_role;
@@ -155,7 +155,7 @@ private:
     std::vector<std::string> dst_ports;
     std::vector<std::string> when_src_zone;
     std::vector<std::string> when_dst_zone;
-    std::vector<std::string> zones; 
+    std::vector<std::string> zones;
 
     std::string use_type;
     std::string use_name;
index 542f3af13c5798300931496e27cc719081fd6e2e..6210852082ae9a6d037b90999f9cddebfe7fd5d0 100644 (file)
@@ -41,21 +41,21 @@ private:
 } // namespace
 
 static std::unordered_set<std::string> string_keys = {
-            "category", 
-            "msg",
-            "type",
-            "ver",
-            "group",
+    "category",
+    "msg",
+    "type",
+    "ver",
+    "group",
 };
 
 static std::unordered_set<std::string> int_keys = {
-            "id",
-            "rev",
+    "id",
+    "rev",
 };
 
 static std::unordered_set<std::string> content_keys = {
-            "content",
-            "offset",
+    "content",
+    "offset",
 };
 
 bool File::convert(std::istringstream& data_stream)
index 0a4f7ead3329ed81a1e9d05b8445f25921a7c2d6..5ec7532b83b09f6135a7a02cadf67c4fbeab00ba 100644 (file)
@@ -102,7 +102,7 @@ bool Dns::convert(std::istringstream& data_stream)
         }
     }
 
-    if (!ports_set) 
+    if (!ports_set)
     {
         tcp_bind.set_when_role("server");
         tcp_bind.add_when_port("53");
index df48e12436875f8bc8881ee6ac970ddc6f1cc06f..59ee864d25ec05651d0b765d1cbacbbbfcfbe955 100644 (file)
@@ -104,7 +104,7 @@ bool Imap::convert(std::istringstream& data_stream)
                     bind.set_when_proto("tcp");
                     while (data_stream >> keyword && keyword != "}")
                     {
-                        default_binding = false;;
+                        default_binding = false;
                         bind.add_when_port(keyword);
                     }
                 }
index 138fbaa2ff233bdc4001812b1200240444250a27..95f5ddd495cded9edbdef78528593f975f477b64 100644 (file)
@@ -58,21 +58,21 @@ public:
             std::string protocol;
             std::string ips_policy;
 
-            TRY_FIELD(action);   // ignore since nap rules don't drop
-            TRY_FIELD(src_zone);
-            TRY_FIELD(src_net);
+            TRY_FIELD(action)   // ignore since nap rules don't drop
+            TRY_FIELD(src_zone)
+            TRY_FIELD(src_net)
             if ( src_net != "any" )
-                TRY_FIELD(src_netmask);
+                TRY_FIELD(src_netmask)
 
-            TRY_FIELD(src_port);
-            TRY_FIELD(dst_zone);
-            TRY_FIELD(dst_net);
+            TRY_FIELD(src_port)
+            TRY_FIELD(dst_zone)
+            TRY_FIELD(dst_net)
             if ( dst_net != "any" )
-                TRY_FIELD(dst_netmask);
+                TRY_FIELD(dst_netmask)
 
-            TRY_FIELD(dst_port);
-            TRY_FIELD(vlan);
-            TRY_FIELD(protocol);
+            TRY_FIELD(dst_port)
+            TRY_FIELD(vlan)
+            TRY_FIELD(protocol)
 
             for ( std::string s; data_stream >> s; ips_policy += " " + s );
 
index 42d4ecf620ddaf3c06cdd073d79d63eb99b51988..b6fd3abc5339a0d79f22af7a23d8d7b76611c508 100644 (file)
@@ -312,7 +312,7 @@ bool Smtp::convert(std::istringstream& data_stream)
                     bind.set_when_proto("tcp");
                     while (data_stream >> keyword && keyword != "}")
                     {
-                        default_binding = false; 
+                        default_binding = false;
                         bind.add_when_port(keyword);
                     }
                 }
index 276ea075ebf0eee3a5fe5bb5832bc263a2efcb30..fbe587cbaa25384353100d62a6daacd4945cfed4 100644 (file)
@@ -199,10 +199,10 @@ bool StreamGlobal::convert(std::istringstream& data_stream)
         }
     }
     if ( emit_max_flows )
-       table_api.add_option("max_flows", tcp_max + udp_max + icmp_max + ip_max);
+        table_api.add_option("max_flows", tcp_max + udp_max + icmp_max + ip_max);
 
     if ( emit_pruning_timeout )
-       table_api.add_option("pruning_timeout", INT_MAX == pruning_timeout ? 30 : pruning_timeout);
+        table_api.add_option("pruning_timeout", INT_MAX == pruning_timeout ? 30 : pruning_timeout);
 
     return retval;
 }
index 4082296b996122fcb06c0da01c475a3fd1b636f7..5c77fc5a49a19dc08f33c78c3dc2ab4e6d6f69ff 100644 (file)
@@ -82,7 +82,7 @@ bool StreamHa::convert(std::istringstream& data_stream)
         if (!tmpval)
         {
             data_api.failed_conversion(data_stream, arg_stream.str());
-            retval = false;;
+            retval = false;
         }
     }
     table_api.close_table(); // ha stream
index 4e534107fac5c3b945d3a20a381a243ec51db658..bc421366bca085e5721ff243c1d2750de7fcdc21 100644 (file)
@@ -508,8 +508,8 @@ bool StreamTcp::convert(std::istringstream& data_stream)
             bind_default->print_binding(false);
     }
 
-    //  Add the port bindings separately from the protocol bindings since 
-    //  in 2.9.x they are OR'd not AND'd. Clear the ports so they're not 
+    //  Add the port bindings separately from the protocol bindings since
+    //  in 2.9.x they are OR'd not AND'd. Clear the ports so they're not
     //  included with the protocol bindings.
     cv.make_binder(client);
     client.clear_ports();
index 951f5cbe1a156a3d6182e5706f670d17736b0ef7..6d1e9d1b5be72566538b60b6b73a49457fe827d9 100644 (file)
@@ -107,7 +107,7 @@ bool Gid::convert(std::istringstream& data_stream)
 // Sid
 //
 
-void Sid::convert_sid(std::string& sid, std::istringstream& data_stream, RuleApi& rule_api)
+void Sid::convert_sid(std::string& sid, std::istringstream& data_stream, RuleApi& r_api)
 {
     int sid_num;
     try
@@ -116,7 +116,7 @@ void Sid::convert_sid(std::string& sid, std::istringstream& data_stream, RuleApi
     }
     catch (...)
     {
-        rule_api.bad_rule(data_stream, "sid - invalid input, expecting int type");
+        r_api.bad_rule(data_stream, "sid - invalid input, expecting int type");
         return;
     }
     const int sid_offset = 100;