]> git.ipfire.org Git - people/ms/suricata.git/commitdiff
app-layer: include DetectEngineState in AppLayerTxData
authorJason Ish <jason.ish@oisf.net>
Tue, 9 Nov 2021 23:14:20 +0000 (17:14 -0600)
committerVictor Julien <vjulien@oisf.net>
Mon, 22 Nov 2021 09:24:05 +0000 (10:24 +0100)
Every transaction has an existing mandatory field, tx_data. As
DetectEngineState is also mandatory, include it in tx_data.

This allows us to remove the boilerplate every app-layer has
for managing detect engine state.

38 files changed:
rust/src/applayer.rs
rust/src/applayertemplate/template.rs
rust/src/dcerpc/dcerpc.rs
rust/src/dcerpc/dcerpc_udp.rs
rust/src/dhcp/dhcp.rs
rust/src/dns/dns.rs
rust/src/http2/http2.rs
rust/src/ike/ike.rs
rust/src/krb/krb5.rs
rust/src/modbus/modbus.rs
rust/src/mqtt/mqtt.rs
rust/src/nfs/nfs.rs
rust/src/ntp/ntp.rs
rust/src/rdp/rdp.rs
rust/src/rfb/rfb.rs
rust/src/sip/sip.rs
rust/src/smb/smb.rs
rust/src/snmp/snmp.rs
rust/src/ssh/ssh.rs
src/app-layer-dnp3.c
src/app-layer-dnp3.h
src/app-layer-enip-common.h
src/app-layer-enip.c
src/app-layer-ftp.c
src/app-layer-ftp.h
src/app-layer-htp.c
src/app-layer-htp.h
src/app-layer-parser.c
src/app-layer-parser.h
src/app-layer-register.c
src/app-layer-register.h
src/app-layer-smtp.c
src/app-layer-smtp.h
src/app-layer-ssl.c
src/app-layer-ssl.h
src/app-layer-template.c
src/app-layer-template.h
src/app-layer-tftp.c

index a9ac44394d28d62b90caaf825f53653e0b1b0823..d9e63547558a9e342012d6bacb65e9f524c877a3 100644 (file)
@@ -51,7 +51,7 @@ impl AppLayerTxConfig {
 }
 
 #[repr(C)]
