]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
output-lua: support submodules
authorVictor Julien <victor@inliniac.net>
Wed, 19 Feb 2014 11:52:03 +0000 (12:52 +0100)
committerVictor Julien <victor@inliniac.net>
Fri, 15 Aug 2014 11:58:24 +0000 (13:58 +0200)
Use the OutputCtx::submodules list to register additional log modules.
Currently this is hardcoded to the 'lua' module.

src/runmodes.c

index 2546384a9cb898038b6018eb5894932224793cc5..847fadcb107045ab0026e2a157a2f3caed98ed46 100644 (file)
@@ -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);