]> git.ipfire.org Git - people/ms/suricata.git/commitdiff
rust: merge parser.rs into applayer.rs
authorVictor Julien <victor@inliniac.net>
Fri, 13 Mar 2020 19:01:21 +0000 (20:01 +0100)
committerVictor Julien <victor@inliniac.net>
Tue, 17 Mar 2020 21:03:23 +0000 (22:03 +0100)
Both were serving the same purpose.

14 files changed:
rust/src/applayer.rs
rust/src/applayertemplate/template.rs
rust/src/dhcp/dhcp.rs
rust/src/dns/dns.rs
rust/src/ikev2/ikev2.rs
rust/src/krb/krb5.rs
rust/src/lib.rs
rust/src/nfs/nfs.rs
rust/src/ntp/ntp.rs
rust/src/parser.rs [deleted file]
rust/src/rdp/rdp.rs
rust/src/sip/sip.rs
rust/src/smb/smb.rs
rust/src/snmp/snmp.rs

index 8ca5838afaa7c7503b5bf06206bba19da6671786..6fca0f9ff0257bd1fe243fb71390203ce938882a 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2017 Open Information Security Foundation
+/* Copyright (C) 2017-2020 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
  * 02110-1301, USA.
  */
 
+//! Parser registration functions and common interface
+
 use std;
 use crate::core::{STREAM_TOSERVER};
