8 #include <boost/assign/list_of.hpp>
9 #include <boost/foreach.hpp>
14 #include "bgp/bgp_peer_internal_types.h"
17 using boost::assign::list_of;
29 sbic->set_name(instance->
name());
32 sbic->set_vxlan_id(instance->
vxlan_id());
34 vector<string> import_list;
36 import_list.push_back(rt);
38 sbic->set_import_target(import_list);
39 vector<string> export_list;
41 export_list.push_back(rt);
43 sbic->set_export_target(export_list);
44 sbic->set_has_pnf(instance->
has_pnf());
49 vector<string> neighbors(
51 sbic->set_neighbors(neighbors);
53 vector<ShowBgpServiceChainConfig> sbscc_list;
54 for (
const auto &sc_config :
56 ShowBgpServiceChainConfig sbscc;
60 sbscc.set_routing_instance(sc_config.routing_instance);
61 sbscc.set_service_instance(sc_config.service_instance);
62 sbscc.set_chain_address(sc_config.service_chain_address);
63 sbscc.set_prefixes(sc_config.prefix);
64 sbscc_list.push_back(sbscc);
66 sbic->set_service_chain_infos(sbscc_list);
68 vector<ShowBgpStaticRouteConfig> static_route_list;
70 for (
auto family : families) {
71 for (
const auto &static_rt_config :
73 ShowBgpStaticRouteConfig sbsrc;
74 string prefix = static_rt_config.address.to_string() +
"/";
76 sbsrc.set_prefix(prefix);
77 sbsrc.set_nexthop(static_rt_config.nexthop.to_string());
78 sbsrc.set_targets(static_rt_config.communities);
79 sbsrc.set_targets(static_rt_config.route_targets);
80 static_route_list.push_back(sbsrc);
83 if (!static_route_list.empty())
84 sbic->set_static_routes(static_route_list);
86 vector<ShowBgpRouteAggregateConfig> aggregate_route_list;
87 for (
auto family : families) {
88 for (
const auto &aggregate_rt_config :
90 ShowBgpRouteAggregateConfig sbarc;
91 string prefix = aggregate_rt_config.aggregate.to_string() +
"/";
93 sbarc.set_prefix(prefix);
94 sbarc.set_nexthop(aggregate_rt_config.nexthop.to_string());
95 aggregate_route_list.push_back(sbarc);
98 if (!aggregate_route_list.empty())
99 sbic->set_aggregate_routes(aggregate_route_list);
101 vector<ShowBgpInstanceRoutingPolicyConfig> routing_policy_list;
102 for (
const auto &policy_config :
104 ShowBgpInstanceRoutingPolicyConfig sbirpc;
105 sbirpc.set_policy_name(policy_config.routing_policy_);
106 sbirpc.set_sequence(policy_config.sequence_);
107 routing_policy_list.push_back(sbirpc);
109 if (!routing_policy_list.empty())
110 sbic->set_routing_policies(routing_policy_list);
117 bool BgpShowHandler<ShowBgpInstanceConfigReq, ShowBgpInstanceConfigReqIterate,
118 ShowBgpInstanceConfigResp, ShowBgpInstanceConfig>::CallbackCommon(
127 BgpConfigManager::InstanceMap::const_iterator it = range.first;
128 BgpConfigManager::InstanceMap::const_iterator it_end = range.second;
129 for (uint32_t iter_count = 0; it != it_end; ++it, ++iter_count) {
133 ShowBgpInstanceConfig sbic;
136 if (data->
show_list.size() >= page_limit)
138 if (iter_count >= iter_limit)
143 if (it == it_end || ++it == it_end)
148 bool done = data->
show_list.size() >= page_limit;
149 SaveContextToData(it->second->name(), done, data);
157 void BgpShowHandler<ShowBgpInstanceConfigReq, ShowBgpInstanceConfigReqIterate,
158 ShowBgpInstanceConfigResp, ShowBgpInstanceConfig>::FillShowList(
159 ShowBgpInstanceConfigResp *resp,
160 const vector<ShowBgpInstanceConfig> &show_list) {
161 resp->set_instances(show_list);
167 void ShowBgpInstanceConfigReq::HandleRequest()
const {
174 ShowBgpInstanceConfigReq,
175 ShowBgpInstanceConfigReqIterate,
176 ShowBgpInstanceConfigResp,
177 ShowBgpInstanceConfig>::Callback, _1, _2, _3, _4, _5);
179 ShowBgpInstanceConfigReq,
180 ShowBgpInstanceConfigReqIterate,
181 ShowBgpInstanceConfigResp,
182 ShowBgpInstanceConfig>::CreateData;
184 ps.stages_.push_back(s1);
191 void ShowBgpInstanceConfigReqIterate::HandleRequest()
const {
198 ShowBgpInstanceConfigReq,
199 ShowBgpInstanceConfigReqIterate,
200 ShowBgpInstanceConfigResp,
201 ShowBgpInstanceConfig>::CallbackIterate, _1, _2, _3, _4, _5);
203 ShowBgpInstanceConfigReq,
204 ShowBgpInstanceConfigReqIterate,
205 ShowBgpInstanceConfigResp,
206 ShowBgpInstanceConfig>::CreateData;
208 ps.stages_.push_back(s1);
217 sbrpc->set_name(policy->
name());
218 std::vector<ShowBgpRoutingPolicyTermConfig> terms_list;
219 for (
const auto &term : policy->
terms()) {
220 ShowBgpRoutingPolicyTermConfig sbrptc;
221 sbrptc.set_match(term.match.ToString());
222 sbrptc.set_action(term.action.ToString());
223 terms_list.push_back(sbrptc);
225 sbrpc->set_terms(terms_list);
233 ShowBgpRoutingPolicyConfigReqIterate, ShowBgpRoutingPolicyConfigResp,
234 ShowBgpRoutingPolicyConfig>::CallbackCommon(
243 BgpConfigManager::RoutingPolicyMap::const_iterator it = range.first;
244 BgpConfigManager::RoutingPolicyMap::const_iterator it_end = range.second;
245 for (uint32_t iter_count = 0; it != it_end; ++it, ++iter_count) {
249 ShowBgpRoutingPolicyConfig sbrpc;
252 if (data->
show_list.size() >= page_limit)
254 if (iter_count >= iter_limit)
259 if (it == it_end || ++it == it_end)
264 bool done = data->
show_list.size() >= page_limit;
265 SaveContextToData(it->second->name(), done, data);
274 ShowBgpRoutingPolicyConfigReqIterate, ShowBgpRoutingPolicyConfigResp,
275 ShowBgpRoutingPolicyConfig>::FillShowList(
276 ShowBgpRoutingPolicyConfigResp *resp,
277 const vector<ShowBgpRoutingPolicyConfig> &show_list) {
278 resp->set_routing_policies(show_list);
285 void ShowBgpRoutingPolicyConfigReq::HandleRequest()
const {
292 ShowBgpRoutingPolicyConfigReq,
293 ShowBgpRoutingPolicyConfigReqIterate,
294 ShowBgpRoutingPolicyConfigResp,
295 ShowBgpRoutingPolicyConfig>::Callback, _1, _2, _3, _4, _5);
297 ShowBgpRoutingPolicyConfigReq,
298 ShowBgpRoutingPolicyConfigReqIterate,
299 ShowBgpRoutingPolicyConfigResp,
300 ShowBgpRoutingPolicyConfig>::CreateData;
302 ps.stages_.push_back(s1);
309 void ShowBgpRoutingPolicyConfigReqIterate::HandleRequest()
const {
316 ShowBgpRoutingPolicyConfigReq,
317 ShowBgpRoutingPolicyConfigReqIterate,
318 ShowBgpRoutingPolicyConfigResp,
319 ShowBgpRoutingPolicyConfig>::CallbackIterate, _1, _2, _3, _4, _5);
321 ShowBgpRoutingPolicyConfigReq,
322 ShowBgpRoutingPolicyConfigReqIterate,
323 ShowBgpRoutingPolicyConfigResp,
324 ShowBgpRoutingPolicyConfig>::CreateData;
326 ps.stages_.push_back(s1);
336 sbnc->set_name(neighbor->
name());
338 sbnc->set_passive(neighbor->
passive());
344 sbnc->set_route_origin(route_origin.
origin);
346 sbnc->set_route_origin(
"-");
351 sbnc->set_local_as(neighbor->
local_as());
352 sbnc->set_autonomous_system(neighbor->
peer_as());
354 sbnc->set_address(neighbor->
peer_address().to_string());
358 sbnc->set_hold_time(neighbor->
hold_time());
366 vector<ShowBgpNeighborFamilyConfig> sbnfc_list;
367 for (
const auto& family_config :
369 ShowBgpNeighborFamilyConfig sbnfc;
370 sbnfc.set_family(family_config.family);
371 sbnfc.set_loop_count(family_config.loop_count);
372 sbnfc.set_prefix_limit(family_config.prefix_limit);
373 sbnfc.set_idle_timeout(family_config.idle_timeout);
374 sbnfc.set_default_tunnel_encap_list(
375 family_config.default_tunnel_encap_list);
376 if (family_config.family ==
"inet") {
378 if (!address.is_unspecified())
379 sbnfc.set_gateway_address(address.to_string());
380 }
else if (family_config.family ==
"inet6") {
382 if (!address.is_unspecified())
383 sbnfc.set_gateway_address(address.to_string());
385 sbnfc_list.push_back(sbnfc);
387 sbnc->set_family_attributes_list(sbnfc_list);
394 bool BgpShowHandler<ShowBgpNeighborConfigReq, ShowBgpNeighborConfigReqIterate,
395 ShowBgpNeighborConfigResp, ShowBgpNeighborConfig>::CallbackCommon(
404 BgpConfigManager::InstanceMap::const_iterator it = range.first;
405 BgpConfigManager::InstanceMap::const_iterator it_end = range.second;
406 for (uint32_t iter_count = 0; it != it_end; ++it, ++iter_count) {
408 BOOST_FOREACH(BgpConfigManager::NeighborMap::value_type value,
413 ShowBgpNeighborConfig sbnc;
417 if (data->
show_list.size() >= page_limit)
419 if (iter_count >= iter_limit)
424 if (it == it_end || ++it == it_end)
429 bool done = data->
show_list.size() >= page_limit;
430 SaveContextToData(it->second->name(), done, data);
438 void BgpShowHandler<ShowBgpNeighborConfigReq, ShowBgpNeighborConfigReqIterate,
439 ShowBgpNeighborConfigResp, ShowBgpNeighborConfig>::FillShowList(
440 ShowBgpNeighborConfigResp *resp,
441 const vector<ShowBgpNeighborConfig> &show_list) {
442 resp->set_neighbors(show_list);
448 void ShowBgpNeighborConfigReq::HandleRequest()
const {
455 ShowBgpNeighborConfigReq,
456 ShowBgpNeighborConfigReqIterate,
457 ShowBgpNeighborConfigResp,
458 ShowBgpNeighborConfig>::Callback, _1, _2, _3, _4, _5);
460 ShowBgpNeighborConfigReq,
461 ShowBgpNeighborConfigReqIterate,
462 ShowBgpNeighborConfigResp,
463 ShowBgpNeighborConfig>::CreateData;
465 ps.stages_.push_back(s1);
472 void ShowBgpNeighborConfigReqIterate::HandleRequest()
const {
479 ShowBgpNeighborConfigReq,
480 ShowBgpNeighborConfigReqIterate,
481 ShowBgpNeighborConfigResp,
482 ShowBgpNeighborConfig>::CallbackIterate, _1, _2, _3, _4, _5);
484 ShowBgpNeighborConfigReq,
485 ShowBgpNeighborConfigReqIterate,
486 ShowBgpNeighborConfigResp,
487 ShowBgpNeighborConfig>::CreateData;
489 ps.stages_.push_back(s1);
496 void ShowBgpPeeringConfigReq::HandleRequest()
const {
504 void ShowBgpPeeringConfigReqIterate::HandleRequest()
const {
515 sbgc->set_gr_time(bgsc->
gr_time());
534 ShowBgpGlobalSystemConfigReqIterate,
535 ShowBgpGlobalSystemConfigResp,
536 ShowBgpGlobalSystemConfig>::ConvertReqToData(
537 const ShowBgpGlobalSystemConfigReq *req,
Data *data) {
547 ShowBgpGlobalSystemConfigReqIterate,
548 ShowBgpGlobalSystemConfigResp,
549 ShowBgpGlobalSystemConfig>::CallbackCommon(
554 ShowBgpGlobalSystemConfig sbgc;
566 ShowBgpGlobalSystemConfigReqIterate,
567 ShowBgpGlobalSystemConfigResp,
568 ShowBgpGlobalSystemConfig>::FillShowList(
569 ShowBgpGlobalSystemConfigResp *resp,
570 const vector<ShowBgpGlobalSystemConfig> &show_list) {
571 resp->set_global_instances(show_list);
577 void ShowBgpGlobalSystemConfigReq::HandleRequest()
const {
584 ShowBgpGlobalSystemConfigReq,
585 ShowBgpGlobalSystemConfigReqIterate,
586 ShowBgpGlobalSystemConfigResp,
587 ShowBgpGlobalSystemConfig>::Callback, _1, _2, _3, _4, _5);
590 ShowBgpGlobalSystemConfigReq,
591 ShowBgpGlobalSystemConfigReqIterate,
592 ShowBgpGlobalSystemConfigResp,
593 ShowBgpGlobalSystemConfig>::CreateData;
596 ps.stages_.push_back(s1);
603 void ShowBgpGlobalSystemConfigReqIterate::HandleRequest()
const {
610 ShowBgpGlobalSystemConfigReq,
611 ShowBgpGlobalSystemConfigReqIterate,
612 ShowBgpGlobalSystemConfigResp,
613 ShowBgpGlobalSystemConfig>::CallbackIterate, _1, _2, _3, _4, _5);
616 ShowBgpGlobalSystemConfigReq,
617 ShowBgpGlobalSystemConfigReqIterate,
618 ShowBgpGlobalSystemConfigResp,
619 ShowBgpGlobalSystemConfig>::CreateData;
622 ps.stages_.push_back(s1);
boost::asio::ip::address IpAddress
boost::asio::ip::address_v4 Ip4Address
static void FillBgpGlobalSystemConfigInfo(ShowBgpGlobalSystemConfig *sbgc, const BgpSandeshContext *bsc, const BgpGlobalSystemConfig *bgsc)
static void FillBgpInstanceConfigInfo(ShowBgpInstanceConfig *sbic, const BgpSandeshContext *bsc, const BgpInstanceConfig *instance)
static void FillBgpNeighborConfigInfo(ShowBgpNeighborConfig *sbnc, const BgpSandeshContext *bsc, const BgpNeighborConfig *neighbor)
static void FillBgpRoutingPolicyInfo(ShowBgpRoutingPolicyConfig *sbrpc, const BgpSandeshContext *bsc, const BgpRoutingPolicyConfig *policy)
static std::string FamilyToString(Family fmly)
std::vector< std::string > KeysToStringDetail() const
std::string KeyTypeToString() const
virtual NeighborMapRange NeighborMapItems(const std::string &instance_name) const =0
virtual InstanceMapRange InstanceMapItems(const std::string &start_instance=std::string()) const =0
virtual RoutingPolicyMapRange RoutingPolicyMapItems(const std::string &start_policy=std::string()) const =0
std::pair< InstanceMap::const_iterator, InstanceMap::const_iterator > InstanceMapRange
std::pair< RoutingPolicyMap::const_iterator, RoutingPolicyMap::const_iterator > RoutingPolicyMapRange
bool all_tags_are_global() const
uint16_t bgpaas_port_start() const
uint16_t end_of_rib_timeout() const
uint16_t bgpaas_port_end() const
bool gr_bgp_helper() const
uint16_t rd_cluster_seed() const
uint32_t llgr_time() const
bool always_compare_med() const
uint32_t last_change_at() const
bool gr_xmpp_helper() const
const RoutingPolicyConfigList & routing_policy_list() const
const std::string & virtual_network() const
int virtual_network_index() const
const RouteTargetList & export_list() const
const RouteTargetList & import_list() const
const AggregateRouteList & aggregate_routes(Address::Family family) const
const std::string & name() const
bool virtual_network_allow_transit() const
bool virtual_network_pbb_evpn_enable() const
const ServiceChainList & service_chain_list() const
uint64_t last_change_at() const
const NeighborList & neighbor_list() const
const StaticRouteList & static_routes(Address::Family family) const
AddressFamilyList GetAddressFamilies() const
const std::string & instance_name() const
uint64_t last_change_at() const
const OriginOverrideConfig & origin_override() const
uint32_t cluster_id() const
uint16_t source_port() const
const AuthenticationData & auth_data() const
std::string router_type() const
const std::string & name() const
const IpAddress & gateway_address(Address::Family family) const
std::string private_as_action() const
uint8_t loop_count() const
const IpAddress & peer_address() const
std::string peer_identifier_string() const
const FamilyAttributesList & family_attributes_list() const
uint32_t local_as() const
std::string local_identifier_string() const
const std::string & name() const
const RoutingPolicyTermList & terms() const
BgpConfigManager * config_manager()
BgpGlobalSystemConfig * global_config()
The TaskScheduler keeps track of what tasks are currently schedulable. When a task is enqueued it is ...
int GetTaskId(const std::string &name)
static TaskScheduler * GetInstance()
static bool regex_search(const std::string &input, const regex ®ex)
static bool regex_match(const std::string &input, const regex ®ex)
static const std::string integerToString(const NumberType &num)
uint32_t iter_limit() const
uint32_t page_limit() const
void PeeringShowReqHandler(const ShowBgpPeeringConfigReq *req)
void PeeringShowReqIterateHandler(const ShowBgpPeeringConfigReqIterate *req_iterate)
std::string search_string
std::vector< ShowT > show_list
std::vector< int > instances_
static Address::Family SCFamilyToAddressFamily(Family family)
static std::string UTCUsecToString(uint64_t tstamp)