25#ifndef MYSQL_HARNESS_NET_TS_IMPL_RESOLVER_H_
26#define MYSQL_HARNESS_NET_TS_IMPL_RESOLVER_H_
31#include <system_error>
53 bad_hints = EAI_BADHINTS,
70 overflow = EAI_OVERFLOW,
74 bad_protocol = EAI_PROTOCOL,
78 cancelled = EAI_CANCELED,
82 not_cancelled = EAI_NOTCANCELED,
86 in_progress = EAI_INPROGRESS,
90 all_done = EAI_ALLDONE,
98 idn_encode_failed = EAI_IDN_ENCODE,
114 class category_impl :
public std::error_category {
116 const char *
name()
const noexcept override {
return "resolver"; }
117 std::string message(
int ev)
const override {
return gai_strerror(ev); }
131 static category_impl instance;
163 const auto end =
buf + buf_len;
174 const struct sockaddr *saddr, socklen_t addrlen,
char *
host,
175 socklen_t hostlen,
char *serv, socklen_t servlen,
int flags) {
176#if defined(__APPLE__)
179 if (addrlen <
sizeof(*saddr)) {
184 if ((saddr->sa_family == AF_INET && addrlen <
sizeof(sockaddr_in)) ||
185 (saddr->sa_family == AF_INET6 && addrlen <
sizeof(sockaddr_in6))) {
195 if (ret == EAI_SYSTEM) {
228 const struct addrinfo *hints) {
229 struct addrinfo *ainfo{
nullptr};
235 if (ret == EAI_SYSTEM) {
264 return ret_type{std::in_place, ainfo, &::freeaddrinfo};
271 if (
nullptr == ::inet_ntop(af, src, out, out_len)) {
Definition: expected.h:286
static char buf[MAX_BUF]
Definition: conf_to_src.cc:73
static int flags[50]
Definition: hp_test1.cc:40
const char * host
Definition: mysqladmin.cc:65
static bool interrupted
Definition: mysqladmin.cc:72
Definition: buf0block_hint.cc:30
Container::const_iterator find(const Container &c, Value &&value)
Definition: generic.h:39
Definition: http_server_component.cc:34
const char * begin(const char *const c)
Definition: base64.h:44
stdx::expected< std::unique_ptr< struct addrinfo, void(*)(struct addrinfo *)>, std::error_code > getaddrinfo(const char *node, const char *service, const struct addrinfo *hints)
Definition: resolver.h:227
stdx::expected< const char *, std::error_code > inetntop(int af, const void *src, char *out, size_t out_len)
Definition: resolver.h:267
stdx::expected< void, std::error_code > gethostname(char *buf, size_t buf_len)
get hostname.
Definition: resolver.h:151
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
resolver_errc
Definition: resolver.h:48
@ bad_socktype
ai_socktype not supported
@ host_not_found
NAME or SERVICE is unknown.
@ bad_flags
flags parameter had an invalid value
@ service_not_found
SERVICE not supported for ai_socktype.
@ out_of_memory
memory allocation failed
@ try_again
name could not be resolved at this time
@ fail
non recoverable failed on name resolution
@ bad_family
ai_family not supported
const std::error_category & resolver_category() noexcept
Definition: resolver.h:113
std::error_code make_error_code(resolver_errc ec)
Definition: resolver.h:135
std::error_code make_error_code(net::stream_errc e) noexcept
Definition: buffer.h:103
Definition: gcs_xcom_synode.h:64
unexpected(E) -> unexpected< E >
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:2440
struct sockaddr sockaddr
Definition: sock_probe_win32.h:63
case opt name
Definition: sslopt-case.h:29