Line data Source code
1 : /* 2 : * Copyright (c) 2015 Juniper Networks, Inc. All rights reserved. 3 : */ 4 : 5 : #ifndef vnsw_agent_vrouter_h_ 6 : #define vnsw_agent_vrouter_h_ 7 : 8 : #include <cmn/agent_cmn.h> 9 : #include <oper/oper_db.h> 10 : 11 : class IFMapNode; 12 : 13 : struct VRouterSubnet { 14 : IpAddress ip_prefix; 15 : uint8_t plen; 16 0 : VRouterSubnet() : ip_prefix(), plen(0) {} 17 : VRouterSubnet(const std::string& ip, uint8_t prefix_len); 18 : bool operator==(const VRouterSubnet& rhs) const; 19 : bool IsLess(const VRouterSubnet *rhs) const; 20 : bool operator() (const VRouterSubnet &lhs, const VRouterSubnet &rhs) const; 21 : }; 22 : 23 : // Handle VRouter configuration 24 : class VRouter : public OperIFMapTable { 25 : public: 26 : typedef std::set<VRouterSubnet, VRouterSubnet> VRouterSubnetSet; 27 : VRouter(Agent *agent); 28 : virtual ~VRouter(); 29 : 30 : void ConfigDelete(IFMapNode *node); 31 : void ConfigAddChange(IFMapNode *node); 32 : void ConfigManagerEnqueue(IFMapNode *node); 33 : void FillSandeshInfo(VrouterInfoResp *resp); 34 0 : uint32_t SubnetCount() const { return subnet_list_.size(); } 35 : bool IsSubnetMember(const IpAddress &addr) const; 36 : void Shutdown(); 37 : void Insert(const VRouterSubnet *rhs); 38 0 : void Update(const VRouterSubnet *lhs, const VRouterSubnet *rhs) {} 39 : void Remove(VRouterSubnetSet::iterator &it); 40 : private: 41 : void DeleteSubnetRoutes(); 42 : void ClearSubnets(); 43 : void DeleteRoute(const VRouterSubnet &subnet); 44 : void AddRoute(const VRouterSubnet &subnet); 45 : IFMapNode *FindTarget(IFMapNode *node, std::string node_type) const; 46 : 47 : std::string name_; 48 : VRouterSubnetSet subnet_list_; 49 : std::string display_name_; 50 : DISALLOW_COPY_AND_ASSIGN(VRouter); 51 : }; 52 : 53 : #endif // vnsw_agent_vrouter_h_