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 : #ifndef vnsw_agent_kstate_h 7 : #define vnsw_agent_kstate_h 8 : 9 : #include <boost/any.hpp> 10 : 11 : #include <cmn/agent_cmn.h> 12 : #include <vr_types.h> 13 : #include <vr_flow.h> 14 : #include <kstate/kstate_types.h> 15 : 16 : #include <ksync/ksync_index.h> 17 : #include <ksync/ksync_entry.h> 18 : #include <ksync/ksync_object.h> 19 : #include <ksync/ksync_netlink.h> 20 : #include <ksync/ksync_sock.h> 21 : #include <ksync/ksync_netlink.h> 22 : #include <ksync/ksync_types.h> 23 : #include <vrouter/ksync/agent_ksync_types.h> 24 : 25 : class KState : public AgentSandeshContext { 26 : public: 27 : static const int kMaxEntriesPerResponse = 100; 28 0 : KState(const std::string &s, Sandesh *obj) : response_context_(s), 29 0 : response_object_(obj), vr_response_code_(0), 30 0 : more_context_(boost::any()) {} 31 : 32 : void EncodeAndSend(Sandesh &encoder); 33 : virtual void SendResponse() = 0; 34 : virtual void SendNextRequest() = 0; 35 : virtual void Handler() = 0; 36 0 : virtual void Release() { 37 0 : if (response_object_) { 38 0 : response_object_->Release(); 39 0 : response_object_ = NULL; 40 : } 41 0 : } 42 0 : const std::string response_context() const { return response_context_; } 43 0 : Sandesh *response_object() const { return response_object_; } 44 0 : const boost::any &more_context() const { return more_context_; } 45 0 : void set_vr_response_code(int value) { vr_response_code_ = value; } 46 : bool MoreData() const; 47 : const std::string MacToString(const std::vector<signed char> &mac) const; 48 : virtual void IfMsgHandler(vr_interface_req *req); 49 : virtual void NHMsgHandler(vr_nexthop_req *req); 50 : virtual void RouteMsgHandler(vr_route_req *req); 51 : virtual void MplsMsgHandler(vr_mpls_req *req); 52 : virtual void MirrorMsgHandler(vr_mirror_req *req); 53 : virtual int VrResponseMsgHandler(vr_response *r); 54 0 : virtual void FlowMsgHandler(vr_flow_req *req) {} 55 : virtual void VrfAssignMsgHandler(vr_vrf_assign_req *req); 56 : virtual void VrfMsgHandler(vr_vrf_req *req); 57 : virtual void VrfStatsMsgHandler(vr_vrf_stats_req *req); 58 : virtual void DropStatsMsgHandler(vr_drop_stats_req *req); 59 : virtual void VxLanMsgHandler(vr_vxlan_req *req); 60 0 : virtual void VrouterOpsMsgHandler(vrouter_ops *req) { } 61 : virtual void ForwardingClassMsgHandler(vr_fc_map_req *req); 62 : virtual void QosConfigMsgHandler(vr_qos_map_req *req); 63 : protected: 64 : std::string response_context_; 65 : Sandesh *response_object_; 66 : int vr_response_code_; /* response code from kernel */ 67 : boost::any more_context_; /* context to hold marker info */ 68 : private: 69 : void UpdateContext(const boost::any &); 70 : const std::string PrefixToString(const std::vector<int8_t> &prefix); 71 : }; 72 : 73 : #endif // vnsw_agent_kstate_h