]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
eve: add ip version field 13201/head
authorJuliana Fajardini <jufajardini@oisf.net>
Thu, 8 May 2025 19:00:48 +0000 (16:00 -0300)
committerVictor Julien <victor@inliniac.net>
Fri, 9 May 2025 05:50:43 +0000 (07:50 +0200)
Adds the field `ip_v` (integer) to the common fields of EVE.
To facilitate searches based on IP version, for instance.

Task #7047

etc/schema.json
src/output-json-flow.c
src/output-json.c

index 4919a8f7fa02424ad3bd44b5448060d2d6c466e0..57624ec066a255ba2c1829d88a83c9060c27d557 100644 (file)
         "in_iface": {
             "type": "string"
         },
+        "ip_v": {
+            "type": "integer",
+            "description": "IP version of the packet or flow"
+        },
         "log_level": {
             "type": "string"
         },
index 91fcf34bb535c105f928411af0fa1e252afff275..a57160c602b55d3f78ae0f6ff3bcb95d8f89caaa 100644 (file)
@@ -143,6 +143,13 @@ static SCJsonBuilder *CreateEveHeaderFromFlow(const Flow *f)
             break;
     }
 
+    /* ip version */
+    if (FLOW_IS_IPV4(f)) {
+        SCJbSetUint(jb, "ip_v", 4);
+    } else if (FLOW_IS_IPV6(f)) {
+        SCJbSetUint(jb, "ip_v", 6);
+    }
+
     if (SCProtoNameValid(f->proto)) {
         SCJbSetString(jb, "proto", known_proto[f->proto]);
     } else {
index 3c39d72bde20c3abb76d236a35994062d230f505..512274eeb59f4779fbd98212f530798039ea940c 100644 (file)
@@ -902,6 +902,13 @@ SCJsonBuilder *CreateEveHeader(const Packet *p, enum SCOutputJsonLogDirection di
         SCJbSetString(js, "proto", addr->proto);
     }
 
+    /* ip version */
+    if (PacketIsIPv4(p)) {
+        SCJbSetUint(js, "ip_v", 4);
+    } else if (PacketIsIPv6(p)) {
+        SCJbSetUint(js, "ip_v", 6);
+    }
+
     /* icmp */
     switch (p->proto) {
         case IPPROTO_ICMP: