Squashed commit of the following:
commit
9316db8c7d65535e9c18bbe2df04914760e8423e
Author: Bhagya Tholpady <bbantwal@cisco.com>
Date: Mon Nov 16 18:32:09 2020 -0500
managers: add inspector type in the help module output
void Inspector::rem_ref()
{ --ref_count[slot]; }
+
+static const char* InspectorTypeNames[IT_MAX] =
+{
+ "passive",
+ "wizard",
+ "packet",
+ "stream",
+ "network",
+ "service",
+ "control",
+ "probe"
+};
+
+const char* InspectApi::get_type(InspectorType type)
+{
+ if ( (type < IT_PASSIVE) or (type >= IT_MAX) )
+ return "";
+
+ return InspectorTypeNames[type];
+}
InspectDelFunc dtor; // release inspector instance
InspectSsnFunc ssn; // get new session tracker
InspectFunc reset; // clear stats
+
+ static const char* get_type(InspectorType type);
};
inline const char* Inspector::get_name() const
return v;
}
+const char* InspectorManager::get_inspector_type(const char* name)
+{
+ for ( const auto* p : s_handlers )
+ if ( !strcmp(p->api.base.name, name) )
+ return p->api.get_type(p->api.type);
+
+ return "";
+}
+
void InspectorManager::add_plugin(const InspectApi* api)
{
PHGlobal* g = new PHGlobal(*api);
static void release_plugins();
static std::vector<const InspectApi*> get_apis();
+ static const char* get_inspector_type(const char* name);
static void new_policy(InspectionPolicy*, InspectionPolicy*);
static void delete_policy(InspectionPolicy*, bool cloned);
#include "main/shell.h"
#include "main/snort.h"
#include "main/snort_config.h"
+#include "managers/inspector_manager.h"
#include "parser/parse_conf.h"
#include "parser/parser.h"
#include "profiler/profiler.h"
d.dump(mh->mod->get_name());
}
-static const char* mod_type(const BaseApi* api)
+static std::string mod_type(const BaseApi* api)
{
if ( !api )
return "basic";
- return PluginManager::get_type_name(api->type);
+ std::string type(PluginManager::get_type_name(api->type));
+
+ if ( api->type == PT_INSPECTOR )
+ {
+ std::string itype = InspectorManager::get_inspector_type(api->name);
+ if ( !itype.empty() )
+ type += " (" + itype + ")";
+ }
+
+ return type;
}
static const char* mod_use(Module::Usage use)
if ( const char* h = mod->get_help() )
help = h;
- const char* type = mod_type(mh->api);
+ std::string type = mod_type(mh->api);
const char* usage = mod_use(mod->get_usage());
json.open();