Line data Source code
1 : /* 2 : * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved. 3 : */ 4 : 5 : #include "kstate.h" 6 : #include "forwarding_class_kstate.h" 7 : 8 0 : ForwardingClassKState::ForwardingClassKState( 9 : KForwardingClassResp *obj, const std::string &resp_ctx, 10 0 : vr_fc_map_req &req, int id) : KState(resp_ctx, obj) { 11 0 : std::vector<int16_t> l; 12 0 : l.push_back(id); 13 0 : req.set_fmr_id(l); 14 0 : if (id >= 0) { 15 0 : req.set_h_op(sandesh_op::GET); 16 : } else { 17 0 : req.set_h_op(sandesh_op::DUMP); 18 0 : l.clear(); l.push_back(-1); 19 0 : req.set_fmr_id(l); 20 0 : req.set_fmr_marker(-1); 21 : } 22 0 : } 23 : 24 0 : void ForwardingClassKState::SendNextRequest() { 25 0 : vr_fc_map_req req; 26 0 : req.set_h_op(sandesh_op::DUMP); 27 0 : int16_t id = boost::any_cast<int16_t>(more_context_); 28 0 : req.set_fmr_marker(id); 29 0 : EncodeAndSend(req); 30 0 : } 31 : 32 0 : void ForwardingClassKState::Handler() { 33 0 : KForwardingClassResp *resp = static_cast<KForwardingClassResp *>(response_object_); 34 0 : if (resp) { 35 0 : if (MoreData()) { 36 0 : SendResponse(); 37 0 : SendNextRequest(); 38 : } else { 39 0 : resp->set_context(response_context_); 40 0 : resp->Response(); 41 0 : more_context_ = boost::any(); 42 : } 43 : } 44 0 : } 45 : 46 0 : void ForwardingClassKState::SendResponse() { 47 0 : KForwardingClassResp *resp = static_cast<KForwardingClassResp *>(response_object_); 48 0 : resp->set_context(response_context_); 49 0 : resp->set_more(true); 50 0 : resp->Response(); 51 0 : response_object_ = new KForwardingClassResp(); 52 0 : }