38 case WSATRY_AGAIN:
return UV_EAI_AGAIN;
39 case WSAEINVAL:
return UV_EAI_BADFLAGS;
40 case WSANO_RECOVERY:
return UV_EAI_FAIL;
41 case WSAEAFNOSUPPORT:
return UV_EAI_FAMILY;
42 case WSA_NOT_ENOUGH_MEMORY:
return UV_EAI_MEMORY;
43 case WSAHOST_NOT_FOUND:
return UV_EAI_NONAME;
44 case WSATYPE_NOT_FOUND:
return UV_EAI_SERVICE;
45 case WSAESOCKTNOSUPPORT:
return UV_EAI_SOCKTYPE;
54 #if !defined(_MSC_VER) && !defined(__MINGW64_VERSION_MAJOR)
77 #define ALIGNED_SIZE(X) ((((X) + 3) >> 2) << 2)
79 #ifndef NDIS_IF_MAX_STRING_SIZE
80 #define NDIS_IF_MAX_STRING_SIZE IF_MAX_STRING_SIZE
89 hints =
req->addrinfow;
107 int addrinfo_len = 0;
109 size_t addrinfo_struct_len =
ALIGNED_SIZE(
sizeof(
struct addrinfo));
111 struct addrinfo* addrinfo_ptr;
112 char* alloc_ptr =
NULL;
113 char* cur_ptr =
NULL;
121 if (
status == UV_ECANCELED) {
123 req->retcode = UV_EAI_CANCELED;
127 if (
req->retcode == 0) {
129 addrinfow_ptr =
req->addrinfow;
130 while (addrinfow_ptr !=
NULL) {
131 addrinfo_len += addrinfo_struct_len +
134 name_len = WideCharToMultiByte(CP_UTF8,
148 addrinfow_ptr = addrinfow_ptr->
ai_next;
155 if (alloc_ptr !=
NULL) {
157 addrinfow_ptr =
req->addrinfow;
159 while (addrinfow_ptr !=
NULL) {
161 assert(cur_ptr + addrinfo_struct_len <= alloc_ptr + addrinfo_len);
162 addrinfo_ptr = (
struct addrinfo*)cur_ptr;
163 addrinfo_ptr->ai_family = addrinfow_ptr->
ai_family;
164 addrinfo_ptr->ai_socktype = addrinfow_ptr->
ai_socktype;
165 addrinfo_ptr->ai_protocol = addrinfow_ptr->
ai_protocol;
166 addrinfo_ptr->ai_flags = addrinfow_ptr->
ai_flags;
167 addrinfo_ptr->ai_addrlen = addrinfow_ptr->
ai_addrlen;
168 addrinfo_ptr->ai_canonname =
NULL;
169 addrinfo_ptr->ai_addr =
NULL;
170 addrinfo_ptr->ai_next =
NULL;
172 cur_ptr += addrinfo_struct_len;
175 if (addrinfo_ptr->ai_addrlen > 0) {
176 assert(cur_ptr + addrinfo_ptr->ai_addrlen <=
177 alloc_ptr + addrinfo_len);
178 memcpy(cur_ptr, addrinfow_ptr->
ai_addr, addrinfo_ptr->ai_addrlen);
179 addrinfo_ptr->ai_addr = (
struct sockaddr*)cur_ptr;
185 name_len = WideCharToMultiByte(CP_UTF8,
194 assert(cur_ptr + name_len <= alloc_ptr + addrinfo_len);
195 name_len = WideCharToMultiByte(CP_UTF8,
204 addrinfo_ptr->ai_canonname = cur_ptr;
207 assert(cur_ptr <= alloc_ptr + addrinfo_len);
210 addrinfow_ptr = addrinfow_ptr->
ai_next;
211 if (addrinfow_ptr !=
NULL) {
212 addrinfo_ptr->
ai_next = (
struct addrinfo*)cur_ptr;
215 req->addrinfo = (
struct addrinfo*)alloc_ptr;
217 req->retcode = UV_EAI_MEMORY;
231 if (
req->getaddrinfo_cb)
237 char* alloc_ptr = (
char*)ai;
262 const struct addrinfo* hints) {
263 char hostname_ascii[256];
267 char* alloc_ptr =
NULL;
276 req->getaddrinfo_cb = getaddrinfo_cb;
286 hostname_ascii +
sizeof(hostname_ascii));
289 nodesize =
ALIGNED_SIZE(MultiByteToWideChar(CP_UTF8, 0, hostname_ascii,
290 -1,
NULL, 0) *
sizeof(WCHAR));
292 err = GetLastError();
295 node = hostname_ascii;
298 if (service !=
NULL) {
306 if (servicesize == 0) {
307 err = GetLastError();
316 alloc_ptr = (
char*)
uv__malloc(nodesize + servicesize + hintssize);
323 req->alloc = (
void*)alloc_ptr;
328 req->node = (WCHAR*)alloc_ptr;
329 if (MultiByteToWideChar(CP_UTF8,
334 nodesize /
sizeof(WCHAR)) == 0) {
335 err = GetLastError();
338 alloc_ptr += nodesize;
345 if (service !=
NULL) {
346 req->service = (WCHAR*)alloc_ptr;
347 if (MultiByteToWideChar(CP_UTF8,
352 servicesize /
sizeof(WCHAR)) == 0) {
353 err = GetLastError();
356 alloc_ptr += servicesize;
364 req->addrinfow->ai_family = hints->ai_family;
365 req->addrinfow->ai_socktype = hints->ai_socktype;
366 req->addrinfow->ai_protocol = hints->ai_protocol;
367 req->addrinfow->ai_flags = hints->ai_flags;
368 req->addrinfow->ai_addrlen = 0;
369 req->addrinfow->ai_canonname =
NULL;
370 req->addrinfow->ai_addr =
NULL;
371 req->addrinfow->ai_next =
NULL;
378 if (getaddrinfo_cb) {
408 r = ConvertInterfaceIndexToLuid(ifindex, &luid);
413 r = ConvertInterfaceLuidToNameW(&luid, wname,
ARRAY_SIZE(wname));
419 bufsize = WideCharToMultiByte(CP_UTF8, 0, wname, -1,
NULL, 0,
NULL,
NULL);
423 }
else if (bufsize > *
size) {
429 bufsize = WideCharToMultiByte(CP_UTF8,
456 if (
r >= (
int) *
size) {
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd static protocol static who struct sockaddr static addrlen static backlog struct timeval struct timezone static tz const struct iovec static count static mode const void const struct sockaddr static tolen const char static pathname void static offset struct stat static buf void long static basep static whence static length const void static len static semflg const void static shmflg const struct timespec req
long uv__idna_toascii(const char *s, const char *se, char *d, char *de)
memcpy(mem, inblock.get(), min(CONTAINING_RECORD(inblock.get(), MEMBLOCK, data) ->size, size))
static const char struct stat static buf struct stat static buf static vhangup int status
assert(limit<=UINT32_MAX/2)
#define container_of(ptr, type, member)
struct addrinfoW * ai_next
struct sockaddr * ai_addr
void uv__work_submit(uv_loop_t *loop, struct uv__work *w, enum uv__work_kind kind, void(*work)(struct uv__work *w), void(*done)(struct uv__work *w, int status))
int uv_if_indextoiid(unsigned int ifindex, char *buffer, size_t *size)
void uv_freeaddrinfo(struct addrinfo *ai)
int uv_getaddrinfo(uv_loop_t *loop, uv_getaddrinfo_t *req, uv_getaddrinfo_cb cb, const char *hostname, const char *service, const struct addrinfo *hints)
int uv__getaddrinfo_translate_error(int sys_err)
int uv_if_indextoname(unsigned int ifindex, char *buffer, size_t *size)
void error(const char *msg)
void * uv__malloc(size_t size)
#define UV_REQ_INIT(req, typ)
#define uv__req_register(loop, req)
#define uv__req_unregister(loop, req)
UV_EXTERN int uv_translate_sys_error(int sys_errno)
void(* uv_getaddrinfo_cb)(uv_getaddrinfo_t *req, int status, struct addrinfo *res)
static void uv__getaddrinfo_work(struct uv__work *w)
static void uv__getaddrinfo_done(struct uv__work *w, int status)
struct addrinfoW ADDRINFOW
#define NDIS_IF_MAX_STRING_SIZE
DECLSPEC_IMPORT void WSAAPI FreeAddrInfoW(PADDRINFOW pAddrInfo)
DECLSPEC_IMPORT int WSAAPI GetAddrInfoW(const WCHAR *node, const WCHAR *service, const ADDRINFOW *hints, PADDRINFOW *result)
struct addrinfoW * PADDRINFOW