class IPvX

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

Definition#include <ipvx.hh>
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

Public Methods

Public Static Methods


Detailed Description

 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)).

explicit  IPvX (int family)
throw (InvalidFamily)

IPvX

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 (int family, const uint8_t *from_uint8)
throw (InvalidFamily)

IPvX

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 (const IPv4& ipv4)

IPvX

Constructor from an IPv4 address.

Create an IPvX address from an IPv4 address.

Parameters:
ipv4the IPv4 address to assign the address value from.

 IPvX (const IPv6& ipv6)

IPvX

Constructor from an IPv6 address.

Create an IPvX address from an IPv6 address.

Parameters:
ipv6the IPv6 address to assign the address value from.

 IPvX (const in_addr& from_in_addr)

IPvX

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 (const in6_addr& from_in6_addr)

IPvX

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 (const sockaddr& from_sockaddr)
throw (InvalidFamily)

IPvX

Constructor from sockaddr structure.

Parameters:
from_sockaddrthe storage to copy the address from.

 IPvX (const sockaddr_in& from_sockaddr_in)
throw (InvalidFamily)

IPvX

Constructor from sockaddr_in structure.

Parameters:
from_sockaddr_inthe storage to copy the address from.

 IPvX (const sockaddr_in6& from_sockaddr_in6)
throw (InvalidFamily)

IPvX

Constructor from sockaddr_in6 structure.

Parameters:
from_sockaddr_in6the storage to copy the address from.

 IPvX (const char *from_cstring)
throw (InvalidString)

IPvX

Constructor from a string.

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

size_t  copy_out (uint8_t *to_uint8)

copy_out

[const]

Copy the IPvX raw address to specified memory location.

@param: to_uint8 the pointer to the memory to copy the address to.

Returns: the number of copied octets.

size_t  copy_out (in_addr& to_in_addr)
throw (InvalidFamily)

copy_out

[const]

Copy the IPvX raw address to an in_addr structure.

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.

size_t  copy_out (in6_addr& to_in6_addr)
throw (InvalidFamily)

copy_out

[const]

Copy the IPvX raw address to an in6_addr structure.

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.

size_t  copy_out (sockaddr& to_sockaddr)
throw (InvalidFamily)

copy_out

[const]

Copy the IPvX raw address to a sockaddr structure.

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.

size_t  copy_out (sockaddr_in& to_sockaddr_in)
throw (InvalidFamily)

copy_out

[const]

Copy the IPvX raw address to a sockaddr_in structure.

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

Parameters:
to_sockaddr_inthe storage to copy the address to.

Returns: the number of copied octets.

size_t  copy_out (sockaddr_in6& to_sockaddr_in6)
throw (InvalidFamily)

copy_out

[const]

Copy the IPvX raw address to a sockaddr_in6 structure.

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

Parameters:
to_sockaddr_in6the storage to copy the address to.

Returns: the number of copied octets.

size_t  copy_in (int family, const uint8_t *from_uint8)
throw (InvalidFamily)

copy_in

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

Parameters:
familythe address family.
from_uint8the memory address to copy the address from.

Returns: the number of copied octets.

size_t  copy_in (const in_addr& from_in_addr)

copy_in

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

Parameters:
from_in_addrthe storage to copy the address from.

Returns: the number of copied octets.

size_t  copy_in (const in6_addr& from_in6_addr)

copy_in

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

Parameters:
from_in6_addrthe storage to copy the address from.

Returns: the number of copied octets.

size_t  copy_in (const sockaddr& from_sockaddr)
throw (InvalidFamily)

copy_in

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

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.

size_t  copy_in (const sockaddr_in& from_sockaddr_in)
throw (InvalidFamily)

copy_in

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

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.

size_t  copy_in (const sockaddr_in6& from_sockaddr_in6)
throw (InvalidFamily)

copy_in

Copy a raw address from sockaddr_in6 structure into IPvX structure.

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.

IPvX  operator~ ()

operator~

[const]

Bitwise-Negation Operator

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

IPvX  operator| (const IPvX& other)
throw (InvalidCast)

operator|

[const]

OR Operator

Parameters:
otherthe right-hand operand to OR with.

Returns: bitwise OR of two addresses.

IPvX  operator& (const IPvX& other)
throw (InvalidCast)

operator&

[const]

AND Operator

Parameters:
otherthe right-hand operand to AND with.

Returns: bitwise AND of two addresses.

IPvX  operator^ (const IPvX& other)
throw (InvalidCast)

operator^

[const]

XOR Operator

Parameters:
otherthe right-hand operand to XOR with.

Returns: bitwize eXclusive-OR of two addresses.

IPvX  operator<< (uint32_t left_shift)

operator<<

[const]

Operator <<

Parameters:
left_shiftthe number of bits to shift to the left.

Returns: IPvX address that is shift bitwise to the left.

IPvX  operator>> (uint32_t right_shift)

operator>>

[const]

Operator >>

Parameters:
right_shiftthe number of bits to shift to the right.

Returns: IPvX address that is shift bitwise to the right.

bool  operator< (const IPvX& other)

operator<

