diff --git a/src/feature.c b/src/feature.c index d759194f03..00806b62af 100644 --- a/src/feature.c +++ b/src/feature.c @@ -123,24 +123,30 @@ void ProvidesFeature(const char *feature_name) bool RequiresFeature(const char *feature_name) { - FeatureEntryType t = { 0, feature_name }; + FeatureEntryType f = { feature_name }; SCMutexLock(&feature_table_mutex); - FeatureEntryType *feature = HashTableLookup(feature_hash_table, &t, sizeof(t)); + FeatureEntryType *feature = HashListTableLookup(feature_hash_table, &f, sizeof(f)); SCMutexUnlock(&feature_table_mutex); - return feature != NULL; } void FeatureTrackingRelease(void) { if (feature_hash_table != NULL) { - HashTableFree(feature_hash_table); + HashListTableFree(feature_hash_table); feature_hash_table = NULL; - feature_table_id = 0; } } +void FeatureDump(void) +{ + HashListTableBucket *hb = HashListTableGetListHead(feature_hash_table); + for (; hb != NULL; hb = HashListTableGetListNext(hb)) { + FeatureEntryType *f = HashListTableGetListData(hb); + printf("provided feature name: %s\n", f->feature); + } +} void FeatureTrackingRegister(void) { FeatureInit(); diff --git a/src/feature.h b/src/feature.h index 3bb48a097e..6549c5bbea 100644 --- a/src/feature.h +++ b/src/feature.h @@ -30,6 +30,8 @@ void ProvidesFeature(const char *); bool RequiresFeature(const char *); +void FeatureDump(void); + void FeatureTrackingRelease(void); void FeatureTrackingRegister(void); diff --git a/src/runmodes.h b/src/runmodes.h index c1202b75c1..b437079009 100644 --- a/src/runmodes.h +++ b/src/runmodes.h @@ -56,6 +56,7 @@ enum RunModes { RUNMODE_REMOVE_SERVICE, RUNMODE_CHANGE_SERVICE_PARAMS, #endif + RUNMODE_DUMP_FEATURES, RUNMODE_MAX, }; diff --git a/src/suricata.c b/src/suricata.c index e06620d7ed..e0cd02cb9f 100644 --- a/src/suricata.c +++ b/src/suricata.c @@ -621,6 +621,7 @@ static void PrintUsage(const char *progname) printf("\t--init-errors-fatal : enable fatal failure on signature init error\n"); printf("\t--disable-detection : disable detection engine\n"); printf("\t--dump-config : show the running configuration\n"); + printf("\t--dump-features : display provided features\n"); printf("\t--build-info : display build information\n"); printf("\t--pcap[=] : run in pcap mode, no value select interfaces from suricata.yaml\n"); printf("\t--pcap-file-continuous : when running in pcap mode with a directory, continue checking directory for pcaps until interrupted\n"); @@ -1421,6 +1422,7 @@ static TmEcode ParseCommandLine(int argc, char** argv, SCInstance *suri) int opt; int dump_config = 0; + int dump_features = 0; int list_app_layer_protocols = 0; int list_unittests = 0; int list_runmodes = 0; @@ -1441,6 +1443,7 @@ static TmEcode ParseCommandLine(int argc, char** argv, SCInstance *suri) struct option long_opts[] = { {"dump-config", 0, &dump_config, 1}, + {"dump-features", 0, &dump_features, 1}, {"pfring", optional_argument, 0, 0}, {"pfring-int", required_argument, 0, 0}, {"pfring-cluster-id", required_argument, 0, 0}, @@ -2137,6 +2140,8 @@ static TmEcode ParseCommandLine(int argc, char** argv, SCInstance *suri) suri->run_mode = RUNMODE_LIST_UNITTEST; if (dump_config) suri->run_mode = RUNMODE_DUMP_CONFIG; + if (dump_features) + suri->run_mode = RUNMODE_DUMP_FEATURES; if (conf_test) suri->run_mode = RUNMODE_CONF_TEST; if (engine_analysis) @@ -3063,6 +3068,9 @@ int SuricataMain(int argc, char **argv) } else if (suricata.run_mode == RUNMODE_CONF_TEST){ SCLogNotice("Configuration provided was successfully loaded. Exiting."); goto out; + } else if (suricata.run_mode == RUNMODE_DUMP_FEATURES) { + FeatureDump(); + goto out; } SCSetStartTime(&suricata);