]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Merge pull request #209 in SNORT/snort3 from lru_cache2 to master
authorRuss Combs (rucombs) <rucombs@cisco.com>
Thu, 21 Jan 2016 16:13:51 +0000 (11:13 -0500)
committerRuss Combs (rucombs) <rucombs@cisco.com>
Thu, 21 Jan 2016 16:13:51 +0000 (11:13 -0500)
Squashed commit of the following:

commit 75c8e8f3b2fbf35018f396ed5388303d7c2bd14c
Author: Steve Chew <stechew@cisco.com>
Date:   Wed Jan 20 15:09:58 2016 -0500

    Moved host_tracker code to new location.

configure.ac
src/Makefile.am
src/host_tracker/CMakeLists.txt [new file with mode: 0644]
src/host_tracker/Makefile.am [new file with mode: 0644]
src/host_tracker/host_module.cc [new file with mode: 0644]
src/host_tracker/host_module.h [new file with mode: 0644]
src/host_tracker/host_tracker.h [moved from src/target_based/host_tracker.h with 100% similarity]
src/host_tracker/test/Makefile.am [moved from src/target_based/test/Makefile.am with 100% similarity]
src/host_tracker/test/host_tracker_test.cc [moved from src/target_based/test/host_tracker_test.cc with 99% similarity]
src/main/modules.cc
src/target_based/Makefile.am

index d4e6c2099eec3b0ce106bf5ffb384d5a8e2f75ae..a260e6be9f3fae6a3140a75828d99213e98f5257 100644 (file)
@@ -1078,7 +1078,8 @@ src/search_engines/test/Makefile \
 src/sfip/Makefile \
 src/sfrt/Makefile \
 src/target_based/Makefile \
-src/target_based/test/Makefile \
+src/host_tracker/Makefile \
+src/host_tracker/test/Makefile \
 src/catch/Makefile \
 src/time/Makefile \
 src/ppm/Makefile \
index 1a8fcc79c9d3ebf2288a89dd7138d0c4c820748e..38fcefdd38bbc581b91717100aca4f17e9c161c9 100644 (file)
@@ -83,6 +83,7 @@ ips_options/libips_options.a \
 search_engines/libsearch_engines.a \
 target_based/libtarget_based.a \
 main/libmain.a \
+host_tracker/libhost_tracker.a \
 parser/libparser.a \
 flow/libflow.a \
 control/libcontrol.a \
@@ -119,6 +120,7 @@ flow \
 framework \
 hash \
 helpers \
+host_tracker \
 lua \
 ips_options \
 log \
