xorp

IPvX Class Reference

Basic IPvX class (for both IPv4 and IPv6) More...

#include <ipvx.hh>

List of all members.

Public Member Functions

 IPvX ()
 Default contructor.
 IPvX (int family) throw (InvalidFamily)
 Constructor for a specified address family.
 IPvX (int family, const uint8_t *from_uint8) throw (InvalidFamily)
 Constructor from a (uint8_t *) memory pointer.
 IPvX (const IPv4 &ipv4)
 Constructor from an IPv4 address.
 IPvX (const IPv6 &ipv6)
 Constructor from an IPv6 address.
 IPvX (const in_addr &from_in_addr)
 Constructor from in_addr structure.
 IPvX (const in6_addr &from_in6_addr)
 Constructor from in6_addr structure.
 IPvX (const sockaddr &from_sockaddr) throw (InvalidFamily)
 Constructor from sockaddr structure.
 IPvX (const sockaddr_storage &from_sockaddr_storage) throw (InvalidFamily)
 Constructor from sockaddr_storage structure.
 IPvX (const sockaddr_in &from_sockaddr_in) throw (InvalidFamily)
 Constructor from sockaddr_in structure.
 IPvX (const sockaddr_in6 &from_sockaddr_in6) throw (InvalidFamily)
 Constructor from sockaddr_in6 structure.
 IPvX (const char *from_cstring) throw (InvalidString)
 Constructor from a string.
size_t copy_out (uint8_t *to_uint8) const
 Copy the IPvX raw address to specified memory location.
size_t copy_out (in_addr &to_in_addr) const throw (InvalidFamily)
 Copy the IPvX raw address to an in_addr structure.
size_t copy_out (in6_addr &to_in6_addr) const throw (InvalidFamily)
 Copy the IPvX raw address to an in6_addr structure.
size_t copy_out (sockaddr &to_sockaddr) const throw (InvalidFamily)
 Copy the IPvX raw address to a sockaddr structure.
size_t copy_out (sockaddr_storage &to_sockaddr_storage) const throw (InvalidFamily)
 Copy the IPvX raw address to a sockaddr_storage structure.
size_t copy_out (sockaddr_in &to_sockaddr_in) const throw (InvalidFamily)
 Copy the IPvX raw address to a sockaddr_in structure.
size_t copy_out (sockaddr_in6 &to_sockaddr_in6) const throw (InvalidFamily)
 Copy the IPvX raw address to a sockaddr_in6 structure.
size_t copy_in (int family, const uint8_t *from_uint8) throw (InvalidFamily)
 Copy a raw address of specified family type from specified memory location into IPvX structure.
size_t copy_in (const in_addr &from_in_addr)
 Copy a raw IPv4 address from a in_addr structure into IPvX structure.
size_t copy_in (const in6_addr &from_in6_addr)
 Copy a raw IPv6 address from a in6_addr structure into IPvX structure.
size_t copy_in (const sockaddr &from_sockaddr) throw (InvalidFamily)
 Copy a raw address from a sockaddr structure into IPvX structure.
size_t copy_in (const sockaddr_storage &from_sockaddr_storage) throw (InvalidFamily)
 Copy a raw address from a sockaddr_storage structure into IPvX structure.
size_t copy_in (const sockaddr_in &from_sockaddr_in) throw (InvalidFamily)
 Copy a raw address from a sockaddr_in structure into IPvX structure.
size_t copy_in (const sockaddr_in6 &from_sockaddr_in6) throw (InvalidFamily)
 Copy a raw address from sockaddr_in6 structure into IPvX structure.
IPvX operator~ () const
 Bitwise-Negation Operator.
IPvX operator| (const IPvX &other) const throw (InvalidCast)
 OR Operator.
IPvX operator& (const IPvX &other) const throw (InvalidCast)
 AND Operator.
IPvX operator^ (const IPvX &other) const throw (InvalidCast)
 XOR Operator.
IPvX operator<< (uint32_t left_shift) const
 Operator <<.
IPvX operator>> (uint32_t right_shift) const
 Operator >>
bool operator< (const IPvX &other) const
 Less-Than Operator.