+use crate::core::{DetectEngineState,Flow,AppLayerEventType,AppLayerDecoderEvents,AppProto};
+use crate::filecontainer::FileContainer;
+use crate::applayer;
+use std::os::raw::{c_void,c_char,c_int};
+
+#[repr(C)]
+pub struct AppLayerResult {
+    pub status: i32,
+    pub consumed: u32,
+    pub needed: u32,
+}
+
+impl AppLayerResult {
+    /// parser has successfully processed in the input, and has consumed all of it
+    pub fn ok() -> AppLayerResult {
+        return AppLayerResult {
+            status: 0,
+            consumed: 0,
+            needed: 0,
+        };
+    }
+    /// parser has hit an unrecoverable error. Returning this to the API
+    /// leads to no further calls to the parser.
+    pub fn err() -> AppLayerResult {
+        return AppLayerResult {
+            status: -1,
+            consumed: 0,
+            needed: 0,
+        };
+    }
+    /// parser needs more data. Through 'consumed' it will indicate how many
+    /// of the input bytes it has consumed. Through 'needed' it will indicate
+    /// how many more bytes it needs before getting called again.
+    /// Note: consumed should never be more than the input len
+    ///       needed + consumed should be more than the input len
+    pub fn incomplete(consumed: u32, needed: u32) -> AppLayerResult {
+        return AppLayerResult {
+            status: 1,
+            consumed: consumed,
+            needed: needed,
+        };
+    }
+}
+
+/// Rust parser declaration
+#[repr(C)]
+pub struct RustParser {
+    /// Parser name.
+    pub name:               *const c_char,
+    /// Default port
+    pub default_port:       *const c_char,
+
+    /// IP Protocol (core::IPPROTO_UDP, core::IPPROTO_TCP, etc.)
+    pub ipproto:            c_int,
+
+    /// Probing function, for packets going to server
+    pub probe_ts:           Option<ProbeFn>,
+    /// Probing function, for packets going to client
+    pub probe_tc:           Option<ProbeFn>,
+
+    /// Minimum frame depth for probing
+    pub min_depth:          u16,
+    /// Maximum frame depth for probing
+    pub max_depth:          u16,
+
+    /// Allocation function for a new state
+    pub state_new:          StateAllocFn,
+    /// Function called to free a state
+    pub state_free:         StateFreeFn,
+
+    /// Parsing function, for packets going to server
+    pub parse_ts:           ParseFn,
+    /// Parsing function, for packets going to client
+    pub parse_tc:           ParseFn,
+
+    /// Get the current transaction count
+    pub get_tx_count:       StateGetTxCntFn,
+    /// Get a transaction
+    pub get_tx:             StateGetTxFn,
+    /// Function called to free a transaction
+    pub tx_free:            StateTxFreeFn,
+    /// Function returning the current transaction completion status
+    pub tx_get_comp_st:     StateGetTxCompletionStatusFn,
+    /// Function returning the current transaction progress
+    pub tx_get_progress:    StateGetProgressFn,
+
+    /// Logged transaction getter function
+    pub get_tx_logged:      Option<GetTxLoggedFn>,
+    /// Logged transaction setter function
+    pub set_tx_logged:      Option<SetTxLoggedFn>,
+
+    /// Function called to get a detection state
+    pub get_de_state:       GetDetectStateFn,
+    /// Function called to set a detection state
+    pub set_de_state:       SetDetectStateFn,
+
+    /// Function to get events
+    pub get_events:         Option<GetEventsFn>,
+    /// Function to get an event id from a description
+    pub get_eventinfo:      Option<GetEventInfoFn>,
+    /// Function to get an event description from an event id
+    pub get_eventinfo_byid: Option<GetEventInfoByIdFn>,
+
+    /// Function to allocate local storage
+    pub localstorage_new:   Option<LocalStorageNewFn>,
+    /// Function to free local storage
+    pub localstorage_free:  Option<LocalStorageFreeFn>,
+
+    /// Function to get transaction MPM ID
+    pub get_tx_mpm_id:      Option<GetTxMpmIDFn>,
+    /// Function to set transaction MPM ID
+    pub set_tx_mpm_id:      Option<SetTxMpmIDFn>,
+
+    /// Function to get files
+    pub get_files:          Option<GetFilesFn>,
+
+    /// Function to get the TX iterator
+    pub get_tx_iterator:    Option<GetTxIteratorFn>,
+
+    // Function to set TX detect flags.
+    pub set_tx_detect_flags: Option<SetTxDetectFlagsFn>,
+
+    // Function to get TX detect flags.
+    pub get_tx_detect_flags: Option<GetTxDetectFlagsFn>,
+}
+
+/// Create a slice, given a buffer and a length
+///
+/// UNSAFE !
+#[macro_export]
+macro_rules! build_slice {
+    ($buf:ident, $len:expr) => ( unsafe{ std::slice::from_raw_parts($buf, $len) } );
+}
+
+/// Cast pointer to a variable, as a mutable reference to an object
+///
+/// UNSAFE !
+#[macro_export]
+macro_rules! cast_pointer {
+    ($ptr:ident, $ty:ty) => ( unsafe{ &mut *($ptr as *mut $ty) } );
+}
+
+pub type ParseFn      = extern "C" fn (flow: *const Flow,
+                                       state: *mut c_void,
+                                       pstate: *mut c_void,
+                                       input: *const u8,
+                                       input_len: u32,
+                                       data: *const c_void,
+                                       flags: u8) -> AppLayerResult;
+pub type ProbeFn      = extern "C" fn (flow: *const Flow,direction: u8,input:*const u8, input_len: u32, rdir: *mut u8) -> AppProto;
+pub type StateAllocFn = extern "C" fn () -> *mut c_void;
+pub type StateFreeFn  = extern "C" fn (*mut c_void);
+pub type StateTxFreeFn  = extern "C" fn (*mut c_void, u64);
+pub type StateGetTxFn            = extern "C" fn (*mut c_void, u64) -> *mut c_void;
+pub type StateGetTxCntFn         = extern "C" fn (*mut c_void) -> u64;
+pub type StateGetTxCompletionStatusFn = extern "C" fn (u8) -> c_int;
+pub type StateGetProgressFn = extern "C" fn (*mut c_void, u8) -> c_int;
+pub type GetDetectStateFn   = extern "C" fn (*mut c_void) -> *mut DetectEngineState;
+pub type SetDetectStateFn   = extern "C" fn (*mut c_void, &mut DetectEngineState) -> c_int;
+pub type GetEventInfoFn     = extern "C" fn (*const c_char, *mut c_int, *mut AppLayerEventType) -> c_int;
+pub type GetEventInfoByIdFn = extern "C" fn (c_int, *mut *const c_char, *mut AppLayerEventType) -> i8;
+pub type GetEventsFn        = extern "C" fn (*mut c_void) -> *mut AppLayerDecoderEvents;
+pub type GetTxLoggedFn      = extern "C" fn (*mut c_void, *mut c_void) -> u32;
+pub type SetTxLoggedFn      = extern "C" fn (*mut c_void, *mut c_void, u32);
+pub type LocalStorageNewFn  = extern "C" fn () -> *mut c_void;
+pub type LocalStorageFreeFn = extern "C" fn (*mut c_void);
+pub type GetTxMpmIDFn       = extern "C" fn (*mut c_void) -> u64;
+pub type SetTxMpmIDFn       = extern "C" fn (*mut c_void, u64) -> c_int;
+pub type GetFilesFn         = extern "C" fn (*mut c_void, u8) -> *mut FileContainer;
+pub type GetTxIteratorFn    = extern "C" fn (ipproto: u8, alproto: AppProto,
+                                             state: *mut c_void,
+                                             min_tx_id: u64,
+                                             max_tx_id: u64,
+                                             istate: &mut u64)
+                                             -> AppLayerGetTxIterTuple;
+pub type GetTxDetectFlagsFn = unsafe extern "C" fn(*mut c_void, u8) -> u64;
+pub type SetTxDetectFlagsFn = unsafe extern "C" fn(*mut c_void, u8, u64);
+
+// Defined in app-layer-register.h
+extern {
+    pub fn AppLayerRegisterProtocolDetection(parser: *const RustParser, enable_default: c_int) -> AppProto;
+    pub fn AppLayerRegisterParser(parser: *const RustParser, alproto: AppProto) -> c_int;
+}
+
+// Defined in app-layer-detect-proto.h
+extern {
+    pub fn AppLayerProtoDetectConfProtoDetectionEnabled(ipproto: *const c_char, proto: *const c_char) -> c_int;
+}
+
+// Defined in app-layer-parser.h
+pub const APP_LAYER_PARSER_EOF : u8 = 0b0;
+pub const APP_LAYER_PARSER_NO_INSPECTION : u8 = 0b1;
+pub const APP_LAYER_PARSER_NO_REASSEMBLY : u8 = 0b10;
+pub const APP_LAYER_PARSER_NO_INSPECTION_PAYLOAD : u8 = 0b100;
+pub const APP_LAYER_PARSER_BYPASS_READY : u8 = 0b1000;
 
 pub const APP_LAYER_PARSER_OPT_ACCEPT_GAPS: u32 = BIT_U32!(0);
 
