From: Eric Leblond Date: Thu, 30 Apr 2015 11:28:49 +0000 (+0200) Subject: smtp-json: introduce function to output smtp data X-Git-Tag: suricata-3.0RC1~119 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=47a199ee978608ba4351c40f48c00833bdc3b6c6;p=thirdparty%2Fsuricata.git smtp-json: introduce function to output smtp data --- diff --git a/src/output-json-smtp.c b/src/output-json-smtp.c index 9ebebca7e4..255209571c 100644 --- a/src/output-json-smtp.c +++ b/src/output-json-smtp.c @@ -54,7 +54,7 @@ #ifdef HAVE_LIBJANSSON #include -static json_t *JsonSmtpDataLogger(ThreadVars *tv, void *thread_data, const Packet *p, Flow *f, void *state, void *vtx, uint64_t tx_id) +static json_t *JsonSmtpDataLogger(const Flow *f, void *state, void *vtx, uint64_t tx_id) { json_t *sjs = json_object(); SMTPTransaction *tx = vtx; @@ -97,7 +97,7 @@ static int JsonSmtpLogger(ThreadVars *tv, void *thread_data, const Packet *p, Fl /* reset */ MemBufferReset(buffer); - sjs = JsonSmtpDataLogger(tv, thread_data, p, f, state, tx, tx_id); + sjs = JsonSmtpDataLogger(f, state, tx, tx_id); if (sjs) { json_object_set_new(js, "smtp", sjs); } @@ -117,6 +117,21 @@ static int JsonSmtpLogger(ThreadVars *tv, void *thread_data, const Packet *p, Fl } +json_t *JsonSMTPAddMetadata(const Flow *f) +{ + SMTPState *smtp_state = (SMTPState *)FlowGetAppState(f); + if (smtp_state) { + uint64_t tx_id = AppLayerParserGetTransactionLogId(f->alparser); + SMTPTransaction *tx = AppLayerParserGetTx(IPPROTO_TCP, ALPROTO_SMTP, smtp_state, tx_id); + + if (tx) { + return JsonSmtpDataLogger(f, smtp_state, tx, tx_id); + } + } + + return NULL; +} + static void OutputSmtpLogDeInitCtx(OutputCtx *output_ctx) { OutputJsonEmailCtx *email_ctx = output_ctx->data; diff --git a/src/output-json-smtp.h b/src/output-json-smtp.h index d38187c706..5b3233abca 100644 --- a/src/output-json-smtp.h +++ b/src/output-json-smtp.h @@ -25,5 +25,8 @@ #define __OUTPUT_JSON_SMTP_H__ void TmModuleJsonSmtpLogRegister (void); +#ifdef HAVE_LIBJANSSON +json_t *JsonSMTPAddMetadata(const Flow *f); +#endif #endif /* __OUTPUT_JSON_SMTP_H__ */