diff --git a/src/host_tracker/CMakeLists.txt b/src/host_tracker/CMakeLists.txt
new file mode 100644 (file)
index 0000000..3f58824
--- /dev/null
@@ -0,0 +1,6 @@
+
+add_library( host_tracker STATIC
+    host_module.cc
+    host_module.h
+    host_tracker.h
+)
diff --git a/src/host_tracker/Makefile.am b/src/host_tracker/Makefile.am
new file mode 100644 (file)
index 0000000..24ba00c
--- /dev/null
@@ -0,0 +1,13 @@
+
+noinst_LIBRARIES = libhost_tracker.a
+
+libhost_tracker_a_SOURCES = \
+host_module.cc \
+host_module.h \
+host_tracker.h
+
+if BUILD_UNIT_TESTS
+SUBDIRS = test
+endif
+
+
diff --git a/src/host_tracker/host_module.cc b/src/host_tracker/host_module.cc
new file mode 100644 (file)
index 0000000..595c5e2
--- /dev/null
@@ -0,0 +1,112 @@
+//--------------------------------------------------------------------------
+// Copyright (C) 2015 Cisco and/or its affiliates. All rights reserved.
+//
+// This program is free software; you can redistribute it and/or modify it
+// under the terms of the GNU General Public License Version 2 as published
+// by the Free Software Foundation.  You may not use, modify or distribute
+// this program under any other version of the GNU General Public License.
+//
+// This program is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this program; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+//--------------------------------------------------------------------------
+
+// host_module.cc author Steve Chew <stechew@cisco.com>
+
+#include "host_tracker/host_module.h"
+
+#include "stream/stream_api.h"
+#include "target_based/snort_protocols.h"
+
+const Parameter HostTrackerModule::service_params[] =
+{
+    { "name", Parameter::PT_STRING, nullptr, nullptr,
+      "service identifier" },
+
+    { "proto", Parameter::PT_ENUM, "tcp | udp", "tcp",
+      "ip protocol" },
+
+    { "port", Parameter::PT_PORT, nullptr, nullptr,
+      "port number" },
+
+    { nullptr, Parameter::PT_MAX, nullptr, nullptr, nullptr }
+};
+
+const Parameter HostTrackerModule::host_tracker_params[] =
+{
+    { "ip", Parameter::PT_ADDR, nullptr, "0.0.0.0/32",
+      "hosts address / cidr" },
+
+    { "frag_policy", Parameter::PT_ENUM, IP_POLICIES, nullptr,
+      "defragmentation policy" },
+
+    { "tcp_policy", Parameter::PT_ENUM, TCP_POLICIES, nullptr,
+      "tcp reassembly policy" },
+
+    { "services", Parameter::PT_LIST, HostTrackerModule::service_params, nullptr,
+      "list of service parameters" },
+
+    { nullptr, Parameter::PT_MAX, nullptr, nullptr, nullptr }
+};
+
+
+bool HostTrackerModule::set(const char*, Value& v, SnortConfig*)
+{
+    if ( host and v.is("ip") )
+    {
+        sfip_t addr;
+        v.get_addr(addr);
+        host->set_ip_addr(addr);
+    }
+    else if ( host and v.is("frag_policy") )
+        host->set_frag_policy(v.get_long() + 1);
+
+    else if ( host and v.is("tcp_policy") )
+        host->set_stream_policy(v.get_long() + 1);
+
+    else if ( v.is("name") )
+        app.protocol = AddProtocolReference(v.get_string());
+
+    else if ( v.is("proto") )
+        app.ipproto = AddProtocolReference(v.get_string());
+
+    else if ( v.is("port") )
+        app.port = v.get_long();
+
+    else
+        return false;
+
+    return true;
+}
+
+bool HostTrackerModule::begin(const char* fqn, int idx, SnortConfig*)
+{
+    if ( idx && !strcmp(fqn, "host_tracker") )
+        host = new HostTracker;
+
+    return true;
+}
+
+bool HostTrackerModule::end(const char* fqn, int idx, SnortConfig*)
+{
+    if ( idx && !strcmp(fqn, "host_tracker.services") )
+    {
+        host->add_service(app);
+        memset(&app, 0, sizeof(app));
+    }
+    else if ( idx && !strcmp(fqn, "host_tracker") )
+    {
+        //  FIXIT-H: Next step will be to add the HostTracker object to
+        //  a cache.  For now just delete in the destructor.
+        //SFAT_AddHost(host);
+        //host = nullptr;
+    }
+
+    return true;
+}
+
diff --git a/src/host_tracker/host_module.h b/src/host_tracker/host_module.h
new file mode 100644 (file)
index 0000000..a9184f8
--- /dev/null
@@ -0,0 +1,65 @@
+//--------------------------------------------------------------------------
+// Copyright (C) 2015 Cisco and/or its affiliates. All rights reserved.
+//
+// This program is free software; you can redistribute it and/or modify it
+// under the terms of the GNU General Public License Version 2 as published
+// by the Free Software Foundation.  You may not use, modify or distribute
+// this program under any other version of the GNU General Public License.
+//
+// This program is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this program; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+//--------------------------------------------------------------------------
+
+// host_module.h author Steve Chew <stechew@cisco.com>
+
+#ifndef HOST_MODULE_H
+#define HOST_MODULE_H
+
+//  Loads host configuration data.
+
+//  FIXIT-M - Temporarily create new HostTracker module to test new
+//            HostTracker object.  May eventually replace old Hosts
+//            module with this one.
+
+#include "framework/module.h"
+#include "host_tracker/host_tracker.h"
+
+#define host_tracker_help \
+    "configure hosts"
+
+class HostTrackerModule : public Module
+{
+public:
+    HostTrackerModule() : Module("host_tracker", host_tracker_help, host_tracker_params, true)
+    {
+        host = nullptr;
+    }
+
+    ~HostTrackerModule()
+    {
+        //  FIXIT-H: Change this back to an assert once we hand off the
+        //           host to a cache.
+        if (host)
+            delete host;
+    }
+
+    bool set(const char*, Value&, SnortConfig*) override;
+    bool begin(const char*, int, SnortConfig*) override;
+    bool end(const char*, int, SnortConfig*) override;
+
+private:
+    static const Parameter host_tracker_params[];
+    static const Parameter service_params[];
+
+    HostApplicationEntry app;
+    HostTracker* host;
+};
+
+#endif
+
similarity index 99%
rename from src/target_based/test/host_tracker_test.cc
rename to src/host_tracker/test/host_tracker_test.cc
index 03de79374b47bb40fc3e41e2c771d79c0ce3595b..c00d1dae2117bb81910ca08bf403629f5d8587f7 100644 (file)
@@ -19,7 +19,7 @@
 // host_tracker_test.cc author Steve Chew <stechew@cisco.com>
 // unit tests for HostTracker class
 
