/* -*- 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_MGMT_RIB_MANAGER_HPP
#define NFD_DAEMON_MGMT_RIB_MANAGER_HPP

#include "manager-base.hpp"
#include "rib/route.hpp"

#include <ndn-cxx/mgmt/nfd/controller.hpp>
#include <ndn-cxx/mgmt/nfd/face-event-notification.hpp>
#include <ndn-cxx/mgmt/nfd/face-monitor.hpp>
#include <ndn-cxx/security/validator-config.hpp>
#include <ndn-cxx/util/scheduler.hpp>

namespace nfd {

namespace rib {
class Rib;
class RibUpdate;
} // namespace rib

/**
 * @brief Implements the RIB Management of NFD Management Protocol.
 * @sa https://redmine.named-data.net/projects/nfd/wiki/RibMgmt
 */
class RibManager final : public ManagerBase
{
public:
  RibManager(rib::Rib& rib, ndn::Face& face, ndn::KeyChain& keyChain,
             ndn::nfd::Controller& nfdController, Dispatcher& dispatcher);

  /**
   * @brief Apply localhost_security configuration.
   */
  void
  applyLocalhostConfig(const ConfigSection& section, const std::string& filename);

  /**
   * @brief Apply localhop_security configuration and allow accepting commands on
   *        /localhop/nfd/rib prefix.
   */
  void
  enableLocalhop(const ConfigSection& section, const std::string& filename);

  /**
   * @brief Disallow accepting commands on /localhop/nfd/rib prefix.
   */
  void
  disableLocalhop();

  /**
   * @brief Apply prefix_announcement_validation configuration.
   */
  void
  applyPaConfig(const ConfigSection& section, const std::string& filename);

  /**
   * @brief Start accepting commands and dataset requests.
   */
  void
  registerWithNfd();

  /**
   * @brief Enable NDNLP IncomingFaceId field in order to support self-registration commands.
   */
  void
  enableLocalFields();

public: // self-learning support
  enum class SlAnnounceResult {
    OK,                 ///< RIB and FIB have been updated
    ERROR,              ///< unspecified error
    VALIDATION_FAILURE, ///< the announcement cannot be verified against the trust schema
    EXPIRED,            ///< the announcement has expired
    NOT_FOUND,          ///< route does not exist (slRenew only)
  };

  using SlAnnounceCallback = std::function<void(SlAnnounceResult res)>;
  using SlFindAnnCallback = std::function<void(std::optional<ndn::PrefixAnnouncement>)>;

  /** \brief Insert a route by prefix announcement from self-learning strategy.
   *  \param pa A prefix announcement. It must contain the Data.
   *  \param faceId Face on which the announcement arrives.
   *  \param maxLifetime Maximum route lifetime as imposed by self-learning strategy.
   *  \param cb Callback to receive the operation result.
   *
   *  If \p pa passes validation and is unexpired, inserts or replaces a route for the announced
   *  name and faceId whose lifetime is set to the earlier of now+maxLifetime or prefix
   *  announcement expiration time, updates FIB, and invokes \p cb with SlAnnounceResult::OK.
   *  In case \p pa expires when validation completes, invokes \p cb with SlAnnounceResult::EXPIRED.
   *  If \p pa cannot be verified by the trust schema given in rib.localhop_security config key,
   *  or the relevant config has not been loaded via \c enableLocalHop, invokes \p cb with
   *  SlAnnounceResult::VALIDATION_FAILURE.
   *
   *  Self-learning strategy invokes this method after receiving a Data carrying a prefix
   *  announcement.
   */
  void
  slAnnounce(const ndn::PrefixAnnouncement& pa, uint64_t faceId, time::milliseconds maxLifetime,
             const SlAnnounceCallback& cb);

  /** \brief Renew a route created by prefix announcement from self-learning strategy.
   *  \param name Data name, for finding RIB entry by longest-prefix-match.
   *  \param faceId Nexthop face.
   *  \param maxLifetime Maximum route lifetime as imposed by self-learning strategy.
   *  \param cb Callback to receive the operation result.
   *
   *  If the specified route exists, prolongs its lifetime to the earlier of now+maxLifetime or
   *  prefix announcement expiration time, and invokes \p cb with SlAnnounceResult::OK.
   *  If the prefix announcement has expired, invokes \p cb with SlAnnounceResult::EXPIRED.
   *  If the route is not found, invokes \p cb with SlAnnounceResult::NOT_FOUND.
   *
   *  Self-learning strategy invokes this method after an Interest forwarded via a learned route
   *  is satisfied.
   *
   *  \bug In current implementation, if an slAnnounce operation is in progress to create a Route
   *       or replace a prefix announcement, slRenew could fail because Route does not exist in
   *       existing RIB, or overwrite the new prefix announcement with an old one.
   */
  void
  slRenew(const Name& name, uint64_t faceId, time::milliseconds maxLifetime,
          const SlAnnounceCallback& cb);

