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

#include <ipv4.hpp>

Public Types

enum  { SIZE = 32 }
 
typedef std::uint32_t base_type
 
typedef std::int32_t signed_base_type
 

Public Member Functions

in_addr to_in_addr () const
 
sockaddr_in to_sockaddr (const unsigned short port=0) const
 
std::uint32_t to_uint32 () const
 
void to_byte_string (unsigned char *bytestr) const
 
std::uint32_t to_uint32_net () const
 
unsigned long to_ulong () const
 
long to_long () const
 
Addr netmask_from_this_as_extent () const
 
std::string to_string () const
 
std::string to_hex () const
 
std::string arpa () const
 
openvpn_io::ip::address_v4 to_asio () const
 
Addr operator& (const Addr &other) const
 
Addr operator| (const Addr &other) const
 
Addr operator+ (const long delta) const
 
Addr operator+ (const Addr &other) const
 
Addr operator- (const long delta) 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 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
 
bool unspecified () const
 
bool specified () const
 
bool all_zeros () const
 
bool all_ones () const
 
bool is_loopback () const
 
unsigned int prefix_len () const
 
int prefix_len_nothrow () const
 
unsigned int host_len () const
 
Addr extent_from_netmask () const
 
std::uint32_t extent_from_netmask_uint32 () const
 
template<typename HASH >
void hash (HASH &h) const
 
void negate ()
 
void zero ()
 
void zero_complement ()
 
void one ()
 
Addroperator++ ()
 
Addroperator+= (const long delta)
 
Addroperator-= (const long delta)
 

Static Public Member Functions

static constexpr int ip_version ()
 
static constexpr bool defined ()
 
static Addr from_addr (const Addr &addr)
 
static Addr from_in_addr (const in_addr *in4)
 
static Addr from_sockaddr (const sockaddr_in *sa)
 
static Addr from_uint32 (const base_type addr)
 
static Addr from_uint32_net (const base_type addr)
 
static Addr from_ulong (unsigned long ul)
 
static Addr from_long (long ul)
 
static Addr from_bytes (const unsigned char *bytes)
 
static Addr from_bytes_net (const unsigned char *bytes)
 
static Addr from_zero ()
 
static Addr from_one ()
 
static Addr from_zero_complement ()
 
static Addr netmask_from_prefix_len (const unsigned int prefix_len)
 
template<typename TITLE >
static Addr from_string (const std::string &ipstr, const TITLE &title)
 
static Addr from_string (const std::string &ipstr)
 
static Addr from_hex (const std::string &s)
 
static Addr from_asio (const openvpn_io::ip::address_v4 &asio_addr)
 
static int prefix_len_32 (const std::uint32_t addr)
 
static constexpr unsigned int size ()
 

Static Private Member Functions

static base_type prefix_len_to_netmask_unchecked (const unsigned int prefix_len) noexcept
 
static base_type prefix_len_to_netmask (const unsigned int prefix_len)
 

Private Attributes

union { 
 
   base_type   addr 
 
