wininet: Moved inet_ntop call to GetAddress.
This commit is contained in:
parent
100bd11ae5
commit
47778f95fa
|
@ -2447,7 +2447,7 @@ HINTERNET FTP_Connect(appinfo_t *hIC, LPCWSTR lpszServerName,
|
|||
socklen_t sock_namelen;
|
||||
BOOL bSuccess = FALSE;
|
||||
ftp_session_t *lpwfs = NULL;
|
||||
char szaddr[INET_ADDRSTRLEN];
|
||||
char szaddr[INET6_ADDRSTRLEN];
|
||||
|
||||
TRACE("%p Server(%s) Port(%d) User(%s) Paswd(%s)\n",
|
||||
hIC, debugstr_w(lpszServerName),
|
||||
|
@ -2535,7 +2535,7 @@ HINTERNET FTP_Connect(appinfo_t *hIC, LPCWSTR lpszServerName,
|
|||
(LPWSTR) lpszServerName, (strlenW(lpszServerName)+1) * sizeof(WCHAR));
|
||||
|
||||
sock_namelen = sizeof(socketAddr);
|
||||
if (!GetAddress(lpszServerName, lpwfs->serverport, (struct sockaddr *)&socketAddr, &sock_namelen))
|
||||
if (!GetAddress(lpszServerName, lpwfs->serverport, (struct sockaddr *)&socketAddr, &sock_namelen, szaddr))
|
||||
{
|
||||
INTERNET_SetLastError(ERROR_INTERNET_NAME_NOT_RESOLVED);
|
||||
goto lerror;
|
||||
|
@ -2548,7 +2548,6 @@ HINTERNET FTP_Connect(appinfo_t *hIC, LPCWSTR lpszServerName,
|
|||
goto lerror;
|
||||
}
|
||||
|
||||
inet_ntop(socketAddr.sin_family, &socketAddr.sin_addr, szaddr, sizeof(szaddr));
|
||||
SendAsyncCallback(&hIC->hdr, dwContext, INTERNET_STATUS_NAME_RESOLVED,
|
||||
szaddr, strlen(szaddr)+1);
|
||||
|
||||
|
|
|
@ -1852,8 +1852,7 @@ static BOOL HTTP_DealWithProxy(appinfo_t *hIC, http_session_t *session, http_req
|
|||
static DWORD HTTP_ResolveName(http_request_t *request)
|
||||
{
|
||||
server_t *server = request->proxy ? request->proxy : request->server;
|
||||
socklen_t addr_len;
|
||||
void *addr;
|
||||
int addr_len;
|
||||
|
||||
if(server->addr_len)
|
||||
return ERROR_SUCCESS;
|
||||
|
@ -1864,23 +1863,10 @@ static DWORD HTTP_ResolveName(http_request_t *request)
|
|||
(strlenW(server->name)+1) * sizeof(WCHAR));
|
||||
|
||||
addr_len = sizeof(server->addr);
|
||||
if (!GetAddress(server->name, server->port, (struct sockaddr *)&server->addr, &addr_len))
|
||||
if (!GetAddress(server->name, server->port, (SOCKADDR*)&server->addr, &addr_len, server->addr_str))
|
||||
return ERROR_INTERNET_NAME_NOT_RESOLVED;
|
||||
|
||||
switch(server->addr.ss_family) {
|
||||
case AF_INET:
|
||||
addr = &((struct sockaddr_in *)&server->addr)->sin_addr;
|
||||
break;
|
||||
case AF_INET6:
|
||||
addr = &((struct sockaddr_in6 *)&server->addr)->sin6_addr;
|
||||
break;
|
||||
default:
|
||||
WARN("unsupported family %d\n", server->addr.ss_family);
|
||||
return ERROR_INTERNET_NAME_NOT_RESOLVED;
|
||||
}
|
||||
|
||||
server->addr_len = addr_len;
|
||||
inet_ntop(server->addr.ss_family, addr, server->addr_str, sizeof(server->addr_str));
|
||||
INTERNET_SendCallback(&request->hdr, request->hdr.dwContext,
|
||||
INTERNET_STATUS_NAME_RESOLVED,
|
||||
server->addr_str, strlen(server->addr_str)+1);
|
||||
|
|
|
@ -3453,7 +3453,7 @@ BOOL WINAPI InternetCheckConnectionW( LPCWSTR lpszUrl, DWORD dwFlags, DWORD dwRe
|
|||
socklen_t sa_len = sizeof(saddr);
|
||||
int fd;
|
||||
|
||||
if (!GetAddress(hostW, port, (struct sockaddr *)&saddr, &sa_len))
|
||||
if (!GetAddress(hostW, port, (struct sockaddr *)&saddr, &sa_len, NULL))
|
||||
goto End;
|
||||
init_winsock();
|
||||
fd = socket(saddr.ss_family, SOCK_STREAM, 0);
|
||||
|
|
|
@ -397,8 +397,7 @@ DWORD HTTP_Connect(appinfo_t*,LPCWSTR,
|
|||
LPCWSTR lpszPassword, DWORD dwFlags, DWORD_PTR dwContext,
|
||||
DWORD dwInternalFlags, HINTERNET*) DECLSPEC_HIDDEN;
|
||||
|
||||
BOOL GetAddress(LPCWSTR lpszServerName, INTERNET_PORT nServerPort,
|
||||
struct sockaddr *psa, socklen_t *sa_len) DECLSPEC_HIDDEN;
|
||||
BOOL GetAddress(const WCHAR*,INTERNET_PORT,SOCKADDR*,int*,char*) DECLSPEC_HIDDEN;
|
||||
|
||||
DWORD get_cookie_header(const WCHAR*,const WCHAR*,WCHAR**) DECLSPEC_HIDDEN;
|
||||
DWORD set_cookie(const WCHAR*,const WCHAR*,const WCHAR*,const WCHAR*,DWORD) DECLSPEC_HIDDEN;
|
||||
|
|
|
@ -125,9 +125,10 @@ time_t ConvertTimeString(LPCWSTR asctime)
|
|||
}
|
||||
|
||||
|
||||
BOOL GetAddress(const WCHAR *name, INTERNET_PORT port, struct sockaddr *psa, socklen_t *sa_len)
|
||||
BOOL GetAddress(const WCHAR *name, INTERNET_PORT port, struct sockaddr *psa, int *sa_len, char *addr_str)
|
||||
{
|
||||
ADDRINFOW *res, hints;
|
||||
void *addr = NULL;
|
||||
int ret;
|
||||
|
||||
TRACE("%s\n", debugstr_w(name));
|
||||
|
@ -162,13 +163,17 @@ BOOL GetAddress(const WCHAR *name, INTERNET_PORT port, struct sockaddr *psa, soc
|
|||
switch (res->ai_family)
|
||||
{
|
||||
case AF_INET:
|
||||
addr = &((struct sockaddr_in *)psa)->sin_addr;
|
||||
((struct sockaddr_in *)psa)->sin_port = htons(port);
|
||||
break;
|
||||
case AF_INET6:
|
||||
addr = &((struct sockaddr_in6 *)psa)->sin6_addr;
|
||||
((struct sockaddr_in6 *)psa)->sin6_port = htons(port);
|
||||
break;
|
||||
}
|
||||
|
||||
if(addr_str)
|
||||
inet_ntop(res->ai_family, addr, addr_str, INET6_ADDRSTRLEN);
|
||||
FreeAddrInfoW(res);
|
||||
return TRUE;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue