OpenVPN 3 Core Library
Loading...
Searching...
No Matches
openvpn::IP::Addr Class Reference

#include <ip.hpp>

Collaboration diagram for openvpn::IP::Addr:
[legend]

Public Types

enum  Version { UNSPEC , V4 , V6 }
 
enum  { V4_MASK = (1 << 0) , V6_MASK = (1 << 1) }
 
enum  VersionSize { V4_SIZE = IPv4::Addr::SIZE , V6_SIZE = IPv6::Addr::SIZE }
 
typedef unsigned int VersionMask
 

Public Member Functions

template<typename TITLE >
 Addr (const Addr &other, const TITLE &title, const Version required_version)
 
template<typename TITLE >
 Addr (const Addr &other, const TITLE &title)
 
template<typename TITLE >
 Addr (const std::string &ipstr, const TITLE &title, const Version required_version)
 
template<typename TITLE >
 Addr (const std::string &ipstr, const TITLE &title)
 
 Addr (const std::string &ipstr)
 
template<typename TITLE >
void validate_version (const TITLE &title, const Version required_version) const
 
const IPv4::Addrto_ipv4 () const
 
IPv4::Addr to_ipv4_zero () const
 
const IPv6::Addrto_ipv6 () const
 
IPv6::Addr to_ipv6_zero () const
 
const IPv4::Addrto_ipv4_nocheck () const
 
const IPv6::Addrto_ipv6_nocheck () const
 
unsigned long to_ulong () const
 
long to_long () const
 
void to_byte_string (unsigned char *bytestr) const
 
void to_byte_string_variable (unsigned char *bytestr) const
 
std::uint32_t to_uint32_net () const
 
Addr netmask_from_this_as_extent () const
 
std::string to_string () const
 
std::string to_string_bracket_ipv6 () const
 
std::string to_hex () const
 
std::string arpa () const
 
openvpn_io::ip::address to_asio () const
 
Addr operator+ (const long delta) const
 
Addr operator- (const long delta) const
 
Addr operator<< (const unsigned int shift) const
 
Addr operator>> (const unsigned int shift) const
 
Addr operator~ () const
 
Addr network_addr (const unsigned int prefix_len) const
 
bool operator== (const Addr &other) const
 
bool operator!= (const Addr &other) const
 
bool operator< (const Addr &other) const
 
bool operator> (const Addr &other) const
 
bool operator<= (const Addr &other) const
 
bool operator>= (const Addr &other) const
 
Addr operator+ (const Addr &other) const
 
Addr operator- (const Addr &other) const
 
Addr operator* (const Addr &other) const
 
Addr operator/ (const Addr &other) const
 
Addr operator% (const Addr &other) const
 
Addr operator& (const Addr &other) const
 
Addr operator| (const Addr &other) const
 
bool unspecified () const
 
bool specified () const
 
bool all_zeros () const
 
bool all_ones () const
 
bool is_loopback () const
 
bool is_mapped_address () const
 
IP::Addr to_v4_addr () const
 
bool defined () const
 
const char * version_string () const
 
Version version () const
 
VersionMask version_mask () const
 
int version_index () const
 
int family () const
 
bool is_compatible (const Addr &other) const
 
bool is_ipv6 () const
 
void verify_version_consistency (const Addr &other) const
 
void validate_netmask () const
 
unsigned int prefix_len () const
 
int scope_id () const
 
unsigned int host_len () const
 
Addr extent_from_netmask () const
 
unsigned int size () const
 
unsigned int size_bytes () const
 
template<typename HASH >
void hash (HASH &h) const
 
 Addr ()
 
void reset ()
 
Addroperator= (const Addr &other)
 
Addroperator++ ()
 
Addroperator+= (const long delta)
 
Addroperator-= (const long delta)
 
void reset_ipv4_from_uint32 (const IPv4::Addr::base_type addr)
 

Static Public Member Functions

template<typename TITLE >
static Addr from_string (const std::string &ipstr, const TITLE &title, const Version required_version)
 
template<typename TITLE >
static Addr from_string (const std::string &ipstr, const TITLE &title)
 
