NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
network-monitor.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2013-2018 Regents of the University of California.
4  *
5  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
6  *
7  * ndn-cxx library is free software: you can redistribute it and/or modify it under the
8  * terms of the GNU Lesser General Public License as published by the Free Software
9  * Foundation, either version 3 of the License, or (at your option) any later version.
10  *
11  * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
12  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
13  * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
14  *
15  * You should have received copies of the GNU General Public License and GNU Lesser
16  * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see
17  * <http://www.gnu.org/licenses/>.
18  *
19  * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
20  *
21  * @author Alexander Afanasyev <alexander.afanasyev@ucla.edu>
22  * @author Davide Pesavento <davide.pesavento@lip6.fr>
23  */
24 
25 #ifndef NDN_NET_NETWORK_MONITOR_HPP
26 #define NDN_NET_NETWORK_MONITOR_HPP
27 
30 
31 #include <vector>
32 
33 namespace ndn {
34 namespace net {
35 
36 class NetworkMonitorImpl;
37 
50 class NetworkMonitor : noncopyable
51 {
52 public:
53  class Error : public std::runtime_error
54  {
55  public:
56  using std::runtime_error::runtime_error;
57  };
58 
64  explicit
65  NetworkMonitor(boost::asio::io_service& io);
66 
67  enum Capability : uint32_t {
69  CAP_NONE = 0,
71  CAP_ENUM = 1 << 0,
75  CAP_STATE_CHANGE = 1 << 2,
77  CAP_MTU_CHANGE = 1 << 3,
80  };
81 
83  uint32_t
84  getCapabilities() const;
85 
87  shared_ptr<const NetworkInterface>
88  getNetworkInterface(const std::string& ifname) const;
89 
95  std::vector<shared_ptr<const NetworkInterface>>
96  listNetworkInterfaces() const;
97 
98 protected:
99  explicit
100  NetworkMonitor(unique_ptr<NetworkMonitorImpl> impl);
101 
104  {
105  return *m_impl;
106  }
107 
108 private:
109  const unique_ptr<NetworkMonitorImpl> m_impl;
110  // Intentional violation of code-style rule 1.4: m_impl must be assigned before its signals can
111  // be assigned to references below.
112 
113 public: // signals
116 
119 
126 
129 };
130 
131 class NetworkMonitorImpl : noncopyable
132 {
133 public:
135 
136  virtual
137  ~NetworkMonitorImpl() = default;
138 
139  virtual uint32_t
140  getCapabilities() const = 0;
141 
142  virtual shared_ptr<const NetworkInterface>
143  getNetworkInterface(const std::string&) const = 0;
144 
145  virtual std::vector<shared_ptr<const NetworkInterface>>
146  listNetworkInterfaces() const = 0;
147 
148 protected:
149  static shared_ptr<NetworkInterface>
151 
152 public:
157 
158 protected:
163 };
164 
165 } // namespace net
166 } // namespace ndn
167 
168 #endif // NDN_NET_NETWORK_MONITOR_HPP
Copyright (c) 2011-2015 Regents of the University of California.
listNetworkInterfaces() and getNetworkInterface() are supported
virtual shared_ptr< const NetworkInterface > getNetworkInterface(const std::string &) const =0
virtual std::vector< shared_ptr< const NetworkInterface > > listNetworkInterfaces() const =0
NetworkMonitor(boost::asio::io_service &io)
Construct instance, request enumeration of all network interfaces, and start monitoring for network s...
static shared_ptr< NetworkInterface > makeNetworkInterface()
util::Signal< NetworkMonitorImpl, shared_ptr< const NetworkInterface > > & onInterfaceAdded
Fires when a new interface is added.
NetworkInterface onAddressAdded and onAddressRemoved signals are supported.
NetworkInterface onMtuChanged signal is supported.
NetworkInterface onStateChanged signal is supported.
util::Signal< NetworkMonitorImpl > & onNetworkStateChanged
virtual ~NetworkMonitorImpl()=default
provides a lightweight signal / event system
Definition: signal.hpp:51
uint32_t getCapabilities() const
Returns a bitwise OR'ed set of Capability flags supported on the current platform.
Network interface monitor.
util::Signal< NetworkMonitorImpl > onEnumerationCompleted
NetworkMonitor is not supported and is a no-op.
util::Signal< NetworkMonitorImpl, shared_ptr< const NetworkInterface > > & onInterfaceRemoved
Fires when an interface is removed.
#define DECLARE_SIGNAL_EMIT(signalName)
(implementation detail) declares a 'emit_signalName' method
Definition: emit.hpp:59
util::Signal< NetworkMonitorImpl, shared_ptr< const NetworkInterface > > onInterfaceRemoved
std::vector< shared_ptr< const NetworkInterface > > listNetworkInterfaces() const
Lists all network interfaces currently available on the system.
virtual uint32_t getCapabilities() const =0
shared_ptr< const NetworkInterface > getNetworkInterface(const std::string &ifname) const
Returns the NetworkInterface with the given name, or nullptr if it does not exist.
util::Signal< NetworkMonitorImpl, shared_ptr< const NetworkInterface > > onInterfaceAdded
NetworkMonitorImpl & getImpl()
NetworkMonitor onInterfaceAdded and onInterfaceRemoved signals are supported.
util::Signal< NetworkMonitorImpl > onNetworkStateChanged
util::Signal< NetworkMonitorImpl > & onEnumerationCompleted
Fires when network interfaces enumeration is complete.