detect/feature: Support --dump-features

pull/4568/head
Jeff Lucovsky 6 years ago committed by Victor Julien
parent 5e08e6bccf
commit 1519c1f006

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

@ -30,6 +30,8 @@
void ProvidesFeature(const char *);
bool RequiresFeature(const char *);
void FeatureDump(void);
void FeatureTrackingRelease(void);
void FeatureTrackingRegister(void);

@ -56,6 +56,7 @@ enum RunModes {
RUNMODE_REMOVE_SERVICE,
RUNMODE_CHANGE_SERVICE_PARAMS,
#endif
RUNMODE_DUMP_FEATURES,
RUNMODE_MAX,
};

@ -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[=<dev>] : 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);

Loading…
Cancel
Save