]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Merge pull request #1841 in SNORT/snort3 from ~DAVMCPHE/snort3:stream_consolidate_sou...
authorRuss Combs (rucombs) <rucombs@cisco.com>
Tue, 3 Dec 2019 02:57:37 +0000 (02:57 +0000)
committerRuss Combs (rucombs) <rucombs@cisco.com>
Tue, 3 Dec 2019 02:57:37 +0000 (02:57 +0000)
Squashed commit of the following:

commit e50ee5a0450248a37a310b42f9be1e8868cacaa9
Author: davis mcpherson <davmcphe@cisco.com>
Date:   Mon Nov 25 10:46:55 2019 -0500

    stream_tcp: updates from PR review comments

commit 88137cf6242a9378cf6351882f7631947bff9d84
Author: davis mcpherson <davmcphe@cisco.com>
Date:   Mon Nov 11 08:58:57 2019 -0500

    stream_tcp: move and update the libtcp source files to the tcp source directory to consolidate the stream tcp code into one component (libtcp goes away)

43 files changed:
src/CMakeLists.txt
src/service_inspectors/dce_rpc/dce_http_proxy.cc
src/service_inspectors/dce_rpc/dce_http_server.cc
src/stream/CMakeLists.txt
src/stream/libtcp/CMakeLists.txt [deleted file]
src/stream/libtcp/dev_notes.txt [deleted file]
src/stream/stream.cc
src/stream/tcp/CMakeLists.txt
src/stream/tcp/dev_notes.txt
src/stream/tcp/ips_stream_reassemble.cc
src/stream/tcp/stream_tcp.cc
src/stream/tcp/tcp_normalizer.cc
src/stream/tcp/tcp_normalizers.cc
src/stream/tcp/tcp_reassemblers.cc
src/stream/tcp/tcp_segment_descriptor.cc [moved from src/stream/libtcp/tcp_segment_descriptor.cc with 100% similarity]
src/stream/tcp/tcp_segment_descriptor.h [moved from src/stream/libtcp/tcp_segment_descriptor.h with 100% similarity]
src/stream/tcp/tcp_segment_node.h
src/stream/tcp/tcp_session.cc
src/stream/tcp/tcp_session.h
src/stream/tcp/tcp_state_close_wait.h
src/stream/tcp/tcp_state_closed.h
src/stream/tcp/tcp_state_closing.h
src/stream/tcp/tcp_state_established.h
src/stream/tcp/tcp_state_fin_wait1.h
src/stream/tcp/tcp_state_fin_wait2.h
src/stream/tcp/tcp_state_handler.cc [moved from src/stream/libtcp/tcp_state_handler.cc with 99% similarity]
src/stream/tcp/tcp_state_handler.h [moved from src/stream/libtcp/tcp_state_handler.h with 98% similarity]
src/stream/tcp/tcp_state_last_ack.h
src/stream/tcp/tcp_state_listen.h
src/stream/tcp/tcp_state_machine.cc [moved from src/stream/libtcp/tcp_state_machine.cc with 68% similarity]
src/stream/tcp/tcp_state_machine.h [moved from src/stream/libtcp/tcp_state_machine.h with 84% similarity]
src/stream/tcp/tcp_state_none.h
src/stream/tcp/tcp_state_syn_recv.h
src/stream/tcp/tcp_state_syn_sent.h
src/stream/tcp/tcp_state_time_wait.h
src/stream/tcp/tcp_stream_session.cc [moved from src/stream/libtcp/tcp_stream_session.cc with 100% similarity]
src/stream/tcp/tcp_stream_session.h [moved from src/stream/libtcp/tcp_stream_session.h with 98% similarity]
src/stream/tcp/tcp_stream_state_machine.cc [deleted file]
src/stream/tcp/tcp_stream_state_machine.h [deleted file]
src/stream/tcp/tcp_stream_tracker.cc [moved from src/stream/libtcp/tcp_stream_tracker.cc with 100% similarity]
src/stream/tcp/tcp_stream_tracker.h [moved from src/stream/libtcp/tcp_stream_tracker.h with 98% similarity]
src/stream/tcp/test/stream_tcp_test_utils.cc [moved from src/stream/libtcp/stream_tcp_unit_test.cc with 95% similarity]
src/stream/tcp/test/stream_tcp_test_utils.h [moved from src/stream/libtcp/stream_tcp_unit_test.h with 90% similarity]

