![]() |
FastEngine 0.9.4
A multiplayer oriented 2D engine made with Vulkan.
|
A class to represent an IP address. More...
#include <C_ipAddress.hpp>
Public Member Functions | |
| IpAddress () noexcept | |
| Build a default invalid IP address. | |
| IpAddress (std::string const &address, CheckHostname check=CheckHostname::Yes) | |
| Build an address from a string. | |
| IpAddress (char const *address, CheckHostname check=CheckHostname::Yes) | |
| IpAddress (uint8_t byte3, uint8_t byte2, uint8_t byte1, uint8_t byte0) noexcept | |
| Build an ipv4 address from 4 bytes. | |
| IpAddress (std::initializer_list< uint16_t > words) noexcept | |
| Build an ipv4 address from 8 words in host byte order. | |
| IpAddress (Ipv6Data const &data) noexcept | |
| Build an ipv4 address from Ipv6Data in host byte order. | |
| IpAddress (Ipv4Data address) noexcept | |
| Build an ipv4 address from a host byte order integer. | |
| bool | set (std::string const &address, CheckHostname check=CheckHostname::Yes) |
| Build an address from a string. | |
| bool | set (char const *address, CheckHostname check=CheckHostname::Yes) |
| bool | set (uint8_t byte3, uint8_t byte2, uint8_t byte1, uint8_t byte0) |
| Build an ipv4 address from 4 bytes. | |
| bool | set (std::initializer_list< uint16_t > words) |
| Build an ipv6 address from 8 words in host byte order. | |
| bool | set (Ipv6Data const &data) |
| Build an ipv6 address from Ipv6Data in host byte order. | |
| bool | set (uint8_t const bytes[16]) |
| Build an ipv6 address from a host byte order array of bytes. | |
| bool | set (Ipv4Data address) |
| Build an ipv4 address from a host byte order integer. | |
| bool | setNetworkByteOrdered (Ipv4Data address) |
| Build an ipv4 address from a network byte order integer. | |
| bool | setNetworkByteOrdered (Ipv6Data const &data) |
| Build an ipv6 address from a network byte order data. | |
| bool | setNetworkByteOrdered (uint8_t const bytes[16]) |
| Build an ipv6 address from a network byte order array of bytes. | |
| bool | operator== (IpAddress const &r) const |
| std::optional< std::string > | toString () const |
| Get the ip address in a string format. | |
| std::optional< Data > | getNetworkByteOrder () const |
| Get the ip address in a network byte order. | |
| std::optional< Data > | getHostByteOrder () const |
| Get the ip address in host byte order. | |
| Types | getType () const |
| std::optional< IpAddress > | mapToIpv6 () const |
| Map an ipv4 address to an ipv6 address. | |
| std::optional< IpAddress > | mapToIpv4 () const |
| Map an ipv6 (ipv4-mapped) address back to an ipv4 address. | |
| bool | isIpv4MappedIpv6 () const |
Static Public Member Functions | |
| static std::optional< std::string > | getHostName () |
| Get the standard hostname for the local computer. | |
| static std::vector< IpAddress > | getLocalAddresses (Types type=Types::None) |
| Get a list of local IpAddress of the local computer. | |
| static IpAddress | Any (Types addressType) |
| static IpAddress | Loopback (Types addressType) |
Static Public Attributes | |
| static IpAddress const | None |
| Represent an invalid address. | |
| static IpAddress const | Ipv4Any |
| Represent an unspecified ipv4 address "0.0.0.0". | |
| static IpAddress const | Ipv6Any |
| Represent an unspecified ipv6 address "::". | |
| static IpAddress const | Ipv4Loopback |
| Represent the local host ipv4 address "127.0.0.1". | |
| static IpAddress const | Ipv6Loopback |
| Represent the local host ipv6 address "::1". | |
| static IpAddress const | Ipv4Broadcast |
| Represent the broadcast ipv4 address "255.255.255.255". | |
Friends | |
| struct | std::hash< IpAddress > |
A class to represent an IP address.
This class will automatically handle the byte order of the IP address.
|
noexcept |
Build a default invalid IP address.
| fge::net::IpAddress::IpAddress | ( | std::string const & | address, |
| CheckHostname | check = CheckHostname::Yes ) |
Build an address from a string.
The string can be in the ipv4 form XXX.XXX.XXX.XXX, ipv6, or a hostname.
| address | A string representing the address |
| check | Control if the method should check if the address is a hostname or not |
|
noexcept |
Build an ipv4 address from 4 bytes.
| byte3 | The most significant byte |
| byte2 | The second most significant byte |
| byte1 | The second least significant byte |
| byte0 | The least significant byte |
|
noexcept |
Build an ipv4 address from 8 words in host byte order.
| words | The 8 words representing the ipv6 address in host byte order |
|
noexcept |
Build an ipv4 address from Ipv6Data in host byte order.
| data | The Ipv6Data representing the address in host byte order |
|
noexcept |
Build an ipv4 address from a host byte order integer.
| address | The host byte order integer |
|
nodiscard |
Get the ip address in host byte order.
|
staticnodiscard |
Get the standard hostname for the local computer.
|
staticnodiscard |
Get a list of local IpAddress of the local computer.
| type | The type of address to get, if None, all addresses will be returned |
|
nodiscard |
Get the ip address in a network byte order.
|
nodiscard |
Map an ipv6 (ipv4-mapped) address back to an ipv4 address.
|
nodiscard |
Map an ipv4 address to an ipv6 address.
When using a socket that can communicate with both ipv4 and ipv6, you have to map the ipv4 address to an ipv6 address.
FROM MSDN:
Dual-stack sockets always require IPv6 addresses. The ability to interact with an IPv4 address requires the use of the IPv4-mapped IPv6 address format. Any IPv4 addresses must be represented in the IPv4-mapped IPv6 address format which enables an IPv6 only application to communicate with an IPv4 node. The IPv4-mapped IPv6 address format allows the IPv4 address of an IPv4 node to be represented as an IPv6 address. The IPv4 address is encoded into the low-order 32 bits of the IPv6 address, and the high-order 96 bits hold the fixed prefix 0:0:0:0:0:FFFF. The IPv4-mapped IPv6 address format is specified in RFC 4291.
| bool fge::net::IpAddress::set | ( | Ipv4Data | address | ) |
Build an ipv4 address from a host byte order integer.
| address | The host byte order integer |
| bool fge::net::IpAddress::set | ( | Ipv6Data const & | data | ) |
Build an ipv6 address from Ipv6Data in host byte order.
| data | The Ipv6Data representing the ipv6 address in host byte order |
| bool fge::net::IpAddress::set | ( | std::initializer_list< uint16_t > | words | ) |
Build an ipv6 address from 8 words in host byte order.
Manualy build an ipv6 address with a initializer list.
| words | The 8 words representing the ipv6 address in host byte order |
| bool fge::net::IpAddress::set | ( | std::string const & | address, |
| CheckHostname | check = CheckHostname::Yes ) |
Build an address from a string.
The string can be in the ipv4 form XXX.XXX.XXX.XXX, ipv6, or a hostname.
| address | A string representing the address |
| check | Control if the method should check if the address is a hostname or not |
| bool fge::net::IpAddress::set | ( | uint8_t | byte3, |
| uint8_t | byte2, | ||
| uint8_t | byte1, | ||
| uint8_t | byte0 ) |
Build an ipv4 address from 4 bytes.
| byte3 | The most significant byte |
| byte2 | The second most significant byte |
| byte1 | The second least significant byte |
| byte0 | The least significant byte |
| bool fge::net::IpAddress::set | ( | uint8_t const | bytes[16] | ) |
Build an ipv6 address from a host byte order array of bytes.
| bytes | The host byte order array |
| bool fge::net::IpAddress::setNetworkByteOrdered | ( | Ipv4Data | address | ) |
Build an ipv4 address from a network byte order integer.
| address | The network byte order integer |
| bool fge::net::IpAddress::setNetworkByteOrdered | ( | Ipv6Data const & | data | ) |
Build an ipv6 address from a network byte order data.
| data | The network byte order data |
| bool fge::net::IpAddress::setNetworkByteOrdered | ( | uint8_t const | bytes[16] | ) |
Build an ipv6 address from a network byte order array of bytes.
| bytes | The network byte order array |
|
nodiscard |
Get the ip address in a string format.
|
static |
Represent an unspecified ipv4 address "0.0.0.0".
|
static |
Represent the broadcast ipv4 address "255.255.255.255".
|
static |
Represent the local host ipv4 address "127.0.0.1".
|
static |
Represent an unspecified ipv6 address "::".
|
static |
Represent the local host ipv6 address "::1".
|
static |
Represent an invalid address.