]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Merge pull request #1774 in SNORT/snort3 from ~THOPETER/snort3:small_seg3 to master
authorMike Stepanek (mstepane) <mstepane@cisco.com>
Tue, 1 Oct 2019 14:56:05 +0000 (10:56 -0400)
committerMike Stepanek (mstepane) <mstepane@cisco.com>
Tue, 1 Oct 2019 14:56:05 +0000 (10:56 -0400)
Squashed commit of the following:

commit 48284a400a9d8f852f529a5439ab7bf4178756bb
Author: Tom Peters <thopeter@cisco.com>
Date:   Fri Sep 27 15:26:18 2019 -0400

    stream: clean up update_direction

src/flow/session.h
src/flow/test/session_test.cc
src/stream/icmp/icmp_session.cc
src/stream/icmp/icmp_session.h
src/stream/libtcp/tcp_stream_session.cc
src/stream/libtcp/tcp_stream_session.h
src/stream/stream.cc
src/stream/stream.h
src/stream/user/user_session.cc
src/stream/user/user_session.h

index 25979ebf013d7588dc28c026083917f319c3c079..c7fbec0ebe1e96919bda9afdf663cd26a1a3c0f7 100644 (file)
@@ -40,7 +40,11 @@ public:
     virtual ~Session() = default;
 
     virtual bool setup(snort::Packet*) { return true; }
-    virtual void update_direction(char /*dir*/, const snort::SfIp*, uint16_t /*port*/) { }
+    virtual void update_direction(char /*dir*/, const snort::SfIp*, uint16_t /*port*/)
+    {
+        // UDP is currently the only stream that implements this. Others should not be calling.
+        assert(false);
+    }
     virtual int process(snort::Packet*) { return 0; }
 
     virtual void restart(snort::Packet*) { }
index 9020101f48897b0ebe935ee7ee46751baff27c47..24830e0b8b287bf3e33daa37f1a733d6ec9e32fd 100644 (file)
@@ -51,7 +51,6 @@ TEST(session_test, seesion_class_test)
     Session *ssn = new DummySession(nullptr);
     CHECK(true == ssn->setup(nullptr));
 
-    ssn->update_direction(1, nullptr, 1234);
     CHECK(0 == ssn->process(nullptr));
     ssn->restart(nullptr);
     ssn->flush_client(nullptr);
index 3c4d6b642eeaab2503c85b5fe0554beb705cc390..48d3d5a86aacd793c3d07cfb5ef0f39f22a7915f 100644 (file)
@@ -230,31 +230,3 @@ int IcmpSession::process(Packet* p)
     return status;
 }
 
-#define icmp_sender_ip flow->client_ip
-#define icmp_responder_ip flow->server_ip
-
-void IcmpSession::update_direction(char dir, const SfIp* ip, uint16_t)
-{
-    if (icmp_sender_ip.equals(*ip))
-    {
-        if ((dir == SSN_DIR_FROM_CLIENT) && (flow->ssn_state.direction == FROM_CLIENT))
-        {
-            /* Direction already set as SENDER */
-            return;
-        }
-    }
-    else if (icmp_responder_ip.equals(*ip))
-    {
-        if ((dir == SSN_DIR_FROM_SERVER) && (flow->ssn_state.direction == FROM_SERVER))
-        {
-            /* Direction already set as RESPONDER */
-            return;
-        }
-    }
-
-    /* Swap them -- leave ssn->ssn_state.direction the same */
-    SfIp tmpIp = icmp_sender_ip;
-    icmp_sender_ip = icmp_responder_ip;
-    icmp_responder_ip = tmpIp;
-}
-
index e0d35612fa3ceb61b7c29ee9e11e232423e04391..33b4969332e986ae7b7861975e87ced6fb9e936b 100644 (file)
@@ -29,7 +29,6 @@ public:
     ~IcmpSession() override;
 
     bool setup(snort::Packet*) override;
-    void update_direction(char dir, const snort::SfIp*, uint16_t port) override;
     int process(snort::Packet*) override;
     void clear() override;
 
index f6619bf952520396333cc152df39eabff11e6811..843b8ee9ab656df57aeb5963e74ad0e926db2b08 100644 (file)
@@ -213,42 +213,6 @@ bool TcpStreamSession::are_packets_missing(uint8_t dir)
     return false;
 }
 
