]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
app-layer: remove conditional logic around API calls
authorVictor Julien <victor@inliniac.net>
Tue, 30 Mar 2021 15:17:10 +0000 (17:17 +0200)
committerVictor Julien <victor@inliniac.net>
Tue, 30 Mar 2021 18:36:44 +0000 (20:36 +0200)
Remove logic that suggested some API calls could be conditional,
even though Suricata wouldn't even start up if they weren't
registered.

src/app-layer-parser.c
src/app-layer-parser.h

index 554556881757ac506061b730b36a40285650d060..02a4ef7482ec9a1adbf7ec21a0817e030c58793c 100644 (file)
@@ -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;
     }
index 18258acb3c9655223a3b3ae6fd4743169fb11b67..685b50c5a073bf1daea9b0e097fc49e65831a1a4 100644 (file)
@@ -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);