Line data Source code
1 : /* 2 : * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved. 3 : */ 4 : 5 : #ifndef __DNS_CMN_H_ 6 : #define __DNS_CMN_H_ 7 : 8 : #include <boost/intrusive_ptr.hpp> 9 : #include <boost/bind/bind.hpp> 10 : 11 : #include <io/event_manager.h> 12 : #include <base/logging.h> 13 : #include <base/address.h> 14 : #include <db/db.h> 15 : #include <db/db_entry.h> 16 : #include <db/db_table.h> 17 : #include <base/task.h> 18 : #include <base/task_trigger.h> 19 : #include <io/event_manager.h> 20 : #include <base/misc_utils.h> 21 : #include <sandesh/sandesh_trace.h> 22 : 23 : using namespace boost::placeholders; 24 : 25 : class EventManager; 26 : class DnsManager; 27 : class DnsConfigManager; 28 : class XmppServer; 29 : class DnsAgentXmppChannelManager; 30 : 31 : class Dns { 32 : public: 33 61 : static EventManager *GetEventManager() { return event_mgr_; } 34 1 : static void SetEventManager(EventManager *evm) { event_mgr_ = evm; } 35 : 36 2 : static DnsManager *GetDnsManager() { return dns_mgr_; } 37 15 : static void SetDnsManager(DnsManager *mgr) { dns_mgr_ = mgr; } 38 : 39 53 : static DnsConfigManager *GetDnsConfigManager() { return dns_config_mgr_; } 40 15 : static void SetDnsConfigManager(DnsConfigManager *cfg) { dns_config_mgr_ = cfg; } 41 : 42 0 : static XmppServer *GetXmppServer() { return xmpp_server_; } 43 : static void SetXmppServer(XmppServer *server) { xmpp_server_ = server; } 44 : 45 : static const uint32_t GetXmppServerPort() { return xmpp_srv_port_; } 46 : static void SetXmppServerPort(uint32_t port) { xmpp_srv_port_ = port; } 47 : 48 0 : static DnsAgentXmppChannelManager *GetAgentXmppChannelManager() { 49 0 : return agent_xmpp_channel_mgr_; 50 : } 51 : static void SetAgentXmppChannelManager(DnsAgentXmppChannelManager *mgr) { 52 : agent_xmpp_channel_mgr_ = mgr; 53 : } 54 : 55 : static const std::string &GetHostName() {return host_name_;} 56 : static void SetHostName(const std::string name) { host_name_ = name; }; 57 : static const std::string &GetProgramName() {return prog_name_;} 58 : static void SetProgramName(const char *name) { prog_name_ = name; }; 59 : static const std::string &GetCollector() {return collector_;} 60 : static void SetCollector(std::string name) { collector_ = name; }; 61 : static const uint32_t GetHttpPort() { return http_port_; } 62 : static void SetHttpPort(uint32_t port) { http_port_ = port; }; 63 102 : static const uint32_t GetDnsPort() { return dns_port_; } 64 : static void SetDnsPort(uint32_t port) { dns_port_ = port; }; 65 19 : static std::string GetSelfIp() { return self_ip_; } 66 : static void SetSelfIp(std::string ip) { self_ip_ = ip; } 67 : 68 : static bool GetVersion(std::string &build_info_str); 69 1 : static void Init() { 70 : EventManager *evm; 71 1 : evm = new EventManager(); 72 1 : assert(evm); 73 1 : SetEventManager(evm); 74 : 75 1 : SetTaskSchedulingPolicy(); 76 1 : } 77 : 78 : private: 79 : static void SetTaskSchedulingPolicy(); 80 : 81 : static EventManager *event_mgr_; 82 : static DnsManager *dns_mgr_; 83 : static DnsConfigManager *dns_config_mgr_; 84 : 85 : static XmppServer *xmpp_server_; 86 : static uint32_t xmpp_srv_port_; 87 : static std::string host_name_; 88 : static std::string prog_name_; 89 : static std::string self_ip_; 90 : static std::string collector_; 91 : static uint32_t http_port_; 92 : static uint32_t dns_port_; 93 : static DnsAgentXmppChannelManager *agent_xmpp_channel_mgr_; 94 : }; 95 : 96 : #endif // __DNS_CMN_H_