Line data Source code
1 : /* 2 : * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved. 3 : */ 4 : 5 : #ifndef vnsw_agent_vn_uve_table_base_h 6 : #define vnsw_agent_vn_uve_table_base_h 7 : 8 : #include <string> 9 : #include <set> 10 : #include <map> 11 : #include <vector> 12 : #include <mutex> 13 : 14 : #include <virtual_network_types.h> 15 : #include <oper/vn.h> 16 : #include <uve/vn_uve_entry_base.h> 17 : 18 : //The container class for objects representing VirtualNetwork UVEs 19 : //Defines routines for storing and managing (add, delete, change and send) 20 : //VirtualNetwork UVEs 21 : class VnUveTableBase { 22 : public: 23 : struct VnUveInterfaceState :public DBState { 24 14 : VnUveInterfaceState(const std::string &vm, const std::string &vn) 25 14 : : vm_name_(vm), vn_name_(vn) { 26 14 : } 27 : std::string vm_name_; 28 : std::string vn_name_; 29 : }; 30 : 31 : typedef boost::shared_ptr<VnUveEntryBase> VnUveEntryPtr; 32 : typedef std::map<std::string, VnUveEntryPtr> UveVnMap; 33 : typedef std::pair<std::string, VnUveEntryPtr> UveVnPair; 34 : VnUveTableBase(Agent *agent, uint32_t default_intvl); 35 : virtual ~VnUveTableBase(); 36 : 37 : void RegisterDBClients(); 38 : void Shutdown(void); 39 : void SendVnAclRuleCount(); 40 : bool TimerExpiry(); 41 : 42 : protected: 43 : void Delete(const std::string &name); 44 : VnUveEntryBase* UveEntryFromVn(const VnEntry *vn); 45 : //The following API is made protected for UT. 46 : virtual void DispatchVnMsg(const UveVirtualNetworkAgent &uve); 47 0 : virtual void SendVnAceStats(VnUveEntryBase *entry, const VnEntry *vn) { 48 0 : } 49 : 50 : UveVnMap uve_vn_map_; 51 : Agent *agent_; 52 : /* For exclusion between kTaskFlowStatsCollector and kTaskDBExclude */ 53 : std::mutex uve_vn_map_mutex_; 54 : private: 55 : VnUveEntryBase* Add(const VnEntry *vn); 56 : void Add(const std::string &vn); 57 : virtual VnUveEntryPtr Allocate(const VnEntry *vn); 58 : virtual VnUveEntryPtr Allocate(); 59 : void VnNotify(DBTablePartBase *partition, DBEntryBase *e); 60 : void InterfaceNotify(DBTablePartBase *partition, DBEntryBase *e); 61 : void SendDeleteVnMsg(const std::string &vn); 62 : void MarkChanged(const VnEntry *vn); 63 : void InterfaceDeleteHandler(const std::string &vm, const std::string &vn, 64 : const Interface* intf); 65 : void InterfaceAddHandler(const VnEntry* vn, const Interface* intf, 66 : const std::string &vm_name, 67 : VnUveInterfaceState *state); 68 : void set_expiry_time(int time); 69 : void SendVnMsg(VnUveEntryBase *entry, const VnEntry *vn); 70 : 71 : DBTableBase::ListenerId vn_listener_id_; 72 : DBTableBase::ListenerId intf_listener_id_; 73 : 74 : // Last visited VmEntry by timer 75 : std::string timer_last_visited_; 76 : Timer *timer_; 77 : int expiry_time_; 78 : 79 : DISALLOW_COPY_AND_ASSIGN(VnUveTableBase); 80 : }; 81 : 82 : #endif // vnsw_agent_vn_uve_table_base_h