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

#include "face-common.hpp"

#include <ndn-cxx/lp/packet.hpp>

namespace nfd::face {

/**
 * \brief Fragments network-layer packets into NDNLPv2 link-layer packets.
 * \sa https://redmine.named-data.net/projects/nfd/wiki/NDNLPv2
 */
class LpFragmenter
{
public:
  /**
   * \brief %Options that control the behavior of LpFragmenter.
   */
  struct Options
  {
    /**
     * \brief Maximum number of fragments in a packet.
     */
    size_t nMaxFragments = 400;
  };

  explicit
  LpFragmenter(const Options& options, const LinkService* linkService = nullptr);

  /**
   * \brief Set options for fragmenter.
   */
  void
  setOptions(const Options& options)
  {
    m_options = options;
  }

  /**
   * \brief Returns the LinkService that owns this instance.
   *
   * This is only used for logging, and may be nullptr.
   */
  const LinkService*
  getLinkService() const noexcept
  {
    return m_linkService;
  }

  /**
   * \brief Fragments a network-layer packet into link-layer packets.
   * \param packet an LpPacket that contains a network-layer packet;
   *               must have Fragment field, must not have FragIndex and FragCount fields
   * \param mtu maximum allowable LpPacket size after fragmentation and sequence number assignment
   * \return whether fragmentation succeeded, fragmented packets without sequence number
   */
  std::tuple<bool, std::vector<lp::Packet>>
  fragmentPacket(const lp::Packet& packet, size_t mtu);

private:
  Options m_options;
  const LinkService* m_linkService;
};

std::ostream&
operator<<(std::ostream& os, const FaceLogHelper<LpFragmenter>& flh);

} // namespace nfd::face

#endif // NFD_DAEMON_FACE_LP_FRAGMENTER_HPP
