]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
rust: SCLogDebug is real nop when built as release
authorPhilippe Antoine <contact@catenacyber.fr>
Thu, 6 May 2021 11:30:49 +0000 (13:30 +0200)
committerVictor Julien <victor@inliniac.net>
Fri, 25 Jun 2021 15:11:52 +0000 (17:11 +0200)
Before, even if there were no outputs, all the arguments
were evaluated, which could turn expensive

All variables which are used only in certain build configurations
are now prefixed by underscore to avoid warnings

(cherry picked from commit ef5755338fa6404b60e7f90bfbaca039b2bfda1e)

33 files changed:
rust/src/applayertemplate/template.rs
rust/src/conf.rs
rust/src/dhcp/dhcp.rs
rust/src/dns/dns.rs
rust/src/filecontainer.rs
rust/src/filetracker.rs
rust/src/ftp/mod.rs
rust/src/ikev2/ikev2.rs
rust/src/kerberos.rs
rust/src/krb/krb5.rs
rust/src/log.rs
rust/src/nfs/nfs.rs
rust/src/nfs/nfs2.rs
rust/src/nfs/nfs3.rs
rust/src/nfs/nfs4.rs
rust/src/ntp/ntp.rs
rust/src/sip/sip.rs
rust/src/smb/auth.rs
rust/src/smb/dcerpc.rs
rust/src/smb/debug.rs
rust/src/smb/detect.rs
rust/src/smb/events.rs
rust/src/smb/files.rs
rust/src/smb/session.rs
rust/src/smb/smb.rs
rust/src/smb/smb1.rs
rust/src/smb/smb1_records.rs
rust/src/smb/smb1_session.rs
rust/src/smb/smb2.rs
rust/src/smb/smb2_ioctl.rs
rust/src/smb/smb2_session.rs
rust/src/smb/smb_records.rs
rust/src/snmp/snmp.rs

index 760e67ced35e546d4485d5d3a752030f692d72e2..2e301343ab8ca76c5cdb569db57a0b3d809d53ce 100644 (file)
@@ -17,7 +17,6 @@
 
 use std;
 use crate::core::{self, ALPROTO_UNKNOWN, AppProto, Flow, IPPROTO_TCP};
-use crate::log::*;
 use std::mem::transmute;
 use crate::applayer::{self, LoggerFlags};
 use crate::parser::*;
index 92d3ccd696873196149ace0d040ef5a9a44f01c8..bc3582f73ca1b42825e636eb801457612d36cec2 100644 (file)
@@ -22,8 +22,6 @@ use std::ffi::{CString, CStr};
 use std::ptr;
 use std::str;
 
