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