NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
network-address.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 Davide Pesavento <davide.pesavento@lip6.fr>
22  */
23 
24 #ifndef NDN_NET_NETWORK_ADDRESS_HPP
25 #define NDN_NET_NETWORK_ADDRESS_HPP
26 
28 
29 #include <boost/asio/ip/address.hpp>
30 
31 namespace ndn {
32 namespace net {
33 
34 enum class AddressFamily {
36  V4,
37  V6,
38 };
39 
40 enum class AddressScope {
41  NOWHERE,
42  HOST,
43  LINK,
44  GLOBAL,
45 };
46 
47 std::ostream&
48 operator<<(std::ostream& os, AddressScope scope);
49 
54 {
55 public:
57  boost::asio::ip::address ip,
58  boost::asio::ip::address broadcast,
59  uint8_t prefixLength,
60  AddressScope scope,
61  uint32_t flags);
62 
66  getFamily() const
67  {
68  return m_family;
69  }
70 
73  boost::asio::ip::address
74  getIp() const
75  {
76  return m_ip;
77  }
78 
81  boost::asio::ip::address
82  getBroadcast() const
83  {
84  return m_broadcast;
85  }
86 
89  uint8_t
91  {
92  return m_prefixLength;
93  }
94 
98  getScope() const
99  {
100  return m_scope;
101  }
102 
105  uint32_t
106  getFlags() const
107  {
108  return m_flags;
109  }
110 
111  friend bool
113  {
114  return a.m_ip < b.m_ip;
115  }
116 
117 private:
118  AddressFamily m_family;
119  boost::asio::ip::address m_ip;
120  boost::asio::ip::address m_broadcast;
121  uint8_t m_prefixLength;
122  AddressScope m_scope;
123  uint32_t m_flags; // IFA_F_* in if_addr.h
124 };
125 
126 std::ostream&
127 operator<<(std::ostream& os, const NetworkAddress& address);
128 
129 } // namespace net
130 } // namespace ndn
131 
132 #endif // NDN_NET_NETWORK_ADDRESS_HPP
Copyright (c) 2011-2015 Regents of the University of California.
AddressScope getScope() const
Returns the address scope.
boost::asio::ip::address getIp() const
Returns the IP address (v4 or v6)
AddressFamily getFamily() const
Returns the address family.
uint32_t getFlags() const
Returns a bitset of platform-specific flags enabled on the address.
Stores one IP address supported by a network interface.
boost::asio::ip::address getBroadcast() const
Returns the IP broadcast address.
import common constructs for ndn-cxx library internal use
uint8_t getPrefixLength() const
Returns the prefix length.
friend bool operator<(const NetworkAddress &a, const NetworkAddress &b)
NetworkAddress(AddressFamily family, boost::asio::ip::address ip, boost::asio::ip::address broadcast, uint8_t prefixLength, AddressScope scope, uint32_t flags)
std::ostream & operator<<(std::ostream &os, AddressScope scope)