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

Generated by: LCOV version 1.14