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