LCOV - code coverage report
Current view: top level - bgp - bgp_show_config.cc (source / functions) Hit Total Coverage
Test: OpenSDN C/C++ coverage (all TARGET_SET jobs) Lines: 0 346 0.0 %
Date: 2026-09-28 02:13:17 Functions: 0 23 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :  * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved.
       3             :  */
       4             : 
       5             : #include "bgp/bgp_show_handler.h"
       6             : 
       7             : #include <boost/assign/list_of.hpp>
       8             : #include <boost/foreach.hpp>
       9             : 
      10             : #include "base/regex.h"
      11             : #include "bgp/bgp_config.h"
      12             : #include "bgp/bgp_config_ifmap.h"
      13             : #include "bgp/bgp_peer_internal_types.h"
      14             : #include "bgp/bgp_server.h"
      15             : 
      16             : using boost::assign::list_of;
      17             : using contrail::regex;
      18             : using contrail::regex_match;
      19             : using contrail::regex_search;
      20             : using std::string;
      21             : using std::vector;
      22             : 
      23             : //
      24             : // Fill in information for an instance.
      25             : //
      26           0 : static void FillBgpInstanceConfigInfo(ShowBgpInstanceConfig *sbic,
      27             :     const BgpSandeshContext *bsc, const BgpInstanceConfig *instance) {
      28           0 :     sbic->set_name(instance->name());
      29           0 :     sbic->set_virtual_network(instance->virtual_network());
      30           0 :     sbic->set_virtual_network_index(instance->virtual_network_index());
      31           0 :     sbic->set_vxlan_id(instance->vxlan_id());
      32             : 
      33           0 :     vector<string> import_list;
      34           0 :     for (auto rt : instance->import_list()) {
      35           0 :         import_list.push_back(rt);
      36           0 :     }
      37           0 :     sbic->set_import_target(import_list);
      38           0 :     vector<string> export_list;
      39           0 :     for (auto rt : instance->export_list()) {
      40           0 :         export_list.push_back(rt);
      41           0 :     }
      42           0 :     sbic->set_export_target(export_list);
      43           0 :     sbic->set_has_pnf(instance->has_pnf());
      44           0 :     sbic->set_allow_transit(instance->virtual_network_allow_transit());
      45           0 :     sbic->set_pbb_evpn_enable(instance->virtual_network_pbb_evpn_enable());
      46           0 :     sbic->set_last_change_at(UTCUsecToString(instance->last_change_at()));
      47             : 
      48             :     vector<string> neighbors(
      49           0 :         instance->neighbor_list().begin(), instance->neighbor_list().end());
      50           0 :     sbic->set_neighbors(neighbors);
      51             : 
      52           0 :     vector<ShowBgpServiceChainConfig> sbscc_list;
      53           0 :     for (const auto &sc_config :
      54           0 :         instance->service_chain_list()) {
      55           0 :         ShowBgpServiceChainConfig sbscc;
      56             :         Address::Family family =
      57           0 :             SCAddress::SCFamilyToAddressFamily(sc_config.family);
      58           0 :         sbscc.set_family(Address::FamilyToString(family));
      59           0 :         sbscc.set_routing_instance(sc_config.routing_instance);
      60           0 :         sbscc.set_service_instance(sc_config.service_instance);
      61           0 :         sbscc.set_chain_address(sc_config.service_chain_address);
      62           0 :         sbscc.set_prefixes(sc_config.prefix);
      63           0 :         sbscc_list.push_back(sbscc);
      64           0 :     }
      65           0 :     sbic->set_service_chain_infos(sbscc_list);
      66             : 
      67           0 :     vector<ShowBgpStaticRouteConfig> static_route_list;
      68           0 :     vector<Address::Family> families = list_of(Address::INET)(Address::INET6);
      69           0 :     for (auto family : families) {
      70           0 :         for (const auto &static_rt_config :
      71           0 :             instance->static_routes(family)) {
      72           0 :             ShowBgpStaticRouteConfig sbsrc;
      73           0 :             string prefix = static_rt_config.address.to_string() + "/";
      74           0 :             prefix += integerToString(static_rt_config.prefix_length);
      75           0 :             sbsrc.set_prefix(prefix);
      76           0 :             sbsrc.set_nexthop(static_rt_config.nexthop.to_string());
      77           0 :             sbsrc.set_targets(static_rt_config.communities);
      78           0 :             sbsrc.set_targets(static_rt_config.route_targets);
      79           0 :             static_route_list.push_back(sbsrc);
      80           0 :         }
      81             :     }
      82           0 :     if (!static_route_list.empty())
      83           0 :         sbic->set_static_routes(static_route_list);
      84             : 
      85           0 :     vector<ShowBgpRouteAggregateConfig> aggregate_route_list;
      86           0 :     for (auto family : families) {
      87           0 :         for (const auto &aggregate_rt_config :
      88           0 :             instance->aggregate_routes(family)) {
      89           0 :             ShowBgpRouteAggregateConfig sbarc;
      90           0 :             string prefix = aggregate_rt_config.aggregate.to_string() + "/";
      91           0 :             prefix += integerToString(aggregate_rt_config.prefix_length);
      92           0 :             sbarc.set_prefix(prefix);
      93           0 :             sbarc.set_nexthop(aggregate_rt_config.nexthop.to_string());
      94           0 :             aggregate_route_list.push_back(sbarc);
      95           0 :         }
      96             :     }
      97           0 :     if (!aggregate_route_list.empty())
      98           0 :         sbic->set_aggregate_routes(aggregate_route_list);
      99             : 
     100           0 :     vector<ShowBgpInstanceRoutingPolicyConfig> routing_policy_list;
     101           0 :     for (const auto &policy_config :
     102           0 :                   instance->routing_policy_list()) {
     103           0 :         ShowBgpInstanceRoutingPolicyConfig sbirpc;
     104           0 :         sbirpc.set_policy_name(policy_config.routing_policy_);
     105           0 :         sbirpc.set_sequence(policy_config.sequence_);
     106           0 :         routing_policy_list.push_back(sbirpc);
     107           0 :     }
     108           0 :     if (!routing_policy_list.empty())
     109           0 :         sbic->set_routing_policies(routing_policy_list);
     110           0 : }
     111             : 
     112             : //
     113             : // Specialization of BgpShowHandler<>::CallbackCommon.
     114             : //
     115             : template <>
     116           0 : bool BgpShowHandler<ShowBgpInstanceConfigReq, ShowBgpInstanceConfigReqIterate,
     117             :     ShowBgpInstanceConfigResp, ShowBgpInstanceConfig>::CallbackCommon(
     118             :     const BgpSandeshContext *bsc, Data *data) {
     119           0 :     uint32_t page_limit = bsc->page_limit() ? bsc->page_limit() : kPageLimit;
     120           0 :     uint32_t iter_limit = bsc->iter_limit() ? bsc->iter_limit() : kIterLimit;
     121           0 :     const BgpConfigManager *bcm = bsc->bgp_server->config_manager();
     122             : 
     123           0 :     regex search_expr(data->search_string);
     124             :     BgpConfigManager::InstanceMapRange range =
     125           0 :         bcm->InstanceMapItems(data->next_entry);
     126           0 :     BgpConfigManager::InstanceMap::const_iterator it = range.first;
     127           0 :     BgpConfigManager::InstanceMap::const_iterator it_end = range.second;
     128           0 :     for (uint32_t iter_count = 0; it != it_end; ++it, ++iter_count) {
     129           0 :         const BgpInstanceConfig *instance = it->second;
     130           0 :         if (!regex_search(instance->name(), search_expr))
     131           0 :             continue;
     132           0 :         ShowBgpInstanceConfig sbic;
     133           0 :         FillBgpInstanceConfigInfo(&sbic, bsc, instance);
     134           0 :         data->show_list.push_back(sbic);
     135           0 :         if (data->show_list.size() >= page_limit)
     136           0 :             break;
     137           0 :         if (iter_count >= iter_limit)
     138           0 :             break;
     139           0 :     }
     140             : 
     141             :     // All done if we've looked at all instances.
     142           0 :     if (it == it_end || ++it == it_end)
     143           0 :         return true;
     144             : 
     145             :     // Return true if we've reached the page limit, false if we've reached the
     146             :     // iteration limit.
     147           0 :     bool done = data->show_list.size() >= page_limit;
     148           0 :     SaveContextToData(it->second->name(), done, data);
     149           0 :     return done;
     150           0 : }
     151             : 
     152             : //
     153             : // Specialization of BgpShowHandler<>::FillShowList.
     154             : //
     155             : template <>
     156           0 : void BgpShowHandler<ShowBgpInstanceConfigReq, ShowBgpInstanceConfigReqIterate,
     157             :     ShowBgpInstanceConfigResp, ShowBgpInstanceConfig>::FillShowList(
     158             :         ShowBgpInstanceConfigResp *resp,
     159             :         const vector<ShowBgpInstanceConfig> &show_list) {
     160           0 :     resp->set_instances(show_list);
     161           0 : }
     162             : 
     163             : //
     164             : // Handler for ShowBgpInstanceConfigReq.
     165             : //
     166           0 : void ShowBgpInstanceConfigReq::HandleRequest() const {
     167           0 :     RequestPipeline::PipeSpec ps(this);
     168           0 :     RequestPipeline::StageSpec s1;
     169           0 :     TaskScheduler *scheduler = TaskScheduler::GetInstance();
     170             : 
     171           0 :     s1.taskId_ = scheduler->GetTaskId("bgp::ShowCommand");
     172             :     s1.cbFn_ = boost::bind(&BgpShowHandler<
     173             :         ShowBgpInstanceConfigReq,
     174             :         ShowBgpInstanceConfigReqIterate,
     175             :         ShowBgpInstanceConfigResp,
     176           0 :         ShowBgpInstanceConfig>::Callback, _1, _2, _3, _4, _5);
     177             :     s1.allocFn_ = BgpShowHandler<
     178             :         ShowBgpInstanceConfigReq,
     179             :         ShowBgpInstanceConfigReqIterate,
     180             :         ShowBgpInstanceConfigResp,
     181           0 :         ShowBgpInstanceConfig>::CreateData;
     182           0 :     s1.instances_.push_back(0);
     183           0 :     ps.stages_.push_back(s1);
     184           0 :     RequestPipeline rp(ps);
     185           0 : }
     186             : 
     187             : //
     188             : // Handler for ShowBgpInstanceConfigReqIterate.
     189             : //
     190           0 : void ShowBgpInstanceConfigReqIterate::HandleRequest() const {
     191           0 :     RequestPipeline::PipeSpec ps(this);
     192           0 :     RequestPipeline::StageSpec s1;
     193           0 :     TaskScheduler *scheduler = TaskScheduler::GetInstance();
     194             : 
     195           0 :     s1.taskId_ = scheduler->GetTaskId("bgp::ShowCommand");
     196             :     s1.cbFn_ = boost::bind(&BgpShowHandler<
     197             :         ShowBgpInstanceConfigReq,
     198             :         ShowBgpInstanceConfigReqIterate,
     199             :         ShowBgpInstanceConfigResp,
     200           0 :         ShowBgpInstanceConfig>::CallbackIterate, _1, _2, _3, _4, _5);
     201             :     s1.allocFn_ = BgpShowHandler<
     202             :         ShowBgpInstanceConfigReq,
     203             :         ShowBgpInstanceConfigReqIterate,
     204             :         ShowBgpInstanceConfigResp,
     205           0 :         ShowBgpInstanceConfig>::CreateData;
     206           0 :     s1.instances_.push_back(0);
     207           0 :     ps.stages_.push_back(s1);
     208           0 :     RequestPipeline rp(ps);
     209           0 : }
     210             : 
     211             : //
     212             : // Fill in information for an routing policy.
     213             : //
     214           0 : static void FillBgpRoutingPolicyInfo(ShowBgpRoutingPolicyConfig *sbrpc,
     215             :     const BgpSandeshContext *bsc, const BgpRoutingPolicyConfig *policy) {
     216           0 :     sbrpc->set_name(policy->name());
     217           0 :     std::vector<ShowBgpRoutingPolicyTermConfig> terms_list;
     218           0 :     for (const auto &term : policy->terms()) {
     219           0 :         ShowBgpRoutingPolicyTermConfig sbrptc;
     220           0 :         sbrptc.set_match(term.match.ToString());
     221           0 :         sbrptc.set_action(term.action.ToString());
     222           0 :         terms_list.push_back(sbrptc);
     223           0 :     }
     224           0 :     sbrpc->set_terms(terms_list);
     225           0 : }
     226             : 
     227             : //
     228             : // Specialization of BgpShowHandler<>::CallbackCommon.
     229             : //
     230             : template <>
     231           0 : bool BgpShowHandler<ShowBgpRoutingPolicyConfigReq,
     232             :      ShowBgpRoutingPolicyConfigReqIterate, ShowBgpRoutingPolicyConfigResp,
     233             :      ShowBgpRoutingPolicyConfig>::CallbackCommon(
     234             :     const BgpSandeshContext *bsc, Data *data) {
     235           0 :     uint32_t page_limit = bsc->page_limit() ? bsc->page_limit() : kPageLimit;
     236           0 :     uint32_t iter_limit = bsc->iter_limit() ? bsc->iter_limit() : kIterLimit;
     237           0 :     const BgpConfigManager *bcm = bsc->bgp_server->config_manager();
     238             : 
     239           0 :     regex search_expr(data->search_string);
     240             :     BgpConfigManager::RoutingPolicyMapRange range =
     241           0 :         bcm->RoutingPolicyMapItems(data->next_entry);
     242           0 :     BgpConfigManager::RoutingPolicyMap::const_iterator it = range.first;
     243           0 :     BgpConfigManager::RoutingPolicyMap::const_iterator it_end = range.second;
     244           0 :     for (uint32_t iter_count = 0; it != it_end; ++it, ++iter_count) {
     245           0 :         const BgpRoutingPolicyConfig *policy = it->second;
     246           0 :         if (!regex_search(policy->name(), search_expr))
     247           0 :             continue;
     248           0 :         ShowBgpRoutingPolicyConfig sbrpc;
     249           0 :         FillBgpRoutingPolicyInfo(&sbrpc, bsc, policy);
     250           0 :         data->show_list.push_back(sbrpc);
     251           0 :         if (data->show_list.size() >= page_limit)
     252           0 :             break;
     253           0 :         if (iter_count >= iter_limit)
     254           0 :             break;
     255           0 :     }
     256             : 
     257             :     // All done if we've looked at all policies.
     258           0 :     if (it == it_end || ++it == it_end)
     259           0 :         return true;
     260             : 
     261             :     // Return true if we've reached the page limit, false if we've reached the
     262             :     // iteration limit.
     263           0 :     bool done = data->show_list.size() >= page_limit;
     264           0 :     SaveContextToData(it->second->name(), done, data);
     265           0 :     return done;
     266           0 : }
     267             : 
     268             : //
     269             : // Specialization of BgpShowHandler<>::FillShowList.
     270             : //
     271             : template <>
     272           0 : void BgpShowHandler<ShowBgpRoutingPolicyConfigReq,
     273             :      ShowBgpRoutingPolicyConfigReqIterate, ShowBgpRoutingPolicyConfigResp,
     274             :      ShowBgpRoutingPolicyConfig>::FillShowList(
     275             :         ShowBgpRoutingPolicyConfigResp *resp,
     276             :         const vector<ShowBgpRoutingPolicyConfig> &show_list) {
     277           0 :     resp->set_routing_policies(show_list);
     278           0 : }
     279             : 
     280             : 
     281             : //
     282             : // Handler for ShowBgpRoutingPolicyConfigReq.
     283             : //
     284           0 : void ShowBgpRoutingPolicyConfigReq::HandleRequest() const {
     285           0 :     RequestPipeline::PipeSpec ps(this);
     286           0 :     RequestPipeline::StageSpec s1;
     287           0 :     TaskScheduler *scheduler = TaskScheduler::GetInstance();
     288             : 
     289           0 :     s1.taskId_ = scheduler->GetTaskId("bgp::ShowCommand");
     290             :     s1.cbFn_ = boost::bind(&BgpShowHandler<
     291             :         ShowBgpRoutingPolicyConfigReq,
     292             :         ShowBgpRoutingPolicyConfigReqIterate,
     293             :         ShowBgpRoutingPolicyConfigResp,
     294           0 :         ShowBgpRoutingPolicyConfig>::Callback, _1, _2, _3, _4, _5);
     295             :     s1.allocFn_ = BgpShowHandler<
     296             :         ShowBgpRoutingPolicyConfigReq,
     297             :         ShowBgpRoutingPolicyConfigReqIterate,
     298             :         ShowBgpRoutingPolicyConfigResp,
     299           0 :         ShowBgpRoutingPolicyConfig>::CreateData;
     300           0 :     s1.instances_.push_back(0);
     301           0 :     ps.stages_.push_back(s1);
     302           0 :     RequestPipeline rp(ps);
     303           0 : }
     304             : 
     305             : //
     306             : // Handler for ShowBgpRoutingPolicyConfigReqIterate.
     307             : //
     308           0 : void ShowBgpRoutingPolicyConfigReqIterate::HandleRequest() const {
     309           0 :     RequestPipeline::PipeSpec ps(this);
     310           0 :     RequestPipeline::StageSpec s1;
     311           0 :     TaskScheduler *scheduler = TaskScheduler::GetInstance();
     312             : 
     313           0 :     s1.taskId_ = scheduler->GetTaskId("bgp::ShowCommand");
     314             :     s1.cbFn_ = boost::bind(&BgpShowHandler<
     315             :         ShowBgpRoutingPolicyConfigReq,
     316             :         ShowBgpRoutingPolicyConfigReqIterate,
     317             :         ShowBgpRoutingPolicyConfigResp,
     318           0 :         ShowBgpRoutingPolicyConfig>::CallbackIterate, _1, _2, _3, _4, _5);
     319             :     s1.allocFn_ = BgpShowHandler<
     320             :         ShowBgpRoutingPolicyConfigReq,
     321             :         ShowBgpRoutingPolicyConfigReqIterate,
     322             :         ShowBgpRoutingPolicyConfigResp,
     323           0 :         ShowBgpRoutingPolicyConfig>::CreateData;
     324           0 :     s1.instances_.push_back(0);
     325           0 :     ps.stages_.push_back(s1);
     326           0 :     RequestPipeline rp(ps);
     327           0 : }
     328             : 
     329             : //
     330             : // Fill in information for a neighbor.
     331             : //
     332           0 : static void FillBgpNeighborConfigInfo(ShowBgpNeighborConfig *sbnc,
     333             :     const BgpSandeshContext *bsc, const BgpNeighborConfig *neighbor) {
     334           0 :     sbnc->set_instance_name(neighbor->instance_name());
     335           0 :     sbnc->set_name(neighbor->name());
     336           0 :     sbnc->set_admin_down(neighbor->admin_down());
     337           0 :     sbnc->set_passive(neighbor->passive());
     338           0 :     sbnc->set_as_override(neighbor->as_override());
     339             :     const BgpNeighborConfig::OriginOverrideConfig &route_origin =
     340           0 :                 neighbor->origin_override();
     341           0 :     sbnc->set_origin_override(route_origin.origin_override);
     342           0 :     if (route_origin.origin_override) {
     343           0 :         sbnc->set_route_origin(route_origin.origin);
     344             :     } else {
     345           0 :         sbnc->set_route_origin("-");
     346             :     }
     347           0 :     sbnc->set_private_as_action(neighbor->private_as_action());
     348           0 :     sbnc->set_router_type(neighbor->router_type());
     349           0 :     sbnc->set_local_identifier(neighbor->local_identifier_string());
     350           0 :     sbnc->set_local_as(neighbor->local_as());
     351           0 :     sbnc->set_autonomous_system(neighbor->peer_as());
     352           0 :     sbnc->set_identifier(neighbor->peer_identifier_string());
     353           0 :     sbnc->set_address(neighbor->peer_address().to_string());
     354           0 :     sbnc->set_cluster_id(Ip4Address(neighbor->cluster_id()).to_string());
     355           0 :     sbnc->set_source_port(neighbor->source_port());
     356           0 :     sbnc->set_address_families(neighbor->GetAddressFamilies());
     357           0 :     sbnc->set_hold_time(neighbor->hold_time());
     358           0 :     sbnc->set_loop_count(neighbor->loop_count());
     359           0 :     sbnc->set_last_change_at(UTCUsecToString(neighbor->last_change_at()));
     360           0 :     sbnc->set_auth_type(neighbor->auth_data().KeyTypeToString());
     361           0 :     if (bsc->test_mode()) {
     362           0 :         sbnc->set_auth_keys(neighbor->auth_data().KeysToStringDetail());
     363             :     }
     364             : 
     365           0 :     vector<ShowBgpNeighborFamilyConfig> sbnfc_list;
     366           0 :     for (const auto& family_config :
     367           0 :         neighbor->family_attributes_list()) {
     368           0 :         ShowBgpNeighborFamilyConfig sbnfc;
     369           0 :         sbnfc.set_family(family_config.family);
     370           0 :         sbnfc.set_loop_count(family_config.loop_count);
     371           0 :         sbnfc.set_prefix_limit(family_config.prefix_limit);
     372           0 :         sbnfc.set_idle_timeout(family_config.idle_timeout);
     373           0 :         sbnfc.set_default_tunnel_encap_list(
     374           0 :             family_config.default_tunnel_encap_list);
     375           0 :         if (family_config.family == "inet") {
     376           0 :             IpAddress address = neighbor->gateway_address(Address::INET);
     377           0 :             if (!address.is_unspecified())
     378           0 :                 sbnfc.set_gateway_address(address.to_string());
     379           0 :         } else if (family_config.family == "inet6") {
     380           0 :             IpAddress address = neighbor->gateway_address(Address::INET6);
     381           0 :             if (!address.is_unspecified())
     382           0 :                 sbnfc.set_gateway_address(address.to_string());
     383             :         }
     384           0 :         sbnfc_list.push_back(sbnfc);
     385           0 :     }
     386           0 :     sbnc->set_family_attributes_list(sbnfc_list);
     387           0 : }
     388             : 
     389             : //
     390             : // Specialization of BgpShowHandler<>::CallbackCommon.
     391             : //
     392             : template <>
     393           0 : bool BgpShowHandler<ShowBgpNeighborConfigReq, ShowBgpNeighborConfigReqIterate,
     394             :     ShowBgpNeighborConfigResp, ShowBgpNeighborConfig>::CallbackCommon(
     395             :     const BgpSandeshContext *bsc, Data *data) {
     396           0 :     uint32_t page_limit = bsc->page_limit() ? bsc->page_limit() : kPageLimit;
     397           0 :     uint32_t iter_limit = bsc->iter_limit() ? bsc->iter_limit() : kIterLimit;
     398           0 :     const BgpConfigManager *bcm = bsc->bgp_server->config_manager();
     399             : 
     400           0 :     regex search_expr(data->search_string);
     401             :     BgpConfigManager::InstanceMapRange range =
     402           0 :         bcm->InstanceMapItems(data->next_entry);
     403           0 :     BgpConfigManager::InstanceMap::const_iterator it = range.first;
     404           0 :     BgpConfigManager::InstanceMap::const_iterator it_end = range.second;
     405           0 :     for (uint32_t iter_count = 0; it != it_end; ++it, ++iter_count) {
     406           0 :         const BgpInstanceConfig *instance = it->second;
     407           0 :         BOOST_FOREACH(BgpConfigManager::NeighborMap::value_type value,
     408             :             bcm->NeighborMapItems(instance->name())) {
     409           0 :             const BgpNeighborConfig *neighbor = value.second;
     410           0 :             if (!regex_search(neighbor->name(), search_expr))
     411           0 :                 continue;
     412           0 :             ShowBgpNeighborConfig sbnc;
     413           0 :             FillBgpNeighborConfigInfo(&sbnc, bsc, neighbor);
     414           0 :             data->show_list.push_back(sbnc);
     415           0 :         }
     416           0 :         if (data->show_list.size() >= page_limit)
     417           0 :             break;
     418           0 :         if (iter_count >= iter_limit)
     419           0 :             break;
     420             :     }
     421             : 
     422             :     // All done if we've looked at all instances.
     423           0 :     if (it == it_end || ++it == it_end)
     424           0 :         return true;
     425             : 
     426             :     // Return true if we've reached the page limit, false if we've reached the
     427             :     // iteration limit.
     428           0 :     bool done = data->show_list.size() >= page_limit;
     429           0 :     SaveContextToData(it->second->name(), done, data);
     430           0 :     return done;
     431           0 : }
     432             : 
     433             : //
     434             : // Specialization of BgpShowHandler<>::FillShowList.
     435             : //
     436             : template <>
     437           0 : void BgpShowHandler<ShowBgpNeighborConfigReq, ShowBgpNeighborConfigReqIterate,
     438             :     ShowBgpNeighborConfigResp, ShowBgpNeighborConfig>::FillShowList(
     439             :         ShowBgpNeighborConfigResp *resp,
     440             :         const vector<ShowBgpNeighborConfig> &show_list) {
     441           0 :     resp->set_neighbors(show_list);
     442           0 : }
     443             : 
     444             : //
     445             : // Handler for ShowBgpNeighborConfigReq.
     446             : //
     447           0 : void ShowBgpNeighborConfigReq::HandleRequest() const {
     448           0 :     RequestPipeline::PipeSpec ps(this);
     449           0 :     RequestPipeline::StageSpec s1;
     450           0 :     TaskScheduler *scheduler = TaskScheduler::GetInstance();
     451             : 
     452           0 :     s1.taskId_ = scheduler->GetTaskId("bgp::ShowCommand");
     453             :     s1.cbFn_ = boost::bind(&BgpShowHandler<
     454             :         ShowBgpNeighborConfigReq,
     455             :         ShowBgpNeighborConfigReqIterate,
     456             :         ShowBgpNeighborConfigResp,
     457           0 :         ShowBgpNeighborConfig>::Callback, _1, _2, _3, _4, _5);
     458             :     s1.allocFn_ = BgpShowHandler<
     459             :         ShowBgpNeighborConfigReq,
     460             :         ShowBgpNeighborConfigReqIterate,
     461             :         ShowBgpNeighborConfigResp,
     462           0 :         ShowBgpNeighborConfig>::CreateData;
     463           0 :     s1.instances_.push_back(0);
     464           0 :     ps.stages_.push_back(s1);
     465           0 :     RequestPipeline rp(ps);
     466           0 : }
     467             : 
     468             : //
     469             : // Handler for ShowBgpNeighborConfigReqIterate.
     470             : //
     471           0 : void ShowBgpNeighborConfigReqIterate::HandleRequest() const {
     472           0 :     RequestPipeline::PipeSpec ps(this);
     473           0 :     RequestPipeline::StageSpec s1;
     474           0 :     TaskScheduler *scheduler = TaskScheduler::GetInstance();
     475             : 
     476           0 :     s1.taskId_ = scheduler->GetTaskId("bgp::ShowCommand");
     477             :     s1.cbFn_ = boost::bind(&BgpShowHandler<
     478             :         ShowBgpNeighborConfigReq,
     479             :         ShowBgpNeighborConfigReqIterate,
     480             :         ShowBgpNeighborConfigResp,
     481           0 :         ShowBgpNeighborConfig>::CallbackIterate, _1, _2, _3, _4, _5);
     482             :     s1.allocFn_ = BgpShowHandler<
     483             :         ShowBgpNeighborConfigReq,
     484             :         ShowBgpNeighborConfigReqIterate,
     485             :         ShowBgpNeighborConfigResp,
     486           0 :         ShowBgpNeighborConfig>::CreateData;
     487           0 :     s1.instances_.push_back(0);
     488           0 :     ps.stages_.push_back(s1);
     489           0 :     RequestPipeline rp(ps);
     490           0 : }
     491             : 
     492             : //
     493             : // Handler for ShowBgpPeeringConfigReq.
     494             : //
     495           0 : void ShowBgpPeeringConfigReq::HandleRequest() const {
     496           0 :     BgpSandeshContext *bsc = static_cast<BgpSandeshContext *>(client_context());
     497           0 :     bsc->PeeringShowReqHandler(this);
     498           0 : }
     499             : 
     500             : //
     501             : // Handler for ShowBgpPeeringConfigReqIterate.
     502             : //
     503           0 : void ShowBgpPeeringConfigReqIterate::HandleRequest() const {
     504           0 :     BgpSandeshContext *bsc = static_cast<BgpSandeshContext *>(client_context());
     505           0 :     bsc->PeeringShowReqIterateHandler(this);
     506           0 : }
     507             : 
     508             : //
     509             : // Fill in information for an instance.
     510             : //
     511           0 : static void FillBgpGlobalSystemConfigInfo(ShowBgpGlobalSystemConfig *sbgc,
     512             :     const BgpSandeshContext *bsc, const BgpGlobalSystemConfig *bgsc) {
     513             : 
     514           0 :     sbgc->set_gr_time(bgsc->gr_time());
     515           0 :     sbgc->set_llgr_time(bgsc->llgr_time());
     516           0 :     sbgc->set_last_change_at(bgsc->last_change_at());
     517           0 :     sbgc->set_end_of_rib_timeout(bgsc->end_of_rib_timeout());
     518           0 :     sbgc->set_gr_bgp_helper(bgsc->gr_bgp_helper());
     519           0 :     sbgc->set_gr_xmpp_helper(bgsc->gr_xmpp_helper());
     520           0 :     sbgc->set_gr_enable(bgsc->gr_enable());
     521           0 :     sbgc->set_always_compare_med(bgsc->always_compare_med());
     522           0 :     sbgc->set_rd_cluster_seed(bgsc->rd_cluster_seed());
     523           0 :     sbgc->set_bgpaas_port_start(bgsc->bgpaas_port_start());
     524           0 :     sbgc->set_bgpaas_port_end(bgsc->bgpaas_port_end());
     525           0 :     sbgc->set_all_tags_are_global(bgsc->all_tags_are_global());
     526           0 : }
     527             : 
     528             : //
     529             : //Specialization of BgpShowHandler<>::ConvertReqToData
     530             : //
     531             : template <>
     532           0 : void BgpShowHandler<ShowBgpGlobalSystemConfigReq,
     533             :                     ShowBgpGlobalSystemConfigReqIterate,
     534             :                     ShowBgpGlobalSystemConfigResp,
     535             :                     ShowBgpGlobalSystemConfig>::ConvertReqToData(
     536             :                       const ShowBgpGlobalSystemConfigReq *req, Data *data) {
     537             : 
     538           0 :     data->initialized = true;
     539           0 : }
     540             : 
     541             : //
     542             : // Specialization of BgpShowHandler<>::CallbackCommon.
     543             : //
     544             : template <>
     545           0 : bool BgpShowHandler<ShowBgpGlobalSystemConfigReq,
     546             :                     ShowBgpGlobalSystemConfigReqIterate,
     547             :                     ShowBgpGlobalSystemConfigResp,
     548             :                     ShowBgpGlobalSystemConfig>::CallbackCommon(
     549             :                             const BgpSandeshContext *bsc, Data *data) {
     550             : 
     551           0 :    const  BgpGlobalSystemConfig *bgsc = bsc->bgp_server->global_config();
     552             : 
     553           0 :    ShowBgpGlobalSystemConfig sbgc;
     554           0 :    FillBgpGlobalSystemConfigInfo(&sbgc, bsc, bgsc);
     555           0 :    data->show_list.push_back(sbgc);
     556             : 
     557           0 :    return true;
     558           0 : }
     559             : 
     560             : //
     561             : // Specialization of BgpShowHandler<>::FillShowList.
     562             : //
     563             : template <>
     564           0 : void BgpShowHandler<ShowBgpGlobalSystemConfigReq,
     565             :                     ShowBgpGlobalSystemConfigReqIterate,
     566             :                     ShowBgpGlobalSystemConfigResp,
     567             :                     ShowBgpGlobalSystemConfig>::FillShowList(
     568             :                     ShowBgpGlobalSystemConfigResp *resp,
     569             :                     const vector<ShowBgpGlobalSystemConfig> &show_list) {
     570           0 :     resp->set_global_instances(show_list);
     571           0 : }
     572             : 
     573             : //
     574             : // Handler for ShowBgpGlobalSystemConfigReq.
     575             : //
     576           0 : void ShowBgpGlobalSystemConfigReq::HandleRequest() const {
     577           0 :     RequestPipeline::PipeSpec ps(this);
     578           0 :     RequestPipeline::StageSpec s1;
     579           0 :     TaskScheduler *scheduler = TaskScheduler::GetInstance();
     580             : 
     581           0 :     s1.taskId_ = scheduler->GetTaskId("bgp::ShowCommand");
     582             :     s1.cbFn_ = boost::bind(&BgpShowHandler<
     583             :         ShowBgpGlobalSystemConfigReq,
     584             :         ShowBgpGlobalSystemConfigReqIterate,
     585             :         ShowBgpGlobalSystemConfigResp,
     586           0 :         ShowBgpGlobalSystemConfig>::Callback, _1, _2, _3, _4, _5);
     587             : 
     588             :     s1.allocFn_ = BgpShowHandler<
     589             :         ShowBgpGlobalSystemConfigReq,
     590             :         ShowBgpGlobalSystemConfigReqIterate,
     591             :         ShowBgpGlobalSystemConfigResp,
     592           0 :         ShowBgpGlobalSystemConfig>::CreateData;
     593             : 
     594           0 :     s1.instances_.push_back(0);
     595           0 :     ps.stages_.push_back(s1);
     596           0 :     RequestPipeline rp(ps);
     597           0 : }
     598             : 
     599             : //
     600             : // Handler for ShowBgpGlobalSystemConfigReqIterate.
     601             : //
     602           0 : void ShowBgpGlobalSystemConfigReqIterate::HandleRequest() const {
     603           0 :     RequestPipeline::PipeSpec ps(this);
     604           0 :     RequestPipeline::StageSpec s1;
     605           0 :     TaskScheduler *scheduler = TaskScheduler::GetInstance();
     606             : 
     607           0 :     s1.taskId_ = scheduler->GetTaskId("bgp::ShowCommand");
     608             :     s1.cbFn_ = boost::bind(&BgpShowHandler<
     609             :         ShowBgpGlobalSystemConfigReq,
     610             :         ShowBgpGlobalSystemConfigReqIterate,
     611             :         ShowBgpGlobalSystemConfigResp,
     612           0 :         ShowBgpGlobalSystemConfig>::CallbackIterate, _1, _2, _3, _4, _5);
     613             : 
     614             :     s1.allocFn_ = BgpShowHandler<
     615             :         ShowBgpGlobalSystemConfigReq,
     616             :         ShowBgpGlobalSystemConfigReqIterate,
     617             :         ShowBgpGlobalSystemConfigResp,
     618           0 :         ShowBgpGlobalSystemConfig>::CreateData;
     619             : 
     620           0 :     s1.instances_.push_back(0);
     621           0 :     ps.stages_.push_back(s1);
     622           0 :     RequestPipeline rp(ps);
     623           0 : }

Generated by: LCOV version 1.14