json-smtp: add tx_id param to metadata generation

In all metadata generation contexts we know the tx_id so we better
used it to log the correct transaction and not an other one.
pull/1671/head
Eric Leblond 11 years ago
parent 0ef0f1d526
commit d9b602fc0f

@ -246,7 +246,7 @@ static int AlertJson(ThreadVars *tv, JsonAlertLogThread *aft, const Packet *p)
/* http alert */
if (proto == ALPROTO_SMTP) {
hjs = JsonSMTPAddMetadata(p->flow);
hjs = JsonSMTPAddMetadata(p->flow, pa->tx_id);
if (hjs)
json_object_set_new(js, "smtp", hjs);
}

@ -99,7 +99,7 @@ static void FileWriteJsonRecord(JsonFileLogThread *aft, const Packet *p, const F
json_object_set_new(js, "http", hjs);
break;
case ALPROTO_SMTP:
hjs = JsonSMTPAddMetadata(p->flow);
hjs = JsonSMTPAddMetadata(p->flow, ff->txid);
if (hjs)
json_object_set_new(js, "smtp", hjs);
hjs = JsonEmailAddMetadata(p->flow);

@ -117,11 +117,10 @@ static int JsonSmtpLogger(ThreadVars *tv, void *thread_data, const Packet *p, Fl
}
json_t *JsonSMTPAddMetadata(const Flow *f)
json_t *JsonSMTPAddMetadata(const Flow *f, uint64_t tx_id)
{
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) {

@ -26,7 +26,7 @@
void TmModuleJsonSmtpLogRegister (void);
#ifdef HAVE_LIBJANSSON
json_t *JsonSMTPAddMetadata(const Flow *f);
json_t *JsonSMTPAddMetadata(const Flow *f, uint64_t tx_id);
#endif
#endif /* __OUTPUT_JSON_SMTP_H__ */

Loading…
Cancel
Save