-- parsing fixes
-- updated config_changes.txt
-- fixed doc format and added errors.txt
+-- revised help options (again) to be more consistent with other (gnu style) programs
121
-- valgrind fixes
/*
** Copyright (C) 2014 Cisco and/or its affiliates. All rights reserved.
-** Copyright (C) 2013-2013 Sourcefire, Inc.
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License Version 2 as
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
+// help.cc author Russ Combs <rucombs@cisco.com>
#include "help.h"
#include <string>
using namespace std;
+#include "main.h"
#include "config_file.h"
#include "helpers/process.h"
#include "main/snort.h"
"\n"
"Snort has several options to get more help:\n"
"\n"
-"--help list command line options\n"
-"--help! this overview of help\n"
+"-? list command line options\n"
+"--help this overview of help\n"
"--help-builtin [<module prefix>] output matching builtin rules\n"
"--help-buffers output available inspection buffers\n"
"--help-commands [<module prefix>] output matching commands\n"
"++ IPS rules may also have a wild card parameter, which is indicated by a *.\n"
" Only used for metadata that Snort ignores.\n"
"++ The snort module has command line options starting with a -.\n"
+"\n"
+"Report bugs to bugs@snort.org.\n"
;
//-------------------------------------------------------------------------
exit(0);
}
-void help_usage(SnortConfig*, const char* val)
+void help_usage(SnortConfig*, const char*)
{
- fprintf(stdout, "USAGE: %s [-options]\n", "snort");
- help_args(val);
+ fprintf(stdout, "usage:\n");
+ fprintf(stdout, "%s [-options] -c conf [-T]: validate conf\n", "snort");
+ fprintf(stdout, "%s [-options] -c conf -i iface: process live\n", "snort");
+ fprintf(stdout, "%s [-options] -c conf -r pcap: process readback\n", "snort");
exit(1);
}
void list_interfaces(SnortConfig*, const char*)
{
- DisplayBanner();
PrintAllInterfaces();
exit(0);
}
#include "rules.h"
#include "treenodes.h"
#include "snort_debug.h"
-#include "main/snort_config.h"
#include "util.h"
#include "parser.h"
#include "packet_io/trough.h"
#include "packet_time.h"
#include "perf_monitor/perf_base.h"
#include "perf_monitor/perf.h"
-//#include "sflsq.h"
#include "ips_options/ips_flowbits.h"
#include "event_queue.h"
#include "framework/mpse.h"
+#include "main/build.h"
+#include "main/snort_config.h"
#include "main/shell.h"
#include "main/analyzer.h"
#include "managers/module_manager.h"
snort_cmd_line_conf = parse_cmd_line(argc, argv);
snort_conf = snort_cmd_line_conf;
- /* Tell 'em who wrote it, and what "it" is */
- if (!ScLogQuiet())
- PrintVersion();
-
- InitProtoNames();
- SFAT_Init();
-
+ LogMessage("--------------------------------------------------\n");
+ LogMessage("o\")~ Snort++ %s-%s\n", VERSION, BUILD);
LogMessage("--------------------------------------------------\n");
ModuleManager::init();
ScriptManager::load_scripts(snort_cmd_line_conf->script_path);
PluginManager::load_plugins(snort_cmd_line_conf->plugin_path);
- ModuleManager::dump_modules();
- PluginManager::dump_plugins();
+
+ if ( snort_conf->run_flags & RUN_FLAG__SHOW_PLUGINS )
+ {
+ ModuleManager::dump_modules();
+ PluginManager::dump_plugins();
+ }
+
+ InitProtoNames();
+ SFAT_Init();
FileAPIInit();
register_profiles();
RUN_FLAG__NO_PCRE = 0x01000000,
/* If stream5 is configured, the STATEFUL flag is set. This is
* somewhat misnamed and is used to assure a session is established */
- RUN_FLAG__ASSURE_EST = 0x02000000 /* config stateful */
+ RUN_FLAG__ASSURE_EST = 0x02000000,
+ RUN_FLAG__SHOW_PLUGINS = 0x04000000 // --show-plugins
,RUN_FLAG__TREAT_DROP_AS_IGNORE= 0x10000000, /* --treat-drop-as-ignore */
RUN_FLAG__PCAP_RELOAD = 0x20000000, /* --pcap-reload */
{ "--shell", Parameter::PT_IMPLIED, nullptr, nullptr,
"enable the interactive command line", },
+ { "--show-plugins", Parameter::PT_IMPLIED, nullptr, nullptr,
+ "list module and plugin versions", },
+
{ "--skip", Parameter::PT_INT, "0:", nullptr,
"<n> skip 1st n packets", },
bool SnortModule::set(const char*, Value& v, SnortConfig* sc)
{
if ( v.is("-?") )
- help_usage(sc, v.get_string());
+ help_options(sc, v.get_string());
else if ( v.is("-A") )
config_alert_mode(sc, v.get_string());
sc->run_flags |= RUN_FLAG__INLINE_TEST;
else if ( v.is("--help") )
- help_usage(sc, v.get_string());
-
- else if ( v.is("--help!") )
help_basic(sc, v.get_string());
else if ( v.is("--help-builtin") )
else if ( v.is("--shell") )
sc->run_flags |= RUN_FLAG__SHELL;
+ else if ( v.is("--show-plugins") )
+ sc->run_flags |= RUN_FLAG__SHOW_PLUGINS;
+
else if ( v.is("--skip") )
sc->pkt_skip = v.get_long();
return;
}
s_modules.sort(comp_gids);
+ unsigned c = 0;
for ( auto p : s_modules )
{
cout << endl << "Peg counts: " << endl << endl;
show_pegs(name);
}
+ c++;
}
+ if ( !c )
+ cout << "no match" << endl;
}
void ModuleManager::show_configs(const char* pfx, bool exact)
{
s_modules.sort(comp_mods);
+ unsigned c = 0;
for ( auto p : s_modules )
{
}
if ( !pfx )
cout << endl;
+
+ c++;
}
+ if ( !c )
+ cout << "no match" << endl;
}
void ModuleManager::show_commands(const char* pfx)
{
s_modules.sort(comp_mods);
unsigned len = pfx ? strlen(pfx) : 0;
+ unsigned n = 0;
for ( auto p : s_modules )
{
cout << endl;
c++;
}
+ n++;
}
+ if ( !n )
+ cout << "no match" << endl;
}
void ModuleManager::show_gids(const char* pfx)
{
s_modules.sort(comp_gids);
unsigned len = pfx ? strlen(pfx) : 0;
+ unsigned c = 0;
for ( auto p : s_modules )
{
cout << ": " << Markup::sanitize(m->get_name());
cout << endl;
}
+ c++;
}
+ if ( !c )
+ cout << "no match" << endl;
}
void ModuleManager::show_pegs(const char* pfx)
{
s_modules.sort(comp_gids);
unsigned len = pfx ? strlen(pfx) : 0;
+ unsigned c = 0;
for ( auto p : s_modules )
{
cout << endl;
++pegs;
}
+ c++;
}
+ if ( !c )
+ cout << "no match" << endl;
}
void ModuleManager::show_rules(const char* pfx)
{
s_modules.sort(comp_gids);
unsigned len = pfx ? strlen(pfx) : 0;
+ unsigned c = 0;
for ( auto p : s_modules )
{
cout << endl;
r++;
}
+ c++;
}
+ if ( !c )
+ cout << "no match" << endl;
}
void ModuleManager::load_commands(SnortConfig* sc)
{
s_modules.sort(comp_gids);
unsigned len = pfx ? strlen(pfx) : 0;
+ unsigned c = 0;
for ( auto p : s_modules )
{
r++;
}
+ c++;
}
+ if ( !c )
+ cout << "no match" << endl;
}
void ModuleManager::dump_stats (SnortConfig*)
#include <string>
using namespace std;
+#include "main/help.h"
#include "main/snort_module.h"
#include "framework/module.h"
#include "framework/parameter.h"
ArgList al(argc, argv);
const char* key, *val;
+ unsigned c = 0;
// get special options first
while ( al.get_arg(key, val) )
+ {
::set(key, val, sc, false);
+ c++;
+ }
// now get the rest
al.reset();
while ( al.get_arg(key, val) )
+ {
::set(key, val, sc, true);
+ c++;
+ }
- check_flags(sc);
+ if ( !c )
+ help_usage(sc, "");
+ else
+ check_flags(sc);
if ( int k = get_parse_errors() )
FatalError("see prior %d errors\n", k);
UpdateFlowIPState(&sfFlow, &flow->client_ip,
&flow->server_ip, SFS_STATE_UDP_CREATED);
- flow->s5_state.direction = FROM_SENDER;
-
if ( flow_con->expected_flow(flow, p) )
return false;