commands.txt \
config.txt \
gids.txt \
+modules.txt \
options.txt \
version.txt
gids.txt: $(snort)
$(snort) --markup --help-gids | sort -n -k 1.4 > $@
+modules.txt: $(snort)
+ for m in `$(snort) --list-modules` ; do \
+ $(snort) --markup --help-module $$m ; \
+ done > $@
+
options.txt: $(snort)
$(snort) --markup --help-options | sort > $@
include::differences.txt[]
+== Modules
+
+include::modules.txt[]
+
== Command Line Options
include::options.txt[]
/*
* Function: LogMessage(const char *, ...)
*
- * Purpose: Print a message to stderr or with logfacility.
+ * Purpose: Print a message to stdout or with logfacility.
*
* Arguments: format => the formatted error string to print out
* ... => format commands/fillers
if (snort_conf == NULL)
{
va_start(ap, format);
- vfprintf(stderr, format, ap);
+ vfprintf(stdout, format, ap);
va_end(ap);
return;
}
}
else
{
- vfprintf(stderr, format, ap);
+ vfprintf(stdout, format, ap);
}
va_end(ap);
// markup foo (for asciidoc)
//-------------------------------------------------------------------------
+static const char* head()
+{ return s_markup ? "=== " : ""; }
+
static const char* item()
{ return s_markup ? "* " : ""; }
return err;
}
+void ModuleManager::list_modules()
+{
+ s_modules.sort(comp_mods);
+
+ for ( auto* p : s_modules )
+ LogMessage("%s\n", p->mod->get_name());
+}
+
void ModuleManager::dump_modules()
{
s_modules.sort(comp_mods);
d.dump(p->mod->get_name());
}
+static const char* mod_types[PT_MAX] =
+{
+ "data",
+ "codec",
+ "logger",
+ "ips option",
+ "so rule",
+ "inspector",
+ "search engine"
+};
+
+static const char* mod_type(const BaseApi* api)
+{
+ if ( !api )
+ return "basic";
+
+ if ( api->type > PT_MAX )
+ return "error";
+
+ return mod_types[api->type];
+}
+
void ModuleManager::show_module(bool markup, const char* name)
{
s_modules.sort(comp_gids);
if ( strcmp(m->get_name(), name) )
continue;
- LogMessage("\nModule: %s\n", name);
+ cout << endl << head() << name << endl << endl;
+ cout << "Type: " << mod_type(p->api) << endl << endl;
if ( const Parameter* p = m->get_parameters() )
{
if ( p->type < Parameter::PT_MAX )
{
- LogMessage("\nConfiguration:\n");
+ cout << endl << "Configuration: " << endl << endl;
show_configs(markup, name);
}
}
if ( m->get_commands() )
{
- LogMessage("\nCommands:\n");
+ cout << endl << "Commands: " << endl << endl;
show_commands(markup, name);
}
if ( m->get_rules() )
{
- LogMessage("\nRules:\n");
+ cout << endl << "Rules: " << endl << endl;
show_rules(markup, name);
}
if ( m->get_pegs() )
{
- LogMessage("\nPeg counts:\n");
+ cout << endl << "Peg counts: " << endl << endl;
show_pegs(markup, name);
}
}
static void add_module(class Module*, const struct BaseApi* = nullptr);
static Module* get_module(const char*);
+ static void list_modules();
static void dump_modules();
+
static void show_module(bool markup, const char*);
static void show_configs(bool markup, const char* = nullptr);
static void show_commands(bool markup, const char* = nullptr);
static void show_gids(bool markup, const char* = nullptr);
static void show_pegs(bool markup, const char* = nullptr);
+
static void show_rules(bool markup, const char* = nullptr);
static void load_rules(SnortConfig*);
exit(0);
}
-enum HelpType { HT_CFG, HT_CMD, HT_GID, HT_IPS, HT_MOD, HT_BUF };
+enum HelpType { HT_CFG, HT_CMD, HT_GID, HT_IPS, HT_MOD, HT_BUF, HT_LST };
static void show_help(SnortConfig* sc, const char* val, HelpType ht)
{
case HT_BUF:
InspectorManager::dump_buffers();
break;
+ case HT_LST:
+ ModuleManager::list_modules();
+ break;
}
ModuleManager::term();
PluginManager::release_plugins();
show_help(sc, val, HT_MOD);
}
+static void config_list_modules(SnortConfig* sc, const char* val)
+{
+ show_help(sc, val, HT_LST);
+}
+
static void config_lua(SnortConfig*, const char* val)
{
Shell::set_overrides(val);
{ "help-signals", config_help_signals,
"dump available control signals" },
+ { "list-modules", config_list_modules,
+ "list all known modules" },
+
{ "lua", config_lua,
"<chunk> extend/override conf with chunk; may be repeated" },