7 #include <boost/assign/list_of.hpp>
8 #include <boost/foreach.hpp>
13 #include "bgp/bgp_peer_internal_types.h"
16 using boost::assign::list_of;
28 sbic->set_name(instance->
name());
31 sbic->set_vxlan_id(instance->
vxlan_id());
33 vector<string> import_list;
35 import_list.push_back(rt);
37 sbic->set_import_target(import_list);
38 vector<string> export_list;
40 export_list.push_back(rt);
42 sbic->set_export_target(export_list);
43 sbic->set_has_pnf(instance->
has_pnf());
48 vector<string> neighbors(
50 sbic->set_neighbors(neighbors);
52 vector<ShowBgpServiceChainConfig> sbscc_list;
53 for (
const auto &sc_config :
55 ShowBgpServiceChainConfig sbscc;
59 sbscc.set_routing_instance(sc_config.routing_instance);
60 sbscc.set_service_instance(sc_config.service_instance);
61 sbscc.set_chain_address(sc_config.service_chain_address);
62 sbscc.set_prefixes(sc_config.prefix);
63 sbscc_list.push_back(sbscc);
65 sbic->set_service_chain_infos(sbscc_list);
67 vector<ShowBgpStaticRouteConfig> static_route_list;
69 for (
auto family : families) {
70 for (
const auto &static_rt_config :
72 ShowBgpStaticRouteConfig sbsrc;
73 string prefix = static_rt_config.address.to_string() +
"/";
75 sbsrc.set_prefix(prefix);
76 sbsrc.set_nexthop(static_rt_config.nexthop.to_string());
77 sbsrc.set_targets(static_rt_config.communities);
78 sbsrc.set_targets(static_rt_config.route_targets);
79 static_route_list.push_back(sbsrc);
82 if (!static_route_list.empty())
83 sbic->set_static_routes(static_route_list);
85 vector<ShowBgpRouteAggregateConfig> aggregate_route_list;
86 for (
auto family : families) {
87 for (
const auto &aggregate_rt_config :
89 ShowBgpRouteAggregateConfig sbarc;
90 string prefix = aggregate_rt_config.aggregate.to_string() +
"/";
92 sbarc.set_prefix(prefix);
93 sbarc.set_nexthop(aggregate_rt_config.nexthop.to_string());
94 aggregate_route_list.push_back(sbarc);
97 if (!aggregate_route_list.empty())
98 sbic->set_aggregate_routes(aggregate_route_list);
100 vector<ShowBgpInstanceRoutingPolicyConfig> routing_policy_list;
101 for (
const auto &policy_config :
103 ShowBgpInstanceRoutingPolicyConfig sbirpc;
104 sbirpc.set_policy_name(policy_config.routing_policy_);
105 sbirpc.set_sequence(policy_config.sequence_);
106 routing_policy_list.push_back(sbirpc);
108 if (!routing_policy_list.empty())
109 sbic->set_routing_policies(routing_policy_list);
116 bool BgpShowHandler<ShowBgpInstanceConfigReq, ShowBgpInstanceConfigReqIterate,
117 ShowBgpInstanceConfigResp, ShowBgpInstanceConfig>::CallbackCommon(
126 BgpConfigManager::InstanceMap::const_iterator it = range.first;
127 BgpConfigManager::InstanceMap::const_iterator it_end = range.second;
128 for (uint32_t iter_count = 0; it != it_end; ++it, ++iter_count) {
132 ShowBgpInstanceConfig sbic;
135 if (data->
show_list.size() >= page_limit)
137 if (iter_count >= iter_limit)
142 if (it == it_end || ++it == it_end)
147 bool done = data->
show_list.size() >= page_limit;
148 SaveContextToData(it->second->name(), done, data);
156 void BgpShowHandler<ShowBgpInstanceConfigReq, ShowBgpInstanceConfigReqIterate,
157 ShowBgpInstanceConfigResp, ShowBgpInstanceConfig>::FillShowList(
158 ShowBgpInstanceConfigResp *resp,
159 const vector<ShowBgpInstanceConfig> &show_list) {
160 resp->set_instances(show_list);
166 void ShowBgpInstanceConfigReq::HandleRequest()
const {
173 ShowBgpInstanceConfigReq,
174 ShowBgpInstanceConfigReqIterate,
175 ShowBgpInstanceConfigResp,
176 ShowBgpInstanceConfig>::Callback, _1, _2, _3, _4, _5);
178 ShowBgpInstanceConfigReq,
179 ShowBgpInstanceConfigReqIterate,
180 ShowBgpInstanceConfigResp,
181 ShowBgpInstanceConfig>::CreateData;
183 ps.stages_.push_back(s1);
190 void ShowBgpInstanceConfigReqIterate::HandleRequest()
const {
197 ShowBgpInstanceConfigReq,
198 ShowBgpInstanceConfigReqIterate,
199 ShowBgpInstanceConfigResp,
200 ShowBgpInstanceConfig>::CallbackIterate, _1, _2, _3, _4, _5);
202 ShowBgpInstanceConfigReq,
203 ShowBgpInstanceConfigReqIterate,
204 ShowBgpInstanceConfigResp,
205 ShowBgpInstanceConfig>::CreateData;
207 ps.stages_.push_back(s1);
216 sbrpc->set_name(policy->
name());
217 std::vector<ShowBgpRoutingPolicyTermConfig> terms_list;
218 for (
const auto &term : policy->
terms()) {
219 ShowBgpRoutingPolicyTermConfig sbrptc;
220 sbrptc.set_match(term.match.ToString());
221 sbrptc.set_action(term.action.ToString());
222 terms_list.push_back(sbrptc);
224 sbrpc->set_terms(terms_list);
232 ShowBgpRoutingPolicyConfigReqIterate, ShowBgpRoutingPolicyConfigResp,
233 ShowBgpRoutingPolicyConfig>::CallbackCommon(
242 BgpConfigManager::RoutingPolicyMap::const_iterator it = range.first;
243 BgpConfigManager::RoutingPolicyMap::const_iterator it_end = range.second;
244 for (uint32_t iter_count = 0; it != it_end; ++it, ++iter_count) {
248 ShowBgpRoutingPolicyConfig sbrpc;
251 if (data->
show_list.size() >= page_limit)
253 if (iter_count >= iter_limit)
258 if (it == it_end || ++it == it_end)
263 bool done = data->
show_list.size() >= page_limit;
264 SaveContextToData(it->second->name(), done, data);
273 ShowBgpRoutingPolicyConfigReqIterate, ShowBgpRoutingPolicyConfigResp,
274 ShowBgpRoutingPolicyConfig>::FillShowList(
275 ShowBgpRoutingPolicyConfigResp *resp,
276 const vector<ShowBgpRoutingPolicyConfig> &show_list) {
277 resp->set_routing_policies(show_list);
284 void ShowBgpRoutingPolicyConfigReq::HandleRequest()
const {
291 ShowBgpRoutingPolicyConfigReq,
292 ShowBgpRoutingPolicyConfigReqIterate,
293 ShowBgpRoutingPolicyConfigResp,
294 ShowBgpRoutingPolicyConfig>::Callback, _1, _2, _3, _4, _5);
296 ShowBgpRoutingPolicyConfigReq,
297 ShowBgpRoutingPolicyConfigReqIterate,
298 ShowBgpRoutingPolicyConfigResp,
299 ShowBgpRoutingPolicyConfig>::CreateData;
301 ps.stages_.push_back(s1);
308 void ShowBgpRoutingPolicyConfigReqIterate::HandleRequest()
const {
315 ShowBgpRoutingPolicyConfigReq,
316 ShowBgpRoutingPolicyConfigReqIterate,
317 ShowBgpRoutingPolicyConfigResp,
318 ShowBgpRoutingPolicyConfig>::CallbackIterate, _1, _2, _3, _4, _5);
320 ShowBgpRoutingPolicyConfigReq,
321 ShowBgpRoutingPolicyConfigReqIterate,
322 ShowBgpRoutingPolicyConfigResp,
323 ShowBgpRoutingPolicyConfig>::CreateData;
325 ps.stages_.push_back(s1);
335 sbnc->set_name(neighbor->
name());
337 sbnc->set_passive(neighbor->
passive());
343 sbnc->set_route_origin(route_origin.
origin);
345 sbnc->set_route_origin(
"-");
350 sbnc->set_local_as(neighbor->
local_as());
351 sbnc->set_autonomous_system(neighbor->
peer_as());
353 sbnc->set_address(neighbor->
peer_address().to_string());
357 sbnc->set_hold_time(neighbor->
hold_time());
365 vector<ShowBgpNeighborFamilyConfig> sbnfc_list;
366 for (
const auto& family_config :
368 ShowBgpNeighborFamilyConfig sbnfc;
369 sbnfc.set_family(family_config.family);
370 sbnfc.set_loop_count(family_config.loop_count);
371 sbnfc.set_prefix_limit(family_config.prefix_limit);
372 sbnfc.set_idle_timeout(family_config.idle_timeout);
373 sbnfc.set_default_tunnel_encap_list(
374 family_config.default_tunnel_encap_list);
375 if (family_config.family ==
"inet") {
377 if (!address.is_unspecified())
378 sbnfc.set_gateway_address(address.to_string());
379 }
else if (family_config.family ==
"inet6") {
381 if (!address.is_unspecified())
382 sbnfc.set_gateway_address(address.to_string());
384 sbnfc_list.push_back(sbnfc);
386 sbnc->set_family_attributes_list(sbnfc_list);
393 bool BgpShowHandler<ShowBgpNeighborConfigReq, ShowBgpNeighborConfigReqIterate,
394 ShowBgpNeighborConfigResp, ShowBgpNeighborConfig>::CallbackCommon(
403 BgpConfigManager::InstanceMap::const_iterator it = range.first;
404 BgpConfigManager::InstanceMap::const_iterator it_end = range.second;
405 for (uint32_t iter_count = 0; it != it_end; ++it, ++iter_count) {
407 BOOST_FOREACH(BgpConfigManager::NeighborMap::value_type value,
412 ShowBgpNeighborConfig sbnc;
416 if (data->
show_list.size() >= page_limit)
418 if (iter_count >= iter_limit)
423 if (it == it_end || ++it == it_end)
428 bool done = data->
show_list.size() >= page_limit;
429 SaveContextToData(it->second->name(), done, data);
437 void BgpShowHandler<ShowBgpNeighborConfigReq, ShowBgpNeighborConfigReqIterate,
438 ShowBgpNeighborConfigResp, ShowBgpNeighborConfig>::FillShowList(
439 ShowBgpNeighborConfigResp *resp,
440 const vector<ShowBgpNeighborConfig> &show_list) {
441 resp->set_neighbors(show_list);
447 void ShowBgpNeighborConfigReq::HandleRequest()
const {
454 ShowBgpNeighborConfigReq,
455 ShowBgpNeighborConfigReqIterate,
456 ShowBgpNeighborConfigResp,
457 ShowBgpNeighborConfig>::Callback, _1, _2, _3, _4, _5);
459 ShowBgpNeighborConfigReq,
460 ShowBgpNeighborConfigReqIterate,
461 ShowBgpNeighborConfigResp,
462 ShowBgpNeighborConfig>::CreateData;
464 ps.stages_.push_back(s1);
471 void ShowBgpNeighborConfigReqIterate::HandleRequest()
const {
478 ShowBgpNeighborConfigReq,
479 ShowBgpNeighborConfigReqIterate,
480 ShowBgpNeighborConfigResp,
481 ShowBgpNeighborConfig>::CallbackIterate, _1, _2, _3, _4, _5);
483 ShowBgpNeighborConfigReq,
484 ShowBgpNeighborConfigReqIterate,
485 ShowBgpNeighborConfigResp,
486 ShowBgpNeighborConfig>::CreateData;
488 ps.stages_.push_back(s1);
495 void ShowBgpPeeringConfigReq::HandleRequest()
const {
503 void ShowBgpPeeringConfigReqIterate::HandleRequest()
const {
514 sbgc->set_gr_time(bgsc->
gr_time());
532 ShowBgpGlobalSystemConfigReqIterate,
533 ShowBgpGlobalSystemConfigResp,
534 ShowBgpGlobalSystemConfig>::ConvertReqToData(
535 const ShowBgpGlobalSystemConfigReq *req,
Data *data) {
545 ShowBgpGlobalSystemConfigReqIterate,
546 ShowBgpGlobalSystemConfigResp,
547 ShowBgpGlobalSystemConfig>::CallbackCommon(
552 ShowBgpGlobalSystemConfig sbgc;
564 ShowBgpGlobalSystemConfigReqIterate,
565 ShowBgpGlobalSystemConfigResp,
566 ShowBgpGlobalSystemConfig>::FillShowList(
567 ShowBgpGlobalSystemConfigResp *resp,
568 const vector<ShowBgpGlobalSystemConfig> &show_list) {
569 resp->set_global_instances(show_list);
575 void ShowBgpGlobalSystemConfigReq::HandleRequest()
const {
582 ShowBgpGlobalSystemConfigReq,
583 ShowBgpGlobalSystemConfigReqIterate,
584 ShowBgpGlobalSystemConfigResp,
585 ShowBgpGlobalSystemConfig>::Callback, _1, _2, _3, _4, _5);
588 ShowBgpGlobalSystemConfigReq,
589 ShowBgpGlobalSystemConfigReqIterate,
590 ShowBgpGlobalSystemConfigResp,
591 ShowBgpGlobalSystemConfig>::CreateData;
594 ps.stages_.push_back(s1);
601 void ShowBgpGlobalSystemConfigReqIterate::HandleRequest()
const {
608 ShowBgpGlobalSystemConfigReq,
609 ShowBgpGlobalSystemConfigReqIterate,
610 ShowBgpGlobalSystemConfigResp,
611 ShowBgpGlobalSystemConfig>::CallbackIterate, _1, _2, _3, _4, _5);
614 ShowBgpGlobalSystemConfigReq,
615 ShowBgpGlobalSystemConfigReqIterate,
616 ShowBgpGlobalSystemConfigResp,
617 ShowBgpGlobalSystemConfig>::CreateData;
620 ps.stages_.push_back(s1);
const std::string & virtual_network() const
std::vector< int > instances_
virtual NeighborMapRange NeighborMapItems(const std::string &instance_name) const =0
const RouteTargetList & import_list() const
const OriginOverrideConfig & origin_override() const
static Address::Family SCFamilyToAddressFamily(Family family)
The TaskScheduler keeps track of what tasks are currently schedulable. When a task is enqueued it is ...
uint64_t last_change_at() const
static void FillBgpGlobalSystemConfigInfo(ShowBgpGlobalSystemConfig *sbgc, const BgpSandeshContext *bsc, const BgpGlobalSystemConfig *bgsc)
std::pair< RoutingPolicyMap::const_iterator, RoutingPolicyMap::const_iterator > RoutingPolicyMapRange
const std::string & name() const
std::pair< InstanceMap::const_iterator, InstanceMap::const_iterator > InstanceMapRange
const std::string & instance_name() const
bool gr_bgp_helper() const
std::string KeyTypeToString() const
boost::asio::ip::address IpAddress
uint32_t last_change_at() const
BgpGlobalSystemConfig * global_config()
uint16_t rd_cluster_seed() const
static void FillBgpNeighborConfigInfo(ShowBgpNeighborConfig *sbnc, const BgpSandeshContext *bsc, const BgpNeighborConfig *neighbor)
const RouteTargetList & export_list() const
const FamilyAttributesList & family_attributes_list() const
std::string router_type() const
bool virtual_network_pbb_evpn_enable() const
std::string private_as_action() const
uint8_t loop_count() const
int GetTaskId(const std::string &name)
std::vector< std::string > KeysToStringDetail() const
static bool regex_match(const std::string &input, const regex ®ex)
bool gr_xmpp_helper() const
const std::string & name() const
uint16_t source_port() const
bool always_compare_med() const
static const std::string integerToString(const NumberType &num)
static TaskScheduler * GetInstance()
uint32_t iter_limit() const
BgpConfigManager * config_manager()
uint64_t last_change_at() const
uint16_t end_of_rib_timeout() const
const AuthenticationData & auth_data() const
std::string peer_identifier_string() const
std::vector< ShowT > show_list
uint32_t local_as() const
std::string search_string
static bool regex_search(const std::string &input, const regex ®ex)
const ServiceChainList & service_chain_list() const
boost::asio::ip::address_v4 Ip4Address
uint16_t bgpaas_port_start() const
uint32_t cluster_id() const
virtual InstanceMapRange InstanceMapItems(const std::string &start_instance=std::string()) const =0
AddressFamilyList GetAddressFamilies() const
static std::string FamilyToString(Family fmly)
uint32_t page_limit() const
const AggregateRouteList & aggregate_routes(Address::Family family) const
uint16_t bgpaas_port_end() const
const IpAddress & gateway_address(Address::Family family) const
static void FillBgpRoutingPolicyInfo(ShowBgpRoutingPolicyConfig *sbrpc, const BgpSandeshContext *bsc, const BgpRoutingPolicyConfig *policy)
const RoutingPolicyConfigList & routing_policy_list() const
void PeeringShowReqHandler(const ShowBgpPeeringConfigReq *req)
std::string local_identifier_string() const
const NeighborList & neighbor_list() const
int virtual_network_index() const
void PeeringShowReqIterateHandler(const ShowBgpPeeringConfigReqIterate *req_iterate)
const std::string & name() const
bool virtual_network_allow_transit() const
uint32_t llgr_time() const
const IpAddress & peer_address() const
static void FillBgpInstanceConfigInfo(ShowBgpInstanceConfig *sbic, const BgpSandeshContext *bsc, const BgpInstanceConfig *instance)
virtual RoutingPolicyMapRange RoutingPolicyMapItems(const std::string &start_policy=std::string()) const =0
const StaticRouteList & static_routes(Address::Family family) const
static std::string UTCUsecToString(uint64_t tstamp)
const RoutingPolicyTermList & terms() const