]> git.ipfire.org Git - people/ms/suricata.git/commitdiff
app-layer: remove callback for completion status
authorVictor Julien <victor@inliniac.net>
Fri, 30 Oct 2020 12:40:17 +0000 (13:40 +0100)
committerVictor Julien <victor@inliniac.net>
Mon, 7 Dec 2020 19:47:56 +0000 (20:47 +0100)
Since the completion status was a constant for all parsers, remove the
callback logic and instead register the values themselves. This should
avoid a lot of unnecessary callback calls.

Update all parsers to take advantage of this.

35 files changed:
rust/src/applayer.rs
rust/src/applayertemplate/template.rs
rust/src/dcerpc/dcerpc.rs
rust/src/dhcp/dhcp.rs
rust/src/dns/dns.rs
rust/src/http2/http2.rs
rust/src/ikev2/ikev2.rs
rust/src/krb/krb5.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-dcerpc-udp.c
src/app-layer-dcerpc.c
src/app-layer-dnp3.c
src/app-layer-enip.c
src/app-layer-ftp.c
src/app-layer-htp.c
src/app-layer-modbus.c
src/app-layer-nfs-tcp.c
src/app-layer-nfs-udp.c
src/app-layer-parser.c
src/app-layer-parser.h
src/app-layer-register.c
src/app-layer-register.h
src/app-layer-smb.c
src/app-layer-smtp.c
src/app-layer-ssl.c
src/app-layer-template.c
src/app-layer-tftp.c

