From f80623fd73e7d6df56bbc33f19218b4bc1e1e581 Mon Sep 17 00:00:00 2001 From: Victor Julien Date: Thu, 1 Sep 2016 15:07:31 +0200 Subject: [PATCH] prefilter: show prefilter capability in --list-keywords --- src/detect.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/detect.c b/src/detect.c index 30c62f6f39..521065c7ce 100644 --- a/src/detect.c +++ b/src/detect.c @@ -4020,8 +4020,10 @@ int SigGroupCleanup (DetectEngineCtx *de_ctx) return 0; } -static inline void PrintFeatureList(int flags, char sep) +static void PrintFeatureList(const SigTableElmt *e, char sep) { + const uint8_t flags = e->flags; + int prev = 0; if (flags & SIGMATCH_NOOPT) { printf("No option"); @@ -4045,18 +4047,24 @@ static inline void PrintFeatureList(int flags, char sep) printf("payload inspecting keyword"); prev = 1; } + if (e->SupportsPrefilter) { + if (prev == 1) + printf("%c", sep); + printf("prefilter"); + prev = 1; + } if (prev == 0) { printf("none"); } } -static inline void SigMultilinePrint(int i, char *prefix) +static void SigMultilinePrint(int i, char *prefix) { if (sigmatch_table[i].desc) { printf("%sDescription: %s\n", prefix, sigmatch_table[i].desc); } printf("%sFeatures: ", prefix); - PrintFeatureList(sigmatch_table[i].flags, ','); + PrintFeatureList(&sigmatch_table[i], ','); if (sigmatch_table[i].url) { printf("\n%sDocumentation: %s", prefix, sigmatch_table[i].url); } @@ -4079,7 +4087,7 @@ void SigTableList(const char *keyword) } } } - } else if (!strcmp("csv", keyword)) { + } else if (strcmp("csv", keyword) == 0) { printf("name;description;app layer;features;documentation\n"); for (i = 0; i < size; i++) { if (sigmatch_table[i].name != NULL) { @@ -4092,7 +4100,7 @@ void SigTableList(const char *keyword) } /* Build feature */ printf(";Unset;"); // this used to be alproto - PrintFeatureList(sigmatch_table[i].flags, ':'); + PrintFeatureList(&sigmatch_table[i], ':'); printf(";"); if (sigmatch_table[i].url) { printf("%s", sigmatch_table[i].url); @@ -4101,7 +4109,7 @@ void SigTableList(const char *keyword) printf("\n"); } } - } else if (!strcmp("all", keyword)) { + } else if (strcmp("all", keyword) == 0) { for (i = 0; i < size; i++) { if (sigmatch_table[i].name != NULL) { printf("%s:\n", sigmatch_table[i].name); @@ -4111,7 +4119,7 @@ void SigTableList(const char *keyword) } else { for (i = 0; i < size; i++) { if ((sigmatch_table[i].name != NULL) && - !strcmp(sigmatch_table[i].name, keyword)) { + strcmp(sigmatch_table[i].name, keyword) == 0) { printf("= %s =\n", sigmatch_table[i].name); if (sigmatch_table[i].flags & SIGMATCH_NOT_BUILT) { printf("Not built-in\n");