From: Victor Julien Date: Fri, 3 Dec 2021 08:45:56 +0000 (+0100) Subject: detect: add buffer helper functions X-Git-Tag: suricata-7.0.0-beta1~1136 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=db272443791896a2e29f9bf267e132f05d5f5ea1;p=thirdparty%2Fsuricata.git detect: add buffer helper functions --- diff --git a/src/detect-engine.c b/src/detect-engine.c index 3bf1268295..5cb6e30452 100644 --- a/src/detect-engine.c +++ b/src/detect-engine.c @@ -920,6 +920,30 @@ const char *DetectBufferTypeGetDescriptionByName(const char *name) return exists->description; } +void DetectEngineBufferTypeSupportsPacket(DetectEngineCtx *de_ctx, const char *name) +{ + DetectBufferType *exists = DetectEngineBufferTypeLookupByName(de_ctx, name); + BUG_ON(!exists); + exists->packet = true; + SCLogDebug("%p %s -- %d supports packet inspection", exists, name, exists->id); +} + +void DetectEngineBufferTypeSupportsMpm(DetectEngineCtx *de_ctx, const char *name) +{ + DetectBufferType *exists = DetectEngineBufferTypeLookupByName(de_ctx, name); + BUG_ON(!exists); + exists->mpm = true; + SCLogDebug("%p %s -- %d supports mpm", exists, name, exists->id); +} + +void DetectEngineBufferTypeSupportsTransformations(DetectEngineCtx *de_ctx, const char *name) +{ + DetectBufferType *exists = DetectEngineBufferTypeLookupByName(de_ctx, name); + BUG_ON(!exists); + exists->supports_transforms = true; + SCLogDebug("%p %s -- %d supports transformations", exists, name, exists->id); +} + bool DetectEngineBufferTypeSupportsPacketGetById(const DetectEngineCtx *de_ctx, const int id) { const DetectBufferType *map = DetectEngineBufferTypeGetById(de_ctx, id); diff --git a/src/detect-engine.h b/src/detect-engine.h index fadb6af09c..933222d3c9 100644 --- a/src/detect-engine.h +++ b/src/detect-engine.h @@ -75,6 +75,9 @@ bool DetectEngineBufferRunValidateCallback( const DetectEngineCtx *de_ctx, const int id, const Signature *s, const char **sigerror); bool DetectEngineBufferTypeValidateTransform(DetectEngineCtx *de_ctx, int sm_list, const uint8_t *content, uint16_t content_len, const char **namestr); +void DetectEngineBufferTypeSupportsPacket(DetectEngineCtx *de_ctx, const char *name); +void DetectEngineBufferTypeSupportsMpm(DetectEngineCtx *de_ctx, const char *name); +void DetectEngineBufferTypeSupportsTransformations(DetectEngineCtx *de_ctx, const char *name); /* prototypes */ DetectEngineCtx *DetectEngineCtxInitWithPrefix(const char *prefix);