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_cache {} guid2name_cache {} read_offset_cache {} ssn2tree_cache {} dcerpc_rec_frag_cache {} file_ts_guid {} file_tc_guid {} transactions {}",
self.ssn2vec_cache.len(),
self.guid2name_cache.len(),
self.read_offset_cache.len(),
self.ssn2tree_cache.len(),
self.dcerpc_rec_frag_cache.len(),
self.file_ts_guid.len(),
self.file_tc_guid.len(),
self.transactions.len());
}
}