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