From 11e55fe7d9e23605c5c61c9b2d22eb5195073c3d Mon Sep 17 00:00:00 2001 From: Pavel Odintsov Date: Tue, 27 Jan 2015 12:53:55 +0300 Subject: [PATCH] Add ability to read main config file from plugins --- example_plugin/example_collector.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/example_plugin/example_collector.cpp b/example_plugin/example_collector.cpp index 064f68c..7dc61d5 100644 --- a/example_plugin/example_collector.cpp +++ b/example_plugin/example_collector.cpp @@ -10,7 +10,10 @@ // For support uint32_t, uint16_t #include -//#include + +// For config map operations +#include +#include // For support: IPPROTO_TCP, IPPROTO_ICMP, IPPROTO_UDP #include @@ -22,6 +25,9 @@ // Get log4cpp logger from main programm extern log4cpp::Category& logger; +// Global configuration map +extern std::map configuration_map; + // This variable name should be uniq for every plugin! process_packet_pointer example_process_func_ptr = NULL; @@ -29,6 +35,12 @@ void start_example_collection(process_packet_pointer func_ptr) { logger<< log4cpp::Priority::INFO<<"Example plugin started"; example_process_func_ptr = func_ptr; + std::string example_plugin_config_param = ""; + + if (configuration_map.count("some_plugin_param_from_global_config") != 0) { + example_plugin_config_param = configuration_map[ "some_plugin_param_from_global_config" ]; + } + // We should fill this structure for passing to FastNetMon simple_packet current_packet;