]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
moved Parameter* from deflt to range for list and table
authorRuss Combs <rucombs@cisco.com>
Wed, 4 Jun 2014 13:56:11 +0000 (09:56 -0400)
committerRuss Combs <rucombs@cisco.com>
Wed, 4 Jun 2014 13:56:11 +0000 (09:56 -0400)
12 files changed:
ChangeLog
src/framework/parameter.cc
src/framework/parameter.h
src/main/modules.cc
src/managers/module_manager.cc
src/network_inspectors/arp_spoof/arp_module.cc
src/network_inspectors/normalize/norm_module.cc
src/service_inspectors/ftp_telnet/ftp_module.cc
src/service_inspectors/http_inspect/hi_module.cc
src/stream/base/stream_module.cc
src/stream/ip/ip_defrag.cc
src/stream/tcp/tcp_module.cc

index a6a64d452097371fc12964fb8176c60463ad8ef0..6b1c181b3499090d78c05864c3715d55f08a2144 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+85
+-- swapped use of range and deflt for PT_TABLE and PT_LIST Parameters
+   (Parameter* is now in range so that deflt may be used for tabl/list
+   defaults)
+
 84
 -- pulled in latest codecs
 -- removed src/mempool/
index 421245e4bc01e880a7393f93e1419750dcec25b7..1daea9038f9f60e935012a6b2cf30236e6386fb7 100644 (file)
@@ -283,7 +283,7 @@ bool Parameter::validate(Value& v) const
     {
     // bool values
     case PT_BOOL:
-        return valid_bool(v, range);
+        return valid_bool(v, (const char*)range);
 
     // num values
     case PT_PORT:
@@ -291,31 +291,31 @@ bool Parameter::validate(Value& v) const
             return valid_int(v, "0:65535");
         // if a range was given fall thru
     case PT_INT:
-        return valid_int(v, range);
+        return valid_int(v, (const char*)range);
     case PT_REAL:
-        return valid_real(v, range);
+        return valid_real(v, (const char*)range);
 
     // string values
     case PT_STRING:
-        return valid_string(v, range);
+        return valid_string(v, (const char*)range);
     case PT_SELECT:
-        return valid_select(v, range);
+        return valid_select(v, (const char*)range);
     case PT_MULTI:
-        return valid_multi(v, range);
+        return valid_multi(v, (const char*)range);
     case PT_ENUM:
-        return valid_enum(v, range);
+        return valid_enum(v, (const char*)range);
 
     // address values
     case PT_MAC:
-        return valid_mac(v, range);
+        return valid_mac(v, (const char*)range);
     case PT_IP4:
-        return valid_ip4(v, range);
+        return valid_ip4(v, (const char*)range);
     case PT_ADDR:
-        return valid_addr(v, range);
+        return valid_addr(v, (const char*)range);
 
     // list values
     case PT_BIT_LIST:
-        return valid_bit_list(v, range);
+        return valid_bit_list(v, (const char*)range);
 
     case PT_ADDR_LIST:
         return true;
index dcb0f35e2c854f243ace40895b16c99d9cdf11c8..be3ac1aef78759f6e1dddf42143b863522debe39 100644 (file)
@@ -29,8 +29,8 @@ struct Parameter
 {
     enum Type
     {
-        PT_TABLE,      // deflt is Parameter*
-        PT_LIST,       // deflt is Parameter*, range is max
+        PT_TABLE,      // range is Parameter*, deflt is TBD
+        PT_LIST,       // range is Parameter*, deflt is TBD
         PT_BOOL,       // if you are reading this, get more coffee
         PT_INT,        // signed 64 bits or less determined by range
         PT_REAL,       // double
@@ -48,8 +48,8 @@ struct Parameter
     };
     const char* name;
     Type type;
-    const char* range;
-    const void* deflt;  // nullptr|const char*|const Parameter*
+    const void* range;  // nullptr|const char*|const Parameter*
+    const char* deflt;
     const char* help;
 
     const char* get_type() const;
index 3f86179acd00ed15bbfea5d958bbfd4436739bd3..06b187459824f0325d3e83b76cb2800a93ed5ed7 100644 (file)
@@ -325,7 +325,7 @@ static const Parameter profile_rule_params[] =
       "avg_ticks_per_match | avg_ticks_per_no_match",
       "avg_ticks", "sort by given field" },
 
-    { "file", Parameter::PT_TABLE, nullptr, profile_file_params,
+    { "file", Parameter::PT_TABLE, profile_file_params, nullptr,
       "file config" },
 
     { nullptr, Parameter::PT_MAX, nullptr, nullptr, nullptr }
@@ -340,7 +340,7 @@ static const Parameter profile_preproc_params[] =
       "checks | avg_ticks | total_ticks", "avg_ticks",
       "sort by given field" },
 
-    { "file", Parameter::PT_TABLE, nullptr, profile_file_params,
+    { "file", Parameter::PT_TABLE, profile_file_params, nullptr,
       "file config" },
 
     { nullptr, Parameter::PT_MAX, nullptr, nullptr, nullptr }
@@ -348,10 +348,10 @@ static const Parameter profile_preproc_params[] =
 
 static const Parameter profile_params[] =
 {
-    { "rules", Parameter::PT_TABLE, nullptr, profile_rule_params,
+    { "rules", Parameter::PT_TABLE, profile_rule_params, nullptr,
       "" },
 
-    { "preprocs", Parameter::PT_TABLE, nullptr, profile_preproc_params,
+    { "preprocs", Parameter::PT_TABLE, profile_preproc_params, nullptr,
       "" },
 
     { nullptr, Parameter::PT_MAX, nullptr, nullptr, nullptr }
@@ -652,7 +652,7 @@ static const Parameter output_params[] =
     { "log_ipv6_extra_data", Parameter::PT_BOOL, nullptr, "false",
       "log IPv6 source and destination addresses as unified2 extra data records" },
 
-    { "event_trace", Parameter::PT_TABLE, nullptr, output_event_trace_params,
+    { "event_trace", Parameter::PT_TABLE, output_event_trace_params, nullptr,
       "" },
 
     { "quiet", Parameter::PT_BOOL, nullptr, "false",
@@ -1699,10 +1699,10 @@ static const Parameter binder_use_params[] =
 
 static const Parameter binder_params[] =
 {
-    { "when", Parameter::PT_TABLE, nullptr, binder_when_params,
+    { "when", Parameter::PT_TABLE, binder_when_params, nullptr,
       "match criteria" },
 
-    { "use", Parameter::PT_TABLE, nullptr, binder_use_params,
+    { "use", Parameter::PT_TABLE, binder_use_params, nullptr,
       "target configuration" },
 
     { nullptr, Parameter::PT_MAX, nullptr, nullptr, nullptr }
@@ -1826,7 +1826,7 @@ static const Parameter hosts_params[] =
     { "tcp_policy", Parameter::PT_ENUM, tcp_policies, "linux",
       "tcp reassembly policy" },
 
-    { "services", Parameter::PT_LIST, nullptr, service_params,
+    { "services", Parameter::PT_LIST, service_params, nullptr,
       "list of service parameters" },
 
     { nullptr, Parameter::PT_MAX, nullptr, nullptr, nullptr }
index e2b642f74b383510d7b07b1b63a7d97d4038f3ac..53e530bfef9c048d2b783d184e92d3126a2bc3a6 100644 (file)
@@ -192,7 +192,7 @@ static void dump_field(string& key, const char* pfx, const Parameter* p, bool li
     // we dump just one list entry
     if ( p->type == Parameter::PT_TABLE ||
          p->type == Parameter::PT_LIST )
-        dump_table(key, pfx, (Parameter*)p->deflt);
+        dump_table(key, pfx, (Parameter*)p->range);
 
     else if ( !pfx || !strncmp(key.c_str(), pfx, strlen(pfx)) )
     {
@@ -243,7 +243,7 @@ static const Parameter* get_params(string& sfx, const Parameter* p)
          p->type != Parameter::PT_LIST )
         return p;
 
-    p = (const Parameter*)p->deflt;
+    p = (const Parameter*)p->range;
     return get_params(sfx,  p);
 }
 
index a53a6b7b556009818f60f1b3833458c799e308a2..d28e30982f4655af3f8956bd3491d2fa9a142dc8 100644 (file)
@@ -52,7 +52,7 @@ static const Parameter arp_spoof_params[] =
     { "unicast", Parameter::PT_BOOL, nullptr, "false",
       "help" },
 
-    { "hosts", Parameter::PT_LIST, nullptr, arp_spoof_hosts_params,
+    { "hosts", Parameter::PT_LIST, arp_spoof_hosts_params, nullptr,
       "help" },
 
     { nullptr, Parameter::PT_MAX, nullptr, nullptr, nullptr }
index 67c514b6f7a552a6419d8aa23945c267e274bcf6..c85969155d621433f839d7144896e6868ac9de3f 100644 (file)
@@ -135,10 +135,10 @@ static const Parameter norm_tcp_params[] =
 
 static const Parameter normalize_params[] =
 {
-    { "ip4", Parameter::PT_TABLE, nullptr, norm_ip4_params,
+    { "ip4", Parameter::PT_TABLE, norm_ip4_params, nullptr,
       "set ip4 normalization options" },
 
-    { "tcp", Parameter::PT_TABLE, nullptr, norm_tcp_params,
+    { "tcp", Parameter::PT_TABLE, norm_tcp_params, nullptr,
       "set tcp normalization options" },
 
     { "ip6", Parameter::PT_BOOL, nullptr, "false",
index 4225b6a4fc22d9a7bc9e2c73666e404b5726cea2..f603130eb36a7280463e8495c55dcaaf049df7b9 100644 (file)
@@ -51,7 +51,7 @@ static const Parameter ftp_client_params[] =
     { "bounce", Parameter::PT_BOOL, nullptr, "false",
       "check for bounces" },
 
-    { "bounce_to", Parameter::PT_TABLE, nullptr, client_bounce_params,
+    { "bounce_to", Parameter::PT_TABLE, client_bounce_params, nullptr,
       "allow bounces to CIDRs / ports" },
 
     { "ignore_telnet_erase_cmds", Parameter::PT_BOOL, nullptr, "false",
@@ -269,7 +269,7 @@ static const Parameter ftp_directory_params[] =
 
 static const Parameter ftp_server_params[] =
 {
-    { "alt_max_param", Parameter::PT_LIST, nullptr, ftp_server_alt_max_params,
+    { "alt_max_param", Parameter::PT_LIST, ftp_server_alt_max_params, nullptr,
       "specify non-default maximum command lengths" },
 
     { "chk_str_fmt", Parameter::PT_STRING, nullptr, nullptr,
@@ -281,7 +281,7 @@ static const Parameter ftp_server_params[] =
     { "data_xfer_cmds", Parameter::PT_STRING, nullptr, nullptr,
       "check the formatting of the given commands" },
 
-    { "directory_cmds", Parameter::PT_LIST, nullptr, ftp_directory_params,
+    { "directory_cmds", Parameter::PT_LIST, ftp_directory_params, nullptr,
       "specify command-response pairs" },
 
     { "file_put_cmds", Parameter::PT_STRING, nullptr, nullptr,
@@ -299,7 +299,7 @@ static const Parameter ftp_server_params[] =
     { "check_encrypted", Parameter::PT_BOOL, nullptr, "false",
       "check for end of encryption" },
 
-    { "cmd_validity", Parameter::PT_LIST, nullptr, ftp_server_validity_params,
+    { "cmd_validity", Parameter::PT_LIST, ftp_server_validity_params, nullptr,
       "specify command formats" },
 
     { "def_max_param_len", Parameter::PT_INT, "1:", "100",
index dd068e9800b5acd50f7a879a22d84d17c560c69b..990718f9fe7010622c131c74c7d105474d5bcaf5 100644 (file)
@@ -70,7 +70,7 @@ static const Parameter hi_global_params[] =
     { "compress_depth", Parameter::PT_INT, "1:65535", "1460",
       "maximum amount of packet payload to decompress" },
 
-    { "decode", Parameter::PT_TABLE, nullptr, hi_decode_params,
+    { "decode", Parameter::PT_TABLE, hi_decode_params, nullptr,
       "help" },
 
     { "decompress_depth", Parameter::PT_INT, "1:65535", "2920",
@@ -86,13 +86,13 @@ static const Parameter hi_global_params[] =
     { "memcap", Parameter::PT_INT, "2304:", "150994944",
       "limit of memory used for logging extra data" },
 
-    //{ "mime", Parameter::PT_TABLE, nullptr, hi_mime_params,
+    //{ "mime", Parameter::PT_TABLE, hi_mime_params, nullptr,
     //  "help" },
 
     { "proxy_alert", Parameter::PT_BOOL, nullptr, "false",
       "alert on proxy usage for servers without allow_proxy_use" },
 
-    { "unicode_map", Parameter::PT_TABLE, nullptr, hi_umap_params,
+    { "unicode_map", Parameter::PT_TABLE, hi_umap_params, nullptr,
       "help" },
 
     { nullptr, Parameter::PT_MAX, nullptr, nullptr, nullptr }
@@ -292,7 +292,7 @@ static const Parameter hi_server_params[] =
     { "iis_unicode", Parameter::PT_BOOL, nullptr, "false",
       "enable unicode code point mapping using unicode_map settings" },
 
-    { "iis_unicode_map", Parameter::PT_TABLE, nullptr, hi_umap_params,
+    { "iis_unicode_map", Parameter::PT_TABLE, hi_umap_params, nullptr,
       "help" },
 
     { "inspect_gzip", Parameter::PT_BOOL, nullptr, "false",
@@ -367,7 +367,7 @@ static const Parameter hi_server_params[] =
     { "u_encode", Parameter::PT_BOOL, nullptr, "false",
       "decode %uXXXX character sequences" },
 
-    { "unicode_map", Parameter::PT_TABLE, nullptr, hi_umap_params,
+    { "unicode_map", Parameter::PT_TABLE, hi_umap_params, nullptr,
       "help" },
 
     { "unlimited_decompress", Parameter::PT_INT, nullptr, "false",
index dd2ad050d6f522c7c506e8e5e2a0deee6ff6303d..3e430800934537ffc593ba30aa6dbff1708c94a8 100644 (file)
@@ -61,16 +61,16 @@ static const Parameter proto_params[] =
 
 static const Parameter stream_params[] =
 {
-    { "icmp_cache", Parameter::PT_TABLE, nullptr, proto_params,
+    { "icmp_cache", Parameter::PT_TABLE, proto_params, nullptr,
       "configure icmp cache limits" },
 
-    { "ip_cache", Parameter::PT_TABLE, nullptr, proto_params,
+    { "ip_cache", Parameter::PT_TABLE, proto_params, nullptr,
       "configure ip cache limits" },
 
-    { "tcp_cache", Parameter::PT_TABLE, nullptr, proto_params,
+    { "tcp_cache", Parameter::PT_TABLE, proto_params, nullptr,
       "configure tcp cache limits" },
 
-    { "udp_cache", Parameter::PT_TABLE, nullptr, proto_params,
+    { "udp_cache", Parameter::PT_TABLE, proto_params, nullptr,
       "configure udp cache limits" },
 
     { nullptr, Parameter::PT_MAX, nullptr, nullptr, nullptr }
index 8589e82a9a8adcac5d1456446d8a27b0b187e3fe..f4d75dcdf2c054c25deb77f55f609feb791338ca 100644 (file)
@@ -462,6 +462,7 @@ static inline void EventAnomScMinTTL(FragEngine*)
     t_stats.alerts++;
 }
 
+#if 0
 static int FragPolicyIdFromName(char *name)
 {
     if (!name)
@@ -499,6 +500,7 @@ static int FragPolicyIdFromName(char *name)
     }
     return FRAG_POLICY_DEFAULT;
 }
+#endif
 
 /**
  * Check to see if a FragTracker has timed out
index db8f8f70905c5fc8164a9fcc135b5ea7107fbd20..b6dc7730c4a5fb1207eeb73d4b6ec492f89a118d 100644 (file)
@@ -157,10 +157,10 @@ static const Parameter stream_tcp_params[] =
     { "show_rebuilt_packets", Parameter::PT_BOOL, nullptr, "false",
       "enable cmg like output of reassembled packets" },
 
-    { "queue_limit", Parameter::PT_TABLE, nullptr, stream_queue_limit_params,
+    { "queue_limit", Parameter::PT_TABLE, stream_queue_limit_params, nullptr,
       "limit amount of segment data queued" },
 
-    { "small_segments", Parameter::PT_TABLE, nullptr, stream_tcp_small_params,
+    { "small_segments", Parameter::PT_TABLE, stream_tcp_small_params, nullptr,
       "limit number of small segments queued" },
 
     { "session_timeout", Parameter::PT_INT, "1:86400", "30",