-use crate::log::*;
-
 extern {
     fn ConfGet(key: *const c_char, res: *mut *const c_char) -> i8;
     fn ConfGetChildValue(conf: *const c_void, key: *const c_char,
index 4c5af84c713edb0fc1363e2d710f01ad19e6eccb..5ed17277c5e1035de50c09bae004eed583b1ef2e 100644 (file)
@@ -20,7 +20,6 @@ use crate::core;
 use crate::core::{ALPROTO_UNKNOWN, AppProto, Flow, IPPROTO_UDP};
 use crate::core::{sc_detect_engine_state_free, sc_app_layer_decoder_events_free_events};
 use crate::dhcp::parser::*;
-use crate::log::*;
 use crate::parser::*;
 use std;
 use std::ffi::{CStr,CString};
index c9b688f1ffb877cfc9bc213bdbe30555e3291443..2b73ef2dd55e247ef30a1a070bf04e3a6d77deb6 100644 (file)
@@ -20,7 +20,6 @@ extern crate nom;
 use std;
 use std::mem::transmute;
 
-use crate::log::*;
 use crate::applayer::LoggerFlags;
 use crate::core;
 use crate::dns::parser;
index 38520cfa9ea12fbd0c977bc0a32509d163f62ded..b3b321c274bb3568950ba52db0c2aba7c793c400 100644 (file)
@@ -18,7 +18,6 @@
 use std::ptr;
 use std::os::raw::{c_void};
 
-use crate::log::*;
 use crate::core::*;
 
 pub struct File;
index 1981b54e006d3b3a41305e4b56ad59abc1960aa9..2dcb9ce1c8a2f14a11c64c606065b9e8da21ed39 100644 (file)
@@ -28,7 +28,6 @@
  * The tracker does continue to follow the file.
  */
 
-use crate::log::*;
 use crate::core::*;
 use std::collections::HashMap;
 use std::collections::hash_map::Entry::{Occupied, Vacant};
@@ -122,10 +121,10 @@ impl FileTransferTracker {
         self.file_is_truncated = true;
     }
 
-    pub fn create(&mut self, name: &[u8], file_size: u64) {
+    pub fn create(&mut self, _name: &[u8], _file_size: u64) {
         if self.file_open == true { panic!("close existing file first"); }
 
-        SCLogDebug!("CREATE: name {:?} file_size {}", name, file_size);
+        SCLogDebug!("CREATE: name {:?} file_size {}", _name, _file_size);
     }
 
     pub fn new_chunk(&mut self, config: &'static SuricataFileContext,
@@ -251,7 +250,7 @@ impl FileTransferTracker {
 
                     if self.chunk_is_ooo == false {
                         loop {
-                            let offset = self.tracked;
+                            let _offset = self.tracked;
                             match self.chunks.remove(&self.tracked) {
                                 Some(c) => {
                                     let res = files.file_append(&self.track_id, &c.chunk, c.contains_gap);
@@ -269,10 +268,10 @@ impl FileTransferTracker {
                                     self.tracked += c.chunk.len() as u64;
                                     self.cur_ooo -= c.chunk.len() as u64;
 
-                                    SCLogDebug!("STORED OOO CHUNK at offset {}, tracked now {}, stored len {}", offset, self.tracked, c.chunk.len());
+                                    SCLogDebug!("STORED OOO CHUNK at offset {}, tracked now {}, stored len {}", _offset, self.tracked, c.chunk.len());
                                 },
                                 _ => {
-                                    SCLogDebug!("NO STORED CHUNK found at offset {}", self.tracked);
+                                    SCLogDebug!("NO STORED CHUNK found at _offset {}", self.tracked);
                                     break;
                                 },
                             };
index e07bebb8eca166f3bfeef538423fa96937c1c72c..2e387baacbc976fe4f7548dc243dde03d2391ad3 100644 (file)
@@ -23,8 +23,6 @@ use std::str;
 use std;
 use std::str::FromStr;
 
-use crate::log::*;
-
 // We transform an integer string into a i64, ignoring surrounding whitespaces
 // We look for a digit suite, and try to convert it.
 // If either str::from_utf8 or FromStr::from_str fail,
@@ -105,11 +103,9 @@ pub extern "C" fn rs_ftp_pasv_response(input: *const u8, len: u32) -> u16 {
             return dport;
         },
         Err(nom::Err::Incomplete(_)) => {
-            let buf = unsafe{std::slice::from_raw_parts(input, len as usize)};
             SCLogDebug!("pasv incomplete: '{:?}'", String::from_utf8_lossy(buf));
         },
         Err(_) => {
-            let buf = unsafe{std::slice::from_raw_parts(input, len as usize)};
             SCLogDebug!("pasv error on '{:?}'", String::from_utf8_lossy(buf));
         },
     }
@@ -169,11 +165,9 @@ pub extern "C" fn rs_ftp_epsv_response(input: *const u8, len: u32) -> u16 {
             return dport;
         },
         Err(nom::Err::Incomplete(_)) => {
-            let buf = unsafe{std::slice::from_raw_parts(input, len as usize)};
             SCLogDebug!("epsv incomplete: '{:?}'", String::from_utf8_lossy(buf));
         },
         Err(_) => {
-            let buf = unsafe{std::slice::from_raw_parts(input, len as usize)};
             SCLogDebug!("epsv incomplete: '{:?}'", String::from_utf8_lossy(buf));
         },
 
index bbf626d90f0209166ffe3f3d0dc9344dd0fe0f52..8e1bdba234b56ad67deaa2109a416ce80a359873 100644 (file)
@@ -26,8 +26,6 @@ use crate::parser::*;
 use std;
 use std::ffi::{CStr,CString};
 
-use crate::log::*;
-
 use nom;
 
 #[repr(u32)]
@@ -187,8 +185,8 @@ impl IKEV2State {
                                         self.dh_group = kex.dh_group;
                                     }
                                 },
-                                IkeV2PayloadContent::Nonce(ref n) => {
-                                    SCLogDebug!("Nonce: {:?}", n);
+                                IkeV2PayloadContent::Nonce(ref _n) => {
+                                    SCLogDebug!("Nonce: {:?}", _n);
                                 },
                                 IkeV2PayloadContent::Notify(ref n) => {
                                     SCLogDebug!("Notify: {:?}", n);
@@ -216,7 +214,7 @@ impl IKEV2State {
                             }
                         };
                     },
-                    e => { SCLogDebug!("parse_ikev2_payload_with_type: {:?}",e); () },
+                    _e => { SCLogDebug!("parse_ikev2_payload_with_type: {:?}",_e); () },
                 }
                 1
             },
@@ -341,8 +339,8 @@ impl IKEV2State {
                             _ => (),
                         }
                     },
-                    IkeV2Transform::Unknown(tx_type,tx_id) => {
-                        SCLogDebug!("Unknown proposal: type={:?}, id={}", tx_type, tx_id);
+                    IkeV2Transform::Unknown(_tx_type,_tx_id) => {
+                        SCLogDebug!("Unknown proposal: type={:?}, id={}", _tx_type, _tx_id);
                         self.set_event(IKEV2Event::UnknownProposal);
                     },
                     _ => (),
index 02343bf57e25998e7876c7e5ed7d2491e304aef7..631bc8fc82a2d99e1fb8cadf193c16a0fae1aee8 100644 (file)
@@ -22,8 +22,6 @@ use nom::{ErrorKind, IResult, le_u16};
 use der_parser;
 use der_parser::parse_der_oid;
 
-use crate::log::*;
-
 pub const SECBLOB_NOT_SPNEGO :  u32 = 128;
 pub const SECBLOB_KRB_FMT_ERR : u32 = 129;
 
index eb753600db48da7d9c0155342681956d38361bc1..58e0c3c03df4c595a6c79e3cbca694d6ff5fecf2 100644 (file)
@@ -29,8 +29,6 @@ use crate::core;
 use crate::core::{AppProto,Flow,ALPROTO_FAILED,ALPROTO_UNKNOWN,STREAM_TOCLIENT,STREAM_TOSERVER,sc_detect_engine_state_free};
 use crate::parser::*;
 
-use crate::log::*;
-
 #[repr(u32)]
 pub enum KRB5Event {
     MalformedData = 0,
index fdb0524ea35a6755f01308fd8e15513fc2b7c428..eb74c6ebecffe55fbaad4b421aa3814159fc196e 100644 (file)
@@ -22,6 +22,7 @@ use std::path::Path;
 use crate::core::*;
 
 #[derive(Debug)]
+#[repr(C)]
 pub enum Level {
     NotSet = -1,
     None = 0,
@@ -67,19 +68,33 @@ pub fn sclog(level: Level, file: &str, line: u32, function: &str,
                    message);
 }
 
+#[cfg(feature = "function-macro")]
+#[macro_export(local_inner_macros)]
+macro_rules!function {
+    () => {{
+         // Okay, this is ugly, I get it. However, this is the best we can get on a stable rust.
+         fn __f() {}
+         fn type_name_of<T>(_: T) -> &'static str {
+             std::any::type_name::<T>()
+         }
+         let name = type_name_of(__f);
+         &name[..name.len() - 5]
+    }}
+}
 /// Return the function name, but for now just return <rust> as Rust
 /// has no macro to return the function name, but may in the future,
 /// see: https://github.com/rust-lang/rfcs/pull/1719
+#[cfg(not(feature = "function-macro"))]
+#[macro_export(local_inner_macros)]
 macro_rules!function {
     () => {{ "<rust>" }}
 }
 
 #[macro_export]
 macro_rules!do_log {
-    ($level:expr, $file:expr, $line:expr, $function:expr, $code:expr,
-     $($arg:tt)*) => {
-        if get_log_level() >= $level as i32 {
-            sclog($level, $file, $line, $function, $code,
+    ($level:expr, $code:expr, $($arg:tt)*) => {
+        if $crate::log::get_log_level() >= $level as i32 {
+            $crate::log::sclog($level, file!(), line!(), $crate::function!(), $code,
                   &(format!($($arg)*)));
         }
     }
@@ -88,37 +103,44 @@ macro_rules!do_log {
 #[macro_export]
 macro_rules!SCLogNotice {
     ($($arg:tt)*) => {
-        do_log!(Level::Notice, file!(), line!(), function!(), 0, $($arg)*);
+        $crate::do_log!($crate::log::Level::Notice, 0, $($arg)*);
     }
 }
 
 #[macro_export]
 macro_rules!SCLogInfo {
     ($($arg:tt)*) => {
-        do_log!(Level::Info, file!(), line!(), function!(), 0, $($arg)*);
+        $crate::do_log!($crate::log::Level::Info, 0, $($arg)*);
     }
 }
 
 #[macro_export]
 macro_rules!SCLogPerf {
     ($($arg:tt)*) => {
-        do_log!(Level::Perf, file!(), line!(), function!(), 0, $($arg)*);
+        $crate::do_log!($crate::log::Level::Perf, 0, $($arg)*);
     }
 }
 
 #[macro_export]
 macro_rules!SCLogConfig {
     ($($arg:tt)*) => {
-        do_log!(Level::Config, file!(), line!(), function!(), 0, $($arg)*);
+        $crate::do_log!($crate::log::Level::Config, 0, $($arg)*);
     }
 }
 
+#[macro_export]
+macro_rules!SCLogError {
+    ($($arg:tt)*) => {
+        $crate::do_log!($crate::log::Level::Error, 0, $($arg)*);
+    };
+}
+
 // Debug mode: call C SCLogDebug
 #[cfg(feature = "debug")]
 #[macro_export]
 macro_rules!SCLogDebug {
     ($($arg:tt)*) => {
-        do_log!(Level::Debug, file!(), line!(), function!(), 0, $($arg)*);
+        do_log!($crate::log::Level::Debug, 0, $($arg)*);
     }
 }
 
@@ -127,7 +149,7 @@ macro_rules!SCLogDebug {
 #[cfg(not(feature = "debug"))]
 #[macro_export]
 macro_rules!SCLogDebug {
-    ($last:expr) => { let _ = &$last; let _ = Level::Debug; };
+    ($last:expr) => { let _ = &$last; let _ = $crate::log::Level::Debug; };
     ($one:expr, $($arg:tt)*) => { let _ = &$one; SCLogDebug!($($arg)*); };
 }
 
index b68b57759a2fb023ca66291d3832bbf02c294ae5..8518a8c27842eb5be8fb150794d518e47ff807b0 100644 (file)
@@ -25,7 +25,6 @@ use std::ffi::CStr;
 
 use nom;
 
-use crate::log::*;
 use crate::applayer;
 use crate::applayer::LoggerFlags;
 use crate::core::*;
@@ -1094,9 +1093,9 @@ impl NFSState {
         if self.ts_gap {
             SCLogDebug!("TS trying to catch up after GAP (input {})", cur_i.len());
 
-            let mut cnt = 0;
+            let mut _cnt = 0;
             while cur_i.len() > 0 {
-                cnt += 1;
+                _cnt += 1;
                 match nfs_probe(cur_i, STREAM_TOSERVER) {
                     1 => {
                         SCLogDebug!("expected data found");
@@ -1104,14 +1103,15 @@ impl NFSState {
                         break;
                     },
                     0 => {
-                        SCLogDebug!("incomplete, queue and retry with the next block (input {}). Looped {} times.", cur_i.len(), cnt);
+                        SCLogDebug!("incomplete, queue and retry with the next block (input {}). Looped {} times.",
+                                cur_i.len(), _cnt);
                         self.tcp_buffer_ts.extend_from_slice(cur_i);
                         return 0;
                     },
                     -1 => {
                         cur_i = &cur_i[1..];
                         if cur_i.len() == 0 {
-                            SCLogDebug!("all post-GAP data in this chunk was bad. Looped {} times.", cnt);
+                            SCLogDebug!("all post-GAP data in this chunk was bad. Looped {} times.", _cnt);
                         }
                     },
                     _ => { return 1; },
@@ -1258,9 +1258,9 @@ impl NFSState {
         if self.tc_gap {
             SCLogDebug!("TC trying to catch up after GAP (input {})", cur_i.len());
 
-            let mut cnt = 0;
+            let mut _cnt = 0;
             while cur_i.len() > 0 {
-                cnt += 1;
+                _cnt += 1;
                 match nfs_probe(cur_i, STREAM_TOCLIENT) {
                     1 => {
                         SCLogDebug!("expected data found");
@@ -1268,14 +1268,15 @@ impl NFSState {
                         break;
                     },
                     0 => {
-                        SCLogDebug!("incomplete, queue and retry with the next block (input {}). Looped {} times.", cur_i.len(), cnt);
+                        SCLogDebug!("incomplete, queue and retry with the next block (input {}). Looped {} times.",
+                                cur_i.len(), _cnt);
                         self.tcp_buffer_tc.extend_from_slice(cur_i);
                         return 0;
                     },
                     -1 => {
                         cur_i = &cur_i[1..];
                         if cur_i.len() == 0 {
-                            SCLogDebug!("all post-GAP data in this chunk was bad. Looped {} times.", cnt);
+                            SCLogDebug!("all post-GAP data in this chunk was bad. Looped {} times.", _cnt);
                         }
                     },
                     _ => { return 1; },
index 719ed41ca673172d5244fb430239034a1204edcc..9c907912e3112340efbb93d51d2faf42721b8989 100644 (file)
@@ -18,7 +18,6 @@
 // written by Victor Julien
 
 use nom;
-use crate::log::*;
 
 use crate::nfs::nfs::*;
 use crate::nfs::types::*;
index 7e585932333947cbc4ea4c1bc6e1435d48ae55b9..bf76274c92f4cf03957c28adadf0b10815b617c1 100644 (file)
@@ -18,7 +18,6 @@
 // written by Victor Julien
 
 use nom;
-use crate::log::*;
 use crate::core::*;
 
 use crate::nfs::nfs::*;
index 9f33d9b5a40194a601aede77caa4e6581fe0369a..698105d0ac3598965a42ac8fad7c6f2a5a4af08a 100644 (file)
@@ -21,7 +21,6 @@ use nom;
 use nom::be_u32;
 
 use crate::core::*;
-use crate::log::*;
 
 use crate::nfs::nfs::*;
 use crate::nfs::types::*;
@@ -194,8 +193,8 @@ impl NFSState {
                         self.commit_v4(r, fh);
                     }
                 }
-                &Nfs4RequestContent::Close(ref rd) => {
-                    SCLogDebug!("CLOSEv4: {:?}", rd);
+                &Nfs4RequestContent::Close(ref _rd) => {
+                    SCLogDebug!("CLOSEv4: {:?}", _rd);
                 }
                 &Nfs4RequestContent::Create(ref rd) => {
                     SCLogDebug!("CREATEv4: {:?}", rd);
@@ -210,11 +209,11 @@ impl NFSState {
                     xidmap.file_name = rd.to_vec();
                     main_opcode = NFSPROC4_REMOVE;
                 }
-                &Nfs4RequestContent::SetClientId(ref rd) => {
+                &Nfs4RequestContent::SetClientId(ref _rd) => {
                     SCLogDebug!("SETCLIENTIDv4: client id {} r_netid {} r_addr {}",
-                            String::from_utf8_lossy(&rd.client_id),
-                            String::from_utf8_lossy(&rd.r_netid),
-                            String::from_utf8_lossy(&rd.r_addr));
+                            String::from_utf8_lossy(&_rd.client_id),
+                            String::from_utf8_lossy(&_rd.r_netid),
+                            String::from_utf8_lossy(&_rd.r_addr));
                 }
                 &_ => { },
             }
@@ -300,13 +299,13 @@ impl NFSState {
         for c in &cr.commands {
             SCLogDebug!("c {:?}", c);
             match c {
-                &Nfs4ResponseContent::ReadDir(s, ref rd) => {
+                &Nfs4ResponseContent::ReadDir(_s, ref rd) => {
                     if let &Some(ref rd) = rd {
-                        SCLogDebug!("READDIRv4: status {} eof {}", s, rd.eof);
+                        SCLogDebug!("READDIRv4: status {} eof {}", _s, rd.eof);
 
                         for d in &rd.listing {
-                            if let &Some(ref d) = d {
-                                SCLogDebug!("READDIRv4: dir {}", String::from_utf8_lossy(&d.name));
+                            if let &Some(ref _d) = d {
+                                SCLogDebug!("READDIRv4: dir {}", String::from_utf8_lossy(&_d.name));
                             }
                         }
 
@@ -338,9 +337,9 @@ impl NFSState {
                         self.process_read_record(r, &reply, Some(&xidmap));
                     }
                 },
-                &Nfs4ResponseContent::Open(s, ref rd) => {
-                    if let &Some(ref rd) = rd {
-                        SCLogDebug!("OPENv4: status {} opendata {:?}", s, rd);
+                &Nfs4ResponseContent::Open(_s, ref rd) => {
+                    if let &Some(ref _rd) = rd {
+                        SCLogDebug!("OPENv4: status {} opendata {:?}", _s, _rd);
                         insert_filename_with_getfh = true;
                     }
                 },
index 8dfe62c6a93b93dc354dee30d654dec1592ccd13..3cbb031eea4881d93889e98b58b3f31c370d8640 100644 (file)
@@ -26,8 +26,6 @@ use crate::parser::*;
 use std;
 use std::ffi::{CStr,CString};
 
-use crate::log::*;
-
 use nom;
 
 #[repr(u32)]
index 8df2a2f3476ab3e3156baf6e34f54fa25f66f57c..a49067f5afcffcd04a8a16843907a78dc5113437 100755 (executable)
@@ -23,7 +23,6 @@ use applayer;
 use conf;
 use core;
 use core::{sc_detect_engine_state_free, AppProto, Flow, ALPROTO_UNKNOWN};
-use log::*;
 use parser::*;
 use sip::parser::*;
 use std;
index ba15a2b72ff357aa1955338089eba96fff6a4a87..79fbc8d150fc36974016003c0d258e20919594f5 100644 (file)
@@ -17,7 +17,6 @@
 
 use crate::kerberos::*;
 
-use crate::log::*;
 use crate::smb::ntlmssp_records::*;
 use crate::smb::smb::*;
 
index 7cb9b7d6d9255d7c89e4118ec167231668f53721..4bb9fa019686358c4def9e67dc31d3d697f538f3 100644 (file)
@@ -17,8 +17,6 @@
 
 // written by Victor Julien
 
-use crate::log::*;
-
 use crate::smb::smb::*;
 use crate::smb::smb2::*;
 use crate::smb::dcerpc_records::*;
index 3387111ead28281461bd57ffc11d00e070fba85a..454519629203481d4a87e2071ba099a4b4fcf8ca 100644 (file)
@@ -17,9 +17,6 @@
 
 use crate::smb::smb::*;
 
-#[cfg(feature = "debug")]
-use log::*;
-
 impl SMBState {
     #[cfg(not(feature = "debug"))]
     pub fn _debug_tx_stats(&self) { }
index 58d65c32241ade002649e9bf7019112e4b96e711..5c2b344cb08f2a462ab3e31d73ac45acefcbcdc0 100644 (file)
@@ -18,7 +18,6 @@
 use std;
 use std::ptr;
 use crate::core::*;
-use crate::log::*;
 use crate::smb::smb::*;
 
 #[no_mangle]
index 3093d08e2fe4ac807d16af26cffb0655b2a90294..1b29da7d4394b3a7d295a10a17708a1ba8f6cc5f 100644 (file)
@@ -16,7 +16,6 @@
  */
 
 use crate::core::*;
-use crate::log::*;
 use crate::smb::smb::*;
 
 #[repr(u32)]
index b8667e3fb87f5e51d15f22230638c843b2ebea9f..f1c455fbdb3bbd17d89a5b571e4d3c9aa27839d8 100644 (file)
@@ -16,7 +16,6 @@
  */
 
 use crate::core::*;
-use crate::log::*;
 use crate::filetracker::*;
 use crate::filecontainer::*;
 
index 941b9eb3007366923700569221d5c449cc5bbfb9..43883a77d57e612dd526d2bb89ffff46ae2a0378 100644 (file)
@@ -15,7 +15,6 @@
  * 02110-1301, USA.
  */
 
-use crate::log::*;
 use crate::kerberos::*;
 use crate::smb::smb::*;
 use crate::smb::smb1_session::*;
index 964e74ce09a7be36fe25e4b3713836aadb0d8e0f..231be9aaa7f8942e7faf59d04295528f81e985a1 100644 (file)
@@ -35,7 +35,6 @@ use std::collections::HashMap;
 use nom;
 
 use crate::core::*;
-use crate::log::*;
 use crate::applayer;
 use crate::applayer::LoggerFlags;
 
@@ -1723,8 +1722,8 @@ impl SMBState {
                     }
                     cur_i = rem;
                 },
-                Err(nom::Err::Incomplete(needed)) => {
-                    SCLogDebug!("INCOMPLETE have {} needed {:?}", cur_i.len(), needed);
+                Err(nom::Err::Incomplete(_needed)) => {
+                    SCLogDebug!("INCOMPLETE have {} needed {:?}", cur_i.len(), _needed);
                     let consumed = self.parse_tcp_data_tc_partial(cur_i);
                     cur_i = &cur_i[consumed ..];
 
index 47e2d90dd4098b6db4605c0ab57cb3e1efddefc8..fe7c55313332faaf11dfacd49c6c9b431f022a50 100644 (file)
@@ -22,7 +22,6 @@
 use nom;
 
 use crate::core::*;
-use crate::log::*;
 
 use crate::smb::smb::*;
 use crate::smb::dcerpc::*;
@@ -235,14 +234,14 @@ pub fn smb1_request_record<'b>(state: &mut SMBState, r: &SmbRecord<'b>) -> u32 {
                                             true
 
                                         },
-                                        Err(nom::Err::Incomplete(n)) => {
-                                            SCLogDebug!("TRANS2 SET_FILE_INFO DATA DISPOSITION INCOMPLETE {:?}", n);
+                                        Err(nom::Err::Incomplete(_n)) => {
+                                            SCLogDebug!("TRANS2 SET_FILE_INFO DATA DISPOSITION INCOMPLETE {:?}", _n);
                                             events.push(SMBEvent::MalformedData);
                                             false
                                         },
-                                        Err(nom::Err::Error(e)) |
-                                        Err(nom::Err::Failure(e)) => {
-                                            SCLogDebug!("TRANS2 SET_FILE_INFO DATA DISPOSITION ERROR {:?}", e);
+                                        Err(nom::Err::Error(_e)) |
+                                        Err(nom::Err::Failure(_e)) => {
+                                            SCLogDebug!("TRANS2 SET_FILE_INFO DATA DISPOSITION ERROR {:?}", _e);
                                             events.push(SMBEvent::MalformedData);
                                             false
                                         },
@@ -263,14 +262,14 @@ pub fn smb1_request_record<'b>(state: &mut SMBState, r: &SmbRecord<'b>) -> u32 {
                                             tx.vercmd.set_smb1_cmd(SMB1_COMMAND_TRANS2);
                                             true
                                         },
-                                        Err(nom::Err::Incomplete(n)) => {
-                                            SCLogDebug!("TRANS2 SET_PATH_INFO DATA RENAME INCOMPLETE {:?}", n);
+                                        Err(nom::Err::Incomplete(_n)) => {
+                                            SCLogDebug!("TRANS2 SET_PATH_INFO DATA RENAME INCOMPLETE {:?}", _n);
                                             events.push(SMBEvent::MalformedData);
                                             false
                                         },
-                                        Err(nom::Err::Error(e)) |
-                                        Err(nom::Err::Failure(e)) => {
-                                            SCLogDebug!("TRANS2 SET_PATH_INFO DATA RENAME ERROR {:?}", e);
+                                        Err(nom::Err::Error(_e)) |
+                                        Err(nom::Err::Failure(_e)) => {
+                                            SCLogDebug!("TRANS2 SET_PATH_INFO DATA RENAME ERROR {:?}", _e);
                                             events.push(SMBEvent::MalformedData);
                                             false
                                         },
@@ -279,14 +278,14 @@ pub fn smb1_request_record<'b>(state: &mut SMBState, r: &SmbRecord<'b>) -> u32 {
                                     false
                                 }
                             },
-                            Err(nom::Err::Incomplete(n)) => {
-                                SCLogDebug!("TRANS2 SET_PATH_INFO PARAMS INCOMPLETE {:?}", n);
+                            Err(nom::Err::Incomplete(_n)) => {
+                                SCLogDebug!("TRANS2 SET_PATH_INFO PARAMS INCOMPLETE {:?}", _n);
                                 events.push(SMBEvent::MalformedData);
                                 false
                             },
-                            Err(nom::Err::Error(e)) |
-                            Err(nom::Err::Failure(e)) => {
-                                SCLogDebug!("TRANS2 SET_PATH_INFO PARAMS ERROR {:?}", e);
+                            Err(nom::Err::Error(_e)) |
+                            Err(nom::Err::Failure(_e)) => {
+                                SCLogDebug!("TRANS2 SET_PATH_INFO PARAMS ERROR {:?}", _e);
                                 events.push(SMBEvent::MalformedData);
                                 false
                             },
@@ -318,14 +317,14 @@ pub fn smb1_request_record<'b>(state: &mut SMBState, r: &SmbRecord<'b>) -> u32 {
                                             true
 
                                         },
-                                        Err(nom::Err::Incomplete(n)) => {
-                                            SCLogDebug!("TRANS2 SET_FILE_INFO DATA DISPOSITION INCOMPLETE {:?}", n);
+                                        Err(nom::Err::Incomplete(_n)) => {
+                                            SCLogDebug!("TRANS2 SET_FILE_INFO DATA DISPOSITION INCOMPLETE {:?}", _n);
                                             events.push(SMBEvent::MalformedData);
                                             false
                                         },
-                                        Err(nom::Err::Error(e)) |
-                                        Err(nom::Err::Failure(e)) => {
-                                            SCLogDebug!("TRANS2 SET_FILE_INFO DATA DISPOSITION ERROR {:?}", e);
+                                        Err(nom::Err::Error(_e)) |
+                                        Err(nom::Err::Failure(_e)) => {
+                                            SCLogDebug!("TRANS2 SET_FILE_INFO DATA DISPOSITION ERROR {:?}", _e);
                                             events.push(SMBEvent::MalformedData);
                                             false
                                         },
@@ -351,14 +350,14 @@ pub fn smb1_request_record<'b>(state: &mut SMBState, r: &SmbRecord<'b>) -> u32 {
                                             tx.vercmd.set_smb1_cmd(SMB1_COMMAND_TRANS2);
                                             true
                                         },
-                                        Err(nom::Err::Incomplete(n)) => {
-                                            SCLogDebug!("TRANS2 SET_FILE_INFO DATA RENAME INCOMPLETE {:?}", n);
+                                        Err(nom::Err::Incomplete(_n)) => {
+                                            SCLogDebug!("TRANS2 SET_FILE_INFO DATA RENAME INCOMPLETE {:?}", _n);
                                             events.push(SMBEvent::MalformedData);
                                             false
                                         },
-                                        Err(nom::Err::Error(e)) |
-                                        Err(nom::Err::Failure(e)) => {
-                                            SCLogDebug!("TRANS2 SET_FILE_INFO DATA RENAME ERROR {:?}", e);
+                                        Err(nom::Err::Error(_e)) |
+                                        Err(nom::Err::Failure(_e)) => {
+                                            SCLogDebug!("TRANS2 SET_FILE_INFO DATA RENAME ERROR {:?}", _e);
                                             events.push(SMBEvent::MalformedData);
                                             false
                                         },
@@ -367,14 +366,14 @@ pub fn smb1_request_record<'b>(state: &mut SMBState, r: &SmbRecord<'b>) -> u32 {
                                     false
                                 }
                             },
-                            Err(nom::Err::Incomplete(n)) => {
-                                SCLogDebug!("TRANS2 SET_FILE_INFO PARAMS INCOMPLETE {:?}", n);
+                            Err(nom::Err::Incomplete(_n)) => {
+                                SCLogDebug!("TRANS2 SET_FILE_INFO PARAMS INCOMPLETE {:?}", _n);
                                 events.push(SMBEvent::MalformedData);
                                 false
                             },
-                            Err(nom::Err::Error(e)) |
-                            Err(nom::Err::Failure(e)) => {
-                                SCLogDebug!("TRANS2 SET_FILE_INFO PARAMS ERROR {:?}", e);
+                            Err(nom::Err::Error(_e)) |
+                            Err(nom::Err::Failure(_e)) => {
+                                SCLogDebug!("TRANS2 SET_FILE_INFO PARAMS ERROR {:?}", _e);
                                 events.push(SMBEvent::MalformedData);
                                 false
                             },
@@ -383,14 +382,14 @@ pub fn smb1_request_record<'b>(state: &mut SMBState, r: &SmbRecord<'b>) -> u32 {
                         false
                     }
                 },
-                Err(nom::Err::Incomplete(n)) => {
-                    SCLogDebug!("TRANS2 INCOMPLETE {:?}", n);
+                Err(nom::Err::Incomplete(_n)) => {
+                    SCLogDebug!("TRANS2 INCOMPLETE {:?}", _n);
                     events.push(SMBEvent::MalformedData);
                     false
                 },
-                Err(nom::Err::Error(e)) |
-                Err(nom::Err::Failure(e)) => {
-                    SCLogDebug!("TRANS2 ERROR {:?}", e);
+                Err(nom::Err::Error(_e)) |
+                Err(nom::Err::Failure(_e)) => {
+                    SCLogDebug!("TRANS2 ERROR {:?}", _e);
                     events.push(SMBEvent::MalformedData);
                     false
                 },
@@ -813,11 +812,11 @@ pub fn smb1_trans_request_record<'b>(state: &mut SMBState, r: &SmbRecord<'b>)
                 let mut frankenfid = pipe.fid.to_vec();
                 frankenfid.extend_from_slice(&u32_as_bytes(r.ssn_id));
 
-                let (filename, is_dcerpc) = match state.get_service_for_guid(&frankenfid) {
+                let (_filename, is_dcerpc) = match state.get_service_for_guid(&frankenfid) {
                     (n, x) => (n, x),
                 };
                 SCLogDebug!("smb1_trans_request_record: name {} is_dcerpc {}",
-                        filename, is_dcerpc);
+                        _filename, is_dcerpc);
                 pipe_dcerpc = is_dcerpc;
             }
 
@@ -854,11 +853,11 @@ pub fn smb1_trans_response_record<'b>(state: &mut SMBState, r: &SmbRecord<'b>)
             let mut frankenfid = fid.to_vec();
             frankenfid.extend_from_slice(&u32_as_bytes(r.ssn_id));
 
-            let (filename, is_dcerpc) = match state.get_service_for_guid(&frankenfid) {
+            let (_filename, is_dcerpc) = match state.get_service_for_guid(&frankenfid) {
                 (n, x) => (n, x),
             };
             SCLogDebug!("smb1_trans_response_record: name {} is_dcerpc {}",
-                    filename, is_dcerpc);
+                    _filename, is_dcerpc);
 
             // if we get status 'BUFFER_OVERFLOW' this is only a part of
             // the data. Store it in the ssn/tree for later use.
index 1ae9ac50f672f8bf50f051ff026b0b70fa62dbb0..e7367e644301f2b62aef5198dad48d11c78eb323 100644 (file)
@@ -15,7 +15,6 @@
  * 02110-1301, USA.
  */
 
-use crate::log::*;
 use nom::{rest, le_u8, le_u16, le_u32, le_u64, IResult};
 use crate::smb::smb::*;
 use crate::smb::smb_records::*;
index 35d6495839efdf46aedad5e3a6a11dbe3d7ff99e..8c9b123974dedc581f241937c5c1e53a46a01756 100644 (file)
@@ -15,8 +15,6 @@
  * 02110-1301, USA.
  */
 
-use crate::log::*;
-
 use crate::smb::smb_records::*;
 use crate::smb::smb1_records::*;
 use crate::smb::smb::*;
index e5219dfebe00155fbed8689e6f045a4154c0bb97..c25cf0cca696b7bdcb0dd75db91a76d3085a29d8 100644 (file)
@@ -18,7 +18,6 @@
 use nom;
 
 use crate::core::*;
-use crate::log::*;
 
 use crate::smb::smb::*;
 use crate::smb::smb2_records::*;
@@ -580,20 +579,20 @@ pub fn smb2_response_record<'b>(state: &mut SMBState, r: &Smb2Record<'b>)
             if r.nt_status == SMB_NTSTATUS_SUCCESS {
                 match parse_smb2_response_write(r.data)
                 {
-                    Ok((_, wr)) => {
-                        SCLogDebug!("SMBv2: Write response => {:?}", wr);
+                    Ok((_, _wr)) => {
+                        SCLogDebug!("SMBv2: Write response => {:?}", _wr);
 
                         /* search key-guid map */
                         let guid_key = SMBCommonHdr::new(SMBHDR_TYPE_GUID,
                                 r.session_id, r.tree_id, r.message_id);
-                        let guid_vec = match state.ssn2vec_map.remove(&guid_key) {
+                        let _guid_vec = match state.ssn2vec_map.remove(&guid_key) {
                             Some(p) => p,
                             None => {
                                 SCLogDebug!("SMBv2 response: GUID NOT FOUND");
                                 Vec::new()
                             },
                         };
-                        SCLogDebug!("SMBv2 write response for GUID {:?}", guid_vec);
+                        SCLogDebug!("SMBv2 write response for GUID {:?}", _guid_vec);
                     }
                     _ => {
                         events.push(SMBEvent::MalformedData);
index 480e8696bd8c79208f962c3e0ab877d23a62f02c..93e5f381d26760022cc6b98b8a627fdc29681063 100644 (file)
@@ -15,7 +15,6 @@
  * 02110-1301, USA.
  */
 
-use crate::log::*;
 use crate::smb::smb::*;
 use crate::smb::smb2::*;
 use crate::smb::smb2_records::*;
index 91399a5dbc963bbbd20e39db46e19edc49cdc1c8..356c89e4b5fd1065a88d1c4bef7319deb4dea7b0 100644 (file)
@@ -15,8 +15,6 @@
  * 02110-1301, USA.
  */
 
-use crate::log::*;
-
 use crate::smb::smb2_records::*;
 use crate::smb::smb::*;
 //use smb::events::*;
index 110d8eafeba321eead02e7c0a2faf7d65a10015f..dac72e7ba8ec522ad056ded5b0460d1cf8c2a430 100644 (file)
@@ -17,7 +17,6 @@
 
 use nom;
 use nom::{ErrorKind, IResult};
-use crate::log::*;
 
 /// parse a UTF16 string that is null terminated. Normally by 2 null
 /// bytes, but at the end of the data it can also be a single null.
index 6ad91745d4840edf0075bda92efacdab54c90ed5..4a9fd8fa1f77d333f095aacb15978a3da63c88d0 100644 (file)
@@ -26,8 +26,6 @@ use std;
 use std::ffi::{CStr,CString};
 use std::mem::transmute;
 
-use crate::log::*;
-
 use der_parser::{DerObjectContent,parse_der_sequence};
 use der_parser::oid::Oid;
 use nom;
@@ -196,8 +194,8 @@ impl SNMPState {
             Ok((_rem,SnmpGenericMessage::V1(msg))) |
             Ok((_rem,SnmpGenericMessage::V2(msg))) => self.handle_snmp_v12(msg, direction),
             Ok((_rem,SnmpGenericMessage::V3(msg))) => self.handle_snmp_v3(msg, direction),
-            Err(e) => {
-                SCLogDebug!("parse_snmp failed: {:?}", e);
+            Err(_e) => {
+                SCLogDebug!("parse_snmp failed: {:?}", _e);
                 self.set_event(SNMPEvent::MalformedData);
                 -1
             },