winhttp: Use winsock sockets.
Signed-off-by: Hans Leidekker <hans@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
79bc939b40
commit
ca56f99280
|
@ -1,8 +1,8 @@
|
|||
MODULE = winhttp.dll
|
||||
IMPORTLIB = winhttp
|
||||
IMPORTS = uuid jsproxy user32 advapi32
|
||||
IMPORTS = uuid jsproxy user32 advapi32 ws2_32
|
||||
DELAYIMPORTS = oleaut32 ole32 crypt32 secur32
|
||||
EXTRALIBS = $(CORESERVICES_LIBS) $(SOCKET_LIBS)
|
||||
EXTRALIBS = $(CORESERVICES_LIBS)
|
||||
|
||||
C_SRCS = \
|
||||
cookie.c \
|
||||
|
|
|
@ -17,15 +17,15 @@
|
|||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "ws2tcpip.h"
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "wine/debug.h"
|
||||
#include "wine/list.h"
|
||||
|
||||
#include "windef.h"
|
||||
#include "winbase.h"
|
||||
#include "winhttp.h"
|
||||
|
||||
#include "wine/debug.h"
|
||||
#include "wine/list.h"
|
||||
#include "winhttp_private.h"
|
||||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(winhttp);
|
||||
|
|
|
@ -19,15 +19,14 @@
|
|||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "wine/port.h"
|
||||
#include "wine/debug.h"
|
||||
|
||||
#include "ws2tcpip.h"
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "windef.h"
|
||||
#include "winbase.h"
|
||||
#include "winhttp.h"
|
||||
|
||||
#include "wine/debug.h"
|
||||
#include "winhttp_private.h"
|
||||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(winhttp);
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
|
||||
#define COBJMACROS
|
||||
#include "config.h"
|
||||
#include "ws2tcpip.h"
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "windef.h"
|
||||
|
|
|
@ -18,134 +18,31 @@
|
|||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "wine/port.h"
|
||||
|
||||
#define NONAMELESSUNION
|
||||
#include "ws2tcpip.h"
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#ifdef HAVE_SYS_SOCKET_H
|
||||
# include <sys/socket.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_IOCTL_H
|
||||
# include <sys/ioctl.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_FILIO_H
|
||||
# include <sys/filio.h>
|
||||
#endif
|
||||
#ifdef HAVE_POLL_H
|
||||
# include <poll.h>
|
||||
#endif
|
||||
|
||||
#define NONAMELESSUNION
|
||||
|
||||
#include "wine/debug.h"
|
||||
#include "wine/library.h"
|
||||
|
||||
#include "windef.h"
|
||||
#include "winbase.h"
|
||||
#include "winhttp.h"
|
||||
#include "schannel.h"
|
||||
|
||||
#include "wine/debug.h"
|
||||
#include "wine/library.h"
|
||||
#include "winhttp_private.h"
|
||||
|
||||
/* to avoid conflicts with the Unix socket headers */
|
||||
#define USE_WS_PREFIX
|
||||
#include "winsock2.h"
|
||||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(winhttp);
|
||||
|
||||
#ifndef HAVE_GETADDRINFO
|
||||
|
||||
/* critical section to protect non-reentrant gethostbyname() */
|
||||
static CRITICAL_SECTION cs_gethostbyname;
|
||||
static CRITICAL_SECTION_DEBUG critsect_debug =
|
||||
{
|
||||
0, 0, &cs_gethostbyname,
|
||||
{ &critsect_debug.ProcessLocksList, &critsect_debug.ProcessLocksList },
|
||||
0, 0, { (DWORD_PTR)(__FILE__ ": cs_gethostbyname") }
|
||||
};
|
||||
static CRITICAL_SECTION cs_gethostbyname = { &critsect_debug, -1, 0, 0, 0, 0 };
|
||||
|
||||
#endif
|
||||
|
||||
/* translate a unix error code into a winsock error code */
|
||||
static int sock_get_error( int err )
|
||||
{
|
||||
#if !defined(__MINGW32__) && !defined (_MSC_VER)
|
||||
switch (err)
|
||||
{
|
||||
case EINTR: return WSAEINTR;
|
||||
case EBADF: return WSAEBADF;
|
||||
case EPERM:
|
||||
case EACCES: return WSAEACCES;
|
||||
case EFAULT: return WSAEFAULT;
|
||||
case EINVAL: return WSAEINVAL;
|
||||
case EMFILE: return WSAEMFILE;
|
||||
case EWOULDBLOCK: return WSAEWOULDBLOCK;
|
||||
case EINPROGRESS: return WSAEINPROGRESS;
|
||||
case EALREADY: return WSAEALREADY;
|
||||
case ENOTSOCK: return WSAENOTSOCK;
|
||||
case EDESTADDRREQ: return WSAEDESTADDRREQ;
|
||||
case EMSGSIZE: return WSAEMSGSIZE;
|
||||
case EPROTOTYPE: return WSAEPROTOTYPE;
|
||||
case ENOPROTOOPT: return WSAENOPROTOOPT;
|
||||
case EPROTONOSUPPORT: return WSAEPROTONOSUPPORT;
|
||||
case ESOCKTNOSUPPORT: return WSAESOCKTNOSUPPORT;
|
||||
case EOPNOTSUPP: return WSAEOPNOTSUPP;
|
||||
case EPFNOSUPPORT: return WSAEPFNOSUPPORT;
|
||||
case EAFNOSUPPORT: return WSAEAFNOSUPPORT;
|
||||
case EADDRINUSE: return WSAEADDRINUSE;
|
||||
case EADDRNOTAVAIL: return WSAEADDRNOTAVAIL;
|
||||
case ENETDOWN: return WSAENETDOWN;
|
||||
case ENETUNREACH: return WSAENETUNREACH;
|
||||
case ENETRESET: return WSAENETRESET;
|
||||
case ECONNABORTED: return WSAECONNABORTED;
|
||||
case EPIPE:
|
||||
case ECONNRESET: return WSAECONNRESET;
|
||||
case ENOBUFS: return WSAENOBUFS;
|
||||
case EISCONN: return WSAEISCONN;
|
||||
case ENOTCONN: return WSAENOTCONN;
|
||||
case ESHUTDOWN: return WSAESHUTDOWN;
|
||||
case ETOOMANYREFS: return WSAETOOMANYREFS;
|
||||
case ETIMEDOUT: return WSAETIMEDOUT;
|
||||
case ECONNREFUSED: return WSAECONNREFUSED;
|
||||
case ELOOP: return WSAELOOP;
|
||||
case ENAMETOOLONG: return WSAENAMETOOLONG;
|
||||
case EHOSTDOWN: return WSAEHOSTDOWN;
|
||||
case EHOSTUNREACH: return WSAEHOSTUNREACH;
|
||||
case ENOTEMPTY: return WSAENOTEMPTY;
|
||||
#ifdef EPROCLIM
|
||||
case EPROCLIM: return WSAEPROCLIM;
|
||||
#endif
|
||||
#ifdef EUSERS
|
||||
case EUSERS: return WSAEUSERS;
|
||||
#endif
|
||||
#ifdef EDQUOT
|
||||
case EDQUOT: return WSAEDQUOT;
|
||||
#endif
|
||||
#ifdef ESTALE
|
||||
case ESTALE: return WSAESTALE;
|
||||
#endif
|
||||
#ifdef EREMOTE
|
||||
case EREMOTE: return WSAEREMOTE;
|
||||
#endif
|
||||
default: errno = err; perror( "sock_set_error" ); return WSAEFAULT;
|
||||
}
|
||||
#endif
|
||||
return err;
|
||||
}
|
||||
|
||||
static int sock_send(int fd, const void *msg, size_t len, int flags)
|
||||
{
|
||||
int ret;
|
||||
do
|
||||
{
|
||||
if ((ret = send(fd, msg, len, flags)) == -1) WARN("send error %s\n", strerror(errno));
|
||||
if ((ret = send(fd, msg, len, flags)) == -1) WARN("send error %u\n", WSAGetLastError());
|
||||
}
|
||||
while(ret == -1 && errno == EINTR);
|
||||
while(ret == -1 && WSAGetLastError() == WSAEINTR);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -154,9 +51,9 @@ static int sock_recv(int fd, void *msg, size_t len, int flags)
|
|||
int ret;
|
||||
do
|
||||
{
|
||||
if ((ret = recv(fd, msg, len, flags)) == -1) WARN("recv error %s\n", strerror(errno));
|
||||
if ((ret = recv(fd, msg, len, flags)) == -1) WARN("recv error %u\n", WSAGetLastError());
|
||||
}
|
||||
while(ret == -1 && errno == EINTR);
|
||||
while(ret == -1 && WSAGetLastError() == WSAEINTR);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -254,11 +151,32 @@ static DWORD netconn_verify_cert( PCCERT_CONTEXT cert, WCHAR *server, DWORD secu
|
|||
return err;
|
||||
}
|
||||
|
||||
static BOOL winsock_loaded;
|
||||
|
||||
void netconn_unload( void )
|
||||
{
|
||||
#ifndef HAVE_GETADDRINFO
|
||||
DeleteCriticalSection(&cs_gethostbyname);
|
||||
#endif
|
||||
if (winsock_loaded) WSACleanup();
|
||||
}
|
||||
|
||||
static BOOL WINAPI winsock_startup( INIT_ONCE *once, void *param, void **ctx )
|
||||
{
|
||||
int ret;
|
||||
WSADATA data;
|
||||
if (!(ret = WSAStartup( MAKEWORD(1,1), &data ))) winsock_loaded = TRUE;
|
||||
else ERR( "WSAStartup failed: %d\n", ret );
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void winsock_init(void)
|
||||
{
|
||||
static INIT_ONCE once = INIT_ONCE_STATIC_INIT;
|
||||
InitOnceExecuteOnce( &once, winsock_startup, NULL, NULL );
|
||||
}
|
||||
|
||||
static void set_blocking( netconn_t *conn, BOOL blocking )
|
||||
{
|
||||
ULONG state = !blocking;
|
||||
ioctlsocket( conn->socket, FIONBIO, &state );
|
||||
}
|
||||
|
||||
netconn_t *netconn_create( hostdata_t *host, const struct sockaddr_storage *sockaddr, int timeout )
|
||||
|
@ -266,8 +184,8 @@ netconn_t *netconn_create( hostdata_t *host, const struct sockaddr_storage *sock
|
|||
netconn_t *conn;
|
||||
unsigned int addr_len;
|
||||
BOOL ret = FALSE;
|
||||
int res;
|
||||
ULONG state;
|
||||
|
||||
winsock_init();
|
||||
|
||||
conn = heap_alloc_zero(sizeof(*conn));
|
||||
if (!conn) return NULL;
|
||||
|
@ -275,8 +193,7 @@ netconn_t *netconn_create( hostdata_t *host, const struct sockaddr_storage *sock
|
|||
conn->sockaddr = *sockaddr;
|
||||
if ((conn->socket = socket( sockaddr->ss_family, SOCK_STREAM, 0 )) == -1)
|
||||
{
|
||||
WARN("unable to create socket (%s)\n", strerror(errno));
|
||||
set_last_error( sock_get_error( errno ) );
|
||||
WARN("unable to create socket (%u)\n", WSAGetLastError());
|
||||
heap_free(conn);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -293,66 +210,38 @@ netconn_t *netconn_create( hostdata_t *host, const struct sockaddr_storage *sock
|
|||
assert(0);
|
||||
}
|
||||
|
||||
if (timeout > 0)
|
||||
{
|
||||
state = 1;
|
||||
ioctlsocket( conn->socket, FIONBIO, &state );
|
||||
}
|
||||
if (timeout > 0) set_blocking( conn, FALSE );
|
||||
|
||||
for (;;)
|
||||
if (!connect( conn->socket, (const struct sockaddr *)&conn->sockaddr, addr_len )) ret = TRUE;
|
||||
else
|
||||
{
|
||||
res = 0;
|
||||
if (connect( conn->socket, (const struct sockaddr *)&conn->sockaddr, addr_len ) < 0)
|
||||
DWORD err = WSAGetLastError();
|
||||
if (err == WSAEWOULDBLOCK || err == WSAEINPROGRESS)
|
||||
{
|
||||
res = sock_get_error( errno );
|
||||
if (res == WSAEWOULDBLOCK || res == WSAEINPROGRESS)
|
||||
{
|
||||
struct pollfd pfd;
|
||||
FD_SET set;
|
||||
TIMEVAL timeval = { 0, timeout * 1000 };
|
||||
int res;
|
||||
|
||||
pfd.fd = conn->socket;
|
||||
pfd.events = POLLOUT;
|
||||
for (;;)
|
||||
{
|
||||
res = 0;
|
||||
if (poll( &pfd, 1, timeout ) > 0)
|
||||
{
|
||||
ret = TRUE;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
res = sock_get_error( errno );
|
||||
if (res != WSAEINTR) break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (res != WSAEINTR) break;
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = TRUE;
|
||||
break;
|
||||
FD_ZERO( &set );
|
||||
FD_SET( conn->socket, &set );
|
||||
if ((res = select( conn->socket + 1, NULL, &set, NULL, &timeval )) > 0) ret = TRUE;
|
||||
else if (!res) set_last_error( ERROR_WINHTTP_TIMEOUT );
|
||||
}
|
||||
}
|
||||
if (timeout > 0)
|
||||
{
|
||||
state = 0;
|
||||
ioctlsocket( conn->socket, FIONBIO, &state );
|
||||
}
|
||||
|
||||
if (timeout > 0) set_blocking( conn, TRUE );
|
||||
|
||||
if (!ret)
|
||||
{
|
||||
WARN("unable to connect to host (%d)\n", res);
|
||||
set_last_error( res );
|
||||
WARN("unable to connect to host (%u)\n", get_last_error());
|
||||
netconn_close( conn );
|
||||
return NULL;
|
||||
}
|
||||
return conn;
|
||||
}
|
||||
|
||||
BOOL netconn_close( netconn_t *conn )
|
||||
void netconn_close( netconn_t *conn )
|
||||
{
|
||||
int res;
|
||||
|
||||
if (conn->secure)
|
||||
{
|
||||
heap_free( conn->peek_msg_mem );
|
||||
|
@ -360,15 +249,9 @@ BOOL netconn_close( netconn_t *conn )
|
|||
heap_free(conn->extra_buf);
|
||||
DeleteSecurityContext(&conn->ssl_ctx);
|
||||
}
|
||||
res = closesocket( conn->socket );
|
||||
closesocket( conn->socket );
|
||||
release_host( conn->host );
|
||||
heap_free(conn);
|
||||
if (res == -1)
|
||||
{
|
||||
set_last_error( sock_get_error( errno ) );
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL netconn_secure_connect( netconn_t *conn, WCHAR *hostname, DWORD security_flags, CredHandle *cred_handle,
|
||||
|
@ -552,12 +435,7 @@ BOOL netconn_send( netconn_t *conn, const void *msg, size_t len, int *sent )
|
|||
|
||||
return TRUE;
|
||||
}
|
||||
if ((*sent = sock_send( conn->socket, msg, len, 0 )) == -1)
|
||||
{
|
||||
set_last_error( sock_get_error( errno ) );
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
return ((*sent = sock_send( conn->socket, msg, len, 0 )) != -1);
|
||||
}
|
||||
|
||||
static BOOL read_ssl_chunk(netconn_t *conn, void *buf, SIZE_T buf_size, SIZE_T *ret_size, BOOL *eof)
|
||||
|
@ -700,12 +578,7 @@ BOOL netconn_recv( netconn_t *conn, void *buf, size_t len, int flags, int *recvd
|
|||
*recvd = size;
|
||||
return TRUE;
|
||||
}
|
||||
if ((*recvd = sock_recv( conn->socket, buf, len, flags )) == -1)
|
||||
{
|
||||
set_last_error( sock_get_error( errno ) );
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
return ((*recvd = sock_recv( conn->socket, buf, len, flags )) != -1);
|
||||
}
|
||||
|
||||
ULONG netconn_query_data_available( netconn_t *conn )
|
||||
|
@ -715,86 +588,54 @@ ULONG netconn_query_data_available( netconn_t *conn )
|
|||
|
||||
DWORD netconn_set_timeout( netconn_t *netconn, BOOL send, int value )
|
||||
{
|
||||
struct timeval tv;
|
||||
|
||||
/* value is in milliseconds, convert to struct timeval */
|
||||
tv.tv_sec = value / 1000;
|
||||
tv.tv_usec = (value % 1000) * 1000;
|
||||
|
||||
if (setsockopt( netconn->socket, SOL_SOCKET, send ? SO_SNDTIMEO : SO_RCVTIMEO, (void*)&tv, sizeof(tv) ) == -1)
|
||||
int opt = send ? SO_SNDTIMEO : SO_RCVTIMEO;
|
||||
if (setsockopt( netconn->socket, SOL_SOCKET, opt, (void *)&value, sizeof(value) ) == -1)
|
||||
{
|
||||
WARN("setsockopt failed (%s)\n", strerror( errno ));
|
||||
return sock_get_error( errno );
|
||||
DWORD err = WSAGetLastError();
|
||||
WARN("setsockopt failed (%u)\n", err );
|
||||
return err;
|
||||
}
|
||||
return ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
BOOL netconn_is_alive( netconn_t *netconn )
|
||||
{
|
||||
#ifdef MSG_DONTWAIT
|
||||
ssize_t len;
|
||||
BYTE b;
|
||||
|
||||
len = recv( netconn->socket, &b, 1, MSG_PEEK | MSG_DONTWAIT );
|
||||
return len == 1 || (len == -1 && errno == EWOULDBLOCK);
|
||||
#elif defined(__MINGW32__) || defined(_MSC_VER)
|
||||
ULONG mode;
|
||||
int len;
|
||||
char b;
|
||||
DWORD err;
|
||||
|
||||
mode = 1;
|
||||
if(!ioctlsocket(netconn->socket, FIONBIO, &mode))
|
||||
return FALSE;
|
||||
set_blocking( netconn, FALSE );
|
||||
len = sock_recv( netconn->socket, &b, 1, MSG_PEEK );
|
||||
err = WSAGetLastError();
|
||||
set_blocking( netconn, TRUE );
|
||||
|
||||
len = recv(netconn->socket, &b, 1, MSG_PEEK);
|
||||
|
||||
mode = 0;
|
||||
if(!ioctlsocket(netconn->socket, FIONBIO, &mode))
|
||||
return FALSE;
|
||||
|
||||
return len == 1 || (len == -1 && WSAGetLastError() == WSAEWOULDBLOCK);
|
||||
#else
|
||||
FIXME("not supported on this platform\n");
|
||||
return TRUE;
|
||||
#endif
|
||||
return len == 1 || (len == -1 && err == WSAEWOULDBLOCK);
|
||||
}
|
||||
|
||||
static DWORD resolve_hostname( const WCHAR *hostnameW, INTERNET_PORT port, struct sockaddr_storage *sa )
|
||||
static DWORD resolve_hostname( const WCHAR *name, INTERNET_PORT port, struct sockaddr_storage *sa )
|
||||
{
|
||||
char *hostname;
|
||||
#ifdef HAVE_GETADDRINFO
|
||||
struct addrinfo *res, hints;
|
||||
ADDRINFOW *res, hints;
|
||||
int ret;
|
||||
#else
|
||||
struct hostent *he;
|
||||
struct sockaddr_in *sin = (struct sockaddr_in *)sa;
|
||||
#endif
|
||||
|
||||
if (!(hostname = strdupWA( hostnameW ))) return ERROR_OUTOFMEMORY;
|
||||
|
||||
#ifdef HAVE_GETADDRINFO
|
||||
memset( &hints, 0, sizeof(struct addrinfo) );
|
||||
memset( &hints, 0, sizeof(hints) );
|
||||
/* Prefer IPv4 to IPv6 addresses, since some web servers do not listen on
|
||||
* their IPv6 addresses even though they have IPv6 addresses in the DNS.
|
||||
*/
|
||||
hints.ai_family = AF_INET;
|
||||
|
||||
ret = getaddrinfo( hostname, NULL, &hints, &res );
|
||||
ret = GetAddrInfoW( name, NULL, &hints, &res );
|
||||
if (ret != 0)
|
||||
{
|
||||
TRACE("failed to get IPv4 address of %s (%s), retrying with IPv6\n", debugstr_w(hostnameW), gai_strerror(ret));
|
||||
TRACE("failed to get IPv4 address of %s, retrying with IPv6\n", debugstr_w(name));
|
||||
hints.ai_family = AF_INET6;
|
||||
ret = getaddrinfo( hostname, NULL, &hints, &res );
|
||||
ret = GetAddrInfoW( name, NULL, &hints, &res );
|
||||
if (ret != 0)
|
||||
{
|
||||
TRACE("failed to get address of %s (%s)\n", debugstr_w(hostnameW), gai_strerror(ret));
|
||||
heap_free( hostname );
|
||||
TRACE("failed to get address of %s\n", debugstr_w(name));
|
||||
return ERROR_WINHTTP_NAME_NOT_RESOLVED;
|
||||
}
|
||||
}
|
||||
heap_free( hostname );
|
||||
memcpy( sa, res->ai_addr, res->ai_addrlen );
|
||||
/* Copy port */
|
||||
switch (res->ai_family)
|
||||
{
|
||||
case AF_INET:
|
||||
|
@ -805,27 +646,8 @@ static DWORD resolve_hostname( const WCHAR *hostnameW, INTERNET_PORT port, struc
|
|||
break;
|
||||
}
|
||||
|
||||
freeaddrinfo( res );
|
||||
FreeAddrInfoW( res );
|
||||
return ERROR_SUCCESS;
|
||||
#else
|
||||
EnterCriticalSection( &cs_gethostbyname );
|
||||
|
||||
he = gethostbyname( hostname );
|
||||
heap_free( hostname );
|
||||
if (!he)
|
||||
{
|
||||
TRACE("failed to get address of %s (%d)\n", debugstr_w(hostnameW), h_errno);
|
||||
LeaveCriticalSection( &cs_gethostbyname );
|
||||
return ERROR_WINHTTP_NAME_NOT_RESOLVED;
|
||||
}
|
||||
memset( sa, 0, sizeof(struct sockaddr_in) );
|
||||
memcpy( &sin->sin_addr, he->h_addr, he->h_length );
|
||||
sin->sin_family = he->h_addrtype;
|
||||
sin->sin_port = htons( port );
|
||||
|
||||
LeaveCriticalSection( &cs_gethostbyname );
|
||||
return ERROR_SUCCESS;
|
||||
#endif
|
||||
}
|
||||
|
||||
struct resolve_args
|
||||
|
|
|
@ -21,13 +21,9 @@
|
|||
|
||||
#define COBJMACROS
|
||||
#include "config.h"
|
||||
#include "wine/port.h"
|
||||
|
||||
#include "ws2tcpip.h"
|
||||
#include <stdarg.h>
|
||||
#include <assert.h>
|
||||
#ifdef HAVE_ARPA_INET_H
|
||||
# include <arpa/inet.h>
|
||||
#endif
|
||||
|
||||
#include "windef.h"
|
||||
#include "winbase.h"
|
||||
|
@ -38,9 +34,8 @@
|
|||
#include "schannel.h"
|
||||
#include "winhttp.h"
|
||||
|
||||
#include "winhttp_private.h"
|
||||
|
||||
#include "wine/debug.h"
|
||||
#include "winhttp_private.h"
|
||||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(winhttp);
|
||||
|
||||
|
@ -1481,10 +1476,6 @@ static BOOL secure_proxy_connect( request_t *request )
|
|||
return ret;
|
||||
}
|
||||
|
||||
#ifndef INET6_ADDRSTRLEN
|
||||
#define INET6_ADDRSTRLEN 46
|
||||
#endif
|
||||
|
||||
static WCHAR *addr_to_str( struct sockaddr_storage *addr )
|
||||
{
|
||||
char buf[INET6_ADDRSTRLEN];
|
||||
|
|
|
@ -17,9 +17,7 @@
|
|||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "wine/port.h"
|
||||
#include "wine/debug.h"
|
||||
|
||||
#include "ws2tcpip.h"
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
@ -34,9 +32,6 @@
|
|||
|
||||
#include "windef.h"
|
||||
#include "winbase.h"
|
||||
#ifndef __MINGW32__
|
||||
#define USE_WS_PREFIX
|
||||
#endif
|
||||
#include "winsock2.h"
|
||||
#include "ws2ipdef.h"
|
||||
#include "winhttp.h"
|
||||
|
@ -46,6 +41,7 @@
|
|||
#include "dispex.h"
|
||||
#include "activscp.h"
|
||||
|
||||
#include "wine/debug.h"
|
||||
#include "winhttp_private.h"
|
||||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(winhttp);
|
||||
|
@ -649,46 +645,8 @@ static WCHAR *blob_to_str( DWORD encoding, CERT_NAME_BLOB *blob )
|
|||
return ret;
|
||||
}
|
||||
|
||||
static BOOL convert_sockaddr( const struct sockaddr *addr, SOCKADDR_STORAGE *addr_storage )
|
||||
static BOOL copy_sockaddr( const struct sockaddr *addr, SOCKADDR_STORAGE *addr_storage )
|
||||
{
|
||||
#ifndef __MINGW32__
|
||||
switch (addr->sa_family)
|
||||
{
|
||||
case AF_INET:
|
||||
{
|
||||
const struct sockaddr_in *addr_unix = (const struct sockaddr_in *)addr;
|
||||
struct WS_sockaddr_in *addr_win = (struct WS_sockaddr_in *)addr_storage;
|
||||
char *p;
|
||||
|
||||
addr_win->sin_family = WS_AF_INET;
|
||||
addr_win->sin_port = addr_unix->sin_port;
|
||||
memcpy( &addr_win->sin_addr, &addr_unix->sin_addr, 4 );
|
||||
p = (char *)&addr_win->sin_addr + 4;
|
||||
memset( p, 0, sizeof(*addr_storage) - (p - (char *)addr_win) );
|
||||
return TRUE;
|
||||
}
|
||||
case AF_INET6:
|
||||
{
|
||||
const struct sockaddr_in6 *addr_unix = (const struct sockaddr_in6 *)addr;
|
||||
struct WS_sockaddr_in6 *addr_win = (struct WS_sockaddr_in6 *)addr_storage;
|
||||
|
||||
addr_win->sin6_family = WS_AF_INET6;
|
||||
addr_win->sin6_port = addr_unix->sin6_port;
|
||||
addr_win->sin6_flowinfo = addr_unix->sin6_flowinfo;
|
||||
memcpy( &addr_win->sin6_addr, &addr_unix->sin6_addr, 16 );
|
||||
#ifdef HAVE_STRUCT_SOCKADDR_IN6_SIN6_SCOPE_ID
|
||||
addr_win->sin6_scope_id = addr_unix->sin6_scope_id;
|
||||
#else
|
||||
addr_win->sin6_scope_id = 0;
|
||||
#endif
|
||||
memset( addr_win + 1, 0, sizeof(*addr_storage) - sizeof(*addr_win) );
|
||||
return TRUE;
|
||||
}
|
||||
default:
|
||||
ERR("unhandled family %u\n", addr->sa_family);
|
||||
return FALSE;
|
||||
}
|
||||
#else
|
||||
switch (addr->sa_family)
|
||||
{
|
||||
case AF_INET:
|
||||
|
@ -711,7 +669,6 @@ static BOOL convert_sockaddr( const struct sockaddr *addr, SOCKADDR_STORAGE *add
|
|||
ERR("unhandled family %u\n", addr->sa_family);
|
||||
return FALSE;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static BOOL request_query_option( object_header_t *hdr, DWORD option, LPVOID buffer, LPDWORD buflen )
|
||||
|
@ -829,8 +786,8 @@ static BOOL request_query_option( object_header_t *hdr, DWORD option, LPVOID buf
|
|||
return FALSE;
|
||||
}
|
||||
if (getsockname( request->netconn->socket, &local, &len )) return FALSE;
|
||||
if (!convert_sockaddr( &local, &info->LocalAddress )) return FALSE;
|
||||
if (!convert_sockaddr( remote, &info->RemoteAddress )) return FALSE;
|
||||
if (!copy_sockaddr( &local, &info->LocalAddress )) return FALSE;
|
||||
if (!copy_sockaddr( remote, &info->RemoteAddress )) return FALSE;
|
||||
info->cbSize = sizeof(*info);
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -1338,11 +1295,7 @@ static BOOL is_domain_suffix( const char *domain, const char *suffix )
|
|||
|
||||
static int reverse_lookup( const struct addrinfo *ai, char *hostname, size_t len )
|
||||
{
|
||||
int ret = -1;
|
||||
#ifdef HAVE_GETNAMEINFO
|
||||
ret = getnameinfo( ai->ai_addr, ai->ai_addrlen, hostname, len, NULL, 0, 0 );
|
||||
#endif
|
||||
return ret;
|
||||
return getnameinfo( ai->ai_addr, ai->ai_addrlen, hostname, len, NULL, 0, 0 );
|
||||
}
|
||||
|
||||
static WCHAR *build_wpad_url( const char *hostname, const struct addrinfo *ai )
|
||||
|
@ -1434,7 +1387,6 @@ BOOL WINAPI WinHttpDetectAutoProxyConfigUrl( DWORD flags, LPWSTR *url )
|
|||
}
|
||||
if (flags & WINHTTP_AUTO_DETECT_TYPE_DNS_A)
|
||||
{
|
||||
#ifdef HAVE_GETADDRINFO
|
||||
char *fqdn, *domain, *p;
|
||||
|
||||
if (!(fqdn = get_computer_name( ComputerNamePhysicalDnsFullyQualified ))) return FALSE;
|
||||
|
@ -1476,9 +1428,6 @@ BOOL WINAPI WinHttpDetectAutoProxyConfigUrl( DWORD flags, LPWSTR *url )
|
|||
}
|
||||
heap_free( domain );
|
||||
heap_free( fqdn );
|
||||
#else
|
||||
FIXME("getaddrinfo not found at build time\n");
|
||||
#endif
|
||||
}
|
||||
if (!ret)
|
||||
{
|
||||
|
|
|
@ -17,16 +17,16 @@
|
|||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "ws2tcpip.h"
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "wine/debug.h"
|
||||
|
||||
#include "windef.h"
|
||||
#include "winbase.h"
|
||||
#include "winreg.h"
|
||||
#include "winhttp.h"
|
||||
#include "shlwapi.h"
|
||||
|
||||
#include "wine/debug.h"
|
||||
#include "winhttp_private.h"
|
||||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(winhttp);
|
||||
|
|
|
@ -27,23 +27,6 @@
|
|||
#include "wine/list.h"
|
||||
#include "wine/unicode.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
#ifdef HAVE_SYS_SOCKET_H
|
||||
# include <sys/socket.h>
|
||||
#endif
|
||||
#ifdef HAVE_NETINET_IN_H
|
||||
# include <netinet/in.h>
|
||||
#endif
|
||||
#ifdef HAVE_NETDB_H
|
||||
# include <netdb.h>
|
||||
#endif
|
||||
#if defined(__MINGW32__) || defined (_MSC_VER)
|
||||
# include <ws2tcpip.h>
|
||||
#else
|
||||
# define closesocket close
|
||||
# define ioctlsocket ioctl
|
||||
#endif
|
||||
|
||||
#include "ole2.h"
|
||||
#include "sspi.h"
|
||||
#include "wincrypt.h"
|
||||
|
@ -301,7 +284,7 @@ DWORD get_last_error( void ) DECLSPEC_HIDDEN;
|
|||
void send_callback( object_header_t *, DWORD, LPVOID, DWORD ) DECLSPEC_HIDDEN;
|
||||
void close_connection( request_t * ) DECLSPEC_HIDDEN;
|
||||
|
||||
BOOL netconn_close( netconn_t * ) DECLSPEC_HIDDEN;
|
||||
void netconn_close( netconn_t * ) DECLSPEC_HIDDEN;
|
||||
netconn_t *netconn_create( hostdata_t *, const struct sockaddr_storage *, int ) DECLSPEC_HIDDEN;
|
||||
void netconn_unload( void ) DECLSPEC_HIDDEN;
|
||||
ULONG netconn_query_data_available( netconn_t * ) DECLSPEC_HIDDEN;
|
||||
|
|
Loading…
Reference in New Issue