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 8227 : RTargetTable::RTargetTable(DB *db, const string &name) 14 8227 : : BgpTable(db, name) { 15 8227 : } 16 : 17 77291 : unique_ptr<DBEntry> RTargetTable::AllocEntry(const DBRequestKey *key) const { 18 77291 : const RequestKey *pfxkey = static_cast<const RequestKey *>(key); 19 77291 : return unique_ptr<DBEntry> (new RTargetRoute(pfxkey->prefix)); 20 : } 21 : 22 249 : unique_ptr<DBEntry> RTargetTable::AllocEntryStr(const string &key_str) const { 23 249 : RTargetPrefix prefix = RTargetPrefix::FromString(key_str); 24 498 : return unique_ptr<DBEntry> (new RTargetRoute(prefix)); 25 : } 26 : 27 809879 : size_t RTargetTable::Hash(const DBEntry *entry) const { 28 809879 : return 0; 29 : } 30 : 31 123643 : size_t RTargetTable::Hash(const DBRequestKey *key) const { 32 123643 : return 0; 33 : } 34 : 35 110163 : BgpRoute *RTargetTable::TableFind(DBTablePartition *rtp, 36 : const DBRequestKey *prefix) { 37 110163 : const RequestKey *pfxkey = static_cast<const RequestKey *>(prefix); 38 110163 : RTargetRoute rt_key(pfxkey->prefix); 39 220326 : return static_cast<BgpRoute *>(rtp->Find(&rt_key)); 40 110163 : } 41 : 42 8227 : DBTableBase *RTargetTable::CreateTable(DB *db, const string &name) { 43 8227 : RTargetTable *table = new RTargetTable(db, name); 44 8227 : table->Init(); 45 8227 : 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 85809 : bool RTargetTable::Export(RibOut *ribout, Route *route, 55 : const RibPeerSet &peerset, UpdateInfoSList &uinfo_slist) { 56 85809 : BgpRoute *bgp_route = static_cast<BgpRoute *> (route); 57 85809 : UpdateInfo *uinfo = GetUpdateInfo(ribout, bgp_route, peerset); 58 85809 : if (!uinfo) return false; 59 54464 : uinfo_slist->push_front(*uinfo); 60 : 61 54464 : return true; 62 : } 63 : 64 87152 : void RTargetTable::AddRemoveCallback(const DBEntryBase *entry, bool add) const { 65 87152 : if (add) 66 43576 : last_updated_ = UTCTimestamp(); 67 87152 : } 68 : 69 159 : static void RegisterFactory() { 70 159 : DB::RegisterFactory("bgp.rtarget.0", &RTargetTable::CreateTable); 71 159 : } 72 : MODULE_INITIALIZER(RegisterFactory);