NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
network-address.cpp
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2013-2021 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 Davide Pesavento <davide.pesavento@lip6.fr>
22
*/
23
24
#include "
ndn-cxx/net/network-address.hpp
"
25
26
#ifdef __linux__
27
#include <linux/if_addr.h>
28
#endif
29
30
namespace
ndn
{
31
namespace
net
{
32
33
std::ostream&
34
operator<<
(std::ostream& os,
AddressScope
scope)
35
{
36
switch
(scope) {
37
case
AddressScope::NOWHERE
:
38
return
os <<
"nowhere"
;
39
case
AddressScope::HOST
:
40
return
os <<
"host"
;
41
case
AddressScope::LINK
:
42
return
os <<
"link"
;
43
case
AddressScope::GLOBAL
:
44
return
os <<
"global"
;
45
}
46
return
os;
47
}
48
49
NetworkAddress::NetworkAddress
(
AddressFamily
family,
50
const
boost::asio::ip::address& ip,
51
const
boost::asio::ip::address& broadcast,
52
uint8_t prefixLength,
53
AddressScope
scope,
54
uint32_t flags)
55
: m_family(family)
56
, m_ip(ip)
57
, m_broadcast(broadcast)
58
, m_prefixLength(prefixLength)
59
, m_scope(scope)
60
, m_flags(flags)
61
{
62
}
63
64
bool
65
NetworkAddress::isDeprecated
()
const
66
{
67
#ifdef __linux__
68
return
m_flags & IFA_F_DEPRECATED;
69
#else
70
// should probably check for IN6_IFF_DEPRECATED on macOS and FreeBSD, but the
71
// NetworkMonitor backend for those platforms doesn't provide any address flags
72
return
false
;
73
#endif
74
}
75
76
std::ostream&
77
operator<<
(std::ostream& os,
const
NetworkAddress
& addr)
78
{
79
return
os << addr.
getIp
() <<
'/'
<<
static_cast<
unsigned
int
>
(addr.
getPrefixLength
());
80
}
81
82
}
// namespace net
83
}
// namespace ndn
ndn
Copyright (c) 2011-2015 Regents of the University of California.
Definition:
ndn-strategy-choice-helper.hpp:34
ndn::net::AddressScope
AddressScope
Definition:
network-address.hpp:40
ndn::net::NetworkAddress::getIp
boost::asio::ip::address getIp() const
Returns the IP address (v4 or v6)
Definition:
network-address.hpp:76
ndn::net::AddressScope::LINK
network-address.hpp
ndn::net::AddressFamily
AddressFamily
Definition:
network-address.hpp:34
ndn::net::AddressScope::GLOBAL
ndn::net::AddressScope::NOWHERE
ndn::net::NetworkAddress
Stores one IP address supported by a network interface.
Definition:
network-address.hpp:53
ndn::net::NetworkAddress::getPrefixLength
uint8_t getPrefixLength() const
Returns the prefix length.
Definition:
network-address.hpp:94
ndn::net::NetworkAddress::NetworkAddress
NetworkAddress(AddressFamily family, const boost::asio::ip::address &ip, const boost::asio::ip::address &broadcast, uint8_t prefixLength, AddressScope scope, uint32_t flags)
Definition:
network-address.cpp:49
ndn::net::AddressScope::HOST
ndn::net::NetworkAddress::isDeprecated
bool isDeprecated() const
Returns true if the address is deprecated.
Definition:
network-address.cpp:65
ndn::net::operator<<
std::ostream & operator<<(std::ostream &os, AddressScope scope)
Definition:
network-address.cpp:34
ndn::net
Definition:
link-type-helper.cpp:30
ndnSIM
ndn-cxx
ndn-cxx
net
network-address.cpp
Generated on Fri May 6 2022 12:34:12 for ndnSIM by
1.8.13