/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
 * Copyright (c) 2014-2016,  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_INTERNAL_TRANSPORT_HPP
#define NFD_DAEMON_FACE_INTERNAL_TRANSPORT_HPP

#include "transport.hpp"
#include <ndn-cxx/transport/transport.hpp>

namespace nfd {
namespace face {

/** \brief abstracts a transport that can be paired with another
 */
class InternalTransportBase
{
public:
  /** \brief causes the transport to receive a link-layer packet
   */
  virtual void
  receiveFromLink(const Block& packet) = 0;

  signal::Signal<InternalTransportBase, Block> afterSend;

protected:
  DECLARE_SIGNAL_EMIT(afterSend)
};

/** \brief implements a forwarder-side transport that can be paired with another
 */
class InternalForwarderTransport : public face::Transport, public InternalTransportBase
{
public:
  InternalForwarderTransport(const FaceUri& localUri = FaceUri("internal://"),
                             const FaceUri& remoteUri = FaceUri("internal://"),
                             ndn::nfd::FaceScope scope = ndn::nfd::FACE_SCOPE_LOCAL,
                             ndn::nfd::LinkType linkType = ndn::nfd::LINK_TYPE_POINT_TO_POINT);

  virtual void
  receiveFromLink(const Block& packet) override;

protected:
  virtual void
  beforeChangePersistency(ndn::nfd::FacePersistency newPersistency) override;

  virtual void
  doClose() override;

private:
  virtual void
  doSend(Packet&& packet) override;

private:
  NFD_LOG_INCLASS_DECLARE();
};

/** \brief implements a client-side transport that can be paired with another
 */
class InternalClientTransport : public ndn::Transport, public InternalTransportBase
{
public:
  /** \brief connect to a forwarder-side transport
   *  \param forwarderTransport the forwarder-side transport to connect to; may be nullptr
   *
   *  The connected forwarder-side transport will be disconnected automatically if this method
   *  is called again, or if that transport is closed.
   *  It's safe to use InternalClientTransport without a connected forwarder-side transport:
   *  all sent packets would be lost, and nothing would be received.
   */
  void
  connectToForwarder(InternalForwarderTransport* forwarderTransport);

  virtual void
  receiveFromLink(const Block& packet) override;

  virtual void
  close() override
  {
  }

  virtual void
  pause() override
  {
  }

  virtual void
  resume() override
  {
  }

  virtual void
  send(const Block& wire) override;

  virtual void
  send(const Block& header, const Block& payload) override;

private:
  NFD_LOG_INCLASS_DECLARE();

  signal::ScopedConnection m_fwToClientTransmitConn;
  signal::ScopedConnection m_clientToFwTransmitConn;
  signal::ScopedConnection m_fwTransportStateConn;
};

} // namespace face
} // namespace nfd

#endif // NFD_DAEMON_FACE_INTERNAL_TRANSPORT_HPP
