]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
output-json: add create header with tx function
authorEric Leblond <eric@regit.org>
Tue, 15 Sep 2015 14:34:44 +0000 (16:34 +0200)
committerEric Leblond <eric@regit.org>
Tue, 6 Oct 2015 21:30:46 +0000 (23:30 +0200)
To be able to correlate between events, it is better to have the
tx_id information in the root object. This function adds a new
function to automate the addition of the field.

src/output-json.c
src/output-json.h

index 74289f1b58542ec6a83718b262146fb089673be5..a8e5456351d118bb896716589c217f23588d4d7b 100644 (file)
@@ -327,6 +327,18 @@ json_t *CreateJSONHeader(Packet *p, int direction_sensitive, char *event_type)
     return js;
 }
 
+json_t *CreateJSONHeaderWithTxId(Packet *p, int direction_sensitive, char *event_type, uint32_t tx_id)
+{
+    json_t *js = CreateJSONHeader(p, direction_sensitive, event_type);
+    if (unlikely(js == NULL))
+        return NULL;
+
+    /* tx id for correlation with other events */
+    json_object_set_new(js, "tx_id", json_integer(tx_id));
+
+    return js;
+}
+
 int OutputJSONBuffer(json_t *js, LogFileCtx *file_ctx, MemBuffer *buffer)
 {
     char *js_s = json_dumps(js,
index 1acde3e67792d826e5401e402c1e358f452e6a72..15c2829555c2ce5813ba7c9c37d5e2191987c138 100644 (file)
@@ -35,6 +35,7 @@ void TmModuleOutputJsonRegister (void);
 void CreateJSONFlowId(json_t *js, const Flow *f);
 void JsonTcpFlags(uint8_t flags, json_t *js);
 json_t *CreateJSONHeader(Packet *p, int direction_sensative, char *event_type);
+json_t *CreateJSONHeaderWithTxId(Packet *p, int direction_sensitive, char *event_type, uint32_t tx_id);
 TmEcode OutputJSON(json_t *js, void *data, uint64_t *count);
 int OutputJSONBuffer(json_t *js, LogFileCtx *file_ctx, MemBuffer *buffer);
 OutputCtx *OutputJsonInitCtx(ConfNode *);