]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
smb: split probing function for code style
authorPhilippe Antoine <contact@catenacyber.fr>
Tue, 2 Feb 2021 12:29:14 +0000 (13:29 +0100)
committerVictor Julien <victor@inliniac.net>
Sat, 27 Feb 2021 17:46:54 +0000 (18:46 +0100)
Introduces rs_smb_probe_tcp_midstream

(cherry picked from commit 9dc5258a21cecdabca26aaac108e83d85147d30b)

rust/src/smb/smb.rs

index 70262391cc688d8a7b22f534971a3c705089c367..ada497b5791f6fa55dd6f2e1c46a3106a0e5799c 100644 (file)
@@ -1905,15 +1905,8 @@ pub extern "C" fn rs_smb_parse_response_tcp_gap(
     state.parse_tcp_data_tc_gap(input_len as u32)
 }
 
-// probing parser
-// return 1 if found, 0 is not found
-#[no_mangle]
-pub extern "C" fn rs_smb_probe_tcp(direction: u8,
-        input: *const u8, len: u32,
-        rdir: *mut u8)
-    -> i8
+fn rs_smb_probe_tcp_midstream(direction: u8, slice: &[u8], rdir: *mut u8) -> i8
 {
-    let slice = build_slice!(input, len as usize);
     match search_smb_record(slice) {
         Ok((_, ref data)) => {
             SCLogDebug!("smb found");
@@ -1972,6 +1965,21 @@ pub extern "C" fn rs_smb_probe_tcp(direction: u8,
             SCLogDebug!("no dice");
         },
     }
+    return 0;
+}
+
+// probing parser
+// return 1 if found, 0 is not found
+#[no_mangle]
+pub extern "C" fn rs_smb_probe_tcp(flags: u8,
+        input: *const u8, len: u32,
+        rdir: *mut u8)
+    -> i8
+{
+    let slice = build_slice!(input, len as usize);
+    if rs_smb_probe_tcp_midstream(flags, slice, rdir) == 1 {
+        return 1;
+    }
     match parse_nbss_record_partial(slice) {
         Ok((_, ref hdr)) => {
             if hdr.is_smb() {