bool operator== (const IPvX &other) const
 Equality Operator.
bool operator!= (const IPvX &other) const
 Not-Equal Operator.
IPvXoperator-- ()
 Decrement Operator.
IPvXoperator++ ()
 Increment Operator.
string str () const
 Convert this address from binary form to presentation format.
bool is_zero () const
 Test if this address is numerically zero.
bool is_unicast () const
 Test if this address is a valid unicast address.
bool is_multicast () const
 Test if this address is a valid multicast address.
bool is_class_a () const
 Test if this address belongs to the IPv4 Class A address space (0.0.0.0/1).
bool is_class_b () const
 Test if this address belongs to the IPv4 Class B address space (128.0.0.0/2).
bool is_class_c () const
 Test if this address belongs to the IPv4 Class C address space (192.0.0.0/3).
bool is_experimental () const
 Test if this address belongs to the IPv4 experimental Class E address space (240.0.0.0/4).
bool is_linklocal_unicast () const
 Test if this address is a valid link-local unicast address.
bool is_interfacelocal_multicast () const
 Test if this address is a valid interface-local multicast address.
bool is_nodelocal_multicast () const
 Test if this address is a valid node-local multicast address.
bool is_linklocal_multicast () const
 Test if this address is a valid link-local multicast address.
bool is_loopback () const
 Test if this address is a valid loopback address.
size_t addr_bytelen () const
 Get the address octet-size for this address.
uint32_t addr_bitlen () const
 Get the address bit-length for this address.
uint32_t ip_multicast_base_address_mask_len () const
 Get the mask length for the multicast base address for this address.
uint32_t ip_class_a_base_address_mask_len () const throw (InvalidFamily)
 Get the mask length for the Class A base address for this address.
uint32_t ip_class_b_base_address_mask_len () const throw (InvalidFamily)
 Get the mask length for the Class B base address for this address.
uint32_t ip_class_c_base_address_mask_len () const throw (InvalidFamily)
 Get the mask length for the Class C base address for this address.
uint32_t ip_experimental_base_address_mask_len () const throw (InvalidFamily)
 Get the mask length for the experimental base address for this address.
IPvX make_prefix (uint32_t mask_len) const throw (InvalidNetmaskLength)
 Make an IPvX mask prefix for the address family of this address.
IPvX mask_by_prefix_len (uint32_t prefix_len) const throw (InvalidNetmaskLength)
 Make an IPvX address prefix.
uint32_t mask_len () const
 Get the mask length.
bool is_ipv4 () const
 Test if this address is IPv4 address.
bool is_ipv6 () const
 Test if this address is IPv6 address.
IPv4 get_ipv4 () const throw (InvalidCast)
 Get IPv4 address.
IPv6 get_ipv6 () const throw (InvalidCast)
 Get IPv6 address.
void get (IPv4 &to_ipv4) const throw (InvalidCast)
 Assign address value to an IPv4 address.
void get (IPv6 &to_ipv6) const throw (InvalidCast)
 Assign address value to an IPv6 address.
int af () const
 Get the address family.
uint32_t ip_version () const throw (InvalidFamily)
 Get the IP protocol version.
const string & ip_version_str () const throw (InvalidFamily)
 Get the human-readable string with the IP protocol version.
uint32_t bits (uint32_t lsb, uint32_t len) const throw (InvalidFamily)
 Extract bits from an address.
uint32_t bit_count () const
 Count the number of bits that are set in this address.
uint32_t leading_zero_count () const
 Count the number of leading zeroes in this address.

Static Public Member Functions

static size_t addr_bytelen (int family) throw (InvalidFamily)
 Get the address octet-size.
static uint32_t addr_bitlen (int family) throw (InvalidFamily)
 Get the address bit-length.
static uint32_t ip_multicast_base_address_mask_len (int family) throw (InvalidFamily)
 Get the mask length for the multicast base address.
static uint32_t ip_class_a_base_address_mask_len (int family) throw (InvalidFamily)
 Get the mask length for the Class A base address.
static uint32_t ip_class_b_base_address_mask_len (int family) throw (InvalidFamily)
 Get the mask length for the Class B base address.
