LCOV - code coverage report
Current view: top level - bgp/rtarget - rtarget_table.cc (source / functions) Hit Total Coverage
Test: OpenSDN C/C++ coverage (all TARGET_SET jobs) Lines: 32 37 86.5 %
Date: 2026-11-16 02:06:09 Functions: 9 11 81.8 %
Legend: Lines: hit not hit

          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             : #include "bgp/rtarget/rtarget_table.h"
       7             : 
       8             : #include "bgp/bgp_update.h"
       9             : #include "db/db.h"
      10             : 
      11             : using std::unique_ptr;
      12             : using std::string;
      13             : 
      14          20 : RTargetTable::RTargetTable(DB *db, const string &name)
      15          20 :         : BgpTable(db, name) {
      16          20 : }
      17             : 
      18        4394 : unique_ptr<DBEntry> RTargetTable::AllocEntry(const DBRequestKey *key) const {
      19        4394 :     const RequestKey *pfxkey = static_cast<const RequestKey *>(key);
      20        4394 :     return unique_ptr<DBEntry> (new RTargetRoute(pfxkey->prefix));
      21             : }
      22             : 
      23           0 : unique_ptr<DBEntry> RTargetTable::AllocEntryStr(const string &key_str) const {
      24           0 :     RTargetPrefix prefix = RTargetPrefix::FromString(key_str);
      25           0 :     return unique_ptr<DBEntry> (new RTargetRoute(prefix));
      26             : }
      27             : 
      28       41483 : size_t RTargetTable::Hash(const DBEntry *entry) const {
      29       41483 :     return 0;
      30             : }
      31             : 
      32        3455 : size_t RTargetTable::Hash(const DBRequestKey *key) const {
      33        3455 :     return 0;
      34             : }
      35             : 
      36        3068 : BgpRoute *RTargetTable::TableFind(DBTablePartition *rtp,
      37             :                                   const DBRequestKey *prefix) {
      38        3068 :     const RequestKey *pfxkey = static_cast<const RequestKey *>(prefix);
      39        3068 :     RTargetRoute rt_key(pfxkey->prefix);
      40        6136 :     return static_cast<BgpRoute *>(rtp->Find(&rt_key));
      41        3068 : }
      42             : 
      43          20 : DBTableBase *RTargetTable::CreateTable(DB *db, const string &name) {
      44          20 :     RTargetTable *table = new RTargetTable(db, name);
      45          20 :     table->Init();
      46          20 :     return table;
      47             : }
      48             : 
      49           0 : BgpRoute *RTargetTable::RouteReplicate(BgpServer *server,
      50             :         BgpTable *src_table, BgpRoute *src_rt, const BgpPath *src_path,
      51             :         ExtCommunityPtr community) {
      52           0 :     return NULL;
      53             : }
      54             : 
      55        4965 : bool RTargetTable::Export(RibOut *ribout, Route *route,
      56             :         const RibPeerSet &peerset, UpdateInfoSList &uinfo_slist) {
      57        4965 :     BgpRoute *bgp_route = static_cast<BgpRoute *> (route);
      58        4965 :     UpdateInfo *uinfo = GetUpdateInfo(ribout, bgp_route, peerset);
      59        4965 :     if (!uinfo) return false;
      60        3540 :     uinfo_slist->push_front(*uinfo);
      61             : 
      62        3540 :     return true;
      63             : }
      64             : 
      65        2724 : void RTargetTable::AddRemoveCallback(const DBEntryBase *entry, bool add) const {
      66        2724 :     if (add)
      67        1362 :         last_updated_ = UTCTimestamp();
      68        2724 : }
      69             : 
      70           1 : static void RegisterFactory() {
      71           1 :     DB::RegisterFactory("bgp.rtarget.0", &RTargetTable::CreateTable);
      72           1 : }
      73             : MODULE_INITIALIZER(RegisterFactory);

Generated by: LCOV version 1.14