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

#include <ipv4.hpp>

Public Types

using base_type = std::uint32_t
 
using signed_base_type = std::int32_t
 

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 Public Attributes

static constexpr unsigned int SIZE = 32
 

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

using openvpn::IPv4::Addr::base_type = std::uint32_t

Definition at line 45 of file ipv4.hpp.

◆ signed_base_type

Definition at line 46 of file ipv4.hpp.

Member Function Documentation

◆ all_ones()

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

Definition at line 441 of file ipv4.hpp.

◆ all_zeros()

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

Definition at line 436 of file ipv4.hpp.

Here is the caller graph for this function:

◆ arpa()

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

Definition at line 284 of file ipv4.hpp.

◆ defined()

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

Definition at line 53 of file ipv4.hpp.

◆ extent_from_netmask()

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

Definition at line 473 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 480 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 58 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 294 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 150 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 157 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 236 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 63 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 138 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 172 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 77 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 211 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 202 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 97 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 109 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 126 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 165 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 179 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 520 of file ipv4.hpp.

◆ host_len()

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

Definition at line 467 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 48 of file ipv4.hpp.

◆ is_loopback()

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

Definition at line 446 of file ipv4.hpp.

◆ negate()

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

Definition at line 538 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 186 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 193 of file ipv4.hpp.

◆ network_addr()

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

Definition at line 389 of file ipv4.hpp.

◆ one()

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

Definition at line 553 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 401 of file ipv4.hpp.

◆ operator%()

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

Definition at line 360 of file ipv4.hpp.

◆ operator&()

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

Definition at line 306 of file ipv4.hpp.

◆ operator*()

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

Definition at line 346 of file ipv4.hpp.

◆ operator+() [1/2]

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

Definition at line 327 of file ipv4.hpp.

◆ operator+() [2/2]

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

Definition at line 320 of file ipv4.hpp.

Here is the caller graph for this function:

◆ operator++()

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

Definition at line 558 of file ipv4.hpp.

◆ operator+=()

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

Definition at line 564 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 339 of file ipv4.hpp.

◆ operator-() [2/2]

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

Definition at line 334 of file ipv4.hpp.

◆ operator-=()

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

Definition at line 570 of file ipv4.hpp.

◆ operator/()

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

Definition at line 353 of file ipv4.hpp.

◆ operator<()

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

Definition at line 406 of file ipv4.hpp.

◆ operator<<()

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

Definition at line 367 of file ipv4.hpp.

◆ operator<=()

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

Definition at line 416 of file ipv4.hpp.

◆ operator==()

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

Definition at line 396 of file ipv4.hpp.

◆ operator>()

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

Definition at line 411 of file ipv4.hpp.

◆ operator>=()

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

Definition at line 421 of file ipv4.hpp.

◆ operator>>()

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

Definition at line 374 of file ipv4.hpp.

◆ operator|()

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

Definition at line 313 of file ipv4.hpp.

◆ operator~()

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

Definition at line 381 of file ipv4.hpp.

◆ prefix_len()

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

Definition at line 453 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 491 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 461 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 583 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 576 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 514 of file ipv4.hpp.

◆ specified()

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

Definition at line 431 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 301 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 116 of file ipv4.hpp.

◆ to_hex()

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

Definition at line 264 of file ipv4.hpp.

◆ to_in_addr()

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

Definition at line 70 of file ipv4.hpp.

◆ to_long()

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

Definition at line 145 of file ipv4.hpp.

◆ to_sockaddr()

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

Definition at line 84 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 229 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 104 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 121 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 133 of file ipv4.hpp.

◆ unspecified()

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

Definition at line 426 of file ipv4.hpp.

Here is the caller graph for this function:

◆ zero()

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

Definition at line 543 of file ipv4.hpp.

Here is the caller graph for this function:

◆ zero_complement()

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

Definition at line 548 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 591 of file ipv4.hpp.

◆ bytes

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

Definition at line 592 of file ipv4.hpp.

◆ SIZE

constexpr unsigned int openvpn::IPv4::Addr::SIZE = 32
staticconstexpr

Definition at line 43 of file ipv4.hpp.

◆ [union]

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

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