]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
quic: log version as string
authorVictor Julien <vjulien@oisf.net>
Fri, 14 Jan 2022 15:31:34 +0000 (16:31 +0100)
committerVictor Julien <vjulien@oisf.net>
Wed, 19 Jan 2022 13:10:50 +0000 (14:10 +0100)
Log as Q043, Q044, Q045, Q046. If the version is not supported/recognized,
log the 4 bytes as hex.

Only log for txs based on long headers.

rust/src/quic/logger.rs
rust/src/quic/parser.rs

index 619364ea6826116fb3440b053d38289bf3efad8d..98bcdd3689e94bfa88784bcf91e8b1b62a37a0de 100644 (file)
@@ -20,8 +20,9 @@ use crate::jsonbuilder::{JsonBuilder, JsonError};
 
 fn log_template(tx: &QuicTransaction, js: &mut JsonBuilder) -> Result<(), JsonError> {
     js.open_object("quic")?;
-    js.set_uint("version", u32::from(tx.header.version).into())?;
-
+    if tx.header.flags.is_long {
+        js.set_string("version", String::from(tx.header.version).as_str())?;
+    }
     js.open_array("cyu")?;
     for cyu in &tx.cyu {
         js.start_object()?;
index 7888e9c9956887fcc1b6716937a60a58b6e79e88..f4626563cd7cda9019d3bd337a94188a7b41ea57 100644 (file)
@@ -52,6 +52,17 @@ impl QuicVersion {
     }
 }
 
+impl From<QuicVersion> for String {
+    fn from(from: QuicVersion) -> Self {
+        match from {
+            QuicVersion(0x51303433) => "Q043".to_string(),
+            QuicVersion(0x51303434) => "Q044".to_string(),
+            QuicVersion(0x51303435) => "Q045".to_string(),
+            QuicVersion(0x51303436) => "Q046".to_string(),
+            QuicVersion(x) => format!("{:x}", x),
+        }
+    }
+}
 impl From<QuicVersion> for u32 {
     fn from(from: QuicVersion) -> Self {
         from.0