-#include "target_based/host_tracker.h"
+#include "host_tracker/host_tracker.h"
 
 #include <CppUTest/CommandLineTestRunner.h>
 #include <CppUTest/TestHarness.h>
index adffb9135df704e8965550d049b5c63db1a9d97a..ab2375c4bf79d6d5e45f4af6e5e54112f778f80c 100644 (file)
@@ -61,7 +61,7 @@ using namespace std;
 #include "stream/stream_api.h"
 #include "utils/stats.h"
 #include "target_based/snort_protocols.h"
-#include "target_based/host_tracker.h"
+#include "host_tracker/host_module.h"
 
 //-------------------------------------------------------------------------
 // detection module
@@ -2053,93 +2053,6 @@ bool HostsModule::end(const char* fqn, int idx, SnortConfig*)
     return true;
 }
 
-//-------------------------------------------------------------------------
-// HostTracker module
-//-------------------------------------------------------------------------
-
-//  FIXIT-M - Temporarily create new HostTracker module to test new
-//            HostTracker object.  May eventually replace old Hosts
-//            module with this one.
-
-class HostTrackerModule : public Module
-{
-public:
-    HostTrackerModule() : Module("host_tracker", hosts_help, hosts_params, true)
-    {
-        host = nullptr;
-    }
-
-    ~HostTrackerModule()
-    {
-        //  FIXIT-H: Change this back to an assert once we hand off the
-        //           host to a cache.
-        if (host)
-            delete host;
-    }
-
-    bool set(const char*, Value&, SnortConfig*) override;
-    bool begin(const char*, int, SnortConfig*) override;
-    bool end(const char*, int, SnortConfig*) override;
-
-private:
-    HostApplicationEntry app;
-    HostTracker* host;
-};
-
-bool HostTrackerModule::set(const char*, Value& v, SnortConfig*)
-{
-    if ( host and v.is("ip") )
-    {
-        sfip_t addr;
-        v.get_addr(addr);
-        host->set_ip_addr(addr);
-    }
-    else if ( host and v.is("frag_policy") )
-        host->set_frag_policy(v.get_long() + 1);
-
-    else if ( host and v.is("tcp_policy") )
-        host->set_stream_policy(v.get_long() + 1);
-
-    else if ( v.is("name") )
-        app.protocol = AddProtocolReference(v.get_string());
-
-    else if ( v.is("proto") )
-        app.ipproto = AddProtocolReference(v.get_string());
-
-    else if ( v.is("port") )
-        app.port = v.get_long();
-
-    else
-        return false;
-
-    return true;
-}
-
-bool HostTrackerModule::begin(const char* fqn, int idx, SnortConfig*)
-{
-    if ( idx && !strcmp(fqn, "host_tracker") )
-        host = new HostTracker;
-
-    return true;
-}
-
-bool HostTrackerModule::end(const char* fqn, int idx, SnortConfig*)
-{
-    if ( idx && !strcmp(fqn, "host_tracker.services") )
-    {
-        host->add_service(app);
-        memset(&app, 0, sizeof(app));
-    }
-    else if ( idx && !strcmp(fqn, "host_tracker") )
-    {
-        //  FIXIT-H: Next step will be to add the HostTracker object to
-        //  a cache.  For now just delete in the destructor.
-        //SFAT_AddHost(host);
-        //host = nullptr;
-    }
-
-    return true;
-}
 
 #if 0
 //-------------------------------------------------------------------------
index 3b78e77da312f330f4681d98f1f69c78c000d657..0334d7799ecbf391209206ff8675954f462a5f86 100644 (file)
@@ -7,12 +7,7 @@ sftarget_reader.h \
 sftarget_hostentry.cc \
 sftarget_hostentry.h \
 sftarget_data.h \
-host_tracker.h \
 snort_protocols.cc \
 snort_protocols.h
 
-if BUILD_UNIT_TESTS
-SUBDIRS = test
-endif
-