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