25#ifndef JOIN_CORE_MACADDRESS_HPP
26#define JOIN_CORE_MACADDRESS_HPP
52 using iterator = std::array<uint8_t, IFHWADDRLEN>::iterator;
132 const uint8_t*
addr ()
const;
138 socklen_t
length ()
const;
297 const uint8_t&
operator[] (
size_t position)
const;
313 std::array<uint8_t, IFHWADDRLEN> _mac = {};
322 MacAddress
operator+ (
int value,
const MacAddress& a);
330 MacAddress
operator+ (
const MacAddress& a,
int value);
338 bool operator== (
const MacAddress& a,
const MacAddress& b);
346 bool operator!= (
const MacAddress& a,
const MacAddress& b);
354 bool operator< (
const MacAddress& a,
const MacAddress& b);
362 bool operator<= (
const MacAddress& a,
const MacAddress& b);
370 bool operator> (
const MacAddress& a,
const MacAddress& b);
378 bool operator>= (
const MacAddress& a,
const MacAddress& b);
386 MacAddress
operator& (
const MacAddress& a,
const MacAddress& b);
394 MacAddress
operator| (
const MacAddress& a,
const MacAddress& b);
402 MacAddress
operator^ (
const MacAddress& a,
const MacAddress& b);
410 std::ostream&
operator<< (std::ostream& out,
const MacAddress& a);
IPv6, IPv4 address class.
Definition ipaddress.hpp:51
MAC address class.
Definition macaddress.hpp:46
socklen_t length() const
get the size in byte of the internal MAC address array.
Definition macaddress.cpp:173
void clear()
clear MAC address (wilcard address).
Definition macaddress.cpp:292
bool isBroadcast() const
check if MAC address is a broadcast address.
Definition macaddress.cpp:191
~MacAddress()=default
destroy the MacAddress instance.
static const MacAddress broadcast
broadcast MAC address.
Definition macaddress.hpp:309
std::array< uint8_t, IFHWADDRLEN >::iterator iterator
iterator from nested container.
Definition macaddress.hpp:52
int family() const
get address family.
Definition macaddress.cpp:155
iterator begin()
returns an iterator to the first element of the nested container.
Definition macaddress.cpp:301
MacAddress()
create the MacAddress instance (wilcard address).
Definition macaddress.cpp:55
IpAddress toUniqueLocalIpv6() const
convert MAC address to a unique local IPv6 address using eui-64.
Definition macaddress.cpp:272
static bool isMacAddress(const std::string &address)
check if the specified string is a MAC address.
Definition macaddress.cpp:201
bool isWildcard() const
check if MAC address is a wildcard address.
Definition macaddress.cpp:182
MacAddress & operator+=(int value)
add the provided value to the current MAC address.
Definition macaddress.cpp:432
MacAddress operator~() const
perform NOT operation on MAC address.
Definition macaddress.cpp:496
MacAddress & operator=(const MacAddress &address)
assign the MacAddress instance by copy.
Definition macaddress.cpp:381
const_iterator cbegin() const
returns an iterator to the first element of the nested container.
Definition macaddress.cpp:319
std::array< uint8_t, IFHWADDRLEN >::const_iterator const_iterator
constant iterator from nested container.
Definition macaddress.hpp:55
MacAddress & operator++()
perform pre-increment operation on MAC address.
Definition macaddress.cpp:448
IpAddress toLinkLocalIpv6() const
convert MAC address to a link local IPv6 address.
Definition macaddress.cpp:258
std::ios_base &(std::ios_base &) CaseConvert
case conversion function.
Definition macaddress.hpp:49
const_iterator cend() const
return an iterator to the element following the last element of the nested container.
Definition macaddress.cpp:346
static const MacAddress wildcard
wildcard MAC address.
Definition macaddress.hpp:306
IpAddress toIpv6(const IpAddress &prefix, int len) const
convert MAC address to IPv6 address using prefix.
Definition macaddress.cpp:238
std::string toString(CaseConvert caseConvert=std::nouppercase) const
convert internal address array to string.
Definition macaddress.cpp:219
const uint8_t * addr() const
get the internal MAC address array address.
Definition macaddress.cpp:164
uint8_t & operator[](size_t position)
returns a reference to the element at the specified location.
Definition macaddress.cpp:468
iterator end()
return an iterator to the element following the last element of the nested container.
Definition macaddress.cpp:328
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:1719
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:1665
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
IpAddress operator|(const IpAddress &a, const IpAddress &b)
perform OR operation on IP address.
Definition ipaddress.cpp:1692
bool operator==(const BasicUnixEndpoint< Protocol > &a, const BasicUnixEndpoint< Protocol > &b) noexcept
compare if endpoints are equal.
Definition endpoint.hpp:183
MacAddress operator+(int value, const MacAddress &a)
add the provided value to the provided MAC address.
Definition macaddress.cpp:512
IpAddress address
Definition tcpacceptor_test.cpp:35