+pub type AppLayerGetTxIteratorFn = extern "C" fn (ipproto: u8,
+                                                  alproto: AppProto,
+                                                  alstate: *mut c_void,
+                                                  min_tx_id: u64,
+                                                  max_tx_id: u64,
+                                                  istate: &mut u64) -> applayer::AppLayerGetTxIterTuple;
+
+extern {
+    pub fn AppLayerParserStateSetFlag(state: *mut c_void, flag: u8);
+    pub fn AppLayerParserStateIssetFlag(state: *mut c_void, flag: u8) -> c_int;
+    pub fn AppLayerParserConfParserEnabled(ipproto: *const c_char, proto: *const c_char) -> c_int;
+    pub fn AppLayerParserRegisterGetTxIterator(ipproto: u8, alproto: AppProto, fun: AppLayerGetTxIteratorFn);
+    pub fn AppLayerParserRegisterDetectFlagsFuncs(
+        ipproto: u8,
+        alproto: AppProto,
+        GetTxDetectFlats: GetTxDetectFlagsFn,
+        SetTxDetectFlags: SetTxDetectFlagsFn,
+    );
+    pub fn AppLayerParserRegisterOptionFlags(ipproto: u8, alproto: AppProto, flags: u32);
+}
+
 #[repr(C)]
 pub struct AppLayerGetTxIterTuple {
     tx_ptr: *mut std::os::raw::c_void,
index 385afd96e4622d5c72c5238080d0a2f717d3f0d0..7b80fbba5b449793194d161148d7fb2d7b36ee6c 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2018 Open Information Security Foundation
+/* Copyright (C) 2018-2020 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
@@ -19,8 +19,7 @@ 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::*;
+use crate::applayer::{self, *};
 use std::ffi::CString;
 use nom;
 use super::parser;
index 9ffefc19ec6d33eb19d3ad35d3251a22dbc1d64b..77eff829fc8de60bf76f22115a5649f5a498e5c3 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2018 Open Information Security Foundation
+/* Copyright (C) 2018-2020 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
  * 02110-1301, USA.
  */
 
-use crate::applayer;
+use crate::applayer::{self, *};
 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};
 use std::mem::transmute;
