|
NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
|
API Documentation
|
Go to the documentation of this file.
36 NetworkInterface::NetworkInterface()
48 if (!address.
getIp().is_unspecified()) {
51 bool isNew = m_netAddresses.erase(address) == 0;
52 m_netAddresses.insert(address);
54 NDN_LOG_DEBUG(
"added address " << address <<
" to " << m_name);
55 onAddressAdded(address);
65 if (m_netAddresses.erase(address) > 0) {
66 NDN_LOG_DEBUG(
"removed address " << address <<
" from " << m_name);
67 onAddressRemoved(address);
74 NetworkInterface::setIndex(
int index)
80 NetworkInterface::setName(
const std::string&
name)
82 BOOST_ASSERT(!
name.empty());
93 NetworkInterface::setFlags(uint32_t flags)
101 if (m_state != state) {
103 onStateChanged(state, m_state);
108 NetworkInterface::setMtu(uint32_t mtu)
112 onMtuChanged(mtu, m_mtu);
119 m_etherAddress = address;
125 m_etherBrdAddress = address;
132 case InterfaceType::UNKNOWN:
133 return os <<
"unknown";
134 case InterfaceType::LOOPBACK:
135 return os <<
"loopback";
136 case InterfaceType::ETHERNET:
137 return os <<
"ether";
146 case InterfaceState::UNKNOWN:
147 return os <<
"unknown";
148 case InterfaceState::DOWN:
150 case InterfaceState::NO_CARRIER:
151 return os <<
"no-carrier";
152 case InterfaceState::DORMANT:
153 return os <<
"dormant";
154 case InterfaceState::RUNNING:
155 return os <<
"running";
161 printFlag(std::ostream& os, uint32_t& flags, uint32_t flagVal,
const char* flagStr)
163 if (flags & flagVal) {
165 os << flagStr << (flags ?
"," :
"");
176 #define PRINT_IFF(flag) printFlag(os, flags, IFF_##flag, #flag)
182 #if defined(IFF_NOTRAILERS)
190 #if defined(__linux__)
196 #elif defined(__APPLE__) || defined(__FreeBSD__)
203 #if defined(__FreeBSD__)
212 #if defined(__linux__)
213 #define PRINT_IF_FLAG(flag) printFlag(os, flags, linux_if::FLAG_##flag, #flag)
214 PRINT_IF_FLAG(LOWER_UP);
225 os <<
" state " << netif.
getState() <<
" mtu " << netif.
getMtu() <<
"\n"
230 os <<
" " << (addr.getFamily() == AddressFamily::V4 ?
"inet " :
"inet6 ") << addr;
231 if (netif.
canBroadcast() && !addr.getBroadcast().is_unspecified())
232 os <<
" brd " << addr.getBroadcast();
233 os <<
" scope " << addr.getScope() <<
"\n";
#define NDN_LOG_INIT(name)
declare a log module
std::ostream & operator<<(std::ostream &os, const NetworkInterface &netif)
int getIndex() const
Returns an opaque ID that uniquely identifies the interface on the system.
Represents one network interface attached to the host.
InterfaceType getType() const
Returns the hardware type of the interface.
represents an Ethernet hardware address
Helper class to convert a number to hexadecimal format, for use with stream insertion operators.
Stores one IP address supported by a network interface.
void swap(any &x, any &y) any_noexcept
uint32_t getFlags() const
Returns a bitset of platform-specific flags enabled on the interface.
bool canBroadcast() const
Returns true if the interface supports broadcast communication.
boost::asio::ip::address getIp() const
Returns the IP address (v4 or v6)
InterfaceType
Indicates the hardware type of a network interface.
const std::set< NetworkAddress > & getNetworkAddresses() const
Returns a list of all network-layer addresses present on the interface.
ethernet::Address getEthernetAddress() const
Returns the link-layer (Ethernet) address of the interface.
InterfaceState
Indicates the state of a network interface.
InterfaceState getState() const
Returns the current state of the interface.
uint32_t getMtu() const
Returns the MTU (maximum transmission unit) of the interface.
#define NDN_LOG_DEBUG(expression)
static void printFlag(std::ostream &os, uint32_t &flags, uint32_t flagVal, const char *flagStr)
std::string getName() const
Returns the name of the interface, unique on the system.
@ DORMANT
interface has a carrier but it cannot send or receive normal user traffic yet
ethernet::Address getEthernetBroadcastAddress() const
Returns the link-layer (Ethernet) broadcast address of the interface.
@ RUNNING
interface can be used to send and receive packets
Copyright (c) 2011-2015 Regents of the University of California.