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