static uint32_t ip_class_c_base_address_mask_len (int family) throw (InvalidFamily)
 Get the mask length for the Class C base address.
static uint32_t ip_experimental_base_address_mask_len (int family) throw (InvalidFamily)
 Get the mask length for the experimental base address.
static IPvX make_prefix (int family, uint32_t mask_len) throw (InvalidFamily, InvalidNetmaskLength)
 Make an IPvX mask prefix.
static const IPvXZERO (int family) throw (InvalidFamily)
 Pre-defined IPvX address constants.
static const IPvXANY (int family) throw (InvalidFamily)
static const IPvXALL_ONES (int family) throw (InvalidFamily)
static const IPvXLOOPBACK (int family) throw (InvalidFamily)
static const IPvXMULTICAST_BASE (int family) throw (InvalidFamily)
static const IPvXMULTICAST_ALL_SYSTEMS (int family) throw (InvalidFamily)
static const IPvXMULTICAST_ALL_ROUTERS (int family) throw (InvalidFamily)
static const IPvXDVMRP_ROUTERS (int family) throw (InvalidFamily)
static const IPvXOSPFIGP_ROUTERS (int family) throw (InvalidFamily)
static const IPvXOSPFIGP_DESIGNATED_ROUTERS (int family) throw (InvalidFamily)
static const IPvXRIP2_ROUTERS (int family) throw (InvalidFamily)
static const IPvXPIM_ROUTERS (int family) throw (InvalidFamily)
static const IPvXSSM_ROUTERS (int family) throw (InvalidFamily)
static const IPvXCLASS_A_BASE (int family) throw (InvalidFamily)
static const IPvXCLASS_B_BASE (int family) throw (InvalidFamily)
static const IPvXCLASS_C_BASE (int family) throw (InvalidFamily)
static const IPvXEXPERIMENTAL_BASE (int family) throw (InvalidFamily)

Private Attributes

uint32_t _addr [4]
int _af

Friends

class IPv4
class IPv6

Detailed Description

Basic IPvX class (for both IPv4 and IPv6)


Constructor & Destructor Documentation

IPvX::IPvX ( )

Default contructor.

Creates an IPvX address with address family of AF_INET, and address value of INADDR_ANY (i.e., containing IPv4(0)).

IPvX::IPvX ( int  family) throw (InvalidFamily) [explicit]

Constructor for a specified address family.

Creates an address of specified family, and address value of INADDR_ANY or IN6ADDR_ANY (for IPv4 and IPv6 respectively).

Parameters:
familythe address family.
IPvX::IPvX ( int  family,
const uint8_t *  from_uint8 
) throw (InvalidFamily)

Constructor from a (uint8_t *) memory pointer.

Creates an address of specified family, and address value by using data from specified location.

Parameters:
familythe address family.
from_uint8the pointer to the memory to copy the address value from.
IPvX::IPvX ( const IPv4 ipv4)

Constructor from an IPv4 address.

Create an IPvX address from an IPv4 address.

Parameters:
ipv4the IPv4 address to assign the address value from.
IPvX::IPvX ( const IPv6 ipv6)

Constructor from an IPv6 address.

Create an IPvX address from an IPv6 address.

Parameters:
ipv6the IPv6 address to assign the address value from.
IPvX::IPvX ( const in_addr &  from_in_addr)

Constructor from in_addr structure.

Note that this address must be of AF_INET family.

Parameters:
from_in_addrthe storage to copy the address value from.
IPvX::IPvX ( const in6_addr &  from_in6_addr)

Constructor from in6_addr structure.

Note that this address must be of AF_INET6 family.

Parameters:
from_in6_addrthe storage to copy the address value from.
IPvX::IPvX ( const sockaddr &  from_sockaddr) throw (InvalidFamily)

Constructor from sockaddr structure.

Parameters:
from_sockaddrthe storage to copy the address from.
IPvX::IPvX ( const sockaddr_storage &  from_sockaddr_storage) throw (InvalidFamily)

Constructor from sockaddr_storage structure.

Parameters:
from_sockaddr_storagethe storage to copy the address from.
IPvX::IPvX ( const sockaddr_in &  from_sockaddr_in) throw (InvalidFamily)

