Line data Source code
1 : /* 2 : * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved. 3 : */ 4 : 5 : #ifndef SRC_BGP_BGP_SANDESH_H_ 6 : #define SRC_BGP_BGP_SANDESH_H_ 7 : 8 : #include <boost/function.hpp> 9 : #include <sandesh/sandesh.h> 10 : 11 : #include <string> 12 : #include <vector> 13 : 14 : class BgpServer; 15 : class BgpXmppChannelManager; 16 : class BgpNeighborResp; 17 : class BgpNeighborReq; 18 : class ShowBgpNeighborSummaryReq; 19 : class ShowNeighborStatisticsReq; 20 : class ShowBgpPeeringConfigReq; 21 : class ShowBgpPeeringConfigReqIterate; 22 : 23 : struct BgpSandeshContext : public SandeshContext { 24 : typedef boost::function<bool(const BgpSandeshContext *, bool, 25 : uint32_t, uint32_t, const std::string &, const std::string &, 26 : std::vector<BgpNeighborResp> *, std::string *)> NeighborListExtension; 27 : 28 : typedef boost::function<void(size_t *, const BgpSandeshContext *, 29 : const ShowNeighborStatisticsReq *)> NeighborStatisticsExtension; 30 : 31 : typedef boost::function<void(const BgpSandeshContext *, 32 : const ShowBgpPeeringConfigReq *)> PeeringReqHandler; 33 : typedef boost::function<void(const BgpSandeshContext *, 34 : const ShowBgpPeeringConfigReqIterate *)> PeeringReqIterateHandler; 35 : 36 : BgpSandeshContext(); 37 : 38 : void SetNeighborShowExtensions( 39 : const NeighborListExtension &show_neighbor, 40 : const NeighborStatisticsExtension &show_neighbor_statistics); 41 : 42 : void SetPeeringShowHandlers( 43 : const PeeringReqHandler &show_peering_req_handler, 44 : const PeeringReqIterateHandler &show_peering_req_iterate_handler); 45 : 46 : BgpServer *bgp_server; 47 : BgpXmppChannelManager *xmpp_peer_manager; 48 : 49 : bool ShowNeighborExtension(const BgpSandeshContext *bsc, bool summary, 50 : uint32_t page_limit, uint32_t iter_limit, 51 : const std::string &start_neighbor, const std::string &search_string, 52 : std::vector<BgpNeighborResp> *list, std::string *next_neighbor) const; 53 : void ShowNeighborStatisticsExtension(size_t *count, 54 : const ShowNeighborStatisticsReq *req) const; 55 : 56 : void PeeringShowReqHandler(const ShowBgpPeeringConfigReq *req); 57 : void PeeringShowReqIterateHandler( 58 : const ShowBgpPeeringConfigReqIterate *req_iterate); 59 : 60 : // For testing. 61 1247 : bool test_mode() const { return test_mode_; } 62 29 : void set_test_mode(bool test_mode) { test_mode_ = test_mode; } 63 5070 : uint32_t page_limit() const { return page_limit_; } 64 882 : void set_page_limit(uint32_t page_limit) { page_limit_ = page_limit; } 65 6223 : uint32_t iter_limit() const { return iter_limit_; } 66 850 : void set_iter_limit(uint32_t iter_limit) { iter_limit_ = iter_limit; } 67 : 68 : private: 69 : bool test_mode_; 70 : uint32_t page_limit_; 71 : uint32_t iter_limit_; 72 : NeighborListExtension show_neighbor_ext_; 73 : NeighborStatisticsExtension show_neighbor_statistics_ext_; 74 : PeeringReqHandler show_peering_req_handler_; 75 : PeeringReqIterateHandler show_peering_req_iterate_handler_; 76 : }; 77 : 78 : #endif // SRC_BGP_BGP_SANDESH_H_