Line data Source code
1 : /* 2 : * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved. 3 : * Copyright Contributors to the OpenSDN project 4 : */ 5 : 6 : #ifndef __AGENT_OPER_GLOBAL_SYSTEM_CONFIG_H 7 : #define __AGENT_OPER_GLOBAL_SYSTEM_CONFIG_H 8 : 9 : #include <cmn/agent_cmn.h> 10 : #include <oper/oper_db.h> 11 : 12 : class IFMapNode; 13 : namespace autogen { 14 : class GlobalSystemConfig; 15 : } 16 : 17 : struct BGPaaServiceParameters { 18 : typedef std::pair<uint16_t, uint16_t> BGPaaServicePortRangePair; 19 : void Reset(); 20 : 21 : int port_start; 22 : int port_end; 23 : }; 24 : 25 : struct GracefulRestartParameters { 26 : public: 27 : typedef boost::function<void()> Callback; 28 : typedef std::vector<Callback> CallbackList; 29 : void Reset(); 30 : void Update(autogen::GlobalSystemConfig *cfg); 31 : void Register(GracefulRestartParameters::Callback cb); 32 0 : bool enable() const { return enable_; } 33 0 : bool xmpp_helper_enable() const { return xmpp_helper_enable_; } 34 0 : bool config_seen() const { return config_seen_; } 35 0 : uint32_t end_of_rib_time() { return end_of_rib_time_; } 36 2 : uint32_t long_lived_restart_time() { return long_lived_restart_time_; } 37 21 : uint64_t llgr_stale_time() { return (long_lived_restart_time_ + 38 21 : end_of_rib_time_); } 39 86 : bool IsEnabled() const { 40 86 : return (config_seen_ && enable_ && xmpp_helper_enable_); 41 : } 42 : 43 : private: 44 : void Notify(); 45 : 46 : bool enable_; 47 : uint64_t end_of_rib_time_; 48 : uint64_t long_lived_restart_time_; 49 : bool xmpp_helper_enable_; 50 : CallbackList callbacks_; 51 : bool config_seen_; 52 : }; 53 : 54 : struct FastConvergenceParameters { 55 : void Reset(); 56 : 57 : uint8_t xmpp_hold_time; 58 : bool enable; 59 : }; 60 : 61 : class GlobalSystemConfig : public OperIFMapTable { 62 : public: 63 : GlobalSystemConfig(Agent *agent); 64 : virtual ~GlobalSystemConfig(); 65 : 66 : void ConfigDelete(IFMapNode *node); 67 : void ConfigAddChange(IFMapNode *node); 68 : void ConfigManagerEnqueue(IFMapNode *node); 69 0 : BGPaaServiceParameters::BGPaaServicePortRangePair bgpaas_port_range() const { 70 0 : return std::make_pair(bgpaas_parameters_.port_start, 71 0 : bgpaas_parameters_.port_end); 72 : } 73 : void Reset(); 74 : GracefulRestartParameters &gres_parameters(); 75 4 : FastConvergenceParameters &fc_params() { return fc_params_; } 76 : bool cfg_igmp_enable() const; 77 : void FillSandeshInfo(GlobalSystemConfigResp *resp); 78 : 79 : private: 80 : BGPaaServiceParameters bgpaas_parameters_; 81 : GracefulRestartParameters gres_parameters_; 82 : FastConvergenceParameters fc_params_; 83 : bool cfg_igmp_enable_; 84 : DISALLOW_COPY_AND_ASSIGN(GlobalSystemConfig); 85 : }; 86 : #endif