// Transactions.
pub transactions: Vec<DNSTransaction>,
- pub de_state_count: u64,
-
pub events: u16,
pub request_buffer: Vec<u8>,
return DNSState{
tx_id: 0,
transactions: Vec::new(),
- de_state_count: 0,
events: 0,
request_buffer: Vec::new(),
response_buffer: Vec::new(),
return DNSState{
tx_id: 0,
transactions: Vec::new(),
- de_state_count: 0,
events: 0,
request_buffer: Vec::with_capacity(0xffff),
response_buffer: Vec::with_capacity(0xffff),
match tx.de_state {
Some(state) => {
core::sc_detect_engine_state_free(state);
- self.de_state_count -= 1;
}
_ => {}
}
}
}
-#[no_mangle]
-pub extern "C" fn rs_dns_state_has_detect_state(state: &mut DNSState) -> u8
-{
- if state.de_state_count > 0 {
- return 1;
- }
- return 0;
-}
-
#[no_mangle]
pub extern "C" fn rs_dns_state_set_tx_detect_state(
- state: &mut DNSState,
tx: &mut DNSTransaction,
de_state: &mut core::DetectEngineState)
{
- state.de_state_count += 1;
tx.de_state = Some(de_state);
}
}
}
+impl Drop for NFSTransaction {
+ fn drop(&mut self) {
+ match self.de_state {
+ Some(state) => {
+ sc_detect_engine_state_free(state);
+ }
+ _ => {}
+ }
+ self.free();
+ }
+}
+
#[derive(Debug)]
pub struct NFSRequestXidMap {
progver: u32,
/// tx counter for assigning incrementing id's to tx's
tx_id: u64,
-
- pub de_state_count: u64,
}
impl NFSState {
nfs_version:0,
events:0,
tx_id:0,
- de_state_count:0,
}
}
pub fn free(&mut self) {
}
if found {
SCLogDebug!("freeing TX with ID {} at index {}", tx_id, index);
- self.free_tx_at_index(index);
- }
- }
-
- fn free_tx_at_index(&mut self, index: usize) {
- let tx = self.transactions.remove(index);
- match tx.de_state {
- Some(state) => {
- sc_detect_engine_state_free(state);
- self.de_state_count -= 1;
- }
- _ => {}
+ self.transactions.remove(index);
}
}
return tx.logged.get();
}
-#[no_mangle]
-pub extern "C" fn rs_nfs3_state_has_detect_state(state: &mut NFSState) -> u8
-{
- if state.de_state_count > 0 {
- return 1;
- }
- return 0;
-}
-
#[no_mangle]
pub extern "C" fn rs_nfs3_state_set_tx_detect_state(
- state: &mut NFSState,
tx: &mut NFSTransaction,
de_state: &mut DetectEngineState)
{
- state.de_state_count += 1;
tx.de_state = Some(de_state);
}
{
match tx.de_state {
Some(ds) => {
+ SCLogDebug!("{}: getting de_state", tx.id);
return ds;
},
None => {
+ SCLogDebug!("{}: getting de_state: have none", tx.id);
return std::ptr::null_mut();
}
}
SCFree(s);
}
-static int DCERPCUDPStateHasTxDetectState(void *state)
+static int DCERPCUDPSetTxDetectState(void *vtx, DetectEngineState *de_state)
{
- DCERPCUDPState *dce_state = (DCERPCUDPState *)state;
- if (dce_state->de_state)
- return 1;
- return 0;
-}
-
-static int DCERPCUDPSetTxDetectState(void *state, void *vtx, DetectEngineState *de_state)
-{
- DCERPCUDPState *dce_state = (DCERPCUDPState *)state;
+ DCERPCUDPState *dce_state = (DCERPCUDPState *)vtx;
dce_state->de_state = de_state;
return 0;
}
AppLayerParserRegisterTxFreeFunc(IPPROTO_UDP, ALPROTO_DCERPC, DCERPCUDPStateTransactionFree);
- AppLayerParserRegisterDetectStateFuncs(IPPROTO_UDP, ALPROTO_DCERPC, DCERPCUDPStateHasTxDetectState,
+ AppLayerParserRegisterDetectStateFuncs(IPPROTO_UDP, ALPROTO_DCERPC,
DCERPCUDPGetTxDetectState, DCERPCUDPSetTxDetectState);
AppLayerParserRegisterGetTx(IPPROTO_UDP, ALPROTO_DCERPC, DCERPCUDPGetTx);
SCFree(s);
}
-static int DCERPCStateHasTxDetectState(void *state)
+static int DCERPCSetTxDetectState(void *vtx, DetectEngineState *de_state)
{
- DCERPCState *dce_state = (DCERPCState *)state;
- if (dce_state->de_state)
- return 1;
- return 0;
-}
-
-static int DCERPCSetTxDetectState(void *state, void *vtx, DetectEngineState *de_state)
-{
- DCERPCState *dce_state = (DCERPCState *)state;
+ DCERPCState *dce_state = (DCERPCState *)vtx;
dce_state->de_state = de_state;
return 0;
}
AppLayerParserRegisterTxFreeFunc(IPPROTO_TCP, ALPROTO_DCERPC, DCERPCStateTransactionFree);
- AppLayerParserRegisterDetectStateFuncs(IPPROTO_TCP, ALPROTO_DCERPC, DCERPCStateHasTxDetectState,
+ AppLayerParserRegisterDetectStateFuncs(IPPROTO_TCP, ALPROTO_DCERPC,
DCERPCGetTxDetectState, DCERPCSetTxDetectState);
AppLayerParserRegisterGetTx(IPPROTO_TCP, ALPROTO_DCERPC, DCERPCGetTx);
/**
* \brief App-layer support.
*/
-static int DNP3SetTxDetectState(void *state, void *vtx, DetectEngineState *s)
+static int DNP3SetTxDetectState(void *vtx, DetectEngineState *s)
{
DNP3Transaction *tx = vtx;
tx->de_state = s;
DNP3GetEvents);
AppLayerParserRegisterHasEventsFunc(IPPROTO_TCP, ALPROTO_DNP3,
DNP3HasEvents);
- AppLayerParserRegisterDetectStateFuncs(IPPROTO_TCP, ALPROTO_DNP3, NULL,
+ AppLayerParserRegisterDetectStateFuncs(IPPROTO_TCP, ALPROTO_DNP3,
DNP3GetTxDetectState, DNP3SetTxDetectState);
AppLayerParserRegisterGetTx(IPPROTO_TCP, ALPROTO_DNP3, DNP3GetTx);
if (tx->de_state != NULL) {
DetectEngineStateFree(tx->de_state);
- BUG_ON(state->tx_with_detect_state_cnt == 0);
- state->tx_with_detect_state_cnt--;
}
if (state->iter == tx)
return NULL;
}
-int DNSStateHasTxDetectState(void *alstate)
-{
- DNSState *state = (DNSState *)alstate;
- return (state->tx_with_detect_state_cnt > 0);
-}
-
DetectEngineState *DNSGetTxDetectState(void *vtx)
{
DNSTransaction *tx = (DNSTransaction *)vtx;
return tx->de_state;
}
-int DNSSetTxDetectState(void *alstate, void *vtx, DetectEngineState *s)
+int DNSSetTxDetectState(void *vtx, DetectEngineState *s)
{
- DNSState *state = (DNSState *)alstate;
DNSTransaction *tx = (DNSTransaction *)vtx;
- state->tx_with_detect_state_cnt++;
tx->de_state = s;
return 0;
}
SCFree(dns_state->buffer);
}
- BUG_ON(dns_state->tx_with_detect_state_cnt > 0);
-
DNSDecrMemcap(sizeof(DNSState), dns_state);
BUG_ON(dns_state->memuse > 0);
SCFree(s);
uint32_t unreplied_cnt; /**< number of unreplied requests in a row */
uint32_t memuse; /**< state memuse, for comparing with
state-memcap settings */
- uint64_t tx_with_detect_state_cnt;
-
struct timeval last_req; /**< Timestamp of last request. */
struct timeval last_resp; /**< Timestamp of last response. */
void DNSStateTransactionFree(void *state, uint64_t tx_id);
DNSTransaction *DNSTransactionFindByTxId(const DNSState *dns_state, const uint16_t tx_id);
-int DNSStateHasTxDetectState(void *alstate);
DetectEngineState *DNSGetTxDetectState(void *vtx);
-int DNSSetTxDetectState(void *alstate, void *vtx, DetectEngineState *s);
+int DNSSetTxDetectState(void *vtx, DetectEngineState *s);
uint64_t DNSGetTxDetectFlags(void *vtx, uint8_t dir);
void DNSSetTxDetectFlags(void *vtx, uint8_t dir, uint64_t detect_flags);
rs_dns_state_tx_free(state, tx_id);
}
-static int RustDNSStateHasTxDetectState(void *state)
-{
- return rs_dns_state_has_detect_state(state);
-}
-
static DetectEngineState *RustDNSGetTxDetectState(void *tx)
{
return rs_dns_state_get_tx_detect_state(tx);
}
-static int RustDNSSetTxDetectState(void *state, void *tx,
+static int RustDNSSetTxDetectState(void *tx,
DetectEngineState *s)
{
- rs_dns_state_set_tx_detect_state(state, tx, s);
+ rs_dns_state_set_tx_detect_state(tx, s);
return 0;
}
AppLayerParserRegisterHasEventsFunc(IPPROTO_TCP, ALPROTO_DNS,
RustDNSHasEvents);
AppLayerParserRegisterDetectStateFuncs(IPPROTO_TCP, ALPROTO_DNS,
- RustDNSStateHasTxDetectState, RustDNSGetTxDetectState,
- RustDNSSetTxDetectState);
+ RustDNSGetTxDetectState, RustDNSSetTxDetectState);
AppLayerParserRegisterGetTx(IPPROTO_TCP, ALPROTO_DNS, RustDNSGetTx);
AppLayerParserRegisterGetTxCnt(IPPROTO_TCP, ALPROTO_DNS,
RustDNSGetTxCnt);
AppLayerParserRegisterGetEventsFunc(IPPROTO_TCP, ALPROTO_DNS, DNSGetEvents);
AppLayerParserRegisterHasEventsFunc(IPPROTO_TCP, ALPROTO_DNS, DNSHasEvents);
AppLayerParserRegisterDetectStateFuncs(IPPROTO_TCP, ALPROTO_DNS,
- DNSStateHasTxDetectState,
DNSGetTxDetectState, DNSSetTxDetectState);
AppLayerParserRegisterDetectFlagsFuncs(IPPROTO_TCP, ALPROTO_DNS,
DNSGetTxDetectFlags, DNSSetTxDetectFlags);
rs_dns_state_tx_free(state, tx_id);
}
-static int RustDNSStateHasTxDetectState(void *state)
-{
- return rs_dns_state_has_detect_state(state);
-}
-
static DetectEngineState *RustDNSGetTxDetectState(void *tx)
{
return rs_dns_state_get_tx_detect_state(tx);
}
-static int RustDNSSetTxDetectState(void *state, void *tx,
- DetectEngineState *s)
+static int RustDNSSetTxDetectState(void *tx, DetectEngineState *s)
{
- rs_dns_state_set_tx_detect_state(state, tx, s);
+ rs_dns_state_set_tx_detect_state(tx, s);
return 0;
}
AppLayerParserRegisterHasEventsFunc(IPPROTO_UDP, ALPROTO_DNS,
RustDNSHasEvents);
AppLayerParserRegisterDetectStateFuncs(IPPROTO_UDP, ALPROTO_DNS,
- RustDNSStateHasTxDetectState, RustDNSGetTxDetectState,
- RustDNSSetTxDetectState);
+ RustDNSGetTxDetectState, RustDNSSetTxDetectState);
AppLayerParserRegisterDetectFlagsFuncs(IPPROTO_UDP, ALPROTO_DNS,
RustDNSGetDetectFlags, RustDNSSetDetectFlags);
AppLayerParserRegisterGetEventsFunc(IPPROTO_UDP, ALPROTO_DNS, DNSGetEvents);
AppLayerParserRegisterHasEventsFunc(IPPROTO_UDP, ALPROTO_DNS, DNSHasEvents);
AppLayerParserRegisterDetectStateFuncs(IPPROTO_UDP, ALPROTO_DNS,
- DNSStateHasTxDetectState,
DNSGetTxDetectState, DNSSetTxDetectState);
AppLayerParserRegisterDetectFlagsFuncs(IPPROTO_UDP, ALPROTO_DNS,
DNSGetTxDetectFlags, DNSSetTxDetectFlags);
return tx->de_state;
}
-static int ENIPSetTxDetectState(void *state, void *vtx, DetectEngineState *s)
+static int ENIPSetTxDetectState(void *vtx, DetectEngineState *s)
{
ENIPTransaction *tx = (ENIPTransaction *)vtx;
tx->de_state = s;
AppLayerParserRegisterGetEventsFunc(IPPROTO_UDP, ALPROTO_ENIP, ENIPGetEvents);
AppLayerParserRegisterHasEventsFunc(IPPROTO_UDP, ALPROTO_ENIP, ENIPHasEvents);
- AppLayerParserRegisterDetectStateFuncs(IPPROTO_UDP, ALPROTO_ENIP, NULL,
- ENIPGetTxDetectState, ENIPSetTxDetectState);
+ AppLayerParserRegisterDetectStateFuncs(IPPROTO_UDP, ALPROTO_ENIP,
+ ENIPGetTxDetectState, ENIPSetTxDetectState);
AppLayerParserRegisterGetTx(IPPROTO_UDP, ALPROTO_ENIP, ENIPGetTx);
AppLayerParserRegisterGetTxCnt(IPPROTO_UDP, ALPROTO_ENIP, ENIPGetTxCnt);
AppLayerParserRegisterGetEventsFunc(IPPROTO_TCP, ALPROTO_ENIP, ENIPGetEvents);
AppLayerParserRegisterHasEventsFunc(IPPROTO_TCP, ALPROTO_ENIP, ENIPHasEvents);
- AppLayerParserRegisterDetectStateFuncs(IPPROTO_TCP, ALPROTO_ENIP, NULL,
- ENIPGetTxDetectState, ENIPSetTxDetectState);
+ AppLayerParserRegisterDetectStateFuncs(IPPROTO_TCP, ALPROTO_ENIP,
+ ENIPGetTxDetectState, ENIPSetTxDetectState);
AppLayerParserRegisterGetTx(IPPROTO_TCP, ALPROTO_ENIP, ENIPGetTx);
AppLayerParserRegisterGetTxCnt(IPPROTO_TCP, ALPROTO_ENIP, ENIPGetTxCnt);
#endif
}
-static int FTPStateHasTxDetectState(void *state)
+static int FTPSetTxDetectState(void *vtx, DetectEngineState *de_state)
{
- FtpState *ftp_state = (FtpState *)state;
- if (ftp_state->de_state)
- return 1;
- return 0;
-}
-
-static int FTPSetTxDetectState(void *state, void *vtx, DetectEngineState *de_state)
-{
- FtpState *ftp_state = (FtpState *)state;
+ FtpState *ftp_state = (FtpState *)vtx;
ftp_state->de_state = de_state;
return 0;
}
#endif
}
-static int FTPDataStateHasTxDetectState(void *state)
+static int FTPDataSetTxDetectState(void *vtx, DetectEngineState *de_state)
{
- FtpDataState *ftp_state = (FtpDataState *)state;
- if (ftp_state->de_state)
- return 1;
- return 0;
-}
-
-static int FTPDataSetTxDetectState(void *state, void *vtx, DetectEngineState *de_state)
-{
- FtpDataState *ftp_state = (FtpDataState *)state;
+ FtpDataState *ftp_state = (FtpDataState *)vtx;
ftp_state->de_state = de_state;
return 0;
}
AppLayerParserRegisterTxFreeFunc(IPPROTO_TCP, ALPROTO_FTP, FTPStateTransactionFree);
- AppLayerParserRegisterDetectStateFuncs(IPPROTO_TCP, ALPROTO_FTP, FTPStateHasTxDetectState,
- FTPGetTxDetectState, FTPSetTxDetectState);
+ AppLayerParserRegisterDetectStateFuncs(IPPROTO_TCP, ALPROTO_FTP,
+ FTPGetTxDetectState, FTPSetTxDetectState);
AppLayerParserRegisterGetTx(IPPROTO_TCP, ALPROTO_FTP, FTPGetTx);
AppLayerParserRegisterStateFuncs(IPPROTO_TCP, ALPROTO_FTPDATA, FTPDataStateAlloc, FTPDataStateFree);
AppLayerParserRegisterParserAcceptableDataDirection(IPPROTO_TCP, ALPROTO_FTPDATA, STREAM_TOSERVER | STREAM_TOCLIENT);
AppLayerParserRegisterTxFreeFunc(IPPROTO_TCP, ALPROTO_FTPDATA, FTPDataStateTransactionFree);
- AppLayerParserRegisterDetectStateFuncs(IPPROTO_TCP, ALPROTO_FTPDATA, FTPDataStateHasTxDetectState,
+ AppLayerParserRegisterDetectStateFuncs(IPPROTO_TCP, ALPROTO_FTPDATA,
FTPDataGetTxDetectState, FTPDataSetTxDetectState);
AppLayerParserRegisterGetFilesFunc(IPPROTO_TCP, ALPROTO_FTPDATA, FTPDataStateGetFiles);
if (htud->boundary)
HTPFree(htud->boundary, htud->boundary_len);
if (htud->de_state != NULL) {
- if (likely(state != NULL)) { // should be impossible that it's null
- BUG_ON(state->tx_with_detect_state_cnt == 0);
- state->tx_with_detect_state_cnt--;
- }
-
DetectEngineStateFree(htud->de_state);
}
HTPFree(htud, sizeof(HtpTxUserData));
}
htp_connp_destroy_all(s->connp);
}
- BUG_ON(s->tx_with_detect_state_cnt > 0);
FileContainerFree(s->files_ts);
FileContainerFree(s->files_tc);
}
}
-static int HTPStateHasTxDetectState(void *alstate)
-{
- HtpState *htp_state = (HtpState *)alstate;
- return (htp_state->tx_with_detect_state_cnt > 0);
-}
-
static DetectEngineState *HTPGetTxDetectState(void *vtx)
{
htp_tx_t *tx = (htp_tx_t *)vtx;
return tx_ud ? tx_ud->de_state : NULL;
}
-static int HTPSetTxDetectState(void *alstate, void *vtx, DetectEngineState *s)
+static int HTPSetTxDetectState(void *vtx, DetectEngineState *s)
{
- HtpState *htp_state = (HtpState *)alstate;
htp_tx_t *tx = (htp_tx_t *)vtx;
HtpTxUserData *tx_ud = htp_tx_get_user_data(tx);
if (tx_ud == NULL) {
memset(tx_ud, 0, sizeof(*tx_ud));
htp_tx_set_user_data(tx, tx_ud);
}
- htp_state->tx_with_detect_state_cnt++;
tx_ud->de_state = s;
return 0;
}
AppLayerParserRegisterTruncateFunc(IPPROTO_TCP, ALPROTO_HTTP, HTPStateTruncate);
AppLayerParserRegisterDetectStateFuncs(IPPROTO_TCP, ALPROTO_HTTP,
- HTPStateHasTxDetectState,
HTPGetTxDetectState, HTPSetTxDetectState);
AppLayerParserRegisterDetectFlagsFuncs(IPPROTO_TCP, ALPROTO_HTTP,
HTPGetTxDetectFlags, HTPSetTxDetectFlags);
uint16_t flags;
uint16_t events;
uint16_t htp_messages_offset; /**< offset into conn->messages list */
- uint64_t tx_with_detect_state_cnt;
} HtpState;
/** part of the engine needs the request body (e.g. http_client_body keyword) */
return tx->de_state;
}
-static int ModbusSetTxDetectState(void *state, void *vtx, DetectEngineState *s)
+static int ModbusSetTxDetectState(void *vtx, DetectEngineState *s)
{
ModbusTransaction *tx = (ModbusTransaction *)vtx;
tx->de_state = s;
AppLayerParserRegisterGetEventsFunc(IPPROTO_TCP, ALPROTO_MODBUS, ModbusGetEvents);
AppLayerParserRegisterHasEventsFunc(IPPROTO_TCP, ALPROTO_MODBUS, ModbusHasEvents);
- AppLayerParserRegisterDetectStateFuncs(IPPROTO_TCP, ALPROTO_MODBUS, NULL,
+ AppLayerParserRegisterDetectStateFuncs(IPPROTO_TCP, ALPROTO_MODBUS,
ModbusGetTxDetectState, ModbusSetTxDetectState);
AppLayerParserRegisterGetTx(IPPROTO_TCP, ALPROTO_MODBUS, ModbusGetTx);
/**
* \brief set store tx detect state
*/
-static int NFSTCPSetTxDetectState(void *state, void *vtx,
- DetectEngineState *s)
+static int NFSTCPSetTxDetectState(void *vtx, DetectEngineState *s)
{
- rs_nfs3_state_set_tx_detect_state(state, vtx, s);
+ rs_nfs3_state_set_tx_detect_state(vtx, s);
return 0;
}
/* What is this being registered for? */
AppLayerParserRegisterDetectStateFuncs(IPPROTO_TCP, ALPROTO_NFS,
- NULL, NFSTCPGetTxDetectState, NFSTCPSetTxDetectState);
+ NFSTCPGetTxDetectState, NFSTCPSetTxDetectState);
AppLayerParserRegisterGetEventInfo(IPPROTO_TCP, ALPROTO_NFS,
NFSTCPStateGetEventInfo);
/**
* \brief set store tx detect state
*/
-static int NFSSetTxDetectState(void *state, void *vtx,
- DetectEngineState *s)
+static int NFSSetTxDetectState(void *vtx, DetectEngineState *s)
{
- rs_nfs3_state_set_tx_detect_state(state, vtx, s);
+ rs_nfs3_state_set_tx_detect_state(vtx, s);
return 0;
}
/* What is this being registered for? */
AppLayerParserRegisterDetectStateFuncs(IPPROTO_UDP, ALPROTO_NFS,
- NULL, NFSGetTxDetectState, NFSSetTxDetectState);
+ NFSGetTxDetectState, NFSSetTxDetectState);
AppLayerParserRegisterGetEventInfo(IPPROTO_UDP, ALPROTO_NFS,
NFSStateGetEventInfo);
LoggerId (*StateGetTxLogged)(void *alstate, void *tx);
void (*StateSetTxLogged)(void *alstate, void *tx, LoggerId logger);
- int (*StateHasTxDetectState)(void *alstate);
DetectEngineState *(*GetTxDetectState)(void *tx);
- int (*SetTxDetectState)(void *alstate, void *tx, DetectEngineState *);
+ int (*SetTxDetectState)(void *tx, DetectEngineState *);
uint64_t (*GetTxDetectFlags)(void *tx, uint8_t dir);
void (*SetTxDetectFlags)(void *tx, uint8_t dir, uint64_t);
}
void AppLayerParserRegisterDetectStateFuncs(uint8_t ipproto, AppProto alproto,
- int (*StateHasTxDetectState)(void *alstate),
DetectEngineState *(*GetTxDetectState)(void *tx),
- int (*SetTxDetectState)(void *alstate, void *tx, DetectEngineState *))
+ int (*SetTxDetectState)(void *tx, DetectEngineState *))
{
SCEnter();
- alp_ctx.ctxs[FlowGetProtoMapping(ipproto)][alproto].StateHasTxDetectState = StateHasTxDetectState;
alp_ctx.ctxs[FlowGetProtoMapping(ipproto)][alproto].GetTxDetectState = GetTxDetectState;
alp_ctx.ctxs[FlowGetProtoMapping(ipproto)][alproto].SetTxDetectState = SetTxDetectState;
return FALSE;
}
-int AppLayerParserHasTxDetectState(uint8_t ipproto, AppProto alproto, void *alstate)
-{
- int r;
- SCEnter();
- if (alp_ctx.ctxs[FlowGetProtoMapping(ipproto)][alproto].StateHasTxDetectState == NULL)
- return -ENOSYS;
- r = alp_ctx.ctxs[FlowGetProtoMapping(ipproto)][alproto].StateHasTxDetectState(alstate);
- SCReturnInt(r);
-}
-
DetectEngineState *AppLayerParserGetTxDetectState(uint8_t ipproto, AppProto alproto, void *tx)
{
SCEnter();
}
int AppLayerParserSetTxDetectState(const Flow *f,
- void *alstate, void *tx, DetectEngineState *s)
+ void *tx, DetectEngineState *s)
{
int r;
SCEnter();
if ((alp_ctx.ctxs[f->protomap][f->alproto].GetTxDetectState(tx) != NULL))
SCReturnInt(-EBUSY);
- r = alp_ctx.ctxs[f->protomap][f->alproto].SetTxDetectState(alstate, tx, s);
+ r = alp_ctx.ctxs[f->protomap][f->alproto].SetTxDetectState(tx, s);
SCReturnInt(r);
}
printf("- StateGetProgress %p StateGetProgressCompletionStatus %p\n", ctx->StateGetProgress, ctx_def->StateGetProgressCompletionStatus);
printf("- GetTxDetectState %p SetTxDetectState %p\n", ctx->GetTxDetectState, ctx->SetTxDetectState);
printf("Optional:\n");
- printf("- StateHasTxDetectState %p\n", ctx->StateHasTxDetectState);
printf("- LocalStorageAlloc %p LocalStorageFree %p\n", ctx->LocalStorageAlloc, ctx->LocalStorageFree);
printf("- StateGetTxLogged %p StateSetTxLogged %p\n", ctx->StateGetTxLogged, ctx->StateSetTxLogged);
printf("- StateGetEvents %p StateHasEvents %p StateGetEventInfo %p\n", ctx->StateGetEvents, ctx->StateHasEvents, ctx->StateGetEventInfo);
int (*StateGetEventInfo)(const char *event_name, int *event_id,
AppLayerEventType *event_type));
void AppLayerParserRegisterDetectStateFuncs(uint8_t ipproto, AppProto alproto,
- int (*StateHasTxDetectState)(void *alstate),
DetectEngineState *(*GetTxDetectState)(void *tx),
- int (*SetTxDetectState)(void *alstate, void *tx, DetectEngineState *));
+ int (*SetTxDetectState)(void *tx, DetectEngineState *));
void AppLayerParserRegisterGetStreamDepth(uint8_t ipproto,
AppProto alproto,
uint32_t (*GetStreamDepth)(void));
int AppLayerParserSupportsTxDetectState(uint8_t ipproto, AppProto alproto);
int AppLayerParserHasTxDetectState(uint8_t ipproto, AppProto alproto, void *alstate);
DetectEngineState *AppLayerParserGetTxDetectState(uint8_t ipproto, AppProto alproto, void *tx);
-int AppLayerParserSetTxDetectState(const Flow *f, void *alstate, void *tx, DetectEngineState *s);
+int AppLayerParserSetTxDetectState(const Flow *f, void *tx, DetectEngineState *s);
uint64_t AppLayerParserGetTxDetectFlags(uint8_t ipproto, AppProto alproto, void *tx, uint8_t dir);
void AppLayerParserSetTxDetectFlags(uint8_t ipproto, AppProto alproto, void *tx, uint8_t dir, uint64_t);
/* What is this being registered for? */
AppLayerParserRegisterDetectStateFuncs(p->ip_proto, alproto,
- p->StateHasTxDetectState, p->GetTxDetectState, p->SetTxDetectState);
+ p->GetTxDetectState, p->SetTxDetectState);
if (p->StateGetEventInfo) {
AppLayerParserRegisterGetEventInfo(p->ip_proto, alproto,
void (*StateSetTxLogged)(void *alstate, void *tx, uint32_t logger);
DetectEngineState *(*GetTxDetectState)(void *tx);
- int (*SetTxDetectState)(void *alstate, void *tx, DetectEngineState *);
- int (*StateHasTxDetectState)(void *alstate);
+ int (*SetTxDetectState)(void *tx, DetectEngineState *);
int (*StateHasEvents)(void *);
AppLayerDecoderEvents *(*StateGetEvents)(void *, uint64_t);
SCReturn;
}
-static int SMBStateHasTxDetectState(void *state)
+static int SMBSetTxDetectState(void *vtx, DetectEngineState *de_state)
{
- SMBState *smb_state = (SMBState *)state;
- if (smb_state->ds.de_state)
- return 1;
- return 0;
-}
-
-static int SMBSetTxDetectState(void *state, void *vtx, DetectEngineState *de_state)
-{
- SMBState *smb_state = (SMBState *)state;
+ SMBState *smb_state = (SMBState *)vtx;
smb_state->ds.de_state = de_state;
return 0;
}
AppLayerParserRegisterTxFreeFunc(IPPROTO_TCP, ALPROTO_SMB, SMBStateTransactionFree);
- AppLayerParserRegisterDetectStateFuncs(IPPROTO_TCP, ALPROTO_SMB, SMBStateHasTxDetectState,
+ AppLayerParserRegisterDetectStateFuncs(IPPROTO_TCP, ALPROTO_SMB,
SMBGetTxDetectState, SMBSetTxDetectState);
AppLayerParserRegisterGetTx(IPPROTO_TCP, ALPROTO_SMB, SMBGetTx);
return tx->de_state;
}
-static int SMTPSetTxDetectState(void *state, void *vtx, DetectEngineState *s)
+static int SMTPSetTxDetectState(void *vtx, DetectEngineState *s)
{
SMTPTransaction *tx = (SMTPTransaction *)vtx;
tx->de_state = s;
AppLayerParserRegisterGetEventInfo(IPPROTO_TCP, ALPROTO_SMTP, SMTPStateGetEventInfo);
AppLayerParserRegisterGetEventsFunc(IPPROTO_TCP, ALPROTO_SMTP, SMTPGetEvents);
- AppLayerParserRegisterDetectStateFuncs(IPPROTO_TCP, ALPROTO_SMTP, NULL,
+ AppLayerParserRegisterDetectStateFuncs(IPPROTO_TCP, ALPROTO_SMTP,
SMTPGetTxDetectState, SMTPSetTxDetectState);
AppLayerParserRegisterDetectFlagsFuncs(IPPROTO_TCP, ALPROTO_SMTP,
SMTPGetTxDetectFlags, SMTPSetTxDetectFlags);
SCFree(s);
}
-static int SSHStateHasTxDetectState(void *state)
+static int SSHSetTxDetectState(void *vtx, DetectEngineState *de_state)
{
- SshState *ssh_state = (SshState *)state;
- if (ssh_state->de_state)
- return 1;
- return 0;
-}
-
-static int SSHSetTxDetectState(void *state, void *vtx, DetectEngineState *de_state)
-{
- SshState *ssh_state = (SshState *)state;
+ SshState *ssh_state = (SshState *)vtx;
ssh_state->de_state = de_state;
return 0;
}
AppLayerParserRegisterTxFreeFunc(IPPROTO_TCP, ALPROTO_SSH, SSHStateTransactionFree);
- AppLayerParserRegisterDetectStateFuncs(IPPROTO_TCP, ALPROTO_SSH, SSHStateHasTxDetectState,
+ AppLayerParserRegisterDetectStateFuncs(IPPROTO_TCP, ALPROTO_SSH,
SSHGetTxDetectState, SSHSetTxDetectState);
AppLayerParserRegisterGetTx(IPPROTO_TCP, ALPROTO_SSH, SSHGetTx);
return (ssl_state->events > 0);
}
-static int SSLStateHasTxDetectState(void *state)
+static int SSLSetTxDetectState(void *vtx, DetectEngineState *de_state)
{
- SSLState *ssl_state = (SSLState *)state;
- if (ssl_state->de_state)
- return 1;
-
- return 0;
-}
-
-static int SSLSetTxDetectState(void *state, void *vtx, DetectEngineState *de_state)
-{
- SSLState *ssl_state = (SSLState *)state;
+ SSLState *ssl_state = (SSLState *)vtx;
ssl_state->de_state = de_state;
return 0;
}
AppLayerParserRegisterHasEventsFunc(IPPROTO_TCP, ALPROTO_TLS, SSLHasEvents);
- AppLayerParserRegisterDetectStateFuncs(IPPROTO_TCP, ALPROTO_TLS, SSLStateHasTxDetectState,
+ AppLayerParserRegisterDetectStateFuncs(IPPROTO_TCP, ALPROTO_TLS,
SSLGetTxDetectState, SSLSetTxDetectState);
AppLayerParserRegisterGetTx(IPPROTO_TCP, ALPROTO_TLS, SSLGetTx);
/**
* \brief ???
*/
-static int TemplateSetTxDetectState(void *state, void *vtx,
+static int TemplateSetTxDetectState(void *vtx,
DetectEngineState *s)
{
TemplateTransaction *tx = vtx;
/* What is this being registered for? */
AppLayerParserRegisterDetectStateFuncs(IPPROTO_TCP, ALPROTO_TEMPLATE,
- NULL, TemplateGetTxDetectState, TemplateSetTxDetectState);
+ TemplateGetTxDetectState, TemplateSetTxDetectState);
AppLayerParserRegisterGetEventInfo(IPPROTO_TCP, ALPROTO_TEMPLATE,
TemplateStateGetEventInfo);
return NULL;
}
-static int TFTPSetTxDetectState(void *state, void *vtx,
+static int TFTPSetTxDetectState(void *vtx,
DetectEngineState *s)
{
return 0;
/* What is this being registered for? */
AppLayerParserRegisterDetectStateFuncs(IPPROTO_UDP, ALPROTO_TFTP,
- NULL, TFTPGetTxDetectState,
+ TFTPGetTxDetectState,
TFTPSetTxDetectState);
AppLayerParserRegisterGetEventInfo(IPPROTO_UDP, ALPROTO_TFTP,
destate = DetectEngineStateAlloc();
if (destate == NULL)
return;
- if (AppLayerParserSetTxDetectState(f, f->alstate, tx, destate) < 0) {
+ if (AppLayerParserSetTxDetectState(f, tx, destate) < 0) {
DetectEngineStateFree(destate);
return;
}