26#ifndef MYSQL_HARNESS_NET_TS_INTERNET_H_
27#define MYSQL_HARNESS_NET_TS_INTERNET_H_
35#include <forward_list>
38#include <system_error>
47#include <netinet/in.h>
48#include <netinet/ip6.h>
49#include <netinet/tcp.h>
70 if (std::endian::native == std::endian::big)
return t;
83 if (std::endian::native == std::endian::big)
return t;
99 : array<unsigned char, 4>{{
static_cast<unsigned char>(t)...}} {}
117 return (
to_uint() & 0xff000000) == 0x7f000000;
120 return (
to_uint() & 0xf0000000) == 0xe0000000;
123 template <
class Allocator = std::allocator<
char>>
124 std::basic_string<char, std::char_traits<char>, Allocator>
to_string(
125 const Allocator &a = Allocator())
const {
126 std::basic_string<char, std::char_traits<char>, Allocator> out(a);
127 out.resize(INET_ADDRSTRLEN);
129 if (
nullptr != ::inet_ntop(AF_INET, &
addr_, &out.front(), out.size())) {
130 out.erase(out.find(
'\0'));
161 return a.to_uint() == b.to_uint();
167 return a.to_uint() < b.to_uint();
186 template <
class... T>
188 : array<unsigned char, 16>{{
static_cast<unsigned char>(t)...}} {}
202 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
203 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
211 return (
bytes_[0] == 0xfe) && (
bytes_[1] & 0xc0) == 0x80;
214 return (
bytes_[0] == 0xfe) && (
bytes_[1] & 0xc0) == 0xc0;
247 template <
class Allocator = std::allocator<
char>>
248 std::basic_string<char, std::char_traits<char>, Allocator>
to_string(
249 const Allocator &a = Allocator())
const {
250 std::basic_string<char, std::char_traits<char>, Allocator> out(a);
251 out.resize(INET6_ADDRSTRLEN);
254 ::inet_ntop(AF_INET6,
bytes_.data(), &out.front(), out.size())) {
255 out.erase(out.find(
'\0'));
280 auto const aa = a.to_bytes();
281 auto const bb = b.to_bytes();
285 for (; ndx != aa.size() && aa[ndx] == bb[ndx]; ++ndx)
288 return (ndx == aa.size()) ? a.scope_id() == b.scope_id() :
false;
294 auto const aa = a.to_bytes();
295 auto const bb = b.to_bytes();
299 for (; ndx != aa.size() && aa[ndx] == bb[ndx]; ++ndx)
302 return (ndx == aa.size()) ? a.scope_id() < b.scope_id() : aa[ndx] < bb[ndx];
315 return *
this == any();
318 return *
this == loopback();
323 constexpr address() noexcept : v4_{}, is_v4_{
true} {}
327 constexpr bool is_v4() const noexcept {
return is_v4_; }
328 constexpr bool is_v6() const noexcept {
return !is_v4_; }
347 return is_v4() ? v4_.is_unspecified() : v6_.is_unspecified();
350 return is_v4() ? v4_.is_loopback() : v6_.is_loopback();
353 return is_v4() ? v4_.is_multicast() : v6_.is_multicast();
361 template <
class Allocator = std::allocator<
char>>
362 std::basic_string<char, std::char_traits<char>, Allocator>
to_string(
363 const Allocator &a = Allocator())
const {
364 return is_v4() ? v4_.to_string(a) : v6_.to_string(a);
393 if (
const char *percent = strchr(
str,
'%')) {
394 const char *after_percent = percent + 1;
396 if (*after_percent ==
'\0' || *after_percent ==
'-' ||
397 *after_percent ==
'+') {
402 scope_id = ::strtoul(after_percent, &
err, 10);
407 std::string before_percent(
str, percent);
409 inet_pton_res = ::inet_pton(AF_INET6, before_percent.c_str(), &ipv6_addr);
411 inet_pton_res = ::inet_pton(AF_INET6,
str, &ipv6_addr);
413 if (inet_pton_res == 1) {
416 return ret_type{std::in_place, ipv6_addr, scope_id};
417 }
else if (inet_pton_res == 0) {
436 int res = ::inet_pton(AF_INET,
str, &ipv4_addr);
439 }
else if (res == 0) {
461 if (v4_res)
return address{*v4_res};
474 const std::string &
str) {
478template <
class CharT,
class Traits>
480 std::basic_ostream<CharT, Traits> &os,
const address &addr) {
481 os << addr.to_string().c_str();
487 if (a.is_v4() && b.is_v4())
return a.to_v4() == b.to_v4();
488 if (a.is_v6() && b.is_v6())
return a.to_v6() == b.to_v6();
499 if (a.is_v4() && !b.is_v4())
return true;
500 if (!a.is_v4() && b.is_v4())
return false;
503 if (a.is_v4())
return a.to_v4() < b.to_v4();
504 return a.to_v6() < b.to_v6();
512template <
typename InternetProtocol>
521 std::string service_name)
523 host_name_{
std::move(host_name)},
524 service_name_{
std::move(service_name)} {}
538template <
typename InternetProtocol>
541template <
typename InternetProtocol>
558 bool empty() const noexcept {
return results_.empty(); }
569 const std::string &host_name,
570 const std::string &service_name) {
573 auto tail = results_.before_begin();
574 for (
const auto *cur = ainfo.get(); cur !=
nullptr; cur = cur->ai_next) {
575 std::memcpy(ep.data(), cur->ai_addr, cur->ai_addrlen);
577 tail = results_.emplace_after(tail, ep, host_name, service_name);
583 const std::string &service_name) {
584 auto tail = results_.before_begin();
586 tail = results_.emplace_after(tail, ep, host_name, service_name);
598 static constexpr flags passive = AI_PASSIVE;
599 static constexpr flags canonical_name = AI_CANONNAME;
600 static constexpr flags numeric_host = AI_NUMERICHOST;
601 static constexpr flags numeric_service = AI_NUMERICSERV;
602 static constexpr flags v4_mapped = AI_V4MAPPED;
603 static constexpr flags all_matching = AI_ALL;
604 static constexpr flags address_configured = AI_ADDRCONFIG;
607template <
typename InternetProtocol>
619 const std::string &host_name,
const std::string &service_name,
flags f) {
623 hints.ai_family = AF_UNSPEC;
624 hints.ai_socktype = proto.type();
625 hints.ai_protocol = proto.protocol();
628 hints.ai_flags =
static_cast<decltype(hints.ai_flags)
>(f.to_ulong());
630 auto res = io_ctx_.socket_service()->getaddrinfo(
631 host_name.empty() ?
nullptr : host_name.c_str(),
632 service_name.empty() ?
nullptr : service_name.c_str(), &hints);
636 return results_type{std::move(res.value()), host_name, service_name};
639 const std::string &host_name,
const std::string &service_name) {
640 return resolve(host_name, service_name,
flags{});
644 std::array<char, NI_MAXHOST> host_name;
645 std::array<char, NI_MAXSERV> service_name;
654 static_cast<const struct
sockaddr *
>(ep.data()), ep.size(),
655 host_name.data(), host_name.size(), service_name.data(),
656 service_name.size(),
flags);
662 const auto name_end =
std::find(host_name.begin(), host_name.end(),
'\0');
663 const auto serv_end =
664 std::find(service_name.begin(), service_name.end(),
'\0');
668 std::string{host_name.
begin(), name_end},
669 std::string{service_name.begin(), serv_end},
677template <
typename InternetProtocol>
689 data_.v4.sin_family = protocol_type::v4().family();
701 data_.v4.sin_family =
decltype(data_.v4.sin_family)(proto.family());
711 data_.v4.sin_family = protocol_type::v4().family();
714 auto addr_b = addr.to_v4().to_bytes();
718 reinterpret_cast<unsigned char *
>(&data_.v4.sin_addr.s_addr));
721 data_.v6.sin6_family = protocol_type::v6().family();
724 auto addr_b = addr.to_v6().to_bytes();
725 std::copy(addr_b.begin(), addr_b.end(), data_.v6.sin6_addr.s6_addr);
727 data_.v6.sin6_scope_id = addr.to_v6().scope_id();
735 return data_.v4.sin_family == AF_INET ? protocol_type::v4()
736 : protocol_type::v6();
743 if (protocol().family() == protocol_type::v4().family())
748 std::copy(data_.v6.sin6_addr.s6_addr, data_.v6.sin6_addr.s6_addr + 16,
757 return data_.v4.sin_family == AF_INET ?
network_to_host(data_.v4.sin_port)
764 const void *
data() const noexcept {
return &data_; }
769 void *
data() noexcept {
return &data_; }
775 return data_.v4.sin_family == AF_INET ?
sizeof(sockaddr_in)
776 :
sizeof(sockaddr_in6);
782 constexpr size_t capacity() const noexcept {
return sizeof(data_); }
801 if (
n > capacity())
throw std::length_error(
"n > capacity()");
811template <
class CharT,
class Traits,
class InternetProtocol>
813 std::basic_ostream<CharT, Traits> &os,
814 const basic_endpoint<InternetProtocol> &ep) {
815 std::basic_ostringstream<CharT, Traits> ss;
816 if (ep.protocol() == basic_endpoint<InternetProtocol>::protocol_type::v6()) {
817 ss <<
"[" << ep.address() <<
"]";
821 ss <<
":" << ep.port();
830template <
class InternetProtocol>
833 return a.port() == b.port() && a.address() == b.address();
836template <
class InternetProtocol>
843template <
class Address>
881 return addr_ == rhs.addr_;
885 return addr_ != rhs.addr_;
929template <
class Address>
943 : begin_{first}, end_{last} {}
948 bool empty() const noexcept {
return begin_ == end_; }
949 size_t size() const noexcept {
return end_->to_uint() - begin_->to_uint(); }
952 if (*begin_ <= addr && addr < *end_)
return iterator{addr};
974 : addr_{addr}, prefix_len_{prefix_len} {}
977 auto m =
mask.to_uint();
978 uint32_t t{1U << 31U};
981 for (; sh < 32; ++sh) {
982 if ((m & t) == 0)
break;
998 v <<= 32U - prefix_len_;
1006 auto mask = netmask().to_uint();
1012 return {network(), prefix_length()};
1014 constexpr bool is_host() const noexcept {
return prefix_length() == 32; }
1015 constexpr bool is_subnet_of(
const network_v4 &other)
const noexcept;
1017 template <
class Allocator = std::allocator<
char>>
1018 std::basic_string<char, std::char_traits<char>, Allocator>
to_string(
1019 const Allocator &a = Allocator())
const {
1030 return a.address() == b.address() && a.prefix_length() == b.prefix_length();
1035 return other.prefix_length() < prefix_length() &&
1043template <
class CharT,
class Traits>
1044std::basic_ostream<CharT, Traits> &
operator<<(
1045 std::basic_ostream<CharT, Traits> &os,
const network_v4 &
net) {
1046 os <<
net.to_string().c_str();
1057 : addr_{addr}, prefix_len_{prefix_len} {}
1063 const auto address_bytes =
address().to_bytes();
1065 networkbits(address_bytes, prefix_len_, 0),
1066 networkbits(address_bytes, prefix_len_, 1),
1067 networkbits(address_bytes, prefix_len_, 2),
1068 networkbits(address_bytes, prefix_len_, 3),
1069 networkbits(address_bytes, prefix_len_, 4),
1070 networkbits(address_bytes, prefix_len_, 5),
1071 networkbits(address_bytes, prefix_len_, 6),
1072 networkbits(address_bytes, prefix_len_, 7),
1073 networkbits(address_bytes, prefix_len_, 8),
1074 networkbits(address_bytes, prefix_len_, 9),
1075 networkbits(address_bytes, prefix_len_, 10),
1076 networkbits(address_bytes, prefix_len_, 11),
1077 networkbits(address_bytes, prefix_len_, 12),
1078 networkbits(address_bytes, prefix_len_, 13),
1079 networkbits(address_bytes, prefix_len_, 14),
1080 networkbits(address_bytes, prefix_len_, 15),
1087 return {network(), prefix_length()};
1089 constexpr bool is_host() const noexcept {
return prefix_length() == 128; }
1090 constexpr bool is_subnet_of(
const network_v6 &other)
const noexcept;
1092 template <
class Allocator = std::allocator<
char>>
1093 std::basic_string<char, std::char_traits<char>, Allocator>
to_string(
1094 const Allocator &a = Allocator())
const {
1102 return address_bytes[ndx] & leftmostbits(ndx, prefix_len);
1106 int bitndx = ndx * 8;
1108 if (bitndx > prefix_len)
return 0;
1109 prefix_len -= bitndx;
1110 if (prefix_len >= 8)
return 0xff;
1112 return 0xff << (8 - prefix_len);
1121 return a.address() == b.address() && a.prefix_length() == b.prefix_length();
1126 return other.prefix_length() < prefix_length() &&
1134template <
class CharT,
class Traits>
1135std::basic_ostream<CharT, Traits> &
operator<<(
1136 std::basic_ostream<CharT, Traits> &os,
const network_v6 &
net) {
1137 os <<
net.to_string().c_str();
1162#ifdef TCP_CONGESTION
1170#ifdef TCP_DEFER_ACCEPT
1174#ifdef TCP_EXPEDITED_1122
1176 using expedited_rfc1122 =
1184#ifdef TCP_FASTOPEN_CONNECT
1186 using fast_open_connect =
1247#ifdef TCP_USER_TIMEOUT
1251#ifdef TCP_WINDOW_CLAMP
1255#ifdef TCP_TIMESTAMPS
1259#ifdef TCP_NOTSENT_LOWAT
1299 static constexpr tcp v4() noexcept {
return tcp{AF_INET}; }
1300 static constexpr tcp v6() noexcept {
return tcp{AF_INET6}; }
1302 constexpr int family() const noexcept {
return family_; }
1303 constexpr int type() const noexcept {
return SOCK_STREAM; }
1309 constexpr explicit tcp(
int family) : family_{family} {}
1315 return a.family() == b.family() && a.type() == b.type();
1330 static constexpr udp v4() noexcept {
return udp{AF_INET}; }
1331 static constexpr udp v6() noexcept {
return udp{AF_INET6}; }
1333 constexpr int family() const noexcept {
return family_; }
1334 constexpr int type() const noexcept {
return SOCK_DGRAM; }
1335 constexpr int protocol() const noexcept {
return IPPROTO_UDP; }
1340 constexpr explicit udp(
int family) : family_{family} {}
1348 return a.family() == b.family() && a.type() == b.type();
Kerberos Client Authentication nullptr
Definition: auth_kerberos_client_plugin.cc:251
Definition: socket.h:1293
Definition: socket.h:1090
Definition: io_context.h:991
Definition: io_context.h:61
Definition: internet.h:93
bytes_type addr_
Definition: internet.h:156
static constexpr address_v4 any() noexcept
Definition: internet.h:147
constexpr bool is_loopback() const noexcept
Definition: internet.h:116
constexpr address_v4(uint_type val)
Definition: internet.h:104
constexpr uint_type to_uint() const noexcept
Definition: internet.h:143
constexpr address_v4(const bytes_type &b)
Definition: internet.h:113
constexpr address_v4() noexcept
Definition: internet.h:103
uint_least32_t uint_type
Definition: internet.h:95
constexpr bool is_unspecified() const noexcept
Definition: internet.h:115
static constexpr address_v4 loopback() noexcept
Definition: internet.h:148
constexpr bool is_multicast() const noexcept
Definition: internet.h:119
std::basic_string< char, std::char_traits< char >, Allocator > to_string(const Allocator &a=Allocator()) const
Definition: internet.h:124
constexpr bytes_type to_bytes() const noexcept
Definition: internet.h:140
static constexpr address_v4 broadcast() noexcept
Definition: internet.h:151
IPv6 address with scope_id.
Definition: internet.h:182
constexpr bool is_multicast_site_local() const noexcept
Definition: internet.h:228
constexpr bool is_multicast_org_local() const noexcept
Definition: internet.h:231
constexpr bool is_multicast_link_local() const noexcept
Definition: internet.h:225
constexpr address_v6(const bytes_type &bytes, scope_id_type scope_id=0) noexcept
Definition: internet.h:192
constexpr bool is_v4_mapped() const noexcept
Definition: internet.h:216
constexpr address_v6() noexcept
Definition: internet.h:191
constexpr scope_id_type scope_id() const noexcept
Definition: internet.h:240
std::basic_string< char, std::char_traits< char >, Allocator > to_string(const Allocator &a=Allocator()) const
convert an address_v6 into a string.
Definition: internet.h:248
static constexpr address_v6 loopback()
Definition: internet.h:200
constexpr bool is_multicast() const noexcept
Definition: internet.h:209
constexpr bool is_loopback() const noexcept
Definition: internet.h:317
constexpr bytes_type to_bytes() const noexcept
Definition: internet.h:238
static constexpr address_v6 any()
Definition: internet.h:197
constexpr bool is_site_local() const noexcept
Definition: internet.h:213
constexpr bool is_unspecified() const noexcept
Definition: internet.h:314
constexpr bool is_multicast_node_local() const noexcept
Definition: internet.h:222
constexpr bool is_multicast_global() const noexcept
Definition: internet.h:234
bytes_type bytes_
Definition: internet.h:269
constexpr bool is_link_local() const noexcept
Definition: internet.h:210
scope_id_type scope_id_
Definition: internet.h:270
Definition: internet.h:321
constexpr address_v4 to_v4() const
get address_v4 part.
Definition: internet.h:335
constexpr bool is_v6() const noexcept
Definition: internet.h:328
constexpr bool is_multicast() const noexcept
Definition: internet.h:352
constexpr bool is_v4() const noexcept
Definition: internet.h:327
bool is_v4_
Definition: internet.h:373
address_v6 v6_
Definition: internet.h:370
constexpr address(const address_v4 &a) noexcept
Definition: internet.h:324
constexpr address() noexcept
Definition: internet.h:323
constexpr address_v6 to_v6() const
get address_v6 part.
Definition: internet.h:343
std::basic_string< char, std::char_traits< char >, Allocator > to_string(const Allocator &a=Allocator()) const
convert an address into a string.
Definition: internet.h:362
constexpr bool is_unspecified() const noexcept
Definition: internet.h:346
constexpr bool is_loopback() const noexcept
Definition: internet.h:349
address_v4 v4_
Definition: internet.h:369
constexpr address(const address_v6 &a) noexcept
Definition: internet.h:325
Definition: internet.h:273
bad_address_cast() noexcept=default
Definition: internet.h:847
basic_address_iterator operator--(int) noexcept
Definition: internet.h:874
basic_address_iterator & operator++() noexcept
Definition: internet.h:859
basic_address_iterator & operator--() noexcept
Definition: internet.h:869
basic_address_iterator(const value_type &a) noexcept
Definition: internet.h:855
std::input_iterator_tag iterator_category
Definition: internet.h:853
ptrdiff_t difference_type
Definition: internet.h:850
bool operator==(const basic_address_iterator &rhs) const noexcept
Definition: internet.h:880
bool operator!=(const basic_address_iterator &rhs) const noexcept
Definition: internet.h:884
basic_address_iterator operator++(int) noexcept
Definition: internet.h:864
reference operator*() const noexcept
Definition: internet.h:857
pointer operator->() const noexcept
Definition: internet.h:858
value_type addr_
Definition: internet.h:889
Definition: internet.h:893
pointer operator->() const noexcept
Definition: internet.h:904
value_type addr_
Definition: internet.h:921
basic_address_iterator & operator++() noexcept
reference operator*() const noexcept
Definition: internet.h:903
basic_address_iterator(const value_type &a) noexcept
Definition: internet.h:901
basic_address_iterator & operator--() noexcept
std::input_iterator_tag iterator_category
Definition: internet.h:899
ptrdiff_t difference_type
Definition: internet.h:896
Definition: internet.h:844
Definition: internet.h:936
iterator find(const value_type &addr) const noexcept
Definition: internet.h:951
basic_address_range(const value_type &first, const value_type &last) noexcept
Definition: internet.h:942
basic_address_range() noexcept
Definition: internet.h:941
size_t size() const noexcept
Definition: internet.h:949
bool empty() const noexcept
Definition: internet.h:948
iterator end_
Definition: internet.h:959
iterator begin_
Definition: internet.h:958
iterator begin() const noexcept
Definition: internet.h:945
iterator end() const noexcept
Definition: internet.h:946
Definition: internet.h:963
Definition: internet.h:930
Definition: internet.h:678
const void * data() const noexcept
const pointer to the underlying sockaddr.
Definition: internet.h:764
size_t size_type
Definition: internet.h:681
constexpr size_type size() const noexcept
size of the underlying sockaddr.
Definition: internet.h:774
constexpr basic_endpoint(const protocol_type &proto, port_type port_num) noexcept
construct from protocol and port-number.
Definition: internet.h:697
void resize(size_type n)
set the size of valid data of the underlying sockaddr.
Definition: internet.h:800
void * data() noexcept
pointer to the underlying sockaddr.
Definition: internet.h:769
constexpr size_t capacity() const noexcept
get capacity of the underlying sockaddr.
Definition: internet.h:782
constexpr basic_endpoint(const ip::address &addr, port_type port_num) noexcept
construct from address and port-number.
Definition: internet.h:708
constexpr protocol_type protocol() const noexcept
get protocol of the endpoint.
Definition: internet.h:734
InternetProtocol protocol_type
Definition: internet.h:680
sockaddr_in v4
Definition: internet.h:806
constexpr basic_endpoint()
default constructor.
Definition: internet.h:688
sockaddr_in6 v6
Definition: internet.h:807
constexpr ip::address address() const noexcept
get address of the endpoint.
Definition: internet.h:742
constexpr port_type port() const noexcept
get port of the endpoint.
Definition: internet.h:756
endpoint of IPv4/IPv6 based connection.
Definition: internet.h:513
basic_resolver_entry(const endpoint_type &ep, std::string host_name, std::string service_name)
Definition: internet.h:520
std::string host_name() const
Definition: internet.h:528
basic_resolver_entry()=default
endpoint_type ep_
Definition: internet.h:532
typename protocol_type::endpoint endpoint_type
Definition: internet.h:516
endpoint_type endpoint() const
Definition: internet.h:526
std::string host_name_
Definition: internet.h:533
std::string service_name_
Definition: internet.h:534
InternetProtocol protocol_type
Definition: internet.h:515
std::string service_name() const
Definition: internet.h:529
Definition: internet.h:542
const_iterator iterator
Definition: internet.h:550
typename protocol_type::endpoint endpoint_type
Definition: internet.h:545
InternetProtocol protocol_type
Definition: internet.h:544
size_type max_size() const noexcept
Definition: internet.h:557
const_iterator cbegin() const
Definition: internet.h:562
basic_resolver_results(std::unique_ptr< addrinfo, void(*)(addrinfo *)> ainfo, const std::string &host_name, const std::string &service_name)
Definition: internet.h:568
ptrdiff_t difference_type
Definition: internet.h:551
std::forward_list< value_type > results_
Definition: internet.h:590
basic_resolver_results(const endpoint_type &ep, const std::string &host_name, const std::string &service_name)
Definition: internet.h:582
typename std::forward_list< value_type >::const_iterator const_iterator
Definition: internet.h:549
bool empty() const noexcept
Definition: internet.h:558
const_iterator begin() const
Definition: internet.h:560
const_iterator end() const
Definition: internet.h:561
basic_resolver_results()=default
size_type size() const noexcept
Definition: internet.h:556
size_t size_type
Definition: internet.h:552
Definition: internet.h:608
stdx::expected< results_type, error_type > resolve(const endpoint_type &ep)
Definition: internet.h:643
typename InternetProtocol::endpoint endpoint_type
Definition: internet.h:612
InternetProtocol protocol_type
Definition: internet.h:611
impl::socket::error_type error_type
Definition: internet.h:614
stdx::expected< results_type, error_type > resolve(const std::string &host_name, const std::string &service_name)
Definition: internet.h:638
basic_resolver(io_context &io_ctx)
Definition: internet.h:616
io_context & io_ctx_
Definition: internet.h:674
stdx::expected< results_type, error_type > resolve(const std::string &host_name, const std::string &service_name, flags f)
Definition: internet.h:618
Definition: internet.h:970
constexpr bool is_subnet_of(const network_v4 &other) const noexcept
Definition: internet.h:1033
constexpr address_v4 network() const noexcept
Definition: internet.h:1002
constexpr int prefix_length() const noexcept
Definition: internet.h:994
constexpr network_v4(const address_v4 &addr, const address_v4 &mask)
Definition: internet.h:975
constexpr address_v4 broadcast() const noexcept
Definition: internet.h:1005
constexpr address_v4 netmask() const noexcept
Definition: internet.h:995
address_v4_range hosts() const noexcept
constexpr network_v4 canonical() const noexcept
Definition: internet.h:1011
constexpr network_v4() noexcept=default
std::basic_string< char, std::char_traits< char >, Allocator > to_string(const Allocator &a=Allocator()) const
Definition: internet.h:1018
constexpr bool is_host() const noexcept
Definition: internet.h:1014
constexpr address_v4 address() const noexcept
Definition: internet.h:993
Definition: internet.h:1053
address_v6_range hosts() const noexcept
constexpr unsigned char networkbits(const address_v6::bytes_type &address_bytes, int prefix_len, int ndx) const
Definition: internet.h:1099
constexpr address_v6 network() const noexcept
Definition: internet.h:1062
std::basic_string< char, std::char_traits< char >, Allocator > to_string(const Allocator &a=Allocator()) const
Definition: internet.h:1093
constexpr bool is_host() const noexcept
Definition: internet.h:1089
constexpr network_v6 canonical() const noexcept
Definition: internet.h:1086
constexpr uint8_t leftmostbits(int ndx, int prefix_len) const
Definition: internet.h:1105
constexpr int prefix_length() const noexcept
Definition: internet.h:1061
constexpr bool is_subnet_of(const network_v6 &other) const noexcept
Definition: internet.h:1124
constexpr network_v6() noexcept=default
constexpr address_v6 address() const noexcept
Definition: internet.h:1060
Definition: internet.h:594
std::bitset< 32 > flags
Definition: internet.h:596
TCP protocol.
Definition: internet.h:1155
static constexpr tcp v4() noexcept
Definition: internet.h:1299
constexpr int protocol() const noexcept
Definition: internet.h:1304
int family_
Definition: internet.h:1311
constexpr int family() const noexcept
Definition: internet.h:1302
constexpr int type() const noexcept
Definition: internet.h:1303
constexpr tcp(int family)
Definition: internet.h:1309
static constexpr tcp v6() noexcept
Definition: internet.h:1300
Definition: internet.h:1324
int family_
Definition: internet.h:1342
constexpr int protocol() const noexcept
Definition: internet.h:1335
constexpr int family() const noexcept
Definition: internet.h:1333
constexpr int type() const noexcept
Definition: internet.h:1334
static constexpr udp v4() noexcept
Definition: internet.h:1330
constexpr udp(int family)
Definition: internet.h:1340
static constexpr udp v6() noexcept
Definition: internet.h:1331
base-class of socket options.
Definition: socket.h:77
Definition: expected.h:284
static std::string to_string(const LEX_STRING &str)
Definition: lex_string.h:50
static mi_bit_type mask[]
Definition: mi_packrec.cc:141
void copy(Shards< COUNT > &dst, const Shards< COUNT > &src) noexcept
Copy the counters, overwrite destination.
Definition: ut0counter.h:354
std::string str(const mysqlrouter::ConfigGenerator::Options::Endpoint &ep)
Definition: config_generator.cc:1081
Container::const_iterator find(const Container &c, Value &&value)
Definition: generic.h:39
static Value err()
Create a Value object that represents an error condition.
Definition: json_binary.cc:927
stdx::expected< void, std::error_code > getnameinfo(const struct sockaddr *saddr, socklen_t addrlen, char *host, socklen_t hostlen, char *serv, socklen_t servlen, int flags)
Definition: resolver.h:173
std::error_code last_error_code()
get last std::error_code for socket-errors.
Definition: socket_error.h:107
std::error_code error_type
Definition: socket_constants.h:55
constexpr bool operator>=(const address_v4 &a, const address_v4 &b) noexcept
Definition: internet.h:175
stdx::expected< address, std::error_code > make_address(const char *str)
make address from a c-string.
Definition: internet.h:454
stdx::expected< address_v6, std::error_code > make_address_v6(const char *str)
make address_v6 from a string.
Definition: internet.h:383
constexpr bool operator==(const address_v4 &a, const address_v4 &b) noexcept
Definition: internet.h:160
constexpr T host_to_network(const T t) noexcept
convert an integer from host-endianness into network endianness.
Definition: internet.h:68
constexpr bool operator<(const address_v4 &a, const address_v4 &b) noexcept
Definition: internet.h:166
stdx::expected< address_v4, std::error_code > make_address_v4(const char *str)
make address_v4 from a string.
Definition: internet.h:432
uint_least32_t scope_id_type
Definition: internet.h:91
constexpr bool operator<=(const address_v4 &a, const address_v4 &b) noexcept
Definition: internet.h:172
constexpr T network_to_host(const T t) noexcept
convert an integer from network-endianness into host endianness.
Definition: internet.h:81
std::basic_ostream< CharT, Traits > & operator<<(std::basic_ostream< CharT, Traits > &os, const address &addr)
Definition: internet.h:479
constexpr bool operator>(const address_v4 &a, const address_v4 &b) noexcept
Definition: internet.h:169
uint_least16_t port_type
Definition: internet.h:90
constexpr bool operator!=(const address_v4 &a, const address_v4 &b) noexcept
Definition: internet.h:163
std::error_code make_error_code(resolver_errc ec)
Definition: resolver.h:135
Definition: gcs_xcom_synode.h:64
unexpected(E) -> unexpected< E >
constexpr T byteswap(T num) noexcept
Definition: bit.h:52
std::conditional_t< !std::is_array< T >::value, std::unique_ptr< T, detail::Deleter< T > >, std::conditional_t< detail::is_unbounded_array_v< T >, std::unique_ptr< T, detail::Array_deleter< std::remove_extent_t< T > > >, void > > unique_ptr
The following is a common type that is returned by all the ut::make_unique (non-aligned) specializati...
Definition: ut0new.h:2438
required string type
Definition: replication_group_member_actions.proto:34
struct sockaddr sockaddr
Definition: sock_probe_win32.h:63
Definition: internet.h:96
constexpr bytes_type(T... t)
Definition: internet.h:98
Definition: internet.h:184
constexpr bytes_type(T... t)
Definition: internet.h:187
#define IPPROTO_TCP
Definition: task_os.h:87
int n
Definition: xcom_base.cc:509