Constructor from sockaddr_in structure.

Parameters:
from_sockaddr_inthe storage to copy the address from.
Exceptions:
InvalidFamilythrown if from_sockaddr_in is not a AF_INET sockaddr.
IPvX::IPvX ( const sockaddr_in6 &  from_sockaddr_in6) throw (InvalidFamily)

Constructor from sockaddr_in6 structure.

Parameters:
from_sockaddr_in6the storage to copy the address from.
Exceptions:
InvalidFamilythrown if from_sockaddr_in6 is not a AF_INET6 sockaddr.
IPvX::IPvX ( const char *  from_cstring) throw (InvalidString)

Constructor from a string.

Parameters:
from_cstringC-style string in the IPv4 dotted decimal or IPv6 canonical human-readable format used for initialization.

Member Function Documentation

static uint32_t IPvX::addr_bitlen ( int  family) throw (InvalidFamily) [inline, static]

Get the address bit-length.

Note that this is a static function and is to be used without a particular object. Example: uint32_t my_bitlen = IPvX::addr_bitlen(my_family);

Parameters:
familythe address family.
Returns:
address size in number of bits for an address of address family of family.
uint32_t IPvX::addr_bitlen ( ) const [inline]

Get the address bit-length for this address.

Note that this is not a static function, hence it has to be used with a particular object. Example: uint32_t my_bitlen = ipvx.addr_bitlen();

Parameters:
familythe address family.
Returns:
address size in number of bits for this IPvX address.
size_t IPvX::addr_bytelen ( int  family) throw (InvalidFamily) [static]

Get the address octet-size.

Note that this is a static function and is to be used without a particular object. Example: size_t my_size = IPvX::addr_bytelen(my_family);

Parameters:
familythe address family.
Returns:
address size in number of octets for an address of address family of family.
size_t IPvX::addr_bytelen ( ) const [inline]

Get the address octet-size for this address.

Note that this is not a static function, hence it has to be used with a particular object. Example: size_t my_size = ipvx.addr_bytelen();

Parameters:
familythe address family.
Returns:
address size in number of octets for this IPvX address.
int IPvX::af ( ) const [inline]

Get the address family.

Returns:
the address family of this address (AF_INET or AF_INET6).
uint32_t IPvX::bit_count ( ) const [inline]

Count the number of bits that are set in this address.

Returns:
the number of bits that are set in this address.
uint32_t IPvX::bits ( uint32_t  lsb,
uint32_t  len 
) const throw (InvalidFamily) [inline]

Extract bits from an address.

Parameters:
lsbstarting bit position (from the right) to extract.
lennumber of bits to extract. The maximum value is 32.
Returns:
the first len bits starting from the rightmost position lsb. The returned bits are in host order.
size_t IPvX::copy_in ( const in_addr &  from_in_addr)

Copy a raw IPv4 address from a in_addr structure into IPvX structure.

Copy a raw address of family AF_INET from .

Parameters:
from_in_addrthe storage to copy the address from.
Returns:
the number of copied octets.
the number of copied octets.
size_t IPvX::copy_in ( const in6_addr &  from_in6_addr)

Copy a raw IPv6 address from a in6_addr structure into IPvX structure.

Copy a raw address of family AF_INET6 from .

Parameters:
from_in6_addrthe storage to copy the address from.
Returns:
the number of copied octets.
the number of copied octets.
size_t IPvX::copy_in ( int  family,
const uint8_t *  from_uint8 
) throw (InvalidFamily)

Copy a raw address of specified family type from specified memory location into IPvX structure.

Copy a raw address of family from the memory pointed by .

Parameters:
familythe address family.
from_uint8the memory address to copy the address from.
Returns:
the number of copied octets.
the number of copied octets.
size_t IPvX::copy_in ( const sockaddr &  from_sockaddr) throw (InvalidFamily)

Copy a raw address from a sockaddr structure into IPvX structure.

Copy a raw address from .

Copy a raw address from a sockaddr structure, and set internal address family appropriately.

