]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
refactor for start of binder
authorRuss Combs <rucombs@cisco.com>
Mon, 19 May 2014 16:49:38 +0000 (12:49 -0400)
committerRuss Combs <rucombs@cisco.com>
Mon, 19 May 2014 16:49:38 +0000 (12:49 -0400)
28 files changed:
ChangeLog
configure.ac
src/codecs/codec_events.cc
src/codecs/codec_events.h
src/codecs/decode.cc
src/codecs/encode.cc
src/detection/fpcreate.cc
src/flow/flow.h
src/flow/flow_control.cc
src/flow/flow_control.h
src/main/binder.cc
src/main/binder.h
src/main/policy.cc
src/main/policy.h
src/main/snort.cc
src/main/snort.h
src/main/snort_config.cc
src/managers/inspector_manager.cc
src/managers/inspector_manager.h
src/managers/mpse_manager.cc
src/network_inspectors/normalize/normalize.cc
src/network_inspectors/normalize/normalize.h
src/network_inspectors/port_scan/port_scan.cc
src/parser/parser.cc
src/stream/base/stream_base.cc
src/stream/stream_api.cc
src/stream/stream_api.h
src/stream/tcp/tcp_session.cc

index 152dfecdb296cb61e629f0cd783d808b6a6c729d..753ce49038bd598abf48495cecebf6e50d789bd6 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+80
+-- deleted port monitor foo; will be obviated by binder
+-- removed ttl norm checks from codecs; made no sense; drop iff rule is drop
+-- moved stream_* bindings to binder
+
 79
 -- pulled in latest codecs
 
index cc14aad5cea890505b04bba94e39287eaea9f024..4b8208b6d05ac8cb82f10b58e914588860b55582 100644 (file)
@@ -25,7 +25,7 @@
 # initialization
 #--------------------------------------------------------------------------
 
-AC_INIT([snort], [2.10.079])
+AC_INIT([snort], [2.10.080])
 AC_PREREQ([2.68])
 
 AC_CONFIG_SRCDIR([src/main.h])
index f4f8aa75d570aa4916f0918a1a048e7cba14de28..9d395b24e24a379929ede25d0ec2ee90e669cc8d 100644 (file)
@@ -85,15 +85,6 @@ void codec_events::exec_hop_drop (Packet* p, int sid)
         ErrorMessage("%d:%d\n", GID_DECODE, sid);
 
     SnortEventqAdd(GID_DECODE, sid);
-
-    if ( ScNormalDrop(NORM_IP6_TTL) )
-    {
-        DEBUG_WRAP(DebugMessage(DEBUG_DECODE,
-           "Dropping bad packet (IP6 hop limit)\n"););
-        p->error_flags |= PKT_ERR_BAD_TTL;
-        Active_DropPacket();
-//        dc.bad_ttl++;
-    }
 }
 
 void codec_events::exec_ttl_drop (Packet *p, int sid)
@@ -105,15 +96,6 @@ void codec_events::exec_ttl_drop (Packet *p, int sid)
         ErrorMessage("%d:%d\n", GID_DECODE, sid);
 
     SnortEventqAdd(GID_DECODE, sid);
-
-    if ( ScNormalDrop(NORM_IP4_TTL) )
-    {
-        DEBUG_WRAP(DebugMessage(DEBUG_DECODE,
-           "Dropping bad packet (IP4 TTL)\n"););
-        p->error_flags |= PKT_ERR_BAD_TTL;
-        Active_DropPacket();
-//        dc.bad_ttl++;
-    }
 }
 
 void codec_events::exec_icmp_chksm_drop (Packet*)
@@ -137,9 +119,3 @@ void codec_events::decoder_alert_encapsulated(
     p->greh = NULL;
 }
 
-int codec_events::ScNormalDrop (NormFlags nf)
-{
-    return !Normalize_IsEnabled(snort_conf, nf);
-}
-
-
index b9c5a6fe96c380ba3042b14cdce7071d21e56777..1e4158535e00613a4460a28d12903ed96b75e6ea 100644 (file)
@@ -45,8 +45,6 @@ namespace codec_events
     void decoder_alert_encapsulated(
         Packet *p, int sid, const uint8_t *pkt, uint32_t len);
 
-    int ScNormalDrop (NormFlags nf);
-
 } //namespace codec_events
 
 
index 307934d0e10268c8f0f9afafa51c2619d04d77e5..5e4ac4d7547f21d63e7171beb6c9a5c282e523af 100644 (file)
@@ -91,11 +91,8 @@ uint32_t EXTRACT_32BITS (u_char *p)
 }
 #endif /* WORDS_MUSTALIGN && !__GNUC__ */
 
-
-
 static inline void CheckIPv4_MinTTL(Packet *p, uint8_t ttl)
 {
-
     // this sequence of tests is best for the "normal" case where
     // the packet ttl is >= the configured min (the default is 1)
     if( ttl < ScMinTTL() )
@@ -111,8 +108,6 @@ static inline void CheckIPv4_MinTTL(Packet *p, uint8_t ttl)
     }
 }
 
-
-
 static inline void CheckIPv6_MinTTL(Packet *p, uint8_t hop_limit)
 {
     // this sequence of tests is best for the "normal" case where
@@ -130,8 +125,6 @@ static inline void CheckIPv6_MinTTL(Packet *p, uint8_t hop_limit)
     }
 }
 
-
-
 /* Decoding of ttl/hop_limit is based on the policy min_ttl */
 void DecodePolicySpecific(Packet *p)
 {
index a6ee6e4c5d7f55fc87609f46fc66f90297b7f2d7..8bd55b1f4b2ced2cc09b3860f2a9e8865ab3c268 100644 (file)
@@ -41,6 +41,7 @@
 #include "packet_io/sfdaq.h"
 #include "sf_iph.h"
 #include "snort.h"
+#include "stream/stream.h"
 #include "stream/stream_api.h"
 #include "encode.h"
 #include "sf_protocols.h"
@@ -50,8 +51,6 @@
 #include "protocols/eth.h"
 #include "protocols/gtp.h"
 #include "codecs/checksum.h"
-
 
 #define GET_IP_HDR_LEN(h) (((h)->ip_verhl & 0x0f) << 2)
 #define GET_TCP_HDR_LEN(h) (((h)->th_offx2 & 0xf0) >> 2)
index 03787c6eb1a399a2d50efb6859102da6e5091c0e..e087b23b6dc3cb289897ae3d7a155a3853bf18d2 100644 (file)
@@ -766,7 +766,6 @@ void fpSetDetectSearchOpt(FastPatternConfig *fp, int flag)
     fp->search_opt = flag;
 }
 
