From 646b9cae800a3e7dfb944b132ed7ec94833c994b Mon Sep 17 00:00:00 2001 From: Juan Lang Date: Wed, 8 Jul 2009 10:39:37 -0700 Subject: [PATCH] winhttp: Convert connect_t's address type from a struct sockaddr_in to a struct sockaddr_storage. --- dlls/winhttp/request.c | 16 +++++++++++++--- dlls/winhttp/winhttp_private.h | 2 +- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/dlls/winhttp/request.c b/dlls/winhttp/request.c index f088c40855c..d9147d32994 100644 --- a/dlls/winhttp/request.c +++ b/dlls/winhttp/request.c @@ -713,6 +713,7 @@ BOOL WINAPI WinHttpQueryHeaders( HINTERNET hrequest, DWORD level, LPCWSTR name, static BOOL open_connection( request_t *request ) { connect_t *connect; + const void *addr; char address[32]; WCHAR *addressW; INTERNET_PORT port; @@ -727,16 +728,25 @@ static BOOL open_connection( request_t *request ) slen = sizeof(connect->sockaddr); if (!netconn_resolve( connect->servername, port, (struct sockaddr *)&connect->sockaddr, &slen )) return FALSE; - inet_ntop( connect->sockaddr.sin_family, &connect->sockaddr.sin_addr, address, sizeof(address) ); + switch (connect->sockaddr.ss_family) + { + case AF_INET: + addr = &((struct sockaddr_in *)&connect->sockaddr)->sin_addr; + break; + default: + WARN("unsupported address family %d\n", connect->sockaddr.ss_family); + return FALSE; + } + inet_ntop( connect->sockaddr.ss_family, addr, address, sizeof(address) ); addressW = strdupAW( address ); send_callback( &request->hdr, WINHTTP_CALLBACK_STATUS_NAME_RESOLVED, addressW, strlenW(addressW) + 1 ); - TRACE("connecting to %s:%u\n", address, ntohs(connect->sockaddr.sin_port)); + TRACE("connecting to %s:%u\n", address, port); send_callback( &request->hdr, WINHTTP_CALLBACK_STATUS_CONNECTING_TO_SERVER, addressW, 0 ); - if (!netconn_create( &request->netconn, connect->sockaddr.sin_family, SOCK_STREAM, 0 )) + if (!netconn_create( &request->netconn, connect->sockaddr.ss_family, SOCK_STREAM, 0 )) { heap_free( addressW ); return FALSE; diff --git a/dlls/winhttp/winhttp_private.h b/dlls/winhttp/winhttp_private.h index 750acf50aed..2143953c034 100644 --- a/dlls/winhttp/winhttp_private.h +++ b/dlls/winhttp/winhttp_private.h @@ -110,7 +110,7 @@ typedef struct LPWSTR password; INTERNET_PORT hostport; INTERNET_PORT serverport; - struct sockaddr_in sockaddr; + struct sockaddr_storage sockaddr; } connect_t; typedef struct