Line data Source code
1 : /* 2 : * Copyright (c) 2014 Juniper Networks, Inc. All rights reserved. 3 : */ 4 : 5 : #ifndef vnsw_agent_pkt_control_interface_hpp 6 : #define vnsw_agent_pkt_control_interface_hpp 7 : 8 : #include <string> 9 : #include <boost/bind/bind.hpp> 10 : #include <boost/function.hpp> 11 : #include <boost/asio.hpp> 12 : 13 : #include <pkt/pkt_handler.h> 14 : 15 : using namespace boost::placeholders; 16 : 17 : class PktHandler; 18 : 19 : // ControlInterface is base class for control packet I/O between agent and 20 : // dataplane. Control packets can be for ARP resolution, Diagnostics, Flow 21 : // setup traps etc... 22 : class ControlInterface { 23 : public: 24 : static const uint32_t kMaxPacketSize = 9060; 25 : 26 1 : ControlInterface() { } 27 1 : virtual ~ControlInterface() { } 28 : 29 1 : void Init(PktHandler *pkt_handler) { 30 1 : pkt_handler_ = pkt_handler; 31 1 : InitControlInterface(); 32 1 : } 33 : 34 1 : void Shutdown() { ShutdownControlInterface(); } 35 1 : void IoShutdown() { IoShutdownControlInterface(); } 36 : 37 : // Initialize the implementation of COntrolInterface 38 : virtual void InitControlInterface() = 0; 39 : 40 : // Shutdown control packet interface 41 : virtual void ShutdownControlInterface() = 0; 42 : 43 : // Stop I/O operations 44 : virtual void IoShutdownControlInterface() = 0; 45 : 46 : // Name of the control interface 47 : virtual const std::string &Name() const = 0; 48 : 49 : // Length of header added by implementation of ControlInterface. Buffer 50 : // passed in Send should reserve atleast EncapsulationLength() bytes 51 : // TBD : To go from here 52 : virtual uint32_t EncapsulationLength() const = 0; 53 : 54 : // Transmit packet on ControlInterface 55 : virtual int Send(const AgentHdr &hdr, const PacketBufferPtr &pkt) = 0; 56 : 57 : // Handle control packet. AgentHdr is already decoded 58 18021 : bool Process(const AgentHdr &hdr, const PacketBufferPtr &pkt) { 59 18021 : pkt_handler_->HandleRcvPkt(hdr, pkt); 60 18021 : return true; 61 : } 62 : 63 3 : PktHandler *pkt_handler() const { return pkt_handler_; } 64 : private: 65 : PktHandler *pkt_handler_; 66 : 67 : DISALLOW_COPY_AND_ASSIGN(ControlInterface); 68 : }; 69 : 70 : #endif // vnsw_agent_pkt_control_interface_hpp