]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
more tweaks to bindings
authorRuss Combs <rucombs@cisco.com>
Tue, 6 May 2014 11:32:19 +0000 (07:32 -0400)
committerRuss Combs <rucombs@cisco.com>
Tue, 6 May 2014 11:32:19 +0000 (07:32 -0400)
src/main/binder.h
src/main/modules.cc

index 2e53168149c2efe9ec85ceafe57e391e9cddca22..3fe13b466d787423173e3a51a1a10b14f29de0c5 100644 (file)
@@ -39,6 +39,14 @@ enum BindAction
     BA_BLOCK
 };
 
+enum BindProto
+{
+    BP_IP,
+    BP_ICMP,
+    BP_TCP,
+    BP_UDP
+};
+
 struct Binding
 {
     // when
@@ -46,7 +54,7 @@ struct Binding
     std::string when_svc;
     VlanList vlans;
     std::string nets;
-    ByteList protos;
+    BindProto proto;
     PortList ports;
     BindRole role;
 
index 0011227ced5bc9de99f526f5da89a4a43de53275..1b40e6ff9ee55418ce4f06be48ab534138e2d4c6 100644 (file)
@@ -1643,7 +1643,7 @@ static const Parameter bindings_when_params[] =
     { "nets", Parameter::PT_ADDR_LIST, nullptr, nullptr,
       "list of networks" },
 
-    { "proto", Parameter::PT_SELECT, "ip | icmp | tcp | udp", nullptr,
+    { "proto", Parameter::PT_ENUM, "ip | icmp | tcp | udp", nullptr,
       "protocol" },
 
     { "ports", Parameter::PT_BIT_LIST, "65535", nullptr,
@@ -1708,28 +1708,25 @@ private:
 bool BindingsModule::set(const char* fqn, Value& v, SnortConfig*)
 {
     // both
-    if ( v.is("policy_id") )
-    {
-        if ( !strcmp(fqn, "bindings.when") )
-            work->when_id = v.get_string();
-        else
-            work->use_id = v.get_string();
-    }
-    else if ( v.is("service") )
-    {
-        if ( !strcmp(fqn, "bindings.when") )
-            work->when_svc = v.get_string();
-        else
-            work->use_svc = v.get_string();
-    }
+    if ( !strcmp(fqn, "bindings.when.policy_id") )
+        work->when_id = v.get_string();
+
+    else if ( !strcmp(fqn, "bindings.use.policy_id") )
+        work->use_id = v.get_string();
+
+    else if ( !strcmp(fqn, "bindings.when.service") )
+        work->when_svc = v.get_string();
+
+    else if ( !strcmp(fqn, "bindings.use.service") )
+        work->use_svc = v.get_string();
+
     // when
     else if ( v.is("nets") )
         work->nets = v.get_string();
 
     else if ( v.is("proto") )
-    {
-        //v.get_bits(work->proto); FIXIT ?
-    }
+        work->proto = (BindProto)v.get_long();
+
     else if ( v.is("ports") )
         v.get_bits(work->ports);