LCOV - code coverage report
Current view: top level - bgp - bgp_show_mvpn_manager.cc (source / functions) Hit Total Coverage
Test: OpenSDN C/C++ coverage (all TARGET_SET jobs) Lines: 0 62 0.0 %
Date: 2026-11-16 02:06:09 Functions: 0 5 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :  * Copyright (c) 2017 Juniper Networks, Inc. All rights reserved.
       3             :  * Copyright Contributors to the OpenSDN project
       4             :  */
       5             : 
       6             : #include "bgp/bgp_show_handler.h"
       7             : 
       8             : #include "base/regex.h"
       9             : #include "bgp/bgp_peer_internal_types.h"
      10             : #include "bgp/bgp_mvpn.h"
      11             : #include "bgp/bgp_server.h"
      12             : #include "bgp/mvpn/mvpn_table.h"
      13             : #include "bgp/routing-instance/routing_instance.h"
      14             : 
      15             : using contrail::regex;
      16             : using contrail::regex_match;
      17             : using contrail::regex_search;
      18             : using std::string;
      19             : using std::vector;
      20             : 
      21             : //
      22             : // Fill in information for an mvpn table.
      23             : //
      24           0 : static void FillMvpnManagerInfo(ShowMvpnManager *smm,
      25             :     const BgpSandeshContext *bsc, const MvpnTable *table) {
      26           0 :     smm->set_name(table->name());
      27           0 :     const MvpnManager *manager = table->manager();
      28           0 :     if (!manager)
      29           0 :         return;
      30             : 
      31           0 :     smm->set_project_manager(
      32             :         table->routing_instance()->mvpn_project_manager_network());
      33           0 :     smm->set_deleted(manager->deleted());
      34           0 :     smm->set_deleted_at(
      35           0 :         UTCUsecToString(manager->deleter()->delete_time_stamp_usecs()));
      36             : }
      37             : 
      38             : //
      39             : // Specialization of BgpShowHandler<>::CallbackCommon.
      40             : //
      41             : template <>
      42           0 : bool BgpShowHandler<ShowMvpnManagerReq, ShowMvpnManagerReqIterate,
      43             :     ShowMvpnManagerResp, ShowMvpnManager>::CallbackCommon(
      44             :     const BgpSandeshContext *bsc, Data *data) {
      45           0 :     uint32_t page_limit = bsc->page_limit() ? bsc->page_limit() : kPageLimit;
      46           0 :     uint32_t iter_limit = bsc->iter_limit() ? bsc->iter_limit() : kIterLimit;
      47           0 :     RoutingInstanceMgr *rim = bsc->bgp_server->routing_instance_mgr();
      48             : 
      49           0 :     regex search_expr(data->search_string);
      50             :     RoutingInstanceMgr::const_name_iterator it =
      51           0 :         rim->name_clower_bound(data->next_entry);
      52           0 :     for (uint32_t iter_count = 0; it != rim->name_cend(); ++it, ++iter_count) {
      53           0 :         const RoutingInstance *rtinstance = it->second;
      54             :         const MvpnTable *table = static_cast<const MvpnTable *>(
      55           0 :             rtinstance->GetTable(Address::MVPN));
      56           0 :         if (!table)
      57           0 :             continue;
      58           0 :         if ((!regex_search(table->name(), search_expr)) &&
      59           0 :             (data->search_string != "deleted" || !table->IsDeleted())) {
      60           0 :             continue;
      61             :         }
      62           0 :         ShowMvpnManager smm;
      63           0 :         FillMvpnManagerInfo(&smm, bsc, table);
      64           0 :         data->show_list.push_back(smm);
      65           0 :         if (data->show_list.size() >= page_limit)
      66           0 :             break;
      67           0 :         if (iter_count >= iter_limit)
      68           0 :             break;
      69           0 :     }
      70             : 
      71             :     // All done if we've looked at all instances.
      72           0 :     if (it == rim->name_cend() || ++it == rim->name_cend())
      73           0 :         return true;
      74             : 
      75             :     // Return true if we've reached the page limit, false if we've reached the
      76             :     // iteration limit.
      77           0 :     bool done = data->show_list.size() >= page_limit;
      78           0 :     SaveContextToData(it->second->name(), done, data);
      79           0 :     return done;
      80           0 : }
      81             : 
      82             : //
      83             : // Specialization of BgpShowHandler<>::FillShowList.
      84             : //
      85             : template <>
      86           0 : void BgpShowHandler<ShowMvpnManagerReq, ShowMvpnManagerReqIterate,
      87             :     ShowMvpnManagerResp, ShowMvpnManager>::FillShowList(
      88             :     ShowMvpnManagerResp *resp,
      89             :     const vector<ShowMvpnManager> &show_list) {
      90           0 :     resp->set_managers(show_list);
      91           0 : }
      92             : 
      93             : //
      94             : // Handler for ShowMvpnManagerReq.
      95             : //
      96           0 : void ShowMvpnManagerReq::HandleRequest() const {
      97           0 :     RequestPipeline::PipeSpec ps(this);
      98           0 :     RequestPipeline::StageSpec s1;
      99           0 :     TaskScheduler *scheduler = TaskScheduler::GetInstance();
     100             : 
     101           0 :     s1.taskId_ = scheduler->GetTaskId("bgp::ShowCommand");
     102             :     s1.cbFn_ = boost::bind(&BgpShowHandler<
     103             :         ShowMvpnManagerReq,
     104             :         ShowMvpnManagerReqIterate,
     105             :         ShowMvpnManagerResp,
     106           0 :         ShowMvpnManager>::Callback, _1, _2, _3, _4, _5);
     107             :     s1.allocFn_ = BgpShowHandler<
     108             :         ShowMvpnManagerReq,
     109             :         ShowMvpnManagerReqIterate,
     110             :         ShowMvpnManagerResp,
     111           0 :         ShowMvpnManager>::CreateData;
     112           0 :     s1.instances_.push_back(0);
     113           0 :     ps.stages_.push_back(s1);
     114           0 :     RequestPipeline rp(ps);
     115           0 : }
     116             : 
     117             : //
     118             : // Handler for ShowMvpnManagerReqIterate.
     119             : //
     120           0 : void ShowMvpnManagerReqIterate::HandleRequest() const {
     121           0 :     RequestPipeline::PipeSpec ps(this);
     122           0 :     RequestPipeline::StageSpec s1;
     123           0 :     TaskScheduler *scheduler = TaskScheduler::GetInstance();
     124             : 
     125           0 :     s1.taskId_ = scheduler->GetTaskId("bgp::ShowCommand");
     126             :     s1.cbFn_ = boost::bind(&BgpShowHandler<
     127             :         ShowMvpnManagerReq,
     128             :         ShowMvpnManagerReqIterate,
     129             :         ShowMvpnManagerResp,
     130           0 :         ShowMvpnManager>::CallbackIterate, _1, _2, _3, _4, _5);
     131             :     s1.allocFn_ = BgpShowHandler<
     132             :         ShowMvpnManagerReq,
     133             :         ShowMvpnManagerReqIterate,
     134             :         ShowMvpnManagerResp,
     135           0 :         ShowMvpnManager>::CreateData;
     136           0 :     s1.instances_.push_back(0);
     137           0 :     ps.stages_.push_back(s1);
     138           0 :     RequestPipeline rp(ps);
     139           0 : }

Generated by: LCOV version 1.14