OpenSDN source code
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
vxlan_kstate.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved.
3  */
4 
5 #include "kstate.h"
6 #include "vxlan_kstate.h"
7 
8 VxLanKState::VxLanKState(KVxLanResp *obj, const std::string &resp_ctx,
9  vr_vxlan_req &req, int id) : KState(resp_ctx, obj) {
10  req.set_vxlanr_vnid(id);
11  if (id >= 0) {
12  req.set_h_op(sandesh_op::GET);
13  } else {
14  req.set_h_op(sandesh_op::DUMP);
15  req.set_vxlanr_vnid(-1);
16  }
17 }
18 
20  vr_vxlan_req req;
21  req.set_h_op(sandesh_op::DUMP);
22  req.set_vxlanr_vnid(0);
23  int32_t label = boost::any_cast<int32_t>(more_context_);
24  req.set_vxlanr_vnid(label);
25  EncodeAndSend(req);
26 }
27 
29  KVxLanResp *resp = static_cast<KVxLanResp *>(response_object_);
30  if (resp) {
31  if (MoreData()) {
32  /* There are more labels in Kernel. We need to query them from
33  * Kernel and send it to Sandesh.
34  */
35  SendResponse();
37  } else {
38  resp->set_context(response_context_);
39  resp->Response();
40  more_context_ = boost::any();
41  }
42  }
43 }
44 
46 
47  KVxLanResp *resp = static_cast<KVxLanResp *>(response_object_);
48  resp->set_context(response_context_);
49  resp->set_more(true);
50  resp->Response();
51 
52  response_object_ = new KVxLanResp();
53 }
std::string response_context_
Definition: kstate.h:63
Definition: kstate.h:24
boost::any more_context_
Definition: kstate.h:66
virtual void Handler()
Definition: vxlan_kstate.cc:28
Sandesh * response_object_
Definition: kstate.h:64
virtual void SendResponse()
Definition: vxlan_kstate.cc:45
bool MoreData() const
Definition: kstate.cc:29
void EncodeAndSend(Sandesh &encoder)
Definition: kstate.cc:63
virtual void SendNextRequest()
Definition: vxlan_kstate.cc:19
VxLanKState(KVxLanResp *obj, const std::string &resp_ctx, vr_vxlan_req &req, int id)
Definition: vxlan_kstate.cc:8