diff --git a/src/app-layer-detect-proto.c b/src/app-layer-detect-proto.c index 555eeadde6..8eb92639f7 100644 --- a/src/app-layer-detect-proto.c +++ b/src/app-layer-detect-proto.c @@ -1657,7 +1657,7 @@ void AppLayerProtoDetectReset(Flow *f) 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; diff --git a/src/app-layer-parser.c b/src/app-layer-parser.c index 44a03368cb..021e8039cf 100644 --- a/src/app-layer-parser.c +++ b/src/app-layer-parser.c @@ -883,8 +883,8 @@ uint8_t AppLayerParserGetFirstDataDir(uint8_t ipproto, AppProto alproto) 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(); @@ -892,7 +892,7 @@ uint64_t AppLayerParserGetTransactionActive(uint8_t ipproto, AppProto alproto, 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; @@ -933,14 +933,14 @@ DetectEngineState *AppLayerParserGetTxDetectState(uint8_t ipproto, AppProto alpr 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); } @@ -1104,7 +1104,7 @@ void AppLayerParserSetEOF(AppLayerParserState *pstate) SCReturn; } -int AppLayerParserHasDecoderEvents(uint8_t ipproto, AppProto alproto, +int AppLayerParserHasDecoderEvents(const Flow *f, void *alstate, AppLayerParserState *pstate, uint8_t flags) { @@ -1117,10 +1117,10 @@ int AppLayerParserHasDecoderEvents(uint8_t ipproto, AppProto alproto, 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; @@ -1128,9 +1128,9 @@ int AppLayerParserHasDecoderEvents(uint8_t ipproto, AppProto alproto, } 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; } @@ -1209,19 +1209,19 @@ void AppLayerParserSetStreamDepth(uint8_t ipproto, AppProto alproto, uint32_t st 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); diff --git a/src/app-layer-parser.h b/src/app-layer-parser.h index e887e0008b..83e6672d00 100644 --- a/src/app-layer-parser.h +++ b/src/app-layer-parser.h @@ -188,7 +188,7 @@ int AppLayerParserGetStateProgressCompletionStatus(AppProto alproto, uint8_t dir 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); @@ -196,7 +196,7 @@ int AppLayerParserSupportsFiles(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); @@ -206,7 +206,7 @@ int AppLayerParserSetTxMpmIDs(uint8_t ipproto, AppProto alproto, void *tx, uint6 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); @@ -215,11 +215,11 @@ int AppLayerParserProtocolSupportsTxs(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); diff --git a/src/app-layer.c b/src/app-layer.c index dd0907aef8..667363cd02 100644 --- a/src/app-layer.c +++ b/src/app-layer.c @@ -342,7 +342,7 @@ static int TCPProtoDetect(ThreadVars *tv, StreamTcpSetStreamFlagAppProtoDetectionCompleted(stream); TcpSessionSetReassemblyDepth(ssn, - AppLayerParserGetStreamDepth(f->proto, f->alproto)); + AppLayerParserGetStreamDepth(f)); FlagPacketFlow(p, f, flags); /* account flow if we have both sides */ @@ -496,7 +496,7 @@ static int TCPProtoDetect(ThreadVars *tv, APPLAYER_DETECT_PROTOCOL_ONLY_ONE_DIRECTION); StreamTcpSetStreamFlagAppProtoDetectionCompleted(stream); TcpSessionSetReassemblyDepth(ssn, - AppLayerParserGetStreamDepth(f->proto, f->alproto)); + AppLayerParserGetStreamDepth(f)); *alproto = ALPROTO_FAILED; FlagPacketFlow(p, f, flags); diff --git a/src/detect-engine-state.c b/src/detect-engine-state.c index 6ba9dc979c..b8a98fccad 100644 --- a/src/detect-engine-state.c +++ b/src/detect-engine-state.c @@ -317,7 +317,7 @@ static void StoreStateTxFileOnly(DetectEngineThreadCtx *det_ctx, 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; } @@ -342,7 +342,7 @@ static void StoreStateTx(DetectEngineThreadCtx *det_ctx, 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; } diff --git a/src/detect.c b/src/detect.c index 458aef4c9d..be63e61b36 100644 --- a/src/detect.c +++ b/src/detect.c @@ -1013,8 +1013,7 @@ void SigMatchSignatures(ThreadVars *th_v, DetectEngineCtx *de_ctx, DetectEngineT 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); diff --git a/src/flow-timeout.c b/src/flow-timeout.c index 9547b617ec..f2c5718c03 100644 --- a/src/flow-timeout.c +++ b/src/flow-timeout.c @@ -322,13 +322,11 @@ int FlowForceReassemblyNeedReassembly(Flow *f, int *server, int *client) { 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; } diff --git a/src/flow.c b/src/flow.c index 50075d975f..c371b54e16 100644 --- a/src/flow.c +++ b/src/flow.c @@ -94,7 +94,7 @@ void FlowCleanupAppLayer(Flow *f) 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; diff --git a/src/output-tx.c b/src/output-tx.c index 74afe11c10..575bf5aa06 100644 --- a/src/output-tx.c +++ b/src/output-tx.c @@ -148,7 +148,7 @@ static TmEcode OutputTxLog(ThreadVars *tv, Packet *p, void *thread_data) Flow * const f = p->flow; - AppProto alproto = f->alproto; + const AppProto alproto = f->alproto; if (AppLayerParserProtocolIsTxAware(p->proto, alproto) == 0) goto end;