return false;
}
requires_privileged_start = instance->can_start_unprivileged();
- analyzer = new Analyzer(instance, idx, source, sc->pkt_cnt);
+ analyzer = new Analyzer(instance, idx, source, sc->pkt_cnt, sc->retry_timeout);
analyzer->set_skip_cnt(sc->pkt_skip);
#ifdef REG_TEST
analyzer->set_pause_after_cnt(sc->pkt_pause_cnt);
public:
RetryQueue(unsigned interval_ms)
{
+ LogMessage("Retry queue interval is: %u ms\n", interval_ms);
assert(interval_ms > 0);
interval = { static_cast<time_t>(interval_ms / 1000), static_cast<suseconds_t>((interval_ms % 1000) * 1000) };
}
TraceApi::thread_term();
}
-Analyzer::Analyzer(SFDAQInstance* instance, unsigned i, const char* s, uint64_t msg_cnt) :
+Analyzer::Analyzer(SFDAQInstance* instance, unsigned i, const char* s, uint64_t msg_cnt, const uint32_t retry_timeout) :
id(i),
exit_after_cnt(msg_cnt),
source(s ? s : ""),
daq_instance(instance),
- retry_queue(new RetryQueue(200)),
+ retry_queue(new RetryQueue(retry_timeout)),
oops_handler(new OopsHandler())
{
set_state(State::NEW);
static void set_main_hook(MainHook_f);
Analyzer() = delete;
- Analyzer(snort::SFDAQInstance*, unsigned id, const char* source, uint64_t msg_cnt = 0);
+ Analyzer(snort::SFDAQInstance*, unsigned id, const char* source, uint64_t msg_cnt = 0, const uint32_t retry_timeout = 200);
~Analyzer();
void operator()(Swapper*, uint16_t run_num);
SoRules* so_rules = nullptr;
DumpConfigType dump_config_type = DUMP_CONFIG_NONE;
-
+ uint32_t retry_timeout = 200; // Milliseconds to hold packet on retry queue.
std::string dump_config_file;
std::thread* config_dumper = nullptr;
private:
{ "--process-all-events", Parameter::PT_IMPLIED, nullptr, nullptr,
"process all action groups" },
+ { "--retry-timeout", Parameter::PT_INT, "0:max32", "200",
+ "Number of milliseconds a packet stays in the retry queue before being reexamined" },
+
{ "--rule", Parameter::PT_STRING, nullptr, nullptr,
"<rules> to be added to configuration; may be repeated" },
else if ( is(v, "--process-all-events") )
sc->set_process_all_events(true);
+ else if ( is(v, "--retry-timeout") )
+ sc->retry_timeout = v.get_uint32();
+
else if ( is(v, "--rule") )
parser_append_rules(v.get_string());
void FileService::thread_init() { }
void FileService::thread_term() { }
void ErrorMessage(const char*,...) { }
-void LogMessage(const char*,...) { }
[[noreturn]] void FatalError(const char*,...) { exit(-1); }
void ParseWarning(WarningGroup, const char*, ...) { }
void HighAvailabilityManager::thread_init() { }
{ return 0; }
void ThreadConfig::update_thread_status(bool) {}
void ThreadConfig::kick_watchdog() {}
+
+// Mock the log function to copy the log message
+char captured_log[64];
+void LogMessage(const char* format, va_list& args)
+{
+ vsnprintf(captured_log, sizeof(captured_log),format, args);
+}
+void LogMessage(const char* format,...)
+{
+ va_list args;
+ va_start(args, format);
+ LogMessage(format, args);
+ va_end(args);
+}
}
const FlowCacheConfig& FlowControl::get_flow_cache_config() const
pkt.action = &active_action;
di = new SFDAQInstance(nullptr, 0, nullptr);
pkt.daq_instance = di;
- analyzer = new Analyzer(di, 0, nullptr);
+ analyzer = new Analyzer(di, 0, nullptr, 0, 40);
}
void teardown() override
mock().checkExpectations();
}
+TEST(distill_verdict_tests, logmessage_verify)
+{
+ STRCMP_EQUAL(captured_log, "Retry queue interval is: 40 ms\n");
+}
//-------------------------------------------------------------------------
// main
//-------------------------------------------------------------------------
sc->output_flags = cmd_line_conf->output_flags;
sc->tweaks = cmd_line_conf->tweaks;
sc->dump_config_type = cmd_line_conf->dump_config_type;
+ sc->retry_timeout = cmd_line_conf->retry_timeout;
sc->dump_config_file = cmd_line_conf->dump_config_file;
sc->pid_filename = cmd_line_conf->pid_filename;
sc->max_procs = cmd_line_conf->max_procs;