[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.

bool  operator== (const IPvX& other)

operator==

[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.

bool  operator!= (const IPvX& other)

operator!=

[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&  operator-- ()

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.

IPvX&  operator++ ()

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.

string  str ()

str

[const]

Convert this address from binary form to presentation format.

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

bool  is_zero ()

is_zero

[const]

Test if this address is numerically zero.

Returns: true if the address is numerically zero.

bool  is_unicast ()

is_unicast

[const]

Test if this address is a valid unicast address.

Returns: true if the address is a valid unicast address.

bool  is_multicast ()

is_multicast

[const]

Test if this address is a valid multicast address.

Returns: true if the address is a valid multicast address.

bool  is_nodelocal_multicast ()

is_nodelocal_multicast

[const]

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

Returns: true if the address is a valid multicast address, and the scope of the address is node-local.

bool  is_linklocal_multicast ()

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.

size_t  addr_size (int family)
throw (InvalidFamily)

addr_size

[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_size(my_family);

Parameters:
familythe address family.

Returns: address size in number of octets for an address of address family of family.

size_t  addr_size ()

addr_size

[const]

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_size();

Parameters:
familythe address family.

Returns: address size in number of octets for this IPvX address.

inline uint32_t  addr_bitlen (int family)
throw (InvalidFamily)

addr_bitlen

[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.

inline uint32_t  addr_bitlen ()

addr_bitlen

[const]

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.

uint32_t  ip_multicast_base_address_mask_len (int family)
throw (InvalidFamily)

ip_multicast_base_address_mask_len

[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  ip_multicast_base_address_mask_len ()

ip_multicast_base_address_mask_len

[const]

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.

IPvX  make_prefix (int family, uint32_t mask_len)
throw (InvalidFamily, InvalidNetmaskLength)

make_prefix

[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  make_prefix (uint32_t mask_len)
throw (InvalidNetmaskLength)

make_prefix

[const]

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  mask_by_prefix_len (uint32_t prefix_len)
throw (InvalidNetmaskLength)

mask_by_prefix_len

[const]

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  mask_len ()

mask_len

[const]

Get the mask length.

Returns: the prefix length of the contiguous mask presumably stored as an IPvX address.

inline bool  is_ipv4 ()

is_ipv4

[const]

Test if this address is IPv4 address.

Returns: true if the address is IPv4.

inline bool  is_ipv6 ()

is_ipv6

[const]

Test if this address is IPv6 address.

Returns: true if the address is IPv6.

inline IPv4  get_ipv4 ()
throw (InvalidCast)

get_ipv4

[const]

Get IPv4 address.

Returns: IPv4 address contained with IPvX structure.

inline IPv6  get_ipv6 ()
throw (InvalidCast)

get_ipv6

[const]

Get IPv6 address.

Returns: IPv6 address contained with IPvX structure.

inline void  get (IPv4& to_ipv4)
throw (InvalidCast)

get

[const]

Assign address value to an IPv4 address.

Parameters:
to_ipv4IPv4 address to be assigned IPv4 value contained within this address.

inline void  get (IPv6& to_ipv6)
throw (InvalidCast)

get

[const]

Assign address value to an IPv6 address.

Parameters:
to_ipv6IPv6 address to be assigned IPv4 value contained within this address.

inline int  af ()

af

[const]

Get the address family.

Returns: the address family of this address (AF_INET or AF_INET6).

uint32_t  ip_version ()
throw (InvalidFamily)

ip_version

[const]

Get the IP protocol version.

Returns: the IP protocol version of this address.

const string&  ip_version_str ()
throw (InvalidFamily)

ip_version_str

[const]

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

Returns: the human-readable string with the IP protocol version of this address.

inline uint32_t  bits (uint32_t lsb, uint32_t len)
throw (InvalidFamily)

bits

[const]

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.

const IPvX&  ZERO (int family)
throw (InvalidFamily)

ZERO

[static]

Pre-defined IPvX address constants.

const IPvX&  ANY (int family)
throw (InvalidFamily)

ANY

[static]

const IPvX&  ALL_ONES (int family)
throw (InvalidFamily)

ALL_ONES

[static]

const IPvX&  MULTICAST_BASE (int family)
throw (InvalidFamily)

MULTICAST_BASE

[static]

const IPvX&  MULTICAST_ALL_SYSTEMS (int family)
throw (InvalidFamily)

MULTICAST_ALL_SYSTEMS

[static]

const IPvX&  MULTICAST_ALL_ROUTERS (int family)
throw (InvalidFamily)

MULTICAST_ALL_ROUTERS

[static]

const IPvX&  DVMRP_ROUTERS (int family)
throw (InvalidFamily)

DVMRP_ROUTERS

[static]

const IPvX&  RIP2_ROUTERS (int family)
throw (InvalidFamily)

RIP2_ROUTERS

[static]

const IPvX&  PIM_ROUTERS (int family)
throw (InvalidFamily)

PIM_ROUTERS

[static]

const IPvX&  OSPFIGP_ROUTERS (int family)
throw (InvalidFamily)

OSPFIGP_ROUTERS

[static]

const IPvX&  OSPFIGP_DESIGNATED_ROUTERS (int family)
throw (InvalidFamily)

OSPFIGP_DESIGNATED_ROUTERS

[static]


Generated by: pavlin on possum.icir.org on Thu Nov 6 23:46:46 2003, using kdoc 2.0a54+XORP.