/* -*- 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_CORE_NETWORK_HPP
#define NFD_CORE_NETWORK_HPP

#include <boost/asio/ip/address.hpp>
#include <string_view>

namespace nfd {

class Network
{
public:
  Network();

  Network(const boost::asio::ip::address& minAddress,
          const boost::asio::ip::address& maxAddress);

  bool
  doesContain(const boost::asio::ip::address& address) const
  {
    return m_minAddress <= address && address <= m_maxAddress;
  }

  static const Network&
  getMaxRangeV4();

  static const Network&
  getMaxRangeV6();

  static bool
  isValidCidr(std::string_view cidr);

  bool
  operator==(const Network& rhs) const
  {
    return m_minAddress == rhs.m_minAddress && m_maxAddress == rhs.m_maxAddress;
  }

  bool
  operator!=(const Network& rhs) const
  {
    return !(*this == rhs);
  }

private:
  boost::asio::ip::address m_minAddress;
  boost::asio::ip::address m_maxAddress;

  friend std::ostream&
  operator<<(std::ostream& os, const Network& network);

  friend std::istream&
  operator>>(std::istream& is, Network& network);
};

std::ostream&
operator<<(std::ostream& os, const Network& network);

std::istream&
operator>>(std::istream& is, Network& network);

} // namespace nfd

#endif // NFD_CORE_NETWORK_HPP
