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 \
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 \
framework \
hash \
helpers \
+host_tracker \
lua \
ips_options \
log \
--- /dev/null
+
+add_library( host_tracker STATIC
+ host_module.cc
+ host_module.h
+ host_tracker.h
+)
--- /dev/null
+
+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
+
+
--- /dev/null
+//--------------------------------------------------------------------------
+// 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;
+}
+
--- /dev/null
+//--------------------------------------------------------------------------
+// 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
+
// 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>
#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
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
//-------------------------------------------------------------------------
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
-