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