Parameters:
from_sockaddrthe storage to copy the address from.
Returns:
the number of copied octets.
the number of copied octets.
size_t IPvX::copy_in ( const sockaddr_in &  from_sockaddr_in) throw (InvalidFamily)

Copy a raw address from a sockaddr_in structure into IPvX structure.

Copy a raw address from .

Copy a raw address from a sockaddr_in structure, and set internal address family appropriately.

Parameters:
from_sockaddr_inthe storage to copy the address from.
Returns:
the number of copied octets.
Exceptions:
InvalidFamilythrown if from_sockaddr_in is not a AF_INET sockaddr.
Returns:
the number of copied octets.
size_t IPvX::copy_in ( const sockaddr_storage &  from_sockaddr_storage) throw (InvalidFamily)

Copy a raw address from a sockaddr_storage structure into IPvX structure.

Copy a raw address from .

Copy a raw address from a sockaddr_storage structure, and set internal address family appropriately.

Parameters:
from_sockaddr_storagethe storage to copy the address from.
Returns:
the number of copied octets.
the number of copied octets.
size_t IPvX::copy_in ( const sockaddr_in6 &  from_sockaddr_in6) throw (InvalidFamily)

Copy a raw address from sockaddr_in6 structure into IPvX structure.

Copy a raw address from .

Copy a raw address from sockaddr_in6 structure, and set internal address family appropriately.

Parameters:
from_sockaddr_in6the storage to copy the address from.
Returns:
the number of copied octets.
Exceptions:
InvalidFamilythrown if from_sockaddr_in6 is not a AF_INET6 sockaddr.
Returns:
the number of copied octets.
size_t IPvX::copy_out ( sockaddr &  to_sockaddr) const throw (InvalidFamily)

Copy the IPvX raw address to a sockaddr structure.

Copy the raw address to , and assign appropriately the rest of the fields in .

Copy the raw address held within an IPvX instance to an sockaddr structure and assign appropriately and set fields within sockaddr appropriately. The underlying address representation may be either IPv4 or IPv6.

Parameters:
to_sockaddrthe storage to copy the address to.
Returns:
the number of copied octets.
the number of copied octets.
size_t IPvX::copy_out ( uint8_t *  to_uint8) const

Copy the IPvX raw address to specified memory location.

Copy the raw address to memory pointed by .

Parameters:
to_uint8 the pointer to the memory to copy the address to.
Returns:
the number of copied octets.
the number of copied octets.
size_t IPvX::copy_out ( in_addr &  to_in_addr) const throw (InvalidFamily)

Copy the IPvX raw address to an in_addr structure.

Copy the raw address to .

Note that this address must be of AF_INET family.

Parameters:
to_in_addrthe storage to copy the address to.
Returns:
the number of copied octets.
the number of copied octets.
size_t IPvX::copy_out ( sockaddr_storage &  to_sockaddr_storage) const throw (InvalidFamily)

Copy the IPvX raw address to a sockaddr_storage structure.

Copy the raw address to , and assign appropriately the rest of the fields in .

Copy the raw address held within an IPvX instance to an sockaddr_storage structure and assign appropriately and set fields within sockaddr_storage appropriately. The underlying address representation may be either IPv4 or IPv6.

Parameters:
to_sockaddr_storagethe storage to copy the address to.
Returns:
the number of copied octets.
the number of copied octets.
size_t IPvX::copy_out ( sockaddr_in &  to_sockaddr_in) const throw (InvalidFamily)

Copy the IPvX raw address to a sockaddr_in structure.

Copy the raw address to , and assign appropriately the rest of the fields in .

Copy the raw address held within an IPvX instance to an sockaddr_in structure and assign appropriately and set fields within to_sockaddr_in appropriately.

Note that this address must be of AF_INET family.

Parameters:
to_sockaddr_inthe storage to copy the address to.
Returns:
the number of copied octets.
the number of copied octets.
size_t IPvX::copy_out ( in6_addr &  to_in6_addr) const throw (InvalidFamily)

Copy the IPvX raw address to an in6_addr structure.

Copy the raw address to .

Note that this address must be of AF_INET6 family.

