]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
eve: dnp3: respect global metadata config
authorJason Ish <ish@unx.ca>
Mon, 11 Dec 2017 21:49:45 +0000 (15:49 -0600)
committerVictor Julien <victor@inliniac.net>
Tue, 30 Jan 2018 13:43:51 +0000 (14:43 +0100)
src/output-json-dnp3.c

index 91f7689042dee5f3e86b163ae7f68ed8a6c23907..1fe73d3495c05362847f83d0bac36688e493f0b7 100644 (file)
@@ -50,6 +50,7 @@ typedef struct LogDNP3FileCtx_ {
     LogFileCtx *file_ctx;
     uint32_t    flags;
     uint8_t     include_object_data;
+    bool        include_metadata;
 } LogDNP3FileCtx;
 
 typedef struct LogDNP3LogThread_ {
@@ -315,6 +316,9 @@ static int JsonDNP3LoggerToServer(ThreadVars *tv, void *thread_data,
         if (unlikely(js == NULL)) {
             return TM_ECODE_OK;
         }
+        if (thread->dnp3log_ctx->include_metadata) {
+            JsonAddMetadata(p, f, js);
+        }
         json_t *dnp3js = JsonDNP3LogRequest(tx);
         if (dnp3js != NULL) {
             json_object_set_new(js, "dnp3", dnp3js);
@@ -341,6 +345,9 @@ static int JsonDNP3LoggerToClient(ThreadVars *tv, void *thread_data,
         if (unlikely(js == NULL)) {
             return TM_ECODE_OK;
         }
+        if (thread->dnp3log_ctx->include_metadata) {
+            JsonAddMetadata(p, f, js);
+        }
         json_t *dnp3js = JsonDNP3LogResponse(tx);
         if (dnp3js != NULL) {
             json_object_set_new(js, "dnp3", dnp3js);
@@ -365,13 +372,14 @@ static void OutputDNP3LogDeInitCtxSub(OutputCtx *output_ctx)
 static OutputInitResult OutputDNP3LogInitSub(ConfNode *conf, OutputCtx *parent_ctx)
 {
     OutputInitResult result = { NULL, false };
-    OutputJsonCtx *ajt = parent_ctx->data;
+    OutputJsonCtx *json_ctx = parent_ctx->data;
 
     LogDNP3FileCtx *dnp3log_ctx = SCCalloc(1, sizeof(*dnp3log_ctx));
     if (unlikely(dnp3log_ctx == NULL)) {
         return result;
     }
-    dnp3log_ctx->file_ctx = ajt->file_ctx;
+    dnp3log_ctx->file_ctx = json_ctx->file_ctx;
+    dnp3log_ctx->include_metadata = json_ctx->include_metadata;
 
     OutputCtx *output_ctx = SCCalloc(1, sizeof(*output_ctx));
     if (unlikely(output_ctx == NULL)) {