From efc9a7a3989df42f09f9018b9aa01044b1a05441 Mon Sep 17 00:00:00 2001 From: Victor Julien Date: Fri, 30 Oct 2020 13:40:17 +0100 Subject: [PATCH] app-layer: remove callback for completion status 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. --- rust/src/applayer.rs | 6 +-- rust/src/applayertemplate/template.rs | 11 +----- rust/src/dcerpc/dcerpc.rs | 5 --- rust/src/dhcp/dhcp.rs | 10 +---- rust/src/dns/dns.rs | 15 ++------ rust/src/http2/http2.rs | 8 +--- rust/src/ikev2/ikev2.rs | 11 +----- rust/src/krb/krb5.rs | 11 +----- rust/src/mqtt/mqtt.rs | 8 +--- rust/src/nfs/nfs.rs | 8 ---- rust/src/ntp/ntp.rs | 11 +----- rust/src/rdp/rdp.rs | 9 +---- rust/src/rfb/rfb.rs | 11 +----- rust/src/sip/sip.rs | 8 +--- rust/src/smb/smb.rs | 8 ---- rust/src/snmp/snmp.rs | 11 +----- rust/src/ssh/ssh.rs | 8 +--- src/app-layer-dcerpc-udp.c | 8 +--- src/app-layer-dcerpc.c | 9 +---- src/app-layer-dnp3.c | 11 +----- src/app-layer-enip.c | 13 +------ src/app-layer-ftp.c | 19 ++-------- src/app-layer-htp.c | 11 ++---- src/app-layer-modbus.c | 10 +---- src/app-layer-nfs-tcp.c | 12 +----- src/app-layer-nfs-udp.c | 12 +----- src/app-layer-parser.c | 54 +++++++++++++++++---------- src/app-layer-parser.h | 4 +- src/app-layer-register.c | 4 +- src/app-layer-register.h | 3 +- src/app-layer-smb.c | 3 +- src/app-layer-smtp.c | 7 +--- src/app-layer-ssl.c | 9 +---- src/app-layer-template.c | 12 +----- src/app-layer-tftp.c | 12 +----- 35 files changed, 94 insertions(+), 278 deletions(-) diff --git a/rust/src/applayer.rs b/rust/src/applayer.rs index 8eacadcc00..476ea1cb36 100644 --- a/rust/src/applayer.rs +++ b/rust/src/applayer.rs @@ -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; diff --git a/rust/src/applayertemplate/template.rs b/rust/src/applayertemplate/template.rs index 25576b51c4..99d9343eb9 100644 --- a/rust/src/applayertemplate/template.rs +++ b/rust/src/applayertemplate/template.rs @@ -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, diff --git a/rust/src/dcerpc/dcerpc.rs b/rust/src/dcerpc/dcerpc.rs index 70786abe02..62a899df90 100644 --- a/rust/src/dcerpc/dcerpc.rs +++ b/rust/src/dcerpc/dcerpc.rs @@ -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) diff --git a/rust/src/dhcp/dhcp.rs b/rust/src/dhcp/dhcp.rs index 442ccecd71..e4ff939580 100644 --- a/rust/src/dhcp/dhcp.rs +++ b/rust/src/dhcp/dhcp.rs @@ -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, diff --git a/rust/src/dns/dns.rs b/rust/src/dns/dns.rs index 89f32e8e67..e876be23c8 100644 --- a/rust/src/dns/dns.rs +++ b/rust/src/dns/dns.rs @@ -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), diff --git a/rust/src/http2/http2.rs b/rust/src/http2/http2.rs index 252e3950d6..a0d97904d8 100644 --- a/rust/src/http2/http2.rs +++ b/rust/src/http2/http2.rs @@ -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, diff --git a/rust/src/ikev2/ikev2.rs b/rust/src/ikev2/ikev2.rs index 3e81be13fa..c3e3693303 100644 --- a/rust/src/ikev2/ikev2.rs +++ b/rust/src/ikev2/ikev2.rs @@ -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, diff --git a/rust/src/krb/krb5.rs b/rust/src/krb/krb5.rs index 5c5975ef6f..067213abdc 100644 --- a/rust/src/krb/krb5.rs +++ b/rust/src/krb/krb5.rs @@ -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, diff --git a/rust/src/mqtt/mqtt.rs b/rust/src/mqtt/mqtt.rs index 183bc4dd33..33702cf221 100644 --- a/rust/src/mqtt/mqtt.rs +++ b/rust/src/mqtt/mqtt.rs @@ -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, diff --git a/rust/src/nfs/nfs.rs b/rust/src/nfs/nfs.rs index 283370fe16..d33d548b43 100644 --- a/rust/src/nfs/nfs.rs +++ b/rust/src/nfs/nfs.rs @@ -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) diff --git a/rust/src/ntp/ntp.rs b/rust/src/ntp/ntp.rs index 913d5810db..02e9fdca9b 100644 --- a/rust/src/ntp/ntp.rs +++ b/rust/src/ntp/ntp.rs @@ -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, diff --git a/rust/src/rdp/rdp.rs b/rust/src/rdp/rdp.rs index fac136b6e3..b03a774772 100644 --- a/rust/src/rdp/rdp.rs +++ b/rust/src/rdp/rdp.rs @@ -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, diff --git a/rust/src/rfb/rfb.rs b/rust/src/rfb/rfb.rs index aa18ab5d40..3bbc330551 100644 --- a/rust/src/rfb/rfb.rs +++ b/rust/src/rfb/rfb.rs @@ -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, diff --git a/rust/src/sip/sip.rs b/rust/src/sip/sip.rs index 9cfaf52002..8874bdccef 100755 --- a/rust/src/sip/sip.rs +++ b/rust/src/sip/sip.rs @@ -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, diff --git a/rust/src/smb/smb.rs b/rust/src/smb/smb.rs index 70262391cc..3a516b841d 100644 --- a/rust/src/smb/smb.rs +++ b/rust/src/smb/smb.rs @@ -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) diff --git a/rust/src/snmp/snmp.rs b/rust/src/snmp/snmp.rs index a712d0f3af..20136838f2 100644 --- a/rust/src/snmp/snmp.rs +++ b/rust/src/snmp/snmp.rs @@ -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, diff --git a/rust/src/ssh/ssh.rs b/rust/src/ssh/ssh.rs index c58c4b47cd..5330853465 100644 --- a/rust/src/ssh/ssh.rs +++ b/rust/src/ssh/ssh.rs @@ -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, diff --git a/src/app-layer-dcerpc-udp.c b/src/app-layer-dcerpc-udp.c index d38378ae07..bc03e8b8c9 100644 --- a/src/app-layer-dcerpc-udp.c +++ b/src/app-layer-dcerpc-udp.c @@ -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"); diff --git a/src/app-layer-dcerpc.c b/src/app-layer-dcerpc.c index 40cd753bf0..334ab952ca 100644 --- a/src/app-layer-dcerpc.c +++ b/src/app-layer-dcerpc.c @@ -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); diff --git a/src/app-layer-dnp3.c b/src/app-layer-dnp3.c index 2507a226a8..7b5f2382b4 100644 --- a/src/app-layer-dnp3.c +++ b/src/app-layer-dnp3.c @@ -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); diff --git a/src/app-layer-enip.c b/src/app-layer-enip.c index 0bb841d67c..8243a994ab 100644 --- a/src/app-layer-enip.c +++ b/src/app-layer-enip.c @@ -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); diff --git a/src/app-layer-ftp.c b/src/app-layer-ftp.c index 6c56013408..a616024f5d 100644 --- a/src/app-layer-ftp.c +++ b/src/app-layer-ftp.c @@ -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; diff --git a/src/app-layer-htp.c b/src/app-layer-htp.c index 469fd2f1a7..1f91a7d9a6 100644 --- a/src/app-layer-htp.c +++ b/src/app-layer-htp.c @@ -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); diff --git a/src/app-layer-modbus.c b/src/app-layer-modbus.c index 97cfa7e336..7945ce9cde 100644 --- a/src/app-layer-modbus.c +++ b/src/app-layer-modbus.c @@ -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); diff --git a/src/app-layer-nfs-tcp.c b/src/app-layer-nfs-tcp.c index 92ed47e937..e806324976 100644 --- a/src/app-layer-nfs-tcp.c +++ b/src/app-layer-nfs-tcp.c @@ -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, diff --git a/src/app-layer-nfs-udp.c b/src/app-layer-nfs-udp.c index 7b44487d82..209de497b3 100644 --- a/src/app-layer-nfs-udp.c +++ b/src/app-layer-nfs-udp.c @@ -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, diff --git a/src/app-layer-parser.c b/src/app-layer-parser.c index f18762f72d..46385e3bd7 100644 --- a/src/app-layer-parser.c +++ b/src/app-layer-parser.c @@ -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 */ diff --git a/src/app-layer-parser.h b/src/app-layer-parser.h index 86c3a3696f..18258acb3c 100644 --- a/src/app-layer-parser.h +++ b/src/app-layer-parser.h @@ -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)); diff --git a/src/app-layer-register.c b/src/app-layer-register.c index 234246b527..5cef99e7d2 100644 --- a/src/app-layer-register.c +++ b/src/app-layer-register.c @@ -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, diff --git a/src/app-layer-register.h b/src/app-layer-register.h index 47da98dade..6f317cca65 100644 --- a/src/app-layer-register.h +++ b/src/app-layer-register.h @@ -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); diff --git a/src/app-layer-smb.c b/src/app-layer-smb.c index 6d26533297..b383534156 100644 --- a/src/app-layer-smb.c +++ b/src/app-layer-smb.c @@ -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); diff --git a/src/app-layer-smtp.c b/src/app-layer-smtp.c index 68defb13dd..b9bc9deba6 100644 --- a/src/app-layer-smtp.c +++ b/src/app-layer-smtp.c @@ -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" diff --git a/src/app-layer-ssl.c b/src/app-layer-ssl.c index ba921db089..99701b4d66 100644 --- a/src/app-layer-ssl.c +++ b/src/app-layer-ssl.c @@ -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) { diff --git a/src/app-layer-template.c b/src/app-layer-template.c index d01968cad6..5604654d33 100644 --- a/src/app-layer-template.c +++ b/src/app-layer-template.c @@ -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, diff --git a/src/app-layer-tftp.c b/src/app-layer-tftp.c index f41a059a36..e2df52a966 100644 --- a/src/app-layer-tftp.c +++ b/src/app-layer-tftp.c @@ -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);