LibSWOC++ 1.5.14
Solid Wall of C++
Loading...
Searching...
No Matches
swoc::IPAddr Class Reference

#include <IPAddr.h>

Collaboration diagram for swoc::IPAddr:
Collaboration graph

Classes

union  raw_addr_type
 Address data. More...
 

Public Member Functions

 IPAddr ()=default
 Default constructor - invalid result.
 
 IPAddr (self_type const &that)=default
 Copy constructor.
 
self_typeoperator= (self_type const &that)=default
 Copy assignment.
 
 IPAddr (in_addr_t addr)
 Construct using IPv4 addr.
 
 IPAddr (IP4Addr const &addr)
 Construct using an IPv4 addr.
 
 IPAddr (in6_addr const &addr)
 Construct using IPv6 addr.
 
 IPAddr (IP6Addr const &addr)
 construct using an IPv6 addr
 
 IPAddr (sockaddr const *addr)
 Construct from sockaddr.
 
 IPAddr (IPEndpoint const &addr)
 Construct from IPEndpoint.
 
 IPAddr (string_view const &text)
 
self_typeassign (sockaddr const *addr)
 Set to the address in addr.
 
self_typeassign (sockaddr_in const *addr)
 Set to the address in addr.
 
self_typeassign (sockaddr_in6 const *addr)
 Set to the address in addr.
 
self_typeassign (in_addr_t addr)
 Set to IPv4 addr.
 
self_typeassign (in6_addr const &addr)
 Set to IPv6 addr.
 
self_typeoperator= (IPEndpoint const &ip)
 Assign from end point.
 
self_typeoperator= (in_addr_t ip)
 Assign from IPv4 raw address.
 
self_typeoperator= (in6_addr const &addr)
 Assign from IPv6 raw address.
 
bool operator== (self_type const &that) const
 
bool operator!= (self_type const &that) const
 
bool operator< (self_type const &that) const
 
bool operator> (self_type const &that) const
 
bool operator<= (self_type const &that) const
 
bool operator>= (self_type const &that) const
 
self_typeoperator= (sockaddr const *addr)
 Assign from sockaddr.
 
self_typeoperator&= (IPMask const &mask)
 
self_typeoperator|= (IPMask const &mask)
 
sockaddr * copy_to (sockaddr *sa) const
 
bool load (string_view const &text)
 
int cmp (self_type const &that) const
 Generic compare.
 
bool is_same_family (self_type const &that)
 
sa_family_t family () const
 
bool is_ip4 () const
 Test for IPv4.
 
bool is_ip6 () const
 Test for IPv6.
 
IP4Addr const & ip4 () const
 
 operator IP4Addr () const
 
IP6Addr const & ip6 () const
 
 operator IP6Addr () const
 
bool is_valid () const
 Test for validity.
 
self_typeinvalidate ()
 Make invalid.
 
bool is_loopback () const
 Test for loopback.
 
bool is_multicast () const
 Test for multicast.
 
bool is_link_local () const
 
bool is_private () const
 Pre-constructed invalid instance.
 

Static Public Attributes

static self_type const INVALID
 

Protected Attributes

friend IP4Addr
 
friend IP6Addr
 
union swoc::IPAddr::raw_addr_type _addr
 
sa_family_t _family {AF_UNSPEC}
 Protocol family.
 

Friends

class IPRange
 

Detailed Description

An IPv4 or IPv6 address.

The family type is stored. For comparisons, invalid < IPv4 < IPv6. All invalid instances are equal.

Definition at line 501 of file IPAddr.h.

Constructor & Destructor Documentation

◆ IPAddr() [1/7]

swoc::IPAddr::IPAddr ( in_addr_t addr)
inlineexplicit

Construct using IPv4 addr.

Definition at line 1232 of file IPAddr.h.

◆ IPAddr() [2/7]

swoc::IPAddr::IPAddr ( IP4Addr const & addr)
inline

Construct using an IPv4 addr.

Definition at line 514 of file IPAddr.h.

◆ IPAddr() [3/7]

