]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
rust/direction: move direction to own file (cleanup)
authorJason Ish <jason.ish@oisf.net>
Fri, 17 Jan 2025 17:29:06 +0000 (11:29 -0600)
committerVictor Julien <victor@inliniac.net>
Fri, 17 Jan 2025 21:06:56 +0000 (22:06 +0100)
Move the implementation of Direction to its own file, direction.rs.

44 files changed:
rust/src/applayer.rs
rust/src/applayertemplate/detect.rs
rust/src/bittorrent_dht/bittorrent_dht.rs
rust/src/bittorrent_dht/parser.rs
rust/src/core.rs
rust/src/dcerpc/dcerpc.rs
rust/src/dcerpc/dcerpc_udp.rs
rust/src/direction.rs [new file with mode: 0644]
rust/src/dns/detect.rs
rust/src/dns/dns.rs
rust/src/enip/detect.rs
rust/src/enip/enip.rs
rust/src/frames.rs
rust/src/http2/decompression.rs
rust/src/http2/detect.rs
rust/src/http2/http2.rs
rust/src/http2/range.rs
rust/src/ike/ike.rs
rust/src/ike/ikev1.rs
rust/src/ike/ikev2.rs
rust/src/ike/logger.rs
rust/src/krb/krb5.rs
rust/src/ldap/ldap.rs
rust/src/lib.rs
rust/src/mqtt/detect.rs
rust/src/mqtt/mqtt.rs
rust/src/nfs/nfs.rs
rust/src/nfs/nfs3.rs
rust/src/nfs/nfs4.rs
rust/src/ntp/ntp.rs
rust/src/pgsql/pgsql.rs
rust/src/quic/quic.rs
rust/src/rfb/rfb.rs
rust/src/sip/detect.rs
rust/src/sip/sip.rs
rust/src/smb/detect.rs
rust/src/smb/files.rs
rust/src/smb/smb.rs
rust/src/smb/smb1.rs
rust/src/smb/smb2.rs
rust/src/snmp/snmp.rs
rust/src/ssh/detect.rs
rust/src/ssh/ssh.rs
rust/src/websocket/websocket.rs

index 4518ae9cf3c7d00d8aa66de647f57516dd4d7d9f..048afbe5a7f52373e1371f38c7c4264aab5db621 100644 (file)
@@ -18,7 +18,8 @@
 //! Parser registration functions and common interface module.
 
 use std;
-use crate::core::{self,DetectEngineState,AppLayerEventType,AppProto,Direction};
+use crate::core::{self,DetectEngineState,AppLayerEventType,AppProto};
+use crate::direction::Direction;
 use crate::filecontainer::FileContainer;
 use crate::flow::Flow;
 use std::os::raw::{c_void,c_char,c_int};
index 5cfa364bd82cc1c9d8991cf1b9c7042c51215011..9eaf880ed7859fd37d8fbb0a2c82a67158bc9aae 100644 (file)
@@ -19,7 +19,7 @@ use super::template::{TemplateTransaction, ALPROTO_TEMPLATE};
 /* TEMPLATE_START_REMOVE */
 use crate::conf::conf_get_node;
 /* TEMPLATE_END_REMOVE */
-use crate::core::Direction;
+use crate::direction::Direction;
 use crate::detect::{
     DetectBufferSetActiveList, DetectHelperBufferMpmRegister, DetectHelperGetData,
     DetectHelperKeywordRegister, DetectSignatureSetAppProto, SCSigTableElmt,
index 82c267df372c082fd2349f7b9e3be678fa9ec103..33c4c51f449c78bf8306b696fb16d26a65fd6e22 100644 (file)
@@ -19,7 +19,8 @@ use crate::applayer::{self, *};
 use crate::bittorrent_dht::parser::{
     parse_bittorrent_dht_packet, BitTorrentDHTError, BitTorrentDHTRequest, BitTorrentDHTResponse,
 };
-use crate::core::{AppProto, ALPROTO_UNKNOWN, IPPROTO_UDP, Direction};
+use crate::core::{AppProto, ALPROTO_UNKNOWN, IPPROTO_UDP};
+use crate::direction::Direction;
 use crate::flow::Flow;
 use std::ffi::CString;
 use std::os::raw::c_char;
@@ -99,7 +100,7 @@ impl BitTorrentDHTState {
         }
     }
 
