void AppIdContext::pterm()
{
- if (odp_ctxt)
- {
- odp_ctxt->get_app_info_mgr().cleanup_appid_info_table();
- delete odp_ctxt;
- }
-
if (odp_thread_local_ctxt)
{
delete odp_thread_local_ctxt;
odp_thread_local_ctxt = nullptr;
}
+
+ if (odp_ctxt)
+ {
+ odp_ctxt->get_app_info_mgr().cleanup_appid_info_table();
+ delete odp_ctxt;
+ }
}
bool AppIdContext::init_appid(SnortConfig* sc, AppIdInspector& inspector)
odp_ctxt->get_service_disco_mgr().initialize(inspector);
odp_ctxt->set_client_and_service_detectors();
+ if (!appidDebug)
+ {
+ appidDebug = new AppIdDebug();
+ appidDebug->set_enabled(config.log_all_sessions);
+ }
+
odp_thread_local_ctxt->initialize(sc, *this, true);
odp_ctxt->initialize(inspector);
static void appid_inspector_tinit()
{
AppIdPegCounts::init_pegs();
- appidDebug = new AppIdDebug();
+ if (!appidDebug)
+ appidDebug = new AppIdDebug();
}
static void appid_inspector_tterm()
AppIdPegCounts::cleanup_pegs();
AppIdServiceState::clean();
delete appidDebug;
+ appidDebug = nullptr;
}
static Inspector* appid_inspector_ctor(Module* m)
return 0;
}
+static int detector_log_snort_message(lua_State* L)
+{
+ const auto& name = (*UserData<LuaObject>::check(L, DETECTOR, 1))->get_detector()->get_name();
+
+ unsigned int level = lua_tonumber(L, 2);
+ const char* message = lua_tostring(L, 3);
+
+ switch (level)
+ {
+ case LUA_LOG_CRITICAL:
+ appid_log(nullptr, TRACE_CRITICAL_LEVEL, "%s:%s\n", name.c_str(), message);
+ break;
+
+ case LUA_LOG_ERR:
+ appid_log(nullptr, TRACE_ERROR_LEVEL, "%s:%s\n", name.c_str(), message);
+ break;
+
+ case LUA_LOG_WARN:
+ appid_log(nullptr, TRACE_WARNING_LEVEL, "%s:%s\n", name.c_str(), message);
+ break;
+
+ case LUA_LOG_NOTICE:
+ case LUA_LOG_INFO:
+ if ( !appidDebug or !appidDebug->is_enabled() )
+ return 0;
+ appid_log(nullptr, TRACE_INFO_LEVEL, "AppIdDbg %s:%s\n", name.c_str(), message);
+ break;
+
+ case LUA_LOG_TRACE:
+ appid_log(init(L) ? nullptr : CURRENT_PACKET, TRACE_DEBUG_LEVEL, "%s:%s\n", name.c_str(), message);
+ break;
+
+ default:
+ break;
+ }
+
+ return 0;
+}
+
/** Add a netbios domain
* lua params:
* 1 - the netbios domain
{ "htons", detector_htons },
{ "htonl", detector_htonl },
{ "log", detector_log_message },
+ { "cLog", detector_log_snort_message},
{ "addHttpPattern", detector_add_http_pattern },
{ "addAppUrl", detector_add_url_application },
{ "addRTMPUrl", detector_add_rtmp_url },