-- made some packet data available to alert_luajit
-- fixed flow init when not bound
-- tweaked stats output - no section if all counts zero
+-- fixed pause/resume
122
-- pulled thread pinning from Josh
static int exit_logged = 0;
static bool paused = false;
+static bool pause_enabled = false;
+static bool shell_enabled = false;
+
const struct timespec main_sleep = { 0, 100000000 }; // 0.1 sec
static const char* prompt = "o\")~ ";
+const char* get_prompt()
+{ return prompt; }
+
//-------------------------------------------------------------------------
// swap foo
//-------------------------------------------------------------------------
FD_ZERO(&inputs);
int max_fd = -1;
- if ( snort_conf->run_flags & RUN_FLAG__SHELL )
+ if ( shell_enabled )
{
FD_SET(STDIN_FILENO, &inputs);
max_fd = STDIN_FILENO;
if ( snort_conf->run_flags & RUN_FLAG__PAUSE )
{
LogMessage("Paused; resume to start packet processing\n");
- paused = true;
+ paused = pause_enabled = true;
}
else
LogMessage("Commencing packet processing\n");
if ( snort_conf->run_flags & RUN_FLAG__SHELL )
{
LogMessage("Entering command shell\n");
+ shell_enabled = true;
request.set(STDOUT_FILENO, "");
request.show_prompt();
}
if ( paused || Trough_Next() )
return true;
- if ( snort_conf->run_flags & RUN_FLAG__PAUSE )
+ if ( pause_enabled )
{
LogMessage("== pausing\n");
- snort_conf->run_flags &= ~RUN_FLAG__PAUSE;
+ pause_enabled = false;
paused = true;
return true;
}
unsigned idx = max_pigs, swine = 0;
init_main_thread_sig();
- while ( !exit_logged && (dont_stop() || swine) )
+ while ( !exit_logged && (swine || dont_stop()) )
{
if ( ++idx >= max_pigs )
idx = 0;
struct lua_State;
+const char* get_prompt();
+
int main_dump_plugins(lua_State* = nullptr);
int main_dump_stats(lua_State* = nullptr);
int main_rotate_stats(lua_State* = nullptr);
break;
case AC_ROTATE:
- snort_rotate();
+ snort_thread_rotate();
command = AC_NONE;
break;
// conditions; that means the idle processing may not be useful
// or that we need a hook to do things periodically even when
// traffic is available
- snort_idle();
+ snort_thread_idle();
}
}
#include "ips_options/ips_flowbits.h"
#include "event_queue.h"
#include "framework/mpse.h"
+#include "main.h"
#include "main/build.h"
#include "main/snort_config.h"
#include "main/shell.h"
snort_conf = snort_cmd_line_conf;
LogMessage("--------------------------------------------------\n");
- LogMessage("o\")~ Snort++ %s-%s\n", VERSION, BUILD);
+ LogMessage("%s Snort++ %s-%s\n", get_prompt(), VERSION, BUILD);
LogMessage("--------------------------------------------------\n");
ModuleManager::init();
SnortCleanup();
snort_conf = &tmp;
- LogMessage("Snort exiting\n");
+ LogMessage("%s Snort exiting\n", get_prompt());
closelog();
}
return verdict;
}
-void snort_idle()
+void snort_thread_idle()
{
if ( flow_con )
flow_con->timeout_flows(16384, time(NULL));
pc.idle++;
}
-void snort_rotate()
+void snort_thread_rotate()
{
SetRotatePerfFileFlag();
}
void snort_thread_init(const char* intf);
void snort_thread_term();
-void snort_idle();
-void snort_rotate();
+void snort_thread_idle();
+void snort_thread_rotate();
void CapturePacket();
void DecodeRebuiltPacket (Packet*, const DAQ_PktHdr_t*, const uint8_t* pkt, Flow*);
if ( !h || (h->api && h->api->type == PT_IPS_OPTION) )
return false;
+ //printf("open %s %d\n", s, idx);
Module* m = h->mod;
if (strcmp(m->get_name(), s))
string key = fqn;
set_top(key);
+ //printf("close %s %d\n", s, idx);
+
if ( ModHook* h = get_hook(key.c_str()) )
{
if ( !h->mod->end(s, idx, s_config) )
SO_PUBLIC bool set_bool(const char* fqn, bool b)
{
+ //printf("bool %s %d\n", fqn, b);
Value v(b);
return set_value(fqn, v);
}
SO_PUBLIC bool set_number(const char* fqn, double d)
{
+ //printf("real %s %f\n", fqn, d);
Value v(d);
return set_value(fqn, v);
}
SO_PUBLIC bool set_string(const char* fqn, const char* s)
{
+ //printf("string %s %s\n", fqn, s);
Value v(s);
return set_value(fqn, v);
}