Parameters:
to_in6_addrthe storage to copy the address to.
Returns:
the number of copied octets.
the number of copied octets.
size_t IPvX::copy_out ( sockaddr_in6 &  to_sockaddr_in6) const throw (InvalidFamily)

Copy the IPvX raw address to a sockaddr_in6 structure.

Copy the raw address to , and assign appropriately the rest of the fields in .

Copy the raw address held within an IPvX instance to a sockaddr_in6 structure and assign appropriately and set fields within to_sockaddr_in6 appropriately.

Note that this address must be of AF_INET6 family.

Parameters:
to_sockaddr_in6the storage to copy the address to.
Returns:
the number of copied octets.
the number of copied octets.
void IPvX::get ( IPv4 to_ipv4) const throw (InvalidCast) [inline]

Assign address value to an IPv4 address.

Parameters:
to_ipv4IPv4 address to be assigned IPv4 value contained within this address.
void IPvX::get ( IPv6 to_ipv6) const throw (InvalidCast) [inline]

Assign address value to an IPv6 address.

Parameters:
to_ipv6IPv6 address to be assigned IPv4 value contained within this address.
IPv4 IPvX::get_ipv4 ( ) const throw (InvalidCast) [inline]

Get IPv4 address.

Returns:
IPv4 address contained with IPvX structure.
IPv6 IPvX::get_ipv6 ( ) const throw (InvalidCast) [inline]

Get IPv6 address.

Returns:
IPv6 address contained with IPvX structure.
uint32_t IPvX::ip_class_a_base_address_mask_len ( int  family) throw (InvalidFamily) [static]

Get the mask length for the Class A base address.

This method applies only for IPv4. Note that this is a static function and can be used without a particular object. Example: uint32_t my_len = IPvX::ip_class_a_base_address_mask_len(my_family);

Parameters:
familythe address family.
Returns:
the Class A base address mask length for an address of address family of family.
uint32_t IPvX::ip_class_a_base_address_mask_len ( ) const throw (InvalidFamily) [inline]

Get the mask length for the Class A base address for this address.

This method applies only for IPv4. Note that this is not a static function, hence it has to be used with a particular object. Example: size_t my_len = ipvx.ip_class_a_base_address_mask_len();

Parameters:
familythe address family.
Returns:
the Class A base address mask length for this IPvX address.
uint32_t IPvX::ip_class_b_base_address_mask_len ( int  family) throw (InvalidFamily) [static]

Get the mask length for the Class B base address.

This method applies only for IPv4. Note that this is a static function and can be used without a particular object. Example: uint32_t my_len = IPvX::ip_class_b_base_address_mask_len(my_family);

Parameters:
familythe address family.
Returns:
the Class B base address mask length for an address of address family of family.
uint32_t IPvX::ip_class_b_base_address_mask_len ( ) const throw (InvalidFamily) [inline]

Get the mask length for the Class B base address for this address.

This method applies only for IPv4. Note that this is not a static function, hence it has to be used with a particular object. Example: size_t my_len = ipvx.ip_class_b_base_address_mask_len();

Parameters:
familythe address family.
Returns:
the Class B base address mask length for this IPvX address.
uint32_t IPvX::ip_class_c_base_address_mask_len ( int  family) throw (InvalidFamily) [static]

Get the mask length for the Class C base address.

This method applies only for IPv4. Note that this is a static function and can be used without a particular object. Example: uint32_t my_len = IPvX::ip_class_c_base_address_mask_len(my_family);

Parameters:
familythe address family.
Returns:
the Class C base address mask length for an address of address family of family.
uint32_t IPvX::ip_class_c_base_address_mask_len ( ) const throw (InvalidFamily) [inline]

Get the mask length for the Class C base address for this address.

This method applies only for IPv4. Note that this is not a static function, hence it has to be used with a particular object. Example: size_t my_len = ipvx.ip_class_c_base_address_mask_len();

Parameters:
familythe address family.
Returns:
the Class C base address mask length for this IPvX address.
uint32_t IPvX::ip_experimental_base_address_mask_len ( int  family) throw (InvalidFamily) [static]

Get the mask length for the experimental base address.

