f->probing_parser_toserver_alproto_masks = 0;
f->probing_parser_toclient_alproto_masks = 0;
- AppLayerParserStateCleanup(f->proto, f->alproto, f->alstate, f->alparser);
+ AppLayerParserStateCleanup(f, f->alstate, f->alparser);
f->alstate = NULL;
f->alparser = NULL;
f->alproto = ALPROTO_UNKNOWN;
SCReturnCT(r, "uint8_t");
}
-uint64_t AppLayerParserGetTransactionActive(uint8_t ipproto, AppProto alproto,
- AppLayerParserState *pstate, uint8_t direction)
+uint64_t AppLayerParserGetTransactionActive(const Flow *f,
+ AppLayerParserState *pstate, uint8_t direction)
{
SCEnter();
uint64_t log_id = pstate->log_id;
uint64_t inspect_id = pstate->inspect_id[direction & STREAM_TOSERVER ? 0 : 1];
- if (alp_ctx.ctxs[FlowGetProtoMapping(ipproto)][alproto].logger == TRUE) {
+ if (alp_ctx.ctxs[f->protomap][f->alproto].logger == TRUE) {
active_id = (log_id < inspect_id) ? log_id : inspect_id;
} else {
active_id = inspect_id;
SCReturnPtr(s, "DetectEngineState");
}
-int AppLayerParserSetTxDetectState(uint8_t ipproto, AppProto alproto,
+int AppLayerParserSetTxDetectState(const Flow *f,
void *alstate, void *tx, DetectEngineState *s)
{
int r;
SCEnter();
- if ((alp_ctx.ctxs[FlowGetProtoMapping(ipproto)][alproto].GetTxDetectState(tx) != NULL))
+ if ((alp_ctx.ctxs[f->protomap][f->alproto].GetTxDetectState(tx) != NULL))
SCReturnInt(-EBUSY);
- r = alp_ctx.ctxs[FlowGetProtoMapping(ipproto)][alproto].SetTxDetectState(alstate, tx, s);
+ r = alp_ctx.ctxs[f->protomap][f->alproto].SetTxDetectState(alstate, tx, s);
SCReturnInt(r);
}
SCReturn;
}
-int AppLayerParserHasDecoderEvents(uint8_t ipproto, AppProto alproto,
+int AppLayerParserHasDecoderEvents(const Flow *f,
void *alstate, AppLayerParserState *pstate,
uint8_t flags)
{
uint64_t tx_id;
uint64_t max_id;
- if (AppLayerParserProtocolIsTxEventAware(ipproto, alproto)) {
+ if (AppLayerParserProtocolIsTxEventAware(f->proto, f->alproto)) {
/* fast path if supported by alproto */
- if (alp_ctx.ctxs[FlowGetProtoMapping(ipproto)][alproto].StateHasEvents != NULL) {
- if (alp_ctx.ctxs[FlowGetProtoMapping(ipproto)][alproto].
+ if (alp_ctx.ctxs[f->protomap][f->alproto].StateHasEvents != NULL) {
+ if (alp_ctx.ctxs[f->protomap][f->alproto].
StateHasEvents(alstate) == 1)
{
goto present;
} else {
/* check each tx */
tx_id = AppLayerParserGetTransactionInspectId(pstate, flags);
- max_id = AppLayerParserGetTxCnt(ipproto, alproto, alstate);
+ max_id = AppLayerParserGetTxCnt(f->proto, f->alproto, alstate);
for ( ; tx_id < max_id; tx_id++) {
- decoder_events = AppLayerParserGetEventsByTx(ipproto, alproto, alstate, tx_id);
+ decoder_events = AppLayerParserGetEventsByTx(f->proto, f->alproto, alstate, tx_id);
if (decoder_events && decoder_events->cnt)
goto present;
}
SCReturn;
}
-uint32_t AppLayerParserGetStreamDepth(uint8_t ipproto, AppProto alproto)
+uint32_t AppLayerParserGetStreamDepth(const Flow *f)
{
- SCReturnInt(alp_ctx.ctxs[FlowGetProtoMapping(ipproto)][alproto].stream_depth);
+ SCReturnInt(alp_ctx.ctxs[f->protomap][f->alproto].stream_depth);
}
/***** Cleanup *****/
-void AppLayerParserStateCleanup(uint8_t ipproto, AppProto alproto, void *alstate,
+void AppLayerParserStateCleanup(const Flow *f, void *alstate,
AppLayerParserState *pstate)
{
SCEnter();
- AppLayerParserProtoCtx *ctx = &alp_ctx.ctxs[FlowGetProtoMapping(ipproto)][alproto];
+ AppLayerParserProtoCtx *ctx = &alp_ctx.ctxs[f->protomap][f->alproto];
if (ctx->StateFree != NULL && alstate != NULL)
ctx->StateFree(alstate);
int AppLayerParserGetEventInfo(uint8_t ipproto, AppProto alproto, const char *event_name,
int *event_id, AppLayerEventType *event_type);
-uint64_t AppLayerParserGetTransactionActive(uint8_t ipproto, AppProto alproto, AppLayerParserState *pstate, uint8_t direction);
+uint64_t AppLayerParserGetTransactionActive(const Flow *f, AppLayerParserState *pstate, uint8_t direction);
uint8_t AppLayerParserGetFirstDataDir(uint8_t ipproto, AppProto alproto);
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(uint8_t ipproto, AppProto alproto, void *alstate, void *tx, DetectEngineState *s);
+int AppLayerParserSetTxDetectState(const Flow *f, void *alstate, void *tx, DetectEngineState *s);
uint64_t AppLayerParserGetTxMpmIDs(uint8_t ipproto, AppProto alproto, void *tx);
int AppLayerParserSetTxMpmIDs(uint8_t ipproto, AppProto alproto, void *tx, uint64_t);
int AppLayerParserParse(ThreadVars *tv, AppLayerParserThreadCtx *tctx, Flow *f, AppProto alproto,
uint8_t flags, uint8_t *input, uint32_t input_len);
void AppLayerParserSetEOF(AppLayerParserState *pstate);
-int AppLayerParserHasDecoderEvents(uint8_t ipproto, AppProto alproto, void *alstate, AppLayerParserState *pstate,
+int AppLayerParserHasDecoderEvents(const Flow *f, void *alstate, AppLayerParserState *pstate,
uint8_t flags);
int AppLayerParserIsTxAware(AppProto alproto);
int AppLayerParserProtocolIsTxAware(uint8_t ipproto, AppProto alproto);
int AppLayerParserProtocolHasLogger(uint8_t ipproto, AppProto alproto);
void AppLayerParserTriggerRawStreamReassembly(Flow *f, int direction);
void AppLayerParserSetStreamDepth(uint8_t ipproto, AppProto alproto, uint32_t stream_depth);
-uint32_t AppLayerParserGetStreamDepth(uint8_t ipproto, AppProto alproto);
+uint32_t AppLayerParserGetStreamDepth(const Flow *f);
/***** Cleanup *****/
-void AppLayerParserStateCleanup(uint8_t ipproto, AppProto alproto, void *alstate, AppLayerParserState *pstate);
+void AppLayerParserStateCleanup(const Flow *f, void *alstate, AppLayerParserState *pstate);
void AppLayerParserRegisterProtocolParsers(void);
StreamTcpSetStreamFlagAppProtoDetectionCompleted(stream);
TcpSessionSetReassemblyDepth(ssn,
- AppLayerParserGetStreamDepth(f->proto, f->alproto));
+ AppLayerParserGetStreamDepth(f));
FlagPacketFlow(p, f, flags);
/* account flow if we have both sides */
APPLAYER_DETECT_PROTOCOL_ONLY_ONE_DIRECTION);
StreamTcpSetStreamFlagAppProtoDetectionCompleted(stream);
TcpSessionSetReassemblyDepth(ssn,
- AppLayerParserGetStreamDepth(f->proto, f->alproto));
+ AppLayerParserGetStreamDepth(f));
*alproto = ALPROTO_FAILED;
FlagPacketFlow(p, f, flags);
destate = DetectEngineStateAlloc();
if (destate == NULL)
return;
- if (AppLayerParserSetTxDetectState(f->proto, f->alproto, f->alstate, tx, destate) < 0) {
+ if (AppLayerParserSetTxDetectState(f, f->alstate, tx, destate) < 0) {
DetectEngineStateFree(destate);
return;
}
destate = DetectEngineStateAlloc();
if (destate == NULL)
return;
- if (AppLayerParserSetTxDetectState(f->proto, f->alproto, f->alstate, tx, destate) < 0) {
+ if (AppLayerParserSetTxDetectState(f, f->alstate, tx, destate) < 0) {
DetectEngineStateFree(destate);
return;
}
SCLogDebug("packet doesn't have established flag set (proto %d)", p->proto);
}
- app_decoder_events = AppLayerParserHasDecoderEvents(pflow->proto,
- pflow->alproto,
+ app_decoder_events = AppLayerParserHasDecoderEvents(pflow,
pflow->alstate,
pflow->alparser,
flow_flags);
{
uint64_t total_txs = AppLayerParserGetTxCnt(f->proto, f->alproto, f->alstate);
- if (AppLayerParserGetTransactionActive(f->proto, f->alproto,
- f->alparser, STREAM_TOCLIENT) < total_txs)
+ if (AppLayerParserGetTransactionActive(f, f->alparser, STREAM_TOCLIENT) < total_txs)
{
*server = STREAM_HAS_UNPROCESSED_SEGMENTS_NEED_ONLY_DETECTION;
}
- if (AppLayerParserGetTransactionActive(f->proto, f->alproto,
- f->alparser, STREAM_TOSERVER) < total_txs)
+ if (AppLayerParserGetTransactionActive(f, f->alparser, STREAM_TOSERVER) < total_txs)
{
*client = STREAM_HAS_UNPROCESSED_SEGMENTS_NEED_ONLY_DETECTION;
}
if (f == NULL || f->proto == 0)
return;
- AppLayerParserStateCleanup(f->proto, f->alproto, f->alstate, f->alparser);
+ AppLayerParserStateCleanup(f, f->alstate, f->alparser);
f->alstate = NULL;
f->alparser = NULL;
return;
Flow * const f = p->flow;
- AppProto alproto = f->alproto;
+ const AppProto alproto = f->alproto;
if (AppLayerParserProtocolIsTxAware(p->proto, alproto) == 0)
goto end;