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