-#[derive(Default, Debug,PartialEq)]
+#[derive(Debug, PartialEq)]
 pub struct AppLayerTxData {
     /// config: log flags
     pub config: AppLayerTxConfig,
@@ -67,6 +67,22 @@ pub struct AppLayerTxData {
     /// detection engine flags for use by detection engine
     detect_flags_ts: u64,
     detect_flags_tc: u64,
+
+    de_state: *mut DetectEngineState,
+}
+
+impl Default for AppLayerTxData {
+    fn default() -> Self {
+        Self::new()
+    }
+}
+
+impl Drop for AppLayerTxData {
+    fn drop(&mut self) {
+        if self.de_state != std::ptr::null_mut() {
+            core::sc_detect_engine_state_free(self.de_state);
+        }
+    }
 }
 
 impl AppLayerTxData {
@@ -79,6 +95,7 @@ impl AppLayerTxData {
             files_stored: 0,
             detect_flags_ts: 0,
             detect_flags_tc: 0,
+            de_state: std::ptr::null_mut(),
         }
     }
     pub fn init_files_opened(&mut self) {
@@ -210,11 +227,6 @@ pub struct RustParser {
     /// Function returning the current transaction progress
     pub tx_get_progress:    StateGetProgressFn,
 
-    /// 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
@@ -278,8 +290,6 @@ pub type StateTxFreeFn  = unsafe extern "C" fn (*mut c_void, u64);
 pub type StateGetTxFn            = unsafe extern "C" fn (*mut c_void, u64) -> *mut c_void;
 pub type StateGetTxCntFn         = unsafe extern "C" fn (*mut c_void) -> u64;
 pub type StateGetProgressFn = unsafe extern "C" fn (*mut c_void, u8) -> c_int;
-pub type GetDetectStateFn   = unsafe extern "C" fn (*mut c_void) -> *mut DetectEngineState;
-pub type SetDetectStateFn   = unsafe extern "C" fn (*mut c_void, &mut DetectEngineState) -> c_int;
 pub type GetEventInfoFn     = unsafe extern "C" fn (*const c_char, *mut c_int, *mut AppLayerEventType) -> c_int;
 pub type GetEventInfoByIdFn = unsafe extern "C" fn (c_int, *mut *const c_char, *mut AppLayerEventType) -> i8;
 pub type GetEventsFn        = unsafe extern "C" fn (*mut c_void) -> *mut AppLayerDecoderEvents;
@@ -396,42 +406,6 @@ impl LoggerFlags {
 
 }
 
-/// Export a function to get the DetectEngineState on a struct.
-#[macro_export]
-macro_rules!export_tx_get_detect_state {
-    ($name:ident, $type:ty) => (
-        #[no_mangle]
-        pub unsafe extern "C" fn $name(tx: *mut std::os::raw::c_void)
-            -> *mut core::DetectEngineState
-        {
-            let tx = cast_pointer!(tx, $type);
-            match tx.de_state {
-                Some(ds) => {
-                    return ds;
-                },
-                None => {
-                    return std::ptr::null_mut();
-                }
-            }
-        }
-    )
-}
-
-/// Export a function to set the DetectEngineState on a struct.
-#[macro_export]
-macro_rules!export_tx_set_detect_state {
-    ($name:ident, $type:ty) => (
-        #[no_mangle]
-        pub unsafe extern "C" fn $name(tx: *mut std::os::raw::c_void,
-                de_state: &mut core::DetectEngineState) -> std::os::raw::c_int
-        {
-            let tx = cast_pointer!(tx, $type);
-            tx.de_state = Some(de_state);
-            0
-        }
-    )
-}
-
 /// AppLayerEvent trait that will be implemented on enums that
 /// derive AppLayerEvent.
 pub trait AppLayerEvent {
index 3a29765e47f0abed056cda9dfb88068da4e54bc6..1025b57f0f568f175cf7e768a9bd04ceb9408201 100644 (file)
@@ -259,15 +259,6 @@ fn probe(input: &[u8]) -> nom::IResult<&[u8], ()> {
 
 // C exports.
 
-export_tx_get_detect_state!(
-    rs_template_tx_get_detect_state,
-    TemplateTransaction
-);
-export_tx_set_detect_state!(
-    rs_template_tx_set_detect_state,
-    TemplateTransaction
-);
-
 /// C entry point for a probing parser.
 #[no_mangle]
 pub unsafe extern "C" fn rs_template_probing_parser(
@@ -483,8 +474,6 @@ pub unsafe extern "C" fn rs_template_register_parser() {
         tx_comp_st_ts: 1,
         tx_comp_st_tc: 1,
         tx_get_progress: rs_template_tx_get_alstate_progress,
-        get_de_state: rs_template_tx_get_detect_state,
-        set_de_state: rs_template_tx_set_detect_state,
         get_events: Some(rs_template_state_get_events),
         get_eventinfo: Some(TemplateEvent::get_event_info),
         get_eventinfo_byid : Some(TemplateEvent::get_event_info_by_id),
index 30d493562634403ecc0cdc29df8d3a9aa93fba6b..dae73128ff3edd6c288961a3f24541d956b73d94 100644 (file)
@@ -183,7 +183,6 @@ pub struct DCERPCTransaction {
     pub activityuuid: Vec<u8>,
     pub seqnum: u32,
     pub tx_data: AppLayerTxData,
-    pub de_state: Option<*mut core::DetectEngineState>,
 }
 
 impl DCERPCTransaction {
@@ -195,20 +194,10 @@ impl DCERPCTransaction {
             resp_cmd: DCERPC_TYPE_RESPONSE,
             activityuuid: Vec::new(),
             tx_data: AppLayerTxData::new(),
-            de_state: None,
             ..Default::default()
         }
     }
 
-    pub fn free(&mut self) {
-        match self.de_state {
-            Some(state) => {
-                sc_detect_engine_state_free(state);
-            }
-            _ => {}
-        }
-    }
-
     pub fn get_req_ctxid(&self) -> u16 {
         self.ctxid
     }
@@ -226,12 +215,6 @@ impl DCERPCTransaction {
     }
 }
 
-impl Drop for DCERPCTransaction {
-    fn drop(&mut self) {
-        self.free();
-    }
-}
-
 #[derive(Debug)]
 pub struct DCERPCRequest {
     pub ctxid: u16,
@@ -1235,26 +1218,6 @@ pub unsafe extern "C" fn rs_dcerpc_state_trunc(state: *mut std::os::raw::c_void,
     }
 }
 
-#[no_mangle]
-pub unsafe extern "C" fn rs_dcerpc_get_tx_detect_state(
-    vtx: *mut std::os::raw::c_void,
-) -> *mut core::DetectEngineState {
-    let dce_tx = cast_pointer!(vtx, DCERPCTransaction);
-    match dce_tx.de_state {
-        Some(ds) => ds,
-        None => std::ptr::null_mut(),
-    }
-}
-
-#[no_mangle]
-pub unsafe extern "C" fn rs_dcerpc_set_tx_detect_state(
-    vtx: *mut std::os::raw::c_void, de_state: &mut core::DetectEngineState,
-) -> std::os::raw::c_int {
-    let dce_tx = cast_pointer!(vtx, DCERPCTransaction);
-    dce_tx.de_state = Some(de_state);
-    0
-}
-
 #[no_mangle]
 pub unsafe extern "C" fn rs_dcerpc_get_tx(
     vtx: *mut std::os::raw::c_void, tx_id: u64,
@@ -1397,8 +1360,6 @@ pub unsafe extern "C" fn rs_dcerpc_register_parser() {
         tx_comp_st_ts: 1,
         tx_comp_st_tc: 1,
         tx_get_progress: rs_dcerpc_get_alstate_progress,
-        get_de_state: rs_dcerpc_get_tx_detect_state,
-        set_de_state: rs_dcerpc_set_tx_detect_state,
         get_events: None,
         get_eventinfo: None,
         get_eventinfo_byid : None,
index 376fc4755ffd51c0dfb0b9fe62d83572d2e03376..cdd0d2c6a2c643d0c228aa308989b533f244ed7c 100644 (file)
@@ -238,26 +238,6 @@ pub unsafe extern "C" fn rs_dcerpc_udp_state_transaction_free(
     dce_state.free_tx(tx_id);
 }
 
-#[no_mangle]
-pub unsafe extern "C" fn rs_dcerpc_udp_get_tx_detect_state(
-    vtx: *mut std::os::raw::c_void,
-) -> *mut core::DetectEngineState {
-    let dce_state = cast_pointer!(vtx, DCERPCTransaction);
-    match dce_state.de_state {
-        Some(ds) => ds,
-        None => std::ptr::null_mut(),
-    }
-}
-
-#[no_mangle]
-pub unsafe extern "C" fn rs_dcerpc_udp_set_tx_detect_state(
-    vtx: *mut std::os::raw::c_void, de_state: &mut core::DetectEngineState,
-) -> std::os::raw::c_int {
-    let dce_state = cast_pointer!(vtx, DCERPCTransaction);
-    dce_state.de_state = Some(de_state);
-    0
-}
-
 #[no_mangle]
 pub unsafe extern "C" fn rs_dcerpc_udp_get_tx_data(
     tx: *mut std::os::raw::c_void)
@@ -361,8 +341,6 @@ pub unsafe extern "C" fn rs_dcerpc_udp_register_parser() {
         tx_comp_st_ts: 1,
         tx_comp_st_tc: 1,
         tx_get_progress: rs_dcerpc_get_alstate_progress,
-        get_de_state: rs_dcerpc_udp_get_tx_detect_state,
-        set_de_state: rs_dcerpc_udp_set_tx_detect_state,
         get_events: None,
         get_eventinfo: None,
         get_eventinfo_byid: None,
index 3a8156e164addf5207b7708341b030819f720675..abbca1a2a8c4a0a922c64f18bb8ea4d921d6ab81 100644 (file)
@@ -18,7 +18,7 @@
 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::core::sc_app_layer_decoder_events_free_events;
 use crate::dhcp::parser::*;
 use std;
 use std::ffi::CString;
@@ -79,7 +79,6 @@ pub enum DHCPEvent {
 pub struct DHCPTransaction {
     tx_id: u64,
     pub message: DHCPMessage,
-    de_state: Option<*mut core::DetectEngineState>,
     events: *mut core::AppLayerDecoderEvents,
     tx_data: applayer::AppLayerTxData,
 }
@@ -89,7 +88,6 @@ impl DHCPTransaction {
         DHCPTransaction {
             tx_id: id,
             message: message,
-            de_state: None,
             events: std::ptr::null_mut(),
             tx_data: applayer::AppLayerTxData::new(),
         }
@@ -99,12 +97,6 @@ impl DHCPTransaction {
         if !self.events.is_null() {
             sc_app_layer_decoder_events_free_events(&mut self.events);
         }
-        match self.de_state {
-            Some(state) => {
-                sc_detect_engine_state_free(state);
-            }
-            _ => {}
-        }
     }
 
 }
@@ -121,9 +113,6 @@ impl Drop for DHCPTransaction {
     }
 }
 
-export_tx_get_detect_state!(rs_dhcp_tx_get_detect_state, DHCPTransaction);
-export_tx_set_detect_state!(rs_dhcp_tx_set_detect_state, DHCPTransaction);
-
 #[derive(Default)]
 pub struct DHCPState {
     // Internal transaction ID.
@@ -323,8 +312,6 @@ pub unsafe extern "C" fn rs_dhcp_register_parser() {
         tx_comp_st_ts      : 1,
         tx_comp_st_tc      : 1,
         tx_get_progress    : rs_dhcp_tx_get_alstate_progress,
-        get_de_state       : rs_dhcp_tx_get_detect_state,
-        set_de_state       : rs_dhcp_tx_set_detect_state,
         get_events         : Some(rs_dhcp_state_get_events),
         get_eventinfo      : Some(DHCPEvent::get_event_info),
         get_eventinfo_byid : Some(DHCPEvent::get_event_info_by_id),
index 16b67cfa9c1e357ab8a27a7194353aa03ce90863..42504fcec053afe7feb15cf08b472d4bd7d5f89b 100644 (file)
@@ -231,7 +231,6 @@ pub struct DNSTransaction {
     pub id: u64,
     pub request: Option<DNSRequest>,
     pub response: Option<DNSResponse>,
-    pub de_state: Option<*mut core::DetectEngineState>,
     pub events: *mut core::AppLayerDecoderEvents,
     pub tx_data: AppLayerTxData,
 }
@@ -249,7 +248,6 @@ impl DNSTransaction {
             id: 0,
             request: None,
             response: None,
-            de_state: None,
             events: std::ptr::null_mut(),
             tx_data: AppLayerTxData::new(),
         }
@@ -259,12 +257,6 @@ impl DNSTransaction {
         if !self.events.is_null() {
             core::sc_app_layer_decoder_events_free_events(&mut self.events);
         }
-        match self.de_state {
-            Some(state) => {
-                core::sc_detect_engine_state_free(state);
-            }
-            None => { },
-        }
     }
 
     /// Get the DNS transactions ID (not the internal tracking ID).
@@ -806,32 +798,6 @@ pub extern "C" fn rs_dns_tx_is_response(tx: &mut DNSTransaction) -> bool {
     tx.response.is_some()
 }
 
-#[no_mangle]
-pub unsafe extern "C" fn rs_dns_state_set_tx_detect_state(
-    tx: *mut std::os::raw::c_void,
-    de_state: &mut core::DetectEngineState) -> std::os::raw::c_int
-{
-    let tx = cast_pointer!(tx, DNSTransaction);
-    tx.de_state = Some(de_state);
-    return 0;
-}
-
-#[no_mangle]
-pub unsafe extern "C" fn rs_dns_state_get_tx_detect_state(
-    tx: *mut std::os::raw::c_void)
-    -> *mut core::DetectEngineState
-{
-    let tx = cast_pointer!(tx, DNSTransaction);
-    match tx.de_state {
-        Some(ds) => {
-            return ds;
-        },
-        None => {
-            return std::ptr::null_mut();
-        }
-    }
-}
-
 #[no_mangle]
 pub unsafe extern "C" fn rs_dns_state_get_events(tx: *mut std::os::raw::c_void)
                                           -> *mut core::AppLayerDecoderEvents
@@ -840,7 +806,6 @@ pub unsafe extern "C" fn rs_dns_state_get_events(tx: *mut std::os::raw::c_void)
     return tx.events;
 }
 
-#[no_mangle]
 pub unsafe extern "C" fn rs_dns_state_get_tx_data(
     tx: *mut std::os::raw::c_void)
     -> *mut AppLayerTxData
@@ -1004,8 +969,6 @@ pub unsafe extern "C" fn rs_dns_udp_register_parser() {
         localstorage_free: None,
         get_files: None,
         get_tx_iterator: Some(crate::applayer::state_get_tx_iterator::<DNSState, DNSTransaction>),
-        get_de_state: rs_dns_state_get_tx_detect_state,
-        set_de_state: rs_dns_state_set_tx_detect_state,
         get_tx_data: rs_dns_state_get_tx_data,
         apply_tx_config: Some(rs_dns_apply_tx_config),
         flags: APP_LAYER_PARSER_OPT_UNIDIR_TXS,
@@ -1050,8 +1013,6 @@ pub unsafe extern "C" fn rs_dns_tcp_register_parser() {
         localstorage_free: None,
         get_files: None,
         get_tx_iterator: Some(crate::applayer::state_get_tx_iterator::<DNSState, DNSTransaction>),
-        get_de_state: rs_dns_state_get_tx_detect_state,
-        set_de_state: rs_dns_state_set_tx_detect_state,
         get_tx_data: rs_dns_state_get_tx_data,
         apply_tx_config: Some(rs_dns_apply_tx_config),
         flags: APP_LAYER_PARSER_OPT_ACCEPT_GAPS | APP_LAYER_PARSER_OPT_UNIDIR_TXS,
index e009b316f106efe89834bf8a0e31299066243eea..b0545f0a7550bb888720a84c9e4bfbd8ffaeb1c8 100644 (file)
@@ -131,7 +131,6 @@ pub struct HTTP2Transaction {
     decoder: decompression::HTTP2Decoder,
     pub file_range: *mut HttpRangeContainerBlock,
 
-    de_state: Option<*mut core::DetectEngineState>,
     events: *mut core::AppLayerDecoderEvents,
     tx_data: AppLayerTxData,
     pub ft_tc: FileTransferTracker,
@@ -159,7 +158,6 @@ impl HTTP2Transaction {
             frames_ts: Vec::new(),
             decoder: decompression::HTTP2Decoder::new(),
             file_range: std::ptr::null_mut(),
-            de_state: None,
             events: std::ptr::null_mut(),
             tx_data: AppLayerTxData::new(),
             ft_tc: FileTransferTracker::new(),
@@ -172,9 +170,6 @@ impl HTTP2Transaction {
         if !self.events.is_null() {
             core::sc_app_layer_decoder_events_free_events(&mut self.events);
         }
-        if let Some(state) = self.de_state {
-            core::sc_detect_engine_state_free(state);
-        }
         if !self.file_range.is_null() {
             match unsafe { SC } {
                 None => panic!("BUG no suricata_config"),
@@ -988,9 +983,6 @@ impl HTTP2State {
 
 // C exports.
 
-export_tx_get_detect_state!(rs_http2_tx_get_detect_state, HTTP2Transaction);
-export_tx_set_detect_state!(rs_http2_tx_set_detect_state, HTTP2Transaction);
-
 export_tx_data_get!(rs_http2_get_tx_data, HTTP2Transaction);
 
 /// C entry point for a probing parser.
@@ -1165,8 +1157,6 @@ pub unsafe extern "C" fn rs_http2_register_parser() {
         tx_comp_st_ts: HTTP2TransactionState::HTTP2StateClosed as i32,
         tx_comp_st_tc: HTTP2TransactionState::HTTP2StateClosed as i32,
         tx_get_progress: rs_http2_tx_get_alstate_progress,
-        get_de_state: rs_http2_tx_get_detect_state,
-        set_de_state: rs_http2_tx_set_detect_state,
         get_events: Some(rs_http2_state_get_events),
         get_eventinfo: Some(HTTP2Event::get_event_info),
         get_eventinfo_byid: Some(HTTP2Event::get_event_info_by_id),
index 7453c401ca3b421a663f83e2ca0da2e0071d5160..e29edf1d0fbf04631bd11e7ea54aea6a76b44321 100644 (file)
@@ -105,7 +105,6 @@ pub struct IKETransaction {
     pub errors: u32,
 
     logged: LoggerFlags,
-    de_state: Option<*mut core::DetectEngineState>,
     events: *mut core::AppLayerDecoderEvents,
     tx_data: applayer::AppLayerTxData,
 }
@@ -125,7 +124,6 @@ impl IKETransaction {
             payload_types: Default::default(),
             notify_types: vec![],
             logged: LoggerFlags::new(),
-            de_state: None,
             events: std::ptr::null_mut(),
             tx_data: applayer::AppLayerTxData::new(),
             errors: 0,
@@ -136,9 +134,6 @@ impl IKETransaction {
         if !self.events.is_null() {
             core::sc_app_layer_decoder_events_free_events(&mut self.events);
         }
-        if let Some(state) = self.de_state {
-            core::sc_detect_engine_state_free(state);
-        }
     }
 
     /// Set an event.
@@ -293,8 +288,6 @@ fn probe(input: &[u8], direction: Direction, rdir: *mut u8) -> bool {
 }
 
 // C exports.
-export_tx_get_detect_state!(rs_ike_tx_get_detect_state, IKETransaction);
-export_tx_set_detect_state!(rs_ike_tx_set_detect_state, IKETransaction);
 
 /// C entry point for a probing parser.
 #[no_mangle]
@@ -444,8 +437,6 @@ pub unsafe extern "C" fn rs_ike_register_parser() {
         tx_comp_st_ts      : 1,
         tx_comp_st_tc      : 1,
         tx_get_progress    : rs_ike_tx_get_alstate_progress,
-        get_de_state       : rs_ike_tx_get_detect_state,
-        set_de_state       : rs_ike_tx_set_detect_state,
         get_events         : Some(rs_ike_state_get_events),
         get_eventinfo      : Some(IkeEvent::get_event_info),
         get_eventinfo_byid : Some(IkeEvent::get_event_info_by_id),
index e9dc49faa29165e13ff53212f578955b3940e869..679869325213ae837c6df4c4d4c328996bebd6d6 100644 (file)
@@ -27,7 +27,8 @@ use der_parser::ber::BerClass;
 use kerberos_parser::krb5_parser;
 use kerberos_parser::krb5::{EncryptionType,ErrorCode,MessageType,PrincipalName,Realm};
 use crate::applayer::{self, *};
-use crate::core::{self, *};
+use crate::core;
+use crate::core::{AppProto,Flow,ALPROTO_FAILED,ALPROTO_UNKNOWN,Direction};
 
 #[derive(AppLayerEvent)]
 pub enum KRB5Event {
@@ -76,9 +77,6 @@ pub struct KRB5Transaction {
     /// The internal transaction id
     id: u64,
 
-    /// The detection engine state, if present
-    de_state: Option<*mut core::DetectEngineState>,
-
     /// The events associated with this transaction
     events: *mut core::AppLayerDecoderEvents,
 
@@ -237,7 +235,6 @@ impl KRB5Transaction {
             etype: None,
             error_code: None,
             id: id,
-            de_state: None,
             events: std::ptr::null_mut(),
             tx_data: applayer::AppLayerTxData::new(),
         }
@@ -249,9 +246,6 @@ impl Drop for KRB5Transaction {
         if !self.events.is_null() {
             core::sc_app_layer_decoder_events_free_events(&mut self.events);
         }
-        if let Some(state) = self.de_state {
-            sc_detect_engine_state_free(state);
-        }
     }
 }
 
@@ -324,28 +318,6 @@ pub extern "C" fn rs_krb5_tx_get_alstate_progress(_tx: *mut std::os::raw::c_void
     1
 }
 
-#[no_mangle]
-pub unsafe extern "C" fn rs_krb5_state_set_tx_detect_state(
-    tx: *mut std::os::raw::c_void,
-    de_state: &mut core::DetectEngineState) -> std::os::raw::c_int
-{
-    let tx = cast_pointer!(tx,KRB5Transaction);
-    tx.de_state = Some(de_state);
-    0
-}
-
-#[no_mangle]
-pub unsafe extern "C" fn rs_krb5_state_get_tx_detect_state(
-    tx: *mut std::os::raw::c_void)
-    -> *mut core::DetectEngineState
-{
-    let tx = cast_pointer!(tx,KRB5Transaction);
-    match tx.de_state {
-        Some(ds) => ds,
-        None => std::ptr::null_mut(),
-    }
-}
-
 #[no_mangle]
 pub unsafe extern "C" fn rs_krb5_state_get_events(tx: *mut std::os::raw::c_void)
                                           -> *mut core::AppLayerDecoderEvents
@@ -593,8 +565,6 @@ pub unsafe extern "C" fn rs_register_krb5_parser() {
         tx_comp_st_ts      : 1,
         tx_comp_st_tc      : 1,
         tx_get_progress    : rs_krb5_tx_get_alstate_progress,
-        get_de_state       : rs_krb5_state_get_tx_detect_state,
-        set_de_state       : rs_krb5_state_set_tx_detect_state,
         get_events         : Some(rs_krb5_state_get_events),
         get_eventinfo      : Some(KRB5Event::get_event_info),
         get_eventinfo_byid : Some(KRB5Event::get_event_info_by_id),
index 59ed741c01bae5de5d60470c3472b630c6e855c3..a22cf5fe0ae30e2e3f195fecd2639ac804d43807 100644 (file)
@@ -48,7 +48,6 @@ pub struct ModbusTransaction {
     pub response: Option<Message>,
 
     pub events: *mut core::AppLayerDecoderEvents,
-    pub de_state: Option<*mut core::DetectEngineState>,
     pub tx_data: AppLayerTxData,
 }
 
@@ -65,7 +64,6 @@ impl ModbusTransaction {
             request: None,
             response: None,
             events: std::ptr::null_mut(),
-            de_state: None,
             tx_data: AppLayerTxData::new(),
         }
     }
@@ -98,10 +96,6 @@ impl Drop for ModbusTransaction {
         if !self.events.is_null() {
             core::sc_app_layer_decoder_events_free_events(&mut self.events);
         }
-
-        if let Some(state) = self.de_state {
-            core::sc_detect_engine_state_free(state);
-        }
     }
 }
 
@@ -390,26 +384,6 @@ pub unsafe extern "C" fn rs_modbus_state_get_events(
     tx.events
 }
 
-#[no_mangle]
-pub unsafe extern "C" fn rs_modbus_state_get_tx_detect_state(
-    tx: *mut std::os::raw::c_void,
-) -> *mut core::DetectEngineState {
-    let tx = cast_pointer!(tx, ModbusTransaction);
-    match tx.de_state {
-        Some(ds) => ds,
-        None => std::ptr::null_mut(),
-    }
-}
-
-#[no_mangle]
-pub unsafe extern "C" fn rs_modbus_state_set_tx_detect_state(
-    tx: *mut std::os::raw::c_void, de_state: &mut core::DetectEngineState,
-) -> std::os::raw::c_int {
-    let tx = cast_pointer!(tx, ModbusTransaction);
-    tx.de_state = Some(de_state);
-    0
-}
-
 #[no_mangle]
 pub unsafe extern "C" fn rs_modbus_state_get_tx_data(
     tx: *mut std::os::raw::c_void,
@@ -446,8 +420,6 @@ pub unsafe extern "C" fn rs_modbus_register_parser() {
         localstorage_free: None,
         get_files: None,
         get_tx_iterator: Some(applayer::state_get_tx_iterator::<ModbusState, ModbusTransaction>),
-        get_de_state: rs_modbus_state_get_tx_detect_state,
-        set_de_state: rs_modbus_state_set_tx_detect_state,
         get_tx_data: rs_modbus_state_get_tx_data,
         apply_tx_config: None,
         flags: 0,
index a5f1b2b31502072fd0274104ea3a7251b121124b..3627e57f5e3a4fbac9089c65c756c7fbeba5dee2 100644 (file)
@@ -60,7 +60,6 @@ pub struct MQTTTransaction {
     toserver: bool,
 
     logged: LoggerFlags,
-    de_state: Option<*mut core::DetectEngineState>,
     events: *mut core::AppLayerDecoderEvents,
     tx_data: applayer::AppLayerTxData,
 }
@@ -75,7 +74,6 @@ impl MQTTTransaction {
             msg: Vec::new(),
             toclient: false,
             toserver: false,
-            de_state: None,
             events: std::ptr::null_mut(),
             tx_data: applayer::AppLayerTxData::new(),
         };
@@ -87,9 +85,6 @@ impl MQTTTransaction {
         if !self.events.is_null() {
             core::sc_app_layer_decoder_events_free_events(&mut self.events);
         }
-        if let Some(state) = self.de_state {
-            core::sc_detect_engine_state_free(state);
-        }
     }
 }
 
@@ -536,9 +531,6 @@ impl MQTTState {
 
 // C exports.
 
-export_tx_get_detect_state!(rs_mqtt_tx_get_detect_state, MQTTTransaction);
-export_tx_set_detect_state!(rs_mqtt_tx_set_detect_state, MQTTTransaction);
-
 #[no_mangle]
 pub unsafe extern "C" fn rs_mqtt_probing_parser(
     _flow: *const Flow,
@@ -719,8 +711,6 @@ pub unsafe extern "C" fn rs_mqtt_register_parser(cfg_max_msg_len: u32) {
         tx_comp_st_ts: 1,
         tx_comp_st_tc: 1,
         tx_get_progress: rs_mqtt_tx_get_alstate_progress,
-        get_de_state: rs_mqtt_tx_get_detect_state,
-        set_de_state: rs_mqtt_tx_set_detect_state,
         get_events: Some(rs_mqtt_state_get_events),
         get_eventinfo: Some(MQTTEvent::get_event_info),
         get_eventinfo_byid: Some(MQTTEvent::get_event_info_by_id),
index d41aacd5823d646faf5ab6a4526496d907c785fe..444e7856233ced51f21f593d894f8a20c77b93e4 100644 (file)
@@ -179,7 +179,6 @@ pub struct NFSTransaction {
     /// attempt failed.
     pub type_data: Option<NFSTransactionTypeData>,
 
-    pub de_state: Option<*mut DetectEngineState>,
     pub events: *mut AppLayerDecoderEvents,
 
     pub tx_data: AppLayerTxData,
@@ -208,7 +207,6 @@ impl NFSTransaction {
             file_tx_direction: Direction::ToServer,
             file_handle:Vec::new(),
             type_data: None,
-            de_state: None,
             events: std::ptr::null_mut(),
             tx_data: AppLayerTxData::new(),
         }
@@ -220,12 +218,6 @@ impl NFSTransaction {
         if !self.events.is_null() {
             sc_app_layer_decoder_events_free_events(&mut self.events);
         }
-        match self.de_state {
-            Some(state) => {
-                sc_detect_engine_state_free(state);
-            }
-            _ => {}
-        }
     }
 }
 
@@ -1549,34 +1541,6 @@ pub unsafe extern "C" fn rs_nfs_get_tx_data(
     return &mut tx.tx_data;
 }
 
-#[no_mangle]
-pub unsafe extern "C" fn rs_nfs_state_set_tx_detect_state(
-    tx: *mut std::os::raw::c_void,
-    de_state: &mut DetectEngineState) -> i32
-{
-    let tx = cast_pointer!(tx, NFSTransaction);
-    tx.de_state = Some(de_state);
-    0
-}
-
-#[no_mangle]
-pub unsafe extern "C" fn rs_nfs_state_get_tx_detect_state(
-    tx: *mut std::os::raw::c_void)
-    -> *mut DetectEngineState
-{
-    let tx = cast_pointer!(tx, NFSTransaction);
-    match tx.de_state {
-        Some(ds) => {
-            SCLogDebug!("{}: getting de_state", tx.id);
-            return ds;
-        },
-        None => {
-            SCLogDebug!("{}: getting de_state: have none", tx.id);
-            return std::ptr::null_mut();
-        }
-    }
-}
-
 #[no_mangle]
 pub unsafe extern "C" fn rs_nfs_state_get_events(tx: *mut std::os::raw::c_void)
                                           -> *mut AppLayerDecoderEvents
@@ -1911,8 +1875,6 @@ pub unsafe extern "C" fn rs_nfs_register_parser() {
         tx_comp_st_ts: 1,
         tx_comp_st_tc: 1,
         tx_get_progress: rs_nfs_tx_get_alstate_progress,
-        get_de_state: rs_nfs_state_get_tx_detect_state,
-        set_de_state: rs_nfs_state_set_tx_detect_state,
         get_events: Some(rs_nfs_state_get_events),
         get_eventinfo: Some(rs_nfs_state_get_event_info),
         get_eventinfo_byid : Some(rs_nfs_state_get_event_info_by_id),
@@ -1990,8 +1952,6 @@ pub unsafe extern "C" fn rs_nfs_udp_register_parser() {
         tx_comp_st_ts: 1,
         tx_comp_st_tc: 1,
         tx_get_progress: rs_nfs_tx_get_alstate_progress,
-        get_de_state: rs_nfs_state_get_tx_detect_state,
-        set_de_state: rs_nfs_state_set_tx_detect_state,
         get_events: Some(rs_nfs_state_get_events),
         get_eventinfo: Some(rs_nfs_state_get_event_info),
         get_eventinfo_byid : None,
index 6a454bcd2bc82191972d48107102f3014508e890..4b1ba34198fa61871bf2b27dabc7434fd53a9c9f 100644 (file)
@@ -54,9 +54,6 @@ pub struct NTPTransaction {
     /// The internal transaction id
     id: u64,
 
-    /// The detection engine state, if present
-    de_state: Option<*mut core::DetectEngineState>,
-
     /// The events associated with this transaction
     events: *mut core::AppLayerDecoderEvents,
 
@@ -152,7 +149,6 @@ impl NTPTransaction {
         NTPTransaction {
             xid: 0,
             id: id,
-            de_state: None,
             events: std::ptr::null_mut(),
             tx_data: applayer::AppLayerTxData::new(),
         }
@@ -162,9 +158,6 @@ impl NTPTransaction {
         if !self.events.is_null() {
             core::sc_app_layer_decoder_events_free_events(&mut self.events);
         }
-        if let Some(de_state) = self.de_state {
-            core::sc_detect_engine_state_free(de_state);
-        }
     }
 }
 
@@ -258,28 +251,6 @@ pub extern "C" fn rs_ntp_tx_get_alstate_progress(_tx: *mut std::os::raw::c_void,
     1
 }
 
-#[no_mangle]
-pub unsafe extern "C" fn rs_ntp_state_set_tx_detect_state(
-    tx: *mut std::os::raw::c_void,
-    de_state: &mut core::DetectEngineState) -> std::os::raw::c_int
-{
-    let tx = cast_pointer!(tx,NTPTransaction);
-    tx.de_state = Some(de_state);
-    0
-}
-
-#[no_mangle]
-pub unsafe extern "C" fn rs_ntp_state_get_tx_detect_state(
-    tx: *mut std::os::raw::c_void)
-    -> *mut core::DetectEngineState
-{
-    let tx = cast_pointer!(tx,NTPTransaction);
-    match tx.de_state {
-        Some(ds) => ds,
-        None => std::ptr::null_mut(),
-    }
-}
-
 #[no_mangle]
 pub unsafe extern "C" fn rs_ntp_state_get_events(tx: *mut std::os::raw::c_void)
                                           -> *mut core::AppLayerDecoderEvents
@@ -340,8 +311,6 @@ pub unsafe extern "C" fn rs_register_ntp_parser() {
         tx_comp_st_ts      : 1,
         tx_comp_st_tc      : 1,
         tx_get_progress    : rs_ntp_tx_get_alstate_progress,
-        get_de_state       : rs_ntp_state_get_tx_detect_state,
-        set_de_state       : rs_ntp_state_set_tx_detect_state,
         get_events         : Some(rs_ntp_state_get_events),
         get_eventinfo      : Some(NTPEvent::get_event_info),
         get_eventinfo_byid : Some(NTPEvent::get_event_info_by_id),
index 75d7500fa8857bc7797ac8c6427c9f774138fd33..58083cfaff2a726d057a3e9d1167d2fe8a47407b 100644 (file)
@@ -20,7 +20,7 @@
 //! RDP application layer
 
 use crate::applayer::{self, *};
-use crate::core::{self, AppProto, DetectEngineState, Flow, ALPROTO_UNKNOWN, IPPROTO_TCP};
+use crate::core::{AppProto, Flow, ALPROTO_UNKNOWN, IPPROTO_TCP};
 use crate::rdp::parser::*;
 use nom;
 use std;
@@ -51,7 +51,6 @@ pub struct RdpTransaction {
     pub id: u64,
     pub item: RdpTransactionItem,
     // managed by macros `export_tx_get_detect_state!` and `export_tx_set_detect_state!`
-    de_state: Option<*mut DetectEngineState>,
     tx_data: AppLayerTxData,
 }
 
@@ -66,22 +65,9 @@ impl RdpTransaction {
         Self {
             id,
             item,
-            de_state: None,
             tx_data: AppLayerTxData::new(),
         }
     }
-
-    fn free(&mut self) {
-        if let Some(de_state) = self.de_state {
-            core::sc_detect_engine_state_free(de_state);
-        }
-    }
-}
-
-impl Drop for RdpTransaction {
-    fn drop(&mut self) {
-        self.free();
-    }
 }
 
 #[no_mangle]
@@ -401,13 +387,6 @@ pub unsafe extern "C" fn rs_rdp_state_tx_free(state: *mut std::os::raw::c_void,
     state.free_tx(tx_id);
 }
 
-//
-// detection state
-//
-
-export_tx_get_detect_state!(rs_rdp_tx_get_detect_state, RdpTransaction);
-export_tx_set_detect_state!(rs_rdp_tx_set_detect_state, RdpTransaction);
-
 //
 // probe
 //
@@ -496,8 +475,6 @@ pub unsafe extern "C" fn rs_rdp_register_parser() {
         tx_comp_st_ts: 1,
         tx_comp_st_tc: 1,
         tx_get_progress: rs_rdp_tx_get_progress,
-        get_de_state: rs_rdp_tx_get_detect_state,
-        set_de_state: rs_rdp_tx_set_detect_state,
         get_events: None,
         get_eventinfo: None,
         get_eventinfo_byid: None,
index b6414cbedfdf495042170377b3087a7d5560da79..3b7ba127cef5cf608c0d1de9e4822eb07d3717f9 100644 (file)
@@ -44,7 +44,6 @@ pub struct RFBTransaction {
     pub tc_failure_reason: Option<parser::FailureReason>,
     pub tc_server_init: Option<parser::ServerInit>,
 
-    de_state: Option<*mut core::DetectEngineState>,
     events: *mut core::AppLayerDecoderEvents,
     tx_data: applayer::AppLayerTxData,
 }
@@ -74,7 +73,6 @@ impl RFBTransaction {
             tc_failure_reason: None,
             tc_server_init: None,
 
-            de_state: None,
             events: std::ptr::null_mut(),
             tx_data: applayer::AppLayerTxData::new(),
         }
@@ -84,9 +82,6 @@ impl RFBTransaction {
         if !self.events.is_null() {
             core::sc_app_layer_decoder_events_free_events(&mut self.events);
         }
-        if let Some(state) = self.de_state {
-            core::sc_detect_engine_state_free(state);
-        }
     }
 }
 
@@ -498,15 +493,6 @@ impl RFBState {
 
 // C exports.
 
-export_tx_get_detect_state!(
-    rs_rfb_tx_get_detect_state,
-    RFBTransaction
-);
-export_tx_set_detect_state!(
-    rs_rfb_tx_set_detect_state,
-    RFBTransaction
-);
-
 #[no_mangle]
 pub extern "C" fn rs_rfb_state_new(_orig_state: *mut std::os::raw::c_void, _orig_proto: AppProto) -> *mut std::os::raw::c_void {
     let state = RFBState::new();
@@ -628,8 +614,6 @@ pub unsafe extern "C" fn rs_rfb_register_parser() {
         tx_comp_st_ts: 1,
         tx_comp_st_tc: 1,
         tx_get_progress: rs_rfb_tx_get_alstate_progress,
-        get_de_state: rs_rfb_tx_get_detect_state,
-        set_de_state: rs_rfb_tx_set_detect_state,
         get_events: Some(rs_rfb_state_get_events),
         get_eventinfo: None,
         get_eventinfo_byid: None,
index da47c7e262bdd9f885f237365143b3d6075a3b4e..fd9230294c525d647249c4838996386d15b16c00 100755 (executable)
@@ -19,7 +19,7 @@
 
 use crate::applayer::{self, *};
 use crate::core;
-use crate::core::{sc_detect_engine_state_free, AppProto, Flow, ALPROTO_UNKNOWN};
+use crate::core::{AppProto, Flow, ALPROTO_UNKNOWN};
 use crate::sip::parser::*;
 use nom7::Err;
 use std;
@@ -48,7 +48,6 @@ pub struct SIPTransaction {
     pub response: Option<Response>,
     pub request_line: Option<String>,
     pub response_line: Option<String>,
-    de_state: Option<*mut core::DetectEngineState>,
     events: *mut core::AppLayerDecoderEvents,
     tx_data: applayer::AppLayerTxData,
 }
@@ -147,7 +146,6 @@ impl SIPTransaction {
     pub fn new(id: u64) -> SIPTransaction {
         SIPTransaction {
             id,
-            de_state: None,
             request: None,
             response: None,
             request_line: None,
@@ -163,9 +161,6 @@ impl Drop for SIPTransaction {
         if !self.events.is_null() {
             core::sc_app_layer_decoder_events_free_events(&mut self.events);
         }
-        if let Some(state) = self.de_state {
-            sc_detect_engine_state_free(state);
-        }
     }
 }
 
@@ -214,27 +209,6 @@ pub extern "C" fn rs_sip_tx_get_alstate_progress(
     1
 }
 
-#[no_mangle]
-pub unsafe extern "C" fn rs_sip_state_set_tx_detect_state(
-    tx: *mut std::os::raw::c_void,
-    de_state: &mut core::DetectEngineState,
-) -> std::os::raw::c_int {
-    let tx = cast_pointer!(tx, SIPTransaction);
-    tx.de_state = Some(de_state);
-    0
-}
-
-#[no_mangle]
-pub unsafe extern "C" fn rs_sip_state_get_tx_detect_state(
-    tx: *mut std::os::raw::c_void,
-) -> *mut core::DetectEngineState {
-    let tx = cast_pointer!(tx, SIPTransaction);
-    match tx.de_state {
-        Some(ds) => ds,
-        None => std::ptr::null_mut(),
-    }
-}
-
 #[no_mangle]
 pub unsafe extern "C" fn rs_sip_state_get_events(
     tx: *mut std::os::raw::c_void,
@@ -330,8 +304,6 @@ pub unsafe extern "C" fn rs_sip_register_parser() {
         tx_comp_st_ts: 1,
         tx_comp_st_tc: 1,
         tx_get_progress: rs_sip_tx_get_alstate_progress,
-        get_de_state: rs_sip_state_get_tx_detect_state,
-        set_de_state: rs_sip_state_set_tx_detect_state,
         get_events: Some(rs_sip_state_get_events),
         get_eventinfo: Some(SIPEvent::get_event_info),
         get_eventinfo_byid: Some(SIPEvent::get_event_info_by_id),
index 1696cc3f9b2616b79b8e6171331c3701b0316efb..dfaad32588e299651f06367f0d8704361e5fdf7c 100644 (file)
@@ -536,7 +536,6 @@ pub struct SMBTransaction {
     /// Command specific data
     pub type_data: Option<SMBTransactionTypeData>,
 
-    pub de_state: Option<*mut DetectEngineState>,
     pub events: *mut AppLayerDecoderEvents,
     pub tx_data: AppLayerTxData,
 }
@@ -556,7 +555,6 @@ impl SMBTransaction {
               request_done: false,
               response_done: false,
               type_data: None,
-              de_state: None,
               events: std::ptr::null_mut(),
               tx_data: AppLayerTxData::new(),
         }
@@ -577,12 +575,6 @@ impl SMBTransaction {
         if !self.events.is_null() {
             sc_app_layer_decoder_events_free_events(&mut self.events);
         }
-        match self.de_state {
-            Some(state) => {
-                sc_detect_engine_state_free(state);
-            }
-            _ => {}
-        }
     }
 }
 
@@ -2055,31 +2047,6 @@ pub unsafe extern "C" fn rs_smb_get_tx_data(
     return &mut tx.tx_data;
 }
 
-#[no_mangle]
-pub unsafe extern "C" fn rs_smb_state_get_tx_detect_state(
-    tx: *mut std::os::raw::c_void)
-    -> *mut DetectEngineState
-{
-    let tx = cast_pointer!(tx, SMBTransaction);
-    match tx.de_state {
-        Some(ds) => {
-            return ds;
-        },
-        None => {
-            return std::ptr::null_mut();
-        }
-    }
-}
-
-#[no_mangle]
-pub unsafe extern "C" fn rs_smb_state_set_tx_detect_state(
-    tx: *mut std::os::raw::c_void,
-    de_state: &mut DetectEngineState) -> std::os::raw::c_int
-{
-    let tx = cast_pointer!(tx, SMBTransaction);
-    tx.de_state = Some(de_state);
-    0
-}
 
 #[no_mangle]
 pub unsafe extern "C" fn rs_smb_state_truncate(
@@ -2204,8 +2171,6 @@ pub unsafe extern "C" fn rs_smb_register_parser() {
         tx_comp_st_ts: 1,
         tx_comp_st_tc: 1,
         tx_get_progress: rs_smb_tx_get_alstate_progress,
-        get_de_state: rs_smb_state_get_tx_detect_state,
-        set_de_state: rs_smb_state_set_tx_detect_state,
         get_events: Some(rs_smb_state_get_events),
         get_eventinfo: Some(rs_smb_state_get_event_info),
         get_eventinfo_byid : Some(rs_smb_state_get_event_info_by_id),
index c129938cea11b6746becca3c9b3ced4b3967f308..88b974373f30789861410e878e714ba01f49cd08 100644 (file)
@@ -77,9 +77,6 @@ pub struct SNMPTransaction<'a> {
     /// The internal transaction id
     id: u64,
 
-    /// The detection engine state, if present
-    de_state: Option<*mut core::DetectEngineState>,
-
     /// The events associated with this transaction
     events: *mut core::AppLayerDecoderEvents,
 
@@ -247,7 +244,6 @@ impl<'a> SNMPTransaction<'a> {
             usm: None,
             encrypted: false,
             id: id,
-            de_state: None,
             events: std::ptr::null_mut(),
             tx_data: applayer::AppLayerTxData::new(),
         }
@@ -257,9 +253,6 @@ impl<'a> SNMPTransaction<'a> {
         if !self.events.is_null() {
             core::sc_app_layer_decoder_events_free_events(&mut self.events);
         }
-        if let Some(de_state) = self.de_state {
-            core::sc_detect_engine_state_free(de_state);
-        }
     }
 }
 
@@ -352,29 +345,6 @@ pub extern "C" fn rs_snmp_tx_get_alstate_progress(_tx: *mut std::os::raw::c_void
     1
 }
 
-#[no_mangle]
-pub unsafe extern "C" fn rs_snmp_state_set_tx_detect_state(
-    tx: *mut std::os::raw::c_void,
-    de_state: &mut core::DetectEngineState) -> std::os::raw::c_int
-{
-    let tx = cast_pointer!(tx,SNMPTransaction);
-    tx.de_state = Some(de_state);
-    0
-}
-
-#[no_mangle]
-pub unsafe extern "C" fn rs_snmp_state_get_tx_detect_state(
-    tx: *mut std::os::raw::c_void)
-    -> *mut core::DetectEngineState
-{
-    let tx = cast_pointer!(tx,SNMPTransaction);
-    match tx.de_state {
-        Some(ds) => ds,
-        None => std::ptr::null_mut(),
-    }
-}
-
-
 #[no_mangle]
 pub unsafe extern "C" fn rs_snmp_state_get_events(tx: *mut std::os::raw::c_void)
                                            -> *mut core::AppLayerDecoderEvents
@@ -452,8 +422,6 @@ pub unsafe extern "C" fn rs_register_snmp_parser() {
         tx_comp_st_ts      : 1,
         tx_comp_st_tc      : 1,
         tx_get_progress    : rs_snmp_tx_get_alstate_progress,
-        get_de_state       : rs_snmp_state_get_tx_detect_state,
-        set_de_state       : rs_snmp_state_set_tx_detect_state,
         get_events         : Some(rs_snmp_state_get_events),
         get_eventinfo      : Some(SNMPEvent::get_event_info),
         get_eventinfo_byid : Some(SNMPEvent::get_event_info_by_id),
index 507795673dc5e080cd8c217bb16fca2cd1fb7f7e..035fa670660d575e715dc5fbbd77212c697497e9 100644 (file)
@@ -82,7 +82,6 @@ pub struct SSHTransaction {
     pub srv_hdr: SshHeader,
     pub cli_hdr: SshHeader,
 
-    de_state: Option<*mut core::DetectEngineState>,
     events: *mut core::AppLayerDecoderEvents,
     tx_data: AppLayerTxData,
 }
@@ -92,7 +91,6 @@ impl SSHTransaction {
         SSHTransaction {
             srv_hdr: SshHeader::new(),
             cli_hdr: SshHeader::new(),
-            de_state: None,
             events: std::ptr::null_mut(),
             tx_data: AppLayerTxData::new(),
         }
@@ -102,9 +100,6 @@ impl SSHTransaction {
         if !self.events.is_null() {
             core::sc_app_layer_decoder_events_free_events(&mut self.events);
         }
-        if let Some(state) = self.de_state {
-            core::sc_detect_engine_state_free(state);
-        }
     }
 }
 
@@ -351,9 +346,6 @@ impl SSHState {
 
 // C exports.
 
-export_tx_get_detect_state!(rs_ssh_tx_get_detect_state, SSHTransaction);
-export_tx_set_detect_state!(rs_ssh_tx_set_detect_state, SSHTransaction);
-
 export_tx_data_get!(rs_ssh_get_tx_data, SSHTransaction);
 
 #[no_mangle]
@@ -485,8 +477,6 @@ pub unsafe extern "C" fn rs_ssh_register_parser() {
         tx_comp_st_ts: SSHConnectionState::SshStateFinished as i32,
         tx_comp_st_tc: SSHConnectionState::SshStateFinished as i32,
         tx_get_progress: rs_ssh_tx_get_alstate_progress,
-        get_de_state: rs_ssh_tx_get_detect_state,
-        set_de_state: rs_ssh_tx_set_detect_state,
         get_events: Some(rs_ssh_state_get_events),
         get_eventinfo: Some(SSHEvent::get_event_info),
         get_eventinfo_byid: Some(SSHEvent::get_event_info_by_id),
index 7b707f355e7342f205269380c3d1374a7479b0ad..45be2dc2a452741c89bf3430897b423191823611 100644 (file)
@@ -1392,8 +1392,8 @@ static void DNP3TxFree(DNP3Transaction *tx)
 
     AppLayerDecoderEventsFreeEvents(&tx->decoder_events);
 
-    if (tx->de_state != NULL) {
-        DetectEngineStateFree(tx->de_state);
+    if (tx->tx_data.de_state != NULL) {
+        DetectEngineStateFree(tx->tx_data.de_state);
     }
 
     DNP3TxFreeObjectList(&tx->request_objects);
@@ -1535,25 +1535,6 @@ static int DNP3StateGetEventInfoById(int event_id, const char **event_name,
     return 0;
 }
 
-/**
- * \brief App-layer support.
- */
-static DetectEngineState *DNP3GetTxDetectState(void *vtx)
-{
-    DNP3Transaction *tx = vtx;
-    return tx->de_state;
-}
-
-/**
- * \brief App-layer support.
- */
-static int DNP3SetTxDetectState(void *vtx, DetectEngineState *s)
-{
-    DNP3Transaction *tx = vtx;
-    tx->de_state = s;
-    return 0;
-}
-
 static AppLayerTxData *DNP3GetTxData(void *vtx)
 {
     DNP3Transaction *tx = (DNP3Transaction *)vtx;
@@ -1622,8 +1603,6 @@ void RegisterDNP3Parsers(void)
 
         AppLayerParserRegisterGetEventsFunc(IPPROTO_TCP, ALPROTO_DNP3,
             DNP3GetEvents);
-        AppLayerParserRegisterDetectStateFuncs(IPPROTO_TCP, ALPROTO_DNP3,
-            DNP3GetTxDetectState, DNP3SetTxDetectState);
 
         AppLayerParserRegisterGetTx(IPPROTO_TCP, ALPROTO_DNP3, DNP3GetTx);
         AppLayerParserRegisterGetTxCnt(IPPROTO_TCP, ALPROTO_DNP3, DNP3GetTxCnt);
index 818ef5ecece34a7d1e21861c375a7cc1b1b56d42..5c6ee568efa011c4e6b048acb655eb1a005e3426 100644 (file)
@@ -245,7 +245,6 @@ typedef struct DNP3Transaction_ {
 
     AppLayerDecoderEvents *decoder_events; /**< Per transcation
                                             * decoder events. */
-    DetectEngineState *de_state;
 
     TAILQ_ENTRY(DNP3Transaction_) next;
 } DNP3Transaction;
index db58587d3da620eea755fa6c6d6460005cda1716..2eaa3a035ea5662be642bacd1889ca57057bcc1d 100644 (file)
@@ -209,7 +209,6 @@ typedef struct ENIPTransaction_
     AppLayerDecoderEvents *decoder_events;      /**< per tx events */
 
     TAILQ_ENTRY(ENIPTransaction_) next;
-    DetectEngineState *de_state;
     AppLayerTxData tx_data;
 } ENIPTransaction;
 
index 346c4a0d7328bdd2f77b9040cdad526e25df5873..e7a9e9d3eddb43dd01499bb4e7f00867b0f19b5d 100644 (file)
@@ -66,19 +66,6 @@ static int ENIPGetAlstateProgress(void *tx, uint8_t direction)
     return 1;
 }
 
-static DetectEngineState *ENIPGetTxDetectState(void *vtx)
-{
-    ENIPTransaction *tx = (ENIPTransaction *)vtx;
-    return tx->de_state;
-}
-
-static int ENIPSetTxDetectState(void *vtx, DetectEngineState *s)
-{
-    ENIPTransaction *tx = (ENIPTransaction *)vtx;
-    tx->de_state = s;
-    return 0;
-}
-
 static AppLayerTxData *ENIPGetTxData(void *vtx)
 {
     ENIPTransaction *tx = (ENIPTransaction *)vtx;
@@ -196,9 +183,8 @@ static void ENIPTransactionFree(ENIPTransaction *tx, ENIPState *state)
 
     AppLayerDecoderEventsFreeEvents(&tx->decoder_events);
 
-    if (tx->de_state != NULL)
-    {
-        DetectEngineStateFree(tx->de_state);
+    if (tx->tx_data.de_state != NULL) {
+        DetectEngineStateFree(tx->tx_data.de_state);
 
         state->tx_with_detect_state_cnt--;
     }
@@ -513,9 +499,6 @@ void RegisterENIPUDPParsers(void)
 
         AppLayerParserRegisterGetEventsFunc(IPPROTO_UDP, ALPROTO_ENIP, ENIPGetEvents);
 
-        AppLayerParserRegisterDetectStateFuncs(IPPROTO_UDP, ALPROTO_ENIP,
-                ENIPGetTxDetectState, ENIPSetTxDetectState);
-
         AppLayerParserRegisterGetTx(IPPROTO_UDP, ALPROTO_ENIP, ENIPGetTx);
         AppLayerParserRegisterTxDataFunc(IPPROTO_UDP, ALPROTO_ENIP, ENIPGetTxData);
         AppLayerParserRegisterGetTxCnt(IPPROTO_UDP, ALPROTO_ENIP, ENIPGetTxCnt);
@@ -591,9 +574,6 @@ void RegisterENIPTCPParsers(void)
 
         AppLayerParserRegisterGetEventsFunc(IPPROTO_TCP, ALPROTO_ENIP, ENIPGetEvents);
 
-        AppLayerParserRegisterDetectStateFuncs(IPPROTO_TCP, ALPROTO_ENIP,
-                ENIPGetTxDetectState, ENIPSetTxDetectState);
-
         AppLayerParserRegisterGetTx(IPPROTO_TCP, ALPROTO_ENIP, ENIPGetTx);
         AppLayerParserRegisterTxDataFunc(IPPROTO_TCP, ALPROTO_ENIP, ENIPGetTxData);
         AppLayerParserRegisterGetTxCnt(IPPROTO_TCP, ALPROTO_ENIP, ENIPGetTxCnt);
index 9f86df7d2dbc3062c3aca2a99067ed45a6e6d790..0a14e01437b61db19bd8c4e0edbe5ef21e6aa9ae 100644 (file)
@@ -326,8 +326,8 @@ static void FTPTransactionFree(FTPTransaction *tx)
 {
     SCEnter();
 
-    if (tx->de_state != NULL) {
-        DetectEngineStateFree(tx->de_state);
+    if (tx->tx_data.de_state != NULL) {
+        DetectEngineStateFree(tx->tx_data.de_state);
     }
 
     if (tx->request) {
@@ -884,13 +884,6 @@ static void FTPStateFree(void *s)
 #endif
 }
 
-static int FTPSetTxDetectState(void *vtx, DetectEngineState *de_state)
-{
-    FTPTransaction *tx = (FTPTransaction *)vtx;
-    tx->de_state = de_state;
-    return 0;
-}
-
 /**
  * \brief This function returns the oldest open transaction; if none
  * are open, then the oldest transaction is returned
@@ -942,13 +935,6 @@ static void *FTPGetTx(void *state, uint64_t tx_id)
     return NULL;
 }
 
-static DetectEngineState *FTPGetTxDetectState(void *vtx)
-{
-    FTPTransaction *tx = (FTPTransaction *)vtx;
-    return tx->de_state;
-}
-
-
 static AppLayerTxData *FTPGetTxData(void *vtx)
 {
     FTPTransaction *tx = (FTPTransaction *)vtx;
@@ -1175,8 +1161,8 @@ static void FTPDataStateFree(void *s)
 {
     FtpDataState *fstate = (FtpDataState *) s;
 
-    if (fstate->de_state != NULL) {
-        DetectEngineStateFree(fstate->de_state);
+    if (fstate->tx_data.de_state != NULL) {
+        DetectEngineStateFree(fstate->tx_data.de_state);
     }
     if (fstate->file_name != NULL) {
         FTPFree(fstate->file_name, fstate->file_len + 1);
@@ -1193,19 +1179,6 @@ static void FTPDataStateFree(void *s)
 #endif
 }
 
-static int FTPDataSetTxDetectState(void *vtx, DetectEngineState *de_state)
-{
-    FtpDataState *ftp_state = (FtpDataState *)vtx;
-    ftp_state->de_state = de_state;
-    return 0;
-}
-
-static DetectEngineState *FTPDataGetTxDetectState(void *vtx)
-{
-    FtpDataState *ftp_state = (FtpDataState *)vtx;
-    return ftp_state->de_state;
-}
-
 static AppLayerTxData *FTPDataGetTxData(void *vtx)
 {
     FtpDataState *ftp_state = (FtpDataState *)vtx;
@@ -1303,9 +1276,6 @@ void RegisterFTPParsers(void)
 
         AppLayerParserRegisterTxFreeFunc(IPPROTO_TCP, ALPROTO_FTP, FTPStateTransactionFree);
 
-        AppLayerParserRegisterDetectStateFuncs(IPPROTO_TCP, ALPROTO_FTP,
-                FTPGetTxDetectState, FTPSetTxDetectState);
-
         AppLayerParserRegisterGetTx(IPPROTO_TCP, ALPROTO_FTP, FTPGetTx);
         AppLayerParserRegisterTxDataFunc(IPPROTO_TCP, ALPROTO_FTP, FTPGetTxData);
 
@@ -1326,8 +1296,6 @@ void RegisterFTPParsers(void)
         AppLayerParserRegisterStateFuncs(IPPROTO_TCP, ALPROTO_FTPDATA, FTPDataStateAlloc, FTPDataStateFree);
         AppLayerParserRegisterParserAcceptableDataDirection(IPPROTO_TCP, ALPROTO_FTPDATA, STREAM_TOSERVER | STREAM_TOCLIENT);
         AppLayerParserRegisterTxFreeFunc(IPPROTO_TCP, ALPROTO_FTPDATA, FTPDataStateTransactionFree);
-        AppLayerParserRegisterDetectStateFuncs(IPPROTO_TCP, ALPROTO_FTPDATA,
-                FTPDataGetTxDetectState, FTPDataSetTxDetectState);
 
         AppLayerParserRegisterGetFilesFunc(IPPROTO_TCP, ALPROTO_FTPDATA, FTPDataStateGetFiles);
 
index d535ce87c3607ba841d0651ff150861e611cde1c..aaf09f6a1126b2a4e2220cee8ddb77ccc3d810c0 100644 (file)
@@ -153,8 +153,6 @@ typedef struct FTPTransaction_  {
     /* Handle multiple responses */
     TAILQ_HEAD(, FTPString_) response_list;
 
-    DetectEngineState *de_state;
-
     TAILQ_ENTRY(FTPTransaction_) next;
 } FTPTransaction;
 
@@ -201,7 +199,6 @@ typedef struct FtpDataState_ {
     uint8_t *input;
     uint8_t *file_name;
     FileContainer *files;
-    DetectEngineState *de_state;
     int32_t input_len;
     int16_t file_len;
     FtpRequestCommand command;
index 380e61d3e1b9bb43e85f5f6b01aae2256a538195..3b127ac63889d7c6a6ba1c1002d00c8d6adbfd50 100644 (file)
@@ -335,8 +335,8 @@ static void HtpTxUserDataFree(HtpState *state, HtpTxUserData *htud)
         AppLayerDecoderEventsFreeEvents(&htud->decoder_events);
         if (htud->boundary)
             HTPFree(htud->boundary, htud->boundary_len);
-        if (htud->de_state != NULL) {
-            DetectEngineStateFree(htud->de_state);
+        if (htud->tx_data.de_state != NULL) {
+            DetectEngineStateFree(htud->tx_data.de_state);
         }
         HTPFree(htud, sizeof(HtpTxUserData));
     }
@@ -1291,13 +1291,13 @@ static void HtpRequestBodyReassemble(HtpTxUserData *htud,
 static void FlagDetectStateNewFile(HtpTxUserData *tx, int dir)
 {
     SCEnter();
-    if (tx && tx->de_state) {
+    if (tx && tx->tx_data.de_state) {
         if (dir == STREAM_TOSERVER) {
             SCLogDebug("DETECT_ENGINE_STATE_FLAG_FILE_NEW set");
-            tx->de_state->dir_state[0].flags |= DETECT_ENGINE_STATE_FLAG_FILE_NEW;
+            tx->tx_data.de_state->dir_state[0].flags |= DETECT_ENGINE_STATE_FLAG_FILE_NEW;
         } else if (STREAM_TOCLIENT) {
             SCLogDebug("DETECT_ENGINE_STATE_FLAG_FILE_NEW set");
-            tx->de_state->dir_state[1].flags |= DETECT_ENGINE_STATE_FLAG_FILE_NEW;
+            tx->tx_data.de_state->dir_state[1].flags |= DETECT_ENGINE_STATE_FLAG_FILE_NEW;
         }
     }
 }
@@ -3004,24 +3004,6 @@ static void HTPStateTruncate(void *state, uint8_t direction)
     }
 }
 
-static DetectEngineState *HTPGetTxDetectState(void *vtx)
-{
-    htp_tx_t *tx = (htp_tx_t *)vtx;
-    HtpTxUserData *tx_ud = htp_tx_get_user_data(tx);
-    return tx_ud ? tx_ud->de_state : NULL;
-}
-
-static int HTPSetTxDetectState(void *vtx, DetectEngineState *s)
-{
-    htp_tx_t *tx = (htp_tx_t *)vtx;
-    HtpTxUserData *tx_ud = htp_tx_get_user_data(tx);
-    if (tx_ud == NULL) {
-        return -ENOMEM;
-    }
-    tx_ud->de_state = s;
-    return 0;
-}
-
 static AppLayerTxData *HTPGetTxData(void *vtx)
 {
     htp_tx_t *tx = (htp_tx_t *)vtx;
@@ -3117,8 +3099,6 @@ void RegisterHTPParsers(void)
                 IPPROTO_TCP, ALPROTO_HTTP1, HTPStateGetEventInfoById);
 
         AppLayerParserRegisterTruncateFunc(IPPROTO_TCP, ALPROTO_HTTP1, HTPStateTruncate);
-        AppLayerParserRegisterDetectStateFuncs(
-                IPPROTO_TCP, ALPROTO_HTTP1, HTPGetTxDetectState, HTPSetTxDetectState);
         AppLayerParserRegisterTxDataFunc(IPPROTO_TCP, ALPROTO_HTTP1, HTPGetTxData);
 
         AppLayerParserRegisterSetStreamDepthFlag(
index 66c52a359e7784791215d0f068bd8131ca625471..8932fc32f74e55ebbf6660d5f9cf025211194307 100644 (file)
@@ -241,7 +241,6 @@ typedef struct HtpTxUserData_ {
 
     uint8_t request_body_type;
 
-    DetectEngineState *de_state;
     AppLayerTxData tx_data;
 } HtpTxUserData;
 
index 731c987d49b56187c92436841c03324ddddf1e7a..cf80cc938775e2cc85586180e9a818bb5cbc68f3 100644 (file)
@@ -118,9 +118,6 @@ typedef struct AppLayerParserProtoCtx_
     int (*StateGetEventInfo)(const char *event_name,
                              int *event_id, AppLayerEventType *event_type);
 
-    DetectEngineState *(*GetTxDetectState)(void *tx);
-    int (*SetTxDetectState)(void *tx, DetectEngineState *);
-
     AppLayerTxData *(*GetTxData)(void *tx);
     bool (*ApplyTxConfig)(void *state, void *tx, int mode, AppLayerTxConfig);
 
@@ -562,18 +559,6 @@ void AppLayerParserRegisterGetEventInfo(uint8_t ipproto, AppProto alproto,
     SCReturn;
 }
 
-void AppLayerParserRegisterDetectStateFuncs(uint8_t ipproto, AppProto alproto,
-        DetectEngineState *(*GetTxDetectState)(void *tx),
-        int (*SetTxDetectState)(void *tx, DetectEngineState *))
-{
-    SCEnter();
-
-    alp_ctx.ctxs[FlowGetProtoMapping(ipproto)][alproto].GetTxDetectState = GetTxDetectState;
-    alp_ctx.ctxs[FlowGetProtoMapping(ipproto)][alproto].SetTxDetectState = SetTxDetectState;
-
-    SCReturn;
-}
-
 void AppLayerParserRegisterTxDataFunc(uint8_t ipproto, AppProto alproto,
         AppLayerTxData *(*GetTxData)(void *tx))
 {
@@ -1162,7 +1147,8 @@ int AppLayerParserSupportsFiles(uint8_t ipproto, AppProto alproto)
 DetectEngineState *AppLayerParserGetTxDetectState(uint8_t ipproto, AppProto alproto, void *tx)
 {
     SCEnter();
-    DetectEngineState *s = alp_ctx.ctxs[FlowGetProtoMapping(ipproto)][alproto].GetTxDetectState(tx);
+    AppLayerTxData *d = AppLayerParserGetTxData(ipproto, alproto, tx);
+    DetectEngineState *s = d->de_state;
     SCReturnPtr(s, "DetectEngineState");
 }
 
@@ -1170,8 +1156,9 @@ int AppLayerParserSetTxDetectState(const Flow *f,
                                    void *tx, DetectEngineState *s)
 {
     SCEnter();
-    int r = alp_ctx.ctxs[f->protomap][f->alproto].SetTxDetectState(tx, s);
-    SCReturnInt(r);
+    AppLayerTxData *d = alp_ctx.ctxs[f->protomap][f->alproto].GetTxData(tx);
+    d->de_state = s;
+    SCReturnInt(0);
 }
 
 AppLayerTxData *AppLayerParserGetTxData(uint8_t ipproto, AppProto alproto, void *tx)
@@ -1523,7 +1510,6 @@ static void ValidateParserProtoDump(AppProto alproto, uint8_t ipproto)
             ctx->StateGetTx, ctx->StateGetTxCnt, ctx->StateTransactionFree);
     printf("- GetTxData %p\n", ctx->GetTxData);
     printf("- StateGetProgress %p\n", ctx->StateGetProgress);
-    printf("- GetTxDetectState %p SetTxDetectState %p\n", ctx->GetTxDetectState, ctx->SetTxDetectState);
     printf("Optional:\n");
     printf("- LocalStorageAlloc %p LocalStorageFree %p\n", ctx->LocalStorageAlloc, ctx->LocalStorageFree);
     printf("- StateGetEvents %p StateGetEventInfo %p StateGetEventInfoById %p\n", ctx->StateGetEvents, ctx->StateGetEventInfo,
@@ -1559,9 +1545,6 @@ static void ValidateParserProto(AppProto alproto, uint8_t ipproto)
     if (!(BOTH_SET_OR_BOTH_UNSET(ctx->LocalStorageAlloc, ctx->LocalStorageFree))) {
         goto bad;
     }
-    if (!(BOTH_SET(ctx->GetTxDetectState, ctx->SetTxDetectState))) {
-        goto bad;
-    }
     if (ctx->GetTxData == NULL) {
         goto bad;
     }
index 0fb06c1b262df631621e907cba5f914efbbe68c1..e8304ccfc7719799f7d2a201e8c884cd44668ec9 100644 (file)
@@ -204,9 +204,6 @@ void AppLayerParserRegisterGetEventInfo(uint8_t ipproto, AppProto alproto,
 void AppLayerParserRegisterGetEventInfoById(uint8_t ipproto, AppProto alproto,
     int (*StateGetEventInfoById)(int event_id, const char **event_name,
                                  AppLayerEventType *event_type));
-void AppLayerParserRegisterDetectStateFuncs(uint8_t ipproto, AppProto alproto,
-        DetectEngineState *(*GetTxDetectState)(void *tx),
-        int (*SetTxDetectState)(void *tx, DetectEngineState *));
 void AppLayerParserRegisterGetStreamDepth(uint8_t ipproto,
                                           AppProto alproto,
                                           uint32_t (*GetStreamDepth)(void));
index fe2e80bc7422b0a7b3207cdd21c8799b2bd3c889..65f7d4ddbf76aa1dcd38dde4c2b9d837300a0f55 100644 (file)
@@ -137,10 +137,6 @@ int AppLayerRegisterParser(const struct AppLayerParser *p, AppProto alproto)
     AppLayerParserRegisterGetTx(p->ip_proto, alproto,
         p->StateGetTx);
 
-    /* What is this being registered for? */
-    AppLayerParserRegisterDetectStateFuncs(p->ip_proto, alproto,
-        p->GetTxDetectState, p->SetTxDetectState);
-
     if (p->StateGetEventInfo) {
         AppLayerParserRegisterGetEventInfo(p->ip_proto, alproto,
                 p->StateGetEventInfo);
index ee58dc3b97f989022f66f95a5603eda473d3f838..ec37f34fc0648948f306384b1e1a6f111f13d63f 100644 (file)
@@ -49,9 +49,6 @@ typedef struct AppLayerParser {
     const int complete_tc;
     int (*StateGetProgress)(void *alstate, uint8_t direction);
 
-    DetectEngineState *(*GetTxDetectState)(void *tx);
-    int (*SetTxDetectState)(void *tx, DetectEngineState *);
-
     AppLayerDecoderEvents *(*StateGetEvents)(void *);
     int (*StateGetEventInfo)(const char *event_name,
                              int *event_id, AppLayerEventType *event_type);
index bb116ecc0ec7a08cdbda8ccf8648394373e25b53..e3be620d83e0adb6249eb7f7dd021c93b5f266fc 100644 (file)
@@ -374,12 +374,12 @@ static SMTPTransaction *SMTPTransactionCreate(void)
 
 static void FlagDetectStateNewFile(SMTPTransaction *tx)
 {
-    if (tx && tx->de_state) {
+    if (tx && tx->tx_data.de_state) {
         SCLogDebug("DETECT_ENGINE_STATE_FLAG_FILE_NEW set");
-        tx->de_state->dir_state[0].flags |= DETECT_ENGINE_STATE_FLAG_FILE_NEW;
+        tx->tx_data.de_state->dir_state[0].flags |= DETECT_ENGINE_STATE_FLAG_FILE_NEW;
     } else if (tx == NULL) {
         SCLogDebug("DETECT_ENGINE_STATE_FLAG_FILE_NEW NOT set, no TX");
-    } else if (tx->de_state == NULL) {
+    } else if (tx->tx_data.de_state == NULL) {
         SCLogDebug("DETECT_ENGINE_STATE_FLAG_FILE_NEW NOT set, no TX DESTATE");
     }
 }
@@ -1533,8 +1533,8 @@ static void SMTPTransactionFree(SMTPTransaction *tx, SMTPState *state)
     if (tx->decoder_events != NULL)
         AppLayerDecoderEventsFreeEvents(&tx->decoder_events);
 
-    if (tx->de_state != NULL)
-        DetectEngineStateFree(tx->de_state);
+    if (tx->tx_data.de_state != NULL)
+        DetectEngineStateFree(tx->tx_data.de_state);
 
     if (tx->mail_from)
         SCFree(tx->mail_from);
@@ -1762,19 +1762,6 @@ static AppLayerDecoderEvents *SMTPGetEvents(void *tx)
     return ((SMTPTransaction *)tx)->decoder_events;
 }
 
-static DetectEngineState *SMTPGetTxDetectState(void *vtx)
-{
-    SMTPTransaction *tx = (SMTPTransaction *)vtx;
-    return tx->de_state;
-}
-
-static int SMTPSetTxDetectState(void *vtx, DetectEngineState *s)
-{
-    SMTPTransaction *tx = (SMTPTransaction *)vtx;
-    tx->de_state = s;
-    return 0;
-}
-
 static AppLayerTxData *SMTPGetTxData(void *vtx)
 {
     SMTPTransaction *tx = (SMTPTransaction *)vtx;
@@ -1809,8 +1796,6 @@ void RegisterSMTPParsers(void)
         AppLayerParserRegisterGetEventInfo(IPPROTO_TCP, ALPROTO_SMTP, SMTPStateGetEventInfo);
         AppLayerParserRegisterGetEventInfoById(IPPROTO_TCP, ALPROTO_SMTP, SMTPStateGetEventInfoById);
         AppLayerParserRegisterGetEventsFunc(IPPROTO_TCP, ALPROTO_SMTP, SMTPGetEvents);
-        AppLayerParserRegisterDetectStateFuncs(IPPROTO_TCP, ALPROTO_SMTP,
-                                               SMTPGetTxDetectState, SMTPSetTxDetectState);
 
         AppLayerParserRegisterLocalStorageFunc(IPPROTO_TCP, ALPROTO_SMTP, SMTPLocalStorageAlloc,
                                                SMTPLocalStorageFree);
index b8ca5e0fcb693e09b61d0729a5ba8fcf399530cd..530f4a275a8e4346d5fb79cafaa21c901a39938d 100644 (file)
@@ -80,7 +80,6 @@ typedef struct SMTPTransaction_ {
     MimeDecParseState *mime_state;
 
     AppLayerDecoderEvents *decoder_events;          /**< per tx events */
-    DetectEngineState *de_state;
 
     /* MAIL FROM parameters */
     uint8_t *mail_from;
index cd46b6b4d441aee7f127ea8d34447a7778ddf044..5f543561444a1d4e70d9e9318a0278631355d783 100644 (file)
@@ -251,19 +251,6 @@ static AppLayerDecoderEvents *SSLGetEvents(void *tx)
     return ssl_state->decoder_events;
 }
 
-static int SSLSetTxDetectState(void *vtx, DetectEngineState *de_state)
-{
-    SSLState *ssl_state = (SSLState *)vtx;
-    ssl_state->de_state = de_state;
-    return 0;
-}
-
-static DetectEngineState *SSLGetTxDetectState(void *vtx)
-{
-    SSLState *ssl_state = (SSLState *)vtx;
-    return ssl_state->de_state;
-}
-
 static void *SSLGetTx(void *state, uint64_t tx_id)
 {
     SSLState *ssl_state = (SSLState *)state;
@@ -2693,8 +2680,8 @@ static void SSLStateFree(void *p)
 
     AppLayerDecoderEventsFreeEvents(&ssl_state->decoder_events);
 
-    if (ssl_state->de_state != NULL) {
-        DetectEngineStateFree(ssl_state->de_state);
+    if (ssl_state->tx_data.de_state != NULL) {
+        DetectEngineStateFree(ssl_state->tx_data.de_state);
     }
 
     /* Free certificate chain */
@@ -2968,9 +2955,6 @@ void RegisterSSLParsers(void)
 
         AppLayerParserRegisterGetEventsFunc(IPPROTO_TCP, ALPROTO_TLS, SSLGetEvents);
 
-        AppLayerParserRegisterDetectStateFuncs(IPPROTO_TCP, ALPROTO_TLS,
-                                               SSLGetTxDetectState, SSLSetTxDetectState);
-
         AppLayerParserRegisterGetTx(IPPROTO_TCP, ALPROTO_TLS, SSLGetTx);
         AppLayerParserRegisterTxDataFunc(IPPROTO_TCP, ALPROTO_TLS, SSLGetTxData);
 
index bf8fc0f9e29a9bdbe2d2590ff070e11a58f6959a..a5d9c2d0ff229b528a4630cef0f2613e964f503f 100644 (file)
@@ -250,7 +250,6 @@ typedef struct SSLState_ {
     SSLStateConnp client_connp;
     SSLStateConnp server_connp;
 
-    DetectEngineState *de_state;
     AppLayerDecoderEvents *decoder_events;
 } SSLState;
 
index 2a9e37203052b9583eb993a9e2b1a4480ee1bd26..ff343007a1418f9d95cc800d18372c309014a7a3 100644 (file)
@@ -447,26 +447,6 @@ static AppLayerTxData *TemplateGetTxData(void *vtx)
     return &tx->tx_data;
 }
 
-/**
- * \brief retrieve the detection engine per tx state
- */
-static DetectEngineState *TemplateGetTxDetectState(void *vtx)
-{
-    TemplateTransaction *tx = vtx;
-    return tx->de_state;
-}
-
-/**
- * \brief get the detection engine per tx state
- */
-static int TemplateSetTxDetectState(void *vtx,
-    DetectEngineState *s)
-{
-    TemplateTransaction *tx = vtx;
-    tx->de_state = s;
-    return 0;
-}
-
 void RegisterTemplateParsers(void)
 {
     const char *proto_name = "template";
@@ -553,10 +533,6 @@ void RegisterTemplateParsers(void)
         AppLayerParserRegisterTxDataFunc(IPPROTO_TCP, ALPROTO_TEMPLATE,
             TemplateGetTxData);
 
-        /* What is this being registered for? */
-        AppLayerParserRegisterDetectStateFuncs(IPPROTO_TCP, ALPROTO_TEMPLATE,
-            TemplateGetTxDetectState, TemplateSetTxDetectState);
-
         AppLayerParserRegisterGetEventInfo(IPPROTO_TCP, ALPROTO_TEMPLATE,
             TemplateStateGetEventInfo);
         AppLayerParserRegisterGetEventInfoById(IPPROTO_TCP, ALPROTO_TEMPLATE,
index 79960e21a50804bd925db78510d8820332f6aada..fcd20915c3a8bffc230df43a513cabc6cea9763a 100644 (file)
@@ -51,8 +51,6 @@ typedef struct TemplateTransaction
     uint8_t response_done; /*<< Flag to be set when the response is
                             * seen. */
 
-    DetectEngineState *de_state;
-
     AppLayerTxData tx_data;
 
     TAILQ_ENTRY(TemplateTransaction) next;
index e2df52a96678daac3cb3724643d5a5780d798f0a..25a6ed3355a560409932f459cb3c08c406ee2fb2 100644 (file)
@@ -159,17 +159,6 @@ static int TFTPGetStateProgress(void *tx, uint8_t direction)
     return 1;
 }
 
-static DetectEngineState *TFTPGetTxDetectState(void *vtx)
-{
-    return NULL;
-}
-
-static int TFTPSetTxDetectState(void *vtx,
-    DetectEngineState *s)
-{
-    return 0;
-}
-
 void RegisterTFTPParsers(void)
 {
     const char *proto_name = "tftp";
@@ -242,11 +231,6 @@ void RegisterTFTPParsers(void)
         AppLayerParserRegisterGetTx(IPPROTO_UDP, ALPROTO_TFTP,
                                     TFTPGetTx);
 
-        /* What is this being registered for? */
-        AppLayerParserRegisterDetectStateFuncs(IPPROTO_UDP, ALPROTO_TFTP,
-                                               TFTPGetTxDetectState,
-                                               TFTPSetTxDetectState);
-
         AppLayerParserRegisterGetEventInfo(IPPROTO_UDP, ALPROTO_TFTP,
                                            TFTPStateGetEventInfo);
         AppLayerParserRegisterGetEventsFunc(IPPROTO_UDP, ALPROTO_TFTP,