NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.0: NDN, CCN, CCNx, content centric networks
API Documentation
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 <boost/asio.hpp>
30 #include <boost/utility/value_init.hpp>
31 #include <boost/lexical_cast.hpp>
32 
33 namespace nfd {
34 
35 class Network
36 {
37 public:
39  {
40  }
41 
42  Network(const boost::asio::ip::address& minAddress,
43  const boost::asio::ip::address& maxAddress)
44  : m_minAddress(minAddress)
45  , m_maxAddress(maxAddress)
46  {
47  }
48 
49  void
50  print(std::ostream& os) const;
51 
52  bool
53  doesContain(const boost::asio::ip::address& address) const
54  {
55  return (m_minAddress <= address && address <= m_maxAddress);
56  }
57 
58  static const Network&
59  getMaxRangeV4();
60 
61  static const Network&
62  getMaxRangeV6();
63 
64  bool
65  operator==(const Network& rhs) const
66  {
67  return m_minAddress == rhs.m_minAddress && m_maxAddress == rhs.m_maxAddress;
68  }
69 
70  bool
71  operator!=(const Network& rhs) const
72  {
73  return !(*this == rhs);
74  }
75 
76 private:
77  boost::asio::ip::address m_minAddress;
78  boost::asio::ip::address m_maxAddress;
79 
80  friend std::istream&
81  operator>>(std::istream& is, Network& network);
82 
83  friend std::ostream&
84  operator<<(std::ostream& os, const Network& network);
85 };
86 
87 std::ostream&
88 operator<<(std::ostream& os, const Network& network);
89 
90 std::istream&
91 operator>>(std::istream& is, Network& network);
92 
93 } // namespace nfd
94 
95 #endif // NFD_CORE_NETWORK_HPP
bool doesContain(const boost::asio::ip::address &address) const
Definition: network.hpp:53
void print(std::ostream &os) const
Definition: network.cpp:31
Network(const boost::asio::ip::address &minAddress, const boost::asio::ip::address &maxAddress)
Definition: network.hpp:42
bool operator!=(const Network &rhs) const
Definition: network.hpp:71
bool operator==(const Network &rhs) const
Definition: network.hpp:65
static const Network & getMaxRangeV4()
Definition: network.cpp:37
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-common.hpp:38
static const Network & getMaxRangeV6()
Definition: network.cpp:45
friend std::istream & operator>>(std::istream &is, Network &network)
Definition: network.cpp:65
friend std::ostream & operator<<(std::ostream &os, const Network &network)
Definition: network.cpp:58