detect: unify FileMatch API with other calls

pull/2559/head
Victor Julien 8 years ago
parent fe415ae518
commit 5bafc64c08

@ -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) {

@ -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);

@ -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);

@ -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);

@ -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);

@ -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;

@ -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 *);

@ -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);

@ -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 *);

Loading…
Cancel
Save