]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
http2: set Debug on structs
authorVictor Julien <victor@inliniac.net>
Thu, 10 Jun 2021 19:03:31 +0000 (21:03 +0200)
committerPhilippe Antoine <contact@catenacyber.fr>
Mon, 6 Sep 2021 19:36:56 +0000 (21:36 +0200)
(cherry picked from commit 20e8f90981a1a0dca448b00c897c1c583513c25f)

rust/src/http2/decompression.rs
rust/src/http2/http2.rs
rust/src/http2/logger.rs
rust/src/http2/parser.rs

index 77173a612bdea9206ef479a04b83eef1ba6306d7..96dbd11e87feb0bf3b88794cb69216d6b1e8c372 100644 (file)
@@ -34,6 +34,7 @@ pub enum HTTP2ContentEncoding {
 }
 
 //a cursor turning EOF into blocking errors
+#[derive(Debug)]
 pub struct HTTP2cursor {
     pub cursor: Cursor<Vec<u8>>,
 }
@@ -78,6 +79,26 @@ pub enum HTTP2Decompresser {
     BROTLI(brotli::Decompressor<HTTP2cursor>),
 }
 
+impl std::fmt::Debug for HTTP2Decompresser {
+    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+        match self {
+            HTTP2Decompresser::UNASSIGNED => write!(f, "UNASSIGNED"),
+            HTTP2Decompresser::GZIP(_) => write!(f, "GZIP"),
+            HTTP2Decompresser::BROTLI(_) => write!(f, "BROTLI"),
+        }
+    }
+}
+impl std::fmt::Display for HTTP2Decompresser {
+    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+        match self {
+            HTTP2Decompresser::UNASSIGNED => write!(f, "UNASSIGNED"),
+            HTTP2Decompresser::GZIP(_) => write!(f, "GZIP"),
+            HTTP2Decompresser::BROTLI(_) => write!(f, "BROTLI"),
+        }
+    }
+}
+
+#[derive(Debug)]
 struct HTTP2DecoderHalf {
     encoding: HTTP2ContentEncoding,
     decoder: HTTP2Decompresser,
@@ -192,6 +213,7 @@ impl HTTP2DecoderHalf {
     }
 }
 
+#[derive(Debug)]
 pub struct HTTP2Decoder {
     decoder_tc: HTTP2DecoderHalf,
     decoder_ts: HTTP2DecoderHalf,
index c69e91bae9bd697e881afe1fa2f3dff9f2abfbaa..b2e62ec53ce48e6c2778bfabfe71a9ce2e310220 100644 (file)
@@ -84,6 +84,7 @@ pub struct HTTP2FrameUnhandled {
     pub reason: HTTP2FrameUnhandledReason,
 }
 
+#[derive(Debug)]
 pub enum HTTP2FrameTypeData {
     PRIORITY(parser::HTTP2FramePriority),
     GOAWAY(parser::HTTP2FrameGoAway),
@@ -114,11 +115,13 @@ pub enum HTTP2TransactionState {
     HTTP2StateGlobal = 8,
 }
 
+#[derive(Debug)]
 pub struct HTTP2Frame {
     pub header: parser::HTTP2FrameHeader,
     pub data: HTTP2FrameTypeData,
 }
 
+#[derive(Debug)]
 pub struct HTTP2Transaction {
     tx_id: u64,
     pub stream_id: u32,
index 3e254bf6bb14c329eafa3d8f2e86e9dbc6cc8cd3..7e15ffcaabd5ed0830b5e6c7c95bdae0a7bacf94 100644 (file)
@@ -21,7 +21,7 @@ use crate::jsonbuilder::{JsonBuilder, JsonError};
 use std;
 use std::collections::HashMap;
 
-#[derive(Hash, PartialEq, Eq)]
+#[derive(Hash, PartialEq, Eq, Debug)]
 enum HeaderName {
     Method,
     Path,
index 3054a5c436219f8fe6359b7056867e447f46016b..87e988389570f0707715c45f0d00eebf5f0b632d 100644 (file)
@@ -69,7 +69,7 @@ impl std::str::FromStr for HTTP2FrameType {
     }
 }
 
-#[derive(PartialEq)]
+#[derive(PartialEq, Debug)]
 pub struct HTTP2FrameHeader {
     //we could add detection on (GOAWAY) additional data
     pub length: u32,
@@ -142,7 +142,7 @@ impl std::str::FromStr for HTTP2ErrorCode {
     }
 }
 
-#[derive(Clone, Copy)]
+#[derive(Clone, Copy, Debug)]
 pub struct HTTP2FrameGoAway {
     pub errorcode: u32, //HTTP2ErrorCode
 }
@@ -154,7 +154,7 @@ named!(pub http2_parse_frame_goaway<HTTP2FrameGoAway>,
     )
 );
 
-#[derive(Clone, Copy)]
+#[derive(Clone, Copy, Debug)]
 pub struct HTTP2FrameRstStream {
     pub errorcode: u32, ////HTTP2ErrorCode
 }
@@ -166,7 +166,7 @@ named!(pub http2_parse_frame_rststream<HTTP2FrameRstStream>,
     )
 );
 
-#[derive(Clone, Copy)]
+#[derive(Clone, Copy, Debug)]
 pub struct HTTP2FramePriority {
     pub exclusive: u8,
     pub dependency: u32,
@@ -182,7 +182,7 @@ named!(pub http2_parse_frame_priority<HTTP2FramePriority>,
     )
 );
 
-#[derive(Clone, Copy)]
+#[derive(Clone, Copy, Debug)]
 pub struct HTTP2FrameWindowUpdate {
     pub reserved: u8,
     pub sizeinc: u32,
@@ -196,7 +196,7 @@ named!(pub http2_parse_frame_windowupdate<HTTP2FrameWindowUpdate>,
     )
 );
 
-#[derive(Clone, Copy)]
+#[derive(Clone, Copy, Debug)]
 pub struct HTTP2FrameHeadersPriority {
     pub exclusive: u8,
     pub dependency: u32,
@@ -600,7 +600,7 @@ fn http2_parse_headers_block<'a>(
     }
 }
 
-#[derive(Clone)]
+#[derive(Clone, Debug)]
 pub struct HTTP2FrameHeaders {
     pub padlength: Option<u8>,
     pub priority: Option<HTTP2FrameHeadersPriority>,
@@ -649,7 +649,7 @@ pub fn http2_parse_frame_headers<'a>(
     ));
 }
 
-#[derive(Clone)]
+#[derive(Clone, Debug)]
 pub struct HTTP2FramePushPromise {
     pub padlength: Option<u8>,
     pub reserved: u8,
@@ -690,7 +690,7 @@ pub fn http2_parse_frame_push_promise<'a>(
     ));
 }
 
-#[derive(Clone)]
+#[derive(Clone, Debug)]
 pub struct HTTP2FrameContinuation {
     pub blocks: Vec<HTTP2FrameHeaderBlock>,
 }
@@ -898,7 +898,7 @@ named!(pub detect_parse_u64<&str,DetectU64Data>,
     )
 );
 
-#[derive(Clone, Copy)]
+#[derive(Clone, Copy, Debug)]
 pub struct HTTP2FrameSettings {
     pub id: HTTP2SettingsId,
     pub value: u32,