static Addr from_string (const std::string &ipstr)
 
template<typename TITLE >
static std::string validate (const std::string &ipstr, const TITLE &title, const Version required_version)
 
template<typename TITLE >
static std::string validate (const std::string &ipstr, const TITLE &title)
 
static std::string validate (const std::string &ipstr)
 
static bool is_valid (const std::string &ipstr)
 
static Addr from_hex (Version v, const std::string &s)
 
static Addr from_ipv4 (IPv4::Addr addr)
 
static Addr from_ipv6 (IPv6::Addr addr)
 
static Addr from_sockaddr (const struct sockaddr *sa)
 
static bool sockaddr_defined (const struct sockaddr *sa)
 
static Addr from_ulong (Version v, unsigned long ul)
 
static Addr from_long (Version v, const long ul)
 
static Addr from_byte_string (const unsigned char *bytestr)
 
static Addr from_zero (const Version v)
 
static Addr from_one (const Version v)
 
static Addr from_zero_complement (const Version v)
 
static bool validate_prefix_len (Version v, const unsigned int prefix_len)
 
static Addr netmask_from_prefix_len (Version v, const unsigned int prefix_len)
 
static Addr from_asio (const openvpn_io::ip::address &addr)
 
static const char * version_string_static (Version ver)
 
static VersionMask version_mask (const Version ver)
 
static unsigned int version_size (Version v)
 

Private Member Functions

template<typename Comparator >
bool compare (const Addr &other, Comparator comp) const
 
template<typename BinaryOp >
Addr binary_op (const Addr &other, BinaryOp op) const
 

Private Attributes

union { 
 
   IPv4::Addr   v4 
 