-void TcpStreamSession::update_direction(char dir, const SfIp* ip, uint16_t port)
-{
-    SfIp tmpIp;
-    uint16_t tmpPort;
-
-    if (flow->client_ip.equals(*ip) && (flow->client_port == port))
-    {
-        if ((dir == SSN_DIR_FROM_CLIENT) && (flow->ssn_state.direction == FROM_CLIENT))
-        {
-            /* Direction already set as client */
-            return;
-        }
-    }
-    else if (flow->server_ip.equals(*ip) && (flow->server_port == port))
-    {
-        if ((dir == SSN_DIR_FROM_SERVER) && (flow->ssn_state.direction == FROM_SERVER))
-        {
-            /* Direction already set as server */
-            return;
-        }
-    }
-
-    /* Swap them -- leave flow->ssn_state.direction the same */
-    tmpIp = flow->client_ip;
-    tmpPort = flow->client_port;
-    flow->client_ip = flow->server_ip;
-    flow->client_port = flow->server_port;
-    flow->server_ip = tmpIp;
-    flow->server_port = tmpPort;
-
-    SwapPacketHeaderFoo( );
-    TcpStreamTracker tracker = client;
-    client = server;
-    server = tracker;
-}
-
 // FIXIT-H add alert and check alerted go away when we finish
 // packet / PDU split because PDU rules won't run on raw packets
 bool TcpStreamSession::add_alert(Packet* p, uint32_t gid, uint32_t sid)
index d09ae2be0b064b3eb9a65e0a09e9a61d8d602945..78994af4ca3174b76331ed5dd779754c2d41b241 100644 (file)
@@ -50,7 +50,6 @@ public:
     bool are_packets_missing(uint8_t /*dir*/) override;
     uint8_t get_reassembly_direction() override;
     uint8_t missing_in_reassembled(uint8_t /*dir*/) override;
-    void update_direction(char dir, const snort::SfIp*, uint16_t port) override;
     bool add_alert(snort::Packet*, uint32_t gid, uint32_t sid) override;
     bool check_alerted(snort::Packet*, uint32_t gid, uint32_t sid) override;
     int update_alert(snort::Packet*, uint32_t /*gid*/, uint32_t /*sid*/,
index 13d9f0d025cd1cdb41bcd814532d871a05e124ee..3c051a65d51630621db487844912702b83e519b3 100644 (file)
@@ -268,15 +268,6 @@ void Stream::resume_inspection(Flow* flow, char dir)
     }
 }
 
-void Stream::update_direction(
-    Flow* flow, char dir, const SfIp* ip, uint16_t port)
-{
-    if (!flow)
-        return;
-
-    flow->session->update_direction(dir, ip, port);
-}
-
 uint32_t Stream::get_packet_direction(Packet* p)
 {
     if (!p || !(p->flow))
index fa03fe2365561799a8e6ba4486af5ca95e1d961d..ee68fd387a6d77c370f43f06e7f896a1c5512594 100644 (file)
@@ -204,8 +204,6 @@ public:
     //  Populate a session key from the Packet
     static void populate_flow_key(Packet*, FlowKey*);
 
-    static void update_direction(Flow*, char dir, const snort::SfIp* ip, uint16_t port);
-
     static void set_snort_protocol_id(
         Flow*, const HostAttributeEntry*, int direction);
 
index 8fc38a1f91c397621cd29875034b8877bc06cba4..96e432a0a0023cd281f5a90e876dd3d4921779dc 100644 (file)
@@ -516,8 +516,6 @@ int UserSession::process(Packet* p)
 // some will be deleted, some refactored, some implemented
 //-------------------------------------------------------------------------
 
-void UserSession::update_direction(char /*dir*/, const SfIp*, uint16_t /*port*/) { }
-
 bool UserSession::add_alert(Packet*, uint32_t /*gid*/, uint32_t /*sid*/) { return true; }
 bool UserSession::check_alerted(Packet*, uint32_t /*gid*/, uint32_t /*sid*/) { return false; }
 
index 2f263f255a7b480ca4bad4f2ae6c58fd9cec8930..c276234157dbc3ac0107864883e4a621da3648d7 100644 (file)
@@ -101,8 +101,6 @@ private:
     void update(snort::Packet*, snort::Flow*);
     void end(snort::Packet*, snort::Flow*);
 
-    void update_direction(char dir, const snort::SfIp*, uint16_t port) override;
-
     bool add_alert(snort::Packet*, uint32_t gid, uint32_t sid) override;
     bool check_alerted(snort::Packet*, uint32_t gid, uint32_t sid) override;