index 69ebf0d5fdd96a940d5ca5474d6e511b22e93db7..fd0338dfee8e04f934a15a251856f24dd25299dc 100644 (file)
@@ -22,10 +22,9 @@ use std::ffi::CString;
 use std::mem::transmute;
 
 use crate::log::*;
-use crate::applayer::LoggerFlags;
+use crate::applayer::*;
 use crate::core::{self, AppProto, ALPROTO_UNKNOWN, IPPROTO_UDP, IPPROTO_TCP};
 use crate::dns::parser;
-use crate::parser::*;
 
 use nom::IResult;
 use nom::number::streaming::be_u16;
index eb3dfc80886eb779c7c4765804b4061d0b9d7061..2e8864af677ec24c1a1888ed5eeae0a1168483ba 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2017-2018 Open Information Security Foundation
+/* Copyright (C) 2017-2020 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
@@ -21,8 +21,7 @@ use crate::ikev2::ipsec_parser::*;
 use crate::ikev2::state::IKEV2ConnectionState;
 use crate::core;
 use crate::core::{AppProto,Flow,ALPROTO_UNKNOWN,ALPROTO_FAILED,STREAM_TOSERVER,STREAM_TOCLIENT};
-use crate::applayer;
-use crate::parser::*;
+use crate::applayer::{self, *};
 use std;
 use std::ffi::{CStr,CString};
 
index bd28d4806050f48aa2ba57fd650fc27f5b750918..8ed7c5ba3badc90da21e5b6e051ac92d5eaf45af 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2017-2018 Open Information Security Foundation
+/* Copyright (C) 2017-2020 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
@@ -25,10 +25,9 @@ use nom::number::streaming::be_u32;
 use der_parser::der::der_read_element_header;
 use kerberos_parser::krb5_parser;
 use kerberos_parser::krb5::{EncryptionType,ErrorCode,MessageType,PrincipalName,Realm};
-use crate::applayer;
+use crate::applayer::{self, *};
 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::*;
 
index 81ada2101ccc89f573360db3a48c4686d94529dd..a9b6c756ceb2fc6fc1c795de90761c48a72f38f1 100644 (file)
@@ -48,8 +48,6 @@ pub mod json;
 pub mod applayer;
 pub mod filecontainer;
 pub mod filetracker;
-#[macro_use]
-pub mod parser;
 pub mod kerberos;
 
 #[cfg(feature = "lua")]
index b9916c803a0b657a6a0b58f91c33cb77509fa8db..0ac14a7246f3de82ae1bd889cadcbac913de5050 100644 (file)
@@ -27,8 +27,7 @@ use nom;
 
 use crate::log::*;
 use crate::applayer;
-use crate::applayer::LoggerFlags;
-use crate::parser::AppLayerResult;
+use crate::applayer::{LoggerFlags, AppLayerResult};
 use crate::core::*;
 use crate::filetracker::*;
 use crate::filecontainer::*;
index 76118da32c4c5d0231cb061c42f27151f343b089..7811d78da50c0f6a9845577937d7f1eaeb022bbf 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2017 Open Information Security Foundation
+/* Copyright (C) 2017-2020 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
@@ -21,8 +21,7 @@ extern crate ntp_parser;
 use self::ntp_parser::*;
 use crate::core;
 use crate::core::{AppProto,Flow,ALPROTO_UNKNOWN,ALPROTO_FAILED};
-use crate::applayer;
-use crate::parser::*;
+use crate::applayer::{self, *};
 use std;
 use std::ffi::{CStr,CString};
 
diff --git a/rust/src/parser.rs b/rust/src/parser.rs
deleted file mode 100644 (file)
index 0970532..0000000
+++ /dev/null
@@ -1,242 +0,0 @@
-/* Copyright (C) 2017-2020 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.
- */
-
-// written by Pierre Chifflier  <chifflier@wzdftpd.net>
-
-//! Parser registration functions and common interface
-
-use crate::core::{DetectEngineState,Flow,AppLayerEventType,AppLayerDecoderEvents,AppProto};
-use crate::filecontainer::FileContainer;
-use crate::applayer;
-
-use std::os::raw::{c_void,c_char,c_int};
-use crate::applayer::{AppLayerGetTxIterTuple};
-
-#[repr(C)]
-pub struct AppLayerResult {
-    pub status: i32,
-    pub consumed: u32,
-    pub needed: u32,
-}
-
-impl AppLayerResult {
-    /// parser has successfully processed in the input, and has consumed all of it
-    pub fn ok() -> AppLayerResult {
-        return AppLayerResult {
-            status: 0,
-            consumed: 0,
-            needed: 0,
-        };
-    }
-    /// parser has hit an unrecoverable error. Returning this to the API
-    /// leads to no further calls to the parser.
-    pub fn err() -> AppLayerResult {
-        return AppLayerResult {
-            status: -1,
-            consumed: 0,
-            needed: 0,
-        };
-    }
-    /// parser needs more data. Through 'consumed' it will indicate how many
-    /// of the input bytes it has consumed. Through 'needed' it will indicate
-    /// how many more bytes it needs before getting called again.
-    /// Note: consumed should never be more than the input len
-    ///       needed + consumed should be more than the input len
-    pub fn incomplete(consumed: u32, needed: u32) -> AppLayerResult {
-        return AppLayerResult {
-            status: 1,
-            consumed: consumed,
-            needed: needed,
-        };
-    }
-}
-
-/// Rust parser declaration
-#[repr(C)]
-pub struct RustParser {
-    /// Parser name.
-    pub name:               *const c_char,
-    /// Default port
-    pub default_port:       *const c_char,
-
-    /// IP Protocol (core::IPPROTO_UDP, core::IPPROTO_TCP, etc.)
-    pub ipproto:            c_int,
-
-    /// Probing function, for packets going to server
-    pub probe_ts:           Option<ProbeFn>,
-    /// Probing function, for packets going to client
-    pub probe_tc:           Option<ProbeFn>,
-
-    /// Minimum frame depth for probing
-    pub min_depth:          u16,
-    /// Maximum frame depth for probing
-    pub max_depth:          u16,
-
-    /// Allocation function for a new state
-    pub state_new:          StateAllocFn,
-    /// Function called to free a state
-    pub state_free:         StateFreeFn,
-
-    /// Parsing function, for packets going to server
-    pub parse_ts:           ParseFn,
-    /// Parsing function, for packets going to client
-    pub parse_tc:           ParseFn,
-
-    /// Get the current transaction count
-    pub get_tx_count:       StateGetTxCntFn,
-    /// Get a transaction
-    pub get_tx:             StateGetTxFn,
-    /// Function called to free a transaction
-    pub tx_free:            StateTxFreeFn,
-    /// Function returning the current transaction completion status
-    pub tx_get_comp_st:     StateGetTxCompletionStatusFn,
-    /// Function returning the current transaction progress
-    pub tx_get_progress:    StateGetProgressFn,
-
-    /// Logged transaction getter function
-    pub get_tx_logged:      Option<GetTxLoggedFn>,
-    /// Logged transaction setter function
-    pub set_tx_logged:      Option<SetTxLoggedFn>,
-
-    /// Function called to get a detection state
-    pub get_de_state:       GetDetectStateFn,
-    /// Function called to set a detection state
-    pub set_de_state:       SetDetectStateFn,
-
-    /// Function to get events
-    pub get_events:         Option<GetEventsFn>,
-    /// Function to get an event id from a description
-    pub get_eventinfo:      Option<GetEventInfoFn>,
-    /// Function to get an event description from an event id
-    pub get_eventinfo_byid: Option<GetEventInfoByIdFn>,
-
-    /// Function to allocate local storage
-    pub localstorage_new:   Option<LocalStorageNewFn>,
-    /// Function to free local storage
-    pub localstorage_free:  Option<LocalStorageFreeFn>,
-
-    /// Function to get transaction MPM ID
-    pub get_tx_mpm_id:      Option<GetTxMpmIDFn>,
-    /// Function to set transaction MPM ID
-    pub set_tx_mpm_id:      Option<SetTxMpmIDFn>,
-
-    /// Function to get files
-    pub get_files:          Option<GetFilesFn>,
-
-    /// Function to get the TX iterator
-    pub get_tx_iterator:    Option<GetTxIteratorFn>,
-
-    // Function to set TX detect flags.
-    pub set_tx_detect_flags: Option<SetTxDetectFlagsFn>,
-
-    // Function to get TX detect flags.
-    pub get_tx_detect_flags: Option<GetTxDetectFlagsFn>,
-}
-
-
-
-
-/// Create a slice, given a buffer and a length
-///
-/// UNSAFE !
-#[macro_export]
-macro_rules! build_slice {
-    ($buf:ident, $len:expr) => ( unsafe{ std::slice::from_raw_parts($buf, $len) } );
-}
-
-/// Cast pointer to a variable, as a mutable reference to an object
-///
-/// UNSAFE !
-#[macro_export]
-macro_rules! cast_pointer {
-    ($ptr:ident, $ty:ty) => ( unsafe{ &mut *($ptr as *mut $ty) } );
-}
-
-pub type ParseFn      = extern "C" fn (flow: *const Flow,
-                                       state: *mut c_void,
-                                       pstate: *mut c_void,
-                                       input: *const u8,
-                                       input_len: u32,
-                                       data: *const c_void,
-                                       flags: u8) -> AppLayerResult;
-pub type ProbeFn      = extern "C" fn (flow: *const Flow,direction: u8,input:*const u8, input_len: u32, rdir: *mut u8) -> AppProto;
-pub type StateAllocFn = extern "C" fn () -> *mut c_void;
-pub type StateFreeFn  = extern "C" fn (*mut c_void);
-pub type StateTxFreeFn  = extern "C" fn (*mut c_void, u64);
-pub type StateGetTxFn            = extern "C" fn (*mut c_void, u64) -> *mut c_void;
-pub type StateGetTxCntFn         = extern "C" fn (*mut c_void) -> u64;
-pub type StateGetTxCompletionStatusFn = extern "C" fn (u8) -> c_int;
-pub type StateGetProgressFn = extern "C" fn (*mut c_void, u8) -> c_int;
-pub type GetDetectStateFn   = extern "C" fn (*mut c_void) -> *mut DetectEngineState;
-pub type SetDetectStateFn   = extern "C" fn (*mut c_void, &mut DetectEngineState) -> c_int;
-pub type GetEventInfoFn     = extern "C" fn (*const c_char, *mut c_int, *mut AppLayerEventType) -> c_int;
-pub type GetEventInfoByIdFn = extern "C" fn (c_int, *mut *const c_char, *mut AppLayerEventType) -> i8;
-pub type GetEventsFn        = extern "C" fn (*mut c_void) -> *mut AppLayerDecoderEvents;
-pub type GetTxLoggedFn      = extern "C" fn (*mut c_void, *mut c_void) -> u32;
-pub type SetTxLoggedFn      = extern "C" fn (*mut c_void, *mut c_void, u32);
-pub type LocalStorageNewFn  = extern "C" fn () -> *mut c_void;
-pub type LocalStorageFreeFn = extern "C" fn (*mut c_void);
-pub type GetTxMpmIDFn       = extern "C" fn (*mut c_void) -> u64;
-pub type SetTxMpmIDFn       = extern "C" fn (*mut c_void, u64) -> c_int;
-pub type GetFilesFn         = extern "C" fn (*mut c_void, u8) -> *mut FileContainer;
-pub type GetTxIteratorFn    = extern "C" fn (ipproto: u8, alproto: AppProto,
-                                             state: *mut c_void,
-                                             min_tx_id: u64,
-                                             max_tx_id: u64,
-                                             istate: &mut u64)
-                                             -> AppLayerGetTxIterTuple;
-pub type GetTxDetectFlagsFn = unsafe extern "C" fn(*mut c_void, u8) -> u64;
-pub type SetTxDetectFlagsFn = unsafe extern "C" fn(*mut c_void, u8, u64);
-
-// Defined in app-layer-register.h
-extern {
-    pub fn AppLayerRegisterProtocolDetection(parser: *const RustParser, enable_default: c_int) -> AppProto;
-    pub fn AppLayerRegisterParser(parser: *const RustParser, alproto: AppProto) -> c_int;
-}
-
-// Defined in app-layer-detect-proto.h
-extern {
-    pub fn AppLayerProtoDetectConfProtoDetectionEnabled(ipproto: *const c_char, proto: *const c_char) -> c_int;
-}
-
-// Defined in app-layer-parser.h
-pub const APP_LAYER_PARSER_EOF : u8 = 0b0;
-pub const APP_LAYER_PARSER_NO_INSPECTION : u8 = 0b1;
-pub const APP_LAYER_PARSER_NO_REASSEMBLY : u8 = 0b10;
-pub const APP_LAYER_PARSER_NO_INSPECTION_PAYLOAD : u8 = 0b100;
-pub const APP_LAYER_PARSER_BYPASS_READY : u8 = 0b1000;
-
-pub type AppLayerGetTxIteratorFn = extern "C" fn (ipproto: u8,
-                                                  alproto: AppProto,
-                                                  alstate: *mut c_void,
-                                                  min_tx_id: u64,
-                                                  max_tx_id: u64,
-                                                  istate: &mut u64) -> applayer::AppLayerGetTxIterTuple;
-
-extern {
-    pub fn AppLayerParserStateSetFlag(state: *mut c_void, flag: u8);
-    pub fn AppLayerParserStateIssetFlag(state: *mut c_void, flag: u8) -> c_int;
-    pub fn AppLayerParserConfParserEnabled(ipproto: *const c_char, proto: *const c_char) -> c_int;
-    pub fn AppLayerParserRegisterGetTxIterator(ipproto: u8, alproto: AppProto, fun: AppLayerGetTxIteratorFn);
-    pub fn AppLayerParserRegisterDetectFlagsFuncs(
-        ipproto: u8,
-        alproto: AppProto,
-        GetTxDetectFlats: GetTxDetectFlagsFn,
-        SetTxDetectFlags: SetTxDetectFlagsFn,
-    );
-    pub fn AppLayerParserRegisterOptionFlags(ipproto: u8, alproto: AppProto, flags: u32);
-}
index 36533cb0c06ce1cdf33a1b002901ee8b03949796..80c70ac343e6a27ac8d6d073e4443afd9ebcad3b 100644 (file)
@@ -24,7 +24,7 @@ use crate::core::{
 };
 use crate::conf;
 use nom;
