7 #include <boost/assign/list_of.hpp>
8 #include <boost/foreach.hpp>
9 #include <sandesh/request_pipeline.h>
14 #include "bgp/bgp_peer_internal_types.h"
23 using boost::assign::list_of;
33 const ShowNeighborStatisticsReq *req,
BgpServer *bgp_server);
37 const ShowNeighborStatisticsReq *req,
BgpServer *bgp_server) {
40 if (req->get_bgp_or_xmpp().empty() ||
41 boost::iequals(req->get_bgp_or_xmpp(),
"bgp")) {
43 if (!req->get_domain().empty()) {
51 for (; it != rim->
end(); it++) {
66 const ShowNeighborStatisticsReq *req;
69 req =
static_cast<const ShowNeighborStatisticsReq *
>(ps.
snhRequest_.get());
76 if (req->get_bgp_or_xmpp().empty() ||
77 boost::iequals(req->get_bgp_or_xmpp(),
"xmpp")) {
81 ShowNeighborStatisticsResp *resp =
new ShowNeighborStatisticsResp;
82 resp->set_bgp_or_xmpp(req->get_bgp_or_xmpp());
83 resp->set_up_or_down(req->get_up_or_down());
84 resp->set_domain(req->get_domain());
85 resp->set_count(count);
86 resp->set_context(req->context());
92 void ShowNeighborStatisticsReq::HandleRequest()
const {
102 ps.stages_= list_of(s1)
103 .convert_to_container<vector<RequestPipeline::StageSpec> >();
117 const ClearBgpNeighborReq *req;
120 req =
static_cast<const ClearBgpNeighborReq *
>(ps.
snhRequest_.get());
124 ClearBgpNeighborResp *resp =
new ClearBgpNeighborResp;
126 resp->set_success(
false);
129 resp->set_success(
true);
131 resp->set_success(
false);
133 resp->set_context(req->context());
140 void ClearBgpNeighborReq::HandleRequest()
const {
149 ps.stages_= list_of(s1)
150 .convert_to_container<vector<RequestPipeline::StageSpec> >();
165 ShowMulticastTreeLink *smtl) {
166 smtl->set_address(forwarder->
address().to_string());
167 smtl->set_label(forwarder->
label());
171 ShowMulticastForwarder *smf) {
172 smf->set_address(forwarder->
address().to_string());
173 smf->set_label(forwarder->
label());
175 smf->set_router_id(forwarder->
router_id().to_string());
176 for (McastForwarderList::const_iterator it =
179 ShowMulticastTreeLink smtl;
181 smf->links.push_back(smtl);
186 ShowMulticastTree *smt) {
187 smt->set_group(sg->
group().to_string());
188 smt->set_source(sg->
source().to_string());
193 for (McastSGEntry::ForwarderSet::const_iterator it =
196 ShowMulticastForwarder smf;
199 smt->level0_forwarders.push_back(smf);
201 smt->level1_forwarders.push_back(smf);
211 for (McastManagerPartition::SGList::const_iterator it =
213 it != partition->
sg_list_.end(); it++) {
214 ShowMulticastTree smt;
222 int stage,
int instNum,
224 int inst_id = ps.
stages_[stage].instances_[instNum];
228 const ShowMulticastManagerDetailReq *req =
229 static_cast<const ShowMulticastManagerDetailReq *
>(
236 if (mcast_table && !mcast_table->
IsVpnTable())
244 vector<ShowMulticastTree> *tree_list) {
245 for (
size_t idx = 0; idx < sd->size(); idx++) {
248 tree_list->insert(tree_list->end(),
255 int stage,
int instNum,
257 const ShowMulticastManagerReq *req =
258 static_cast<const ShowMulticastManagerReq *
>(ps.
snhRequest_.get());
260 vector<ShowMulticastTree> tree_list;
263 ShowMulticastManagerDetailResp *resp =
264 new ShowMulticastManagerDetailResp;
265 resp->set_trees(tree_list);
266 resp->set_context(req->context());
273 void ShowMulticastManagerDetailReq::HandleRequest()
const {
293 ps.stages_ = list_of(s1)(s2)
294 .convert_to_container<vector<RequestPipeline::StageSpec> >();
309 ShowMvpnNeighbor *snbr) {
311 snbr->set_originator(nbr->
originator().to_string());
321 BOOST_FOREACH(
const MvpnManager::NeighborMap::value_type &val,
323 ShowMvpnNeighbor snbr;
331 int stage,
int instNum,
333 int inst_id = ps.
stages_[stage].instances_[instNum];
337 const ShowMvpnManagerDetailReq *req =
338 static_cast<const ShowMvpnManagerDetailReq *
>(
348 ShowMvpnManagerDetailResp *resp =
new ShowMvpnManagerDetailResp;
350 resp->set_context(req->context());
357 void ShowMvpnManagerDetailReq::HandleRequest()
const {
366 ps.stages_ = list_of(s1)
367 .convert_to_container<vector<RequestPipeline::StageSpec> >();
384 st->set_source(state->
sg().
source.to_string());
385 st->set_group(state->
sg().
group.to_string());
387 st->set_global_ermvpn_tree_rt(
395 vector<string> spmsi_routes_received;
397 spmsi_routes_received.push_back(rt->
ToString());
399 st->set_spmsi_routes_received(spmsi_routes_received);
401 vector<string> leafad_routes_attr_received;
402 BOOST_FOREACH(
const MvpnState::RoutesMap::value_type &val,
406 leafad_routes_attr_received.push_back(
410 st->set_leafad_routes_attr_received(leafad_routes_attr_received);
411 st->set_total_states(state->
states()->size());
413 st->set_refcount(state->
refcount());
421 BOOST_FOREACH(MvpnState::StatesMap::value_type &val,
425 data->
states.push_back(st);
431 int stage,
int instNum,
433 int inst_id = ps.
stages_[stage].instances_[instNum];
437 const ShowMvpnProjectManagerDetailReq *req =
438 static_cast<const ShowMvpnProjectManagerDetailReq *
>(
445 if (ermvpn_table && !ermvpn_table->
IsVpnTable())
453 vector<ShowMvpnState> *states) {
454 for (
size_t idx = 0; idx < sd->size(); idx++) {
457 states->insert(states->end(),
464 int stage,
int instNum,
466 const ShowMvpnProjectManagerReq *req =
467 static_cast<const ShowMvpnProjectManagerReq *
>(
470 vector<ShowMvpnState> states;
473 ShowMvpnProjectManagerDetailResp *resp =
474 new ShowMvpnProjectManagerDetailResp;
475 resp->set_states(states);
476 resp->set_context(req->context());
483 void ShowMvpnProjectManagerDetailReq::HandleRequest()
const {
503 ps.stages_ = list_of(s1)(s2)
504 .convert_to_container<vector<RequestPipeline::StageSpec> >();
520 int stage,
int instNum,
523 const ShowRouteVrfReq *req =
524 static_cast<const ShowRouteVrfReq *
>(ps.
snhRequest_.get());
529 if (!ri)
return true;
531 if (!table)
return true;
537 if (!route)
return true;
538 ShowRoute show_route;
539 show_route.set_prefix(route->
ToString());
542 vector<ShowRoutePath> show_route_paths;
543 for (Route::PathList::const_iterator it = route->
GetPathList().begin();
545 const BgpPath *path =
static_cast<const BgpPath *
>(it.operator->());
547 srp.set_protocol(
"BGP");
555 srp.set_next_hop(attr->
nexthop().to_string());
557 show_route_paths.push_back(srp);
559 show_route.set_paths(show_route_paths);
560 sdata->
routes.push_back(show_route);
566 int stage,
int instNum,
570 for (
size_t i = 0; i < sd->size(); i++) {
574 route = data.
routes.front();
579 ShowRouteVrfResp *resp =
new ShowRouteVrfResp;
580 resp->set_route(route);
581 const ShowRouteVrfReq *req =
582 static_cast<const ShowRouteVrfReq *
>(ps.
snhRequest_.get());
583 resp->set_context(req->context());
589 void ShowRouteVrfReq::HandleRequest()
const {
610 ps.stages_ = list_of(s1)(s2)
611 .convert_to_container<vector<RequestPipeline::StageSpec> >();
620 const ShowBgpServerReq *req =
621 static_cast<const ShowBgpServerReq *
>(ps.
snhRequest_.get());
625 ShowBgpServerResp *resp =
new ShowBgpServerResp;
626 SocketIOStats peer_socket_stats;
628 resp->set_rx_socket_stats(peer_socket_stats);
631 resp->set_tx_socket_stats(peer_socket_stats);
633 resp->set_context(req->context());
639 void ShowBgpServerReq::HandleRequest()
const {
649 ps.stages_ = list_of(s1)
650 .convert_to_container<vector<RequestPipeline::StageSpec> >();
656 xmpp_peer_manager(NULL),
670 bool summary, uint32_t page_limit, uint32_t iter_limit,
671 const string &start_neighbor,
const string &search_string,
672 vector<BgpNeighborResp> *list,
string *next_neighbor)
const {
676 start_neighbor, search_string, list, next_neighbor);
681 size_t *count,
const ShowNeighborStatisticsReq *req)
const {
695 const ShowBgpPeeringConfigReq *req) {
699 ShowBgpPeeringConfigResp *resp =
new ShowBgpPeeringConfigResp;
705 const ShowBgpPeeringConfigReqIterate *req_iterate) {
709 ShowBgpPeeringConfigResp *resp =
new ShowBgpPeeringConfigResp;
static RequestPipeline::InstData * CreateData(int stage)
ErmVpnRoute * global_ermvpn_tree_rt()
std::vector< int > instances_
const NeighborMap & neighbors() const
static RequestPipeline::InstData * CreateData(int stage)
static void FillMvpnNeighborsInfo(MvpnManagerDetailData *data, MvpnTable *table, int inst_id)
virtual std::string ToString() const
const MvpnState::StatesMap & states() const
const RouteDistinguisher & rd() const
NeighborListExtension show_neighbor_ext_
uint32_t local_pref() const
const IpAddress & nexthop() const
BgpTable * GetTable(Address::Family fmly)
The TaskScheduler keeps track of what tasks are currently schedulable. When a task is enqueued it is ...
PeerManager * peer_manager()
RoutingInstance * GetRoutingInstance(const std::string &name)
PeeringReqIterateHandler show_peering_req_iterate_handler_
const AsPathSpec & path() const
bool IsTreeBuilder(uint8_t level) const
boost::function< bool(const BgpSandeshContext *, bool, uint32_t, uint32_t, const std::string &, const std::string &, std::vector< BgpNeighborResp > *, std::string *)> NeighborListExtension
boost::ptr_vector< InstData > StageData
static void FillMvpnNeighborInfo(const MvpnNeighbor *nbr, ShowMvpnNeighbor *snbr)
static void FillMvpnProjectStateInfo(const MvpnState *state, ShowMvpnState *st)
static bool CallbackS1(const Sandesh *sr, const RequestPipeline::PipeSpec ps, int stage, int instNum, RequestPipeline::InstData *data)
static void FillMulticastLinkInfo(const McastForwarder *forwarder, ShowMulticastTreeLink *smtl)
std::string ToString() const
MvpnRoute * source_active_rt()
static void CombineMulticastPartitionInfo(const RequestPipeline::StageData *sd, vector< ShowMulticastTree > *tree_list)
RoutesSet & spmsi_routes_received()
MvpnProjectManager * mvpn_project_manager()
static void FillMulticastTreeInfo(const McastSGEntry *sg, ShowMulticastTree *smt)
void GetTxSocketStats(SocketIOStats *socket_stats) const
static bool CallbackS1(const Sandesh *sr, const RequestPipeline::PipeSpec ps, int stage, int instNum, RequestPipeline::InstData *data)
boost::function< void(const BgpSandeshContext *, const ShowBgpPeeringConfigReq *)> PeeringReqHandler
RoutingInstanceMgr * routing_instance_mgr()
void SetPeeringShowHandlers(const PeeringReqHandler &show_peering_req_handler, const PeeringReqIterateHandler &show_peering_req_iterate_handler)
RoutingInstanceIterator end()
virtual std::string ToString() const
BgpPeer * FindPeer(const std::string &name)
NeighborStatisticsExtension show_neighbor_statistics_ext_
void GetRxSocketStats(SocketIOStats *socket_stats) const
uint32_t source_as() const
void set_as_path(AsPathPtr aspath)
void ShowNeighborStatisticsExtension(size_t *count, const ShowNeighborStatisticsReq *req) const
int GetTaskId(const std::string &name)
const MvpnManager * manager() const
tbb::reader_writer_lock & neighbors_mutex()
const uint64_t last_change_at() const
Ip4Address router_id() const
static bool CallbackS2(const Sandesh *sr, const RequestPipeline::PipeSpec ps, int stage, int instNum, RequestPipeline::InstData *data)
McastTreeManager * GetTreeManager()
bool ShowNeighborExtension(const BgpSandeshContext *bsc, bool summary, uint32_t page_limit, uint32_t iter_limit, const std::string &start_neighbor, const std::string &search_string, std::vector< BgpNeighborResp > *list, std::string *next_neighbor) const
vector< ShowMvpnState > states
static TaskScheduler * GetInstance()
virtual std::string ToString() const
vector< ShowMvpnNeighbor > neighbors
static Ip4Prefix FromString(const std::string &str, boost::system::error_code *errorp=NULL)
static bool CallbackS1(const Sandesh *sr, const RequestPipeline::PipeSpec ps, int stage, int instNum, RequestPipeline::InstData *data)
virtual const std::string & ToString() const =0
boost::function< void(size_t *, const BgpSandeshContext *, const ShowNeighborStatisticsReq *)> NeighborStatisticsExtension
static const std::string duration_usecs_to_string(const uint64_t usecs)
const LabelBlock * label_block() const
BgpSessionManager * session_manager()
std::vector< StageSpec > stages_
Ip4Address address() const
MvpnProjectManagerPartition * GetPartition(int part_id)
const std::string & name() const
RoutesMap & leafad_routes_attr_received()
uint32_t GetLabel() const
virtual std::string ToString() const
virtual bool IsVpnTable() const
const AsPath * as_path() const
static bool CallbackS2(const Sandesh *sr, const RequestPipeline::PipeSpec ps, int stage, int instNum, RequestPipeline::InstData *data)
boost::function< void(const BgpSandeshContext *, const ShowBgpPeeringConfigReqIterate *)> PeeringReqIterateHandler
static const int kPartitionCount
virtual bool IsVpnTable() const
std::vector< ForwarderSet * > forwarder_sets_
static RequestPipeline::InstData * CreateData(int stage)
static bool CallbackS1(const Sandesh *sr, const RequestPipeline::PipeSpec ps, int stage, int instNum, RequestPipeline::InstData *data)
static uint64_t UTCTimestampUsec()
static void FillMvpnProjectPartitionInfo(MvpnProjectManagerDetailData *data, ErmVpnTable *table, int inst_id)
static bool CallbackS2(const Sandesh *sr, const RequestPipeline::PipeSpec ps, int stage, int instNum, RequestPipeline::InstData *data)
const BgpAttr * GetAttr() const
static bool CallbackS1(const Sandesh *sr, const RequestPipeline::PipeSpec ps, int stage, int instNum, RequestPipeline::InstData *data)
McastForwarderList tree_links_
std::string ToString() const
DBEntry * Find(const DBEntry *entry)
static void FillMulticastPartitionInfo(MulticastManagerDetailData *data, ErmVpnTable *table, int inst_id)
const PmsiTunnelSpec & pmsi_tunnel() const
boost::shared_ptr< const SandeshRequest > snhRequest_
const StatesMap * states() const
vector< ShowMulticastTree > tree_list
const uint64_t time_stamp_usecs() const
RoutingInstanceIterator begin()
void SetNeighborShowExtensions(const NeighborListExtension &show_neighbor, const NeighborStatisticsExtension &show_neighbor_statistics)
static int PartitionCount()
void PeeringShowReqHandler(const ShowBgpPeeringConfigReq *req)
static size_t FillBgpNeighborStatistics(const ShowNeighborStatisticsReq *req, BgpServer *bgp_server)
const IpAddress & originator() const
PeeringReqHandler show_peering_req_handler_
static bool CallbackS1(const Sandesh *sr, const RequestPipeline::PipeSpec ps, int stage, int instNum, RequestPipeline::InstData *data)
vector< ShowRoute > routes
const StageData * GetStageData(int stage) const
void PeeringShowReqIterateHandler(const ShowBgpPeeringConfigReqIterate *req_iterate)
MvpnProjectManager * project_manager()
static void CombineMvpnProjectPartitionInfo(const RequestPipeline::StageData *sd, vector< ShowMvpnState > *states)
Ip4Address source() const
static RequestPipeline::InstData * CreateData(int stage)
RoutingInstanceList::iterator RoutingInstanceIterator
static void FillMulticastForwarderInfo(const McastForwarder *forwarder, ShowMulticastForwarder *smf)
virtual std::string ToString() const
static bool CallbackS1(const Sandesh *sr, const RequestPipeline::PipeSpec ps, int stage, int instNum, RequestPipeline::InstData *data)
McastManagerPartition * GetPartition(int part_id)
DBTableBase * FindTable(const std::string &name)
const PathList & GetPathList() const
size_t GetNeighborCount(std::string up_or_down)