LCOV - code coverage report
Current view: top level - vnsw/agent/pkt - control_interface.h (source / functions) Hit Total Coverage
Test: OpenSDN C/C++ coverage (all TARGET_SET jobs) Lines: 12 12 100.0 %
Date: 2026-11-09 02:10:49 Functions: 7 8 87.5 %
Legend: Lines: hit not hit

          Line data    Source code
       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...
      23             : class ControlInterface {
      24             : public:
      25             :     static const uint32_t kMaxPacketSize = 9060;
      26             : 
      27           2 :     ControlInterface() { }
      28           2 :     virtual ~ControlInterface() { }
      29             : 
      30           2 :     void Init(PktHandler *pkt_handler) {
      31           2 :         pkt_handler_ = pkt_handler;
      32           2 :         InitControlInterface();
      33           2 :     }
      34             : 
      35           2 :     void Shutdown() { ShutdownControlInterface(); }
      36           2 :     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       18096 :     bool Process(const AgentHdr &hdr, const PacketBufferPtr &pkt) {
      60       18096 :         pkt_handler_->HandleRcvPkt(hdr, pkt);
      61       18096 :         return true;
      62             :     }
      63             : 
      64           3 :     PktHandler *pkt_handler() const { return pkt_handler_; }
      65             : private:
      66             :     PktHandler *pkt_handler_;
      67             : 
      68             :     DISALLOW_COPY_AND_ASSIGN(ControlInterface);
      69             : };
      70             : 
      71             : #endif // vnsw_agent_pkt_control_interface_hpp

Generated by: LCOV version 1.14