|
join 1.0
lightweight network framework library
|
IPv6, IPv4 address class. More...
#include <ipaddress.hpp>

Public Member Functions | |
| IpAddress () | |
| create the IpAddress instance (default: IPv6 wildcard address). | |
| IpAddress (int family) | |
| create the IpAddress instance using address family. | |
| IpAddress (const IpAddress &address) | |
| create the IpAddress instance by copy. | |
| IpAddress (IpAddress &&address) | |
| create the IpAddress instance by move. | |
| IpAddress (const struct sockaddr &address) | |
| create the IpAddress instance using a sockaddr structure. | |
| IpAddress (const void *address, socklen_t length) | |
| create the IpAddress instance using an in_addr structure or an in6_addr structure. | |
| IpAddress (const void *address, socklen_t length, uint32_t scope) | |
| create the IpAddress instance using an in_addr structure or an in6_addr structure. | |
| IpAddress (const std::string &address, int family) | |
| create the IpAddress instance using a string and address family. | |
| IpAddress (const std::string &address) | |
| create the IpAddress instance using a string. | |
| IpAddress (const char *address, int family) | |
| create the IpAddress instance using a string and address family. | |
| IpAddress (const char *address) | |
| create the IpAddress instance using a string. | |
| IpAddress (int prefix, int family) | |
| create netmask address using prefix length. | |
| IpAddress & | operator= (const IpAddress &address) |
| assign the IpAddress instance by copy. | |
| IpAddress & | operator= (IpAddress &&address) |
| assign the IpAddress instance by move. | |
| IpAddress & | operator= (const struct sockaddr &address) |
| assign the IpAddress using a sockaddr structure. | |
| ~IpAddress () | |
| destroy the IpAddress instance. | |
| int | family () const |
| get address family. | |
| const void * | addr () const |
| get the internal address structure. | |
| socklen_t | length () const |
| get the size in byte of the internal address structure. | |
| uint32_t | scope () const |
| get the scope identifier of the address. | |
| int | prefix () const |
| get prefix length from netmask address. | |
| bool | isWildcard () const |
| check if IP address is a wildcard address. | |
| bool | isLoopBack () const |
| check if IP address is a loopback address. | |
| bool | isLinkLocal () const |
| check if IP address is link local. | |
| bool | isSiteLocal () const |
| check if IP address is site local (deprecated). | |
| bool | isUniqueLocal () const |
| check if IP address is unique local. | |
| bool | isUnicast () const |
| check if IP address is unicast. | |
| bool | isBroadcast (int prefix=0) const |
| check if IP address is a broadcast address. | |
| bool | isMulticast () const |
| check if IP address is multicast. | |
| bool | isGlobal () const |
| check if IP address is global. | |
| bool | isIpv6Address () const |
| check if IP address is an IPv6 address. | |
| bool | isIpv4Compat () const |
| check if IP address is IPv4 compatible (deprecated). | |
| bool | isIpv4Mapped () const |
| check if IP address is IPv4 mapped. | |
| bool | isIpv4Address () const |
| check if IP address is an IPv4 address. | |
| IpAddress | toIpv6 () const |
| convert IP address to an IPv6 address. | |
| IpAddress | toIpv4 () const |
| convert IP address to an IPv4 address. | |
| std::string | toString () const |
| convert internal address structure to string. | |
| std::string | toArpa () const |
| convert IP address to the in-addr.arpa or ip6.arpa domain name. | |
| void | clear () |
| clear IP address (wilcard address). | |
| IpAddress | operator~ () const |
| perform NOT operation on IP address. | |
| uint8_t & | operator[] (size_t position) |
| returns a reference to the element at the specified location. | |
| const uint8_t & | operator[] (size_t position) const |
| returns a reference to the element at the specified location. | |
Static Public Member Functions | |
| static bool | isIpAddress (const std::string &address) |
| check if the specified string is an IP address. | |
| static bool | isIpv6Address (const std::string &address) |
| check if the specified string is an IPv6 address. | |
| static bool | isIpv4Address (const std::string &address) |
| check if the specified string is an IPv4 address. | |
| static IpAddress | ipv4Address (const std::string &interface) |
| get the specified interface IPv4 address. | |
Static Public Attributes | |
| static const IpAddress | ipv6Wildcard = "::" |
| wildcard IPv6 address. | |
| static const IpAddress | ipv6AllNodes = "ff02::1" |
| all nodes multicast IPv6 address. | |
| static const IpAddress | ipv6SolicitedNodes = "ff02::1:ff00:0" |
| solicited nodes multicast IPv6 address. | |
| static const IpAddress | ipv6Routers = "ff02::2" |
| routers multicast IPv6 address. | |
| static constexpr socklen_t | ipv6Length = 16 |
| IPv6 length. | |
| static const IpAddress | ipv4Wildcard = "0.0.0.0" |
| wildcard IPv4 address. | |
| static const IpAddress | ipv4Broadcast = "255.255.255.255" |
| broadcast IPv4 address. | |
| static constexpr socklen_t | ipv4Length = 4 |
| IPv4 length. | |
IPv6, IPv4 address class.
| IpAddress::IpAddress | ( | ) |
create the IpAddress instance (default: IPv6 wildcard address).
| IpAddress::IpAddress | ( | int | family | ) |
create the IpAddress instance using address family.
| family | address family. |
| IpAddress::IpAddress | ( | const IpAddress & | address | ) |
create the IpAddress instance by copy.
| address | address to copy. |
| IpAddress::IpAddress | ( | IpAddress && | address | ) |
create the IpAddress instance by move.
| address | address to move. |
| IpAddress::IpAddress | ( | const struct sockaddr & | address | ) |
create the IpAddress instance using a sockaddr structure.
| address | address structure to use. |
| invalid_argument | if address is wrong. |
| IpAddress::IpAddress | ( | const void * | address, |
| socklen_t | length ) |
create the IpAddress instance using an in_addr structure or an in6_addr structure.
| address | address structure to use. |
| length | address structure size. |
| invalid_argument | if address is wrong. |
| IpAddress::IpAddress | ( | const void * | address, |
| socklen_t | length, | ||
| uint32_t | scope ) |
create the IpAddress instance using an in_addr structure or an in6_addr structure.
| address | address structure to use. |
| length | address structure size. |
| scope | the scope identifier of the address (ignored when IPv4). |
| invalid_argument | if address is wrong. |
| IpAddress::IpAddress | ( | const std::string & | address, |
| int | family ) |
create the IpAddress instance using a string and address family.
| address | address string to use. |
| family | address family. |
| invalid_argument | if address is wrong. |
| IpAddress::IpAddress | ( | const std::string & | address | ) |
create the IpAddress instance using a string.
| address | address string to use. |
| invalid_argument | if address is wrong. |
| IpAddress::IpAddress | ( | const char * | address, |
| int | family ) |
create the IpAddress instance using a string and address family.
| address | address string to use. |
| family | address family. |
| invalid_argument | if address is wrong. |
| IpAddress::IpAddress | ( | const char * | address | ) |
create the IpAddress instance using a string.
| address | address string to use. |
| invalid_argument | if address is wrong. |
| IpAddress::IpAddress | ( | int | prefix, |
| int | family ) |
create netmask address using prefix length.
| prefix | number of bits to create the netmask address from. |
| family | address family. |
| IpAddress::~IpAddress | ( | ) |
destroy the IpAddress instance.
| const void * IpAddress::addr | ( | ) | const |
get the internal address structure.
| void IpAddress::clear | ( | ) |
clear IP address (wilcard address).
| int IpAddress::family | ( | ) | const |
get address family.
|
static |
get the specified interface IPv4 address.
| interface | interface name. |
| bool IpAddress::isBroadcast | ( | int | prefix = 0 | ) | const |
check if IP address is a broadcast address.
| prefix | prefix length. |
| bool IpAddress::isGlobal | ( | ) | const |
check if IP address is global.
|
static |
check if the specified string is an IP address.
| address | string that may contain an IP address. |
| bool IpAddress::isIpv4Address | ( | ) | const |
check if IP address is an IPv4 address.
|
static |
check if the specified string is an IPv4 address.
| address | string that may contain an IPv4 address. |
| bool IpAddress::isIpv4Compat | ( | ) | const |
check if IP address is IPv4 compatible (deprecated).
| bool IpAddress::isIpv4Mapped | ( | ) | const |
check if IP address is IPv4 mapped.
| bool IpAddress::isIpv6Address | ( | ) | const |
check if IP address is an IPv6 address.
|
static |
check if the specified string is an IPv6 address.
| address | string that may contain an IPv6 address. |
| bool IpAddress::isLinkLocal | ( | ) | const |
check if IP address is link local.
| bool IpAddress::isLoopBack | ( | ) | const |
check if IP address is a loopback address.
| bool IpAddress::isMulticast | ( | ) | const |
check if IP address is multicast.
| bool IpAddress::isSiteLocal | ( | ) | const |
check if IP address is site local (deprecated).
| bool IpAddress::isUnicast | ( | ) | const |
check if IP address is unicast.
| bool IpAddress::isUniqueLocal | ( | ) | const |
check if IP address is unique local.
| bool IpAddress::isWildcard | ( | ) | const |
check if IP address is a wildcard address.
| socklen_t IpAddress::length | ( | ) | const |
get the size in byte of the internal address structure.
assign the IpAddress instance by copy.
| address | address to copy. |
| IpAddress & IpAddress::operator= | ( | const struct sockaddr & | address | ) |
assign the IpAddress using a sockaddr structure.
| address | address structure to use. |
| invalid_argument | if address is wrong. |
assign the IpAddress instance by move.
| address | address to move. |
| uint8_t & IpAddress::operator[] | ( | size_t | position | ) |
returns a reference to the element at the specified location.
| position | position of the element to return. |
| invalid_argument | if position is out of range. |
| const uint8_t & IpAddress::operator[] | ( | size_t | position | ) | const |
returns a reference to the element at the specified location.
| position | position of the element to return. |
| invalid_argument | if position is out of range. |
| IpAddress IpAddress::operator~ | ( | ) | const |
perform NOT operation on IP address.
| int IpAddress::prefix | ( | ) | const |
get prefix length from netmask address.
| uint32_t IpAddress::scope | ( | ) | const |
get the scope identifier of the address.
| std::string IpAddress::toArpa | ( | ) | const |
convert IP address to the in-addr.arpa or ip6.arpa domain name.
| IpAddress IpAddress::toIpv4 | ( | ) | const |
convert IP address to an IPv4 address.
| IpAddress IpAddress::toIpv6 | ( | ) | const |
convert IP address to an IPv6 address.
| std::string IpAddress::toString | ( | ) | const |
convert internal address structure to string.
|
static |
broadcast IPv4 address.
|
staticconstexpr |
IPv4 length.
|
static |
wildcard IPv4 address.
|
static |
all nodes multicast IPv6 address.
|
staticconstexpr |
IPv6 length.
|
static |
routers multicast IPv6 address.
|
static |
solicited nodes multicast IPv6 address.
|
static |
wildcard IPv6 address.