Line data Source code
1 : /* 2 : * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved. 3 : */ 4 : 5 : #include "bgp/rtarget/rtarget_table.h" 6 : 7 : #include "bgp/bgp_update.h" 8 : #include "db/db.h" 9 : 10 : using std::unique_ptr; 11 : using std::string; 12 : 13 8228 : RTargetTable::RTargetTable(DB *db, const string &name) 14 8228 : : BgpTable(db, name) { 15 8228 : } 16 : 17 78465 : unique_ptr<DBEntry> RTargetTable::AllocEntry(const DBRequestKey *key) const { 18 78465 : const RequestKey *pfxkey = static_cast<const RequestKey *>(key); 19 78465 : return unique_ptr<DBEntry> (new RTargetRoute(pfxkey->prefix)); 20 : } 21 : 22 257 : unique_ptr<DBEntry> RTargetTable::AllocEntryStr(const string &key_str) const { 23 257 : RTargetPrefix prefix = RTargetPrefix::FromString(key_str); 24 514 : return unique_ptr<DBEntry> (new RTargetRoute(prefix)); 25 : } 26 : 27 813180 : size_t RTargetTable::Hash(const DBEntry *entry) const { 28 813180 : return 0; 29 : } 30 : 31 122662 : size_t RTargetTable::Hash(const DBRequestKey *key) const { 32 122662 : return 0; 33 : } 34 : 35 109576 : BgpRoute *RTargetTable::TableFind(DBTablePartition *rtp, 36 : const DBRequestKey *prefix) { 37 109576 : const RequestKey *pfxkey = static_cast<const RequestKey *>(prefix); 38 109576 : RTargetRoute rt_key(pfxkey->prefix); 39 219152 : return static_cast<BgpRoute *>(rtp->Find(&rt_key)); 40 109576 : } 41 : 42 8228 : DBTableBase *RTargetTable::CreateTable(DB *db, const string &name) { 43 8228 : RTargetTable *table = new RTargetTable(db, name); 44 8228 : table->Init(); 45 8228 : return table; 46 : } 47 : 48 0 : BgpRoute *RTargetTable::RouteReplicate(BgpServer *server, 49 : BgpTable *src_table, BgpRoute *src_rt, const BgpPath *src_path, 50 : ExtCommunityPtr community) { 51 0 : return NULL; 52 : } 53 : 54 86248 : bool RTargetTable::Export(RibOut *ribout, Route *route, 55 : const RibPeerSet &peerset, UpdateInfoSList &uinfo_slist) { 56 86248 : BgpRoute *bgp_route = static_cast<BgpRoute *> (route); 57 86248 : UpdateInfo *uinfo = GetUpdateInfo(ribout, bgp_route, peerset); 58 86248 : if (!uinfo) return false; 59 54432 : uinfo_slist->push_front(*uinfo); 60 : 61 54432 : return true; 62 : } 63 : 64 86820 : void RTargetTable::AddRemoveCallback(const DBEntryBase *entry, bool add) const { 65 86820 : if (add) 66 43410 : last_updated_ = UTCTimestamp(); 67 86820 : } 68 : 69 159 : static void RegisterFactory() { 70 159 : DB::RegisterFactory("bgp.rtarget.0", &RTargetTable::CreateTable); 71 159 : } 72 : MODULE_INITIALIZER(RegisterFactory);