NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.3: NDN, CCN, CCNx, content centric networks
API Documentation
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
network-monitor-impl-rtnl.hpp
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
24
#ifndef NDN_NET_NETWORK_MONITOR_IMPL_RTNL_HPP
25
#define NDN_NET_NETWORK_MONITOR_IMPL_RTNL_HPP
26
27
#include "ndn-cxx-config.hpp"
28
#include "../network-monitor.hpp"
29
30
#ifndef NDN_CXX_HAVE_RTNETLINK
31
#error "This file should not be compiled ..."
32
#endif
33
34
#include <boost/asio/posix/stream_descriptor.hpp>
35
36
#include <array>
37
#include <map>
38
39
#include <linux/netlink.h>
40
#include <linux/rtnetlink.h>
41
#include <linux/if_addr.h>
42
#include <linux/if_link.h>
43
44
namespace
ndn
{
45
namespace
net {
46
47
class
NetworkMonitorImplRtnl
:
public
NetworkMonitorImpl
48
{
49
public
:
50
using
Error
=
NetworkMonitor::Error
;
51
54
explicit
55
NetworkMonitorImplRtnl
(boost::asio::io_service& io);
56
57
~NetworkMonitorImplRtnl
();
58
59
uint32_t
60
getCapabilities
() const final
61
{
62
return
NetworkMonitor::CAP_ENUM
|
63
NetworkMonitor::CAP_IF_ADD_REMOVE
|
64
NetworkMonitor::CAP_STATE_CHANGE
|
65
NetworkMonitor::CAP_MTU_CHANGE
|
66
NetworkMonitor::CAP_ADDR_ADD_REMOVE
;
67
}
68
69
shared_ptr<const NetworkInterface>
70
getNetworkInterface
(
const
std::string& ifname)
const
final
;
71
72
std::vector<shared_ptr<const NetworkInterface>>
73
listNetworkInterfaces
()
const
final
;
74
75
private
:
76
struct
RtnlRequest
77
{
78
nlmsghdr nlh;
79
ifinfomsg ifi;
80
rtattr rta __attribute__((aligned(NLMSG_ALIGNTO)));
// rtattr has to be aligned
81
uint32_t rtext;
// space for IFLA_EXT_MASK
82
};
83
84
bool
85
isEnumerating()
const
;
86
87
void
88
initSocket();
89
90
void
91
sendDumpRequest(uint16_t nlmsgType);
92
93
void
94
asyncRead();
95
96
void
97
handleRead(
const
boost::system::error_code& error,
size_t
nBytesReceived,
98
const
shared_ptr<boost::asio::posix::stream_descriptor>&
socket
);
99
100
void
101
parseNetlinkMessage(
const
nlmsghdr* nlh,
size_t
len);
102
103
void
104
parseLinkMessage(
const
nlmsghdr* nlh,
const
ifinfomsg* ifi);
105
106
void
107
parseAddressMessage(
const
nlmsghdr* nlh,
const
ifaddrmsg* ifa);
108
109
void
110
parseRouteMessage(
const
nlmsghdr* nlh,
const
rtmsg* rtm);
111
112
static
void
113
updateInterfaceState(
NetworkInterface
& interface, uint8_t operState);
114
115
private
:
116
std::map<int, shared_ptr<NetworkInterface>> m_interfaces;
117
std::array<uint8_t, 16384> m_buffer;
118
shared_ptr<boost::asio::posix::stream_descriptor> m_socket;
119
uint32_t m_pid;
120
uint32_t m_sequenceNo;
121
bool
m_isEnumeratingLinks;
122
bool
m_isEnumeratingAddresses;
123
};
124
125
}
// namespace net
126
}
// namespace ndn
127
128
#endif // NDN_NET_NETWORK_MONITOR_IMPL_RTNL_HPP
ndn
Copyright (c) 2011-2015 Regents of the University of California.
Definition:
ndn-strategy-choice-helper.hpp:34
ndn::net::NetworkMonitor::Error
Definition:
network-monitor.hpp:57
ndn::net::NetworkMonitor::CAP_ENUM
listNetworkInterfaces() and getNetworkInterface() are supported
Definition:
network-monitor.hpp:81
ndn::net::NetworkMonitor::CAP_ADDR_ADD_REMOVE
NetworkInterface onAddressAdded and onAddressRemoved signals are supported.
Definition:
network-monitor.hpp:89
ndn::net::NetworkMonitor::CAP_MTU_CHANGE
NetworkInterface onMtuChanged signal is supported.
Definition:
network-monitor.hpp:87
ndn::net::NetworkMonitor::CAP_STATE_CHANGE
NetworkInterface onStateChanged signal is supported.
Definition:
network-monitor.hpp:85
ndn::net::NetworkMonitorImplRtnl
Definition:
network-monitor-impl-rtnl.hpp:47
ndn::net::NetworkMonitorImplRtnl::getNetworkInterface
shared_ptr< const NetworkInterface > getNetworkInterface(const std::string &ifname) const final
Definition:
network-monitor-impl-rtnl.cpp:65
ndn::net::NetworkMonitorImpl
Definition:
network-monitor.hpp:141
ndn::net::NetworkInterface
Represents one network interface attached to the host.
Definition:
network-interface.hpp:68
ndn::net::NetworkMonitorImplRtnl::NetworkMonitorImplRtnl
NetworkMonitorImplRtnl(boost::asio::io_service &io)
initialize netlink socket and start enumerating interfaces
Definition:
network-monitor-impl-rtnl.cpp:43
ndn::net::NetworkMonitor::CAP_IF_ADD_REMOVE
NetworkMonitor onInterfaceAdded and onInterfaceRemoved signals are supported.
Definition:
network-monitor.hpp:83
ndn::net::NetworkMonitorImplRtnl::~NetworkMonitorImplRtnl
~NetworkMonitorImplRtnl()
Definition:
network-monitor-impl-rtnl.cpp:58
websocketpp::transport::asio::socket::error::socket
Catch-all error for socket component errors that don't fit in other categories.
Definition:
base.hpp:83
ndn::net::NetworkMonitorImplRtnl::listNetworkInterfaces
std::vector< shared_ptr< const NetworkInterface > > listNetworkInterfaces() const final
Definition:
network-monitor-impl-rtnl.cpp:75
ndn::net::NetworkMonitorImplRtnl::getCapabilities
uint32_t getCapabilities() const final
Definition:
network-monitor-impl-rtnl.hpp:60
ndnSIM
ndn-cxx
src
net
detail
network-monitor-impl-rtnl.hpp
Generated on Thu Nov 2 2017 03:30:28 for ndnSIM by
1.8.11