From 5bafc64c089daaa1d642d8765da5e1eada14641e Mon Sep 17 00:00:00 2001 From: Victor Julien Date: Fri, 23 Dec 2016 13:57:12 +0100 Subject: [PATCH] detect: unify FileMatch API with other calls --- src/detect-engine-file.c | 4 ++-- src/detect-fileext.c | 6 +++--- src/detect-filemagic.c | 6 +++--- src/detect-filename.c | 6 +++--- src/detect-filesize.c | 6 +++--- src/detect-filestore.c | 4 ++-- src/detect.h | 2 +- src/util-detect-file-hash.c | 4 ++-- src/util-detect-file-hash.h | 2 +- 9 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/detect-engine-file.c b/src/detect-engine-file.c index 9464799b4c..771a4c2983 100644 --- a/src/detect-engine-file.c +++ b/src/detect-engine-file.c @@ -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) { diff --git a/src/detect-fileext.c b/src/detect-fileext.c index eecc63ffe5..a052d97d75 100644 --- a/src/detect-fileext.c +++ b/src/detect-fileext.c @@ -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); diff --git a/src/detect-filemagic.c b/src/detect-filemagic.c index dbf1dd767e..34f6c6fca0 100644 --- a/src/detect-filemagic.c +++ b/src/detect-filemagic.c @@ -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); diff --git a/src/detect-filename.c b/src/detect-filename.c index 67b386b2f7..fcfff9b399 100644 --- a/src/detect-filename.c +++ b/src/detect-filename.c @@ -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); diff --git a/src/detect-filesize.c b/src/detect-filesize.c index 547ea38963..af08f48bae 100644 --- a/src/detect-filesize.c +++ b/src/detect-filesize.c @@ -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); diff --git a/src/detect-filestore.c b/src/detect-filestore.c index 6801e8cbf0..d64b9b44d8 100644 --- a/src/detect-filestore.c +++ b/src/detect-filestore.c @@ -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; diff --git a/src/detect.h b/src/detect.h index 2e01c5f3a2..3d3290cdcf 100644 --- a/src/detect.h +++ b/src/detect.h @@ -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 *); diff --git a/src/util-detect-file-hash.c b/src/util-detect-file-hash.c index e7e157bd9e..7ee4bd9568 100644 --- a/src/util-detect-file-hash.c +++ b/src/util-detect-file-hash.c @@ -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); diff --git a/src/util-detect-file-hash.h b/src/util-detect-file-hash.h index b8d5078934..68fd34dd6f 100644 --- a/src/util-detect-file-hash.h +++ b/src/util-detect-file-hash.h @@ -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 *);