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