12 #include <ovsdb_types.h> 
   14 using namespace OVSDB;
 
   16 static void SandeshError(
const std::string msg, 
const std::string &context) {
 
   17     ErrorResp *resp = 
new ErrorResp();
 
   19     resp->set_context(context);
 
   23 static void SetErrorMsg(
bool &error, std::string &error_msg, std::string msg) {
 
   35     ip_(), port_(0), resp_(NULL), resp_data_(resp_ctx), first_(0),
 
   36     last_(kEntriesPerPage - 1), total_count_(0), needs_next_(false),
 
   37     error_(false), error_msg_(
"") {
 
   38     if (!args.
Get(
"session_ip", &
ip_)) {
 
   43     if (args.
Get(
"session_port", &val)) {
 
   44         port_ = (uint32_t) val;
 
   49     if (args.
Get(
"first", &val)) {
 
   55     if (args.
Get(
"last", &val)) {
 
   56         last_ = (uint32_t) val;
 
   65     ip_(ip), port_(port), resp_(NULL), resp_data_(resp_ctx), first_(0),
 
   66     last_(kEntriesPerPage - 1), total_count_(0), needs_next_(false),
 
   67     error_(false), error_msg_(
"") {
 
   83         boost::system::error_code ec;
 
   87     uint32_t table_size = 0;
 
   88     uint32_t display_count = 0;
 
   90         (session != NULL && session->
client_idl() != NULL)) {
 
  106         table_size = table->
Size();
 
  107         uint8_t cur_count = 0;
 
  108         while (entry != NULL) {
 
  121             entry = table->
Next(entry);
 
  148     args.
Add(
"session_ip", 
ip_);
 
  151     args.
Add(
"first", 0);
 
  159                                          uint32_t table_size) {
 
  160     OvsdbPageResp *resp = 
new OvsdbPageResp();
 
  162     OvsdbPageRespData resp_data;
 
  165     args.
Add(
"session_ip", 
ip_);
 
  170     args.
Add(
"first", 0);
 
  175     resp_data.set_first_page(s);
 
  189         resp_data.set_prev_page(s);
 
  200         resp_data.set_next_page(s);
 
  205     args.
Add(
"first", -1);
 
  206     args.
Add(
"last", -1);
 
  210     resp_data.set_all(s);
 
  213     std::stringstream match_str;
 
  214     if (display_count != 0) {
 
  215         uint32_t last = first + display_count - 1;
 
  216         match_str << first << 
" - " << (last);
 
  221     resp_data.set_entries(match_str.str());
 
  222     resp_data.set_table_size(table_size);
 
  224     resp->set_req(resp_data);
 
  240 void OvsdbPageReq::HandleRequest()
 const {
 
  246     args.
Get(
"ovsdb_table", &table_type);
 
  247     switch (table_type) {
 
boost::asio::ip::address_v4 Ip4Address
bool Add(const std::string &key, const std::string &val)
bool Del(const std::string &key)
bool Get(const std::string &key, std::string *val) const
int Decode(const std::string &str)
int Encode(std::string *str)
OVSDB::OvsdbClient * ovsdb_client() const
static Agent * GetInstance()
KSyncEntry * Next(const KSyncEntry *entry) const
virtual Ip4Address remote_ip() const =0
virtual uint16_t remote_port() const =0
OvsdbClientIdl * client_idl()
virtual OvsdbClientSession * NextSession(OvsdbClientSession *session)=0
virtual OvsdbClientSession * FindSession(Ip4Address ip, uint16_t port)=0
void EncodeSendPageReq(uint32_t display_count, uint32_t table_size)
static const uint8_t kEntriesPerSandesh
virtual TableType GetTableType()=0
virtual void UpdateResp(KSyncEntry *entry, SandeshResponse *resp)=0
virtual bool NoSessionObject()
virtual ~OvsdbSandeshTask()
virtual FilterResp Filter(KSyncEntry *entry)
void SendResponse(bool more)
OvsdbSandeshTask(std::string resp_ctx, AgentSandeshArguments &args)
virtual SandeshResponse * Alloc()=0
static const uint8_t kEntriesPerPage
std::string EncodeFirstPage()
virtual void EncodeArgs(AgentSandeshArguments &args)
@ HA_STALE_L2_ROUTE_TABLE
virtual KSyncObject * GetObject(OvsdbClientSession *session)=0
bool Run()
Code to execute. Returns true if task is completed. Return false to reschedule the task.
virtual void set_more(const bool val)=0
void set_context(std::string context)
The TaskScheduler keeps track of what tasks are currently schedulable. When a task is enqueued it is ...
void Enqueue(Task *task)
Enqueues a task for running. Starts task if all policy rules are met else puts task in waitq....
static TaskScheduler * GetInstance()
Task is a wrapper over tbb::task to support policies.
static void SetErrorMsg(bool &error, std::string &error_msg, std::string msg)
static void SandeshError(const std::string msg, const std::string &context)