LCOV - code coverage report
Current view: top level - bfd - bfd_udp_connection.h (source / functions) Hit Total Coverage
Test: OpenSDN C/C++ coverage (all TARGET_SET jobs) Lines: 1 1 100.0 %
Date: 2026-06-04 02:06:09 Functions: 1 1 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :  * Copyright (c) 2014 CodiLime, Inc. All rights reserved.
       3             :  */
       4             : 
       5             : #ifndef SRC_BFD_UDP_CONNECTION_H_
       6             : #define SRC_BFD_UDP_CONNECTION_H_
       7             : 
       8             : #include "bfd/bfd_connection.h"
       9             : 
      10             : #include <boost/optional.hpp>
      11             : 
      12             : #include "io/udp_server.h"
      13             : 
      14             : namespace BFD {
      15             : class UDPConnectionManager : public Connection {
      16             :  public:
      17             :     typedef boost::function<void(boost::asio::ip::udp::endpoint remote_endpoint,
      18             :                                  const boost::asio::const_buffer &recv_buffer,
      19             :                                  std::size_t bytes_transferred,
      20             :                                  const boost::system::error_code& error)>
      21             :                 RecvCallback;
      22             : 
      23             :     UDPConnectionManager(EventManager *evm, int recvPort = kSingleHop,
      24             :                          int remotePort = kSingleHop);
      25             :     ~UDPConnectionManager();
      26             :     void RegisterCallback(RecvCallback callback);
      27             : 
      28             :     virtual void SendPacket(
      29             :         const boost::asio::ip::udp::endpoint &local_endpoint,
      30             :         const boost::asio::ip::udp::endpoint &remote_endpoint,
      31             :         const SessionIndex &session_index,
      32             :         const boost::asio::mutable_buffer &send, int pktSize);
      33             :     void SendPacket(boost::asio::ip::address remoteHost,
      34             :                     const ControlPacket *packet);
      35             :     virtual Server *GetServer() const;
      36             :     virtual void SetServer(Server *server);
      37             :     virtual void NotifyStateChange(const SessionKey &key, const bool &up);
      38             : 
      39             :  private:
      40             : 
      41             :     class UDPRecvServer : public UdpServer {
      42             :      public:
      43             :         UDPRecvServer(UDPConnectionManager *parent,
      44             :                       EventManager *evm, int recvPort);
      45             :         void RegisterCallback(RecvCallback callback);
      46             :         void HandleReceive(const boost::asio::const_buffer &recv_buffer,
      47             :                 boost::asio::ip::udp::endpoint remote_endpoint,
      48             :                 std::size_t bytes_transferred,
      49             :                 const boost::system::error_code &error);
      50             : 
      51             :      private:
      52             :         UDPConnectionManager *parent_;
      53             :         boost::optional<RecvCallback> callback_;
      54             :     } *udpRecv_;
      55             : 
      56             :     class UDPCommunicator : public UdpServer {
      57             :      public:
      58             :         UDPCommunicator(EventManager *evm, int remotePort);
      59             :         // TODO(bfd) add multiple instances to randomize source port (RFC5881)
      60           1 :         int remotePort() const { return remotePort_; }
      61             :      private:
      62             :         const int remotePort_;
      63             :     } *udpSend_;
      64             : 
      65             :     Server *server_;
      66             : };
      67             : }  // namespace BFD
      68             : 
      69             : #endif  // SRC_BFD_UDP_CONNECTION_H_

Generated by: LCOV version 1.14