|
xorp
|
Basic IPvX class (for both IPv4 and IPv6) More...
#include <ipvx.hh>
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. | |
| IPvX & | operator-- () |
| Decrement Operator. | |
| IPvX & | operator++ () |
| 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 IPvX & | ZERO (int family) throw (InvalidFamily) |
| Pre-defined IPvX address constants. | |
| static const IPvX & | ANY (int family) throw (InvalidFamily) |
| static const IPvX & | ALL_ONES (int family) throw (InvalidFamily) |
| static const IPvX & | LOOPBACK (int family) throw (InvalidFamily) |
| static const IPvX & | MULTICAST_BASE (int family) throw (InvalidFamily) |
| static const IPvX & | MULTICAST_ALL_SYSTEMS (int family) throw (InvalidFamily) |
| static const IPvX & | MULTICAST_ALL_ROUTERS (int family) throw (InvalidFamily) |
| static const IPvX & | DVMRP_ROUTERS (int family) throw (InvalidFamily) |
| static const IPvX & | OSPFIGP_ROUTERS (int family) throw (InvalidFamily) |
| static const IPvX & | OSPFIGP_DESIGNATED_ROUTERS (int family) throw (InvalidFamily) |
| static const IPvX & | RIP2_ROUTERS (int family) throw (InvalidFamily) |
| static const IPvX & | PIM_ROUTERS (int family) throw (InvalidFamily) |
| static const IPvX & | SSM_ROUTERS (int family) throw (InvalidFamily) |
| static const IPvX & | CLASS_A_BASE (int family) throw (InvalidFamily) |
| static const IPvX & | CLASS_B_BASE (int family) throw (InvalidFamily) |
| static const IPvX & | CLASS_C_BASE (int family) throw (InvalidFamily) |
| static const IPvX & | EXPERIMENTAL_BASE (int family) throw (InvalidFamily) |
Private Attributes | |
| uint32_t | _addr [4] |
| int | _af |
Friends | |
| class | IPv4 |
| class | IPv6 |
| 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] |
| IPvX::IPvX | ( | int | family, |
| const uint8_t * | from_uint8 | ||
| ) | throw (InvalidFamily) |
| IPvX::IPvX | ( | const IPv4 & | ipv4 | ) |
| IPvX::IPvX | ( | const IPv6 & | ipv6 | ) |
| IPvX::IPvX | ( | const in_addr & | from_in_addr | ) |
| IPvX::IPvX | ( | const in6_addr & | from_in6_addr | ) |
| IPvX::IPvX | ( | const sockaddr & | from_sockaddr | ) | throw (InvalidFamily) |
| IPvX::IPvX | ( | const sockaddr_storage & | from_sockaddr_storage | ) | throw (InvalidFamily) |
| IPvX::IPvX | ( | const sockaddr_in & | from_sockaddr_in | ) | throw (InvalidFamily) |
Constructor from sockaddr_in structure.
| InvalidFamily | thrown 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.
| InvalidFamily | thrown if from_sockaddr_in6 is not a AF_INET6 sockaddr. |
| IPvX::IPvX | ( | const char * | from_cstring | ) | throw (InvalidString) |
| static uint32_t IPvX::addr_bitlen | ( | int | family | ) | throw (InvalidFamily) [inline, static] |
| uint32_t IPvX::addr_bitlen | ( | ) | const [inline] |
| size_t IPvX::addr_bytelen | ( | int | family | ) | throw (InvalidFamily) [static] |
| size_t IPvX::addr_bytelen | ( | ) | const [inline] |
| int IPvX::af | ( | ) | const [inline] |
| uint32_t IPvX::bit_count | ( | ) | const [inline] |
| uint32_t IPvX::bits | ( | uint32_t | lsb, |
| uint32_t | len | ||
| ) | const throw (InvalidFamily) [inline] |
| size_t IPvX::copy_in | ( | const in_addr & | from_in_addr | ) |
| size_t IPvX::copy_in | ( | const in6_addr & | from_in6_addr | ) |
| size_t IPvX::copy_in | ( | int | family, |
| const uint8_t * | from_uint8 | ||
| ) | throw (InvalidFamily) |
| 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.
| 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.
| InvalidFamily | thrown if from_sockaddr_in is not a AF_INET sockaddr. |
| 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.
| 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.
| InvalidFamily | thrown if from_sockaddr_in6 is not a AF_INET6 sockaddr. |
| 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.
| size_t IPvX::copy_out | ( | uint8_t * | to_uint8 | ) | const |
| size_t IPvX::copy_out | ( | in_addr & | to_in_addr | ) | const throw (InvalidFamily) |
| 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.
| 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.
| size_t IPvX::copy_out | ( | in6_addr & | to_in6_addr | ) | const throw (InvalidFamily) |
| 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.
| void IPvX::get | ( | IPv4 & | to_ipv4 | ) | const throw (InvalidCast) [inline] |
| void IPvX::get | ( | IPv6 & | to_ipv6 | ) | const throw (InvalidCast) [inline] |
| IPv4 IPvX::get_ipv4 | ( | ) | const throw (InvalidCast) [inline] |
| IPv6 IPvX::get_ipv6 | ( | ) | const throw (InvalidCast) [inline] |
| 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);
| family | the address family. |
| uint32_t IPvX::ip_class_a_base_address_mask_len | ( | ) | const throw (InvalidFamily) [inline] |
| 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);
| family | the address family. |
| uint32_t IPvX::ip_class_b_base_address_mask_len | ( | ) | const throw (InvalidFamily) [inline] |
| 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);
| family | the address family. |
| uint32_t IPvX::ip_class_c_base_address_mask_len | ( | ) | const throw (InvalidFamily) [inline] |
| 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);
| family | the address 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();
| family | the address family. |
| 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);
| family | the address family. |
| uint32_t IPvX::ip_multicast_base_address_mask_len | ( | ) | const [inline] |
| uint32_t IPvX::ip_version | ( | ) | const throw (InvalidFamily) |
| const string & IPvX::ip_version_str | ( | ) | const throw (InvalidFamily) |
| bool IPvX::is_class_a | ( | ) | const |
| bool IPvX::is_class_b | ( | ) | const |
| bool IPvX::is_class_c | ( | ) | const |
| bool IPvX::is_experimental | ( | ) | const |
| bool IPvX::is_interfacelocal_multicast | ( | ) | const |
| bool IPvX::is_ipv4 | ( | ) | const [inline] |
| bool IPvX::is_ipv6 | ( | ) | const [inline] |
| bool IPvX::is_linklocal_multicast | ( | ) | const |
| bool IPvX::is_linklocal_unicast | ( | ) | const |
| bool IPvX::is_loopback | ( | ) | const |
Test if this address is a valid loopback address.
| bool IPvX::is_multicast | ( | ) | const |
Test if this 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.
| bool IPvX::is_unicast | ( | ) | const |
Test if this address is a valid unicast address.
| bool IPvX::is_zero | ( | ) | const |
Test if this address is numerically zero.
| uint32_t IPvX::leading_zero_count | ( | ) | const [inline] |
| IPvX IPvX::make_prefix | ( | uint32_t | mask_len | ) | const throw (InvalidNetmaskLength) [inline] |
| IPvX IPvX::make_prefix | ( | int | family, |
| uint32_t | mask_len | ||
| ) | throw (InvalidFamily, InvalidNetmaskLength) [static] |
| IPvX IPvX::mask_by_prefix_len | ( | uint32_t | prefix_len | ) | const throw (InvalidNetmaskLength) |
| uint32_t IPvX::mask_len | ( | ) | const |
| bool IPvX::operator!= | ( | const IPvX & | other | ) | const |
| IPvX IPvX::operator& | ( | const IPvX & | other | ) | const throw (InvalidCast) |
AND Operator.
| other | the right-hand operand to AND with. |
| IPvX & IPvX::operator++ | ( | ) |
| IPvX & IPvX::operator-- | ( | ) |
| bool IPvX::operator< | ( | const IPvX & | other | ) | const |
| IPvX IPvX::operator<< | ( | uint32_t | left_shift | ) | const |
| bool IPvX::operator== | ( | const IPvX & | other | ) | const |
| IPvX IPvX::operator>> | ( | uint32_t | right_shift | ) | const |
| IPvX IPvX::operator^ | ( | const IPvX & | other | ) | const throw (InvalidCast) |
XOR Operator.
| other | the right-hand operand to XOR with. |
| IPvX IPvX::operator| | ( | const IPvX & | other | ) | const throw (InvalidCast) |
OR Operator.
| other | the right-hand operand to OR with. |
| IPvX IPvX::operator~ | ( | ) | const |
Bitwise-Negation Operator.
| string IPvX::str | ( | ) | const |