]> git.ipfire.org Git - people/ms/suricata.git/commitdiff
files: use Direction enum
authorShivani Bhardwaj <shivanib134@gmail.com>
Thu, 12 Aug 2021 12:21:07 +0000 (17:51 +0530)
committerVictor Julien <vjulien@oisf.net>
Fri, 19 Nov 2021 16:20:01 +0000 (17:20 +0100)
rust/src/filecontainer.rs
rust/src/http2/http2.rs
rust/src/nfs/nfs.rs
rust/src/smb/files.rs
rust/src/smb/smb.rs

index e2ff51db5c319c369c6dc8c5cfa831efcd95a165..cc5ddafee2f4f00038f42b4f28cea9ab2ff58e85 100644 (file)
@@ -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)
index 0bea3e2d9c946a9b3c66d17cb74bf54bb41ab27a..806d96267bc25260f3fd2ac9d97ead243b54db10 100644 (file)
@@ -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,
index c11f5f49d32132a011efd830c4e4b4194e8be44b..d919dae2b910bca5470cd9575d1c20d1a27775b6 100644 (file)
@@ -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));
             }
         }
index 6090c9f6988b844780be9e4613b748a70c476a5d..97f302179c678b3ada549261c1fad21b79bca098 100644 (file)
@@ -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));
             }
         }
index 2eea29f691ca363d7dd27c9e62a89074fd2c9c0b..34f4e379dfd86331dc94b1fdf4a44f586708462c 100644 (file)
@@ -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;