/* -*- 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_FACE_COMMON_HPP
#define NFD_DAEMON_FACE_FACE_COMMON_HPP

#include "ethernet-protocol.hpp"
#include "udp-protocol.hpp"
#include "common/logger.hpp"

#include <ndn-cxx/encoding/nfd-constants.hpp>

#include <boost/logic/tribool.hpp>
#include <variant>

namespace nfd {
namespace face {

class Face;
class LinkService;

/**
 * \brief Identifies a face.
 */
using FaceId = uint64_t;

/// Indicates an invalid FaceId
inline constexpr FaceId INVALID_FACEID = ndn::nfd::INVALID_FACE_ID;
/// Identifies the InternalFace used in management
inline constexpr FaceId FACEID_INTERNAL_FACE = 1;
/// Identifies a packet comes from the ContentStore
inline constexpr FaceId FACEID_CONTENT_STORE = 254;
/// Identifies the NullFace that drops every packet
inline constexpr FaceId FACEID_NULL = 255;
/// Upper bound of reserved FaceIds
inline constexpr FaceId FACEID_RESERVED_MAX = 255;

/**
 * \brief Minimum MTU that may be set.
 *
 * This is done to ensure the NDNLPv2 fragmentation feature functions properly.
 */
inline constexpr ssize_t MIN_MTU = 64;

/**
 * \brief Identifies a remote endpoint on the link.
 *
 * This ID is only meaningful in the context of the same Transport.
 * Incoming packets from the same remote endpoint have the same EndpointId,
 * and incoming packets from different remote endpoints have different EndpointIds.
 *
 * Typically, a point-to-point Transport has only one meaningful EndpointId,
 * represented by `std::monostate`.
 */
using EndpointId = std::variant<std::monostate, ethernet::Address, udp::Endpoint>;

/** \brief Parameters used to set Transport properties or LinkService options on a newly created face.
 *
 *  Parameters are passed as a struct rather than individually, so that a future change in the list
 *  of parameters does not require an update to the method signature in all subclasses.
 */
struct FaceParams
{
  ndn::nfd::FacePersistency persistency = ndn::nfd::FACE_PERSISTENCY_PERSISTENT;
  std::optional<time::nanoseconds> baseCongestionMarkingInterval;
  std::optional<uint64_t> defaultCongestionThreshold;
  std::optional<ssize_t> mtu;
  bool wantLocalFields = false;
  bool wantLpReliability = false;
  boost::logic::tribool wantCongestionMarking = boost::logic::indeterminate;
};

/** \brief For internal use by FaceLogging macros.
 *
 *  FaceLogHelper wraps a reference to Face, LinkService, or Transport object.
 *
 *  `std::ostream& operator<<(std::ostream& os, const FaceLogHelper<T>& flh)`
 *  should be specialized to print "[id=888,local=scheme://local/uri,remote=scheme://remote/uri] "
 *  which will appear as part of the log message.
 */
template<typename T>
class FaceLogHelper
{
public:
  explicit
  FaceLogHelper(const T& obj1) noexcept
    : obj(obj1)
  {
  }

public:
  const T& obj;
};

} // namespace face

using face::EndpointId;
using face::FaceId;

} // namespace nfd

/** \defgroup FaceLogging Face logging macros
 *
 * These macros augment the log message with some face-specific information,
 * such as the face ID, that are useful to distinguish which face produced the
 * message. It is strongly recommended to use these macros instead of the
 * generic ones for all logging inside Face, LinkService, Transport subclasses.
 * @{
 */

/** \cond */
// implementation detail
#define NFD_LOG_FACE(level, msg) NFD_LOG_##level( \
  ::nfd::face::FaceLogHelper< \
    std::remove_cv_t<std::remove_reference_t<decltype(*this)>> \
  >(*this) \
  << msg)
/** \endcond */

/** \brief Log a message at TRACE level */
#define NFD_LOG_FACE_TRACE(msg) NFD_LOG_FACE(TRACE, msg)

/** \brief Log a message at DEBUG level */
#define NFD_LOG_FACE_DEBUG(msg) NFD_LOG_FACE(DEBUG, msg)

/** \brief Log a message at INFO level */
#define NFD_LOG_FACE_INFO(msg)  NFD_LOG_FACE(INFO,  msg)

/** \brief Log a message at WARN level */
#define NFD_LOG_FACE_WARN(msg)  NFD_LOG_FACE(WARN,  msg)

/** \brief Log a message at ERROR level */
#define NFD_LOG_FACE_ERROR(msg) NFD_LOG_FACE(ERROR, msg)

/** @} */

#endif // NFD_DAEMON_FACE_FACE_COMMON_HPP
