/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
 * Copyright (c) 2014-2022,  Regents of the University of California,
 *                           Arizona Board of Regents,
 *                           Colorado State University,
 *                           University Pierre & Marie Curie, Sorbonne University,
 *                           Washington University in St. Louis,
 *                           Beijing Institute of Technology,
 *                           The University of Memphis.
 *
 * This file is part of NFD (Named Data Networking Forwarding Daemon).
 * See AUTHORS.md for complete list of NFD authors and contributors.
 *
 * NFD is free software: you can redistribute it and/or modify it under the terms
 * of the GNU General Public License as published by the Free Software Foundation,
 * either version 3 of the License, or (at your option) any later version.
 *
 * NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
 * PURPOSE.  See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along with
 * NFD, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef NFD_DAEMON_FACE_ETHERNET_TRANSPORT_HPP
#define NFD_DAEMON_FACE_ETHERNET_TRANSPORT_HPP

#include "ethernet-protocol.hpp"
#include "pcap-helper.hpp"
#include "transport.hpp"

#include <boost/asio/posix/stream_descriptor.hpp>
#include <ndn-cxx/net/network-interface.hpp>

namespace nfd::face {

/**
 * @brief Base class for Ethernet-based Transports
 */
class EthernetTransport : public Transport
{
public:
  class Error : public std::runtime_error
  {
  public:
    using std::runtime_error::runtime_error;
  };

  /**
   * @brief Processes the payload of an incoming frame
   * @param payload Payload bytes, starting from the first byte after the Ethernet header
   * @param sender Sender address
   */
  void
  receivePayload(span<const uint8_t> payload, const ethernet::Address& sender);

protected:
  EthernetTransport(const ndn::net::NetworkInterface& localEndpoint,
                    const ethernet::Address& remoteEndpoint);

  void
  doClose() final;

  bool
  hasRecentlyReceived() const
  {
    return m_hasRecentlyReceived;
  }

  void
  resetRecentlyReceived()
  {
    m_hasRecentlyReceived = false;
  }

private:
  void
  handleNetifStateChange(ndn::net::InterfaceState netifState);

  void
  doSend(const Block& packet) final;

  /**
   * @brief Sends the specified TLV block on the network wrapped in an Ethernet frame
   */
  void
  sendPacket(const ndn::Block& block);

  void
  asyncRead();

  void
  handleRead(const boost::system::error_code& error);

  void
  handleError(const std::string& errorMessage);

protected:
  boost::asio::posix::stream_descriptor m_socket;
  PcapHelper m_pcap;
  ethernet::Address m_srcAddress;
  ethernet::Address m_destAddress;
  std::string m_interfaceName;

private:
  signal::ScopedConnection m_netifStateChangedConn;
  signal::ScopedConnection m_netifMtuChangedConn;
  bool m_hasRecentlyReceived;
#ifdef _DEBUG
  /// number of frames dropped by the kernel, as reported by libpcap
  size_t m_nDropped;
#endif
};

} // namespace nfd::face

#endif // NFD_DAEMON_FACE_ETHERNET_TRANSPORT_HPP
