Line data Source code
1 : /* 2 : * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved. 3 : */ 4 : 5 : #include "kstate.h" 6 : #include "qos_config_kstate.h" 7 : 8 0 : QosConfigKState::QosConfigKState(KQosConfigResp *obj, const std::string &resp_ctx, 9 0 : vr_qos_map_req &req, int id) : KState(resp_ctx, obj) { 10 0 : req.set_qmr_id(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_qmr_marker(-1); 16 : } 17 0 : } 18 : 19 0 : void QosConfigKState::SendNextRequest() { 20 0 : vr_qos_map_req req; 21 0 : req.set_h_op(sandesh_op::DUMP); 22 0 : req.set_qmr_id(0); 23 0 : uint16_t id = boost::any_cast<uint16_t>(more_context_); 24 0 : req.set_qmr_marker(id); 25 0 : EncodeAndSend(req); 26 0 : } 27 : 28 0 : void QosConfigKState::Handler() { 29 0 : KQosConfigResp *resp = static_cast<KQosConfigResp *>(response_object_); 30 0 : if (resp) { 31 0 : if (MoreData()) { 32 0 : SendResponse(); 33 0 : SendNextRequest(); 34 : } else { 35 0 : resp->set_context(response_context_); 36 0 : resp->Response(); 37 0 : more_context_ = boost::any(); 38 : } 39 : } 40 0 : } 41 : 42 0 : void QosConfigKState::SendResponse() { 43 0 : KQosConfigResp *resp = static_cast<KQosConfigResp *>(response_object_); 44 0 : resp->set_context(response_context_); 45 0 : resp->set_more(true); 46 0 : resp->Response(); 47 0 : response_object_ = new KQosConfigResp(); 48 0 : }