index 779aa3fd226e3aee411cabcad95468e1fd8d01c5..4c58fe463e81e9bd71fa7e13999885b838906a30 100644 (file)
@@ -161,7 +161,6 @@ add_executable( snort
     $<TARGET_OBJECTS:stream_base>
     $<TARGET_OBJECTS:stream_ip>
     $<TARGET_OBJECTS:stream_icmp>
-    $<TARGET_OBJECTS:stream_libtcp>
     $<TARGET_OBJECTS:stream_tcp>
     $<TARGET_OBJECTS:stream_udp>
     $<TARGET_OBJECTS:stream_user>
index 6556e2bec31842d8d90218ba82aca1a01a1bd1d4..8e50ad5c5a6722fc2f7088692acc1fbdad22b160 100644 (file)
@@ -26,7 +26,7 @@
 #include "dce_http_proxy_module.h"
 
 #include "managers/inspector_manager.h"
-#include "stream/libtcp/tcp_stream_session.h"
+#include "stream/tcp/tcp_stream_session.h"
 
 #include "dce_http_proxy_splitter.h"
 
index fc0bdf90b61a5f63e35359aeb4befd0b388560e6..1b3dc9f2a2b5d3a3318090c39b21ed52ee35d837 100644 (file)
@@ -26,7 +26,7 @@
 #include "dce_http_server_module.h"
 
 #include "managers/inspector_manager.h"
-#include "stream/libtcp/tcp_stream_session.h"
+#include "stream/tcp/tcp_stream_session.h"
 
 #include "dce_http_server_splitter.h"
 
index 19eb7f09e54ab9f5f4b082c481834bec280caa75..b531c27b05836e3eb92e7ca40e454ed14110a2e6 100644 (file)
@@ -2,7 +2,6 @@
 add_subdirectory(base)
 add_subdirectory(ip)
 add_subdirectory(icmp)
-add_subdirectory(libtcp)
 add_subdirectory(tcp)
 add_subdirectory(udp)
 add_subdirectory(user)
diff --git a/src/stream/libtcp/CMakeLists.txt b/src/stream/libtcp/CMakeLists.txt
deleted file mode 100644 (file)
index e28affb..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-
-if ( ENABLE_UNIT_TESTS )
-    set(TEST_FILES stream_tcp_unit_test.cc)
-endif()
-
-
-add_library( stream_libtcp OBJECT
-       tcp_segment_descriptor.cc
-       tcp_state_handler.cc
-       tcp_state_machine.cc
-    tcp_stream_session.cc
-    tcp_stream_tracker.cc
-    tcp_segment_descriptor.h
-    tcp_state_handler.h
-    tcp_state_machine.h
-    tcp_stream_session.h
-    tcp_stream_tracker.h
-    ${TEST_FILES}
-)
diff --git a/src/stream/libtcp/dev_notes.txt b/src/stream/libtcp/dev_notes.txt
deleted file mode 100644 (file)
index 0a6ebc9..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-This directory contains the implementation of common TCP session tracking functions.
-
-This TCP library module provides the following functions:
-
-* TCP Segment Descriptor - this class provides access to the various fields of the TCP
-  header and payload
-
-* TCP Stream Tracker - this class encapsulates all the state information required for
-  tracking one side of the TCP connection.  For each flow that is tracked there will be
-  two instances of this tracker, one for each direction.
-
-* TCP State Handler - abstract class interface that defines a method for handling each
-  possible TCP event.  For each TCP state a subclass of this class is created with a
-  state specific implementation for each event handling method.
-
-* TCP State Machine - this class is the engine that dispatches processing to the correct
-  event handling method of the handler for the current TCP state of the flow.
-
-Most of the TCP HA processing is contained in the ../tcp area and one needed to refer
-to ../tcp/dev_notes.txt for a description.
-
-One HA state transition is implemented within this TCP library.  In
-TcpStreamSession::clear(), TcpHAManager::process_deletion() is invoked to
-cause HA to generate a Deletion message for the target flow.  This handles
-the case where a TCP session is being removed from from the flow cache due
-to a timeout or pruning function.  Other normal TCP stream closure actions
-are handled in the ../tcp/tcp_session.cc module.
index 65abe6335d5d72e5ee360c8caa0128c5362164d8..9926ed7aa006602022b8e97843570b2fe3c06f92 100644 (file)
 #include "utils/util.h"
 
 #include "tcp/tcp_session.h"
-#include "libtcp/tcp_stream_session.h"
-
-#ifdef UNIT_TEST
-#include "catch/snort_catch.h"
-#include "libtcp/stream_tcp_unit_test.h"
-#endif
+#include "tcp/tcp_stream_session.h"
 
 using namespace snort;
 
@@ -793,6 +788,9 @@ void Stream::set_no_ack_mode(Flow* flow, bool on_off)
 
 #ifdef UNIT_TEST
 
+#include "catch/snort_catch.h"
+#include "tcp/test/stream_tcp_test_utils.h"
+
 TEST_CASE("Stream API", "[stream_api][stream]")
 {
     // initialization code here
index ad4d30b3116a6e0c3037765cb4be81be73f529b1..38c630f8da8fae96ff30100ce3afba5206ed8aef 100644 (file)
@@ -1,3 +1,7 @@
+if ( ENABLE_UNIT_TESTS )
+    set(TEST_FILES test/stream_tcp_test_utils.cc)
+endif()
+
 add_library( stream_tcp OBJECT
     ips_stream_reassemble.cc
     ips_stream_size.cc
@@ -5,53 +9,62 @@ add_library( stream_tcp OBJECT
     segment_overlap_editor.cc
     stream_tcp.cc
     stream_tcp.h
+    tcp_defs.h
+    tcp_event_logger.h
+    tcp_event_logger.cc
     tcp_ha.cc
     tcp_ha.h
     tcp_module.cc
     tcp_module.h
-    tcp_defs.h
-    tcp_event_logger.h
-    tcp_event_logger.cc
-    tcp_stream_config.h
-    tcp_stream_config.cc
-    tcp_normalizer.h
     tcp_normalizer.cc
-    tcp_normalizers.h
+    tcp_normalizer.h
     tcp_normalizers.cc
-    tcp_segment_node.h
-    tcp_segment_node.cc
-    tcp_reassembler.h
+    tcp_normalizers.h
     tcp_reassembler.cc
-    tcp_reassemblers.h
+    tcp_reassembler.h
     tcp_reassemblers.cc
+    tcp_reassemblers.h
+    tcp_segment_descriptor.cc
+    tcp_segment_descriptor.h
+    tcp_segment_node.cc
+    tcp_segment_node.h
     tcp_session.cc
     tcp_session.h
     tcp_state_closed.cc
-    tcp_state_close_wait.cc
-    tcp_state_closing.cc
-    tcp_state_established.cc
-    tcp_state_fin_wait1.cc
-    tcp_state_fin_wait2.cc
-    tcp_state_last_ack.cc
-    tcp_state_listen.cc
-    tcp_state_none.cc
-    tcp_state_syn_recv.cc
-    tcp_state_syn_sent.cc
-    tcp_state_time_wait.cc
     tcp_state_closed.h
+    tcp_state_close_wait.cc
     tcp_state_close_wait.h
+    tcp_state_closing.cc
     tcp_state_closing.h
+    tcp_state_established.cc
     tcp_state_established.h
+    tcp_state_fin_wait1.cc
     tcp_state_fin_wait1.h
+    tcp_state_fin_wait2.cc
     tcp_state_fin_wait2.h
+    tcp_state_handler.cc
+    tcp_state_handler.h    
+    tcp_state_last_ack.cc
     tcp_state_last_ack.h
+    tcp_state_listen.cc
     tcp_state_listen.h
+    tcp_state_machine.cc
+    tcp_state_machine.h
+    tcp_state_none.cc
     tcp_state_none.h
+    tcp_state_syn_recv.cc
     tcp_state_syn_recv.h
+    tcp_state_syn_sent.cc
     tcp_state_syn_sent.h
+    tcp_state_time_wait.cc
     tcp_state_time_wait.h 
-    tcp_stream_state_machine.cc
-    tcp_stream_state_machine.h
+    tcp_stream_config.cc
+    tcp_stream_config.h
+    tcp_stream_session.cc
+    tcp_stream_session.h
+    tcp_stream_tracker.cc
+    tcp_stream_tracker.h
+    ${TEST_FILES}
 )
 
 add_subdirectory ( test )
index b4bc8bcadce18547683cb511981835d41327bad4..3c0d0d90f42474aa1374a2ff44c7d06de19d95d7 100644 (file)
@@ -11,6 +11,20 @@ functions for loading stream TCP configuration and packet evaluation.  The
 packet eval method is not used as the base Stream Inspector delegates
 packets directly to the TCP session packet processing method.
 
+* TCP Segment Descriptor - this class provides access to the various fields of the TCP
+  header and payload
+
+* TCP Stream Tracker - this class encapsulates all the state information required for
+  tracking one side of the TCP connection.  For each flow that is tracked there will be
+  two instances of this tracker, one for each direction.
+
+* TCP State Handler - abstract class interface that defines a method for handling each
+  possible TCP event.  For each TCP state a subclass of this class is created with a
+  state specific implementation for each event handling method.
+
+* TCP State Machine - this class is the engine that dispatches processing to the correct
+  event handling method of the handler for the current TCP state of the flow.
+  
 The TCP session module implements the following functions:
 
 * TCP segment normalization. Variations in handling normalization are
@@ -62,3 +76,10 @@ TcpHA::deactivate_session() is called from the stream & flow HA logic to
 place a session into standby mode.  Upon receiving an HA Update message, 
 the flow is first created if necessary, and is then placed into Standby
 state.  deactivate_session() sets the TCP specific state for Standy mode.
+
+One HA state transition is implemented within this TCP library.  In
+TcpStreamSession::clear(), TcpHAManager::process_deletion() is invoked to
+cause HA to generate a Deletion message for the target flow.  This handles
+the case where a TCP session is being removed from from the flow cache due
+to a timeout or pruning function.  Other normal TCP stream closure actions
+are handled in the ../tcp/tcp_session.cc module.
index 95f538f14fef825e9159631ab34f150d42e48652..4b58613e31b16af8677bf7eed90ab3a5a3a64e4f 100644 (file)
 
 #include "tcp_session.h"
 
-#ifdef UNIT_TEST
-#include "catch/snort_catch.h"
-#include "stream/libtcp/stream_tcp_unit_test.h"
-#endif
-
 using namespace snort;
 
 //-------------------------------------------------------------------------
@@ -288,7 +283,9 @@ const BaseApi* ips_stream_reassemble = &reassemble_api.base;
 
 #ifdef UNIT_TEST
 
+#include "catch/snort_catch.h"
 #include "framework/cursor.h"
+#include "test/stream_tcp_test_utils.h"
 
 // FIXIT-L these tests need some TLC
 TEST_CASE("IPS Stream Reassemble", "[ips_stream_reassemble][stream_tcp]")
index 847b33ec57dbf65f650399c01554a6d93daae91d..11d6c7c71a20fc89b7135e7f57c8dc5f2307c3eb 100644 (file)
@@ -27,7 +27,7 @@
 #include "tcp_ha.h"
 #include "tcp_module.h"
 #include "tcp_session.h"
-#include "tcp_stream_state_machine.h"
+#include "tcp_state_machine.h"
 
 using namespace snort;
 
@@ -110,10 +110,10 @@ static void tcp_dtor(Inspector* p)
 { delete p; }
 
 static void stream_tcp_pinit()
-{ TcpStreamStateMachine::initialize(); }
+{ TcpStateMachine::initialize(); }
 
 static void stream_tcp_pterm()
-{ TcpStreamStateMachine::finalize(); }
+{ TcpStateMachine::term(); }
 
 static Session* tcp_ssn(Flow* lws)
 { return new TcpSession(lws); }
index 81cd8ed951e59374b9b231d99b27d6bfcfc7ced1..3da3d0902ba373859bc43f6885511c19202cc59d 100644 (file)
 
 #include "tcp_normalizer.h"
 
-#include "stream/libtcp/tcp_stream_session.h"
-#include "stream/libtcp/tcp_stream_tracker.h"
-
 #include "packet_io/active.h"
 
+#include "tcp_stream_session.h"
+#include "tcp_stream_tracker.h"
+
+
 using namespace snort;
 
 THREAD_LOCAL PegCount tcp_norm_stats[PC_TCP_MAX][NORM_MODE_MAX];
index cf19465058df3ef8a4e0c9577a9819d6ab3ea887..da98480b4adacc71727777e1d9e7db0f632f0349 100644 (file)
@@ -26,9 +26,9 @@
 #include "tcp_normalizers.h"
 
 #include "tcp_module.h"
-#include "stream/libtcp/tcp_segment_descriptor.h"
-#include "stream/libtcp/tcp_stream_session.h"
-#include "stream/libtcp/tcp_stream_tracker.h"
+#include "tcp_segment_descriptor.h"
+#include "tcp_stream_session.h"
+#include "tcp_stream_tracker.h"
 
 using namespace snort;
 
index cfb0aba7aed159a96363c5ee2487722f66fd6c93..89033d66c8d3b29c1c3e6d067921f1e470695931 100644 (file)
@@ -24,7 +24,7 @@
 #endif
 
 #include "tcp_reassemblers.h"
-#include "stream/libtcp/tcp_stream_tracker.h"
+#include "tcp_stream_tracker.h"
 
 class TcpReassemblerFirst : public TcpReassembler
 {
index bb4b47337ec01686330121a3df22b4889fdf70f1..54d891bf82a07dcb71b89c06603c4771ee1b6715 100644 (file)
@@ -23,8 +23,9 @@
 #define TCP_SEGMENT_H
 
 #include "main/snort_debug.h"
-#include "stream/libtcp/tcp_segment_descriptor.h"
-#include "stream/tcp/tcp_defs.h"
+
+#include "tcp_segment_descriptor.h"
+#include "tcp_defs.h"
 
 class TcpSegmentDescriptor;
 
index 474dea2adb14a26a0bff3b7b87d91bd47fb4a1ec..fbf912b630f97cc639542a8a6c86a5f4c9c6ff60 100644 (file)
@@ -62,7 +62,7 @@
 #include "tcp_normalizers.h"
 #include "tcp_reassemblers.h"
 #include "tcp_segment_node.h"
-#include "tcp_stream_state_machine.h"
+#include "tcp_state_machine.h"
 
 using namespace snort;
 
@@ -75,7 +75,7 @@ void TcpSession::sterm()
 TcpSession::TcpSession(Flow* flow)
     : TcpStreamSession(flow)
 {
-    tsm = TcpStreamStateMachine::get_instance();
+    tsm = TcpStateMachine::get_instance();
     splitter_init = false;
 
     client.session = this;
index 56de3672c54edb6ff2b9786a89eb6d980e75f3d1..5023920826ecf579a36a75542127f2e57c104bd4 100644 (file)
@@ -20,9 +20,9 @@
 #ifndef TCP_SESSION_H
 #define TCP_SESSION_H
 
-#include "stream/libtcp/tcp_state_machine.h"
-#include "stream/libtcp/tcp_stream_session.h"
-#include "stream/libtcp/tcp_stream_tracker.h"
+#include "tcp_state_machine.h"
+#include "tcp_stream_session.h"
+#include "tcp_stream_tracker.h"
 
 namespace snort
 {
index 3cb7ab7bf4a23b57c76d1f83227f2894a237f259..3d64c66faffadee3feeb99f444ea824576be6cde 100644 (file)
@@ -22,7 +22,7 @@
 #ifndef TCP_STATE_CLOSE_WAIT_H
 #define TCP_STATE_CLOSE_WAIT_H
 
-#include "stream/libtcp/tcp_state_handler.h"
+#include "tcp_state_handler.h"
 
 class TcpStateCloseWait : public TcpStateHandler
 {
index 2018c09b037f0a32f04e4acd8699843e56864d79..549e0bf51777a4bacf715bae9588c0e04857d3f9 100644 (file)
@@ -22,7 +22,7 @@
 #ifndef TCP_STATE_CLOSED_H
 #define TCP_STATE_CLOSED_H
 
-#include "stream/libtcp/tcp_state_handler.h"
+#include "tcp_state_handler.h"
 
 class TcpStateClosed : public TcpStateHandler
 {
index 05e98017ca6abc9ce80c7b6f7ef9f20c6cb20521..371f1af3f85acfcb044036d9b6da06208453fa8e 100644 (file)
@@ -22,7 +22,7 @@
 #ifndef TCP_STATE_CLOSING_H
 #define TCP_STATE_CLOSING_H
 
-#include "stream/libtcp/tcp_state_handler.h"
+#include "tcp_state_handler.h"
 
 class TcpStateClosing : public TcpStateHandler
 {
index a2b8c393866d5157453e9e33859eb13d0e733830..39406b5d2b85ef10078341a82e594b8dfaa6f08f 100644 (file)
@@ -22,7 +22,7 @@
 #ifndef TCP_STATE_ESTABLISHED_H
 #define TCP_STATE_ESTABLISHED_H
 
-#include "stream/libtcp/tcp_state_handler.h"
+#include "tcp_state_handler.h"
 
 class TcpStateEstablished : public TcpStateHandler
 {
index 73a3bbd352bed5096dcc7aaaea1eedf826e0c503..9924766d376656353615bfe11c52e4f3681940cf 100644 (file)
@@ -22,7 +22,7 @@
 #ifndef TCP_STATE_FIN_WAIT1_H
 #define TCP_STATE_FIN_WAIT1_H
 
-#include "stream/libtcp/tcp_state_handler.h"
+#include "tcp_state_handler.h"
 
 class TcpStateFinWait1 : public TcpStateHandler
 {
index efa879c8c60ec7cd1fceb5ce7343942b174c2b84..ceaa293f38013397a6c06d14737be4ae4bac1548 100644 (file)
@@ -22,7 +22,7 @@
 #ifndef TCP_STATE_FIN_WAIT2_H
 #define TCP_STATE_FIN_WAIT2_H
 
-#include "stream/libtcp/tcp_state_handler.h"
+#include "tcp_state_handler.h"
 
 class TcpStateFinWait2 : public TcpStateHandler
 {
similarity index 99%
rename from src/stream/libtcp/tcp_state_handler.cc
rename to src/stream/tcp/tcp_state_handler.cc
index 3a2bc33003f002ed466fb86d24c02738171d7f46..db255c9906bd6a2e5eb794597315745f68f27361 100644 (file)
@@ -27,7 +27,6 @@
 
 #include <iostream>
 
-#include "tcp_segment_descriptor.h"
 #include "tcp_state_machine.h"
 
 #ifdef UNIT_TEST
similarity index 98%
rename from src/stream/libtcp/tcp_state_handler.h
rename to src/stream/tcp/tcp_state_handler.h
index 629b19eef43fbaf6cdfef6a9435efb37737acefe..906083e23bc01434fa51afcde6969f682c80bd4a 100644 (file)
@@ -23,7 +23,8 @@
 #define TCP_STATE_HANDLER_H
 
 #include "protocols/tcp.h"
-#include "stream/libtcp/tcp_stream_tracker.h"
+
+#include "tcp_stream_tracker.h"
 
 class TcpSegmentDescriptor;
 class TcpStateMachine;
index 4b5598b5d1e9cdfa89bb279eb2367ef077db5bce..be54a801e9bdf097821ea19b1391d0c160c4fd53 100644 (file)
@@ -22,7 +22,7 @@
 #ifndef TCP_STATE_LAST_ACK_H
 #define TCP_STATE_LAST_ACK_H
 
-#include "stream/libtcp/tcp_state_handler.h"
+#include "tcp_state_handler.h"
 
 class TcpStateLastAck : public TcpStateHandler
 {
index 21541d52eaccd64149272b00ed36a32125e7fafe..c1866670a03076ba8e4b56bed50ad0883402ab50 100644 (file)
@@ -22,7 +22,7 @@
 #ifndef TCP_STATE_LISTEN_H
 #define TCP_STATE_LISTEN_H
 
-#include "stream/libtcp/tcp_state_handler.h"
+#include "tcp_state_handler.h"
 
 class TcpStateListen : public TcpStateHandler
 {
similarity index 68%
rename from src/stream/libtcp/tcp_state_machine.cc
rename to src/stream/tcp/tcp_state_machine.cc
index 43943617f199426b55015a9910521f8f752f038a..a414a26bb357bd4da18c665ce63cf394da0ac241 100644 (file)
 
 #include "tcp_state_machine.h"
 
+#include "tcp_state_none.h"
+#include "tcp_state_closed.h"
+#include "tcp_state_listen.h"
+#include "tcp_state_syn_sent.h"
+#include "tcp_state_syn_recv.h"
+#include "tcp_state_established.h"
+#include "tcp_state_close_wait.h"
+#include "tcp_state_closing.h"
+#include "tcp_state_fin_wait1.h"
+#include "tcp_state_fin_wait2.h"
+#include "tcp_state_last_ack.h"
+#include "tcp_state_time_wait.h"
+
+TcpStateMachine* TcpStateMachine::tsm = nullptr;
+
+TcpStateMachine* TcpStateMachine::initialize()
+{
+    assert(!tsm);
+    TcpStateMachine::tsm = new TcpStateMachine();
+    return TcpStateMachine::tsm;
+}
+
+void TcpStateMachine::term()
+{
+    delete TcpStateMachine::tsm;
+    TcpStateMachine::tsm = nullptr;
+}
+
 TcpStateMachine::TcpStateMachine()
 {
     for ( auto s = TcpStreamTracker::TCP_LISTEN; s < TcpStreamTracker::TCP_MAX_STATES; s++ )
         tcp_state_handlers[ s ] = nullptr;
+
+    // initialize stream tracker state machine with handler for each state...
+    new TcpStateNone(*this);
+    new TcpStateClosed(*this);
+    new TcpStateListen(*this);
+    new TcpStateSynSent(*this);
+    new TcpStateSynRecv(*this);
+    new TcpStateEstablished(*this);
+    new TcpStateFinWait1(*this);
+    new TcpStateFinWait2(*this);
+    new TcpStateClosing(*this);
+    new TcpStateCloseWait(*this);
+    new TcpStateLastAck(*this);
+    new TcpStateTimeWait(*this);
 }
 
 TcpStateMachine::~TcpStateMachine()
similarity index 84%
rename from src/stream/libtcp/tcp_state_machine.h
rename to src/stream/tcp/tcp_state_machine.h
index d32ceb944adfc14b335b28ac52892d70acf5f4ff..9181c9dd12324b313e4f1185dec77690542604ad 100644 (file)
 #ifndef TCP_STATE_MACHINE_H
 #define TCP_STATE_MACHINE_H
 
-#include "stream/libtcp/tcp_state_handler.h"
-#include "stream/libtcp/tcp_stream_tracker.h"
-#include "stream/libtcp/tcp_segment_descriptor.h"
+#include "tcp_segment_descriptor.h"
+#include "tcp_state_handler.h"
+#include "tcp_stream_tracker.h"
 
 class TcpStateMachine
 {
 public:
     virtual ~TcpStateMachine();
 
+    static TcpStateMachine* initialize();
+    static void term();
+
+    static TcpStateMachine* get_instance()
+    { return TcpStateMachine::tsm; }
+
     virtual void register_state_handler(TcpStreamTracker::TcpState, TcpStateHandler&);
     virtual bool eval(TcpSegmentDescriptor&, TcpStreamTracker&, TcpStreamTracker&);
 
 protected:
     TcpStateMachine();
+    static TcpStateMachine* tsm;
 
     TcpStateHandler* tcp_state_handlers[ TcpStreamTracker::TCP_MAX_STATES ];
 };
index e487d913b209e13aa959ec052f7aae282e2a6e23..7f4f83a26877a293175334fc2326513ce5f39105 100644 (file)
@@ -22,7 +22,7 @@
 #ifndef TCP_STATE_NONE_H
 #define TCP_STATE_NONE_H
 
-#include "stream/libtcp/tcp_state_handler.h"
+#include "tcp_state_handler.h"
 
 class TcpStateNone : public TcpStateHandler
 {
index bf3d2423fa864a126572edbca623c675692f88e1..e94c81427685a514cbf754ee534da2d7b6267c70 100644 (file)
@@ -22,7 +22,7 @@
 #ifndef TCP_STATE_SYN_RECV_H
 #define TCP_STATE_SYN_RECV_H
 
-#include "stream/libtcp/tcp_state_handler.h"
+#include "tcp_state_handler.h"
 
 class TcpStateSynRecv : public TcpStateHandler
 {
index b4cc79754d86e91812b0ab8e763fea017c54af1e..f304ff3d4a103ad0b4f6562c3e6a5a4d038727b8 100644 (file)
@@ -22,7 +22,7 @@
 #ifndef TCP_STATE_SYN_SENT_H
 #define TCP_STATE_SYN_SENT_H
 
-#include "stream/libtcp/tcp_state_handler.h"
+#include "tcp_state_handler.h"
 
 class TcpStateSynSent : public TcpStateHandler
 {
index 42dc1168e15c4602a64bb37f4fff9641fbd39ec4..66e67470c3e5949a70b662e89fbc53edddb4ff3f 100644 (file)
@@ -22,7 +22,7 @@
 #ifndef TCP_STATE_TIME_WAIT_H
 #define TCP_STATE_TIME_WAIT_H
 
-#include "stream/libtcp/tcp_state_handler.h"
+#include "tcp_state_handler.h"
 
 class TcpStateTimeWait : public TcpStateHandler
 {
similarity index 98%
rename from src/stream/libtcp/tcp_stream_session.h
rename to src/stream/tcp/tcp_stream_session.h
index 78994af4ca3174b76331ed5dd779754c2d41b241..3c79fc787c1969e9b36006c21e0054e5dc438b14 100644 (file)
@@ -26,8 +26,8 @@
 #include "flow/session.h"
 #include "protocols/ipv6.h"
 
-#include "stream/libtcp/tcp_stream_tracker.h"
-#include "stream/tcp/tcp_stream_config.h"
+#include "tcp_stream_config.h"
+#include "tcp_stream_tracker.h"
 
 #ifdef DEBUG_MSGS
 extern const char* const flush_policy_names[];
diff --git a/src/stream/tcp/tcp_stream_state_machine.cc b/src/stream/tcp/tcp_stream_state_machine.cc
deleted file mode 100644 (file)
index cd87ba0..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-//--------------------------------------------------------------------------
-// Copyright (C) 2015-2019 Cisco and/or its affiliates. All rights reserved.
-//
-// This program is free software; you can redistribute it and/or modify it
-// under the terms of the GNU General Public License Version 2 as published
-// by the Free Software Foundation.  You may not use, modify or distribute
-// this program under any other version of the GNU General Public License.
-//
-// This program is distributed in the hope that it will be useful, but
-// WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-// General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License along
-// with this program; if not, write to the Free Software Foundation, Inc.,
-// 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
-//--------------------------------------------------------------------------
-
-// tcp_stream_state_machine.cc author davis mcpherson <davmcphe@cisco.com>
-// Created on: Apr 1, 2016
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "tcp_stream_state_machine.h"
-
-#include "tcp_state_none.h"
-#include "tcp_state_closed.h"
-#include "tcp_state_listen.h"
-#include "tcp_state_syn_sent.h"
-#include "tcp_state_syn_recv.h"
-#include "tcp_state_established.h"
-#include "tcp_state_close_wait.h"
-#include "tcp_state_closing.h"
-#include "tcp_state_fin_wait1.h"
-#include "tcp_state_fin_wait2.h"
-#include "tcp_state_last_ack.h"
-#include "tcp_state_time_wait.h"
-
-TcpStreamStateMachine* TcpStreamStateMachine::tsm = nullptr;
-
-TcpStateMachine* TcpStreamStateMachine::initialize()
-{
-    assert(!tsm);
-    TcpStreamStateMachine::tsm = new TcpStreamStateMachine();
-    return TcpStreamStateMachine::tsm;
-}
-
-void TcpStreamStateMachine::finalize()
-{
-    delete TcpStreamStateMachine::tsm;
-    TcpStreamStateMachine::tsm = nullptr;
-}
-
-TcpStreamStateMachine::TcpStreamStateMachine()
-{
-    // initialize stream tracker state machine with handler for each state...
-    new TcpStateNone(*this);
-    new TcpStateClosed(*this);
-    new TcpStateListen(*this);
-    new TcpStateSynSent(*this);
-    new TcpStateSynRecv(*this);
-    new TcpStateEstablished(*this);
-    new TcpStateFinWait1(*this);
-    new TcpStateFinWait2(*this);
-    new TcpStateClosing(*this);
-    new TcpStateCloseWait(*this);
-    new TcpStateLastAck(*this);
-    new TcpStateTimeWait(*this);
-}
diff --git a/src/stream/tcp/tcp_stream_state_machine.h b/src/stream/tcp/tcp_stream_state_machine.h
deleted file mode 100644 (file)
index 40dacb8..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-//--------------------------------------------------------------------------
-// Copyright (C) 2015-2019 Cisco and/or its affiliates. All rights reserved.
-//
-// This program is free software; you can redistribute it and/or modify it
-// under the terms of the GNU General Public License Version 2 as published
-// by the Free Software Foundation.  You may not use, modify or distribute
-// this program under any other version of the GNU General Public License.
-//
-// This program is distributed in the hope that it will be useful, but
-// WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-// General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License along
-// with this program; if not, write to the Free Software Foundation, Inc.,
-// 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
-//--------------------------------------------------------------------------
-
-// tcp_stream_state_machine.h author davis mcpherson <davmcphe@cisco.com>
-// Created on: Apr 1, 2016
-
-#ifndef TCP_STREAM_STATE_MACHINE_H
-#define TCP_STREAM_STATE_MACHINE_H
-
-#include "stream/libtcp/tcp_state_machine.h"
-
-class TcpStreamStateMachine: public TcpStateMachine
-{
-public:
-    static TcpStateMachine* initialize();
-    static void finalize();
-
-    static TcpStateMachine* get_instance()
-    { return TcpStreamStateMachine::tsm; }
-
-private:
-    TcpStreamStateMachine();
-
-    static TcpStreamStateMachine* tsm;
-
-};
-#endif
-
similarity index 98%
rename from src/stream/libtcp/tcp_stream_tracker.h
rename to src/stream/tcp/tcp_stream_tracker.h
index fd26b684666f661eb05c202828fc3d29fa15e8eb..fb0f526d77793de482b37ff54668f8c7aca82bc0 100644 (file)
 #include <daq_common.h>
 
 #include "stream/paf.h"
-#include "stream/tcp/segment_overlap_editor.h"
-#include "stream/tcp/tcp_defs.h"
-#include "stream/tcp/tcp_normalizers.h"
-#include "stream/tcp/tcp_reassemblers.h"
-#include "stream/libtcp/tcp_segment_descriptor.h"
+#include "segment_overlap_editor.h"
+#include "tcp_defs.h"
+#include "tcp_normalizers.h"
+#include "tcp_reassemblers.h"
+#include "tcp_segment_descriptor.h"
 
 /* Only track a maximum number of alerts per session */
 #define MAX_SESSION_ALERTS 8
similarity index 95%
rename from src/stream/libtcp/stream_tcp_unit_test.cc
rename to src/stream/tcp/test/stream_tcp_test_utils.cc
index 9772dd815493cfb7460631cb2bac415ba1f8d2d3..9ebb0fd97c8898151e1ecb367fe2cb5565bc0c3d 100644 (file)
 // 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 //--------------------------------------------------------------------------
 
-// stream_libtcp_unit_test.h author davis mcpherson <davmcphe@@cisco.com>
+// stream_tcp_test_utils.cc author davis mcpherson <davmcphe@cisco.com>
 // Created on: Jul 30, 2015
 
-#include "stream_tcp_unit_test.h"
-
-#ifndef STREAM_LIBTCP_UNIT_TEST
-#define STREAM_LIBTCP_UNIT_TEST
-
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
-#include "stream_tcp_unit_test.h"
+#include "stream_tcp_test_utils.h"
 
 #include "detection/ips_context.h"
 #include "protocols/packet.h"
 #include "protocols/tcp.h"
-#include "stream/tcp/tcp_session.h"
+
+#include "../tcp_session.h"
 
 using namespace snort;
 
@@ -164,5 +160,3 @@ Packet* get_data_packet(Flow* flow)
     return pkt;
 }
 
-#endif
-
similarity index 90%
rename from src/stream/libtcp/stream_tcp_unit_test.h
rename to src/stream/tcp/test/stream_tcp_test_utils.h
index ff67dedca0df8b1e8125613691f6c5ef4f5e9c34..b381f24aecb63fd557026770081b04c0e521be63 100644 (file)
 // 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 //--------------------------------------------------------------------------
 
-// stream_libtcp_unit_test.h author davis mcpherson <davmcphe@@cisco.com>
+// stream_tcp_test_utils.h author davis mcpherson <davmcphe@cisco.com>
 // Created on: Jul 30, 2015
 
-#ifndef STREAM_LIBTCP_UNIT_TEST_H
-#define STREAM_LIBTCP_UNIT_TEST_H
+#ifndef STREAM_TCP_TEST_UTILS_H
+#define STREAM_TCP_TEST_UTILS_H
 
 namespace snort
 {