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  */
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...
23 public:
24  static const uint32_t kMaxPacketSize = 9060;
25 
27  virtual ~ControlInterface() { }
28 
29  void Init(PktHandler *pkt_handler) {
30  pkt_handler_ = pkt_handler;
31  InitControlInterface();
32  }
33 
34  void Shutdown() { ShutdownControlInterface(); }
35  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  bool Process(const AgentHdr &hdr, const PacketBufferPtr &pkt) {
59  pkt_handler_->HandleRcvPkt(hdr, pkt);
60  return true;
61  }
62 
63  PktHandler *pkt_handler() const { return pkt_handler_; }
64 private:
66 
68 };
69 
70 #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:18