Program Listing for File BackendLibfabricConnectionless.hpp

Return to documentation for file (BackendLibfabric/BackendLibfabricConnectionless.hpp)

#ifndef NETIO3BACKEND_BACKENDLIBFABRIC_BACKENDLIBFABRICCONNECTIONLESS_HPP
#define NETIO3BACKEND_BACKENDLIBFABRIC_BACKENDLIBFABRICCONNECTIONLESS_HPP

#include "ConnectionlessEndpointManager.hpp"
#include "netio3-backend/EventLoop/BaseEventLoop.hpp"
#include "netio3-backend/Netio3Backend.hpp"
#include "netio3-backend/NetworkBuffer.hpp"

namespace netio3::libfabric {
  class BackendLibfabricConnectionless : public NetworkBackend
  {
  public:
    BackendLibfabricConnectionless(const NetworkConfig& config, std::shared_ptr<BaseEventLoop> evloop);

    void open_active_endpoint(const EndPointAddress& address,
                              const ConnectionParameters& connection_params) override;

    [[nodiscard]] EndPointAddress open_listen_endpoint(
      const EndPointAddress& address,
      const ConnectionParameters& connection_params) override;

    void close_active_endpoint(const EndPointAddress& address) override;

    void close_listen_endpoint(const EndPointAddress& address) override;

    [[nodiscard]] NetioStatus send_data(const EndPointAddress& address,
                                        std::span<std::uint8_t> data,
                                        std::span<const std::uint8_t> header_data,
                                        std::uint64_t key) override;

    [[nodiscard]] NetioStatus send_data(const EndPointAddress& address,
                                        std::span<const iovec> iov,
                                        std::span<const std::uint8_t> header_data,
                                        std::uint64_t key) override;

    [[nodiscard]] NetioStatus send_data_copy(const EndPointAddress& address,
                                             std::span<const std::uint8_t> data,
                                             std::span<const std::uint8_t> header_data,
                                             std::uint64_t key) override;

    [[nodiscard]] NetioStatus send_data_copy(const EndPointAddress& address,
                                             std::span<const iovec> iov,
                                             std::span<const std::uint8_t> header_data,
                                             std::uint64_t key) override;

    [[nodiscard]] NetworkBuffer* get_buffer(const EndPointAddress& address) override;

    [[nodiscard]] NetioStatus send_buffer(const EndPointAddress& address,
                                          NetworkBuffer* buffer) override;

    [[nodiscard]] std::size_t get_num_available_buffers(const EndPointAddress& address) override;

  private:
    static bool check_ip_address(const EndPointAddress& address);

    BaseEventLoop* m_event_loop{nullptr};
    std::shared_ptr<libfabric::ConnectionlessEndpointManager> m_endpoint_manager{nullptr};
  };
}  // namespace netio3::libfabric

#endif  // NETIO3BACKEND_BACKENDLIBFABRIC_BACKENDLIBFABRICCONNECTIONLESS_HPP