-    pub fn parse(&mut self, input: &[u8], _direction: crate::core::Direction) -> bool {
+    pub fn parse(&mut self, input: &[u8], _direction: Direction) -> bool {
         if !Self::is_dht(input) {
             return true;
         }
@@ -171,7 +172,7 @@ pub unsafe extern "C" fn rs_bittorrent_dht_parse_ts(
 ) -> AppLayerResult {
     return rs_bittorrent_dht_parse(
         _flow, state, _pstate, stream_slice,
-        _data, crate::core::Direction::ToServer);
+        _data, Direction::ToServer);
 }
 
 #[no_mangle]
@@ -181,14 +182,14 @@ pub unsafe extern "C" fn rs_bittorrent_dht_parse_tc(
 ) -> AppLayerResult {
     return rs_bittorrent_dht_parse(
         _flow, state, _pstate, stream_slice,
-        _data, crate::core::Direction::ToClient);
+        _data, Direction::ToClient);
 }
 
 #[no_mangle]
 pub unsafe extern "C" fn rs_bittorrent_dht_parse(
     _flow: *const Flow, state: *mut std::os::raw::c_void, _pstate: *mut std::os::raw::c_void,
     stream_slice: StreamSlice, _data: *const std::os::raw::c_void,
-    direction: crate::core::Direction,
+    direction: Direction,
 ) -> AppLayerResult {
     let state = cast_pointer!(state, BitTorrentDHTState);
     let buf = stream_slice.as_slice();
@@ -302,7 +303,7 @@ pub unsafe extern "C" fn rs_bittorrent_dht_udp_register_parser() {
             BITTORRENT_DHT_PAYLOAD_PREFIX.as_ptr() as *const c_char,
             BITTORRENT_DHT_PAYLOAD_PREFIX.len() as u16 - 1,
             0,
-            crate::core::Direction::ToServer.into(),
+            Direction::ToServer.into(),
         ) < 0
         {
             SCLogDebug!("Failed to register protocol detection pattern for direction TOSERVER");
@@ -313,7 +314,7 @@ pub unsafe extern "C" fn rs_bittorrent_dht_udp_register_parser() {
             BITTORRENT_DHT_PAYLOAD_PREFIX.as_ptr() as *const c_char,
             BITTORRENT_DHT_PAYLOAD_PREFIX.len() as u16 - 1,
             0,
-            crate::core::Direction::ToClient.into(),
+            Direction::ToClient.into(),
         ) < 0
         {
             SCLogDebug!("Failed to register protocol detection pattern for direction TOCLIENT");
index 545a1ad53774694a2d88ac86a87862cd125053c3..d2a93f30c8b182e2b784c30d50ab3d7df81bdeb5 100644 (file)
@@ -446,7 +446,7 @@ pub fn parse_bittorrent_dht_packet(
 #[cfg(test)]
 mod tests {
     use super::*;
-    use crate::core::Direction;
+    use crate::direction::Direction;
     use test_case::test_case;
 
     #[test_case(
index a6578b66add83895ff59b82e16ae15a57bcb486b..387d2b1524d22d9a1b58711bdf32fb8cdfe81b69 100644 (file)
@@ -19,7 +19,6 @@
 
 use std;
 use crate::filecontainer::*;
-use crate::debug_validate_fail;
 use crate::flow::Flow;
 
 /// Opaque C types.
@@ -41,70 +40,6 @@ pub const STREAM_TOCLIENT: u8 = 0x08;
 pub const STREAM_GAP:      u8 = 0x10;
 pub const STREAM_DEPTH:    u8 = 0x20;
 pub const STREAM_MIDSTREAM:u8 = 0x40;
-pub const DIR_BOTH:        u8 = 0b0000_1100;
-const DIR_TOSERVER:        u8 = 0b0000_0100;
-const DIR_TOCLIENT:        u8 = 0b0000_1000;
-
-#[repr(C)]
-#[derive(Debug, PartialEq, Eq, Clone, Copy)]
-pub enum Direction {
-    ToServer = 0x04,
-    ToClient = 0x08,
-}
-
-impl Direction {
-    /// Return true if the direction is to server.
-    pub fn is_to_server(&self) -> bool {
-       matches!(self, Self::ToServer)
-    }
-
-    /// Return true if the direction is to client.
-    pub fn is_to_client(&self) -> bool {
-       matches!(self, Self::ToClient)
-    }
-
-    pub fn index(&self) -> usize {
-        match self {
-            Self::ToClient => 0,
-            _ => 1,
-        }
-    }
-}
-
-impl Default for Direction {
-    fn default() -> Self { Direction::ToServer }
-}
-
-impl std::fmt::Display for Direction {
-    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
-        match self {
-            Self::ToServer => write!(f, "toserver"),
-            Self::ToClient => write!(f, "toclient"),
-        }
-    }
-}
-
-impl From<u8> for Direction {
-    fn from(d: u8) -> Self {
-        if d & (DIR_TOSERVER | DIR_TOCLIENT) == (DIR_TOSERVER | DIR_TOCLIENT) {
-            debug_validate_fail!("Both directions are set");
-            Direction::ToServer
-        } else if d & DIR_TOSERVER != 0 {
-            Direction::ToServer
-        } else if d & DIR_TOCLIENT != 0 {
-            Direction::ToClient
-        } else {
-            debug_validate_fail!("Unknown direction!!");
-            Direction::ToServer
-        }
-    }
-}
-
-impl From<Direction> for u8 {
-    fn from(d: Direction) -> u8 {
-        d as u8
-    }
-}
 
 // Application layer protocol identifiers (app-layer-protos.h)
 pub type AppProto = u16;
@@ -299,17 +234,3 @@ pub fn sc_app_layer_decoder_events_free_events(
         }
     }
 }
-
-#[cfg(test)]
-mod test {
-    use super::*;
-
-    #[test]
-    fn test_direction() {
-       assert!(Direction::ToServer.is_to_server());
-       assert!(!Direction::ToServer.is_to_client());
-
-       assert!(Direction::ToClient.is_to_client());
-       assert!(!Direction::ToClient.is_to_server());
-    }
-}
index 2a2db94a3bb8bbf37d85f12c3fa674130a04b253..433dc4b5bf642f3f0fcfb475493bcfa5dbb61563 100644 (file)
@@ -18,6 +18,7 @@
 use crate::applayer::{self, *};
 use crate::core::{self, *};
 use crate::dcerpc::parser;
+use crate::direction::{Direction, DIR_BOTH};
 use crate::flow::Flow;
 use nom7::error::{Error, ErrorKind};
 use nom7::number::Endianness;
@@ -1389,6 +1390,7 @@ mod tests {
     use crate::applayer::AppLayerResult;
     use crate::core::*;
     use crate::dcerpc::dcerpc::DCERPCState;
+    use crate::direction::Direction;
     use std::cmp;
 
     #[test]
index f890f10acea3bc47283b5b2774fc875836349f61..673d1608ae4a1a5ffd499f2b491d8dcf5dbbf249 100644 (file)
  * 02110-1301, USA.
  */
 
+use crate::core;
 use crate::applayer::{self, *};
-use crate::core::{self, Direction, DIR_BOTH};
 use crate::dcerpc::dcerpc::{
     DCERPCTransaction, DCERPC_MAX_TX, DCERPC_TYPE_REQUEST, DCERPC_TYPE_RESPONSE, PFCL1_FRAG, PFCL1_LASTFRAG,
     rs_dcerpc_get_alstate_progress, ALPROTO_DCERPC, PARSER_NAME,
 };
+use crate::direction::{Direction, DIR_BOTH};
 use crate::flow::Flow;
 use nom7::Err;
 use std;
diff --git a/rust/src/direction.rs b/rust/src/direction.rs
new file mode 100644 (file)
index 0000000..7cf10a0
--- /dev/null
@@ -0,0 +1,97 @@
+/* Copyright (C) 2017-2025 Open Information Security Foundation
+ *
+ * You can copy, redistribute or modify this Program under the terms of
+ * the GNU General Public License version 2 as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * version 2 along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+pub const DIR_BOTH: u8 = 0b0000_1100;
+const DIR_TOSERVER: u8 = 0b0000_0100;
+const DIR_TOCLIENT: u8 = 0b0000_1000;
+
+#[repr(C)]
+#[derive(Debug, PartialEq, Eq, Clone, Copy)]
+pub enum Direction {
+    ToServer = 0x04,
+    ToClient = 0x08,
+}
+
+impl Direction {
+    /// Return true if the direction is to server.
+    pub fn is_to_server(&self) -> bool {
+        matches!(self, Self::ToServer)
+    }
+
+    /// Return true if the direction is to client.
+    pub fn is_to_client(&self) -> bool {
+        matches!(self, Self::ToClient)
+    }
+
+    pub fn index(&self) -> usize {
+        match self {
+            Self::ToClient => 0,
+            _ => 1,
+        }
+    }
+}
+
+impl Default for Direction {
+    fn default() -> Self {
+        Direction::ToServer
+    }
+}
+
+impl std::fmt::Display for Direction {
+    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+        match self {
+            Self::ToServer => write!(f, "toserver"),
+            Self::ToClient => write!(f, "toclient"),
+        }
+    }
+}
+
+impl From<u8> for Direction {
+    fn from(d: u8) -> Self {
+        if d & (DIR_TOSERVER | DIR_TOCLIENT) == (DIR_TOSERVER | DIR_TOCLIENT) {
+            debug_validate_fail!("Both directions are set");
+            Direction::ToServer
+        } else if d & DIR_TOSERVER != 0 {
+            Direction::ToServer
+        } else if d & DIR_TOCLIENT != 0 {
+            Direction::ToClient
+        } else {
+            debug_validate_fail!("Unknown direction!!");
+            Direction::ToServer
+        }
+    }
+}
+
+impl From<Direction> for u8 {
+    fn from(d: Direction) -> u8 {
+        d as u8
+    }
+}
+
+#[cfg(test)]
+mod test {
+    use super::*;
+
+    #[test]
+    fn test_direction() {
+        assert!(Direction::ToServer.is_to_server());
+        assert!(!Direction::ToServer.is_to_client());
+
+        assert!(Direction::ToClient.is_to_client());
+        assert!(!Direction::ToClient.is_to_server());
+    }
+}
index 67e30c9546c53ce237cddfa12cd4202211c6ecb0..2eb81c6ba37628e7c1089a7a647a6fb39881d85b 100644 (file)
@@ -16,7 +16,7 @@
  */
 
 use super::dns::DNSTransaction;
-use crate::core::Direction;
+use crate::direction::Direction;
 use crate::detect::uint::{detect_match_uint, DetectUintData};
 
 /// Perform the DNS opcode match.
index 6cf2e35ecf6d84084038a3edf181063dc24bc65b..30c1254274b80c23cb43ca7812e24d91f159e8fb 100644 (file)
@@ -22,6 +22,8 @@ use std::ffi::CString;
 
 use crate::applayer::*;
 use crate::core::{self, *};
+use crate::direction::Direction;
+use crate::direction::DIR_BOTH;
 use crate::dns::parser;
 use crate::flow::Flow;
 use crate::frames::Frame;
index ff1b38558bab53b269f6eaabf76e93476131dee4..c652aa01ca2479db5b89103e5286e8b99c65377c 100644 (file)
@@ -40,7 +40,7 @@ use crate::detect::{
     SigMatchAppendSMToList, SIGMATCH_INFO_STICKY_BUFFER, SIGMATCH_NOOPT,
 };
 
-use crate::core::Direction;
+use crate::direction::Direction;
 
 use std::ffi::CStr;
 
index 6b99992f1247ede41ba2e851a6508f510fbea099..daccd011e38253fadafc55bd45bbf418d7a12f3d 100644 (file)
@@ -20,10 +20,11 @@ use super::parser;
 use crate::applayer::{self, *};
 use crate::conf::conf_get;
 use crate::core::{
-    AppProto, Direction, ALPROTO_FAILED, ALPROTO_UNKNOWN, IPPROTO_TCP, IPPROTO_UDP,
+    AppProto, ALPROTO_FAILED, ALPROTO_UNKNOWN, IPPROTO_TCP, IPPROTO_UDP,
     STREAM_TOCLIENT, STREAM_TOSERVER,
 };
 use crate::detect::EnumString;
+use crate::direction::Direction;
 use crate::flow::Flow;
 use crate::frames::Frame;
 use nom7 as nom;
index ac7835843848504c362819e7fb83ab9f02e8524b..b1dba3ea40af582b3238f08838278dcf83d74d6f 100644 (file)
@@ -21,7 +21,7 @@ use crate::applayer::StreamSlice;
 use crate::flow::Flow;
 #[cfg(not(test))]
 use crate::core::STREAM_TOSERVER;
-use crate::core::Direction;
+use crate::direction::Direction;
 
 #[cfg(not(test))]
 #[repr(C)]
index 31e8547a8134b85bf50bdb6f62cc7b47367efba0..8456b43267df36f327c2530d71848b746d568d02 100644 (file)
@@ -15,7 +15,7 @@
 * 02110-1301, USA.
 */
 
-use crate::core::Direction;
+use crate::direction::Direction;
 use brotli;
 use flate2::read::{DeflateDecoder, GzDecoder};
 use std;
index 4a05b29103b5cafdd8d4e1f13215b7c846feb289..66de1313650587674e4401daf1bdeea1c53e4726 100644 (file)
@@ -19,7 +19,7 @@ use super::http2::{
     HTTP2Event, HTTP2Frame, HTTP2FrameTypeData, HTTP2State, HTTP2Transaction, HTTP2TransactionState,
 };
 use super::parser;
-use crate::core::Direction;
+use crate::direction::Direction;
 use crate::detect::uint::{detect_match_uint, DetectUintData};
 use std::ffi::CStr;
 use std::str::FromStr;
index 4934c9e0230a78a2c71c7738ee2550a086beb0d2..f6625fc7860b48f55bd21db1c47247ad9efd792c 100644 (file)
@@ -23,6 +23,7 @@ use super::range;
 use crate::applayer::{self, *};
 use crate::conf::conf_get;
 use crate::core::*;
+use crate::direction::Direction;
 use crate::filecontainer::*;
 use crate::filetracker::*;
 use crate::flow::Flow;
index 0749cc0bc52fed0d48c9fdabd0e95693d4054631..41366f8a16ebb6b8443424e341230ede3885d09d 100644 (file)
@@ -17,8 +17,9 @@
 
 use super::detect;
 use crate::core::{
-    Direction, HttpRangeContainerBlock, StreamingBufferConfig, SuricataFileContext, SC,
+    HttpRangeContainerBlock, StreamingBufferConfig, SuricataFileContext, SC,
 };
+use crate::direction::Direction;
 use crate::flow::Flow;
 use crate::http2::http2::HTTP2Transaction;
 use crate::http2::http2::SURICATA_HTTP2_FILE_CONFIG;
index 81e10af24e17e6530a3580ced0a857ba6176d1c4..aed45f644d70f9ff8f3a3b726118df61c08c8189 100644 (file)
@@ -23,6 +23,7 @@ use self::ipsec_parser::*;
 use crate::applayer;
 use crate::applayer::*;
 use crate::core::{self, *};
+use crate::direction::Direction;
 use crate::flow::Flow;
 use crate::ike::ikev1::{handle_ikev1, IkeV1Header, Ikev1Container};
 use crate::ike::ikev2::{handle_ikev2, Ikev2Container};
index 6f598f9806f6d31feee0f143855c3e2b5fb339fe..4ce29d2a10fa846031e2e4d7c56e765b3c219f94 100644 (file)
@@ -19,7 +19,7 @@
 
 use crate::applayer::*;
 use crate::common::to_hex;
-use crate::core::Direction;
+use crate::direction::Direction;
 use crate::ike::ike::{IKEState, IkeEvent};
 use crate::ike::parser::*;
 use nom7::Err;
index d0d1ab321fcd3835c4d72acb42ab77321da85d26..57635f4ad65ce79cebb9c571ca9eaef147e12db8 100644 (file)
@@ -18,7 +18,7 @@
 // written by Pierre Chifflier  <chifflier@wzdftpd.net>
 
 use crate::applayer::*;
-use crate::core::Direction;
+use crate::direction::Direction;
 use crate::ike::ipsec_parser::*;
 
 use super::ipsec_parser::IkeV2Transform;
index cc5705f5808e1c85c6b4dcefbf404e073464f101..75234575375a46726b7c90df0e6aac5bb490547e 100644 (file)
@@ -17,7 +17,7 @@
 
 use super::ike::{IKEState, IKETransaction};
 use super::ipsec_parser::IKEV2_FLAG_INITIATOR;
-use crate::core::Direction;
+use crate::direction::Direction;
 use crate::ike::parser::{ExchangeType, IsakmpPayloadType, SaAttribute};
 use crate::jsonbuilder::{JsonBuilder, JsonError};
 use num_traits::FromPrimitive;
index b322c7b1726ba985ea4c81d301f032d600521dfa..d2f384a81c133992ad0f216fa6f1b561490a1d96 100644 (file)
@@ -28,7 +28,8 @@ use kerberos_parser::krb5::{EncryptionType,ErrorCode,MessageType,PrincipalName,R
 use asn1_rs::FromDer;
 use crate::applayer::{self, *};
 use crate::core;
-use crate::core::{AppProto,ALPROTO_FAILED,ALPROTO_UNKNOWN,Direction, IPPROTO_TCP, IPPROTO_UDP};
+use crate::core::{AppProto,ALPROTO_FAILED,ALPROTO_UNKNOWN, IPPROTO_TCP, IPPROTO_UDP};
+use crate::direction::Direction;
 use crate::flow::Flow;
 
 #[derive(AppLayerEvent)]
index c17de7f991a5c2e80ac37ecc278a2e7b5d159be7..1aa2e08bbcb901bdb128ecea4113ab0720a93101 100644 (file)
@@ -20,6 +20,7 @@
 use crate::applayer::{self, *};
 use crate::conf::conf_get;
 use crate::core::*;
+use crate::direction::Direction;
 use crate::flow::Flow;
 use crate::frames::*;
 use nom7 as nom;
index 9d2b7990f601e568f7df44d35aa6e473aeddaa32..855ee11e29587549b8fd625299549cb8925a05ec 100644 (file)
@@ -140,6 +140,7 @@ pub mod feature;
 pub mod sdp;
 pub mod ldap;
 pub mod flow;
+pub mod direction;
 
 #[allow(unused_imports)]
 pub use suricata_lua_sys;
index 1a7d0483652f4b4c360871398c9e7b760d18c552..13ad30285fe964368fb3fd5429f23372b6846039 100644 (file)
@@ -1426,7 +1426,7 @@ pub unsafe extern "C" fn ScDetectMqttRegister() {
 #[cfg(test)]
 mod test {
     use super::*;
-    use crate::core::Direction;
+    use crate::direction::Direction;
     use crate::detect::uint::DetectUintMode;
     use crate::mqtt::mqtt::MQTTTransaction;
     use crate::mqtt::mqtt_message::*;
index d4ee6cced3cc5a5dc3f698f553a6de4a9551dd08..d280664604ecaaaf86af82a446b1184ebaf12550 100644 (file)
@@ -23,6 +23,7 @@ use crate::applayer::*;
 use crate::applayer::{self, LoggerFlags};
 use crate::conf::{conf_get, get_memval};
 use crate::core::*;
+use crate::direction::Direction;
 use crate::flow::Flow;
 use crate::frames::*;
 use nom7::Err;
index 04c205aabf9be58db21ab1d938dfe2b31b6a548c..48a6bba1c18bf8350dd968a426d06491a811287b 100644 (file)
@@ -26,6 +26,8 @@ use nom7::{Err, Needed};
 
 use crate::applayer;
 use crate::applayer::*;
+use crate::direction::Direction;
+use crate::direction::DIR_BOTH;
 use crate::flow::Flow;
 use crate::frames::*;
 use crate::core::*;
index 032751f536ca819426ab27443f665df619789db5..de7df344f594d77d87e007706fffeaa2674343b8 100644 (file)
@@ -17,8 +17,7 @@
 
 // written by Victor Julien
 
-use crate::core::*;
-
+use crate::direction::Direction;
 use crate::nfs::nfs::*;
 use crate::nfs::types::*;
 use crate::nfs::rpc_records::*;
index 730e82ba1b608d9358dc35cecdf474b2c7d16b40..0e83b8dafe316a4dc51fe7fc9b2bc6d4d9ddad10 100644 (file)
@@ -21,7 +21,7 @@ use nom7::bytes::streaming::take;
 use nom7::number::streaming::be_u32;
 use nom7::{Err, IResult};
 
-use crate::core::*;
+use crate::direction::Direction;
 use crate::nfs::nfs::*;
 use crate::nfs::nfs4_records::*;
 use crate::nfs::nfs_records::*;
index d4c3d8b41b9887467bec242971058621862872c3..a899210214a8984559a4b6b7ebc6ecdd8ce88b5c 100644 (file)
@@ -20,8 +20,9 @@
 extern crate ntp_parser;
 use self::ntp_parser::*;
 use crate::core;
-use crate::core::{AppProto,ALPROTO_UNKNOWN,ALPROTO_FAILED,Direction};
+use crate::core::{AppProto,ALPROTO_UNKNOWN,ALPROTO_FAILED};
 use crate::applayer::{self, *};
+use crate::direction::Direction;
 use crate::flow::Flow;
 use std;
 use std::ffi::CString;
index af6799118e48c41718952661b73127a6e7f6bdfc..56eaba5633578a0a6abf84d3748c9463fe2ebb14 100644 (file)
@@ -22,7 +22,8 @@
 use super::parser::{self, ConsolidatedDataRowPacket, PgsqlBEMessage, PgsqlFEMessage};
 use crate::applayer::*;
 use crate::conf::*;
-use crate::core::{AppProto, Direction, ALPROTO_FAILED, ALPROTO_UNKNOWN, IPPROTO_TCP, *};
+use crate::core::{AppProto, ALPROTO_FAILED, ALPROTO_UNKNOWN, IPPROTO_TCP, *};
+use crate::direction::Direction;
 use crate::flow::Flow;
 use nom7::{Err, IResult};
 use std;
index 54ebc056883dbb747ae80b344be1f7366584a371..3b0e1f65f30f723572bdd0c954a7581e3bc9473f 100644 (file)
@@ -21,8 +21,8 @@ use super::{
     frames::{Frame, QuicTlsExtension, StreamTag},
     parser::{quic_pkt_num, QuicData, QuicHeader, QuicType},
 };
-use crate::{applayer::{self, *}, flow::Flow};
-use crate::core::{AppProto, Direction, ALPROTO_FAILED, ALPROTO_UNKNOWN, IPPROTO_UDP};
+use crate::{applayer::{self, *}, direction::Direction, flow::Flow};
+use crate::core::{AppProto, ALPROTO_FAILED, ALPROTO_UNKNOWN, IPPROTO_UDP};
 use std::collections::VecDeque;
 use std::ffi::CString;
 use tls_parser::TlsExtensionType;
index d7fcdd235417c48d5c82101f1c1e550b8fdbee43..5c2132dc782aed93dcff18ac67e3c77f54498c6d 100644 (file)
@@ -22,6 +22,7 @@ use super::parser;
 use crate::applayer;
 use crate::applayer::*;
 use crate::core::{AppProto, ALPROTO_UNKNOWN, IPPROTO_TCP};
+use crate::direction::Direction;
 use crate::flow::Flow;
 use crate::frames::*;
 use nom7::Err;
@@ -888,7 +889,7 @@ pub unsafe extern "C" fn SCRfbRegisterParser() {
             b"RFB \0".as_ptr() as *const c_char,
             b"RFB ".len() as u16,
             0,
-            crate::core::Direction::ToServer.into(),
+            Direction::ToServer.into(),
         ) < 0
         {
             SCLogDebug!("Failed to register protocol detection pattern for direction TOSERVER");
@@ -899,7 +900,7 @@ pub unsafe extern "C" fn SCRfbRegisterParser() {
             b"RFB \0".as_ptr() as *const c_char,
             b"RFB ".len() as u16,
             0,
-            crate::core::Direction::ToClient.into(),
+            Direction::ToClient.into(),
         ) < 0
         {
             SCLogDebug!("Failed to register protocol detection pattern for direction TOCLIENT");
index 708d5640a16056671cf3cbde076c7ff97920256a..ff2ec3e06e1334e50a042c53e6cb210857c64339 100644 (file)
@@ -17,7 +17,7 @@
 
 // written by Giuseppe Longo <giuseppe@glongo.it>
 
-use crate::core::Direction;
+use crate::direction::Direction;
 use crate::detect::{
     DetectBufferSetActiveList, DetectHelperBufferMpmRegister, DetectHelperGetData,
     DetectHelperGetMultiData, DetectHelperKeywordRegister, DetectHelperMultiBufferMpmRegister,
index 010da975ca7e7c5fb93b57a874914a100627577c..542746567397a63706724e9651e01f2821468ab5 100755 (executable)
@@ -20,6 +20,7 @@
 use crate::applayer::{self, *};
 use crate::core;
 use crate::core::{AppProto, ALPROTO_UNKNOWN, IPPROTO_TCP, IPPROTO_UDP};
+use crate::direction::Direction;
 use crate::flow::Flow;
 use crate::frames::*;
 use crate::sip::parser::*;
@@ -90,7 +91,7 @@ impl SIPState {
         self.transactions.clear();
     }
 
-    fn new_tx(&mut self, direction: crate::core::Direction) -> SIPTransaction {
+    fn new_tx(&mut self, direction: Direction) -> SIPTransaction {
         self.tx_id += 1;
         SIPTransaction::new(self.tx_id, direction)
     }
@@ -128,7 +129,7 @@ impl SIPState {
 
         match sip_parse_request(input) {
             Ok((_, request)) => {
-                let mut tx = self.new_tx(crate::core::Direction::ToServer);
+                let mut tx = self.new_tx(Direction::ToServer);
                 sip_frames_ts(flow, &stream_slice, &request, tx.id);
                 tx.request = Some(request);
                 if let Ok((_, req_line)) = sip_take_line(input) {
@@ -172,7 +173,7 @@ impl SIPState {
             }
             match sip_parse_request(start) {
                 Ok((rem, request)) => {
-                    let mut tx = self.new_tx(crate::core::Direction::ToServer);
+                    let mut tx = self.new_tx(Direction::ToServer);
                     let tx_id = tx.id;
                     sip_frames_ts(flow, &stream_slice, &request, tx_id);
                     tx.request = Some(request);
@@ -224,7 +225,7 @@ impl SIPState {
 
         match sip_parse_response(input) {
             Ok((_, response)) => {
-                let mut tx = self.new_tx(crate::core::Direction::ToClient);
+                let mut tx = self.new_tx(Direction::ToClient);
                 sip_frames_tc(flow, &stream_slice, &response, tx.id);
                 tx.response = Some(response);
                 if let Ok((_, resp_line)) = sip_take_line(input) {
@@ -267,7 +268,7 @@ impl SIPState {
             }
             match sip_parse_response(start) {
                 Ok((rem, response)) => {
-                    let mut tx = self.new_tx(crate::core::Direction::ToClient);
+                    let mut tx = self.new_tx(Direction::ToClient);
                     let tx_id = tx.id;
                     sip_frames_tc(flow, &stream_slice, &response, tx_id);
                     tx.response = Some(response);
@@ -307,7 +308,7 @@ impl SIPState {
 }
 
 impl SIPTransaction {
-    pub fn new(id: u64, direction: crate::core::Direction) -> SIPTransaction {
+    pub fn new(id: u64, direction: Direction) -> SIPTransaction {
         SIPTransaction {
             id,
             request: None,
@@ -515,7 +516,7 @@ fn register_pattern_probe(proto: u8) -> i8 {
                 method.as_ptr() as *const std::os::raw::c_char,
                 depth,
                 0,
-                core::Direction::ToServer as u8,
+                Direction::ToServer as u8,
             );
         }
         r |= AppLayerProtoDetectPMRegisterPatternCS(
@@ -524,7 +525,7 @@ fn register_pattern_probe(proto: u8) -> i8 {
             b"SIP/2.0\0".as_ptr() as *const std::os::raw::c_char,
             8,
             0,
-            core::Direction::ToClient as u8,
+            Direction::ToClient as u8,
         );
         if proto == core::IPPROTO_UDP {
             r |= AppLayerProtoDetectPMRegisterPatternCS(
@@ -533,7 +534,7 @@ fn register_pattern_probe(proto: u8) -> i8 {
                 "UPDATE\0".as_ptr() as *const std::os::raw::c_char,
                 "UPDATE".len() as u16,
                 0,
-                core::Direction::ToServer as u8,
+                Direction::ToServer as u8,
             );
         }
     }
index 968641406bd7b893e4d1ddad565e1807dbbc39bf..cbe2454233362f55496169fddbc487394987a1f4 100644 (file)
  * 02110-1301, USA.
  */
 
-use crate::core::*;
 use crate::dcerpc::dcerpc::DCERPC_TYPE_REQUEST;
 use crate::dcerpc::detect::{DCEIfaceData, DCEOpnumData, DETECT_DCE_OPNUM_RANGE_UNINITIALIZED};
 use crate::detect::uint::detect_match_uint;
+use crate::direction::Direction;
 use crate::smb::smb::*;
 use std::ffi::CStr;
 use std::os::raw::{c_char, c_void};
index e1de7d171a0f7e3ccfcb9b1beb8d3b2bb5a49d1c..c68f3eb07725dd1e689f375aa094b58a9c237e50 100644 (file)
@@ -17,6 +17,7 @@
 
 use std;
 use crate::core::*;
+use crate::direction::Direction;
 use crate::filetracker::*;
 use crate::filecontainer::*;
 
index 9cc5c83ec1783fb9be83e9dca175cad85a778312..43a44545ad0968f4caa82653b0587a4852ede211 100644 (file)
@@ -39,6 +39,7 @@ use std::num::NonZeroUsize;
 use crate::core::*;
 use crate::applayer;
 use crate::applayer::*;
+use crate::direction::Direction;
 use crate::flow::{Flow, FLOW_DIR_REVERSED};
 use crate::frames::*;
 use crate::conf::*;
index c74ab5fd02693ba9067623bf39d8caf144acbcad..474e5d4e541303effed791910cc45f991f31d023 100644 (file)
@@ -19,8 +19,7 @@
  * - check all parsers for calls on non-SUCCESS status
  */
 
-use crate::core::*;
-
+use crate::direction::Direction;
 use crate::smb::smb::*;
 use crate::smb::dcerpc::*;
 use crate::smb::events::*;
index 97deb702ecef793cddf81077286848c377ac624c..b364d66a996e1b8f46f39a61c7a1da2337d31397 100644 (file)
@@ -17,8 +17,7 @@
 
 use nom7::Err;
 
-use crate::core::*;
-
+use crate::direction::Direction;
 use crate::smb::smb::*;
 use crate::smb::smb2_records::*;
 use crate::smb::smb2_session::*;
index d31e0a26bffdd49a540b4d8299cbe9f78ae52fa3..64846eaf3070289a271bd5e07c5fba7e67e4cc80 100644 (file)
@@ -17,6 +17,7 @@
 
 // written by Pierre Chifflier  <chifflier@wzdftpd.net>
 
+use crate::direction::Direction;
 use crate::flow::Flow;
 use crate::snmp::snmp_parser::*;
 use crate::core::{self, *};
index 6aa18cdac781fb3ee9ec380d754786490b69017e..a8ba19ffa8380ae0d36d67c17e89a02a549a2c72 100644 (file)
@@ -16,7 +16,7 @@
  */
 
 use super::ssh::SSHTransaction;
-use crate::core::Direction;
+use crate::direction::Direction;
 use std::ptr;
 
 #[no_mangle]
index c75d56f6e422a0dc2eda595d24d63220792addaa..c0a7677d42f7a6229ad89cd24d9e833ced701564 100644 (file)
@@ -18,6 +18,7 @@
 use super::parser;
 use crate::applayer::*;
 use crate::core::*;
+use crate::direction::Direction;
 use crate::flow::Flow;
 use nom7::Err;
 use std::ffi::CString;
index 0a3f92525cd6be849c7e0a34017995da0ed6df30..1138ab759ab170754ccdf1593874d3916fe3dda6 100644 (file)
@@ -18,7 +18,8 @@
 use super::parser;
 use crate::applayer::{self, *};
 use crate::conf::conf_get;
-use crate::core::{AppProto, Direction, ALPROTO_FAILED, ALPROTO_UNKNOWN, IPPROTO_TCP};
+use crate::core::{AppProto, ALPROTO_FAILED, ALPROTO_UNKNOWN, IPPROTO_TCP};
+use crate::direction::Direction;
 use crate::flow::Flow;
 use crate::frames::Frame;