diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 17:39:49 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 17:39:49 +0000 |
commit | a0aa2307322cd47bbf416810ac0292925e03be87 (patch) | |
tree | 37076262a026c4b48c8a0e84f44ff9187556ca35 /rust/src/smb/debug.rs | |
parent | Initial commit. (diff) | |
download | suricata-a0aa2307322cd47bbf416810ac0292925e03be87.tar.xz suricata-a0aa2307322cd47bbf416810ac0292925e03be87.zip |
Adding upstream version 1:7.0.3.upstream/1%7.0.3
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'rust/src/smb/debug.rs')
-rw-r--r-- | rust/src/smb/debug.rs | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/rust/src/smb/debug.rs b/rust/src/smb/debug.rs new file mode 100644 index 0000000..86799dd --- /dev/null +++ b/rust/src/smb/debug.rs @@ -0,0 +1,74 @@ +/* Copyright (C) 2018-2020 Open Information Security Foundation + * + * You can copy, redistribute or modify this Program under the terms of + * the GNU General Public License version 2 as published by the Free + * Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * version 2 along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +use crate::smb::smb::*; + +impl SMBState { + #[cfg(not(feature = "debug"))] + pub fn _debug_tx_stats(&self) { } + + #[cfg(feature = "debug")] + pub fn _debug_tx_stats(&self) { + if self.transactions.len() > 1 { + let txf = self.transactions.front().unwrap(); + let txl = self.transactions.back().unwrap(); + + SCLogDebug!("TXs {} MIN {} MAX {}", self.transactions.len(), txf.id, txl.id); + SCLogDebug!("- OLD tx.id {}: {:?}", txf.id, txf); + SCLogDebug!("- NEW tx.id {}: {:?}", txl.id, txl); + self._dump_txs(); + } + } + + #[cfg(not(feature = "debug"))] + pub fn _dump_txs(&self) { } + #[cfg(feature = "debug")] + pub fn _dump_txs(&self) { + let len = self.transactions.len(); + for i in 0..len { + let tx = &self.transactions[i]; + let ver = tx.vercmd.get_version(); + let _smbcmd = if ver == 2 { + let (_, cmd) = tx.vercmd.get_smb2_cmd(); + cmd + } else { + let (_, cmd) = tx.vercmd.get_smb1_cmd(); + cmd as u16 + }; + + match tx.type_data { + Some(SMBTransactionTypeData::FILE(ref d)) => { + SCLogDebug!("idx {} tx id {} progress {}/{} filename {} type_data {:?}", + i, tx.id, tx.request_done, tx.response_done, + String::from_utf8_lossy(&d.file_name), tx.type_data); + }, + _ => { + SCLogDebug!("idx {} tx id {} ver:{} cmd:{} progress {}/{} type_data {:?} tx {:?}", + i, tx.id, ver, _smbcmd, tx.request_done, tx.response_done, tx.type_data, tx); + }, + } + } + } + + #[cfg(not(feature = "debug"))] + pub fn _debug_state_stats(&self) { } + + #[cfg(feature = "debug")] + pub fn _debug_state_stats(&self) { + SCLogDebug!("ssn2vec_map {} guid2name_map {} ssn2vecoffset_map {} ssn2tree_map {} ssnguid2vec_map {} file_ts_guid {} file_tc_guid {} transactions {}", self.ssn2vec_map.len(), self.guid2name_map.len(), self.ssn2vecoffset_map.len(), self.ssn2tree_map.len(), self.ssnguid2vec_map.len(), self.file_ts_guid.len(), self.file_tc_guid.len(), self.transactions.len()); + } +} |