This method applies only for IPv4. Note that this is a static function and can be used without a particular object. Example: uint32_t my_len = IPvX::ip_experimental_base_address_mask_len(my_family);

Parameters:
familythe address family.
Returns:
the experimental base address mask length for an address of address family of family.
uint32_t IPvX::ip_experimental_base_address_mask_len ( ) const throw (InvalidFamily) [inline]

Get the mask length for the experimental base address for this address.

This method applies only for IPv4. Note that this is not a static function, hence it has to be used with a particular object. Example: size_t my_len = ipvx.ip_experimental_base_address_mask_len();

Parameters:
familythe address family.
Returns:
the experimental base address mask length for this IPvX address.
uint32_t IPvX::ip_multicast_base_address_mask_len ( int  family) throw (InvalidFamily) [static]

Get the mask length for the multicast base address.

Note that this is a static function and can be used without a particular object. Example: uint32_t my_len = IPvX::ip_multicast_base_address_mask_len(my_family);

Parameters:
familythe address family.
Returns:
the multicast base address mask length for an address of address family of family.
uint32_t IPvX::ip_multicast_base_address_mask_len ( ) const [inline]

Get the mask length for the multicast base address for this address.

Note that this is not a static function, hence it has to be used with a particular object. Example: size_t my_len = ipvx.ip_multicast_base_address_mask_len();

Parameters:
familythe address family.
Returns:
the multicast base address mask length for this IPvX address.
uint32_t IPvX::ip_version ( ) const throw (InvalidFamily)

Get the IP protocol version.

Returns:
the IP protocol version of this address.
IP protocol version.
const string & IPvX::ip_version_str ( ) const throw (InvalidFamily)

Get the human-readable string with the IP protocol version.

Returns:
the human-readable string with the IP protocol version of this address.
IP protocol version string.
bool IPvX::is_class_a ( ) const

Test if this address belongs to the IPv4 Class A address space (0.0.0.0/1).

This method applies only for IPv4, and always returns false for IPv6.

Returns:
true if the address is a valid Class A address.
bool IPvX::is_class_b ( ) const

Test if this address belongs to the IPv4 Class B address space (128.0.0.0/2).

This method applies only for IPv4, and always returns false for IPv6.

Returns:
true if the address is a valid Class B address.
bool IPvX::is_class_c ( ) const

Test if this address belongs to the IPv4 Class C address space (192.0.0.0/3).

This method applies only for IPv4, and always returns false for IPv6.

Returns:
true if the address is a valid Class C address.
bool IPvX::is_experimental ( ) const

Test if this address belongs to the IPv4 experimental Class E address space (240.0.0.0/4).

This method applies only for IPv4, and always returns false for IPv6.

Returns:
true if the address is a valid experimental address.
bool IPvX::is_interfacelocal_multicast ( ) const

Test if this address is a valid interface-local multicast address.

Note that "node-local" multicast addresses were renamed to "interface-local" by RFC-3513.

Returns:
true if the address is a valid multicast address, and the scope of the address is interface-local.
bool IPvX::is_ipv4 ( ) const [inline]

Test if this address is IPv4 address.

Returns:
true if the address is IPv4.
bool IPvX::is_ipv6 ( ) const [inline]

Test if this address is IPv6 address.

Returns:
true if the address is IPv6.
bool IPvX::is_linklocal_multicast ( ) const

Test if this address is a valid link-local multicast address.

Returns:
true if the address is a valid multicast address, and the scope of the address is link-local.
bool IPvX::is_linklocal_unicast ( ) const

Test if this address is a valid link-local unicast address.

Returns:
true if the address is a valid unicast address, and the scope of the address is link-local.
bool IPvX::is_loopback ( ) const

Test if this address is a valid loopback address.

Returns:
true if this address is a valid loopback address.
bool IPvX::is_multicast ( ) const

Test if this address is a valid multicast address.

Returns:
true if the address is a valid multicast address.
bool IPvX::is_nodelocal_multicast ( ) const [inline]

Test if this address is a valid node-local multicast address.

Note that "node-local" multicast addresses were renamed to "interface-local" by RFC-3513. This method is kept for backward compatibility.

