NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
network-monitor.cpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
25 #include "network-monitor.hpp"
26 #include "ndn-cxx-config.hpp"
27 
28 #if defined(NDN_CXX_HAVE_OSX_FRAMEWORKS)
30 #define NETWORK_MONITOR_IMPL_TYPE NetworkMonitorImplOsx
31 #elif defined(NDN_CXX_HAVE_RTNETLINK)
33 #define NETWORK_MONITOR_IMPL_TYPE NetworkMonitorImplRtnl
34 #else
36 #define NETWORK_MONITOR_IMPL_TYPE NetworkMonitorImplNoop
37 #endif
38 
39 namespace ndn {
40 namespace net {
41 
42 NetworkMonitor::NetworkMonitor(boost::asio::io_service& io)
44 {
45 }
46 
47 NetworkMonitor::NetworkMonitor(unique_ptr<NetworkMonitorImpl> impl)
48  : m_impl(std::move(impl))
49  , onEnumerationCompleted(m_impl->onEnumerationCompleted)
50  , onInterfaceAdded(m_impl->onInterfaceAdded)
51  , onInterfaceRemoved(m_impl->onInterfaceRemoved)
52  , onNetworkStateChanged(m_impl->onNetworkStateChanged)
53 {
54 }
55 
56 uint32_t
58 {
59  return m_impl->getCapabilities();
60 }
61 
62 shared_ptr<const NetworkInterface>
63 NetworkMonitor::getNetworkInterface(const std::string& ifname) const
64 {
65  return m_impl->getNetworkInterface(ifname);
66 }
67 
68 std::vector<shared_ptr<const NetworkInterface>>
70 {
71  return m_impl->listNetworkInterfaces();
72 }
73 
74 shared_ptr<NetworkInterface>
76 {
77  // cannot use make_shared because NetworkInterface constructor is private
78  return shared_ptr<NetworkInterface>(new NetworkInterface);
79 }
80 
81 } // namespace net
82 } // namespace ndn
Copyright (c) 2011-2015 Regents of the University of California.
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()
STL namespace.
uint32_t getCapabilities() const
Returns a bitwise OR&#39;ed set of Capability flags supported on the current platform.
#define NETWORK_MONITOR_IMPL_TYPE
Copyright (c) 2013-2017 Regents of the University of California.
Network interface monitor.
Represents one network interface attached to the host.
std::vector< shared_ptr< const NetworkInterface > > listNetworkInterfaces() const
Lists all network interfaces currently available on the system.
shared_ptr< const NetworkInterface > getNetworkInterface(const std::string &ifname) const
Returns the NetworkInterface with the given name, or nullptr if it does not exist.
unique_ptr< T > make_unique(Args &&... args)
Definition: backports.hpp:73