  /** \brief Retrieve an outgoing prefix announcement for self-learning strategy.
   *  \param name Data name.
   *  \param cb Callback to receive a prefix announcement that announces a prefix of \p name, or
   *            nullopt if no RIB entry is found by longest-prefix-match of \p name.
   *
   *  Self-learning strategy invokes this method before sending a Data in reply to a discovery
   *  Interest, so as to attach a prefix announcement onto that Data.
   *
   *  \bug In current implementation, if an slAnnounce operation is in progress, slFindAnn does not
   *       wait for that operation to complete and its result reflects the prior RIB state.
   */
  void
  slFindAnn(const Name& name, const SlFindAnnCallback& cb) const;

private: // RIB and FibUpdater actions
  enum class RibUpdateResult
  {
    OK,
    ERROR,
    EXPIRED,
  };

  static SlAnnounceResult
  getSlAnnounceResultFromRibUpdateResult(RibUpdateResult r);

  /** \brief Start adding a route to RIB and FIB.
   *  \param name route name
   *  \param route route parameters; may contain absolute expiration time
   *  \param expires relative expiration time; if specified, overwrites \c route.expires
   *  \param done completion callback
   */
  void
  beginAddRoute(const Name& name, rib::Route route, std::optional<time::nanoseconds> expires,
                const std::function<void(RibUpdateResult)>& done);

  /** \brief Start removing a route from RIB and FIB.
   *  \param name route name
   *  \param route route parameters
   *  \param done completion callback
   */
  void
  beginRemoveRoute(const Name& name, const rib::Route& route,
                   const std::function<void(RibUpdateResult)>& done);

  void
  beginRibUpdate(const rib::RibUpdate& update,
                 const std::function<void(RibUpdateResult)>& done);

private: // management Dispatcher related
  void
  registerTopPrefix(const Name& topPrefix);

  /** \brief Serve rib/register command.
   */
  void
  registerEntry(const Name& topPrefix, const Interest& interest,
                ControlParameters parameters,
                const ndn::mgmt::CommandContinuation& done);

  /** \brief Serve rib/unregister command.
   */
  void
  unregisterEntry(const Name& topPrefix, const Interest& interest,
                  ControlParameters parameters,
                  const ndn::mgmt::CommandContinuation& done);

  /** \brief Serve rib/list dataset.
   */
  void
  listEntries(const Name& topPrefix, const Interest& interest,
              ndn::mgmt::StatusDatasetContext& context);

  void
  setFaceForSelfRegistration(const Interest& request, ControlParameters& parameters);

  ndn::mgmt::Authorization
  makeAuthorization(const std::string& verb) final;

private: // Face monitor
  void
  fetchActiveFaces();

  void
  onFetchActiveFacesFailure(uint32_t code, const std::string& reason);

NFD_PUBLIC_WITH_TESTS_ELSE_PRIVATE:
  void
  scheduleActiveFaceFetch(const time::seconds& timeToWait);

  void
  removeInvalidFaces(const std::vector<ndn::nfd::FaceStatus>& activeFaces);

  void
  onNotification(const ndn::nfd::FaceEventNotification& notification);

public:
  static inline const Name LOCALHOP_TOP_PREFIX{"/localhop/nfd"};

private:
  rib::Rib& m_rib;
  ndn::KeyChain& m_keyChain;
  ndn::nfd::Controller& m_nfdController;
  Dispatcher& m_dispatcher;

  ndn::nfd::FaceMonitor m_faceMonitor;
  ndn::ValidatorConfig m_localhostValidator;
  ndn::ValidatorConfig m_localhopValidator;
  ndn::ValidatorConfig m_paValidator;
  bool m_isLocalhopEnabled;

  scheduler::ScopedEventId m_activeFaceFetchEvent;
};

std::ostream&
operator<<(std::ostream& os, RibManager::SlAnnounceResult res);

} // namespace nfd

#endif // NFD_DAEMON_MGMT_RIB_MANAGER_HPP
