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