network.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
26 #ifndef NFD_CORE_NETWORK_HPP
27 #define NFD_CORE_NETWORK_HPP
28 
29 #include "common.hpp"
30 
31 namespace nfd {
32 
33 class Network
34 {
35 public:
36  Network();
37 
38  Network(const boost::asio::ip::address& minAddress,
39  const boost::asio::ip::address& maxAddress);
40 
41  bool
42  doesContain(const boost::asio::ip::address& address) const
43  {
44  return m_minAddress <= address && address <= m_maxAddress;
45  }
46 
47  static const Network&
48  getMaxRangeV4();
49 
50  static const Network&
51  getMaxRangeV6();
52 
53  static bool
54  isValidCidr(const std::string& cidr);
55 
56  bool
57  operator==(const Network& rhs) const
58  {
59  return m_minAddress == rhs.m_minAddress && m_maxAddress == rhs.m_maxAddress;
60  }
61 
62  bool
63  operator!=(const Network& rhs) const
64  {
65  return !(*this == rhs);
66  }
67 
68 private:
69  boost::asio::ip::address m_minAddress;
70  boost::asio::ip::address m_maxAddress;
71 
72  friend std::ostream&
73  operator<<(std::ostream& os, const Network& network);
74 
75  friend std::istream&
76  operator>>(std::istream& is, Network& network);
77 };
78 
79 std::ostream&
80 operator<<(std::ostream& os, const Network& network);
81 
82 std::istream&
83 operator>>(std::istream& is, Network& network);
84 
85 } // namespace nfd
86 
87 #endif // NFD_CORE_NETWORK_HPP
friend std::ostream & operator<<(std::ostream &os, const Network &network)
Definition: network.cpp:79
static bool isValidCidr(const std::string &cidr)
Definition: network.cpp:62
bool operator!=(const Network &rhs) const
Definition: network.hpp:63
Copyright (c) 2014-2015, Regents of the University of California, Arizona Board of Regents...
Definition: algorithm.hpp:32
bool doesContain(const boost::asio::ip::address &address) const
Definition: network.hpp:42
bool operator==(const Network &rhs) const
Definition: network.hpp:57
static const Network & getMaxRangeV6()
Definition: network.cpp:52
friend std::istream & operator>>(std::istream &is, Network &network)
Definition: network.cpp:85
static const Network & getMaxRangeV4()
Definition: network.cpp:44