index 8eacadcc00894e029063814bc586d33c3da3fb7f..476ea1cb361f8e2fe96ac3fd273ae6e68950eb88 100644 (file)
@@ -193,8 +193,9 @@ pub struct RustParser {
     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,
+    /// Progress values at which the tx is considered complete in a direction
+    pub tx_comp_st_ts:      c_int,
+    pub tx_comp_st_tc:      c_int,
     /// Function returning the current transaction progress
     pub tx_get_progress:    StateGetProgressFn,
 
@@ -265,7 +266,6 @@ 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;
index 25576b51c49d65cf187c1edcf1116d4de2b15437..99d9343eb951d31cfcfcbadc37b5073a284234dd 100644 (file)
@@ -395,14 +395,6 @@ pub extern "C" fn rs_template_state_get_tx_count(
     return state.tx_id;
 }
 
-#[no_mangle]
-pub extern "C" fn rs_template_state_progress_completion_status(
-    _direction: u8,
-) -> std::os::raw::c_int {
-    // This parser uses 1 to signal transaction completion status.
-    return 1;
-}
-
 #[no_mangle]
 pub extern "C" fn rs_template_tx_get_alstate_progress(
     tx: *mut std::os::raw::c_void,
@@ -535,7 +527,8 @@ pub unsafe extern "C" fn rs_template_register_parser() {
         parse_tc: rs_template_parse_response,
         get_tx_count: rs_template_state_get_tx_count,
         get_tx: rs_template_state_get_tx,
-        tx_get_comp_st: rs_template_state_progress_completion_status,
+        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,
index 70786abe02ee8b0d724fe445009c03b876229a01..62a899df900628a4ca74c3e5cc2c838fc75c40f8 100644 (file)
@@ -1290,11 +1290,6 @@ pub extern "C" fn rs_dcerpc_get_alstate_progress(tx: &mut DCERPCTransaction, dir
     return 0;
 }
 
-#[no_mangle]
-pub extern "C" fn rs_dcerpc_get_alstate_progress_completion_status(_direction: u8) -> u8 {
-    1
-}
-
 #[no_mangle]
 pub extern "C" fn rs_dcerpc_get_tx_data(
     tx: *mut std::os::raw::c_void)
index 442ccecd71171ee9b916438775d637b6d41a6240..e4ff939580b40f29ef0f24b277026f87ebb6abcf 100644 (file)
@@ -253,13 +253,6 @@ pub extern "C" fn rs_dhcp_tx_get_alstate_progress(_tx: *mut std::os::raw::c_void
     return 1;
 }
 
-#[no_mangle]
-pub extern "C" fn rs_dhcp_state_progress_completion_status(
-    _direction: u8) -> std::os::raw::c_int {
-    // The presence of a transaction means we are complete.
-    return 1;
-}
-
 #[no_mangle]
 pub extern "C" fn rs_dhcp_state_get_tx(state: *mut std::os::raw::c_void,
                                        tx_id: u64) -> *mut std::os::raw::c_void {
@@ -423,7 +416,8 @@ pub unsafe extern "C" fn rs_dhcp_register_parser() {
         parse_tc           : rs_dhcp_parse,
         get_tx_count       : rs_dhcp_state_get_tx_count,
         get_tx             : rs_dhcp_state_get_tx,
-        tx_get_comp_st     : rs_dhcp_state_progress_completion_status,
+        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,
index 89f32e8e6703aa1d159ab2ca773d7da9e675cedb..e876be23c8ea4f0c417bd8ed613197a42c8e25fa 100644 (file)
@@ -824,15 +824,6 @@ pub extern "C" fn rs_dns_parse_response_tcp(_flow: *const core::Flow,
     AppLayerResult::ok()
 }
 
-#[no_mangle]
-pub extern "C" fn rs_dns_state_progress_completion_status(
-    _direction: u8)
-    -> std::os::raw::c_int
-{
-    SCLogDebug!("rs_dns_state_progress_completion_status");
-    return 1;
-}
-
 #[no_mangle]
 pub extern "C" fn rs_dns_tx_get_alstate_progress(_tx: *mut std::os::raw::c_void,
                                                  _direction: u8)
@@ -1072,7 +1063,8 @@ pub unsafe extern "C" fn rs_dns_udp_register_parser() {
         parse_tc: rs_dns_parse_response,
         get_tx_count: rs_dns_state_get_tx_count,
         get_tx: rs_dns_state_get_tx,
-        tx_get_comp_st: rs_dns_state_progress_completion_status,
+        tx_comp_st_ts: 1,
+        tx_comp_st_tc: 1,
         tx_get_progress: rs_dns_tx_get_alstate_progress,
         get_events: Some(rs_dns_state_get_events),
         get_eventinfo: Some(rs_dns_state_get_event_info),
@@ -1117,7 +1109,8 @@ pub unsafe extern "C" fn rs_dns_tcp_register_parser() {
         parse_tc: rs_dns_parse_response_tcp,
         get_tx_count: rs_dns_state_get_tx_count,
         get_tx: rs_dns_state_get_tx,
-        tx_get_comp_st: rs_dns_state_progress_completion_status,
+        tx_comp_st_ts: 1,
+        tx_comp_st_tc: 1,
         tx_get_progress: rs_dns_tx_get_alstate_progress,
         get_events: Some(rs_dns_state_get_events),
         get_eventinfo: Some(rs_dns_state_get_event_info),
index 252e3950d605e21e3de0d268f528608c2071f3aa..a0d97904d808d8def835e0b7e4d7540b4afe26ec 100644 (file)
@@ -1011,11 +1011,6 @@ pub extern "C" fn rs_http2_state_get_tx_count(state: *mut std::os::raw::c_void)
     return state.tx_id;
 }
 
-#[no_mangle]
-pub extern "C" fn rs_http2_state_progress_completion_status(_direction: u8) -> std::os::raw::c_int {
-    return HTTP2TransactionState::HTTP2StateClosed as i32;
-}
-
 #[no_mangle]
 pub extern "C" fn rs_http2_tx_get_state(tx: *mut std::os::raw::c_void) -> HTTP2TransactionState {
     let tx = cast_pointer!(tx, HTTP2Transaction);
@@ -1147,7 +1142,8 @@ pub unsafe extern "C" fn rs_http2_register_parser() {
         parse_tc: rs_http2_parse_tc,
         get_tx_count: rs_http2_state_get_tx_count,
         get_tx: rs_http2_state_get_tx,
-        tx_get_comp_st: rs_http2_state_progress_completion_status,
+        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,
index 3e81be13fa1c2dfd98d0208146ef5a7a6021a9ca..c3e36933032e6421dfe742d4e97a9eaa6875b96b 100644 (file)
@@ -528,14 +528,6 @@ pub extern "C" fn rs_ikev2_state_tx_free(state: *mut std::os::raw::c_void,
     state.free_tx(tx_id);
 }
 
-#[no_mangle]
-pub extern "C" fn rs_ikev2_state_progress_completion_status(
-    _direction: u8)
-    -> std::os::raw::c_int
-{
-    return 1;
-}
-
 #[no_mangle]
 pub extern "C" fn rs_ikev2_tx_get_alstate_progress(_tx: *mut std::os::raw::c_void,
                                                  _direction: u8)
@@ -697,7 +689,8 @@ pub unsafe extern "C" fn rs_register_ikev2_parser() {
         parse_tc           : rs_ikev2_parse_response,
         get_tx_count       : rs_ikev2_state_get_tx_count,
         get_tx             : rs_ikev2_state_get_tx,
-        tx_get_comp_st     : rs_ikev2_state_progress_completion_status,
+        tx_comp_st_ts      : 1,
+        tx_comp_st_tc      : 1,
         tx_get_progress    : rs_ikev2_tx_get_alstate_progress,
         get_de_state       : rs_ikev2_state_get_tx_detect_state,
         set_de_state       : rs_ikev2_state_set_tx_detect_state,
index 5c5975ef6f24870056e8fb63694291daccbdd1ba..067213abdc0e87703cfaf6989ffc0a4dd7c5b4e6 100644 (file)
@@ -316,14 +316,6 @@ pub extern "C" fn rs_krb5_state_tx_free(state: *mut std::os::raw::c_void,
     state.free_tx(tx_id);
 }
 
-#[no_mangle]
-pub extern "C" fn rs_krb5_state_progress_completion_status(
-    _direction: u8)
-    -> std::os::raw::c_int
-{
-    return 1;
-}
-
 #[no_mangle]
 pub extern "C" fn rs_krb5_tx_get_alstate_progress(_tx: *mut std::os::raw::c_void,
                                                  _direction: u8)
@@ -643,7 +635,8 @@ pub unsafe extern "C" fn rs_register_krb5_parser() {
         parse_tc           : rs_krb5_parse_response,
         get_tx_count       : rs_krb5_state_get_tx_count,
         get_tx             : rs_krb5_state_get_tx,
-        tx_get_comp_st     : rs_krb5_state_progress_completion_status,
+        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,
index 183bc4dd332c2522b5b5c19453d2db1e8ddccb25..33702cf221c50ecb5156c7009d46289552d23bc7 100644 (file)
@@ -647,11 +647,6 @@ pub extern "C" fn rs_mqtt_state_get_tx_count(state: *mut std::os::raw::c_void) -
     return state.tx_id;
 }
 
-#[no_mangle]
-pub extern "C" fn rs_mqtt_state_progress_completion_status(_direction: u8) -> std::os::raw::c_int {
-    return 1;
-}
-
 #[no_mangle]
 pub extern "C" fn rs_mqtt_tx_is_toclient(tx: *const std::os::raw::c_void) -> std::os::raw::c_int {
     let tx = cast_pointer!(tx, MQTTTransaction);
@@ -815,7 +810,8 @@ pub unsafe extern "C" fn rs_mqtt_register_parser(cfg_max_msg_len: u32) {
         parse_tc: rs_mqtt_parse_response,
         get_tx_count: rs_mqtt_state_get_tx_count,
         get_tx: rs_mqtt_state_get_tx,
-        tx_get_comp_st: rs_mqtt_state_progress_completion_status,
+        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,
index 283370fe16c46d87a68d4b72379f2106888029dd..d33d548b431e3577792a61b49955213b36164a8e 100644 (file)
@@ -1555,14 +1555,6 @@ pub extern "C" fn rs_nfs_state_tx_free(state: &mut NFSState,
     state.free_tx(tx_id);
 }
 
-#[no_mangle]
-pub extern "C" fn rs_nfs_state_progress_completion_status(
-    _direction: u8)
-    -> std::os::raw::c_int
-{
-    return 1;
-}
-
 #[no_mangle]
 pub extern "C" fn rs_nfs_tx_get_alstate_progress(tx: &mut NFSTransaction,
                                                   direction: u8)
index 913d5810db120a9f74211ce89376cb75caf080f8..02e9fdca9bf60f833e70b2365fcc1b92bd7a4322 100644 (file)
@@ -250,14 +250,6 @@ pub extern "C" fn rs_ntp_state_tx_free(state: *mut std::os::raw::c_void,
     state.free_tx(tx_id);
 }
 
-#[no_mangle]
-pub extern "C" fn rs_ntp_state_progress_completion_status(
-    _direction: u8)
-    -> std::os::raw::c_int
-{
-    return 1;
-}
-
 #[no_mangle]
 pub extern "C" fn rs_ntp_tx_get_alstate_progress(_tx: *mut std::os::raw::c_void,
                                                  _direction: u8)
@@ -393,7 +385,8 @@ pub unsafe extern "C" fn rs_register_ntp_parser() {
         parse_tc           : rs_ntp_parse_response,
         get_tx_count       : rs_ntp_state_get_tx_count,
         get_tx             : rs_ntp_state_get_tx,
-        tx_get_comp_st     : rs_ntp_state_progress_completion_status,
+        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,
index fac136b6e3e51169ec7f590243113bc1ee315915..b03a774772177aa56e7f875251336052ebc5c800 100644 (file)
@@ -100,12 +100,6 @@ pub extern "C" fn rs_rdp_state_get_tx_count(state: *mut std::os::raw::c_void) ->
     return state.next_id;
 }
 
-#[no_mangle]
-pub extern "C" fn rs_rdp_tx_get_progress_complete(_direction: u8) -> std::os::raw::c_int {
-    // a parser can implement a multi-step tx completion by using an arbitrary `n`
-    return 1;
-}
-
 #[no_mangle]
 pub extern "C" fn rs_rdp_tx_get_progress(
     _tx: *mut std::os::raw::c_void, _direction: u8,
@@ -481,7 +475,8 @@ pub unsafe extern "C" fn rs_rdp_register_parser() {
         parse_tc: rs_rdp_parse_tc,
         get_tx_count: rs_rdp_state_get_tx_count,
         get_tx: rs_rdp_state_get_tx,
-        tx_get_comp_st: rs_rdp_tx_get_progress_complete,
+        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,
index aa18ab5d4021b110f5a5e3f41d7f2d1c9b077b88..3bbc330551450ee0a7a426770dc1a01932db9746 100644 (file)
@@ -593,14 +593,6 @@ pub extern "C" fn rs_rfb_state_get_tx_count(
     return state.tx_id;
 }
 
-#[no_mangle]
-pub extern "C" fn rs_rfb_state_progress_completion_status(
-    _direction: u8,
-) -> std::os::raw::c_int {
-    // This parser uses 1 to signal transaction completion status.
-    return 1;
-}
-
 #[no_mangle]
 pub extern "C" fn rs_rfb_tx_get_alstate_progress(
     tx: *mut std::os::raw::c_void,
@@ -686,7 +678,8 @@ pub unsafe extern "C" fn rs_rfb_register_parser() {
         parse_tc: rs_rfb_parse_response,
         get_tx_count: rs_rfb_state_get_tx_count,
         get_tx: rs_rfb_state_get_tx,
-        tx_get_comp_st: rs_rfb_state_progress_completion_status,
+        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,
index 9cfaf52002ef5aad1fec20421c620a0d93eddfe8..8874bdccef8ec4b28c9f003f4823c2d9c14fd93a 100755 (executable)
@@ -205,11 +205,6 @@ pub extern "C" fn rs_sip_state_tx_free(state: *mut std::os::raw::c_void, tx_id:
     state.free_tx(tx_id);
 }
 
-#[no_mangle]
-pub extern "C" fn rs_sip_state_progress_completion_status(_direction: u8) -> std::os::raw::c_int {
-    return 1;
-}
-
 #[no_mangle]
 pub extern "C" fn rs_sip_tx_get_alstate_progress(
     _tx: *mut std::os::raw::c_void,
@@ -379,7 +374,8 @@ pub unsafe extern "C" fn rs_sip_register_parser() {
         parse_tc: rs_sip_parse_response,
         get_tx_count: rs_sip_state_get_tx_count,
         get_tx: rs_sip_state_get_tx,
-        tx_get_comp_st: rs_sip_state_progress_completion_status,
+        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,
index 70262391cc688d8a7b22f534971a3c705089c367..3a516b841deb39d9968bf7b87cb57ff75964ada5 100644 (file)
@@ -2038,14 +2038,6 @@ pub extern "C" fn rs_smb_state_tx_free(state: &mut SMBState,
     state.free_tx(tx_id);
 }
 
-#[no_mangle]
-pub extern "C" fn rs_smb_state_progress_completion_status(
-    _direction: u8)
-    -> std::os::raw::c_int
-{
-    return 1;
-}
-
 #[no_mangle]
 pub extern "C" fn rs_smb_tx_get_alstate_progress(tx: &mut SMBTransaction,
                                                   direction: u8)
index a712d0f3af27a3c011c1ce8c86e0b9ed35680bd8..20136838f2647f89befe0c648695b4a93887378f 100644 (file)
@@ -366,14 +366,6 @@ pub extern "C" fn rs_snmp_state_tx_free(state: *mut std::os::raw::c_void,
     state.free_tx(tx_id);
 }
 
-#[no_mangle]
-pub extern "C" fn rs_snmp_state_progress_completion_status(
-    _direction: u8)
-    -> std::os::raw::c_int
-{
-    return 1;
-}
-
 #[no_mangle]
 pub extern "C" fn rs_snmp_tx_get_alstate_progress(_tx: *mut std::os::raw::c_void,
                                                  _direction: u8)
@@ -571,7 +563,8 @@ pub unsafe extern "C" fn rs_register_snmp_parser() {
         parse_tc           : rs_snmp_parse_response,
         get_tx_count       : rs_snmp_state_get_tx_count,
         get_tx             : rs_snmp_state_get_tx,
-        tx_get_comp_st     : rs_snmp_state_progress_completion_status,
+        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,
index c58c4b47cd17753663e1e32ed66f645ba4b509ed..5330853465b0fc13e17a680d858f943bcac87714 100644 (file)
@@ -488,11 +488,6 @@ pub extern "C" fn rs_ssh_state_get_tx_count(_state: *mut std::os::raw::c_void) -
     return 1;
 }
 
-#[no_mangle]
-pub extern "C" fn rs_ssh_state_progress_completion_status(_direction: u8) -> std::os::raw::c_int {
-    return SSHConnectionState::SshStateFinished as i32;
-}
-
 #[no_mangle]
 pub extern "C" fn rs_ssh_tx_get_flags(
     tx: *mut std::os::raw::c_void, direction: u8,
@@ -552,7 +547,8 @@ pub unsafe extern "C" fn rs_ssh_register_parser() {
         parse_tc: rs_ssh_parse_response,
         get_tx_count: rs_ssh_state_get_tx_count,
         get_tx: rs_ssh_state_get_tx,
-        tx_get_comp_st: rs_ssh_state_progress_completion_status,
+        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,
index d38378ae070e37e6bc636505c501b900e61cbc1d..bc03e8b8c9cb342ac422bfa0cbc93a9801c1170d 100644 (file)
@@ -92,11 +92,6 @@ static uint64_t RustDCERPCUDPGetTxCnt(void *state)
     return rs_dcerpc_udp_get_tx_cnt(state);
 }
 
-static int RustDCERPCUDPGetAlstateProgressCompletionStatus(uint8_t direction)
-{
-    return rs_dcerpc_get_alstate_progress_completion_status(direction);
-}
-
 static int RustDCERPCUDPGetAlstateProgress(void *tx, uint8_t direction)
 {
     return rs_dcerpc_get_alstate_progress(tx, direction);
@@ -148,8 +143,7 @@ void RegisterDCERPCUDPParsers(void)
 
         AppLayerParserRegisterGetStateProgressFunc(IPPROTO_UDP, ALPROTO_DCERPC, RustDCERPCUDPGetAlstateProgress);
 
-        AppLayerParserRegisterGetStateProgressCompletionStatus(ALPROTO_DCERPC,
-                                                               RustDCERPCUDPGetAlstateProgressCompletionStatus);
+        AppLayerParserRegisterStateProgressCompletionStatus(ALPROTO_DCERPC, 1, 1);
     } else {
         SCLogInfo("Parsed disabled for %s protocol. Protocol detection"
             "still on.", "dcerpc");
index 40cd753bf0a2ac9bcf5551ddbf342de87b55f1b0..334ab952cae263370675f6e0408c8187b6882be7 100644 (file)
@@ -116,11 +116,6 @@ static uint64_t DCERPCGetTxCnt(void *state)
     return rs_dcerpc_get_tx_cnt(state);
 }
 
-static int DCERPCGetAlstateProgressCompletionStatus(uint8_t direction)
-{
-    return rs_dcerpc_get_alstate_progress_completion_status(direction);
-}
-
 static int DCERPCGetAlstateProgress(void *tx, uint8_t direction)
 {
     return rs_dcerpc_get_alstate_progress(tx, direction);
@@ -178,8 +173,8 @@ void RegisterDCERPCParsers(void)
 
         AppLayerParserRegisterGetStateProgressFunc(IPPROTO_TCP, ALPROTO_DCERPC, DCERPCGetAlstateProgress);
 
-        AppLayerParserRegisterGetStateProgressCompletionStatus(ALPROTO_DCERPC,
-                                                               DCERPCGetAlstateProgressCompletionStatus);
+        AppLayerParserRegisterStateProgressCompletionStatus(ALPROTO_DCERPC, 1, 1);
+
         /* This parser accepts gaps. */
         AppLayerParserRegisterOptionFlags(IPPROTO_TCP, ALPROTO_DCERPC, APP_LAYER_PARSER_OPT_ACCEPT_GAPS);
 
index 2507a226a8e6570e7a4cc48aa18305c371e077b0..7b5f2382b439f38487ab8739ff0349f0232465c6 100644 (file)
@@ -1499,14 +1499,6 @@ static int DNP3GetAlstateProgress(void *tx, uint8_t direction)
     SCReturnInt(retval);
 }
 
-/**
- * \brief App-layer support.
- */
-static int DNP3GetAlstateProgressCompletionStatus(uint8_t direction)
-{
-    return 1;
-}
-
 /**
  * \brief App-layer support.
  */
@@ -1642,8 +1634,7 @@ void RegisterDNP3Parsers(void)
 
         AppLayerParserRegisterGetStateProgressFunc(IPPROTO_TCP, ALPROTO_DNP3,
             DNP3GetAlstateProgress);
-        AppLayerParserRegisterGetStateProgressCompletionStatus(ALPROTO_DNP3,
-            DNP3GetAlstateProgressCompletionStatus);
+        AppLayerParserRegisterStateProgressCompletionStatus(ALPROTO_DNP3, 1, 1);
 
         AppLayerParserRegisterGetEventInfo(IPPROTO_TCP, ALPROTO_DNP3,
             DNP3StateGetEventInfo);
index 0bb841d67c16024e738292f1b61c57ab975e3c7b..8243a994ab584849f333572884e6848c4a413d8f 100644 (file)
@@ -66,15 +66,6 @@ static int ENIPGetAlstateProgress(void *tx, uint8_t direction)
     return 1;
 }
 
-/** \brief get value for 'complete' status in ENIP
- *
- *  For ENIP we use a simple bool.
- */
-static int ENIPGetAlstateProgressCompletionStatus(uint8_t direction)
-{
-    return 1;
-}
-
 static DetectEngineState *ENIPGetTxDetectState(void *vtx)
 {
     ENIPTransaction *tx = (ENIPTransaction *)vtx;
@@ -486,7 +477,7 @@ void RegisterENIPUDPParsers(void)
         AppLayerParserRegisterTxFreeFunc(IPPROTO_UDP, ALPROTO_ENIP, ENIPStateTransactionFree);
 
         AppLayerParserRegisterGetStateProgressFunc(IPPROTO_UDP, ALPROTO_ENIP, ENIPGetAlstateProgress);
-        AppLayerParserRegisterGetStateProgressCompletionStatus(ALPROTO_ENIP, ENIPGetAlstateProgressCompletionStatus);
+        AppLayerParserRegisterStateProgressCompletionStatus(ALPROTO_ENIP, 1, 1);
 
         AppLayerParserRegisterGetEventInfo(IPPROTO_UDP, ALPROTO_ENIP, ENIPStateGetEventInfo);
         AppLayerParserRegisterGetEventInfoById(IPPROTO_UDP, ALPROTO_ENIP, ENIPStateGetEventInfoById);
@@ -566,7 +557,7 @@ void RegisterENIPTCPParsers(void)
         AppLayerParserRegisterTxFreeFunc(IPPROTO_TCP, ALPROTO_ENIP, ENIPStateTransactionFree);
 
         AppLayerParserRegisterGetStateProgressFunc(IPPROTO_TCP, ALPROTO_ENIP, ENIPGetAlstateProgress);
-        AppLayerParserRegisterGetStateProgressCompletionStatus(ALPROTO_ENIP, ENIPGetAlstateProgressCompletionStatus);
+        AppLayerParserRegisterStateProgressCompletionStatus(ALPROTO_ENIP, 1, 1);
 
         AppLayerParserRegisterGetEventInfo(IPPROTO_TCP, ALPROTO_ENIP, ENIPStateGetEventInfo);
 
index 6c560134088386c2e4c90a9e97f3e0a9fe9e3a0d..a616024f5dcf5eb8efb5b38e2831f2d3dc175de3 100644 (file)
@@ -984,11 +984,6 @@ static uint64_t FTPGetTxCnt(void *state)
     return cnt;
 }
 
-static int FTPGetAlstateProgressCompletionStatus(uint8_t direction)
-{
-    return FTP_STATE_FINISHED;
-}
-
 static int FTPGetAlstateProgress(void *vtx, uint8_t direction)
 {
     SCLogDebug("tx %p", vtx);
@@ -1232,11 +1227,6 @@ static uint64_t FTPDataGetTxCnt(void *state)
     return 1;
 }
 
-static int FTPDataGetAlstateProgressCompletionStatus(uint8_t direction)
-{
-    return FTPDATA_STATE_FINISHED;
-}
-
 static int FTPDataGetAlstateProgress(void *tx, uint8_t direction)
 {
     FtpDataState *ftpdata_state = (FtpDataState *)tx;
@@ -1323,9 +1313,8 @@ void RegisterFTPParsers(void)
 
         AppLayerParserRegisterGetStateProgressFunc(IPPROTO_TCP, ALPROTO_FTP, FTPGetAlstateProgress);
 
-        AppLayerParserRegisterGetStateProgressCompletionStatus(ALPROTO_FTP,
-                                                               FTPGetAlstateProgressCompletionStatus);
-
+        AppLayerParserRegisterStateProgressCompletionStatus(
+                ALPROTO_FTP, FTP_STATE_FINISHED, FTP_STATE_FINISHED);
 
         AppLayerRegisterExpectationProto(IPPROTO_TCP, ALPROTO_FTPDATA);
         AppLayerParserRegisterParser(IPPROTO_TCP, ALPROTO_FTPDATA, STREAM_TOSERVER,
@@ -1347,8 +1336,8 @@ void RegisterFTPParsers(void)
 
         AppLayerParserRegisterGetStateProgressFunc(IPPROTO_TCP, ALPROTO_FTPDATA, FTPDataGetAlstateProgress);
 
-        AppLayerParserRegisterGetStateProgressCompletionStatus(ALPROTO_FTPDATA,
-                FTPDataGetAlstateProgressCompletionStatus);
+        AppLayerParserRegisterStateProgressCompletionStatus(
+                ALPROTO_FTPDATA, FTPDATA_STATE_FINISHED, FTPDATA_STATE_FINISHED);
 
         sbcfg.buf_size = 4096;
         sbcfg.Malloc = FTPMalloc;
index 469fd2f1a799c63bca9735a8c76ad80e42a345e6..1f91a7d9a6e7a4dc3fb0323023c7c9ad7cf57783 100644 (file)
@@ -211,7 +211,6 @@ SCEnumCharMap http_decoder_event_table[ ] = {
 static void *HTPStateGetTx(void *alstate, uint64_t tx_id);
 static int HTPStateGetAlstateProgress(void *tx, uint8_t direction);
 static uint64_t HTPStateGetTxCnt(void *alstate);
-static int HTPStateGetAlstateProgressCompletionStatus(uint8_t direction);
 #ifdef UNITTESTS
 static void HTPParserRegisterTests(void);
 #endif
@@ -2980,11 +2979,6 @@ void *HtpGetTxForH2(void *alstate)
     return NULL;
 }
 
-static int HTPStateGetAlstateProgressCompletionStatus(uint8_t direction)
-{
-    return (direction & STREAM_TOSERVER) ? HTP_REQUEST_COMPLETE : HTP_RESPONSE_COMPLETE;
-}
-
 static int HTPStateGetEventInfo(const char *event_name,
                          int *event_id, AppLayerEventType *event_type)
 {
@@ -3129,8 +3123,9 @@ void RegisterHTPParsers(void)
         AppLayerParserRegisterGetStateProgressFunc(IPPROTO_TCP, ALPROTO_HTTP, HTPStateGetAlstateProgress);
         AppLayerParserRegisterGetTxCnt(IPPROTO_TCP, ALPROTO_HTTP, HTPStateGetTxCnt);
         AppLayerParserRegisterGetTx(IPPROTO_TCP, ALPROTO_HTTP, HTPStateGetTx);
-        AppLayerParserRegisterGetStateProgressCompletionStatus(ALPROTO_HTTP,
-                                                               HTPStateGetAlstateProgressCompletionStatus);
+
+        AppLayerParserRegisterStateProgressCompletionStatus(
+                ALPROTO_HTTP, HTP_REQUEST_COMPLETE, HTP_RESPONSE_COMPLETE);
         AppLayerParserRegisterGetEventsFunc(IPPROTO_TCP, ALPROTO_HTTP, HTPGetEvents);
         AppLayerParserRegisterGetEventInfo(IPPROTO_TCP, ALPROTO_HTTP, HTPStateGetEventInfo);
         AppLayerParserRegisterGetEventInfoById(IPPROTO_TCP, ALPROTO_HTTP, HTPStateGetEventInfoById);
index 97cfa7e3365817fc9ad2e0e735dbac022f0cc709..7945ce9cde0b1f891d826d1fbdc3529d0cd0b398 100644 (file)
@@ -235,13 +235,6 @@ static int ModbusGetAlstateProgress(void *modbus_tx, uint8_t direction)
     return 0;
 }
 
-/** \brief Get value for 'complete' status in Modbus
- */
-static int ModbusGetAlstateProgressCompletionStatus(uint8_t direction)
-{
-    return 1;
-}
-
 static void *ModbusGetTx(void *alstate, uint64_t tx_id)
 {
     ModbusState         *modbus = (ModbusState *) alstate;
@@ -1529,8 +1522,7 @@ void RegisterModbusParsers(void)
         AppLayerParserRegisterTxFreeFunc(IPPROTO_TCP, ALPROTO_MODBUS, ModbusStateTxFree);
 
         AppLayerParserRegisterGetStateProgressFunc(IPPROTO_TCP, ALPROTO_MODBUS, ModbusGetAlstateProgress);
-        AppLayerParserRegisterGetStateProgressCompletionStatus(ALPROTO_MODBUS,
-                                                                ModbusGetAlstateProgressCompletionStatus);
+        AppLayerParserRegisterStateProgressCompletionStatus(ALPROTO_MODBUS, 1, 1);
 
         AppLayerParserRegisterGetEventInfo(IPPROTO_TCP, ALPROTO_MODBUS, ModbusStateGetEventInfo);
         AppLayerParserRegisterGetEventInfoById(IPPROTO_TCP, ALPROTO_MODBUS, ModbusStateGetEventInfoById);
index 92ed47e937d07ea8a41cd820d1e94ef4fa7961b0..e8063249767bd2e3679df123cc1c90872759a84f 100644 (file)
@@ -208,15 +208,6 @@ static AppLayerGetTxIterTuple RustNFSTCPGetTxIterator(
     return rs_nfs_state_get_tx_iterator(alstate, min_tx_id, (uint64_t *)istate);
 }
 
-/**
- * \brief Called by the application layer.
- *
- * In most cases 1 can be returned here.
- */
-static int NFSTCPGetAlstateProgressCompletionStatus(uint8_t direction) {
-    return rs_nfs_state_progress_completion_status(direction);
-}
-
 /**
  * \brief Return the state of a transaction in a given direction.
  *
@@ -338,8 +329,7 @@ void RegisterNFSTCPParsers(void)
             NFSTCPGetTxCnt);
 
         /* Transaction handling. */
-        AppLayerParserRegisterGetStateProgressCompletionStatus(ALPROTO_NFS,
-            NFSTCPGetAlstateProgressCompletionStatus);
+        AppLayerParserRegisterStateProgressCompletionStatus(ALPROTO_NFS, 1, 1);
         AppLayerParserRegisterGetStateProgressFunc(IPPROTO_TCP,
             ALPROTO_NFS, NFSTCPGetStateProgress);
         AppLayerParserRegisterGetTx(IPPROTO_TCP, ALPROTO_NFS,
index 7b44487d82838b1e161f97451731cd9fd494291b..209de497b320e1d3817eaac37eef3fad2eaeb441 100644 (file)
@@ -178,15 +178,6 @@ static AppLayerGetTxIterTuple RustNFSGetTxIterator(
     return rs_nfs_state_get_tx_iterator(alstate, min_tx_id, (uint64_t *)istate);
 }
 
-/**
- * \brief Called by the application layer.
- *
- * In most cases 1 can be returned here.
- */
-static int NFSGetAlstateProgressCompletionStatus(uint8_t direction) {
-    return rs_nfs_state_progress_completion_status(direction);
-}
-
 /**
  * \brief Return the state of a transaction in a given direction.
  *
@@ -302,8 +293,7 @@ void RegisterNFSUDPParsers(void)
             NFSGetTxCnt);
 
         /* Transaction handling. */
-        AppLayerParserRegisterGetStateProgressCompletionStatus(ALPROTO_NFS,
-            NFSGetAlstateProgressCompletionStatus);
+        AppLayerParserRegisterStateProgressCompletionStatus(ALPROTO_NFS, 1, 1);
         AppLayerParserRegisterGetStateProgressFunc(IPPROTO_UDP,
             ALPROTO_NFS, NFSGetStateProgress);
         AppLayerParserRegisterGetTx(IPPROTO_UDP, ALPROTO_NFS,
index f18762f72deee4c2b9dd95fd59e386d6244d328e..46385e3bd772824b5a80eedf2b74c5a0244f7883 100644 (file)
@@ -113,7 +113,8 @@ typedef struct AppLayerParserProtoCtx_
     uint64_t (*StateGetTxCnt)(void *alstate);
     void *(*StateGetTx)(void *alstate, uint64_t tx_id);
     AppLayerGetTxIteratorFunc StateGetTxIterator;
-    int (*StateGetProgressCompletionStatus)(uint8_t direction);
+    int complete_ts;
+    int complete_tc;
     int (*StateGetEventInfoById)(int event_id, const char **event_name,
                                  AppLayerEventType *event_type);
     int (*StateGetEventInfo)(const char *event_name,
@@ -524,15 +525,19 @@ void AppLayerParserRegisterGetTxIterator(uint8_t ipproto, AppProto alproto,
     SCReturn;
 }
 
-void AppLayerParserRegisterGetStateProgressCompletionStatus(AppProto alproto,
-    int (*StateGetProgressCompletionStatus)(uint8_t direction))
+void AppLayerParserRegisterStateProgressCompletionStatus(
+        AppProto alproto, const int ts, const int tc)
 {
-    SCEnter();
-
-    alp_ctx.ctxs[FLOW_PROTO_DEFAULT][alproto].
-        StateGetProgressCompletionStatus = StateGetProgressCompletionStatus;
+    BUG_ON(ts == 0);
+    BUG_ON(tc == 0);
+    BUG_ON(!AppProtoIsValid(alproto));
+    BUG_ON(alp_ctx.ctxs[FLOW_PROTO_DEFAULT][alproto].complete_ts != 0 &&
+            alp_ctx.ctxs[FLOW_PROTO_DEFAULT][alproto].complete_ts != ts);
+    BUG_ON(alp_ctx.ctxs[FLOW_PROTO_DEFAULT][alproto].complete_tc != 0 &&
+            alp_ctx.ctxs[FLOW_PROTO_DEFAULT][alproto].complete_tc != tc);
 
-    SCReturn;
+    alp_ctx.ctxs[FLOW_PROTO_DEFAULT][alproto].complete_ts = ts;
+    alp_ctx.ctxs[FLOW_PROTO_DEFAULT][alproto].complete_tc = tc;
 }
 
 void AppLayerParserRegisterGetEventInfoById(uint8_t ipproto, AppProto alproto,
@@ -1025,6 +1030,18 @@ next:
     SCReturn;
 }
 
+static inline int StateGetProgressCompletionStatus(const AppProto alproto, const uint8_t flags)
+{
+    if (flags & STREAM_TOSERVER) {
+        return alp_ctx.ctxs[FLOW_PROTO_DEFAULT][alproto].complete_ts;
+    } else if (flags & STREAM_TOCLIENT) {
+        return alp_ctx.ctxs[FLOW_PROTO_DEFAULT][alproto].complete_tc;
+    } else {
+        DEBUG_VALIDATE_BUG_ON(1);
+        return 0;
+    }
+}
+
 /**
  *  \brief get the progress value for a tx/protocol
  *
@@ -1036,8 +1053,7 @@ int AppLayerParserGetStateProgress(uint8_t ipproto, AppProto alproto,
     SCEnter();
     int r = 0;
     if (unlikely(IS_DISRUPTED(flags))) {
-        r = alp_ctx.ctxs[FLOW_PROTO_DEFAULT][alproto].
-            StateGetProgressCompletionStatus(flags);
+        r = StateGetProgressCompletionStatus(alproto, flags);
     } else {
         r = alp_ctx.ctxs[FlowGetProtoMapping(ipproto)][alproto].
             StateGetProgress(alstate, flags);
@@ -1067,8 +1083,7 @@ int AppLayerParserGetStateProgressCompletionStatus(AppProto alproto,
                                                    uint8_t direction)
 {
     SCEnter();
-    int r = alp_ctx.ctxs[FLOW_PROTO_DEFAULT][alproto].
-                StateGetProgressCompletionStatus(direction);
+    int r = StateGetProgressCompletionStatus(alproto, direction);
     SCReturnInt(r);
 }
 
@@ -1403,8 +1418,12 @@ bool AppLayerParserHasDecoderEvents(AppLayerParserState *pstate)
  */
 int AppLayerParserIsEnabled(AppProto alproto)
 {
-    return (alp_ctx.ctxs[FLOW_PROTO_DEFAULT][alproto]
-            .StateGetProgressCompletionStatus != NULL);
+    for (int i = 0; i < FLOW_PROTO_APPLAYER_MAX; i++) {
+        if (alp_ctx.ctxs[i][alproto].StateGetProgress != NULL) {
+            return 1;
+        }
+    }
+    return 0;
 }
 
 int AppLayerParserProtocolIsTxEventAware(uint8_t ipproto, AppProto alproto)
@@ -1500,7 +1519,6 @@ static void ValidateParserProtoDump(AppProto alproto, uint8_t ipproto)
 {
     uint8_t map = FlowGetProtoMapping(ipproto);
     const AppLayerParserProtoCtx *ctx = &alp_ctx.ctxs[map][alproto];
-    const AppLayerParserProtoCtx *ctx_def = &alp_ctx.ctxs[FLOW_PROTO_DEFAULT][alproto];
     printf("ERROR: incomplete app-layer registration\n");
     printf("AppLayer protocol %s ipproto %u\n", AppProtoToString(alproto), ipproto);
     printf("- option flags %"PRIx32"\n", ctx->option_flags);
@@ -1511,7 +1529,7 @@ static void ValidateParserProtoDump(AppProto alproto, uint8_t ipproto)
     printf("- StateGetTx %p StateGetTxCnt %p StateTransactionFree %p\n",
             ctx->StateGetTx, ctx->StateGetTxCnt, ctx->StateTransactionFree);
     printf("- GetTxData %p\n", ctx->GetTxData);
-    printf("- StateGetProgress %p StateGetProgressCompletionStatus %p\n", ctx->StateGetProgress, ctx_def->StateGetProgressCompletionStatus);
+    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);
@@ -1528,7 +1546,6 @@ static void ValidateParserProto(AppProto alproto, uint8_t ipproto)
 {
     uint8_t map = FlowGetProtoMapping(ipproto);
     const AppLayerParserProtoCtx *ctx = &alp_ctx.ctxs[map][alproto];
-    const AppLayerParserProtoCtx *ctx_def = &alp_ctx.ctxs[FLOW_PROTO_DEFAULT][alproto];
 
     if (ctx->Parser[0] == NULL && ctx->Parser[1] == NULL)
         return;
@@ -1542,8 +1559,7 @@ static void ValidateParserProto(AppProto alproto, uint8_t ipproto)
     if (!(THREE_SET(ctx->StateGetTx, ctx->StateGetTxCnt, ctx->StateTransactionFree))) {
         goto bad;
     }
-    /* special case: StateGetProgressCompletionStatus is used from 'default'. */
-    if (!(BOTH_SET(ctx->StateGetProgress, ctx_def->StateGetProgressCompletionStatus))) {
+    if (ctx->StateGetProgress == NULL) {
         goto bad;
     }
     /* local storage is optional, but needs both set if used */
index 86c3a3696feed77d70e2e38ba4a98f9655186e46..18258acb3c9655223a3b3ae6fd4743169fb11b67 100644 (file)
@@ -170,8 +170,8 @@ void AppLayerParserRegisterGetTx(uint8_t ipproto, AppProto alproto,
                       void *(StateGetTx)(void *alstate, uint64_t tx_id));
 void AppLayerParserRegisterGetTxIterator(uint8_t ipproto, AppProto alproto,
                       AppLayerGetTxIteratorFunc Func);
-void AppLayerParserRegisterGetStateProgressCompletionStatus(AppProto alproto,
-    int (*StateGetStateProgressCompletionStatus)(uint8_t direction));
+void AppLayerParserRegisterStateProgressCompletionStatus(
+        AppProto alproto, const int ts, const int tc);
 void AppLayerParserRegisterGetEventInfo(uint8_t ipproto, AppProto alproto,
     int (*StateGetEventInfo)(const char *event_name, int *event_id,
                              AppLayerEventType *event_type));
index 234246b527e711791d734f5a06b2c270c3f737b1..5cef99e7d2102da3ea87eb5d4e0a4b5b1a8f5eae 100644 (file)
@@ -129,8 +129,8 @@ int AppLayerRegisterParser(const struct AppLayerParser *p, AppProto alproto)
         p->StateGetTxCnt);
 
     /* Transaction handling. */
-    AppLayerParserRegisterGetStateProgressCompletionStatus(alproto,
-        p->StateGetProgressCompletionStatus);
+    AppLayerParserRegisterStateProgressCompletionStatus(alproto, p->complete_ts, p->complete_tc);
+
     AppLayerParserRegisterGetStateProgressFunc(p->ip_proto, alproto,
         p->StateGetProgress);
     AppLayerParserRegisterGetTx(p->ip_proto, alproto,
index 47da98dadef082d07e030084fd02352d597c7c6c..6f317cca6562a027122fa5a328437ec50dbff0b4 100644 (file)
@@ -45,7 +45,8 @@ typedef struct AppLayerParser {
     void *(*StateGetTx)(void *alstate, uint64_t tx_id);
     void (*StateTransactionFree)(void *, uint64_t);
 
-    int (*StateGetProgressCompletionStatus)(uint8_t direction);
+    const int complete_ts;
+    const int complete_tc;
     int (*StateGetProgress)(void *alstate, uint8_t direction);
 
     DetectEngineState *(*GetTxDetectState)(void *tx);
index 6d26533297b1e4cb455d742d916c6734c3675837..b383534156b166e749d01e3fae05d5f1d61be929 100644 (file)
@@ -292,8 +292,7 @@ void RegisterSMBParsers(void)
                 SMBGetTxCnt);
         AppLayerParserRegisterGetStateProgressFunc(IPPROTO_TCP, ALPROTO_SMB,
                 SMBGetAlstateProgress);
-        AppLayerParserRegisterGetStateProgressCompletionStatus(ALPROTO_SMB,
-                rs_smb_state_progress_completion_status);
+        AppLayerParserRegisterStateProgressCompletionStatus(ALPROTO_SMB, 1, 1);
         AppLayerParserRegisterTruncateFunc(IPPROTO_TCP, ALPROTO_SMB,
                                           SMBStateTruncate);
         AppLayerParserRegisterGetFilesFunc(IPPROTO_TCP, ALPROTO_SMB, SMBGetFiles);
index 68defb13dd811a9fce056d496e4ccc01308066ce..b9bc9deba6f489c4a59fb16c41be18e8823d5dac 100644 (file)
@@ -1715,10 +1715,6 @@ static void *SMTPStateGetTx(void *state, uint64_t id)
 
 }
 
-static int SMTPStateGetAlstateProgressCompletionStatus(uint8_t direction) {
-    return 1;
-}
-
 static int SMTPStateGetAlstateProgress(void *vtx, uint8_t direction)
 {
     SMTPTransaction *tx = vtx;
@@ -1816,8 +1812,7 @@ void RegisterSMTPParsers(void)
         AppLayerParserRegisterGetTxCnt(IPPROTO_TCP, ALPROTO_SMTP, SMTPStateGetTxCnt);
         AppLayerParserRegisterGetTx(IPPROTO_TCP, ALPROTO_SMTP, SMTPStateGetTx);
         AppLayerParserRegisterTxDataFunc(IPPROTO_TCP, ALPROTO_SMTP, SMTPGetTxData);
-        AppLayerParserRegisterGetStateProgressCompletionStatus(ALPROTO_SMTP,
-                                                               SMTPStateGetAlstateProgressCompletionStatus);
+        AppLayerParserRegisterStateProgressCompletionStatus(ALPROTO_SMTP, 1, 1);
         AppLayerParserRegisterTruncateFunc(IPPROTO_TCP, ALPROTO_SMTP, SMTPStateTruncate);
     } else {
         SCLogInfo("Parsed disabled for %s protocol. Protocol detection"
index ba921db089694bca1f6e110f5c6e17b4852e3c6e..99701b4d669f82f5e5149636e9cebb87fbfae319 100644 (file)
@@ -276,11 +276,6 @@ static uint64_t SSLGetTxCnt(void *state)
     return 1;
 }
 
-static int SSLGetAlstateProgressCompletionStatus(uint8_t direction)
-{
-    return TLS_STATE_FINISHED;
-}
-
 static int SSLGetAlstateProgress(void *tx, uint8_t direction)
 {
     SSLState *ssl_state = (SSLState *)tx;
@@ -2983,8 +2978,8 @@ void RegisterSSLParsers(void)
 
         AppLayerParserRegisterGetStateProgressFunc(IPPROTO_TCP, ALPROTO_TLS, SSLGetAlstateProgress);
 
-        AppLayerParserRegisterGetStateProgressCompletionStatus(ALPROTO_TLS,
-                                                               SSLGetAlstateProgressCompletionStatus);
+        AppLayerParserRegisterStateProgressCompletionStatus(
+                ALPROTO_TLS, TLS_STATE_FINISHED, TLS_STATE_FINISHED);
 
         ConfNode *enc_handle = ConfGetNode("app-layer.protocols.tls.encryption-handling");
         if (enc_handle != NULL && enc_handle->val != NULL) {
index d01968cad6e7211326de9410caac989c945fd2a2..5604654d335cdb5a29cdcc63a4bc1756c37d9b93 100644 (file)
@@ -406,15 +406,6 @@ static void *TemplateGetTx(void *statev, uint64_t tx_id)
     return NULL;
 }
 
-/**
- * \brief Called by the application layer.
- *
- * In most cases 1 can be returned here.
- */
-static int TemplateGetAlstateProgressCompletionStatus(uint8_t direction) {
-    return 1;
-}
-
 /**
  * \brief Return the state of a transaction in a given direction.
  *
@@ -551,8 +542,7 @@ void RegisterTemplateParsers(void)
             TemplateGetTxCnt);
 
         /* Transaction handling. */
-        AppLayerParserRegisterGetStateProgressCompletionStatus(ALPROTO_TEMPLATE,
-            TemplateGetAlstateProgressCompletionStatus);
+        AppLayerParserRegisterStateProgressCompletionStatus(ALPROTO_TEMPLATE, 1, 1);
         AppLayerParserRegisterGetStateProgressFunc(IPPROTO_TCP,
             ALPROTO_TEMPLATE, TemplateGetStateProgress);
         AppLayerParserRegisterGetTx(IPPROTO_TCP, ALPROTO_TEMPLATE,
index f41a059a36a02f1e9e02cb800718dffd922d8da2..e2df52a96678daac3cb3724643d5a5780d798f0a 100644 (file)
@@ -141,15 +141,6 @@ static void *TFTPGetTx(void *state, uint64_t tx_id)
     return rs_tftp_get_tx(state, tx_id);
 }
 
-/**
- * \brief Called by the application layer.
- *
- * In most cases 1 can be returned here.
- */
-static int TFTPGetAlstateProgressCompletionStatus(uint8_t direction) {
-    return 1;
-}
-
 /**
  * \brief Return the state of a transaction in a given direction.
  *
@@ -244,8 +235,7 @@ void RegisterTFTPParsers(void)
                                        TFTPGetTxCnt);
 
         /* Transaction handling. */
-        AppLayerParserRegisterGetStateProgressCompletionStatus(ALPROTO_TFTP,
-            TFTPGetAlstateProgressCompletionStatus);
+        AppLayerParserRegisterStateProgressCompletionStatus(ALPROTO_TFTP, 1, 1);
         AppLayerParserRegisterGetStateProgressFunc(IPPROTO_UDP,
                                                    ALPROTO_TFTP,
                                                    TFTPGetStateProgress);