]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Merge pull request #1719 in SNORT/snort3 from ~SBAIGAL/snort3:wiz_restart to master
authorSteve Chew (stechew) <stechew@cisco.com>
Tue, 27 Aug 2019 20:28:22 +0000 (16:28 -0400)
committerSteve Chew (stechew) <stechew@cisco.com>
Tue, 27 Aug 2019 20:28:22 +0000 (16:28 -0400)
Squashed commit of the following:

commit 614ef5ef2ffb2a683bd8574c5f6a124f42e17544
Author: Steven Baigal (sbaigal) <sbaigal@cisco.com>
Date:   Fri Aug 2 14:18:37 2019 -0400

    binder: updated change_service event to support service reset via wizard

    removed switch to wizard event and use null service to reset

src/network_inspectors/binder/binder.cc

index aa56124934dc00683b988c645502ebe52f3a858c..0f309e120c877bd59307a7d45e0cd91b77860d0a 100644 (file)
@@ -745,19 +745,49 @@ void Binder::handle_flow_service_change( Flow* flow )
 
     assert(flow);
 
-    Inspector* ins = find_gadget(flow);
-
-    if ( flow->gadget != ins )
+    Inspector* ins = nullptr;
+    if (flow->service)
     {
+        ins = find_gadget(flow);
+        if ( flow->gadget != ins )
+        {
+            if ( flow->gadget )
+                flow->clear_gadget();
+            if ( ins )
+            {
+                flow->set_gadget(ins);
+                flow->ssn_state.snort_protocol_id = ins->get_service();
+            }
+            else
+                flow->ssn_state.snort_protocol_id = UNKNOWN_PROTOCOL_ID;
+        }
+    }
+    else
+    {
+        // reset to wizard when serviec is not specified
+        unsigned sz = bindings.size();
+        for ( unsigned i = 0; i < sz; i++ )
+        {
+            Binding* pb = bindings[i];
+            if ( pb->use.ips_index or pb->use.inspection_index or pb->use.network_index )
+                continue;
+
+            if ( pb->use.what == BindUse::BW_WIZARD )
+            {
+                ins = (Inspector*)pb->use.object;
+                break;
+            }
+        }
+
         if ( flow->gadget )
             flow->clear_gadget();
+        if ( flow->clouseau )
+            flow->clear_clouseau();
         if ( ins )
         {
-            flow->set_gadget(ins);
-            flow->ssn_state.snort_protocol_id = ins->get_service();
+            flow->set_clouseau(ins);
         }
-        else
-            flow->ssn_state.snort_protocol_id = UNKNOWN_PROTOCOL_ID;
+        flow->ssn_state.snort_protocol_id = UNKNOWN_PROTOCOL_ID;
     }
 
     // If there is no inspector bound to this flow after the service change, see if there's at least