Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
fc::ip::address Class Reference

#include <ip.hpp>

Public Member Functions

 address (uint32_t _ip=0)
 
 address (const fc::string &s)
 
addressoperator= (const fc::string &s)
 
 operator fc::string () const
 
 operator uint32_t () const
 
bool is_private_address () const
 
bool is_multicast_address () const
 
bool is_public_address () const
 

Friends

bool operator== (const address &a, const address &b)
 
bool operator!= (const address &a, const address &b)
 

Detailed Description

Definition at line 11 of file ip.hpp.

Constructor & Destructor Documentation

◆ address() [1/2]

fc::ip::address::address ( uint32_t _ip = 0)

Definition at line 10 of file ip.cpp.

11 :_ip(ip){}

◆ address() [2/2]

fc::ip::address::address ( const fc::string & s)

Definition at line 13 of file ip.cpp.

14 {
15 try
16 {
17 _ip = boost::asio::ip::address_v4::from_string(s.c_str()).to_ulong();
18 }
19 FC_RETHROW_EXCEPTIONS(error, "Error parsing IP address ${address}", ("address", s))
20 }
#define FC_RETHROW_EXCEPTIONS(LOG_LEVEL, FORMAT,...)
Catchs all exception's, std::exceptions, and ... and rethrows them after appending the provided log m...
char * s

Member Function Documentation

◆ is_multicast_address()

bool fc::ip::address::is_multicast_address ( ) const

224.0.0.0 to 239.255.255.255

Definition at line 125 of file ip.cpp.

126 {
127 static address min_ip("224.0.0.0");
128 static address max_ip("239.255.255.255");
129 return _ip >= min_ip._ip && _ip <= max_ip._ip;
130 }
address(uint32_t _ip=0)
Definition ip.cpp:10
Here is the caller graph for this function:

◆ is_private_address()

bool fc::ip::address::is_private_address ( ) const
Returns
true if the ip is in the following ranges:

10.0.0.0 to 10.255.255.255 172.16.0.0 to 172.31.255.255 192.168.0.0 to 192.168.255.255 169.254.0.0 to 169.254.255.255

Definition at line 105 of file ip.cpp.

106 {
107 static address min10_ip("10.0.0.0");
108 static address max10_ip("10.255.255.255");
109 static address min172_ip("172.16.0.0");
110 static address max172_ip("172.31.255.255");
111 static address min192_ip("192.168.0.0");
112 static address max192_ip("192.168.255.255");
113 static address min169_ip("169.254.0.0");
114 static address max169_ip("169.254.255.255");
115 if( _ip >= min10_ip._ip && _ip <= max10_ip._ip ) return true;
116 if( _ip >= min172_ip._ip && _ip <= max172_ip._ip ) return true;
117 if( _ip >= min192_ip._ip && _ip <= max192_ip._ip ) return true;
118 if( _ip >= min169_ip._ip && _ip <= max169_ip._ip ) return true;
119 return false;
120 }
Here is the caller graph for this function:

◆ is_public_address()

bool fc::ip::address::is_public_address ( ) const

!private & !multicast

Definition at line 133 of file ip.cpp.

134 {
135 return !( is_private_address() || is_multicast_address() );
136 }
bool is_private_address() const
Definition ip.cpp:105
bool is_multicast_address() const
Definition ip.cpp:125
Here is the call graph for this function:

◆ operator fc::string()

fc::ip::address::operator fc::string ( ) const

Definition at line 39 of file ip.cpp.

40 {
41 try
42 {
43 return boost::asio::ip::address_v4(_ip).to_string().c_str();
44 }
45 FC_RETHROW_EXCEPTIONS(error, "Error parsing IP address to string")
46 }

◆ operator uint32_t()

fc::ip::address::operator uint32_t ( ) const

Definition at line 47 of file ip.cpp.

47 {
48 return _ip;
49 }

◆ operator=()

address & fc::ip::address::operator= ( const fc::string & s)

Definition at line 29 of file ip.cpp.

30 {
31 try
32 {
33 _ip = boost::asio::ip::address_v4::from_string(s.c_str()).to_ulong();
34 }
35 FC_RETHROW_EXCEPTIONS(error, "Error parsing IP address ${address}", ("address", s))
36 return *this;
37 }

Friends And Related Symbol Documentation

◆ operator!=

bool operator!= ( const address & a,
const address & b )
friend

Definition at line 25 of file ip.cpp.

25 {
26 return uint32_t(a) != uint32_t(b);
27 }
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
Definition pointer.h:1181
unsigned int uint32_t
Definition stdint.h:126

◆ operator==

bool operator== ( const address & a,
const address & b )
friend

Definition at line 22 of file ip.cpp.

22 {
23 return uint32_t(a) == uint32_t(b);
24 }

The documentation for this class was generated from the following files: