OpenSDN source code
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
bgp_show_route.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017 Juniper Networks, Inc. All rights reserved.
3  */
4 
5 #ifndef SRC_BGP_BGP_SHOW_ROUTE_H__
6 #define SRC_BGP_BGP_SHOW_ROUTE_H__
7 
8 #include "base/regex.h"
9 #include "bgp/bgp_peer_types.h"
10 #include "sandesh/request_pipeline.h"
11 
12 class BgpRoute;
13 class BgpTable;
14 class ShowRouteReq;
15 class ShowRouteReqIterate;
16 
18 public:
19  static char kIterSeparator[];
20 
21  // kMaxCount can be a function of 'count' field in ShowRouteReq
22  static const uint32_t kUnitTestMaxCount = 100;
23  static const uint32_t kMaxCount = 1000;
24  static uint32_t GetMaxCount(bool test_mode);
25 
27  std::vector<ShowRouteTable> route_table_list;
28  };
29 
30  ShowRouteHandler(const ShowRouteReq *req, int inst_id);
31 
32  // Search for interesting prefixes in a given table for given partition
33  void BuildShowRouteTable(BgpTable *table,
34  std::vector<ShowRoute> *route_list, int count);
35 
36  bool MatchPrefix(const std::string &expected_prefix, BgpRoute *route,
37  bool longer_match, bool shorter_match);
38  bool match(const std::string &expected, const std::string &actual);
39  static RequestPipeline::InstData *CreateData(int stage);
40  static bool CallbackS1Common(const ShowRouteReq *req, int inst_id,
41  ShowRouteData *mydata);
42  static void CallbackS2Common(const ShowRouteReq *req,
44  ShowRouteResp *resp);
45 
46  static bool CallbackS1(const Sandesh *sr,
48  int stage, int instNum, RequestPipeline::InstData *data);
49  static bool CallbackS2(const Sandesh *sr,
50  const RequestPipeline::PipeSpec &ps,
51  int stage, int instNum, RequestPipeline::InstData *data);
52 
53  static bool CallbackS1Iterate(const Sandesh *sr,
54  const RequestPipeline::PipeSpec ps, int stage, int instNum,
56  static bool CallbackS2Iterate(const Sandesh *sr,
57  const RequestPipeline::PipeSpec ps, int stage, int instNum,
59 
60  static std::string SaveContextAndPopLast(const ShowRouteReq *req,
61  std::vector<ShowRouteTable> *route_table_list);
62  static bool ConvertReqIterateToReq(const ShowRouteReqIterate *req_iterate,
63  ShowRouteReq *req);
64  static uint32_t GetMaxRouteCount(const ShowRouteReq *req);
65 
66 private:
67  const ShowRouteReq *req_;
68  int inst_id_;
70 };
71 
72 #endif // SRC_BGP_BGP_SHOW_HANDLER_H__
static const uint32_t kUnitTestMaxCount
static RequestPipeline::InstData * CreateData(int stage)
contrail::regex prefix_expr_
static const uint32_t kMaxCount
ShowRouteHandler(const ShowRouteReq *req, int inst_id)
static void CallbackS2Common(const ShowRouteReq *req, const RequestPipeline::PipeSpec ps, ShowRouteResp *resp)
const ShowRouteReq * req_
static bool CallbackS1(const Sandesh *sr, const RequestPipeline::PipeSpec ps, int stage, int instNum, RequestPipeline::InstData *data)
static bool CallbackS1Iterate(const Sandesh *sr, const RequestPipeline::PipeSpec ps, int stage, int instNum, RequestPipeline::InstData *data)
bool match(const std::string &expected, const std::string &actual)
static std::string SaveContextAndPopLast(const ShowRouteReq *req, std::vector< ShowRouteTable > *route_table_list)
static uint32_t GetMaxCount(bool test_mode)
static bool CallbackS2Iterate(const Sandesh *sr, const RequestPipeline::PipeSpec ps, int stage, int instNum, RequestPipeline::InstData *data)
static bool CallbackS1Common(const ShowRouteReq *req, int inst_id, ShowRouteData *mydata)
static bool ConvertReqIterateToReq(const ShowRouteReqIterate *req_iterate, ShowRouteReq *req)
bool MatchPrefix(const std::string &expected_prefix, BgpRoute *route, bool longer_match, bool shorter_match)
static bool CallbackS2(const Sandesh *sr, const RequestPipeline::PipeSpec &ps, int stage, int instNum, RequestPipeline::InstData *data)
static uint32_t GetMaxRouteCount(const ShowRouteReq *req)
static char kIterSeparator[]
std::vector< ShowRouteTable > route_table_list
void BuildShowRouteTable(BgpTable *table, std::vector< ShowRoute > *route_list, int count)