From: Mats Klepsland Date: Fri, 23 Mar 2018 23:31:25 +0000 (+0100) Subject: detect-engine: add DetectEngineCtx to setup callback function X-Git-Tag: suricata-4.1.0-rc1~105 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=321603de37439d78e913b2d407a6ae8723f2c017;p=thirdparty%2Fsuricata.git detect-engine: add DetectEngineCtx to setup callback function Add detect engine context as variable to setup callback function in 'DetectBufferTypeRegisterSetupCallback'. --- diff --git a/src/detect-engine.c b/src/detect-engine.c index 917855b551..4cadfa523e 100644 --- a/src/detect-engine.c +++ b/src/detect-engine.c @@ -764,7 +764,7 @@ bool DetectBufferTypeSupportsMpmGetById(const DetectEngineCtx *de_ctx, const int } void DetectBufferTypeRegisterSetupCallback(const char *name, - void (*SetupCallback)(Signature *)) + void (*SetupCallback)(const DetectEngineCtx *, Signature *)) { BUG_ON(g_buffer_type_reg_closed); DetectBufferTypeRegister(name); @@ -778,7 +778,7 @@ void DetectBufferRunSetupCallback(const DetectEngineCtx *de_ctx, { const DetectBufferType *map = DetectBufferTypeGetById(de_ctx, id); if (map && map->SetupCallback) { - map->SetupCallback(s); + map->SetupCallback(de_ctx, s); } } diff --git a/src/detect-engine.h b/src/detect-engine.h index fca7902409..b9ff1115d7 100644 --- a/src/detect-engine.h +++ b/src/detect-engine.h @@ -46,7 +46,7 @@ void DetectBufferTypeCloseRegistration(void); void DetectBufferTypeSetDescriptionByName(const char *name, const char *desc); const char *DetectBufferTypeGetDescriptionByName(const char *name); void DetectBufferTypeRegisterSetupCallback(const char *name, - void (*Callback)(Signature *)); + void (*Callback)(const DetectEngineCtx *, Signature *)); void DetectBufferTypeRegisterValidateCallback(const char *name, _Bool (*ValidateCallback)(const Signature *, const char **sigerror)); diff --git a/src/detect-file-data.c b/src/detect-file-data.c index 3d7f370748..3bd7a4c15a 100644 --- a/src/detect-file-data.c +++ b/src/detect-file-data.c @@ -51,7 +51,8 @@ static int DetectFiledataSetup (DetectEngineCtx *, Signature *, const char *); static void DetectFiledataRegisterTests(void); -static void DetectFiledataSetupCallback(Signature *s); +static void DetectFiledataSetupCallback(const DetectEngineCtx *de_ctx, + Signature *s); static int g_file_data_buffer_id = 0; /** @@ -174,7 +175,8 @@ static int DetectFiledataSetup (DetectEngineCtx *de_ctx, Signature *s, const cha return 0; } -static void DetectFiledataSetupCallback(Signature *s) +static void DetectFiledataSetupCallback(const DetectEngineCtx *de_ctx, + Signature *s) { if (s->alproto == ALPROTO_HTTP || s->alproto == ALPROTO_UNKNOWN) { AppLayerHtpEnableRequestBodyCallback(); diff --git a/src/detect-http-client-body.c b/src/detect-http-client-body.c index aa8c87c280..8cb84325eb 100644 --- a/src/detect-http-client-body.c +++ b/src/detect-http-client-body.c @@ -61,7 +61,8 @@ static int DetectHttpClientBodySetup(DetectEngineCtx *, Signature *, const char *); static void DetectHttpClientBodyRegisterTests(void); static void DetectHttpClientBodyFree(void *); -static void DetectHttpClientBodySetupCallback(Signature *s); +static void DetectHttpClientBodySetupCallback(const DetectEngineCtx *de_ctx, + Signature *s); static int g_http_client_body_buffer_id = 0; /** @@ -95,7 +96,8 @@ void DetectHttpClientBodyRegister(void) g_http_client_body_buffer_id = DetectBufferTypeGetByName("http_client_body"); } -static void DetectHttpClientBodySetupCallback(Signature *s) +static void DetectHttpClientBodySetupCallback(const DetectEngineCtx *de_ctx, + Signature *s) { SCLogDebug("callback invoked by %u", s->id); AppLayerHtpEnableRequestBodyCallback(); diff --git a/src/detect-http-raw-uri.c b/src/detect-http-raw-uri.c index 7f9bc4a741..d008a5db59 100644 --- a/src/detect-http-raw-uri.c +++ b/src/detect-http-raw-uri.c @@ -58,7 +58,8 @@ static int DetectHttpRawUriSetup(DetectEngineCtx *, Signature *, const char *); static void DetectHttpRawUriRegisterTests(void); -static void DetectHttpRawUriSetupCallback(Signature *s); +static void DetectHttpRawUriSetupCallback(const DetectEngineCtx *de_ctx, + Signature *s); static bool DetectHttpRawUriValidateCallback(const Signature *s, const char **); static int g_http_raw_uri_buffer_id = 0; @@ -118,7 +119,8 @@ static bool DetectHttpRawUriValidateCallback(const Signature *s, const char **si return DetectUrilenValidateContent(s, g_http_raw_uri_buffer_id, sigerror); } -static void DetectHttpRawUriSetupCallback(Signature *s) +static void DetectHttpRawUriSetupCallback(const DetectEngineCtx *de_ctx, + Signature *s) { SCLogDebug("callback invoked by %u", s->id); DetectUrilenApplyToContent(s, g_http_raw_uri_buffer_id); diff --git a/src/detect-http-uri.c b/src/detect-http-uri.c index 2fe21da726..209a96195e 100644 --- a/src/detect-http-uri.c +++ b/src/detect-http-uri.c @@ -58,7 +58,8 @@ #include "stream-tcp.h" static void DetectHttpUriRegisterTests(void); -static void DetectHttpUriSetupCallback(Signature *s); +static void DetectHttpUriSetupCallback(const DetectEngineCtx *de_ctx, + Signature *s); static bool DetectHttpUriValidateCallback(const Signature *s, const char **sigerror); static int g_http_uri_buffer_id = 0; @@ -122,7 +123,8 @@ static bool DetectHttpUriValidateCallback(const Signature *s, const char **siger return DetectUrilenValidateContent(s, g_http_uri_buffer_id, sigerror); } -static void DetectHttpUriSetupCallback(Signature *s) +static void DetectHttpUriSetupCallback(const DetectEngineCtx *de_ctx, + Signature *s) { SCLogDebug("callback invoked by %u", s->id); DetectUrilenApplyToContent(s, g_http_uri_buffer_id); diff --git a/src/detect.h b/src/detect.h index 311f367404..8776d4725e 100644 --- a/src/detect.h +++ b/src/detect.h @@ -421,7 +421,7 @@ typedef struct DetectBufferType_ { _Bool mpm; _Bool packet; /**< compat to packet matches */ bool supports_transforms; - void (*SetupCallback)(struct Signature_ *); + void (*SetupCallback)(const struct DetectEngineCtx_ *, struct Signature_ *); bool (*ValidateCallback)(const struct Signature_ *, const char **sigerror); DetectEngineTransforms transforms; } DetectBufferType;