Returns:
true if the address is a valid multicast address, and the scope of the address is node-local.
bool IPvX::is_unicast ( ) const

Test if this address is a valid unicast address.

Returns:
true if the address is a valid unicast address.
bool IPvX::is_zero ( ) const

Test if this address is numerically zero.

Returns:
true if the address is numerically zero.
uint32_t IPvX::leading_zero_count ( ) const [inline]

Count the number of leading zeroes in this address.

Returns:
the number of leading zeroes in this address.
IPvX IPvX::make_prefix ( uint32_t  mask_len) const throw (InvalidNetmaskLength) [inline]

Make an IPvX mask prefix for the address family of this address.

Parameters:
mask_lenthe length of the mask to create.
Returns:
a new IPvX address that contains a mask of length mask_len.
IPvX IPvX::make_prefix ( int  family,
uint32_t  mask_len 
) throw (InvalidFamily, InvalidNetmaskLength) [static]

Make an IPvX mask prefix.

Parameters:
familythe address family.
mask_lenthe length of the mask to create.
Returns:
a new IPvX address that contains a mask of length mask_len.
IPvX IPvX::mask_by_prefix_len ( uint32_t  prefix_len) const throw (InvalidNetmaskLength)

Make an IPvX address prefix.

Parameters:
prefix_lenthe length of the mask of the prefix to create.
Returns:
a new IPvX address created by masking this address with a mask of length prefix_len.
uint32_t IPvX::mask_len ( ) const

Get the mask length.

Returns:
the prefix length of the contiguous mask presumably stored as an IPvX address.
bool IPvX::operator!= ( const IPvX other) const

Not-Equal Operator.

Parameters:
otherthe right-hand operand to compare against.
Returns:
true if the left-hand operand is numerically not same as the right-hand operand.
IPvX IPvX::operator& ( const IPvX other) const throw (InvalidCast)

AND Operator.

Parameters:
otherthe right-hand operand to AND with.
Returns:
bitwise AND of two addresses.
IPvX & IPvX::operator++ ( )

Increment Operator.

The numerical value of this address is incremented by one. However, if the address value before the increment was all-1s, after the increment its value would be all-0s (i.e., it will wrap-around).

Returns:
a reference to this address after it was incremented by one.
IPvX & IPvX::operator-- ( )

Decrement Operator.

The numerical value of this address is decremented by one. However, if the address value before the decrement was all-0s, after the decrement its value would be all-1s (i.e., it will wrap-around).

Returns:
a reference to this address after it was decremented by one.
bool IPvX::operator< ( const IPvX other) const

Less-Than Operator.

Parameters:
otherthe right-hand operand to compare against.
Returns:
true if the left-hand operand is numerically smaller than the right-hand operand.
IPvX IPvX::operator<< ( uint32_t  left_shift) const

Operator <<.

Parameters:
left_shiftthe number of bits to shift to the left.
Returns:
IPvX address that is shift bitwise to the left.
bool IPvX::operator== ( const IPvX other) const

Equality Operator.

Parameters:
otherthe right-hand operand to compare against.
Returns:
true if the left-hand operand is numerically same as the right-hand operand.
IPvX IPvX::operator>> ( uint32_t  right_shift) const

Operator >>

Parameters:
right_shiftthe number of bits to shift to the right.
Returns:
IPvX address that is shift bitwise to the right.
IPvX IPvX::operator^ ( const IPvX other) const throw (InvalidCast)

XOR Operator.

Parameters:
otherthe right-hand operand to XOR with.
Returns:
bitwize eXclusive-OR of two addresses.
IPvX IPvX::operator| ( const IPvX other) const throw (InvalidCast)

OR Operator.

Parameters:
otherthe right-hand operand to OR with.
Returns:
bitwise OR of two addresses.
IPvX IPvX::operator~ ( ) const

Bitwise-Negation Operator.

Returns:
address complement (i.e., all 0s become 1s, and vice-versa).
string IPvX::str ( ) const

Convert this address from binary form to presentation format.

Returns:
C++ string with the human-readable ASCII representation of the address.

The documentation for this class was generated from the following files:
 All Classes Namespaces Functions Variables Typedefs Enumerations