}
}
-/** \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 */
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 */
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) {
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",
* \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,
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;
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)(
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;