Electroneum
epee::net_utils::network_address Class Reference

#include <net_utils_base.h>

Public Member Functions

 network_address ()
 
template<typename T >
 network_address (const T &src)
 
bool equal (const network_address &other) const
 
bool less (const network_address &other) const
 
bool is_same_host (const network_address &other) const
 
std::string str () const
 
std::string host_str () const
 
bool is_loopback () const
 
bool is_local () const
 
address_type get_type_id () const
 
zone get_zone () const
 
bool is_blockable () const
 
template<typename Type >
const Typeas () const
 
 if (!epee::serialization::selector< is_store >::serialize(type, stg, hparent_section, "type")) return false
 
 switch (address_type(type))
 
 MERROR ("Unsupported network address type: "<<(unsigned) type)
 

Public Attributes

std::uint8_t type = std::uint8_t(is_store ? this_ref.get_type_id() : address_type::invalid)
 
return false
 

Static Public Attributes

static constexpr std::integral_constant< bool, is_store > is_store_ {}
 

Detailed Description

Definition at line 110 of file net_utils_base.h.

Constructor & Destructor Documentation

◆ network_address() [1/2]

epee::net_utils::network_address::network_address ( )
inline

Definition at line 189 of file net_utils_base.h.

189 : self(nullptr) {}

◆ network_address() [2/2]

template<typename T >
epee::net_utils::network_address::network_address ( const T src)
inline

Definition at line 191 of file net_utils_base.h.

192  : self(std::make_shared<implementation<T>>(src)) {}

Member Function Documentation

◆ as()

template<typename Type >
const Type& epee::net_utils::network_address::as ( ) const
inline

Definition at line 203 of file net_utils_base.h.

203 { return as_mutable<const Type>(); }
Here is the caller graph for this function:

◆ equal()

bool epee::net_utils::network_address::equal ( const network_address other) const

Definition at line 25 of file net_utils_base.cpp.

26  {
27  // clang typeid workaround
28  network_address::interface const* const self_ = self.get();
29  network_address::interface const* const other_self = other.self.get();
30  if (self_ == other_self) return true;
31  if (!self_ || !other_self) return false;
32  if (typeid(*self_) != typeid(*other_self)) return false;
33  return self_->equal(*other_self);
34  }
Here is the caller graph for this function:

◆ get_type_id()

address_type epee::net_utils::network_address::get_type_id ( ) const
inline

Definition at line 200 of file net_utils_base.h.

200 { return self ? self->get_type_id() : address_type::invalid; }
Here is the caller graph for this function:

◆ get_zone()

zone epee::net_utils::network_address::get_zone ( ) const
inline

Definition at line 201 of file net_utils_base.h.

201 { return self ? self->get_zone() : zone::public_; }

◆ host_str()

std::string epee::net_utils::network_address::host_str ( ) const
inline

Definition at line 197 of file net_utils_base.h.

197 { return self ? self->host_str() : "<none>"; }

◆ if()

epee::net_utils::network_address::if ( !epee::serialization::selector< is_store >  ::serializetype, stg, hparent_section, "type")

◆ is_blockable()

bool epee::net_utils::network_address::is_blockable ( ) const
inline

Definition at line 202 of file net_utils_base.h.

202 { return self ? self->is_blockable() : false; }

◆ is_local()

bool epee::net_utils::network_address::is_local ( ) const
inline

Definition at line 199 of file net_utils_base.h.

199 { return self ? self->is_local() : false; }

◆ is_loopback()

bool epee::net_utils::network_address::is_loopback ( ) const
inline

Definition at line 198 of file net_utils_base.h.

198 { return self ? self->is_loopback() : false; }

◆ is_same_host()

bool epee::net_utils::network_address::is_same_host ( const network_address other) const

Definition at line 48 of file net_utils_base.cpp.

49  {
50  // clang typeid workaround
51  network_address::interface const* const self_ = self.get();
52  network_address::interface const* const other_self = other.self.get();
53  if (self_ == other_self) return true;
54  if (!self_ || !other_self) return false;
55  if (typeid(*self_) != typeid(*other_self)) return false;
56  return self_->is_same_host(*other_self);
57  }

◆ less()

bool epee::net_utils::network_address::less ( const network_address other) const

Definition at line 36 of file net_utils_base.cpp.

37  {
38  // clang typeid workaround
39  network_address::interface const* const self_ = self.get();
40  network_address::interface const* const other_self = other.self.get();
41  if (self_ == other_self) return false;
42  if (!self_ || !other_self) return self == nullptr;
43  if (typeid(*self_) != typeid(*other_self))
44  return self_->get_type_id() < other_self->get_type_id();
45  return self_->less(*other_self);
46  }
Here is the caller graph for this function:

◆ MERROR()

epee::net_utils::network_address::MERROR ( "Unsupported network address type: "<<(unsigned)  type)

◆ str()

std::string epee::net_utils::network_address::str ( ) const
inline

Definition at line 196 of file net_utils_base.h.

196 { return self ? self->str() : "<none>"; }
Here is the caller graph for this function:

◆ switch()

epee::net_utils::network_address::switch ( address_type(type )
inline

Definition at line 213 of file net_utils_base.h.

214  {
215  case address_type::ipv4:
216  return this_ref.template serialize_addr<ipv4_network_address>(is_store_, stg, hparent_section);
217  case address_type::tor:
218  return this_ref.template serialize_addr<net::tor_address>(is_store_, stg, hparent_section);
219  case address_type::i2p:
220  return this_ref.template serialize_addr<net::i2p_address>(is_store_, stg, hparent_section);
222  default:
223  break;
224  }
static constexpr std::integral_constant< bool, is_store > is_store_

Member Data Documentation

◆ false

return epee::net_utils::network_address::false

Definition at line 227 of file net_utils_base.h.

◆ is_store_

constexpr std::integral_constant<bool, is_store> epee::net_utils::network_address::is_store_ {}
static

Definition at line 207 of file net_utils_base.h.

◆ type

std::uint8_t epee::net_utils::network_address::type = std::uint8_t(is_store ? this_ref.get_type_id() : address_type::invalid)

Definition at line 209 of file net_utils_base.h.


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