IPvXNet class. Container for IPv4 and IPv6 networks.
Also see IPNet for available methods.
explicit IPvXNet (int family)
throw (InvalidFamily) | IPvXNet |
Constructor for a specified address family.
Creates a network address of specified family, and address value of INADDR_ANY or IN6ADDR_ANY (for IPv4 and IPv6 respectively).
Parameters:
family | the address family. |
IPvXNet (const BaseIPvXNet& n)
| IPvXNet |
Copy constructor for BaseIPvXNet subnet address
Parameters:
n | the subnet to copy from. |
IPvXNet (const IPvXNet& n)
| IPvXNet |
Copy constructor for IPvXNet subnet address
Parameters:
n | the subnet to copy from. |
IPvXNet (const IPv4Net& v4net)
| IPvXNet |
Copy constructor for IPv4Net subnet address
Parameters:
v4net | the subnet to copy from. |
IPvXNet (const IPv6Net& v6net)
| IPvXNet |
Copy constructor for IPv6Net subnet address
Parameters:
v6net | the subnet to copy from. |
IPvXNet (const char *cp)
throw (InvalidString, InvalidNetmaskLength) | IPvXNet |
Constructor from a string.
Parameters:
from_cstring | C-style string with slash separated address and prefix length. Examples: "12.34.56/24", "1234:5678/32::" |
IPvXNet (const IPvX& a, uint32_t prefix_len)
throw (InvalidNetmaskLength) | IPvXNet |
Constructor from a given base address and a prefix length.
Parameters:
a | base address for the subnet. |
prefix_len | length of subnet mask. |
inline bool is_ipv4 ()
| is_ipv4 |
[const]
Test if this subnet is IPv4 subnet.
Returns: true if the subnet is IPv4.
inline bool is_ipv6 ()
| is_ipv6 |
[const]
Test if this subnet is IPv6 subnet.
Returns: true if the subnet is IPv6.
inline IPv4Net get_ipv4net ()
throw (InvalidCast) | get_ipv4net |
[const]
Get IPv4Net subnet.
Returns: IPv4Net subnet contained with IPvXNet structure.
inline IPv6Net get_ipv6net ()
throw (InvalidCast) | get_ipv6net |
[const]
Get IPv6Net subnet.
Returns: IPv6Net subnet contained with IPvXNet structure.
inline void get (IPv4Net& to_ipv4net)
throw (InvalidCast) | get |
[const]
Assign address value to an IPv4Net subnet.
Parameters:
to_ipv4net | IPv4Net subnet to be assigned IPv4Net value contained within this subnet. |
inline void get (IPv6Net& to_ipv6net)
throw (InvalidCast) | get |
[const]
Assign address value to an IPv6Net subnet.
Parameters:
to_ipv6net | IPv6Net subnet to be assigned IPv6Net value contained within this subnet. |
inline int af ()
| af |
[const]
Get the address family.
Returns: the address family of this subnet (AF_INET or AF_INET6).
bool is_unicast ()
| is_unicast |
[const]
Test if this subnet is a unicast prefix.
In case of IPv4 all prefixes that fall within the Class A, Class B or Class C address space are unicast. In case of IPv6 all prefixes that don't contain the multicast address space are unicast. Note that the default route (0.0.0.0/0 for IPv4 or ::/0 for IPv6) is also considered an unicast prefix.
Returns: true if this subnet is a unicast prefix.
inline IPvXNet ip_multicast_base_prefix (int family)
throw (InvalidFamily) | ip_multicast_base_prefix |
[static]
Return the subnet containing all multicast addresses.
Note that this is a static function and can be used without a particular object. Example: IPvXNet my_prefix = IPvXNet::ip_multicast_base_prefix(my_family);
Parameters:
family | the address family. |
Returns: the multicast base prefix address for address family of family.
inline IPvXNet ip_class_a_base_prefix (int family)
throw (InvalidFamily) | ip_class_a_base_prefix |
[static]
Return the subnet containing all IPv4 Class A addresses (0.0.0.0/1).
This method applies only for IPv4. Note that this is a static function and can be used without a particular object. Example: IPvXNet my_prefix = IPvXNet::ip_class_a_base_prefix(my_family);
Parameters:
family | the address family. |
Returns: the Class A base prefix address for address family of family.
inline IPvXNet ip_class_b_base_prefix (int family)
throw (InvalidFamily) | ip_class_b_base_prefix |
[static]
Return the subnet containing all IPv4 Class B addresses (128.0.0.0/2).
This method applies only for IPv4. Note that this is a static function and can be used without a particular object. Example: IPvXNet my_prefix = IPvXNet::ip_class_b_base_prefix(my_family);
Parameters:
family | the address family. |
Returns: the Class B base prefix address for address family of family.
inline IPvXNet ip_class_c_base_prefix (int family)
throw (InvalidFamily) | ip_class_c_base_prefix |
[static]
Return the subnet containing all IPv4 Class C addresses (192.0.0.0/3).
This method applies only for IPv4. Note that this is a static function and can be used without a particular object. Example: IPvXNet my_prefix = IPvXNet::ip_class_c_base_prefix(my_family);
Parameters:
family | the address family. |
Returns: the Class C base prefix address for address family of family.
inline IPvXNet ip_experimental_base_prefix (int family)
throw (InvalidFamily) | ip_experimental_base_prefix |
[static]
Return the subnet containing all IPv4 experimental Class E addresses (240.0.0.0/4).
This method applies only for IPv4. Note that this is a static function and can be used without a particular object. Example: IPvXNet my_prefix = IPvXNet::ip_experimental_base_prefix(my_family);
Parameters:
family | the address family. |
Returns: the experimental base prefix address for address family of family.
bool is_multicast ()
| is_multicast |
[const]
Test if this subnet is within the multicast address range.
Returns: true if this subnet is within the multicast address range.
bool is_class_a ()
| is_class_a |
[const]
Test if this subnet is within the IPv4 Class A address range (0.0.0.0/1).
This method applies only for IPv4, and always returns false for IPv6.
Returns: true if this subnet is within the IPv4 Class A address range.
bool is_class_b ()
| is_class_b |
[const]
Test if this subnet is within the IPv4 Class B address range (128.0.0.0/2).
This method applies only for IPv4, and always returns false for IPv6.
Returns: true if this subnet is within the IPv4 Class B address range.
bool is_class_c ()
| is_class_c |
[const]
Test if this subnet is within the IPv4 Class C address range (192.0.0.0/3).
This method applies only for IPv4, and always returns false for IPv6.
Returns: true if this subnet is within the IPv4 Class C address range.
bool is_experimental ()
| is_experimental |
[const]
Test if this subnet is within the IPv4 experimental Class E address range (240.0.0.0/4).
This method applies only for IPv4, and always returns false for IPv6.
Returns: true if this subnet is within the IPv4 experimental address range.