121
-- valgrind fixes
+-- basic reload restoration
120
-- tweaked --help!
FatalError("Could not AddProtocolReference!\n");
else if( id >= MAX_PROTOCOL_ORDINAL )
- LogMessage("protocol-ordinal=%d exceeds "
+ ParseWarning("protocol-ordinal=%d exceeds "
"limit of %d for service=%s\n",id,MAX_PROTOCOL_ORDINAL,srvc);
}
else if( id > 0 )
{
if( id < MAX_PROTOCOL_ORDINAL )
{
- LogMessage("adding protocol-ordinal=%d as service=%s\n",id,srvc);
+ //LogMessage("adding protocol-ordinal=%d as service=%s\n",id,srvc);
sopg[ id ] = pg;
}
else
- LogMessage("protocol-ordinal=%d exceeds "
+ ParseError("protocol-ordinal=%d exceeds "
"limit of %d for service=%s\n",id,MAX_PROTOCOL_ORDINAL,srvc);
}
else /* id < 0 */
{
- LogMessage("adding protocol-ordinal=%d for "
+ ParseError("adding protocol-ordinal=%d for "
"service=%s, can't use that !!!\n",id,srvc);
}
}
else
{
- LogMessage("*** failed to create and find a port group for '%s' !!! \n",srvc );
+ ParseError("*** failed to create and find a port group for '%s' !!! \n",srvc );
}
}
}
while ( fpl )
{
- if ( !fpl->context )
- continue;
-
- IpsOption* opt = (IpsOption*)fpl->context;
-
- if ( !strcmp(opt->get_name(), name) )
- return fpl->context;
+ if ( fpl->context )
+ {
+ IpsOption* opt = (IpsOption*)fpl->context;
+ if ( !strcmp(opt->get_name(), name) )
+ return fpl->context;
+ }
fpl = fpl->next;
}
return nullptr;
// FIXIT-L executing a command while paused
// will cause a resume
command = ac;
+ take_break();
return true;
}
if ( DAQ_Acquire(0, main_func, NULL) )
break;
- // FIXIT-M acquire(0) won't return until no packets, signal, etc.
+ // FIXIT-L acquire(0) won't return until no packets, signal, etc.
// which makes this idle unlikely to execute under high traffic
// conditions; that means the idle processing may not be useful
// or that we need a hook to do things periodically even when
bool execute(AnalyzerCommand);
void set_config(Swapper* ps) { swap = ps; };
- bool swap_pending() { return swap != nullptr; };
+ bool swap_pending() { return command == AC_SWAP; };
private:
void analyze();
*/
SetRuleStates(snort_conf);
- /* Need to do this after dynamic detection stuff is initialized, too */
- IpsManager::verify(snort_conf);
-
if (snort_conf->file_mask != 0)
umask(snort_conf->file_mask);
else
umask(077); /* set default to be sane */
+ /* Need to do this after dynamic detection stuff is initialized, too */
+ IpsManager::verify(snort_conf);
IpsManager::global_init(snort_conf);
+ ModuleManager::load_commands(snort_conf);
fpCreateFastPacketDetection(snort_conf);
MpseManager::activate_search_engine(snort_conf);
+
CodecManager::instantiate();
SFAT_Start();
/* Need to do this after dynamic detection stuff is initialized, too */
IpsManager::verify(sc);
+ ModuleManager::load_commands(snort_conf);
if ((sc->file_mask != 0) && (sc->file_mask != snort_conf->file_mask))
umask(sc->file_mask);
if ( snort_conf->pkt_cnt && pc.total_from_daq >= snort_conf->pkt_cnt )
DAQ_BreakLoop(-1);
+ if ( break_time() )
+ DAQ_BreakLoop(0);
+
MODULE_PROFILE_END(totalPerfStats);
return verdict;
}
return instance_max;
}
+//-------------------------------------------------------------------------
+// union rules
+//-------------------------------------------------------------------------
+
+static unsigned g_breaks = 0;
+static THREAD_LOCAL unsigned t_breaks = 0;
+
+void take_break()
+{ g_breaks++; }
+
+bool break_time()
+{
+ if ( t_breaks == g_breaks )
+ return false;
+
+ t_breaks = g_breaks;
+ return true;
+}
+
//-------------------------------------------------------------------------
// format is:
// <logdir>/[<run_prefix>][<id#>][<X>]<name>
SO_PUBLIC const char* get_instance_file(std::string&, const char* name);
+void take_break();
+bool break_time();
+
#endif
struct Actor
{
const ActionApi* api;
- IpsAction* act;
+ IpsAction* act; // FIXIT-H must move to SnortConfig for reload?
Actor(const ActionApi* p)
{ api = p; act = nullptr; };
for ( auto& p : s_actors )
if ( p.api == api )
{
- assert(!p.act);
+ //assert(!p.act); FIXIT-H memory leak on reload
p.act = act;
break;
}
struct DataBlock
{
const DataApi* api;
+
+ // FIXIT-H move data to snort config for reload
PlugData* data;
DataBlock(const DataApi* p)
void DataManager::release(PlugData* p)
{
DataBlock* b = get_data(p);
- assert(b && b->data);
+
+ // FIXIT-H this implementation can't reload
+ //assert(b && b->data);
+ if ( !b )
+ return;
b->data->rem_ref();
ModHook* mh = new ModHook(m, b);
s_modules.push_back(mh);
- if ( mh->reg )
- {
- SnortConfig* sc = snort_conf;
- sc->policy_map->get_shell()->install(m->get_name(), mh->reg);
- }
-
#ifdef PERF_PROFILING
RegisterProfile(m);
#endif
}
}
+void ModuleManager::load_commands(SnortConfig* sc)
+{
+ // FIXIT-L ideally only install commands from configured modules
+ // FIXIT-L install commands into working shell
+ Shell* sh = sc->policy_map->get_shell();
+
+ for ( auto p : s_modules )
+ {
+ if ( p->reg )
+ sh->install(p->mod->get_name(), p->reg);
+ }
+}
+
// FIXIT-L currently no way to know whether a module was activated or not
// so modules with common rules will cause duplicate sid warnings
// eg http_inspect and nhttp_inspect both have 119:1-34
static void show_rules(const char* = nullptr);
static void dump_rules(const char* = nullptr);
+ static void load_commands(SnortConfig*);
static void load_rules(SnortConfig*);
static void set_config(SnortConfig*);
static unsigned get_errors();
ArpSpoofModule::ArpSpoofModule() :
Module(MOD_NAME, MOD_HELP, s_params)
{
- config = new ArpSpoofConfig;
- config->check_overwrite = false;
+ config = nullptr;
}
ArpSpoofModule::~ArpSpoofModule()
return true;
}
+ArpSpoofConfig* ArpSpoofModule::get_config()
+{
+ ArpSpoofConfig* temp = config;
+ config = nullptr;
+ return temp;
+}
+
bool ArpSpoofModule::begin(const char*, int, SnortConfig*)
{
+ if ( !config )
+ {
+ config = new ArpSpoofConfig;
+ config->check_overwrite = false;
+ }
memset(&host, 0, sizeof(host));
return true;
}
bool begin(const char*, int, SnortConfig*);
bool end(const char*, int, SnortConfig*);
- ArpSpoofConfig* get_config()
- {
- ArpSpoofConfig* temp = config;
- config = nullptr;
- return temp;
- };
+ ArpSpoofConfig* get_config();
const char** get_pegs() const;
PegCount* get_counts() const;
/****************************************************************************
*
-** Copyright (C) 2014 Cisco and/or its affiliates. All rights reserved.
+ * Copyright (C) 2014 Cisco and/or its affiliates. All rights reserved.
* Copyright (C) 2005-2013 Sourcefire, Inc.
*
* This program is free software; you can redistribute it and/or modify
int IsAdaptiveConfigured()
{
- if ( !curr_cfg )
- return 0;
+ if ( curr_cfg || next_cfg )
+ return 1;
- return 1;
+ return 0;
}
void SFAT_UpdateApplicationProtocol(sfip_t *ipAddr, uint16_t port, uint16_t protocol, uint16_t id)