-// config detect: search-method <method>
 int fpSetDetectSearchMethod(FastPatternConfig* fp, const char* method)
 {
     fp->search_api = MpseManager::get_search_api(method);
index 08996ace1a51360176fb89dd4e7e508df84ba80a..99cfb7238f34e062af1a86e3cf298c6839254fdd 100644 (file)
@@ -33,6 +33,7 @@
 #include "sfip/ipv6_port.h"
 #include "flow/flow_key.h"
 #include "framework/inspector.h"
+#include "normalize/normalize.h"
 
 #define SSNFLAG_SEEN_CLIENT         0x00000001
 #define SSNFLAG_SEEN_SENDER         0x00000001
@@ -150,6 +151,12 @@ public:
     void markup_packet_flags(Packet*);
     void set_direction(Packet*);
 
+    void set_normalizations(uint32_t m)
+    { normal_mask = m; };
+
+    bool norm_is_enabled(uint32_t b)
+    { return Normalize_IsEnabled(normal_mask, (NormFlags)b); };
+
     void set_expire(Packet*, uint32_t timeout);
     int get_expire(Packet*);
     bool expired(Packet*);
@@ -182,6 +189,7 @@ public:  // FIXIT privatize if possible
     snort_ip server_ip; // or uint8_t to reduce sizeof from 24 to 20
 
     uint64_t expire_time;
+    uint32_t normal_mask;
 
     uint16_t client_port;
     uint16_t server_port;
index 4ce2d4d81abe73f07bb1bb339647c9615d9c5cfc..89c8ca35b1712d648828df2a16521c03c11e3410 100644 (file)
@@ -32,6 +32,7 @@
 #include "flow/session.h"
 #include "packet_io/active.h"
 #include "packet_io/sfdaq.h"
+#include "main/binder.h"
 
 FlowControl::FlowControl()
 {
@@ -223,7 +224,7 @@ static bool is_bidirectional(Flow* flow)
     return (flow->s5_state.session_flags & bidir) == bidir;
 }
 
-void FlowControl::process(FlowCache* cache, Inspector* ins, Packet* p)
+void FlowControl::process(FlowCache* cache, Packet* p)
 {
     FlowKey key;
     set_key(&key, p);
@@ -235,25 +236,7 @@ void FlowControl::process(FlowCache* cache, Inspector* ins, Packet* p)
 
     if ( flow->init )
     {
-#if 0
-        // FIXIT BIND this is where bindings are used to set
-        // inspectors on session:
-        if ( bindings )
-        {
-            // -- must set client and server session inspectors
-            // -- must set all bound service inspectors 
-            //    (service inspectors also set later by auto id)
-        }
-        else
-#endif
-        {
-            // default case
-            flow->client = ins;
-            flow->server = ins;
-        }
-        // -- all inspectors must be ref counted when set
-        flow->client->add_ref();
-        flow->server->add_ref();
+        Binder::init_flow(flow);
 
         if ( !flow->session->setup(p) )
             return;
@@ -292,12 +275,12 @@ void FlowControl::init_tcp(
     }
 }
 
-void FlowControl::process_tcp(Inspector* user, Packet* p)
+void FlowControl::process_tcp(Packet* p)
 {
     if( !p->tcph || !tcp_cache )
         return;
 
-    process(tcp_cache, user, p);
+    process(tcp_cache, p);
 }
 
 //-------------------------------------------------------------------------
@@ -324,12 +307,12 @@ void FlowControl::init_udp(
     }
 }
 
-void FlowControl::process_udp(Inspector* user, Packet* p)
+void FlowControl::process_udp(Packet* p)
 {
     if( !p->udph || !udp_cache )
         return;
 
-    process(udp_cache, user, p);
+    process(udp_cache, p);
 }
 
 //-------------------------------------------------------------------------
@@ -356,16 +339,16 @@ void FlowControl::init_icmp(
     }
 }
 
-void FlowControl::process_icmp(Inspector* user, Packet* p)
+void FlowControl::process_icmp(Packet* p)
 {
     if ( !p->icmph )
         return;
 
     if ( icmp_cache )
-        process(icmp_cache, user, p);
+        process(icmp_cache, p);
 
     else
-        process_ip(user, p);
+        process_ip(p);
 }
 
 //-------------------------------------------------------------------------
@@ -392,12 +375,12 @@ void FlowControl::init_ip(
     }
 }
 
-void FlowControl::process_ip(Inspector* user, Packet* p)
+void FlowControl::process_ip(Packet* p)
 {
     if ( !p->iph || !ip_cache )
         return;
 
-    process(ip_cache, user, p);
+    process(ip_cache, p);
 }
 
 //-------------------------------------------------------------------------
index 23a8d87f1d2f50871983ead99d936ed754d573b7..7f64b3cfbe8216eaf07817c9d92dd9578e8b8580 100644 (file)
@@ -41,11 +41,10 @@ public:
     ~FlowControl();
 
 public:
-    // FIXIT BIND supply default inspectors until bindings are in place
-    void process_ip(Inspector*, Packet*);
-    void process_icmp(Inspector*, Packet*);
-    void process_tcp(Inspector*, Packet*);
-    void process_udp(Inspector*, Packet*);
+    void process_ip(Packet*);
+    void process_icmp(Packet*);
+    void process_tcp(Packet*);
+    void process_udp(Packet*);
 
     Flow* find_flow(const FlowKey*);
     Flow* new_flow(const FlowKey*);
@@ -85,7 +84,7 @@ private:
     class FlowCache* get_cache(int proto);
     void set_key(FlowKey*, const Packet*);
 
-    void process(FlowCache*, Inspector*, Packet*);
+    void process(FlowCache*, Packet*);
 
 private:
     FlowCache* tcp_cache;
index 81806aea1ac86a8f9a78801eb29497c6e7e35e69..8aaa0146a4d232904863ff0f350f4de8e17accc3 100644 (file)
 
 #include "binder.h"
 
