Line data Source code
1 : /* 2 : * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved. 3 : */ 4 : 5 : #ifndef vnsw_agent_vn_uve_entry_base_h 6 : #define vnsw_agent_vn_uve_entry_base_h 7 : 8 : #include <string> 9 : #include <set> 10 : #include <map> 11 : #include <vector> 12 : #include <virtual_network_types.h> 13 : #include <oper/interface_common.h> 14 : #include <oper/interface.h> 15 : #include <oper/vn.h> 16 : #include <cmn/agent_cmn.h> 17 : 18 : //The class that defines data-structures to store VirtualNetwork information 19 : //required for sending VirtualNetwork UVE. 20 : class VnUveEntryBase { 21 : public: 22 : typedef std::set<const Interface *> InterfaceSet; 23 : typedef std::set<std::string> VmSet; 24 : 25 : VnUveEntryBase(Agent *agent, const VnEntry *vn); 26 : VnUveEntryBase(Agent *agent); 27 : virtual ~VnUveEntryBase(); 28 : 29 20 : void set_vn(const VnEntry *vn) { vn_ = vn; } 30 : 31 : void InterfaceAdd(const Interface *intf); 32 : void InterfaceDelete(const Interface *intf); 33 : void VmAdd(const std::string &vm); 34 : void VmDelete(const std::string &vm); 35 : bool BuildInterfaceVmList(UveVirtualNetworkAgent &s_vn); 36 : bool FrameVnMsg(const VnEntry *vn, UveVirtualNetworkAgent &uve); 37 0 : const VnEntry *vn() const { return vn_; } 38 : bool FrameVnAclRuleCountMsg(const VnEntry *vn, 39 : UveVirtualNetworkAgent *uve); 40 : 41 41 : void set_changed(bool val) { changed_ = val; } 42 0 : bool changed() const { return changed_; } 43 0 : void set_deleted(bool value) { deleted_ = value; } 44 228 : bool deleted() const { return deleted_; } 45 18 : void set_renewed(bool value) { renewed_ = value; } 46 0 : bool renewed() const { return renewed_; } 47 6 : void set_add_by_vn_notify(bool val) { add_by_vn_notify_ = val; } 48 : virtual void Reset(); 49 : 50 : protected: 51 : bool UveVnAclRuleCountChanged(int32_t size) const; 52 : Agent *agent_; 53 : const VnEntry *vn_; 54 : UveVirtualNetworkAgent uve_info_; 55 : InterfaceSet interface_tree_; 56 : VmSet vm_tree_; 57 : bool add_by_vn_notify_; 58 : 59 : // UVE entry is changed. Timer must generate UVE for this entry 60 : bool changed_; 61 : bool deleted_; 62 : bool renewed_; 63 : private: 64 : bool UveVnInterfaceListChanged(const std::vector<string> &new_list) const; 65 : bool UveVnVmListChanged(const std::vector<string> &new_list) const; 66 : bool UveVnAclChanged(const std::string &name) const; 67 : bool UveVnMirrorAclChanged(const std::string &name) const; 68 : 69 : DISALLOW_COPY_AND_ASSIGN(VnUveEntryBase); 70 : }; 71 : 72 : #endif // vnsw_agent_vn_uve_entry_base_h