swoc::IPAddr::IPAddr ( in6_addr const & addr)
inlineexplicit

Construct using IPv6 addr.

Definition at line 1234 of file IPAddr.h.

◆ IPAddr() [4/7]

swoc::IPAddr::IPAddr ( IP6Addr const & addr)
inline

construct using an IPv6 addr

Definition at line 520 of file IPAddr.h.

◆ IPAddr() [5/7]

swoc::IPAddr::IPAddr ( sockaddr const * addr)
inlineexplicit

Construct from sockaddr.

Definition at line 1236 of file IPAddr.h.

◆ IPAddr() [6/7]

swoc::IPAddr::IPAddr ( IPEndpoint const & addr)
explicit

Construct from IPEndpoint.

Definition at line 513 of file swoc_ip.cc.

◆ IPAddr() [7/7]

swoc::IPAddr::IPAddr ( string_view const & text)
inlineexplicit

Construct from text representation. If the text is invalid the result is an invalid instance.

Definition at line 1240 of file IPAddr.h.

Member Function Documentation

◆ assign() [1/5]

IPAddr & swoc::IPAddr::assign ( in6_addr const & addr)
inline

Set to IPv6 addr.

Definition at line 1306 of file IPAddr.h.

◆ assign() [2/5]

IPAddr & swoc::IPAddr::assign ( in_addr_t addr)
inline

Set to IPv4 addr.

Definition at line 1299 of file IPAddr.h.

◆ assign() [3/5]

IPAddr & swoc::IPAddr::assign ( sockaddr const * addr)

Set to the address in addr.

Definition at line 562 of file swoc_ip.cc.

◆ assign() [4/5]

IPAddr & swoc::IPAddr::assign ( sockaddr_in const * addr)
inline

Set to the address in addr.

Definition at line 1313 of file IPAddr.h.

◆ assign() [5/5]

IPAddr & swoc::IPAddr::assign ( sockaddr_in6 const * addr)
inline

Set to the address in addr.

Definition at line 1324 of file IPAddr.h.

◆ cmp()

int swoc::IPAddr::cmp ( self_type const & that) const

Generic compare.

Definition at line 602 of file swoc_ip.cc.

◆ copy_to()

sockaddr * swoc::IPAddr::copy_to ( sockaddr * sa) const

Copy the address to a socket address.

Parameters
saDestination.
Returns
sa

Definition at line 523 of file swoc_ip.cc.

◆ family()

sa_family_t swoc::IPAddr::family ( ) const
inline

Get the address family.

Returns
The address family.

Definition at line 1264 of file IPAddr.h.

◆ invalidate()

IPAddr & swoc::IPAddr::invalidate ( )
inline

Make invalid.

Definition at line 1340 of file IPAddr.h.

◆ ip4()

IP4Addr const & swoc::IPAddr::ip4 ( ) const
inline
Returns
As IPv4 address - results are undefined if it is not actually IPv4.

Definition at line 1369 of file IPAddr.h.

◆ ip6()

IP6Addr const & swoc::IPAddr::ip6 ( ) const
inline
Returns
As IPv6 address - results are undefined if it is not actually IPv6.

Definition at line 1377 of file IPAddr.h.

◆ is_ip4()

bool swoc::IPAddr::is_ip4 ( ) const
inline

Test for IPv4.

Definition at line 1269 of file IPAddr.h.

◆ is_ip6()

bool swoc::IPAddr::is_ip6 ( ) const
inline

Test for IPv6.

Definition at line 1274 of file IPAddr.h.

◆ is_link_local()

bool swoc::IPAddr::is_link_local ( ) const
inline
Returns
true if this is a link local address, false if not.

Definition at line 1289 of file IPAddr.h.

◆ is_loopback()

bool swoc::IPAddr::is_loopback ( ) const
inline

Test for loopback.

Definition at line 1284 of file IPAddr.h.

◆ is_multicast()

bool swoc::IPAddr::is_multicast ( ) const

Test for multicast.

