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; -*- */
24 #ifndef NDN_NET_NETWORK_ADDRESS_HPP
25 #define NDN_NET_NETWORK_ADDRESS_HPP
26 
27 #include "../common.hpp"
28 #include <boost/asio/ip/address.hpp>
29 
30 namespace ndn {
31 namespace net {
32 
33 enum class AddressFamily {
35  V4,
36  V6,
37 };
38 
39 enum class AddressScope {
40  NOWHERE,
41  HOST,
42  LINK,
43  GLOBAL,
44 };
45 
46 std::ostream&
47 operator<<(std::ostream& os, AddressScope scope);
48 
53 {
54 public:
56  boost::asio::ip::address ip,
57  boost::asio::ip::address broadcast,
58  uint8_t prefixLength,
59  AddressScope scope,
60  uint32_t flags);
61 
65  getFamily() const
66  {
67  return m_family;
68  }
69 
72  boost::asio::ip::address
73  getIp() const
74  {
75  return m_ip;
76  }
77 
80  boost::asio::ip::address
81  getBroadcast() const
82  {
83  return m_broadcast;
84  }
85 
88  uint8_t
90  {
91  return m_prefixLength;
92  }
93 
97  getScope() const
98  {
99  return m_scope;
100  }
101 
104  uint32_t
105  getFlags() const
106  {
107  return m_flags;
108  }
109 
110  friend bool
112  {
113  return a.m_ip < b.m_ip;
114  }
115 
116 private:
117  AddressFamily m_family;
118  boost::asio::ip::address m_ip;
119  boost::asio::ip::address m_broadcast;
120  uint8_t m_prefixLength;
121  AddressScope m_scope;
122  uint32_t m_flags; // IFA_F_* in if_addr.h
123 };
124 
125 std::ostream&
126 operator<<(std::ostream& os, const NetworkAddress& address);
127 
128 } // namespace net
129 } // namespace ndn
130 
131 #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.
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)