+#include "flow/flow.h"
+#include "managers/inspector_manager.h"
+
+class Inspector;
+
+// FIXIT these will move into bindings lookup structures
+// these are for defaults but lookups will support default
+// and non-defaults
+static Inspector* tcp_hand;
+static Inspector* udp_hand;
+static Inspector* icmp_hand;
+static Inspector* ip_hand;
+
+void Binder::init()
+{
+    // FIXIT this is backwards; InspectorManager must call
+    // binder to set the various default inspectors since
+    // binder doesn't know what inspectors are available
+    tcp_hand = InspectorManager::get_inspector("stream_tcp");
+    udp_hand = InspectorManager::get_inspector("stream_udp");
+    ip_hand = InspectorManager::get_inspector("stream_ip");
+    icmp_hand = InspectorManager::get_inspector("stream_icmp");
+
+    if ( !icmp_hand )
+        icmp_hand = ip_hand;
+
+    assert(tcp_hand);
+    assert(udp_hand);
+    assert(ip_hand);
+    assert(icmp_hand);
+}
+
+void Binder::init_flow(Flow* flow)
+{
+    switch ( flow->protocol )
+    {
+    case IPPROTO_TCP:
+        flow->client = tcp_hand;
+        flow->server = tcp_hand;
+        break;
+
+    case IPPROTO_UDP:
+        flow->client = udp_hand;
+        flow->server = udp_hand;
+        break;
+
+    case IPPROTO_ICMP:
+        flow->client = icmp_hand;
+        flow->server = icmp_hand;
+        break;
+
+    case IPPROTO_IP:
+        flow->client = ip_hand;
+        flow->server = ip_hand;
+        break;
+    }
+    if ( flow->client )
+        flow->client->add_ref();
+
+    if ( flow->server )
+        flow->server->add_ref();
+}
+
index 3fe13b466d787423173e3a51a1a10b14f29de0c5..2d96fac238369fe618d0f4f7d63f86c74463e6bd 100644 (file)
@@ -70,5 +70,12 @@ struct Binding
     { role = BR_EITHER; action = BA_INSPECT; };
 };
 
+class Binder
+{
+public:
+    static void init();
+    static void init_flow(class Flow*);
+};
+
 #endif
 
index 5e7da0964cc3ec6fe41c87bc14b172984e226afd..11b79726d2d7285f244e7b409b6bb042222aec38 100644 (file)
@@ -56,8 +56,6 @@ NetworkPolicy::~NetworkPolicy()
 InspectionPolicy::InspectionPolicy()
 {
     framework_policy = nullptr;
-    normal_mask = 0;
-    scanned_proto_mask = 0;
 
     InspectorManager::new_policy(this);
 }
index d340874c2b5883e06e460d5ca401b30203940695..bbaff1809cc0da7da8784a3e2eb3ee4935d3dd6f 100644 (file)
@@ -85,9 +85,6 @@ public:
 
 public:
     struct FrameworkPolicy* framework_policy;
-
-    uint32_t normal_mask;
-    int scanned_proto_mask;
 };
 
 //-------------------------------------------------------------------------
index 9c0142c23e6fbf7e01831737e9fd8021d57441f1..6db9e38420b52cdbd50208efcc1173579a06250c 100644 (file)
@@ -100,6 +100,7 @@ using namespace std;
 #include "file_api/file_service.h"
 #include "flow/flow_control.h"
 #include "main/analyzer.h"
+#include "main/binder.h"
 #include "log/sf_textlog.h"
 #include "log/log_text.h"
 #include "time/periodic.h"
@@ -120,8 +121,8 @@ using namespace std;
 
 //-------------------------------------------------------------------------
 
-THREAD_LOCAL SnortConfig* snort_conf = NULL;
-static SnortConfig* snort_cmd_line_conf = NULL;
+THREAD_LOCAL SnortConfig* snort_conf = nullptr;
+static SnortConfig* snort_cmd_line_conf = nullptr;
 
 static bool snort_initializing = true;
 static int snort_exiting = 0;
@@ -403,6 +404,7 @@ static void SnortInit(int argc, char **argv)
 
     /* Need to do this after dynamic detection stuff is initialized, too */
     IpsManager::verify();
+    Binder::init();
 
     if (snort_conf->file_mask != 0)
         umask(snort_conf->file_mask);
index 4f65529dd5fd94d85730b7d975c23b8015124032..5e8373fa7be5c0d625c5d7eb2c619e6dc8f72cd5 100644 (file)
@@ -212,18 +212,6 @@ static inline int ScLogQuiet(void)
     return snort_conf->logging_flags & LOGGING_FLAG__QUIET;
 }
 
-//-------------------------------------------------------------------------
-// FIXIT should be calling InspectionPolicy methods
-static inline void ScSetScannedProtocols(SnortConfig* sc, int mask)
-{
-    sc->get_inspection_policy()->scanned_proto_mask = mask;
-}
-
-static inline int ScGetScannedProtocols(SnortConfig* sc)
-{
-    return sc->get_inspection_policy()->scanned_proto_mask;
-}
-
 //-------------------------------------------------------------------------
 // FIXIT should be calling NetworkPolicy methods
 
index 808f9e9bb2dff6023abac8235540c6040ffbf3e4..5629d78204c7b439d52a713d816fe88a56e105ea 100644 (file)
@@ -164,300 +164,6 @@ static inline const char* getProtocolName (int protocol)
     return NULL;
 }
 
