From: Victor Julien Date: Thu, 10 Jun 2021 19:03:31 +0000 (+0200) Subject: http2: set Debug on structs X-Git-Tag: suricata-6.0.4~78 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b46b2936f200839f7aedf80c586ee9c91d532efb;p=thirdparty%2Fsuricata.git http2: set Debug on structs (cherry picked from commit 20e8f90981a1a0dca448b00c897c1c583513c25f) --- diff --git a/rust/src/http2/decompression.rs b/rust/src/http2/decompression.rs index 77173a612b..96dbd11e87 100644 --- a/rust/src/http2/decompression.rs +++ b/rust/src/http2/decompression.rs @@ -34,6 +34,7 @@ pub enum HTTP2ContentEncoding { } //a cursor turning EOF into blocking errors +#[derive(Debug)] pub struct HTTP2cursor { pub cursor: Cursor>, } @@ -78,6 +79,26 @@ pub enum HTTP2Decompresser { BROTLI(brotli::Decompressor), } +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, diff --git a/rust/src/http2/http2.rs b/rust/src/http2/http2.rs index c69e91bae9..b2e62ec53c 100644 --- a/rust/src/http2/http2.rs +++ b/rust/src/http2/http2.rs @@ -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, diff --git a/rust/src/http2/logger.rs b/rust/src/http2/logger.rs index 3e254bf6bb..7e15ffcaab 100644 --- a/rust/src/http2/logger.rs +++ b/rust/src/http2/logger.rs @@ -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, diff --git a/rust/src/http2/parser.rs b/rust/src/http2/parser.rs index 3054a5c436..87e9883895 100644 --- a/rust/src/http2/parser.rs +++ b/rust/src/http2/parser.rs @@ -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, ) ); -#[derive(Clone, Copy)] +#[derive(Clone, Copy, Debug)] pub struct HTTP2FrameRstStream { pub errorcode: u32, ////HTTP2ErrorCode } @@ -166,7 +166,7 @@ named!(pub http2_parse_frame_rststream, ) ); -#[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, ) ); -#[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, ) ); -#[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, pub priority: Option, @@ -649,7 +649,7 @@ pub fn http2_parse_frame_headers<'a>( )); } -#[derive(Clone)] +#[derive(Clone, Debug)] pub struct HTTP2FramePushPromise { pub padlength: Option, 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, } @@ -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,