   unsigned char   bytes [4] 
 
u 
 

Friends

class IP::Addr
 

Detailed Description

Definition at line 38 of file ipv4.hpp.

Member Typedef Documentation

◆ base_type

typedef std::uint32_t openvpn::IPv4::Addr::base_type

Definition at line 48 of file ipv4.hpp.

◆ signed_base_type

Definition at line 49 of file ipv4.hpp.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
SIZE 

Definition at line 43 of file ipv4.hpp.

Member Function Documentation

◆ all_ones()

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

Definition at line 444 of file ipv4.hpp.

◆ all_zeros()

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

Definition at line 439 of file ipv4.hpp.

Here is the caller graph for this function:

◆ arpa()

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

Definition at line 287 of file ipv4.hpp.

◆ defined()

static constexpr bool openvpn::IPv4::Addr::defined ( )
inlinestaticconstexpr

Definition at line 56 of file ipv4.hpp.

◆ extent_from_netmask()

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

Definition at line 476 of file ipv4.hpp.

Here is the caller graph for this function:

◆ extent_from_netmask_uint32()

std::uint32_t openvpn::IPv4::Addr::extent_from_netmask_uint32 ( ) const
inline

Definition at line 483 of file ipv4.hpp.

Here is the caller graph for this function:

◆ from_addr()

static Addr openvpn::IPv4::Addr::from_addr ( const Addr addr)
inlinestatic

Definition at line 61 of file ipv4.hpp.

◆ from_asio()

static Addr openvpn::IPv4::Addr::from_asio ( const openvpn_io::ip::address_v4 &  asio_addr)
inlinestatic

Definition at line 297 of file ipv4.hpp.

Here is the caller graph for this function:

◆ from_bytes()

static Addr openvpn::IPv4::Addr::from_bytes ( const unsigned char *  bytes)
inlinestatic

Definition at line 153 of file ipv4.hpp.

Here is the caller graph for this function:

◆ from_bytes_net()

static Addr openvpn::IPv4::Addr::from_bytes_net ( const unsigned char *  bytes)
inlinestatic

Definition at line 160 of file ipv4.hpp.

Here is the caller graph for this function:

◆ from_hex()

static Addr openvpn::IPv4::Addr::from_hex ( const std::string &  s)
inlinestatic

Definition at line 239 of file ipv4.hpp.

Here is the caller graph for this function:

◆ from_in_addr()

static Addr openvpn::IPv4::Addr::from_in_addr ( const in_addr *  in4)
inlinestatic

Definition at line 66 of file ipv4.hpp.

Here is the caller graph for this function:

◆ from_long()

static Addr openvpn::IPv4::Addr::from_long ( long  ul)
inlinestatic

Definition at line 141 of file ipv4.hpp.

Here is the caller graph for this function:

◆ from_one()

static Addr openvpn::IPv4::Addr::from_one ( )
inlinestatic

Definition at line 175 of file ipv4.hpp.

Here is the caller graph for this function:

◆ from_sockaddr()

static Addr openvpn::IPv4::Addr::from_sockaddr ( const sockaddr_in *  sa)
inlinestatic

Definition at line 80 of file ipv4.hpp.

Here is the caller graph for this function:

◆ from_string() [1/2]

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

Definition at line 214 of file ipv4.hpp.

◆ from_string() [2/2]

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

Definition at line 205 of file ipv4.hpp.

Here is the caller graph for this function:

◆ from_uint32()

static Addr openvpn::IPv4::Addr::from_uint32 ( const base_type  addr)
inlinestatic

Definition at line 100 of file ipv4.hpp.

Here is the caller graph for this function:

◆ from_uint32_net()

static Addr openvpn::IPv4::Addr::from_uint32_net ( const base_type  addr)
inlinestatic

Definition at line 112 of file ipv4.hpp.

Here is the caller graph for this function:

◆ from_ulong()

static Addr openvpn::IPv4::Addr::from_ulong ( unsigned long  ul)
inlinestatic

Definition at line 129 of file ipv4.hpp.

Here is the caller graph for this function:

◆ from_zero()

static Addr openvpn::IPv4::Addr::from_zero ( )
inlinestatic

Definition at line 168 of file ipv4.hpp.

Here is the caller graph for this function:

◆ from_zero_complement()

static Addr openvpn::IPv4::Addr::from_zero_complement ( )
inlinestatic

Definition at line 182 of file ipv4.hpp.

Here is the caller graph for this function:

◆ hash()

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

Definition at line 523 of file ipv4.hpp.

◆ host_len()

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

Definition at line 470 of file ipv4.hpp.

Here is the caller graph for this function:

◆ ip_version()

static constexpr int openvpn::IPv4::Addr::ip_version ( )
inlinestaticconstexpr

Definition at line 51 of file ipv4.hpp.

◆ is_loopback()

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

Definition at line 449 of file ipv4.hpp.

◆ negate()

void openvpn::IPv4::Addr::negate ( )
inline

Definition at line 541 of file ipv4.hpp.

◆ netmask_from_prefix_len()

static Addr openvpn::IPv4::Addr::netmask_from_prefix_len ( const unsigned int  prefix_len)
inlinestatic

Definition at line 189 of file ipv4.hpp.

Here is the caller graph for this function:

◆ netmask_from_this_as_extent()

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

Definition at line 196 of file ipv4.hpp.

◆ network_addr()

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

Definition at line 392 of file ipv4.hpp.

◆ one()

void openvpn::IPv4::Addr::one ( )
inline

Definition at line 556 of file ipv4.hpp.

Here is the caller graph for this function:

◆ operator!=()

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

Definition at line 404 of file ipv4.hpp.

◆ operator%()

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

Definition at line 363 of file ipv4.hpp.

◆ operator&()

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

Definition at line 309 of file ipv4.hpp.

◆ operator*()

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

Definition at line 349 of file ipv4.hpp.

◆ operator+() [1/2]

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

Definition at line 330 of file ipv4.hpp.

◆ operator+() [2/2]

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

Definition at line 323 of file ipv4.hpp.

Here is the caller graph for this function:

◆ operator++()

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

Definition at line 561 of file ipv4.hpp.

◆ operator+=()

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

Definition at line 567 of file ipv4.hpp.

Here is the caller graph for this function:

◆ operator-() [1/2]

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

Definition at line 342 of file ipv4.hpp.

◆ operator-() [2/2]

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

Definition at line 337 of file ipv4.hpp.

◆ operator-=()

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

Definition at line 573 of file ipv4.hpp.

◆ operator/()

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

Definition at line 356 of file ipv4.hpp.

◆ operator<()

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

Definition at line 409 of file ipv4.hpp.

◆ operator<<()

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

Definition at line 370 of file ipv4.hpp.

◆ operator<=()

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

Definition at line 419 of file ipv4.hpp.

◆ operator==()

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

Definition at line 399 of file ipv4.hpp.

◆ operator>()

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

Definition at line 414 of file ipv4.hpp.

◆ operator>=()

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

Definition at line 424 of file ipv4.hpp.

◆ operator>>()

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

Definition at line 377 of file ipv4.hpp.

◆ operator|()

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

Definition at line 316 of file ipv4.hpp.

◆ operator~()

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

Definition at line 384 of file ipv4.hpp.

◆ prefix_len()

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

Definition at line 456 of file ipv4.hpp.

Here is the caller graph for this function:

◆ prefix_len_32()

static int openvpn::IPv4::Addr::prefix_len_32 ( const std::uint32_t  addr)
inlinestatic

Definition at line 494 of file ipv4.hpp.

Here is the caller graph for this function:

◆ prefix_len_nothrow()

int openvpn::IPv4::Addr::prefix_len_nothrow ( ) const
inline

Definition at line 464 of file ipv4.hpp.

Here is the caller graph for this function:

◆ prefix_len_to_netmask()

static base_type openvpn::IPv4::Addr::prefix_len_to_netmask ( const unsigned int  prefix_len)
inlinestaticprivate

Definition at line 586 of file ipv4.hpp.

Here is the caller graph for this function:

◆ prefix_len_to_netmask_unchecked()

static base_type openvpn::IPv4::Addr::prefix_len_to_netmask_unchecked ( const unsigned int  prefix_len)
inlinestaticprivatenoexcept

Definition at line 579 of file ipv4.hpp.

Here is the caller graph for this function:

◆ size()

static constexpr unsigned int openvpn::IPv4::Addr::size ( )
inlinestaticconstexpr

Definition at line 517 of file ipv4.hpp.

◆ specified()

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

Definition at line 434 of file ipv4.hpp.

Here is the caller graph for this function:

◆ to_asio()

openvpn_io::ip::address_v4 openvpn::IPv4::Addr::to_asio ( ) const
inline

Definition at line 304 of file ipv4.hpp.

Here is the caller graph for this function:

◆ to_byte_string()

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

Definition at line 119 of file ipv4.hpp.

◆ to_hex()

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

Definition at line 267 of file ipv4.hpp.

◆ to_in_addr()

in_addr openvpn::IPv4::Addr::to_in_addr ( ) const
inline

Definition at line 73 of file ipv4.hpp.

◆ to_long()

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

Definition at line 148 of file ipv4.hpp.

◆ to_sockaddr()

sockaddr_in openvpn::IPv4::Addr::to_sockaddr ( const unsigned short  port = 0) const
inline

Definition at line 87 of file ipv4.hpp.

Here is the caller graph for this function:

◆ to_string()

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

Definition at line 232 of file ipv4.hpp.

Here is the caller graph for this function:

◆ to_uint32()

std::uint32_t openvpn::IPv4::Addr::to_uint32 ( ) const
inline

Definition at line 107 of file ipv4.hpp.

Here is the caller graph for this function:

◆ to_uint32_net()

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

Definition at line 124 of file ipv4.hpp.

Here is the caller graph for this function:

◆ to_ulong()

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

Definition at line 136 of file ipv4.hpp.

◆ unspecified()

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

Definition at line 429 of file ipv4.hpp.

Here is the caller graph for this function:

◆ zero()

void openvpn::IPv4::Addr::zero ( )
inline

Definition at line 546 of file ipv4.hpp.

Here is the caller graph for this function:

◆ zero_complement()

void openvpn::IPv4::Addr::zero_complement ( )
inline

Definition at line 551 of file ipv4.hpp.

Here is the caller graph for this function:

Friends And Related Symbol Documentation

◆ IP::Addr

friend class IP::Addr
friend

Definition at line 40 of file ipv4.hpp.

Member Data Documentation

◆ addr

base_type openvpn::IPv4::Addr::addr

Definition at line 594 of file ipv4.hpp.

◆ bytes

unsigned char openvpn::IPv4::Addr::bytes[4]

Definition at line 595 of file ipv4.hpp.

◆ [union]

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

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