]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
detect: unify FileMatch API with other calls
authorVictor Julien <victor@inliniac.net>
Fri, 23 Dec 2016 12:57:12 +0000 (13:57 +0100)
committerVictor Julien <victor@inliniac.net>
Thu, 16 Feb 2017 09:35:43 +0000 (10:35 +0100)
src/detect-engine-file.c
src/detect-fileext.c
src/detect-filemagic.c
src/detect-filename.c
src/detect-filesize.c
src/detect-filestore.c
src/detect.h
src/util-detect-file-hash.c
src/util-detect-file-hash.h

index 9464799b4c05d445c2b42cb8c7d102c5911ec4e3..771a4c2983bfd5cfbba8921f16b24f1ce16fb4da 100644 (file)
@@ -152,7 +152,7 @@ static int DetectFileInspect(ThreadVars *tv, DetectEngineThreadCtx *det_ctx,
                 if (sigmatch_table[smd->type].FileMatch != NULL) {
                     KEYWORD_PROFILING_START;
                     match = sigmatch_table[smd->type].
-                        FileMatch(tv, det_ctx, f, flags, file, s, smd);
+                        FileMatch(tv, det_ctx, f, flags, file, s, smd->ctx);
                     KEYWORD_PROFILING_END(det_ctx, smd->type, (match > 0));
                     if (match == 0) {
                         r = DETECT_ENGINE_INSPECT_SIG_CANT_MATCH;
@@ -191,7 +191,7 @@ static int DetectFileInspect(ThreadVars *tv, DetectEngineThreadCtx *det_ctx,
             if (fd->scope > FILESTORE_SCOPE_DEFAULT) {
                 KEYWORD_PROFILING_START;
                 match = sigmatch_table[smd->type].
-                    FileMatch(tv, det_ctx, f, flags, /* no file */NULL, s, smd);
+                    FileMatch(tv, det_ctx, f, flags, /* no file */NULL, s, smd->ctx);
                 KEYWORD_PROFILING_END(det_ctx, smd->type, (match > 0));
 
                 if (match == 1) {
index eecc63ffe5d1cd16bc849f8100245f7ff1dae909..a052d97d752303e42082bbe31237f74392be866f 100644 (file)
@@ -52,7 +52,7 @@
 #include "detect-fileext.h"
 
 static int DetectFileextMatch (ThreadVars *, DetectEngineThreadCtx *, Flow *,
-        uint8_t, File *, const Signature *, const SigMatchData *);
+        uint8_t, File *, const Signature *, const SigMatchCtx *);
 static int DetectFileextSetup (DetectEngineCtx *, Signature *, char *);
 static void DetectFileextRegisterTests(void);
 static void DetectFileextFree(void *);
@@ -92,12 +92,12 @@ void DetectFileextRegister(void)
  * \retval 1 match
  */
 static int DetectFileextMatch (ThreadVars *t, DetectEngineThreadCtx *det_ctx,
-        Flow *f, uint8_t flags, File *file, const Signature *s, const SigMatchData *m)
+        Flow *f, uint8_t flags, File *file, const Signature *s, const SigMatchCtx *m)
 {
     SCEnter();
     int ret = 0;
 
-    DetectFileextData *fileext = (DetectFileextData *)m->ctx;
+    DetectFileextData *fileext = (DetectFileextData *)m;
 
     if (file->name == NULL)
         SCReturnInt(0);
index dbf1dd767e4962a0402d38db98464748f60e401f..34f6c6fca0ced6c15e341583a3092e7252252ac9 100644 (file)
@@ -76,7 +76,7 @@ void DetectFilemagicRegister(void)
 #else /* HAVE_MAGIC */
 
 static int DetectFilemagicMatch (ThreadVars *, DetectEngineThreadCtx *, Flow *,
-        uint8_t, File *, const Signature *, const SigMatchData *);
+        uint8_t, File *, const Signature *, const SigMatchCtx *);
 static int DetectFilemagicSetup (DetectEngineCtx *, Signature *, char *);
 static void DetectFilemagicRegisterTests(void);
 static void DetectFilemagicFree(void *);
@@ -179,11 +179,11 @@ int FilemagicThreadLookup(magic_t *ctx, File *file)
  * \retval 1 match
  */
 static int DetectFilemagicMatch (ThreadVars *t, DetectEngineThreadCtx *det_ctx,
-        Flow *f, uint8_t flags, File *file, const Signature *s, const SigMatchData *m)
+        Flow *f, uint8_t flags, File *file, const Signature *s, const SigMatchCtx *m)
 {
     SCEnter();
     int ret = 0;
-    DetectFilemagicData *filemagic = (DetectFilemagicData *)m->ctx;
+    DetectFilemagicData *filemagic = (DetectFilemagicData *)m;
 
     if (file->txid < det_ctx->tx_id)
         SCReturnInt(0);
index 67b386b2f76a7c4de6b880a2f07f24cce450ccdd..fcfff9b3997f0517d2a97a57d79b691dc69a22af 100644 (file)
@@ -53,7 +53,7 @@
 #include "app-layer-parser.h"
 
 static int DetectFilenameMatch (ThreadVars *, DetectEngineThreadCtx *, Flow *,
-        uint8_t, File *, const Signature *, const SigMatchData *);
+        uint8_t, File *, const Signature *, const SigMatchCtx *);
 static int DetectFilenameSetup (DetectEngineCtx *, Signature *, char *);
 static void DetectFilenameRegisterTests(void);
 static void DetectFilenameFree(void *);
@@ -104,12 +104,12 @@ void DetectFilenameRegister(void)
  * \retval 1 match
  */
 static int DetectFilenameMatch (ThreadVars *t, DetectEngineThreadCtx *det_ctx,
-        Flow *f, uint8_t flags, File *file, const Signature *s, const SigMatchData *m)
+        Flow *f, uint8_t flags, File *file, const Signature *s, const SigMatchCtx *m)
 {
     SCEnter();
     int ret = 0;
 
-    DetectFilenameData *filename = (DetectFilenameData *)m->ctx;
+    DetectFilenameData *filename = (DetectFilenameData *)m;
 
     if (file->name == NULL)
         SCReturnInt(0);
index 547ea38963e9804cd4f53f53c219d763ee1f3454..af08f48baec4c51e71266f92afbd7527570a8476 100644 (file)
@@ -50,7 +50,7 @@ static pcre_extra *parse_regex_study;
 
 /*prototypes*/
 static int DetectFilesizeMatch (ThreadVars *t, DetectEngineThreadCtx *det_ctx, Flow *f,
-        uint8_t flags, File *file, const Signature *s, const SigMatchData *m);
+        uint8_t flags, File *file, const Signature *s, const SigMatchCtx *m);
 static int DetectFilesizeSetup (DetectEngineCtx *, Signature *, char *);
 static void DetectFilesizeFree (void *);
 static void DetectFilesizeRegisterTests (void);
@@ -91,11 +91,11 @@ void DetectFilesizeRegister(void)
  * \retval 1 match
  */
 static int DetectFilesizeMatch (ThreadVars *t, DetectEngineThreadCtx *det_ctx, Flow *f,
-        uint8_t flags, File *file, const Signature *s, const SigMatchData *m)
+        uint8_t flags, File *file, const Signature *s, const SigMatchCtx *m)
 {
     SCEnter();
 
-    DetectFilesizeData *fsd = (DetectFilesizeData *)m->ctx;
+    DetectFilesizeData *fsd = (DetectFilesizeData *)m;
     int ret = 0;
     uint64_t file_size = FileTrackedSize(file);
 
index 6801e8cbf0ac20070f74093c147bc5c7d01d8ca4..d64b9b44d881fafa5dfa1d670c246f5d45114809 100644 (file)
@@ -60,7 +60,7 @@ static pcre *parse_regex;
 static pcre_extra *parse_regex_study;
 
 static int DetectFilestoreMatch (ThreadVars *, DetectEngineThreadCtx *,
-        Flow *, uint8_t, File *, const Signature *, const SigMatchData *);
+        Flow *, uint8_t, File *, const Signature *, const SigMatchCtx *);
 static int DetectFilestoreSetup (DetectEngineCtx *, Signature *, char *);
 static void DetectFilestoreFree(void *);
 static void DetectFilestoreRegisterTests(void);
@@ -249,7 +249,7 @@ int DetectFilestorePostMatch(ThreadVars *t, DetectEngineThreadCtx *det_ctx, Pack
  *       needs to be put behind a api.
  */
 static int DetectFilestoreMatch (ThreadVars *t, DetectEngineThreadCtx *det_ctx, Flow *f,
-        uint8_t flags, File *file, const Signature *s, const SigMatchData *m)
+        uint8_t flags, File *file, const Signature *s, const SigMatchCtx *m)
 {
     uint16_t file_id = 0;
 
index 2e01c5f3a2b8a1b8893eb296a0b789cc5a655f38..3d3290cdcf44ba04fbdf71b2ef03150c672073c7 100644 (file)
@@ -927,7 +927,7 @@ typedef struct SigTableElmt_ {
     int (*FileMatch)(ThreadVars *,  /**< thread local vars */
         DetectEngineThreadCtx *,
         Flow *,                     /**< *LOCKED* flow */
-        uint8_t flags, File *, const Signature *, const SigMatchData *);
+        uint8_t flags, File *, const Signature *, const SigMatchCtx *);
 
     /** keyword setup function pointer */
     int (*Setup)(DetectEngineCtx *, Signature *, char *);
index e7e157bd9eef1a45a00042c0364825f977a98fce..7ee4bd9568787f4c16a84d27ac15c1e932c591e2 100644 (file)
@@ -147,11 +147,11 @@ static int HashMatchHashTable(ROHashTable *hash_table, uint8_t *hash,
  * \retval 1 match
  */
 int DetectFileHashMatch (ThreadVars *t, DetectEngineThreadCtx *det_ctx,
-        Flow *f, uint8_t flags, File *file, const Signature *s, const SigMatchData *m)
+        Flow *f, uint8_t flags, File *file, const Signature *s, const SigMatchCtx *m)
 {
     SCEnter();
     int ret = 0;
-    DetectFileHashData *filehash = (DetectFileHashData *)m->ctx;
+    DetectFileHashData *filehash = (DetectFileHashData *)m;
 
     if (file->txid < det_ctx->tx_id) {
         SCReturnInt(0);
index b8d50789344e5ebcb45d045736536e08b51ba20b..68fd34dd6fd6b728ccd5aca59e2a8214f81e3833 100644 (file)
@@ -38,7 +38,7 @@ int ReadHashString(uint8_t *, char *, char *, int, uint16_t);
 int LoadHashTable(ROHashTable *, char *, char *, int, uint32_t);
 
 int DetectFileHashMatch(ThreadVars *, DetectEngineThreadCtx *, Flow *, uint8_t,
-        File *, const Signature *, const SigMatchData *);
+        File *, const Signature *, const SigMatchCtx *);
 int DetectFileHashSetup(DetectEngineCtx *, Signature *, char *, uint32_t, int);
 void DetectFileHashFree(void *);