   IPv6::Addr   v6 
 
u 
 
Version ver
 

Detailed Description

Definition at line 38 of file ip.hpp.

Member Typedef Documentation

◆ VersionMask

typedef unsigned int openvpn::IP::Addr::VersionMask

Definition at line 53 of file ip.hpp.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
V4_MASK 
V6_MASK 

Definition at line 48 of file ip.hpp.

◆ Version

Enumerator
UNSPEC 
V4 
V6 

Definition at line 41 of file ip.hpp.

◆ VersionSize

Enumerator
V4_SIZE 
V6_SIZE 

Definition at line 55 of file ip.hpp.

Constructor & Destructor Documentation

◆ Addr() [1/6]

template<typename TITLE >
openvpn::IP::Addr::Addr ( const Addr other,
const TITLE &  title,
const Version  required_version 
)
inline

Definition at line 64 of file ip.hpp.

◆ Addr() [2/6]

template<typename TITLE >
openvpn::IP::Addr::Addr ( const Addr other,
const TITLE &  title 
)
inline

Definition at line 82 of file ip.hpp.

◆ Addr() [3/6]

template<typename TITLE >
openvpn::IP::Addr::Addr ( const std::string &  ipstr,
const TITLE &  title,
const Version  required_version 
)
inline

Definition at line 88 of file ip.hpp.

◆ Addr() [4/6]

template<typename TITLE >
openvpn::IP::Addr::Addr ( const std::string &  ipstr,
const TITLE &  title 
)
inline

Definition at line 94 of file ip.hpp.

◆ Addr() [5/6]

openvpn::IP::Addr::Addr ( const std::string &  ipstr)
inline

Definition at line 99 of file ip.hpp.

◆ Addr() [6/6]

openvpn::IP::Addr::Addr ( )
inline

Definition at line 1070 of file ip.hpp.

Here is the caller graph for this function:

Member Function Documentation

◆ all_ones()

bool openvpn::IP::Addr::all_ones ( ) const
inline

Definition at line 829 of file ip.hpp.

◆ all_zeros()

bool openvpn::IP::Addr::all_zeros ( ) const
inline

Definition at line 816 of file ip.hpp.

Here is the caller graph for this function:

◆ arpa()

std::string openvpn::IP::Addr::arpa ( ) const
inline

Definition at line 563 of file ip.hpp.

◆ binary_op()

template<typename BinaryOp >
Addr openvpn::IP::Addr::binary_op ( const Addr other,
BinaryOp  op 
) const
inlineprivate

Definition at line 1168 of file ip.hpp.

Here is the caller graph for this function:

◆ compare()

template<typename Comparator >
bool openvpn::IP::Addr::compare ( const Addr other,
Comparator  comp 
) const
inlineprivate

Definition at line 1150 of file ip.hpp.

Here is the caller graph for this function:

◆ defined()

bool openvpn::IP::Addr::defined ( ) const
inline

Definition at line 872 of file ip.hpp.

Here is the caller graph for this function:

◆ extent_from_netmask()

Addr openvpn::IP::Addr::extent_from_netmask ( ) const
inline

Definition at line 1002 of file ip.hpp.

◆ family()

int openvpn::IP::Addr::family ( ) const
inline

Definition at line 931 of file ip.hpp.

Here is the caller graph for this function:

◆ from_asio()

static Addr openvpn::IP::Addr::from_asio ( const openvpn_io::ip::address &  addr)
inlinestatic

Definition at line 576 of file ip.hpp.

Here is the caller graph for this function:

◆ from_byte_string()

static Addr openvpn::IP::Addr::from_byte_string ( const unsigned char *  bytestr)
inlinestatic

Definition at line 395 of file ip.hpp.

◆ from_hex()

static Addr openvpn::IP::Addr::from_hex ( Version  v,
const std::string &  s 
)
inlinestatic

Definition at line 247 of file ip.hpp.

◆ from_ipv4()

static Addr openvpn::IP::Addr::from_ipv4 ( IPv4::Addr  addr)
inlinestatic

Definition at line 260 of file ip.hpp.

Here is the caller graph for this function:

◆ from_ipv6()

static Addr openvpn::IP::Addr::from_ipv6 ( IPv6::Addr  addr)
inlinestatic

Definition at line 268 of file ip.hpp.

Here is the caller graph for this function:

◆ from_long()

static Addr openvpn::IP::Addr::from_long ( Version  v,
const long  ul 
)
inlinestatic

Definition at line 367 of file ip.hpp.

◆ from_one()

static Addr openvpn::IP::Addr::from_one ( const Version  v)
inlinestatic

Definition at line 464 of file ip.hpp.

◆ from_sockaddr()

static Addr openvpn::IP::Addr::from_sockaddr ( const struct sockaddr *  sa)
inlinestatic

Definition at line 326 of file ip.hpp.

Here is the caller graph for this function:

◆ from_string() [1/3]

static Addr openvpn::IP::Addr::from_string ( const std::string &  ipstr)
inlinestatic

Definition at line 125 of file ip.hpp.

◆ from_string() [2/3]

template<typename TITLE >
static Addr openvpn::IP::Addr::from_string ( const std::string &  ipstr,
const TITLE &  title 
)
inlinestatic

Definition at line 120 of file ip.hpp.

◆ from_string() [3/3]

template<typename TITLE >
static Addr openvpn::IP::Addr::from_string ( const std::string &  ipstr,
const TITLE &  title,
const Version  required_version 
)
inlinestatic

Definition at line 105 of file ip.hpp.

Here is the caller graph for this function:

◆ from_ulong()

static Addr openvpn::IP::Addr::from_ulong ( Version  v,
unsigned long  ul 
)
inlinestatic

Definition at line 340 of file ip.hpp.

◆ from_zero()

static Addr openvpn::IP::Addr::from_zero ( const Version  v)
inlinestatic

Definition at line 450 of file ip.hpp.

Here is the caller graph for this function:

◆ from_zero_complement()

static Addr openvpn::IP::Addr::from_zero_complement ( const Version  v)
inlinestatic

Definition at line 478 of file ip.hpp.

Here is the caller graph for this function:

◆ hash()

template<typename HASH >
void openvpn::IP::Addr::hash ( HASH &  h) const
inline

Definition at line 1042 of file ip.hpp.

◆ host_len()

unsigned int openvpn::IP::Addr::host_len ( ) const
inline

Definition at line 988 of file ip.hpp.

◆ is_compatible()

bool openvpn::IP::Addr::is_compatible ( const Addr other) const
inline

Definition at line 944 of file ip.hpp.

Here is the caller graph for this function:

◆ is_ipv6()

bool openvpn::IP::Addr::is_ipv6 ( ) const
inline

Definition at line 949 of file ip.hpp.

Here is the caller graph for this function:

◆ is_loopback()

bool openvpn::IP::Addr::is_loopback ( ) const
inline

Definition at line 842 of file ip.hpp.

◆ is_mapped_address()

bool openvpn::IP::Addr::is_mapped_address ( ) const
inline

Determines if the IP address is a mapped IP address (e.g. ::ffff:127.0.0.1)

Definition at line 858 of file ip.hpp.

Here is the caller graph for this function:

◆ is_valid()

static bool openvpn::IP::Addr::is_valid ( const std::string &  ipstr)
inlinestatic

Definition at line 232 of file ip.hpp.

◆ netmask_from_prefix_len()

static Addr openvpn::IP::Addr::netmask_from_prefix_len ( Version  v,
const unsigned int  prefix_len 
)
inlinestatic

Definition at line 502 of file ip.hpp.

Here is the caller graph for this function:

◆ netmask_from_this_as_extent()

Addr openvpn::IP::Addr::netmask_from_this_as_extent ( ) const
inline

Definition at line 515 of file ip.hpp.

◆ network_addr()

Addr openvpn::IP::Addr::network_addr ( const unsigned int  prefix_len) const
inline

Definition at line 704 of file ip.hpp.

◆ operator!=()

bool openvpn::IP::Addr::operator!= ( const Addr other) const
inline

Definition at line 745 of file ip.hpp.

◆ operator%()

Addr openvpn::IP::Addr::operator% ( const Addr other) const
inline

Definition at line 791 of file ip.hpp.

◆ operator&()

Addr openvpn::IP::Addr::operator& ( const Addr other) const
inline

Definition at line 796 of file ip.hpp.

◆ operator*()

Addr openvpn::IP::Addr::operator* ( const Addr other) const
inline

Definition at line 781 of file ip.hpp.

◆ operator+() [1/2]

Addr openvpn::IP::Addr::operator+ ( const Addr other) const
inline

Definition at line 771 of file ip.hpp.

◆ operator+() [2/2]

Addr openvpn::IP::Addr::operator+ ( const long  delta) const
inline

Definition at line 607 of file ip.hpp.

Here is the caller graph for this function:

◆ operator++()

Addr & openvpn::IP::Addr::operator++ ( )
inline

Definition at line 1087 of file ip.hpp.

◆ operator+=()

Addr & openvpn::IP::Addr::operator+= ( const long  delta)
inline

Definition at line 1103 of file ip.hpp.

◆ operator-() [1/2]

Addr openvpn::IP::Addr::operator- ( const Addr other) const
inline

Definition at line 776 of file ip.hpp.

◆ operator-() [2/2]

Addr openvpn::IP::Addr::operator- ( const long  delta) const
inline

Definition at line 630 of file ip.hpp.

◆ operator-=()

Addr & openvpn::IP::Addr::operator-= ( const long  delta)
inline

Definition at line 1119 of file ip.hpp.

◆ operator/()

Addr openvpn::IP::Addr::operator/ ( const Addr other) const
inline

Definition at line 786 of file ip.hpp.

◆ operator<()

bool openvpn::IP::Addr::operator< ( const Addr other) const
inline

Definition at line 750 of file ip.hpp.

◆ operator<<()

Addr openvpn::IP::Addr::operator<< ( const unsigned int  shift) const
inline

Definition at line 635 of file ip.hpp.

◆ operator<=()

bool openvpn::IP::Addr::operator<= ( const Addr other) const
inline

Definition at line 760 of file ip.hpp.

◆ operator=()

Addr & openvpn::IP::Addr::operator= ( const Addr other)
inline

Definition at line 1080 of file ip.hpp.

◆ operator==()

bool openvpn::IP::Addr::operator== ( const Addr other) const
inline

Definition at line 727 of file ip.hpp.

Here is the caller graph for this function:

◆ operator>()

bool openvpn::IP::Addr::operator> ( const Addr other) const
inline

Definition at line 755 of file ip.hpp.

◆ operator>=()

bool openvpn::IP::Addr::operator>= ( const Addr other) const
inline

Definition at line 765 of file ip.hpp.

◆ operator>>()

Addr openvpn::IP::Addr::operator>> ( const unsigned int  shift) const
inline

Definition at line 658 of file ip.hpp.

◆ operator|()

Addr openvpn::IP::Addr::operator| ( const Addr other) const
inline

Definition at line 801 of file ip.hpp.

◆ operator~()

Addr openvpn::IP::Addr::operator~ ( ) const
inline

Definition at line 681 of file ip.hpp.

◆ prefix_len()

unsigned int openvpn::IP::Addr::prefix_len ( ) const
inline

Definition at line 968 of file ip.hpp.

Here is the caller graph for this function:

◆ reset()

void openvpn::IP::Addr::reset ( )
inline

Definition at line 1075 of file ip.hpp.

◆ reset_ipv4_from_uint32()

void openvpn::IP::Addr::reset_ipv4_from_uint32 ( const IPv4::Addr::base_type  addr)
inline

Definition at line 1135 of file ip.hpp.

◆ scope_id()

int openvpn::IP::Addr::scope_id ( ) const
inline

Definition at line 982 of file ip.hpp.

◆ size()

unsigned int openvpn::IP::Addr::size ( ) const
inline

Definition at line 1016 of file ip.hpp.

Here is the caller graph for this function:

◆ size_bytes()

unsigned int openvpn::IP::Addr::size_bytes ( ) const
inline

Definition at line 1022 of file ip.hpp.

Here is the caller graph for this function:

◆ sockaddr_defined()

static bool openvpn::IP::Addr::sockaddr_defined ( const struct sockaddr *  sa)
inlinestatic

Definition at line 335 of file ip.hpp.

Here is the caller graph for this function:

◆ specified()

bool openvpn::IP::Addr::specified ( ) const
inline

Definition at line 811 of file ip.hpp.

Here is the caller graph for this function:

◆ to_asio()

openvpn_io::ip::address openvpn::IP::Addr::to_asio ( ) const
inline

Definition at line 594 of file ip.hpp.

Here is the caller graph for this function:

◆ to_byte_string()

void openvpn::IP::Addr::to_byte_string ( unsigned char *  bytestr) const
inline

Definition at line 412 of file ip.hpp.

◆ to_byte_string_variable()

void openvpn::IP::Addr::to_byte_string_variable ( unsigned char *  bytestr) const
inline

Definition at line 429 of file ip.hpp.

Here is the caller graph for this function:

◆ to_hex()

std::string openvpn::IP::Addr::to_hex ( ) const
inline

Definition at line 550 of file ip.hpp.

◆ to_ipv4()

const IPv4::Addr & openvpn::IP::Addr::to_ipv4 ( ) const
inline

Definition at line 276 of file ip.hpp.

Here is the caller graph for this function:

◆ to_ipv4_nocheck()

const IPv4::Addr & openvpn::IP::Addr::to_ipv4_nocheck ( ) const
inline

Definition at line 316 of file ip.hpp.

◆ to_ipv4_zero()

IPv4::Addr openvpn::IP::Addr::to_ipv4_zero ( ) const
inline

Definition at line 283 of file ip.hpp.

◆ to_ipv6()

const IPv6::Addr & openvpn::IP::Addr::to_ipv6 ( ) const
inline

Definition at line 296 of file ip.hpp.

Here is the caller graph for this function:

◆ to_ipv6_nocheck()

const IPv6::Addr & openvpn::IP::Addr::to_ipv6_nocheck ( ) const
inline

Definition at line 321 of file ip.hpp.

◆ to_ipv6_zero()

IPv6::Addr openvpn::IP::Addr::to_ipv6_zero ( ) const
inline

Definition at line 303 of file ip.hpp.

◆ to_long()

long openvpn::IP::Addr::to_long ( ) const
inline

Definition at line 381 of file ip.hpp.

◆ to_string()

std::string openvpn::IP::Addr::to_string ( ) const
inline

Definition at line 528 of file ip.hpp.

Here is the caller graph for this function:

◆ to_string_bracket_ipv6()

std::string openvpn::IP::Addr::to_string_bracket_ipv6 ( ) const
inline

Definition at line 539 of file ip.hpp.

Here is the caller graph for this function:

◆ to_uint32_net()

std::uint32_t openvpn::IP::Addr::to_uint32_net ( ) const
inline

Definition at line 444 of file ip.hpp.

◆ to_ulong()

unsigned long openvpn::IP::Addr::to_ulong ( ) const
inline

Definition at line 354 of file ip.hpp.

◆ to_v4_addr()

IP::Addr openvpn::IP::Addr::to_v4_addr ( ) const
inline

Definition at line 866 of file ip.hpp.

Here is the caller graph for this function:

◆ unspecified()

bool openvpn::IP::Addr::unspecified ( ) const
inline

Definition at line 806 of file ip.hpp.

Here is the caller graph for this function:

◆ validate() [1/3]

static std::string openvpn::IP::Addr::validate ( const std::string &  ipstr)
inlinestatic

Definition at line 145 of file ip.hpp.

◆ validate() [2/3]

template<typename TITLE >
static std::string openvpn::IP::Addr::validate ( const std::string &  ipstr,
const TITLE &  title 
)
inlinestatic

Definition at line 140 of file ip.hpp.

◆ validate() [3/3]

template<typename TITLE >
static std::string openvpn::IP::Addr::validate ( const std::string &  ipstr,
const TITLE &  title,
const Version  required_version 
)
inlinestatic

Definition at line 131 of file ip.hpp.

Here is the caller graph for this function:

◆ validate_netmask()

void openvpn::IP::Addr::validate_netmask ( ) const
inline

Definition at line 961 of file ip.hpp.

◆ validate_prefix_len()

static bool openvpn::IP::Addr::validate_prefix_len ( Version  v,
const unsigned int  prefix_len 
)
inlinestatic

Definition at line 492 of file ip.hpp.

◆ validate_version()

template<typename TITLE >
void openvpn::IP::Addr::validate_version ( const TITLE &  title,
const Version  required_version 
) const
inline

Definition at line 151 of file ip.hpp.

Here is the caller graph for this function:

◆ verify_version_consistency()

void openvpn::IP::Addr::verify_version_consistency ( const Addr other) const
inline

Definition at line 954 of file ip.hpp.

◆ version()

Version openvpn::IP::Addr::version ( ) const
inline

Definition at line 895 of file ip.hpp.

Here is the caller graph for this function:

◆ version_index()

int openvpn::IP::Addr::version_index ( ) const
inline

Definition at line 918 of file ip.hpp.

◆ version_mask() [1/2]

VersionMask openvpn::IP::Addr::version_mask ( ) const
inline

Definition at line 913 of file ip.hpp.

Here is the caller graph for this function:

◆ version_mask() [2/2]

static VersionMask openvpn::IP::Addr::version_mask ( const Version  ver)
inlinestatic

Definition at line 900 of file ip.hpp.

Here is the caller graph for this function:

◆ version_size()

static unsigned int openvpn::IP::Addr::version_size ( Version  v)
inlinestatic

Definition at line 1028 of file ip.hpp.

Here is the caller graph for this function:

◆ version_string()

const char * openvpn::IP::Addr::version_string ( ) const
inline

Definition at line 877 of file ip.hpp.

Here is the caller graph for this function:

◆ version_string_static()

static const char * openvpn::IP::Addr::version_string_static ( Version  ver)
inlinestatic

Definition at line 882 of file ip.hpp.

Here is the caller graph for this function:

Member Data Documentation

◆ [union]

union { ... } openvpn::IP::Addr::u

◆ v4

IPv4::Addr openvpn::IP::Addr::v4

Definition at line 1143 of file ip.hpp.

◆ v6

IPv6::Addr openvpn::IP::Addr::v6

Definition at line 1144 of file ip.hpp.

◆ ver

Version openvpn::IP::Addr::ver
private

Definition at line 1147 of file ip.hpp.


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