Line data Source code
1 : /* 2 : * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved. 3 : */ 4 : 5 : #ifndef SRC_BGP_ERMVPN_ERMVPN_TABLE_H_ 6 : #define SRC_BGP_ERMVPN_ERMVPN_TABLE_H_ 7 : 8 : #include <string> 9 : 10 : #include "bgp/bgp_attr.h" 11 : #include "bgp/bgp_table.h" 12 : #include "bgp/ermvpn/ermvpn_route.h" 13 : 14 : class BgpServer; 15 : class BgpRoute; 16 : class McastTreeManager; 17 : class MvpnProjectManager; 18 : 19 : class ErmVpnTable : public BgpTable { 20 : public: 21 : static const int kPartitionCount = 1; 22 : 23 : struct RequestKey : BgpTable::RequestKey { 24 15325 : RequestKey(const ErmVpnPrefix &prefix, const IPeer *ipeer) 25 15325 : : prefix(prefix), peer(ipeer) { 26 15324 : } 27 : ErmVpnPrefix prefix; 28 : const IPeer *peer; 29 14117 : virtual const IPeer *GetPeer() const { return peer; } 30 : }; 31 : 32 : ErmVpnTable(DB *db, const std::string &name); 33 : 34 : virtual std::unique_ptr<DBEntry> AllocEntry(const DBRequestKey *key) const; 35 : virtual std::unique_ptr<DBEntry> AllocEntryStr(const std::string &key) const; 36 : 37 444946 : virtual Address::Family family() const { return Address::ERMVPN; } 38 : bool IsMaster() const; 39 665671 : virtual bool IsVpnTable() const { return IsMaster(); } 40 : 41 : virtual size_t Hash(const DBEntry *entry) const; 42 : virtual size_t Hash(const DBRequestKey *key) const; 43 : size_t Hash(const Ip4Address &group) const; 44 282125 : virtual int PartitionCount() const { return kPartitionCount; } 45 : 46 : virtual BgpRoute *RouteReplicate(BgpServer *server, BgpTable *src_table, 47 : BgpRoute *src_rt, const BgpPath *path, 48 : ExtCommunityPtr ptr); 49 : 50 : virtual bool Export(RibOut *ribout, Route *route, 51 : const RibPeerSet &peerset, 52 : UpdateInfoSList &info_slist); 53 : static DBTableBase *CreateTable(DB *db, const std::string &name); 54 : size_t HashFunction(const ErmVpnPrefix &prefix) const; 55 : bool IsGlobalTreeRootRoute(ErmVpnRoute *rt) const; 56 : 57 : const ErmVpnRoute *FindRoute(const ErmVpnPrefix &prefix) const; 58 : ErmVpnRoute *FindRoute(const ErmVpnPrefix &prefix); 59 : void CreateTreeManager(); 60 : void DestroyTreeManager(); 61 : McastTreeManager *GetTreeManager(); 62 : const McastTreeManager *GetTreeManager() const; 63 : virtual void set_routing_instance(RoutingInstance *rtinstance); 64 55995 : const McastTreeManager *tree_manager() const { return tree_manager_; } 65 18956 : McastTreeManager *tree_manager() { return tree_manager_; } 66 : void CreateMvpnProjectManager(); 67 : void DestroyMvpnProjectManager(); 68 1 : MvpnProjectManager *mvpn_project_manager() { return mvpn_project_manager_; } 69 186143 : const MvpnProjectManager *mvpn_project_manager() const { 70 186143 : return mvpn_project_manager_; 71 : } 72 : void GetMvpnSourceAddress(ErmVpnRoute *ermvpn_route, 73 : Ip4Address *address) const; 74 : 75 : private: 76 : friend class BgpMulticastTest; 77 : 78 : virtual BgpRoute *TableFind(DBTablePartition *rtp, 79 : const DBRequestKey *prefix); 80 : McastTreeManager *tree_manager_; 81 : MvpnProjectManager *mvpn_project_manager_; 82 : 83 : DISALLOW_COPY_AND_ASSIGN(ErmVpnTable); 84 : }; 85 : 86 : #endif // SRC_BGP_ERMVPN_ERMVPN_TABLE_H_