From: Victor Julien Date: Tue, 30 Mar 2021 15:17:10 +0000 (+0200) Subject: app-layer: remove conditional logic around API calls X-Git-Tag: suricata-7.0.0-beta1~1707 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1098e3b7c65f7ecab2d269016f7ad322fc0899f5;p=thirdparty%2Fsuricata.git app-layer: remove conditional logic around API calls Remove logic that suggested some API calls could be conditional, even though Suricata wouldn't even start up if they weren't registered. --- diff --git a/src/app-layer-parser.c b/src/app-layer-parser.c index 5545568817..02a4ef7482 100644 --- a/src/app-layer-parser.c +++ b/src/app-layer-parser.c @@ -890,7 +890,7 @@ void AppLayerParserTransactionsCleanup(Flow *f) if (unlikely(p->StateTransactionFree == NULL)) SCReturn; - const bool has_tx_detect_flags = (p->GetTxData != NULL && !g_detect_disabled); + const bool has_tx_detect_flags = !g_detect_disabled; const uint8_t ipproto = f->proto; const AppProto alproto = f->alproto; void * const alstate = f->alstate; @@ -1150,13 +1150,6 @@ int AppLayerParserSupportsFiles(uint8_t ipproto, AppProto alproto) return FALSE; } -int AppLayerParserSupportsTxDetectState(uint8_t ipproto, AppProto alproto) -{ - if (alp_ctx.ctxs[FlowGetProtoMapping(ipproto)][alproto].GetTxDetectState != NULL) - return TRUE; - return FALSE; -} - DetectEngineState *AppLayerParserGetTxDetectState(uint8_t ipproto, AppProto alproto, void *tx) { SCEnter(); @@ -1168,33 +1161,16 @@ DetectEngineState *AppLayerParserGetTxDetectState(uint8_t ipproto, AppProto alpr int AppLayerParserSetTxDetectState(const Flow *f, 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(tx, s); + int r = alp_ctx.ctxs[f->protomap][f->alproto].SetTxDetectState(tx, s); SCReturnInt(r); } -bool AppLayerParserSupportsTxDetectFlags(AppProto alproto) -{ - SCEnter(); - for (uint8_t p = 0; p < FLOW_PROTO_APPLAYER_MAX; p++) { - if (alp_ctx.ctxs[p][alproto].GetTxData != NULL) { - SCReturnBool(true); - } - } - SCReturnBool(false); -} - AppLayerTxData *AppLayerParserGetTxData(uint8_t ipproto, AppProto alproto, void *tx) { SCEnter(); - if (alp_ctx.ctxs[FlowGetProtoMapping(ipproto)][alproto].GetTxData) { - AppLayerTxData *d = alp_ctx.ctxs[FlowGetProtoMapping(ipproto)][alproto].GetTxData(tx); - SCReturnPtr(d, "AppLayerTxData"); - } - SCReturnPtr(NULL, "AppLayerTxData"); + AppLayerTxData *d = alp_ctx.ctxs[FlowGetProtoMapping(ipproto)][alproto].GetTxData(tx); + SCReturnPtr(d, "AppLayerTxData"); } void AppLayerParserApplyTxConfig(uint8_t ipproto, AppProto alproto, @@ -1577,9 +1553,6 @@ static void ValidateParserProto(AppProto alproto, uint8_t ipproto) if (!(BOTH_SET(ctx->GetTxDetectState, ctx->SetTxDetectState))) { goto bad; } - if (!(BOTH_SET_OR_BOTH_UNSET(ctx->GetTxDetectState, ctx->SetTxDetectState))) { - goto bad; - } if (ctx->GetTxData == NULL) { goto bad; } diff --git a/src/app-layer-parser.h b/src/app-layer-parser.h index 18258acb3c..685b50c5a0 100644 --- a/src/app-layer-parser.h +++ b/src/app-layer-parser.h @@ -229,13 +229,10 @@ uint64_t AppLayerParserGetTransactionActive(const Flow *f, AppLayerParserState * uint8_t AppLayerParserGetFirstDataDir(uint8_t ipproto, AppProto alproto); 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(const Flow *f, void *tx, DetectEngineState *s); -bool AppLayerParserSupportsTxDetectFlags(AppProto alproto); - AppLayerTxData *AppLayerParserGetTxData(uint8_t ipproto, AppProto alproto, void *tx); void AppLayerParserApplyTxConfig(uint8_t ipproto, AppProto alproto, void *state, void *tx, enum ConfigAction mode, AppLayerTxConfig);