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

#include <IPRange.h>

Collaboration diagram for swoc::IPNet:
Collaboration graph

Public Member Functions

 IPNet ()=default
 Construct invalid network.
 
 IPNet (self_type const &that)=default
 Copy constructor.
 
 IPNet (IPAddr const &addr, IPMask const &mask)
 
 IPNet (TextView text)
 
bool load (swoc::TextView text)
 
bool empty () const
 
IPAddr min () const
 
IPAddr max () const
 
IPMask::raw_type width () const
 
IPMask const & mask () const
 
IPRange as_range () const
 
bool is_ip4 () const
 
bool is_ip6 () const
 
sa_family_t family () const
 Address family of network.
 
IP4Net ip4 () const
 
IP6Net ip6 () const
 
self_typeassign (IPAddr const &addr, IPMask const &mask)
 
self_typeclear ()
 Reset network to invalid state.
 
bool operator== (self_type const &that) const
 Equality.
 
bool operator!= (self_type const &that) const
 Inequality.
 

Protected Attributes

IPAddr _addr
 Address and family.
 
IPMask _mask
 Network mask.
 

Detailed Description

Representation of an IP address network.

Definition at line 863 of file IPRange.h.

Constructor & Destructor Documentation

◆ IPNet() [1/2]

swoc::IPNet::IPNet ( IPAddr const & addr,
IPMask const & mask )
inline

Construct from addr and mask.

Parameters
addrAn address in the network.
maskThe mask for the network.

The network is based on the mask, and the resulting network address is chosen such that the network will contain addr. For a given addr and mask there is only one network that satisifies these criteria.

Definition at line 2208 of file IPRange.h.

◆ IPNet() [2/2]

swoc::IPNet::IPNet ( TextView text)
inline

Construct from text.

Parameters
textNetwork description.

The format must be "addr/mask" where "addr" is a valid address and mask is either a single number for the mask width (CIDR) or a mask in address notation.

Definition at line 2210 of file IPRange.h.

Member Function Documentation

◆ as_range()

IPRange swoc::IPNet::as_range ( ) const
inline
Returns
A range that exactly covers the network.

Definition at line 2240 of file IPRange.h.

◆ assign()

IPNet::self_type & swoc::IPNet::assign ( IPAddr const & addr,
IPMask const & mask )
inline

Assign an addr and mask to this.

Parameters
addrNetwork addres.
maskNetwork mask.
Returns
this.

Definition at line 2245 of file IPRange.h.

◆ clear()

auto swoc::IPNet::clear ( )
inline

Reset network to invalid state.

Definition at line 2292 of file IPRange.h.

◆ empty()

bool swoc::IPNet::empty ( ) const
inline
Returns
true if the network contains no addresses (is invalid).

Definition at line 2215 of file IPRange.h.

◆ family()

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

Address family of network.

Definition at line 928 of file IPRange.h.

◆ ip4()

IP4Net swoc::IPNet::ip4 ( ) const
inline
Returns
The network as explicitly IPv4.

Definition at line 2282 of file IPRange.h.

◆ ip6()

IP6Net swoc::IPNet::ip6 ( ) const
inline
Returns
The network as explicitly IPv6.

Definition at line 2287 of file IPRange.h.

◆ is_ip4()

bool swoc::IPNet::is_ip4 ( ) const
inline
Returns
true if network is IPv4.

Definition at line 916 of file IPRange.h.

◆ is_ip6()

bool swoc::IPNet::is_ip6 ( ) const
inline
Returns
true if network is IPv6.

Definition at line 922 of file IPRange.h.

◆ load()

bool swoc::IPNet::load ( swoc::TextView text)

Parse network as text.

Parameters
textString describing the network in CIDR format.
Returns
true if a valid string, false if not.

Definition at line 897 of file swoc_ip.cc.

◆ mask()

IPMask const & swoc::IPNet::mask ( ) const
inline
Returns
The mask for the network.

Definition at line 2235 of file IPRange.h.

◆ max()

IPAddr swoc::IPNet::max ( ) const
inline
Returns
Largest address in the network.

Definition at line 2225 of file IPRange.h.

◆ min()

IPAddr swoc::IPNet::min ( ) const
inline
Returns
Network address - smallest address in the network.

Definition at line 2220 of file IPRange.h.

◆ operator!=()

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

Inequality.

Definition at line 2257 of file IPRange.h.

◆ operator==()

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

Equality.

Definition at line 2252 of file IPRange.h.

◆ width()

IPMask::raw_type swoc::IPNet::width ( ) const
inline
Returns
The number of bits in the mask.

Definition at line 2230 of file IPRange.h.

Member Data Documentation

◆ _addr

IPAddr swoc::IPNet::_addr
protected

Address and family.

Definition at line 956 of file IPRange.h.

◆ _mask

IPMask swoc::IPNet::_mask
protected

Network mask.

Definition at line 957 of file IPRange.h.


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