-/**check whether a flow bit is set for an option node.
- *
- * @param otn Option Tree Node
- * @returns 0 - no flow bit is set, 1 otherwise
- */
-#if 0
-static int OtnHasFlowOrFlowbit(OptTreeNode *otn)
-{
-    if (otn_has_plugin(otn, RULE_OPTION_TYPE_FLOW) ||
-        otn_has_plugin(otn, RULE_OPTION_TYPE_FLOWBIT))
-    {
-        return 1;
-    }
-    return 0;
-}
-
-static void addRuleToIgnoreList(IgnoredRuleList **ppIgnoredRuleList, OptTreeNode *otn)
-{
-    IgnoredRuleList *ignored_rule;
-
-    ignored_rule = (IgnoredRuleList*)SnortAlloc(sizeof(*ignored_rule));
-    ignored_rule->otn = otn;
-    ignored_rule->next = *ppIgnoredRuleList;
-    *ppIgnoredRuleList = ignored_rule;
-}
-
-static void printIgnoredRules(
-    IgnoredRuleList *pIgnoredRuleList,
-    int any_any_flow
-    )
-{
-    char six_sids = 0;
-    int sids_ignored = 0;
-    char buf[STD_BUF];
-    IgnoredRuleList *ignored_rule;
-    IgnoredRuleList *next_ignored_rule;
-
-    buf[0] = '\0';
-
-    for (ignored_rule = pIgnoredRuleList; ignored_rule != NULL; )
-    {
-        if (any_any_flow == 0)
-        {
-            if (six_sids == 1)
-            {
-                SnortSnprintfAppend(buf, STD_BUF-1, "\n");
-                LogMessage("%s", buf);
-                six_sids = 0;
-            }
-
-            if (sids_ignored == 0)
-            {
-                SnortSnprintf(buf, STD_BUF-1, "    %d:%d",
-                        ignored_rule->otn->sigInfo.generator,
-                        ignored_rule->otn->sigInfo.id);
-            }
-            else
-            {
-                SnortSnprintfAppend(buf, STD_BUF-1, ", %d:%d",
-                        ignored_rule->otn->sigInfo.generator,
-                        ignored_rule->otn->sigInfo.id);
-            }
-            sids_ignored++;
-            if (sids_ignored %6 == 0)
-            {
-                /* Have it print next time through */
-                six_sids = 1;
-                sids_ignored = 0;
-            }
-        }
-        next_ignored_rule = ignored_rule->next;
-        free(ignored_rule);
-        ignored_rule = next_ignored_rule;
-    }
-
-    if (sids_ignored || six_sids)
-    {
-        SnortSnprintfAppend(buf, STD_BUF-1, "\n");
-        LogMessage("%s", buf);
-    }
-}
-
-/**Determines whether any_any_flow should be ignored or not.
- *
- * Dont ignore any_any_flows if flow bit is set on an any_any_flow,
- * or ignoreAnyAnyRules is not set.
- * @param portList port list
- * @param rtn Rule tree node
- * @param any_any_flow - set if any_any_flow is ignored,0 otherwise
- * @param ppIgnoredRuleList
- * @param ignoreAnyAnyRules
- * @returns
- */
-static int AnyAnyFlow(
-    uint16_t *portList,
-    OptTreeNode *otn,
-    RuleTreeNode*,
-    int any_any_flow,
-    IgnoredRuleList **ppIgnoredRuleList,
-    int ignoreAnyAnyRules)
-{
-    /**if any_any_flow is set then following code has no effect.*/
-    if (any_any_flow)
-    {
-        return any_any_flow;
-    }
-
-    /* Look for an OTN with flow or flowbits keyword */
-    if (OtnHasFlowOrFlowbit(otn))
-    {
-        int i;
-
-        for (i=1;i<=MAX_PORTS;i++)
-        {
-            /* track sessions for ALL ports becuase
-             * of any -> any with flow/flowbits */
-            portList[i] |= PORT_MONITOR_SESSION;
-        }
-        return 1;
-    }
-
-    if (ignoreAnyAnyRules)
-    {
-
-        /* if not, then ignore the content/pcre/etc */
-        if (otn_has_plugin(otn, RULE_OPTION_TYPE_CONTENT) ||
-                otn_has_plugin(otn, RULE_OPTION_TYPE_CONTENT_URI) ||
-                otn_has_plugin(otn, RULE_OPTION_TYPE_BYTE_TEST) ||
-                otn_has_plugin(otn, RULE_OPTION_TYPE_PCRE))
-        {
-            /* Ignoring this rule.... */
-            addRuleToIgnoreList(ppIgnoredRuleList, otn);
-        }
-    }
-
-    return 0;
-}
-
-/**initialize given port list from the given ruleset, for a given policy
- * @param portList pointer to array of MAX_PORTS+1 uint8_t. This array content
- * is changed by walking through the rulesets.
- * @param protocol - protocol type
- */
-static void setPortFilterList(
-        SnortConfig* sc,uint16_t *portList,
-        int protocol,
-        int ignoreAnyAnyRules,
-        PolicyId policyId
-        )
-{
-    char *port_array = NULL;
-    int num_ports = 0;
-    int i;
-    RuleTreeNode *rtn;
-    OptTreeNode *otn;
-    int inspectSrc, inspectDst;
-    char any_any_flow = 0;
-    IgnoredRuleList *pIgnoredRuleList = NULL;     ///list of ignored rules
-    SFGHASH_NODE *hashNode;
-    int flowBitIsSet = 0;
-
-    if ((protocol == IPPROTO_TCP) && (ignoreAnyAnyRules == 0))
-    {
-        int j;
-        for (j=0; j<MAX_PORTS; j++)
-        {
-            portList[j] |= PORT_MONITOR_SESSION | PORT_MONITOR_INSPECT;
-        }
-        return;
-    }
-
-    /* Post-process TCP rules to establish TCP ports to inspect. */
-    for (hashNode = sfghash_findfirst(sc->otn_map);
-         hashNode;
-         hashNode = sfghash_findnext(sc->otn_map))
-    {
-        otn = (OptTreeNode *)hashNode->data;
-        flowBitIsSet = OtnHasFlowOrFlowbit(otn);
-
-        rtn = getRtnFromOtn(otn, policyId);
-
-        if (!rtn)
-        {
-            continue;
-        }
-
-        if (rtn->proto == protocol)
-        {
-            //do operation
-            inspectSrc = inspectDst = 0;
-            if (PortObjectHasAny(rtn->src_portobject))
-            {
-                inspectSrc = -1;
-            }
-            else
-            {
-                port_array = PortObjectCharPortArray(port_array, rtn->src_portobject, &num_ports);
-                if (port_array && num_ports != 0)
-                {
-                    inspectSrc = 1;
-                    for (i=0;i<SFPO_MAX_PORTS;i++)
-                    {
-                        if (port_array[i])
-                        {
-                            portList[i] |= PORT_MONITOR_INSPECT;
-                            /* port specific rule */
-                                /* Look for an OTN with flow or flowbits keyword */
-                                if (flowBitIsSet)
-                                {
-                                    portList[i] |= PORT_MONITOR_SESSION;
-                                }
-                        }
-                    }
-                }
-                if ( port_array )
-                {
-                    free(port_array);
-                    port_array = NULL;
-                }
-            }
-            if (PortObjectHasAny(rtn->dst_portobject))
-            {
-                inspectDst = -1;
-            }
-            else
-            {
-                port_array = PortObjectCharPortArray(port_array, rtn->dst_portobject, &num_ports);
-                if (port_array && num_ports != 0)
-                {
-                    inspectDst = 1;
-                    for (i=0;i<SFPO_MAX_PORTS;i++)
-                    {
-                        if (port_array[i])
-                        {
-                            portList[i] |= PORT_MONITOR_INSPECT;
-                            /* port specific rule */
-                                if (flowBitIsSet)
-                                {
-                                    portList[i] |= PORT_MONITOR_SESSION;
-                                }
-                        }
-                    }
-                }
-                if ( port_array )
-                {
-                    free(port_array);
-                    port_array = NULL;
-                }
-            }
-            if ((inspectSrc == -1) && (inspectDst == -1))
-            {
-                /* any -> any rule */
-                if (any_any_flow == 0)
-                {
-                    any_any_flow = AnyAnyFlow(portList, otn, rtn, any_any_flow,
-                            &pIgnoredRuleList, ignoreAnyAnyRules);
-                }
-            }
-        }
-    }
-
-    // If portscan is tracking TCP/UDP, need to create sessions for all ports 
-    if (((protocol == IPPROTO_UDP) && (ScGetScannedProtocols(sc) & PS_PROTO_UDP))
-     || ((protocol == IPPROTO_TCP) && (ScGetScannedProtocols(sc) & PS_PROTO_TCP)))
-    {
-        int j;
-        for (j=0; j<MAX_PORTS; j++)
-        {
-            portList[j] |= PORT_MONITOR_SESSION;
-        }
-    }
-
-    if (any_any_flow == 1)
-    {
-        const char* protocolName = getProtocolName(protocol);
-
-        LogMessage("WARNING: 'ignore_any_rules' option for Stream5 %s "
-            "disabled because of %s rule with flow or flowbits option.\n",
-            protocolName, protocolName);
-    }
-
-    else if (pIgnoredRuleList)
-    {
-        const char* protocolName = getProtocolName(protocol);
-
-        LogMessage("WARNING: Rules (GID:SID) effectively ignored because of "
-            "'ignore_any_rules' option for Stream5 %s.\n", protocolName);
-    }
-    // free list; print iff any_any_flow
-    printIgnoredRules(pIgnoredRuleList, any_any_flow);
-
-}
-#endif
-
 //-------------------------------------------------------------------------
 // public methods
 //-------------------------------------------------------------------------
