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,
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;
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,
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,
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)
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 {
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,
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)
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),
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),
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);
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,
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)
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,
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)
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,
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);
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,
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)
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)
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,
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,
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,
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,
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,
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,
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,
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)
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)
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,
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,
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,
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);
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");
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);
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);
SCReturnInt(retval);
}
-/**
- * \brief App-layer support.
- */
-static int DNP3GetAlstateProgressCompletionStatus(uint8_t direction)
-{
- return 1;
-}
-
/**
* \brief App-layer support.
*/
AppLayerParserRegisterGetStateProgressFunc(IPPROTO_TCP, ALPROTO_DNP3,
DNP3GetAlstateProgress);
- AppLayerParserRegisterGetStateProgressCompletionStatus(ALPROTO_DNP3,
- DNP3GetAlstateProgressCompletionStatus);
+ AppLayerParserRegisterStateProgressCompletionStatus(ALPROTO_DNP3, 1, 1);
AppLayerParserRegisterGetEventInfo(IPPROTO_TCP, ALPROTO_DNP3,
DNP3StateGetEventInfo);
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;
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);
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);
return cnt;
}
-static int FTPGetAlstateProgressCompletionStatus(uint8_t direction)
-{
- return FTP_STATE_FINISHED;
-}
-
static int FTPGetAlstateProgress(void *vtx, uint8_t direction)
{
SCLogDebug("tx %p", vtx);
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;
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,
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;
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
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)
{
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);
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;
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);
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.
*
NFSTCPGetTxCnt);
/* Transaction handling. */
- AppLayerParserRegisterGetStateProgressCompletionStatus(ALPROTO_NFS,
- NFSTCPGetAlstateProgressCompletionStatus);
+ AppLayerParserRegisterStateProgressCompletionStatus(ALPROTO_NFS, 1, 1);
AppLayerParserRegisterGetStateProgressFunc(IPPROTO_TCP,
ALPROTO_NFS, NFSTCPGetStateProgress);
AppLayerParserRegisterGetTx(IPPROTO_TCP, ALPROTO_NFS,
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.
*
NFSGetTxCnt);
/* Transaction handling. */
- AppLayerParserRegisterGetStateProgressCompletionStatus(ALPROTO_NFS,
- NFSGetAlstateProgressCompletionStatus);
+ AppLayerParserRegisterStateProgressCompletionStatus(ALPROTO_NFS, 1, 1);
AppLayerParserRegisterGetStateProgressFunc(IPPROTO_UDP,
ALPROTO_NFS, NFSGetStateProgress);
AppLayerParserRegisterGetTx(IPPROTO_UDP, ALPROTO_NFS,
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,
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,
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
*
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);
uint8_t direction)
{
SCEnter();
- int r = alp_ctx.ctxs[FLOW_PROTO_DEFAULT][alproto].
- StateGetProgressCompletionStatus(direction);
+ int r = StateGetProgressCompletionStatus(alproto, direction);
SCReturnInt(r);
}
*/
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)
{
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);
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);
{
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;
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 */
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));
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,
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);
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);
}
-static int SMTPStateGetAlstateProgressCompletionStatus(uint8_t direction) {
- return 1;
-}
-
static int SMTPStateGetAlstateProgress(void *vtx, uint8_t direction)
{
SMTPTransaction *tx = vtx;
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"
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;
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) {
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.
*
TemplateGetTxCnt);
/* Transaction handling. */
- AppLayerParserRegisterGetStateProgressCompletionStatus(ALPROTO_TEMPLATE,
- TemplateGetAlstateProgressCompletionStatus);
+ AppLayerParserRegisterStateProgressCompletionStatus(ALPROTO_TEMPLATE, 1, 1);
AppLayerParserRegisterGetStateProgressFunc(IPPROTO_TCP,
ALPROTO_TEMPLATE, TemplateGetStateProgress);
AppLayerParserRegisterGetTx(IPPROTO_TCP, ALPROTO_TEMPLATE,
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.
*
TFTPGetTxCnt);
/* Transaction handling. */
- AppLayerParserRegisterGetStateProgressCompletionStatus(ALPROTO_TFTP,
- TFTPGetAlstateProgressCompletionStatus);
+ AppLayerParserRegisterStateProgressCompletionStatus(ALPROTO_TFTP, 1, 1);
AppLayerParserRegisterGetStateProgressFunc(IPPROTO_UDP,
ALPROTO_TFTP,
TFTPGetStateProgress);