ips_replace
-- stream workarounds for new packet / protocol foo and shutdown sequencing
-- fixed end of rule parsing to not require ; and recognize incomplete rules
+-- fixed executing a command wile paused
112
-- initial action plugin - reject
// FIXIT make these non-blocking
// FIXIT allow at least 2 remote controls
+// FIXIT bind to configured ip including INADDR_ANY
+// (default is loopback if enabled)
static int listener = -1;
static int remote_control = -1;
listener = socket(AF_INET, SOCK_STREAM, 0);
if (listener < 0)
+ {
+ FatalError("socket failed: %s\n", strerror(errno));
return -2;
+ }
+
+ // FIXIT does this disable time wait for us?
+ int on = 1;
+ setsockopt(listener, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on));
struct sockaddr_in addr;
memset(&addr, 0, sizeof(addr));
addr.sin_family = AF_INET;
- addr.sin_addr.s_addr = INADDR_ANY;
+ addr.sin_addr.s_addr = htonl(0x7F000001);
addr.sin_port = htons(snort_conf->remote_control);
if ( ::bind(listener, (struct sockaddr*)&addr, sizeof(addr)) < 0 )
+ {
+ FatalError("bind failed: %s\n", strerror(errno));
return -3;
+ }
// FIXIT configure max conns
if ( listen(listener, 5) < 0 )
+ {
+ FatalError("listen failed: %s\n", strerror(errno));
return -4;
+ }
return 0;
}
return false;
}
+ if ( snort_conf->run_flags & RUN_FLAG__PAUSE )
+ {
+ LogMessage("Paused; resume to start packet processing\n");
+ paused = true;
+ }
+ else
+ LogMessage("Commencing packet processing\n");
+
if ( snort_conf->run_flags & RUN_FLAG__SHELL )
{
LogMessage("Entering command shell\n");
request.show_prompt();
}
- if ( snort_conf->run_flags & RUN_FLAG__PAUSE )
- paused = true;
- else
- LogMessage("Commencing packet processing\n");
-
return true;
}
done = true;
}
+bool Analyzer::execute(AnalyzerCommand ac)
+{
+ if ( command && command != AC_PAUSE )
+ return false;
+
+ // FIXIT executing a command while paused
+ // will cause a resume
+ command = ac;
+ return true;
+}
+
+// clear pause in analyze() to avoid extra acquires
+// (eg stop while paused)
+// clear other commands here to avoid clearing an
+// unexecuted command received while paused
bool Analyzer::handle(AnalyzerCommand ac)
{
switch ( ac )
case AC_PAUSE:
{
- chrono::seconds sec(1);
- this_thread::sleep_for(sec);
+ chrono::milliseconds ms(500);
+ this_thread::sleep_for(ms);
}
break;
case AC_RESUME:
+ command = AC_NONE;
break;
case AC_ROTATE:
snort_rotate();
+ command = AC_NONE;
break;
case AC_SWAP:
swap->apply();
swap = nullptr;
}
+ command = AC_NONE;
break;
default:
if ( command == AC_PAUSE )
continue;
-
- command = AC_NONE;
}
if ( DAQ_Acquire(0, main_func, NULL) )
break;
const char* get_source() { return source; };
// FIXIT add asynchronous response too
- void execute(AnalyzerCommand ac) { command = ac; };
+ bool execute(AnalyzerCommand);
+
void set_config(Swapper* ps) { swap = ps; };
bool swap_pending() { return swap != nullptr; };
bool done;
uint64_t count;
const char* source;
- AnalyzerCommand command;
+ volatile AnalyzerCommand command;
Swapper* swap;
};
"dump the raw packet data starting at the link layer" },
{ "x", config_conf_error_out,
- "exit on misconfiguration (same as --conf-error-out)" },
+ "same as --conf-error-out" },
{ "y", ConfigShowYear,
"include year in timestamp in the alert and log files" },
"<filter options> are standard BPF options, as seen in TCPDump" },
{ "conf-error-out", config_conf_error_out,
- "exit if certain Snort configuration problems occur (same as -x)" },
+ "output error instead of warning if duplicate rules are found (same as -x)" },
{ "create-pidfile", ConfigCreatePidFile,
"create PID file, even when not in Daemon mode" },
"list all known modules" },
{ "list-plugins", list_plugins,
- "list all known modules" },
+ "list all known plugins" },
{ "lua", config_lua,
"<chunk> extend/override conf with chunk; may be repeated" },