2626 *
2727 */
2828
29- #include " ipfixprobe.hpp"
30-
3129#include " buildConfig.hpp"
30+ #include " ipfixprobe.hpp"
3231
3332#include < fstream>
3433#include < future>
4746#endif
4847#include " stats.hpp"
4948
49+ #include < ipfixprobe/pluginFactory/pluginFactory.hpp>
50+
5051namespace ipxp {
5152
5253volatile sig_atomic_t stop = 0 ;
@@ -90,56 +91,38 @@ void error(std::string msg)
9091 std::cerr << " Error: " << msg << std::endl;
9192}
9293
93- template <typename T>
94- static void print_plugins_help (std::vector<Plugin*>& plugins)
94+ static void printPluginsUsage (const std::vector<PluginManifest>& pluginsManifest)
9595{
96- for (auto & it : plugins) {
97- if (dynamic_cast <T*>(it)) {
98- OptionsParser* parser = it->get_parser ();
99- parser->usage (std::cout);
100- std::cout << std::endl;
101- delete parser;
96+ for (const auto & pluginManifest : pluginsManifest) {
97+ if (pluginManifest.usage ) {
98+ pluginManifest.usage ();
10299 }
103100 }
104101}
105102
106103void print_help (ipxp_conf_t & conf, const std::string& arg)
107104{
108- auto deleter = [&](std::vector<Plugin*>* p) {
109- for (auto & it : *p) {
110- delete it;
111- }
112- delete p;
113- };
114- auto plugins = std::unique_ptr<std::vector<Plugin*>, decltype (deleter)>(
115- new std::vector<Plugin*>(conf.mgr .get ()),
116- deleter);
117-
118105 if (arg == " input" ) {
119- print_plugins_help<InputPlugin>(*plugins);
120- } else if (arg == " storage" ) {
121- print_plugins_help<StoragePlugin>(*plugins);
122- } else if (arg == " output" ) {
123- print_plugins_help<OutputPlugin>(*plugins);
124- } else if (arg == " process" ) {
125- print_plugins_help<ProcessPlugin>(*plugins);
126- } else {
127- Plugin* p;
128- try {
129- p = conf.mgr .get (arg);
130- if (p == nullptr ) {
131- std::cout << " No help available for " << arg << std::endl;
132- return ;
133- }
134- } catch (PluginManagerError& e) {
135- error (std::string (" when loading plugin: " ) + e.what ());
136- return ;
137- }
138- OptionsParser* parser = p->get_parser ();
139- parser->usage (std::cout);
140- delete parser;
141- delete p;
106+ auto & inputPluginFactory = InputPluginFactory::getInstance ();
107+ return printPluginsUsage (inputPluginFactory.getRegisteredPlugins ());
108+ }
109+
110+ if (arg == " storage" ) {
111+ auto & storagePluginFactory = StoragePluginFactory::getInstance ();
112+ return printPluginsUsage (storagePluginFactory.getRegisteredPlugins ());
142113 }
114+
115+ if (arg == " output" ) {
116+ auto & outputPluginFactory = OutputPluginFactory::getInstance ();
117+ return printPluginsUsage (outputPluginFactory.getRegisteredPlugins ());
118+ }
119+
120+ if (arg == " process" ) {
121+ auto & processPluginFactory = ProcessPluginFactory::getInstance ();
122+ return printPluginsUsage (processPluginFactory.getRegisteredPlugins ());
123+ }
124+
125+ std::cerr << " No help available for " << arg << std::endl;
143126}
144127
145128void process_plugin_argline (
@@ -262,6 +245,7 @@ bool process_plugin_args(ipxp_conf_t& conf, IpfixprobeOptParser& parser)
262245 if (process_name == BASIC_PLUGIN_NAME) {
263246 continue ;
264247 }
248+ /*
265249 try {
266250 process_plugin = dynamic_cast<ProcessPlugin*>(conf.mgr.get(process_name));
267251 if (process_plugin == nullptr) {
@@ -279,6 +263,7 @@ bool process_plugin_args(ipxp_conf_t& conf, IpfixprobeOptParser& parser)
279263 } catch (PluginManagerError& e) {
280264 throw IPXPError(process_name + std::string(": ") + e.what());
281265 }
266+ */
282267 }
283268
284269 // telemetry
@@ -297,6 +282,7 @@ bool process_plugin_args(ipxp_conf_t& conf, IpfixprobeOptParser& parser)
297282 conf.holder .add (statsFile);
298283
299284 OutputPlugin* output_plugin = nullptr ;
285+ /*
300286 try {
301287 output_plugin = dynamic_cast<OutputPlugin*>(conf.mgr.get(output_name));
302288 if (output_plugin == nullptr) {
@@ -318,6 +304,7 @@ bool process_plugin_args(ipxp_conf_t& conf, IpfixprobeOptParser& parser)
318304 } catch (PluginManagerError& e) {
319305 throw IPXPError(output_name + std::string(": ") + e.what());
320306 }
307+ */
321308
322309 {
323310 std::promise<WorkerResult>* output_res = new std::promise<WorkerResult>();
@@ -360,6 +347,7 @@ bool process_plugin_args(ipxp_conf_t& conf, IpfixprobeOptParser& parser)
360347 auto pipeline_queue_dir
361348 = pipeline_dir->addDir (" queues" )->addDir (std::to_string (pipeline_idx));
362349
350+ /*
363351 try {
364352 input_plugin = dynamic_cast<InputPlugin*>(conf.mgr.get(input_name));
365353 if (input_plugin == nullptr) {
@@ -398,6 +386,7 @@ bool process_plugin_args(ipxp_conf_t& conf, IpfixprobeOptParser& parser)
398386 } catch (PluginManagerError& e) {
399387 throw IPXPError(storage_name + std::string(": ") + e.what());
400388 }
389+ */
401390
402391 std::vector<ProcessPlugin*> storage_process_plugins;
403392 for (auto & it : *process_plugins) {
@@ -638,6 +627,7 @@ int run(int argc, char* argv[])
638627 IpfixprobeOptParser parser;
639628 ipxp_conf_t conf;
640629 int status = EXIT_SUCCESS;
630+ const bool loadPluginsRecursive = true ;
641631
642632 register_handlers ();
643633
@@ -649,6 +639,8 @@ int run(int argc, char* argv[])
649639 goto EXIT;
650640 }
651641
642+ conf.pluginManager .loadPlugins (" /usr/local/lib64/ipfixprobe/" , loadPluginsRecursive);
643+
652644 if (parser.m_help ) {
653645 if (parser.m_help_str .empty ()) {
654646 parser.usage (std::cout, 0 , IPXP_APP_NAME);
0 commit comments