From: Shivani Bhardwaj Date: Thu, 12 Aug 2021 12:21:07 +0000 (+0530) Subject: files: use Direction enum X-Git-Tag: suricata-7.0.0-beta1~1224 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0c6e9ac93196f03021bda8252ba50e11ca028f1b;p=thirdparty%2Fsuricata.git files: use Direction enum --- diff --git a/rust/src/filecontainer.rs b/rust/src/filecontainer.rs index e2ff51db5c..cc5ddafee2 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 0bea3e2d9c..806d96267b 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 c11f5f49d3..d919dae2b9 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 6090c9f698..97f302179c 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 2eea29f691..34f4e379df 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;