25#ifndef __JOIN_IPADDRESS_HPP__
26#define __JOIN_IPADDRESS_HPP__
36#include <sys/socket.h>
37#include <netinet/in.h>
174 const void*
addr ()
const;
180 socklen_t
length ()
const;
186 uint32_t
scope ()
const;
316 std::string
toArpa ()
const;
350 const uint8_t&
operator[] (
size_t position)
const;
378 std::unique_ptr <IpAddressImpl> _ip;
IPv6, IPv4 address class.
Definition ipaddress.hpp:51
bool isIpv4Mapped() const
check if IP address is IPv4 mapped.
Definition ipaddress.cpp:1430
bool isLinkLocal() const
check if IP address is link local.
Definition ipaddress.cpp:1313
IpAddress & operator=(const IpAddress &address)
assign the IpAddress instance by copy.
Definition ipaddress.cpp:1189
bool isIpv4Address() const
check if IP address is an IPv4 address.
Definition ipaddress.cpp:1439
static const IpAddress ipv6Routers
routers multicast IPv6 address.
Definition ipaddress.hpp:362
static const IpAddress ipv6AllNodes
all nodes multicast IPv6 address.
Definition ipaddress.hpp:356
static const IpAddress ipv6SolicitedNodes
solicited nodes multicast IPv6 address.
Definition ipaddress.hpp:359
IpAddress operator~() const
perform NOT operation on IP address.
Definition ipaddress.cpp:1554
bool isSiteLocal() const
check if IP address is site local (deprecated).
Definition ipaddress.cpp:1322
bool isIpv4Compat() const
check if IP address is IPv4 compatible (deprecated).
Definition ipaddress.cpp:1421
std::string toString() const
convert internal address structure to string.
Definition ipaddress.cpp:1500
static constexpr socklen_t ipv6Length
IPv6 length.
Definition ipaddress.hpp:365
bool isLoopBack() const
check if IP address is a loopback address.
Definition ipaddress.cpp:1304
int prefix() const
get prefix length from netmask address.
Definition ipaddress.cpp:1286
uint32_t scope() const
get the scope identifier of the address.
Definition ipaddress.cpp:1277
uint8_t & operator[](size_t position)
returns a reference to the element at the specified location.
Definition ipaddress.cpp:1574
void clear()
clear IP address (wilcard address).
Definition ipaddress.cpp:1518
bool isBroadcast(int prefix=0) const
check if IP address is a broadcast address.
Definition ipaddress.cpp:1349
int family() const
get address family.
Definition ipaddress.cpp:1250
static const IpAddress ipv4Wildcard
wildcard IPv4 address.
Definition ipaddress.hpp:368
~IpAddress()
destroy the IpAddress instance.
Definition ipaddress.cpp:1242
socklen_t length() const
get the size in byte of the internal address structure.
Definition ipaddress.cpp:1268
static const IpAddress ipv4Broadcast
broadcast IPv4 address.
Definition ipaddress.hpp:371
std::string toArpa() const
convert IP address to the in-addr.arpa or ip6.arpa domain name.
Definition ipaddress.cpp:1509
bool isGlobal() const
check if IP address is global.
Definition ipaddress.cpp:1367
bool isUnicast() const
check if IP address is unicast.
Definition ipaddress.cpp:1331
IpAddress toIpv6() const
convert IP address to an IPv6 address.
Definition ipaddress.cpp:1465
static IpAddress ipv4Address(const std::string &interface)
get the specified interface IPv4 address.
Definition ipaddress.cpp:1527
bool isMulticast() const
check if IP address is multicast.
Definition ipaddress.cpp:1358
static constexpr socklen_t ipv4Length
IPv4 length.
Definition ipaddress.hpp:374
bool isWildcard() const
check if IP address is a wildcard address.
Definition ipaddress.cpp:1295
static bool isIpAddress(const std::string &address)
check if the specified string is an IP address.
Definition ipaddress.cpp:1376
const void * addr() const
get the internal address structure.
Definition ipaddress.cpp:1259
static const IpAddress ipv6Wildcard
wildcard IPv6 address.
Definition ipaddress.hpp:353
IpAddress()
create the IpAddress instance (default: IPv6 wildcard address).
Definition ipaddress.cpp:947
IpAddress toIpv4() const
convert IP address to an IPv4 address.
Definition ipaddress.cpp:1484
bool isUniqueLocal() const
check if IP address is unique local.
Definition ipaddress.cpp:1340
bool isIpv6Address() const
check if IP address is an IPv6 address.
Definition ipaddress.cpp:1394
Definition acceptor.hpp:32
bool operator<(const BasicUnixEndpoint< Protocol > &a, const BasicUnixEndpoint< Protocol > &b) noexcept
compare if endpoint is lower.
Definition endpoint.hpp:207
IpAddress operator^(const IpAddress &a, const IpAddress &b)
perform XOR operation on IP address.
Definition ipaddress.cpp:1720
bool operator>(const BasicUnixEndpoint< Protocol > &a, const BasicUnixEndpoint< Protocol > &b) noexcept
compare if endpoint is greater.
Definition endpoint.hpp:219
IpAddress operator&(const IpAddress &a, const IpAddress &b)
perform AND operation on IP address.
Definition ipaddress.cpp:1666
bool operator!=(const BasicUnixEndpoint< Protocol > &a, const BasicUnixEndpoint< Protocol > &b) noexcept
compare if endpoints are not equal.
Definition endpoint.hpp:195
bool operator>=(const BasicUnixEndpoint< Protocol > &a, const BasicUnixEndpoint< Protocol > &b) noexcept
compare if endpoint is greater or equal.
Definition endpoint.hpp:243
std::ostream & operator<<(std::ostream &os, const BasicUnixEndpoint< Protocol > &endpoint)
push endpoint representation into a stream.
Definition endpoint.hpp:255
bool operator<=(const BasicUnixEndpoint< Protocol > &a, const BasicUnixEndpoint< Protocol > &b) noexcept
compare if endpoint is lower or equal.
Definition endpoint.hpp:231
std::vector< IpAddress > IpAddressList
List of IP address.
Definition ipaddress.hpp:45
IpAddress operator|(const IpAddress &a, const IpAddress &b)
perform OR operation on IP address.
Definition ipaddress.cpp:1693
bool operator==(const BasicUnixEndpoint< Protocol > &a, const BasicUnixEndpoint< Protocol > &b) noexcept
compare if endpoints are equal.
Definition endpoint.hpp:183
IpAddress address
Definition tcpacceptor_test.cpp:35