#include "framework/ips_action.h"
#include "framework/module.h"
#include "log/messages.h"
+#include "main/snort_config.h"
#include "packet_io/active.h"
#include "profiler/profiler.h"
#include "protocols/packet.h"
return true;
}
-bool ReactModule::begin(const char*, int, SnortConfig*)
+bool ReactModule::begin(const char*, int, SnortConfig* sc)
{
page.clear();
+ sc->set_active_enabled();
return true;
}
{
ReactModule* m = (ReactModule*)p;
ReactData* rd = new ReactData(m->page);
- Active::set_enabled();
return new ReactAction(rd);
}
#include "framework/ips_action.h"
#include "framework/module.h"
+#include "main/snort_config.h"
#include "packet_io/active.h"
#include "profiler/profiler.h"
uint32_t flags;
};
-bool RejectModule::begin(const char*, int, SnortConfig*)
+bool RejectModule::begin(const char*, int, SnortConfig* sc)
{
flags = 0;
+ sc->set_active_enabled();
return true;
}
static IpsAction* rej_ctor(Module* p)
{
RejectModule* m = (RejectModule*)p;
- Active::set_enabled();
return new RejectAction(m->flags);
}
#include "detection/detection_engine.h"
#include "framework/ips_action.h"
#include "framework/module.h"
+#include "main/snort_config.h"
#include "packet_io/active.h"
#include "protocols/packet.h"
ReplaceModule() : Module(s_name, s_help, s_params) { }
bool set(const char*, Value&, SnortConfig*) override;
bool begin(const char*, int, SnortConfig*) override;
- bool end(const char*, int, SnortConfig*) override;
Usage get_usage() const override
{ return DETECT; }
return true;
}
-bool ReplaceModule::begin(const char*, int, SnortConfig*)
+bool ReplaceModule::begin(const char*, int, SnortConfig* sc)
{
disable_replace = false;
- return true;
-}
-
-bool ReplaceModule::end(const char*, int, SnortConfig*)
-{
+ sc->set_active_enabled();
return true;
}
IpsAction(s_name, ACT_RESET)
{
disable_replace = dr;
- Active::set_enabled();
}
void ReplaceAction::exec(Packet* p)
return true;
}
-bool FileIdModule::end(const char* fqn, int idx, SnortConfig*)
+bool FileIdModule::end(const char* fqn, int idx, SnortConfig* sc)
{
if (!idx)
{
if ( need_active )
- Active::set_enabled();
+ sc->set_active_enabled();
return true;
}
sc->set_dst_mac(v.get_string());
else if ( v.is("max_responses") )
+ {
sc->max_responses = v.get_uint8();
+ if ( sc->max_responses )
+ sc->set_active_enabled();
+ }
+
else if ( v.is("min_interval") )
sc->min_interval = v.get_uint8();
parser_term(sc);
- Active::init(sc);
-
LogMessage("%s\n", LOG_DIV);
SFDAQ::init(sc->daq_config, ThreadConfig::get_instance_max());
Plugins* plugins = nullptr;
SoRules* so_rules = nullptr;
private:
+ bool active_enabled = false;
std::list<ReloadResourceTuner*> reload_tuners;
public:
bool assure_established() const
{ return run_flags & RUN_FLAG__ASSURE_EST; }
+ // active stuff
+ void set_active_enabled()
+ { active_enabled = true; }
+
+ bool is_active_enabled() const
+ { return active_enabled; }
+
// other stuff
uint8_t min_ttl() const
{ return get_network_policy()->min_ttl; }
{ "block", "cant_block", "would_block", "force_block" },
{ "reset", "cant_reset", "would_reset", "force_reset" },
};
-bool Active::enabled = false;
THREAD_LOCAL uint8_t Active::s_attempts = 0;
THREAD_LOCAL bool Active::s_suspend = false;
//--------------------------------------------------------------------
-void Active::init(SnortConfig* sc)
-{
- if (sc->max_responses > 0)
- Active::set_enabled();
-}
-
bool Active::thread_init(const SnortConfig* sc)
{
s_attempts = sc->respond_attempts;
if ( s_attempts > MAX_ATTEMPTS )
s_attempts = MAX_ATTEMPTS;
- if ( enabled && !s_attempts )
+ if ( sc->is_active_enabled() && !s_attempts )
s_attempts = 1;
- if ( enabled && (!SFDAQ::can_inject() || !sc->respond_device.empty()) )
+ if ( sc->is_active_enabled() && (!SFDAQ::can_inject() || !sc->respond_device.empty()) )
{
if ( sc->read_mode() || !open(sc->respond_device.c_str()) )
{
if ( force or p->context->conf->inline_mode() or p->context->conf->treat_drop_as_ignore() )
Stream::drop_flow(p);
- if ( enabled )
+ if ( p->context->conf->is_active_enabled() )
{
if (reject)
Active::queue(reject, p);
public:
- static void init(SnortConfig*);
static bool thread_init(const SnortConfig*);
static void thread_term();
- static void set_enabled(bool on_off = true)
- { enabled = on_off; }
-
static void suspend()
{ s_suspend = true; }
private:
static const char* act_str[ACT_MAX][AST_MAX];
- static bool enabled;
static THREAD_LOCAL uint8_t s_attempts;
static THREAD_LOCAL bool s_suspend;
#include "smtp_module.h"
+#include "main/snort_config.h"
#include "log/messages.h"
#include "packet_io/active.h"
#include "utils/util.h"
}
else if ( v.is("xlink2state") )
- {
config->xlink2state = (SMTPXlinkState)v.get_uint8();
- Active::set_enabled();
- }
else
return false;
return true;
}
-bool SmtpModule::end(const char* fqn, int idx, SnortConfig*)
+bool SmtpModule::end(const char* fqn, int idx, SnortConfig* sc)
{
+ if ( !strcmp(fqn, "smtp") and config->xlink2state )
+ sc->set_active_enabled();
+
if ( !idx )
return true;