00001 //--------------------------------------------------------------------------
00002 // Copyright (C) 2016-2017 Cisco and/or its affiliates. All rights reserved.
00003 //
00004 // This program is free software; you can redistribute it and/or modify it
00005 // under the terms of the GNU General Public License Version 2 as published
00006 // by the Free Software Foundation. You may not use, modify or distribute
00007 // this program under any other version of the GNU General Public License.
00008 //
00009 // This program is distributed in the hope that it will be useful, but
00010 // WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00012 // General Public License for more details.
00013 //
00014 // You should have received a copy of the GNU General Public License along
00015 // with this program; if not, write to the Free Software Foundation, Inc.,
00016 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00017 //--------------------------------------------------------------------------
00018 // analyzer_command.cc author Michael Altizer <mialtize@cisco.com>
00019
00020 #ifdef HAVE_CONFIG_H
00021 #include "config.h"
00022 #endif
00023
00024 #include "analyzer_command.h"
00025
00026 #include <cassert>
00027
00028 #include "log/messages.h"
00029 #include "managers/module_manager.h"
00030 #include "utils/stats.h"
00031
00032 #include "analyzer.h"
00033 #include "snort.h"
00034 #include "snort_config.h"
00035 #include "swapper.h"
00036
00037 void ACStart::execute(Analyzer& analyzer)
00038 {
00039 analyzer.start();
00040 }
00041
00042 void ACRun::execute(Analyzer& analyzer)
00043 {
00044 analyzer.run(paused);
00045 paused = false;
00046 }
00047
00048 void ACStop::execute(Analyzer& analyzer)
00049 {
00050 analyzer.stop();
00051 }
00052
00053 void ACPause::execute(Analyzer& analyzer)
00054 {
00055 analyzer.pause();
00056 }
00057
00058 void ACResume::execute(Analyzer& analyzer)
00059 {
00060 analyzer.resume();
00061 }
00062
00063 void ACRotate::execute(Analyzer&)
00064 {
00065 Snort::thread_rotate();
00066 }
00067
00068 void ACGetStats::execute(Analyzer&)
00069 {
00070 // FIXIT-P This incurs locking on all threads to retrieve stats. It could be reimplemented to
00071 // optimize for large thread counts by retrieving stats in the command and accumulating in the
00072 // main thread.
00073 ModuleManager::accumulate(snort_conf);
00074 }
00075
00076 ACGetStats::~ACGetStats()
00077 {
00078 // FIXIT-L This should track the owner so it can dump stats to the shell instead of the logs
00079 // when initiated by a shell command
00080 DropStats();
00081 }
00082
00083 ACSwap::ACSwap(Swapper* ps) : ps(ps)
00084 {
00085 assert(Swapper::get_reload_in_progress() == false);
00086 Swapper::set_reload_in_progress(true);
00087 }
00088
00089 void ACSwap::execute(Analyzer&)
00090 {
00091 if (ps)
00092 ps->apply();
00093 }
00094
00095 ACSwap::~ACSwap()
00096 {
00097 delete ps;
00098 Swapper::set_reload_in_progress(false);
00099 LogMessage("== reload complete\n");
00100 }
00101
00102 void ACDAQSwap::execute(Analyzer& analyzer)
00103 {
00104 analyzer.reload_daq();
00105 }
00106
00107 ACDAQSwap::~ACDAQSwap()
00108 {
00109 LogMessage("== daq module reload complete\n");
00110 }
00111
END OF CODE