22 #include "gossip_thread.h" 24 #include <plugins/gossip/gossip/gossip_group_manager.h> 30 #define CFG_PREFIX "/gossip/" 57 std::map<std::string, GossipGroupConfiguration> groups;
58 std::set<std::string> ignored_groups;
60 std::string prefix = CFG_PREFIX
"groups/";
62 std::shared_ptr<Configuration::ValueIterator> i(
config->
search(prefix.c_str()));
64 std::string cfg_name = std::string(i->path()).substr(prefix.length());
65 cfg_name = cfg_name.substr(0, cfg_name.find(
"/"));
67 if ( (groups.find(cfg_name) == groups.end()) &&
68 (ignored_groups.find(cfg_name) == ignored_groups.end()) ) {
70 std::string cfg_prefix = prefix + cfg_name +
"/";
79 std::string addr =
config->
get_string((cfg_prefix +
"broadcast-address").c_str());
81 if (
config->
exists((cfg_prefix +
"broadcast-send-port").c_str()) &&
82 config->
exists((cfg_prefix +
"broadcast-recv-port").c_str()) )
84 unsigned int send_port =
86 unsigned int recv_port =
89 if (send_port > 0xFFFF) {
90 throw Exception(
"Port number too high: %u > %u", send_port, 0xFFFF);
92 if (recv_port > 0xFFFF) {
93 throw Exception(
"Port number too high: %u > %u", recv_port, 0xFFFF);
98 unsigned int port =
config->
get_uint((cfg_prefix +
"broadcast-port").c_str());
101 throw Exception(
"Port number too high: %u > %u", port, 0xFFFF);
108 groups[cfg_name].crypto_key =
111 groups[cfg_name].crypto_cipher =
115 groups[cfg_name].crypto_cipher =
"aes-128-ecb";
118 groups[cfg_name].crypto_cipher.c_str(), cfg_name.c_str());
123 ignored_groups.insert(cfg_name);
135 gossip_aspect_inifin_.
set_manager(group_mgr_.get());
virtual void loop()
Code to execute in the thread.
virtual void init()
Initialize the thread.
ServicePublisher * service_publisher
Service publisher to publish services on the network.
Fawkes library namespace.
virtual bool get_bool(const char *path)=0
Get value from configuration which is of type bool.
virtual ValueIterator * search(const char *path)=0
Iterator with search results.
Thread class encapsulation of pthreads.
Logger * logger
This is the Logger member used to access the logger.
Group configuration for initial groups.
Base class for exceptions in Fawkes.
virtual ~GossipThread()
Destructor.
Abstract class for a Gossip group manager.
const char * name() const
Get name of thread.
virtual void finalize()
Finalize the thread.
Thread aspect provide a new aspect.
virtual void log_debug(const char *component, const char *format,...)=0
Log debug message.
virtual bool exists(const char *path)=0
Check if a given value exists.
GossipThread()
Constructor.
virtual unsigned int get_uint(const char *path)=0
Get value from configuration which is of type unsigned int.
Configuration * config
This is the Configuration member used to access the configuration.
virtual std::string get_string(const char *path)=0
Get value from configuration which is of type string.
void set_manager(GossipGroupManager *gossip_group_mgr)
Set gossip group manger.