index 0acc522e9fc39556965348168ad7e8c71da91164..e26b29e07b3d1ad9db351d6c149e776bbd9dbd1a 100644 (file)
@@ -48,7 +48,8 @@ using namespace std;
 // this distinction should be more precise when policy foo is ripped out of
 // the instances.
 
-struct PHGlobal {
+struct PHGlobal
+{
     const InspectApi& api;
     bool init;
 
@@ -59,7 +60,8 @@ struct PHGlobal {
     { return ( a->api.type < b->api.type ); };
 };
 
-struct PHClass {
+struct PHClass
+{
     const InspectApi& api;
 
     PHClass(const InspectApi& p) : api(p) { };
@@ -69,7 +71,8 @@ struct PHClass {
     { return ( a->api.type < b->api.type ); };
 };
 
-struct PHInstance {
+struct PHInstance
+{
     PHClass& pp_class;
     Inspector* handler;
 
@@ -159,6 +162,15 @@ void InspectorManager::add_plugin(const InspectApi* api)
     s_handlers.push_back(g);
 }
 
+static const InspectApi* get_plugin(const char* keyword)
+{
+    for ( auto* p : s_handlers )
+        if ( !strcasecmp(p->api.base.name, keyword) )
+            return &p->api;
+
+    return nullptr;
+}
+
 void InspectorManager::dump_plugins()
 {
     Dumper d("Inspectors");
@@ -260,8 +272,7 @@ void InspectorManager::dispatch_meta (FrameworkPolicy* fp, int type, const uint8
         p->handler->meta(type, data);
 }
 
-Inspector* InspectorManager::get_inspector(
-    const char* key, InspectSsnFunc& f)
+Inspector* InspectorManager::get_inspector(const char* key)
 {
     InspectionPolicy* pi = get_inspection_policy();
 
@@ -273,10 +284,15 @@ Inspector* InspectorManager::get_inspector(
     if ( !p )
         return nullptr;
 
-    f = p->pp_class.api.ssn;
     return p->handler;
 } 
 
+InspectSsnFunc InspectorManager::get_session(const char* key)
+{
+    const InspectApi* api = get_plugin(key);
+    return api ? api->ssn : nullptr;
+} 
+
 //-------------------------------------------------------------------------
 // config stuff
 //-------------------------------------------------------------------------
index 3eeb6989bc1ab18e3678ef53a823014961ab408a..018f8bd2671bbc7e89f71e22fa544d0e6dfd656f 100644 (file)
@@ -50,7 +50,8 @@ public:
     static void reset_stats(SnortConfig*);
 
     static void instantiate(const InspectApi*, Module*, SnortConfig*);
-    static Inspector* get_inspector(const char* key, InspectSsnFunc&);
+    static Inspector* get_inspector(const char* key);
+    static InspectSsnFunc get_session(const char* key);
 
     static bool configure(SnortConfig*);
     static void print_config(SnortConfig*);
index d95bd752ce98ed80b740894e5748498e305dd43d..41cf8fe599f963f6ab18d238ac5b738a980a795f 100644 (file)
@@ -87,7 +87,8 @@ const MpseApi* MpseManager::get_search_api(const char* name)
 }
 
 Mpse* MpseManager::get_search_engine(
-    SnortConfig* sc,const MpseApi* api,
+    SnortConfig* sc,
+    const MpseApi* api,
     bool use_gc,
     void (*user_free)(void*),
     void (*tree_free)(void**),
index b9df3dd4dcc26c828fe6b868b926dd57d53c5ea3..8b75388e685e84fb161022893677a020bb2711b9 100644 (file)
@@ -202,9 +202,6 @@ bool Normalizer::configure(SnortConfig*)
         return true;
     }
 
-    InspectionPolicy* ips = get_inspection_policy();
-    ips->normal_mask = config.normalizer_flags;
-
     NetworkPolicy* nap = get_network_policy();
 
     if ( nap->new_ttl && nap->new_ttl < nap->min_ttl )
@@ -250,12 +247,6 @@ static void mod_dtor(Module* m)
 
 static const char* name = "normalize";
 
-int Normalize_IsEnabled (SnortConfig*, NormFlags nf)
-{
-    uint32_t mask = get_inspection_policy()->normal_mask;
-    return ( (mask & nf) != 0 );
-}
-
 static void no_init()
 {
 #ifdef PERF_PROFILING
index 8a9b0e0879be0e8da7b01522d92a562cc0f47410..9aed536ea0e2af49eca216aa42260b1246917ed4 100644 (file)
@@ -48,7 +48,10 @@ typedef enum {
     NORM_ALL             = 0x0003FFFF  // all normalizations on
 } NormFlags;
 
-int Normalize_IsEnabled(struct SnortConfig*, NormFlags);
+static inline int Normalize_IsEnabled(uint32_t mask, NormFlags nf)
+{
+    return ( (mask & nf) != 0 );
+}
 
 #endif
 
index e7c97ffe3044e64d562d0965c6818a9fea0500e1..c14d909cf68dd85beb54c4f4ce18fbf24e2e1104 100644 (file)
@@ -873,15 +873,13 @@ PortScan::~PortScan()
         Share::release(global);
 }
 
-bool PortScan::configure(SnortConfig* sc)
+bool PortScan::configure(SnortConfig*)
 {
     // FIXIT use fixed base file name
     config->logfile = SnortStrdup("portscan.log");
 
     global = (PsData*)Share::acquire(PS_GLOBAL);
     config->common = global->data;
-
-    ScSetScannedProtocols(sc, config->detect_scans);
     return true;
 }
 
index 0c67221dd4d647c1199d36c302408c96fd2d364c..8ebb0288337d2bc2abd9b3b724835c164d29817b 100644 (file)
@@ -582,6 +582,7 @@ static void IntegrityCheckRules(SnortConfig *sc)
 SnortConfig * ParseSnortConf(VarNode* tmp)
 {
     SnortConfig *sc = SnortConfNew();
+    snort_conf = sc;
 
     const char* fname = get_snort_conf();
 
index faede69aac931a79542272f930b6f3508c39df2d..1d222b92866d727c8201ecfcbcd1fc5df5ba7dfa 100644 (file)
@@ -118,16 +118,6 @@ Stream5GlobalConfig::Stream5GlobalConfig()
     prune_log_max = 1048576;
 }
 
-//-------------------------------------------------------------------------
-// class stuff
-//-------------------------------------------------------------------------
-
-// FIXIT BIND replace these with binder 
-static Inspector* ip_hand = nullptr;
-static Inspector* icmp_hand = nullptr;
-static Inspector* tcp_hand = nullptr;
-static Inspector* udp_hand = nullptr;
-
 //-------------------------------------------------------------------------
 // inspector stuff
 //-------------------------------------------------------------------------
@@ -161,22 +151,22 @@ void StreamBase::pinit()
 
     if ( config->tcp_cfg.max_sessions )
     {
-        tcp_hand = InspectorManager::get_inspector("stream_tcp", f);
+        f = InspectorManager::get_session("stream_tcp");
         flow_con->init_tcp(config->tcp_cfg, f);
     }
     if ( config->udp_cfg.max_sessions )
     {
-        udp_hand = InspectorManager::get_inspector("stream_udp", f);
+        f = InspectorManager::get_session("stream_udp");
         flow_con->init_udp(config->udp_cfg, f);
     }
     if ( config->ip_cfg.max_sessions )
     {
-        ip_hand = InspectorManager::get_inspector("stream_ip", f);
+        f = InspectorManager::get_session("stream_ip");
         flow_con->init_ip(config->ip_cfg, f);
     }
     if ( config->icmp_cfg.max_sessions )
     {
-        icmp_hand = InspectorManager::get_inspector("stream_icmp", f);
+        f = InspectorManager::get_session("stream_icmp");
         flow_con->init_icmp(config->icmp_cfg, f);
     }
     if ( config->tcp_cfg.max_sessions || config->udp_cfg.max_sessions )
@@ -214,22 +204,22 @@ void StreamBase::eval(Packet *p)
     switch ( GET_IPH_PROTO(p) )
     {
     case IPPROTO_TCP:
-        flow_con->process_tcp(tcp_hand, p);
+        flow_con->process_tcp(p);
         t_stats.tcp++;
         break;
 
     case IPPROTO_UDP:
-        flow_con->process_udp(udp_hand, p);
+        flow_con->process_udp(p);
         t_stats.udp++;
         break;
 
     case IPPROTO_ICMP:
-        flow_con->process_icmp(icmp_hand, p);
+        flow_con->process_icmp(p);
         t_stats.icmp++;
         break;
 
     case IPPROTO_IP:
-        flow_con->process_ip(ip_hand, p);
+        flow_con->process_ip(p);
         t_stats.ip++;
         break;
 
index 948ade2cbf2210e7f0ed1edd53226a34e76aa567..f46caededc7a7f4c4da7b9111e908fb5624408c6 100644 (file)
@@ -361,15 +361,6 @@ StreamFlowData *Stream::get_flow_data(Packet *p)
     return flow->flowdata;
 }
 
-uint16_t Stream::get_preprocessor_status_bit(void)
-{
-    static uint16_t preproc_filter_status_bit = PORT_MONITOR_SESSION;  // FIXIT bad joojoo
-
-    preproc_filter_status_bit <<= 1;
-
-    return preproc_filter_status_bit;
-}
-
 void Stream::init_active_response(Packet* p, Flow* flow)
 {
     if ( !flow ) return;
index f015d114af66ebe75e3ea69357c52ad83d0e25a1..e3a7248c205d2e1354e51c253648438384dc511c 100644 (file)
@@ -276,14 +276,6 @@ public:
      */
     static int16_t set_application_protocol_id(Flow*, int16_t appId);
 
-    /*  Get an independent bit to allow an entity to enable and
-     *  disable port session tracking and syn session creation
-     *  without affecting the status of set by other entities.
-     *  Returns a bitmask (with the bit range 3-15) or 0, if no bits
-     *  are available.
-     */
-    static uint16_t get_preprocessor_status_bit(void);
-
     // initialize response count and expiration time
     static void init_active_response(Packet*, Flow*);
 
@@ -307,20 +299,6 @@ public:
     static bool is_paf_active(Flow*, bool toServer);
     static bool activate_paf(Flow*, bool toServer);
 
-    /*  Set flag to force sessions to be created on SYN packets.
-     *  This function can only be used with independent bits
-     *  acquired from get_preprocessor_status_bit. If this is called
-     *  during parsing a preprocessor configuration, make sure to
-     *  set the parsing argument to 1.
-     */
-    static void set_tcp_syn_session_status(SnortConfig* sc, uint16_t status);
-    /*  Unset flag that forces sessions to be created on SYN
-     *  packets. This function can only be used with independent
-     *  bits acquired from get_preprocessor_status_bit. If this is
-     *  called during parsing a preprocessor configuration, make
-     *  sure to set the parsing argument to 1.
-     */
-    static void unset_tcp_syn_session_status(SnortConfig* sc, uint16_t status);
     /* Turn off inspection for potential session.
      * Adds session identifiers to a hash table.
      * TCP only.
@@ -430,24 +408,7 @@ private:
     uint8_t s5_cb_idx;
 };
 
-/**Port Inspection States. Port can be either ignored,
- * or inspected or session tracked. The values are bitmasks.
- */
-typedef enum {
-    /**Dont monitor the port. */
-    PORT_MONITOR_NONE = 0x00,
-
-    /**Inspect the port. */
-    PORT_MONITOR_INSPECT = 0x01,
-
-    /**perform session tracking on the port. */
-    PORT_MONITOR_SESSION = 0x02
-
-} PortMonitorStates;
-
 extern Stream stream;
 
-#define PORT_MONITOR_SESSION_BITS   0xFFFE
-
 #endif
 
index 2b06aa7694f56ac02acbfdcd775f81dc9a28d69e..cad3f9cb78b249fd0f32e7e15f696682b76e9314 100644 (file)
@@ -647,8 +647,15 @@ static inline void InitFlushMgr(
     mgr->auto_disable = auto_disable;
 
     UpdateFlushMgr(mgr, flush_point_list, 0, paf_max);
+}
+
+static inline void pInitFlushMgr(
+    Flow* flow, FlushMgr *mgr, FlushPointList *flush_point_list,
+    uint8_t policy, uint8_t auto_disable, unsigned paf_max)
+{
+    InitFlushMgr(mgr, flush_point_list, policy, auto_disable, paf_max);
 
-    if ( Normalize_IsEnabled(snort_conf, NORM_TCP_IPS) )
+    if ( Normalize_IsEnabled(flow->normal_mask, NORM_TCP_IPS) )
     {
         if ( policy == STREAM_FLPOLICY_FOOTPRINT )
             mgr->flush_policy = STREAM_FLPOLICY_FOOTPRINT_IPS;
@@ -659,7 +666,7 @@ static inline void InitFlushMgr(
 }
 
 static inline void InitFlushMgrByService (
-    StreamTracker* pst, int16_t service, bool c2s, uint8_t flush_policy)
+    Flow* flow, StreamTracker* pst, int16_t service, bool c2s, uint8_t flush_policy)
 {
     uint8_t registration, auto_disable = 0;
     bool flush = (flush_policy != STREAM_FLPOLICY_IGNORE);
@@ -678,7 +685,7 @@ static inline void InitFlushMgrByService (
         s5_paf_setup(&pst->paf_state, registration);
         auto_disable = !flush;
     }   
-    InitFlushMgr(&pst->flush_mgr, &pst->config->flush_point_list,
+    pInitFlushMgr(flow, &pst->flush_mgr, &pst->config->flush_point_list,
         flush_policy, auto_disable, pst->config->paf_max);
 }
 
@@ -761,7 +768,7 @@ bool Stream5ActivatePafTcp (Flow* lwssn, bool to_server)
     switch ( fm->flush_policy)
     {
     case STREAM_FLPOLICY_IGNORE:
-        InitFlushMgr(fm, &trk->config->flush_point_list,
+        pInitFlushMgr(lwssn, fm, &trk->config->flush_point_list,
             STREAM_FLPOLICY_PROTOCOL, 0, trk->config->paf_max);
         break;
 
@@ -1571,9 +1578,14 @@ static inline void NormalDropPacket (Packet*)
     Active_DropPacket();
 }
 
+static inline bool Normalize_IsEnabled(Packet* p, NormFlags f)
+{
+    return p->flow->norm_is_enabled(f);
+}
+
 static inline int NormalDropPacketIf (Packet* p, NormFlags f)
 {
-    if ( Normalize_IsEnabled(snort_conf, f) )
+    if ( Normalize_IsEnabled(p, f) )
     {
         NormalDropPacket(p);
         normStats[PC_TCP_BLOCK]++;
@@ -1627,7 +1639,7 @@ static inline int NormalTrimPayloadIf (
     Packet* p, NormFlags f, uint16_t max, TcpDataBlock* tdb
 ) {
     if (
-        Normalize_IsEnabled(snort_conf, f) &&
+        Normalize_IsEnabled(p, f) &&
         p->dsize > max )
     {
         NormalTrimPayload(p, max, tdb);
@@ -1862,7 +1874,7 @@ static inline int ValidTimestamp(StreamTracker *talker,
 
 #if 0
     if ( p->tcph->th_flags & TH_ACK &&
-        Normalize_IsEnabled(snort_conf, NORM_TCP_OPT) )
+        Normalize_IsEnabled(p, NORM_TCP_OPT) )
     {
         // FIXTHIS validate tsecr here (check that it was previously sent)
         // checking for the most recent ts is easy enough must check if
@@ -2146,7 +2158,7 @@ static inline void UpdateSsn(
          // forces seq-- on ACK of FIN.  :(
          rcv->s_mgr.state == TCP_STATE_ESTABLISHED &&
          rcv->s_mgr.state_queue == TCP_STATE_NONE &&
-         Normalize_IsEnabled(snort_conf, NORM_TCP_IPS) )
+         Normalize_IsEnabled(p, NORM_TCP_IPS) )
     {
         // walk the seglist until a gap or tdb->ack whichever is first
         // if a gap exists prior to ack, move ack back to start of gap
@@ -2743,7 +2755,7 @@ static inline int flush_stream(
     TcpSession *tcpssn, StreamTracker *st, Packet *p,
     snort_ip_p sip, snort_ip_p dip, uint16_t sp, uint16_t dp, uint32_t dir)
 {
-    if ( Normalize_IsEnabled(snort_conf, NORM_TCP_IPS) )
+    if ( Normalize_IsEnabled(p, NORM_TCP_IPS) )
     {
         uint32_t bytes = get_q_sequenced(st);
         return flush_to_seq(tcpssn, st, bytes, p, sip, dip, sp, dp, dir);
@@ -3367,7 +3379,7 @@ static uint32_t Stream5GetTcpTimestamp(Packet *p, uint32_t *ts, int strip)
     {
         if(p->tcp_options[i].code == TCPOPT_TIMESTAMP)
         {
-            if ( strip && Normalize_IsEnabled(snort_conf, NORM_TCP_OPT) )
+            if ( strip && Normalize_IsEnabled(p, NORM_TCP_OPT) )
             {
                 NormalStripTimeStamp(p, i);
             }
@@ -3861,7 +3873,7 @@ static int StreamQueue(StreamTracker *st, Packet *p, TcpDataBlock *tdb,
         int last = 0;
     );
 
-    ips_data = Normalize_IsEnabled(snort_conf, NORM_TCP_IPS);
+    ips_data = Normalize_IsEnabled(p, NORM_TCP_IPS);
     if ( ips_data )
         reassembly_policy = REASSEMBLY_POLICY_FIRST;
     else
@@ -5165,12 +5177,16 @@ static int NewTcpSession(
          * the server port and we're reassembling the client side.
          * That should make this almost as clear as opaque mud!
          */
+        // FIXIT these used to fall back to port configs which were deleted
+        // need to ensure that we can track a session w/o doing reassembly
+        // is else init flush to ignore needed?
         if (tmp->server.config->flush_config_protocol[lwssn->s5_state.application_protocol].configured == 1)
         {
             StreamTracker* pst = &tmp->server;
             uint8_t flush_policy =
                 pst->config->flush_config_protocol[lwssn->s5_state.application_protocol].client.flush_policy;
-            InitFlushMgrByService(pst, lwssn->s5_state.application_protocol, true, flush_policy);
+            InitFlushMgrByService(
+                lwssn, pst, lwssn->s5_state.application_protocol, true, flush_policy);
         }
 
         if (tmp->client.config->flush_config_protocol[lwssn->s5_state.application_protocol].configured == 1)
@@ -5178,7 +5194,8 @@ static int NewTcpSession(
             StreamTracker* pst = &tmp->client;
             uint8_t flush_policy =
                 pst->config->flush_config_protocol[lwssn->s5_state.application_protocol].server.flush_policy;
-            InitFlushMgrByService(pst, lwssn->s5_state.application_protocol, false, flush_policy);
+            InitFlushMgrByService(
+                lwssn, pst, lwssn->s5_state.application_protocol, false, flush_policy);
         }
 
 #ifdef DEBUG_STREAM5
@@ -5673,7 +5690,7 @@ static int ProcessTcp(
         if (StreamGetPolicy(lwssn, config, FROM_CLIENT) !=
             STREAM_POLICY_MACOS)
         {
-            if ( Normalize_IsEnabled(snort_conf, NORM_TCP_TRIM) )
+            if ( Normalize_IsEnabled(p, NORM_TCP_TRIM) )
             {
                 NormalTrimPayload(p, 0, tdb); // remove data on SYN
             }
@@ -5866,7 +5883,7 @@ static int ProcessTcp(
             talker->s_mgr.sub_state |= SUB_RST_SENT;
             Stream5UpdatePerfBaseState(&sfBase, lwssn, TCP_STATE_CLOSING);
 
-            if ( Normalize_IsEnabled(snort_conf, NORM_TCP_IPS) )
+            if ( Normalize_IsEnabled(p, NORM_TCP_IPS) )
                 listener->s_mgr.state = TCP_STATE_CLOSED;
             /* else for ids:
                 leave listener open, data may be in transit */
@@ -6198,7 +6215,7 @@ static int ProcessTcp(
             // window is zero in one direction until we've seen both sides.
             if ( !(lwssn->s5_state.session_flags & SSNFLAG_MIDSTREAM) )
             {
-                if ( Normalize_IsEnabled(snort_conf, NORM_TCP_TRIM) )
+                if ( Normalize_IsEnabled(p, NORM_TCP_TRIM) )
                 {
                     // sender of syn w/mss limits payloads from peer
                     // since we store mss on sender side, use listener mss
@@ -6215,7 +6232,7 @@ static int ProcessTcp(
 
                     NormalTrimPayload(p, max, tdb);
                 }
-                if ( Normalize_IsEnabled(snort_conf, NORM_TCP_ECN_STR) )
+                if ( Normalize_IsEnabled(p, NORM_TCP_ECN_STR) )
                     NormalCheckECN(tcpssn, p);
             }
             /*
@@ -6265,7 +6282,7 @@ static int ProcessTcp(
 
                 if ((listener->flush_mgr.flush_policy != STREAM_FLPOLICY_PROTOCOL) &&
                     (listener->flush_mgr.flush_policy != STREAM_FLPOLICY_PROTOCOL_IPS) &&
-                    Normalize_IsEnabled(snort_conf, NORM_TCP_IPS))
+                    Normalize_IsEnabled(p, NORM_TCP_IPS))
                 {
                     p->packet_flags |= PKT_PDU_TAIL;
                 }
@@ -7354,7 +7371,7 @@ char Stream5SetReassemblyTcp(
             }
             else
             {
-                InitFlushMgr(&tcpssn->client.flush_mgr,
+                pInitFlushMgr(lwssn, &tcpssn->client.flush_mgr,
                     &tcpssn->client.config->flush_point_list,
                     flush_policy, 0, tcpssn->client.config->paf_max);
             }
@@ -7371,7 +7388,7 @@ char Stream5SetReassemblyTcp(
             }
             else
             {
-                InitFlushMgr(&tcpssn->server.flush_mgr,
+                pInitFlushMgr(lwssn, &tcpssn->server.flush_mgr,
                     &tcpssn->server.config->flush_point_list,
                     flush_policy, 0, tcpssn->server.config->paf_max);
             }
@@ -7382,14 +7399,14 @@ char Stream5SetReassemblyTcp(
     {
         if (dir & SSN_DIR_CLIENT)
         {
-            InitFlushMgr(&tcpssn->client.flush_mgr,
+            pInitFlushMgr(lwssn, &tcpssn->client.flush_mgr,
                 &tcpssn->client.config->flush_point_list,
                 flush_policy, 0, tcpssn->client.config->paf_max);
         }
 
         if (dir & SSN_DIR_SERVER)
         {
-            InitFlushMgr(&tcpssn->server.flush_mgr,
+            pInitFlushMgr(lwssn, &tcpssn->server.flush_mgr,
                 &tcpssn->server.config->flush_point_list,
                 flush_policy, 0, tcpssn->server.config->paf_max);
         }