From 0c6e9ac93196f03021bda8252ba50e11ca028f1b Mon Sep 17 00:00:00 2001 From: Shivani Bhardwaj Date: Thu, 12 Aug 2021 17:51:07 +0530 Subject: [PATCH] files: use Direction enum --- rust/src/filecontainer.rs | 4 ++-- rust/src/http2/http2.rs | 2 +- rust/src/nfs/nfs.rs | 6 +++--- rust/src/smb/files.rs | 4 ++-- rust/src/smb/smb.rs | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/rust/src/filecontainer.rs b/rust/src/filecontainer.rs index e2ff51db5..cc5ddafee 100644 --- a/rust/src/filecontainer.rs +++ b/rust/src/filecontainer.rs @@ -37,9 +37,9 @@ pub struct Files { } impl Files { - pub fn get(&mut self, direction: u8) -> (&mut FileContainer, u16) + pub fn get(&mut self, direction: Direction) -> (&mut FileContainer, u16) { - if direction == STREAM_TOSERVER { + if direction == Direction::ToServer { (&mut self.files_ts, self.flags_ts) } else { (&mut self.files_tc, self.flags_tc) diff --git a/rust/src/http2/http2.rs b/rust/src/http2/http2.rs index 0bea3e2d9..806d96267 100644 --- a/rust/src/http2/http2.rs +++ b/rust/src/http2/http2.rs @@ -871,7 +871,7 @@ impl HTTP2State { let index = self.find_tx_index(sid); if index > 0 { let tx_same = &mut self.transactions[index - 1]; - let (files, flags) = self.files.get(dir); + let (files, flags) = self.files.get(dir.into()); match tx_same.decompress( &rem[..hlsafe], dir, diff --git a/rust/src/nfs/nfs.rs b/rust/src/nfs/nfs.rs index c11f5f49d..d919dae2b 100644 --- a/rust/src/nfs/nfs.rs +++ b/rust/src/nfs/nfs.rs @@ -474,7 +474,7 @@ impl NFSState { if self.ts > f.post_gap_ts { tx.request_done = true; tx.response_done = true; - let (files, flags) = self.files.get(tx.file_tx_direction); + let (files, flags) = self.files.get(tx.file_tx_direction.into()); f.file_tracker.trunc(files, flags); } else { post_gap_txs = true; @@ -594,7 +594,7 @@ impl NFSState { tx.id, String::from_utf8_lossy(file_name)); self.transactions.push(tx); let tx_ref = self.transactions.last_mut(); - let (files, flags) = self.files.get(direction); + let (files, flags) = self.files.get(direction.into()); return (tx_ref.unwrap(), files, flags) } @@ -608,7 +608,7 @@ impl NFSState { tx.file_handle == fh { SCLogDebug!("Found NFS file TX with ID {} XID {:04X}", tx.id, tx.xid); - let (files, flags) = self.files.get(direction); + let (files, flags) = self.files.get(direction.into()); return Some((tx, files, flags)); } } diff --git a/rust/src/smb/files.rs b/rust/src/smb/files.rs index 6090c9f69..97f302179 100644 --- a/rust/src/smb/files.rs +++ b/rust/src/smb/files.rs @@ -77,7 +77,7 @@ impl SMBState { tx.id, String::from_utf8_lossy(file_name)); self.transactions.push(tx); let tx_ref = self.transactions.last_mut(); - let (files, flags) = self.files.get(direction); + let (files, flags) = self.files.get(direction.into()); return (tx_ref.unwrap(), files, flags) } @@ -95,7 +95,7 @@ impl SMBState { if found { SCLogDebug!("SMB: Found SMB file TX with ID {}", tx.id); - let (files, flags) = self.files.get(direction); + let (files, flags) = self.files.get(direction.into()); return Some((tx, files, flags)); } } diff --git a/rust/src/smb/smb.rs b/rust/src/smb/smb.rs index 2eea29f69..34f4e379d 100644 --- a/rust/src/smb/smb.rs +++ b/rust/src/smb/smb.rs @@ -1131,7 +1131,7 @@ impl SMBState { if self.ts > f.post_gap_ts { tx.request_done = true; tx.response_done = true; - let (files, flags) = self.files.get(f.direction); + let (files, flags) = self.files.get(f.direction.into()); f.file_tracker.trunc(files, flags); } else { post_gap_txs = true; -- 2.47.3