]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
detect-engine: add DetectEngineCtx to setup callback function
authorMats Klepsland <mats.klepsland@gmail.com>
Fri, 23 Mar 2018 23:31:25 +0000 (00:31 +0100)
committerVictor Julien <victor@inliniac.net>
Thu, 3 May 2018 12:50:47 +0000 (14:50 +0200)
Add detect engine context as variable to setup callback function
in 'DetectBufferTypeRegisterSetupCallback'.

src/detect-engine.c
src/detect-engine.h
src/detect-file-data.c
src/detect-http-client-body.c
src/detect-http-raw-uri.c
src/detect-http-uri.c
src/detect.h

index 917855b551e99c6ee0c56a25eea645673eb343a4..4cadfa523ecd0d9eb858275c83380c4b83e78b0c 100644 (file)
@@ -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);
     }
 }
 
index fca7902409522d66970c545e0c8e9d60b9505006..b9ff1115d79aed1a851ac2dfebf0ca504a481184 100644 (file)
@@ -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));
 
index 3d7f370748a030f45477c390429363b2ed51ae0b..3bd7a4c15a16441c6c74762e214ec9efa2af92aa 100644 (file)
@@ -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();
index aa8c87c2802670e5bc83750ce9016fd695d8b7a3..8cb84325eb7da24d3cf102e5f6c9f7dba7aa0c18 100644 (file)
@@ -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();
index 7f9bc4a74182184ba9b623311a3f5b3b2913262f..d008a5db59f8b011ff57beb8997782f3fdbd5329 100644 (file)
@@ -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);
index 2fe21da726cb2523d8337c2612defbe71061cc76..209a96195ec1c0f5e2b639cf5040f0e05966305a 100644 (file)
@@ -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);
index 311f36740480537bdcca32c417c6a7271db2bf0e..8776d4725e600a376de19e453a56ab99c2ab282e 100644 (file)
@@ -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;