Line data Source code
1 : /* 2 : * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved. 3 : */ 4 : 5 : #ifndef SRC_BGP_RTARGET_RTARGET_TABLE_H_ 6 : #define SRC_BGP_RTARGET_RTARGET_TABLE_H_ 7 : 8 : #include <atomic> 9 : #include <string> 10 : 11 : #include "bgp/bgp_attr.h" 12 : #include "bgp/bgp_table.h" 13 : #include "bgp/rtarget/rtarget_address.h" 14 : #include "bgp/rtarget/rtarget_route.h" 15 : 16 : class BgpServer; 17 : class BgpRoute; 18 : 19 : class RTargetTable : public BgpTable { 20 : public: 21 : struct RequestKey : BgpTable::RequestKey { 22 161445 : RequestKey(const RTargetPrefix &prefix, const IPeer *ipeer) 23 161445 : : prefix(prefix), peer(ipeer) { 24 161446 : } 25 : RTargetPrefix prefix; 26 : const IPeer *peer; 27 119935 : virtual const IPeer *GetPeer() const { return peer; } 28 : }; 29 : 30 : RTargetTable(DB *db, const std::string &name); 31 : 32 : virtual std::unique_ptr<DBEntry> AllocEntry(const DBRequestKey *key) const; 33 : virtual std::unique_ptr<DBEntry> AllocEntryStr(const std::string &key) const; 34 : 35 621589 : virtual Address::Family family() const { return Address::RTARGET; } 36 : 37 : virtual size_t Hash(const DBEntry *entry) const; 38 : virtual size_t Hash(const DBRequestKey *key) const; 39 : 40 : virtual BgpRoute *RouteReplicate(BgpServer *server, BgpTable *src_table, 41 : BgpRoute *src_rt, const BgpPath *path, 42 : ExtCommunityPtr ptr); 43 : 44 : virtual bool Export(RibOut *ribout, Route *route, 45 : const RibPeerSet &peerset, 46 : UpdateInfoSList &info_slist); 47 : static DBTableBase *CreateTable(DB *db, const std::string &name); 48 0 : time_t last_updated() const { return last_updated_; } 49 : 50 : private: 51 : virtual BgpRoute *TableFind(DBTablePartition *rtp, 52 : const DBRequestKey *prefix); 53 : void AddRemoveCallback(const DBEntryBase *entry, bool add) const; 54 : 55 : mutable std::atomic<time_t> last_updated_; 56 : 57 : DISALLOW_COPY_AND_ASSIGN(RTargetTable); 58 : }; 59 : 60 : #endif // SRC_BGP_RTARGET_RTARGET_TABLE_H_