-use crate::parser::*;
+use crate::applayer::*;
 use crate::rdp::parser::*;
 use std;
 use std::mem::transmute;
index a8e4299f50f3f388f786c86fae4d0683a40cf829..0733306b3e60b98da2482b69fee33106d9026c7a 100755 (executable)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2019 Open Information Security Foundation
+/* Copyright (C) 2019-2020 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
 
 extern crate nom;
 
-use crate::applayer;
+use crate::applayer::{self, *};
 use crate::conf;
 use crate::core;
 use crate::core::{sc_detect_engine_state_free, AppProto, Flow, ALPROTO_UNKNOWN};
 use crate::log::*;
-use crate::parser::*;
 use crate::sip::parser::*;
 use std;
 use std::ffi::{CStr, CString};
index c8fc4fcdee5fa0b1b11c850eafdd315784b1a851..45033c37ee6ecd12ac79382ec3c14d72aa16107c 100644 (file)
@@ -37,8 +37,7 @@ use nom;
 use crate::core::*;
 use crate::log::*;
 use crate::applayer;
-use crate::applayer::LoggerFlags;
-use crate::parser::AppLayerResult;
+use crate::applayer::{LoggerFlags, AppLayerResult};
 
 use crate::smb::nbss_records::*;
 use crate::smb::smb1_records::*;
index b8b1d9be2dfad1006343796a21a7a41fce7a3c00..b555f15baf469cb3582246e8be58a798d1d96db3 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2017-2019 Open Information Security Foundation
+/* Copyright (C) 2017-2020 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
@@ -20,8 +20,7 @@
 use crate::snmp::snmp_parser::*;
 use crate::core;
 use crate::core::{AppProto,Flow,ALPROTO_UNKNOWN,ALPROTO_FAILED,STREAM_TOSERVER,STREAM_TOCLIENT};
-use crate::applayer;
-use crate::parser::*;
+use crate::applayer::{self, *};
 use std;
 use std::ffi::{CStr,CString};
 use std::mem::transmute;