]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
added per module documentation
authorRuss Combs <rucombs@cisco.com>
Wed, 16 Jul 2014 01:45:13 +0000 (21:45 -0400)
committerRuss Combs <rucombs@cisco.com>
Wed, 16 Jul 2014 01:45:13 +0000 (21:45 -0400)
doc/Makefile.am
doc/snort_manual.txt
src/log/messages.cc
src/managers/module_manager.cc
src/managers/module_manager.h
src/parser/cmd_line.cc

index ecda761c5c20abb1e9f99038fba9f682d3e4f025..cba73eceb9629df156a7c8e798f1946124766ef0 100644 (file)
@@ -7,6 +7,7 @@ builtin.txt \
 commands.txt \
 config.txt \
 gids.txt \
+modules.txt \
 options.txt \
 version.txt
 
@@ -53,6 +54,11 @@ config.txt: $(snort)
 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 > $@
 
index 014e3c0fad6d5b2a88b1eb5d65e305db8bba950f..d0ba037b01606ce4f37acc475d979a9d524f437a 100644 (file)
@@ -18,6 +18,10 @@ include::tips.txt[]
 
 include::differences.txt[]
 
+== Modules
+
+include::modules.txt[]
+
 == Command Line Options
 
 include::options.txt[]
index aa61514d02d8343fe1356df6ee41bb74f506c109..2d60d571692c11b7ffdbc29167e1226ee9bbc0ca 100644 (file)
@@ -54,7 +54,7 @@ static int already_fatal = 0;
 /*
  * 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
@@ -69,7 +69,7 @@ void LogMessage(const char *format,...)
     if (snort_conf == NULL)
     {
         va_start(ap, format);
-        vfprintf(stderr, format, ap);
+        vfprintf(stdout, format, ap);
         va_end(ap);
         return;
     }
@@ -86,7 +86,7 @@ void LogMessage(const char *format,...)
     }
     else
     {
-        vfprintf(stderr, format, ap);
+        vfprintf(stdout, format, ap);
     }
 
     va_end(ap);
index 32181f7647a6bee69763914026ddd5648cece3e3..1ee4f63510b5f40f44b87b9ebbea2d61f7e16c3f 100644 (file)
@@ -65,6 +65,9 @@ static bool s_markup = false;
 // markup foo (for asciidoc)
 //-------------------------------------------------------------------------
 
+static const char* head()
+{ return s_markup ? "=== " : ""; }
+
 static const char* item()
 { return s_markup ? "* " : ""; }
 
@@ -483,6 +486,14 @@ unsigned ModuleManager::get_errors()
     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);
@@ -493,6 +504,28 @@ void ModuleManager::dump_modules()
             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);
@@ -506,32 +539,33 @@ void ModuleManager::show_module(bool markup, const char* name)
         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);
         }
     }
index 7dce1a4ff6d099bc06838459939bdd520505bde0..575d7a12ee95a1d432394030a74d47fbdd17efab 100644 (file)
@@ -35,12 +35,15 @@ public:
     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*);
 
index 460c17ff1362b6153b8824634db4783629a1550c..d9764872372f737b6e3cf6a70036511a87a5e940 100644 (file)
@@ -257,7 +257,7 @@ static void config_help_signals(SnortConfig*, const char*)
     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)
 {
@@ -285,6 +285,9 @@ 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();
@@ -327,6 +330,11 @@ static void config_help_module(SnortConfig* sc, const char* val)
     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);
@@ -803,6 +811,9 @@ static ConfigFunc basic_opts[] =
     { "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" },