From: Eric Leblond Date: Tue, 15 Sep 2015 14:34:44 +0000 (+0200) Subject: output-json: add create header with tx function X-Git-Tag: suricata-3.0RC1~88 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=113d6a395020396d9d29e0ff7cb796caa85f9bc9;p=thirdparty%2Fsuricata.git output-json: add create header with tx function 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. --- diff --git a/src/output-json.c b/src/output-json.c index 74289f1b58..a8e5456351 100644 --- a/src/output-json.c +++ b/src/output-json.c @@ -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, diff --git a/src/output-json.h b/src/output-json.h index 1acde3e677..15c2829555 100644 --- a/src/output-json.h +++ b/src/output-json.h @@ -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 *);