From: Victor Julien Date: Mon, 19 Oct 2020 13:33:00 +0000 (+0200) Subject: detect: remove inspect v1 API X-Git-Tag: suricata-7.0.0-beta1~1959 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d694dac5a8c1fdf4541d26be25cfed1fd53eb594;p=thirdparty%2Fsuricata.git detect: remove inspect v1 API --- diff --git a/src/detect-engine.c b/src/detect-engine.c index 62427a84f7..7e6633483d 100644 --- a/src/detect-engine.c +++ b/src/detect-engine.c @@ -165,67 +165,6 @@ void DetectPktInspectEngineRegister(const char *name, } } -/** \brief register inspect engine at start up time - * - * \note errors are fatal */ -void DetectAppLayerInspectEngineRegister(const char *name, - AppProto alproto, uint32_t dir, - int progress, InspectEngineFuncPtr Callback) -{ - if (AppLayerParserIsEnabled(alproto)) { - if (!AppLayerParserSupportsTxDetectFlags(alproto)) { - FatalError(SC_ERR_INITIALIZATION, - "Inspect engine registered for app-layer protocol without " - "TX detect flag support: %s", AppProtoToString(alproto)); - } - } - DetectBufferTypeRegister(name); - const int sm_list = DetectBufferTypeGetByName(name); - if (sm_list == -1) { - FatalError(SC_ERR_INITIALIZATION, - "failed to register inspect engine %s", name); - } - - if ((alproto >= ALPROTO_FAILED) || - (!(dir == SIG_FLAG_TOSERVER || dir == SIG_FLAG_TOCLIENT)) || - (sm_list < DETECT_SM_LIST_MATCH) || (sm_list >= SHRT_MAX) || - (progress < 0 || progress >= SHRT_MAX) || - (Callback == NULL)) - { - SCLogError(SC_ERR_INVALID_ARGUMENTS, "Invalid arguments"); - BUG_ON(1); - } - - int direction; - if (dir == SIG_FLAG_TOSERVER) { - direction = 0; - } else { - direction = 1; - } - - DetectEngineAppInspectionEngine *new_engine = SCMalloc(sizeof(DetectEngineAppInspectionEngine)); - if (unlikely(new_engine == NULL)) { - exit(EXIT_FAILURE); - } - memset(new_engine, 0, sizeof(*new_engine)); - new_engine->alproto = alproto; - new_engine->dir = direction; - new_engine->sm_list = sm_list; - new_engine->progress = progress; - new_engine->Callback = Callback; - - if (g_app_inspect_engines == NULL) { - g_app_inspect_engines = new_engine; - } else { - DetectEngineAppInspectionEngine *t = g_app_inspect_engines; - while (t->next != NULL) { - t = t->next; - } - - t->next = new_engine; - } -} - /** \brief register inspect engine at start up time * * \note errors are fatal */ @@ -303,7 +242,6 @@ static void DetectAppLayerInspectEngineCopy( new_engine->dir = t->dir; new_engine->sm_list = new_list; /* use new list id */ new_engine->progress = t->progress; - new_engine->Callback = t->Callback; new_engine->v2 = t->v2; new_engine->v2.transforms = transforms; /* assign transforms */ @@ -335,7 +273,6 @@ static void DetectAppLayerInspectEngineCopyListToDetectCtx(DetectEngineCtx *de_c new_engine->dir = t->dir; new_engine->sm_list = t->sm_list; new_engine->progress = t->progress; - new_engine->Callback = t->Callback; new_engine->v2 = t->v2; if (de_ctx->app_inspect_engines == NULL) { @@ -568,7 +505,6 @@ int DetectEngineAppInspectionEngine2Signature(DetectEngineCtx *de_ctx, Signature new_engine->dir = t->dir; new_engine->sm_list = t->sm_list; new_engine->smd = ptrs[new_engine->sm_list]; - new_engine->Callback = t->Callback; new_engine->progress = t->progress; new_engine->v2 = t->v2; SCLogDebug("sm_list %d new_engine->v2 %p/%p/%p", diff --git a/src/detect-engine.h b/src/detect-engine.h index a8c1e71795..7d61ff91e7 100644 --- a/src/detect-engine.h +++ b/src/detect-engine.h @@ -141,9 +141,6 @@ int DetectEngineInspectPktBufferGeneric( * \param progress Minimal progress value for inspect engine to run * \param Callback The engine callback. */ -void DetectAppLayerInspectEngineRegister(const char *name, - AppProto alproto, uint32_t dir, - int progress, InspectEngineFuncPtr Callback); void DetectAppLayerInspectEngineRegister2(const char *name, AppProto alproto, uint32_t dir, int progress, InspectEngineFuncPtr2 Callback2, diff --git a/src/detect.c b/src/detect.c index 92a32f2ff2..549fa394b0 100644 --- a/src/detect.c +++ b/src/detect.c @@ -1133,14 +1133,9 @@ static bool DetectRunTxInspectRule(ThreadVars *tv, TRACE_SID_TXS(s->id, tx, "stream skipped, stored result %d used instead", match); } else { KEYWORD_PROFILING_SET_LIST(det_ctx, engine->sm_list); - if (engine->Callback) { - match = engine->Callback(tv, de_ctx, det_ctx, - s, engine->smd, f, flow_flags, alstate, tx->tx_ptr, tx->tx_id); - } else { - BUG_ON(engine->v2.Callback == NULL); - match = engine->v2.Callback(de_ctx, det_ctx, engine, - s, f, flow_flags, alstate, tx->tx_ptr, tx->tx_id); - } + DEBUG_VALIDATE_BUG_ON(engine->v2.Callback == NULL); + match = engine->v2.Callback( + de_ctx, det_ctx, engine, s, f, flow_flags, alstate, tx->tx_ptr, tx->tx_id); TRACE_SID_TXS(s->id, tx, "engine %p match %d", engine, match); if (engine->stream) { can->stream_stored = true; diff --git a/src/detect.h b/src/detect.h index c1fc715ca0..3644eb7744 100644 --- a/src/detect.h +++ b/src/detect.h @@ -384,13 +384,6 @@ typedef InspectionBuffer *(*InspectionBufferGetDataPtr)( const DetectEngineTransforms *transforms, Flow *f, const uint8_t flow_flags, void *txv, const int list_id); - -typedef int (*InspectEngineFuncPtr)(ThreadVars *tv, - struct DetectEngineCtx_ *de_ctx, struct DetectEngineThreadCtx_ *det_ctx, - const struct Signature_ *sig, const SigMatchData *smd, - Flow *f, uint8_t flags, void *alstate, - void *tx, uint64_t tx_id); - struct DetectEngineAppInspectionEngine_; typedef int (*InspectEngineFuncPtr2)( @@ -408,14 +401,6 @@ typedef struct DetectEngineAppInspectionEngine_ { uint16_t sm_list:14; int16_t progress; - /* \retval 0 No match. Don't discontinue matching yet. We need more data. - * 1 Match. - * 2 Sig can't match. - * 3 Special value used by filestore sigs to indicate disabling - * filestore for the tx. - */ - InspectEngineFuncPtr Callback; - struct { InspectionBufferGetDataPtr GetData; InspectEngineFuncPtr2 Callback;