From: Eric Leblond Date: Fri, 24 Jan 2025 13:44:34 +0000 (+0100) Subject: eve/netflow: add tx_cnt X-Git-Tag: suricata-8.0.0-rc1~458 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=668c6d646e9575a95d2a692658c72d9533f89d28;p=thirdparty%2Fsuricata.git eve/netflow: add tx_cnt This patch adds a `tx_cnt` field to `netflow` events to give some context about the underlying protocol activity. Ticket: #7635 --- diff --git a/etc/schema.json b/etc/schema.json index 0bdb0178c5..774bf36df5 100644 --- a/etc/schema.json +++ b/etc/schema.json @@ -3493,6 +3493,9 @@ }, "start": { "type": "string" + }, + "tx_cnt": { + "type": "integer" } }, "additionalProperties": false diff --git a/src/output-json-netflow.c b/src/output-json-netflow.c index 6a2bb7ff17..b577571d6c 100644 --- a/src/output-json-netflow.c +++ b/src/output-json-netflow.c @@ -24,6 +24,7 @@ */ #include "suricata-common.h" +#include "app-layer-parser.h" #include "detect.h" #include "pkt-var.h" #include "conf.h" @@ -198,6 +199,13 @@ static void NetFlowLogEveToServer(SCJsonBuilder *js, Flow *f) SCJbSetUint(js, "min_ttl", f->min_ttl_toserver); SCJbSetUint(js, "max_ttl", f->max_ttl_toserver); + if (f->alstate) { + uint64_t tx_id = AppLayerParserGetTxCnt(f, f->alstate); + if (tx_id) { + SCJbSetUint(js, "tx_cnt", tx_id); + } + } + /* Close netflow. */ SCJbClose(js); @@ -244,6 +252,13 @@ static void NetFlowLogEveToClient(SCJsonBuilder *js, Flow *f) SCJbSetUint(js, "max_ttl", f->max_ttl_toclient); } + if (f->alstate) { + uint64_t tx_id = AppLayerParserGetTxCnt(f, f->alstate); + if (tx_id) { + SCJbSetUint(js, "tx_cnt", tx_id); + } + } + /* Close netflow. */ SCJbClose(js);