From: Victor Julien Date: Wed, 19 Feb 2014 11:52:03 +0000 (+0100) Subject: output-lua: support submodules X-Git-Tag: suricata-2.1beta2~162 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=95e0eae69af40f3fead22894b256d21817364a4a;p=thirdparty%2Fsuricata.git output-lua: support submodules Use the OutputCtx::submodules list to register additional log modules. Currently this is hardcoded to the 'lua' module. --- diff --git a/src/runmodes.c b/src/runmodes.c index 2546384a9c..847fadcb10 100644 --- a/src/runmodes.c +++ b/src/runmodes.c @@ -752,6 +752,37 @@ void RunModeInitializeOutputs(void) * main output ctx from which the sub-modules share the * LogFileCtx */ AddOutputToFreeList(module, output_ctx); + + } else if (strcmp(output->val, "lua") == 0) { + SCLogDebug("handle lua"); + + ConfNode *scripts = ConfNodeLookupChild(output_config, "scripts"); + BUG_ON(scripts == NULL); //TODO + + OutputModule *m; + TAILQ_FOREACH(m, &output_ctx->submodules, entries) { + SCLogDebug("m %p %s:%s", m, m->name, m->conf_name); + + ConfNode *script = NULL; + TAILQ_FOREACH(script, &scripts->head, next) { + SCLogDebug("script %s", script->val); + if (strcmp(script->val, m->conf_name) == 0) { + break; + } + } + BUG_ON(script == NULL); + + /* pass on parent output_ctx */ + OutputCtx *sub_output_ctx = + m->InitSubFunc(script, output_ctx); + if (sub_output_ctx == NULL) { + SCLogInfo("sub_output_ctx NULL, skipping"); + continue; + } + + SetupOutput(m->name, m, sub_output_ctx); + } + } else { AddOutputToFreeList(module, output_ctx); SetupOutput(module->name, module, output_ctx);