Module: wine Branch: master Commit: 058e918da5a520d6fd08674cea57302550e0cf05 URL: http://source.winehq.org/git/wine.git/?a=commit;h=058e918da5a520d6fd08674cea...
Author: Juan Lang juan.lang@gmail.com Date: Thu Jul 9 11:36:00 2009 -0700
wininet: Convert WININETSESSIONW's socketAddress to a struct sockaddr_storage.
---
dlls/wininet/http.c | 30 +++++++++++++++++++++++++----- dlls/wininet/internet.h | 2 +- 2 files changed, 26 insertions(+), 6 deletions(-)
diff --git a/dlls/wininet/http.c b/dlls/wininet/http.c index f7df3a9..9573f6f 100644 --- a/dlls/wininet/http.c +++ b/dlls/wininet/http.c @@ -1452,6 +1452,7 @@ static BOOL HTTP_ResolveName(LPWININETHTTPREQW lpwhr) { char szaddr[32]; LPWININETHTTPSESSIONW lpwhs = lpwhr->lpHttpSession; + const void *addr;
INTERNET_SendCallback(&lpwhr->hdr, lpwhr->hdr.dwContext, INTERNET_STATUS_RESOLVING_NAME, @@ -1466,8 +1467,17 @@ static BOOL HTTP_ResolveName(LPWININETHTTPREQW lpwhr) return FALSE; }
- inet_ntop(lpwhs->socketAddress.sin_family, &lpwhs->socketAddress.sin_addr, - szaddr, sizeof(szaddr)); + switch (lpwhs->socketAddress.ss_family) + { + case AF_INET: + addr = &((struct sockaddr_in *)&lpwhs->socketAddress)->sin_addr; + break; + default: + WARN("unsupported family %d\n", lpwhs->socketAddress.ss_family); + INTERNET_SetLastError(ERROR_INTERNET_NAME_NOT_RESOLVED); + return FALSE; + } + inet_ntop(lpwhs->socketAddress.ss_family, addr, szaddr, sizeof(szaddr)); INTERNET_SendCallback(&lpwhr->hdr, lpwhr->hdr.dwContext, INTERNET_STATUS_NAME_RESOLVED, szaddr, strlen(szaddr)+1); @@ -4108,6 +4118,7 @@ static BOOL HTTP_OpenConnection(LPWININETHTTPREQW lpwhr) LPWININETHTTPSESSIONW lpwhs; LPWININETAPPINFOW hIC = NULL; char szaddr[32]; + const void *addr;
TRACE("-->\n");
@@ -4128,14 +4139,23 @@ static BOOL HTTP_OpenConnection(LPWININETHTTPREQW lpwhr) lpwhs = lpwhr->lpHttpSession;
hIC = lpwhs->lpAppInfo; - inet_ntop(lpwhs->socketAddress.sin_family, &lpwhs->socketAddress.sin_addr, - szaddr, sizeof(szaddr)); + switch (lpwhs->socketAddress.ss_family) + { + case AF_INET: + addr = &((struct sockaddr_in *)&lpwhs->socketAddress)->sin_addr; + break; + default: + WARN("unsupported family %d\n", lpwhs->socketAddress.ss_family); + INTERNET_SetLastError(ERROR_INTERNET_NAME_NOT_RESOLVED); + return FALSE; + } + inet_ntop(lpwhs->socketAddress.ss_family, addr, szaddr, sizeof(szaddr)); INTERNET_SendCallback(&lpwhr->hdr, lpwhr->hdr.dwContext, INTERNET_STATUS_CONNECTING_TO_SERVER, szaddr, strlen(szaddr)+1);
- if (!NETCON_create(&lpwhr->netConnection, lpwhs->socketAddress.sin_family, + if (!NETCON_create(&lpwhr->netConnection, lpwhs->socketAddress.ss_family, SOCK_STREAM, 0)) { WARN("Socket creation failed: %u\n", INTERNET_GetLastError()); diff --git a/dlls/wininet/internet.h b/dlls/wininet/internet.h index eae3423..4cd22d6 100644 --- a/dlls/wininet/internet.h +++ b/dlls/wininet/internet.h @@ -165,7 +165,7 @@ typedef struct LPWSTR lpszPassword; INTERNET_PORT nHostPort; /* the final destination port of the request */ INTERNET_PORT nServerPort; /* the port of the server we directly connect to */ - struct sockaddr_in socketAddress; + struct sockaddr_storage socketAddress; socklen_t sa_len; } WININETHTTPSESSIONW, *LPWININETHTTPSESSIONW;