Definition at line 646 of file swoc_ip.cc.

◆ is_private()

bool swoc::IPAddr::is_private ( ) const
inline

Pre-constructed invalid instance.

Returns
true if this is a private address, false if not.

Definition at line 1294 of file IPAddr.h.

◆ is_same_family()

bool swoc::IPAddr::is_same_family ( self_type const & that)
inline

Test for same address family. return true if that is the same address family as this.

Definition at line 1279 of file IPAddr.h.

◆ is_valid()

bool swoc::IPAddr::is_valid ( ) const
inline

Test for validity.

Definition at line 1335 of file IPAddr.h.

◆ load()

bool swoc::IPAddr::load ( string_view const & text)

Parse a string and load the result in this.

Parameters
textText to parse.
Returns
true on success, false otherwise.

Definition at line 533 of file swoc_ip.cc.

◆ operator IP4Addr()

swoc::IPAddr::operator IP4Addr ( ) const
inlineexplicit
Returns
As IPv4 address - results are undefined if it is not actually IPv4.

Definition at line 1372 of file IPAddr.h.

◆ operator IP6Addr()

swoc::IPAddr::operator IP6Addr ( ) const
inlineexplicit
Returns
As IPv6 address - results are undefined if it is not actually IPv6.

Definition at line 1380 of file IPAddr.h.

◆ operator!=()

bool swoc::IPAddr::operator!= ( self_type const & that) const
inline

Definition at line 1395 of file IPAddr.h.

◆ operator&=()

IPAddr::self_type & swoc::IPAddr::operator&= ( IPMask const & mask)

Definition at line 626 of file swoc_ip.cc.

◆ operator<()

bool swoc::IPAddr::operator< ( self_type const & that) const

Definition at line 577 of file swoc_ip.cc.

◆ operator<=()

bool swoc::IPAddr::operator<= ( self_type const & that) const
inline

Definition at line 1404 of file IPAddr.h.

◆ operator=() [1/4]

IPAddr & swoc::IPAddr::operator= ( in6_addr const & addr)
inline

Assign from IPv6 raw address.

Definition at line 1252 of file IPAddr.h.

◆ operator=() [2/4]

IPAddr & swoc::IPAddr::operator= ( in_addr_t ip)
inline

Assign from IPv4 raw address.

Definition at line 1245 of file IPAddr.h.

◆ operator=() [3/4]

IPAddr & swoc::IPAddr::operator= ( IPEndpoint const & ip)

Assign from end point.

Definition at line 518 of file swoc_ip.cc.

◆ operator=() [4/4]

IPAddr & swoc::IPAddr::operator= ( sockaddr const * addr)
inline

Assign from sockaddr.

Definition at line 1259 of file IPAddr.h.

◆ operator==()

bool swoc::IPAddr::operator== ( self_type const & that) const
inline

Definition at line 1385 of file IPAddr.h.

◆ operator>()

bool swoc::IPAddr::operator> ( self_type const & that) const
inline

Definition at line 1400 of file IPAddr.h.

◆ operator>=()

bool swoc::IPAddr::operator>= ( self_type const & that) const
inline

Definition at line 1410 of file IPAddr.h.

◆ operator|=()

IPAddr::self_type & swoc::IPAddr::operator|= ( IPMask const & mask)

Definition at line 636 of file swoc_ip.cc.

Friends And Related Symbol Documentation

◆ IPRange

friend class IPRange
friend

Definition at line 502 of file IPAddr.h.

Member Data Documentation

◆ _family

sa_family_t swoc::IPAddr::_family {AF_UNSPEC}
protected

Protocol family.

Definition at line 659 of file IPAddr.h.

◆ INVALID

IPAddr const swoc::IPAddr::INVALID
static

Definition at line 637 of file IPAddr.h.

◆ IP4Addr

friend swoc::IPAddr::IP4Addr
protected

Definition at line 640 of file IPAddr.h.

◆ IP6Addr

friend swoc::IPAddr::IP6Addr
protected

Definition at line 641 of file IPAddr.h.


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