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.
pull/5636/head
Victor Julien 4 years ago
parent 84385549fe
commit efc9a7a398

@ -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;

@ -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,

@ -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)

@ -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,

@ -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),

@ -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,

@ -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,

@ -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,

@ -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,

@ -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)

@ -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,

@ -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,

@ -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,

@ -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,

@ -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)

@ -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,

@ -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,

@ -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");

@ -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);

@ -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);

@ -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);

@ -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;

@ -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);

@ -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);

@ -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,

@ -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,

@ -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 */

@ -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));

@ -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,

@ -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);

@ -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);

@ -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"

@ -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) {

@ -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,

@ -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);

Loading…
Cancel
Save