mswsock: Implement 3 functions by calling through SIO_GET_EXTENSION_FUNCTION_POINTER.

This commit is contained in:
Jon Griffiths 2008-07-13 12:22:33 -07:00 committed by Alexandre Julliard
parent 8e86162be5
commit 2da98052d9

View file

@ -31,95 +31,127 @@
WINE_DEFAULT_DEBUG_CHANNEL(mswsock);
static LPFN_ACCEPTEX acceptex_fn;
static LPFN_GETACCEPTEXSOCKADDRS acceptexsockaddrs_fn;
static LPFN_TRANSMITFILE transmitfile_fn;
static BOOL initialised;
/* Get pointers to the ws2_32 implementations.
* NOTE: This assumes that ws2_32 contains only one implementation
* of these functions, i.e. that you cannot get different functions
* back by passing another socket in. If that ever changes, we'll need
* to think about associating the functions with the socket and
* exposing that information to this dll somehow.
*/
static void get_fn(SOCKET s, GUID* guid, FARPROC* fn)
{
FARPROC func;
DWORD len;
if (!WSAIoctl(s, SIO_GET_EXTENSION_FUNCTION_POINTER, guid, sizeof(*guid),
&func, sizeof(func), &len, NULL, NULL))
*fn = func;
}
static void get_fn_pointers(SOCKET s)
{
GUID acceptex_guid = WSAID_ACCEPTEX;
GUID acceptexsockaddrs_guid = WSAID_GETACCEPTEXSOCKADDRS;
GUID transmitfile_guid = WSAID_TRANSMITFILE;
get_fn(s, &acceptex_guid, (FARPROC*)&acceptex_fn);
get_fn(s, &acceptexsockaddrs_guid, (FARPROC*)&acceptexsockaddrs_fn);
get_fn(s, &transmitfile_guid, (FARPROC*)&transmitfile_fn);
initialised = TRUE;
}
/***********************************************************************
* AcceptEx (MSWSOCK.@)
*
* This function is used to accept a new connection, get the local and remote
* address, and receive the initial block of data sent by the client.
* Accept a new connection, retrieving the connected addresses and initial data.
*
* TODO
* This function is currently implemented as a stub.
* listener [I] Listening socket
* acceptor [I] Socket to accept on
* dest [O] Destination for inital data
* dest_len [I] Size of dest in bytes
* local_addr_len [I] Number of bytes reserved in dest for local addrress
* rem_addr_len [I] Number of bytes reserved in dest for remote addrress
* received [O] Destination for number of bytes of initial data
* overlapped [I] For asynchronous execution
*
* RETURNS
* Success: TRUE
* Failure: FALSE. Use WSAGetLastError() for details of the error.
*/
BOOL WINAPI AcceptEx(
SOCKET sListenSocket, /* [in] Descriptor identifying a socket that
has already been called with the listen
function */
SOCKET sAcceptSocket, /* [in] Descriptor identifying a socket on
which to accept an incoming connection */
PVOID lpOutputBuffer, /* [in] Pointer to a buffer */
DWORD dwReceiveDataLength, /* [in] Number of bytes in lpOutputBuffer
that will be used for actual receive data
at the beginning of the buffer */
DWORD dwLocalAddressLength, /* [in] Number of bytes reserved for the
local address information */
DWORD dwRemoteAddressLength, /* [in] Number of bytes reserved for the
remote address information */
LPDWORD lpdwBytesReceived, /* [out] Pointer to a DWORD that receives
the count of bytes received */
LPOVERLAPPED lpOverlapped) /* [in] Specify in order to achieve an
overlapped (asynchronous) I/O
operation */
BOOL WINAPI AcceptEx(SOCKET listener, SOCKET acceptor, PVOID dest, DWORD dest_len,
DWORD local_addr_len, DWORD rem_addr_len, LPDWORD received,
LPOVERLAPPED overlapped)
{
FIXME("(listen=%ld, accept=%ld, %p, %d, %d, %d, %p, %p), not implemented\n",
sListenSocket,sAcceptSocket,lpOutputBuffer,dwReceiveDataLength,
dwLocalAddressLength,dwRemoteAddressLength,lpdwBytesReceived,lpOverlapped
);
return FALSE;
if (!initialised)
get_fn_pointers(acceptor);
if (!acceptex_fn)
return FALSE;
return acceptex_fn(listener, acceptor, dest, dest_len, local_addr_len,
rem_addr_len, received, overlapped);
}
/***********************************************************************
* GetAcceptExSockaddrs (MSWSOCK.@)
*
* Get infomation about an accepted socket.
*
* data [O] Destination for the first block of data from AcceptEx()
* data_len [I] length of data in bytes
* local_len [I] Bytes reserved for local addrinfo
* rem_len [I] Bytes reserved for remote addrinfo
* local_addr [O] Destination for local sockaddr
* local_addr_len [I] Size of local_addr
* rem_addr [O] Destination for remote sockaddr
* rem_addr_len [I] Size of rem_addr
*
* RETURNS
* Nothing.
*/
VOID WINAPI GetAcceptExSockaddrs(
PVOID lpOutputBuffer, /* [in] Pointer to a buffer */
DWORD dwReceiveDataLength, /* [in] Number of bytes in the buffer used
for receiving the first data */
DWORD dwLocalAddressLength, /* [in] Number of bytes reserved for the
local address information */
DWORD dwRemoteAddressLength, /* [in] Number of bytes reserved for the
remote address information */
struct sockaddr **LocalSockaddr, /* [out] Pointer to the sockaddr
structure that receives the local
address of the connection */
LPINT LocalSockaddrLength, /* [out] Size in bytes of the local
address */
struct sockaddr **RemoteSockaddr, /* [out] Pointer to the sockaddr
structure that receives the remote
address of the connection */
LPINT RemoteSockaddrLength) /* [out] Size in bytes of the remote address */
VOID WINAPI GetAcceptExSockaddrs(PVOID data, DWORD data_len, DWORD local_len, DWORD rem_len,
struct sockaddr **local_addr, LPINT local_addr_len,
struct sockaddr **rem_addr, LPINT rem_addr_len)
{
FIXME("not implemented\n");
if (acceptexsockaddrs_fn)
acceptexsockaddrs_fn(data, data_len, local_len, rem_len,
local_addr, local_addr_len, rem_addr, rem_addr_len);
}
/***********************************************************************
* TransmitFile (MSWSOCK.@)
*
* This function is used to transmit a file over socket.
* Transmit a file over a socket.
*
* TODO
* This function is currently implemented as a stub.
* PARAMS
* s [I] Handle to a connected socket
* file [I] Opened file handle for file to send
* total_len [I] Total number of file bytes to send
* chunk_len [I] Chunk size to send file in (0=default)
* overlapped [I] For asynchronous operation
* buffers [I] Head/tail data, or NULL if none
* flags [I] TF_ Flags from mswsock.h
*
* RETURNS
* Success: TRUE
* Failure: FALSE. Use WSAGetLastError() for details of the error.
*/
BOOL WINAPI TransmitFile(
SOCKET hSocket, /* [in] Handle to a connected socket */
HANDLE hFile, /* [in] Handle to the open file that should be
transmitted */
DWORD nNumberOfBytesToWrite, /* [in] Number of file bytes to
transmit */
DWORD nNumberOfBytesPerSend, /* [in] Size in bytes of each block of
data sent in each send operation */
LPOVERLAPPED lpOverlapped, /* [in] Specify in order to achieve an
overlapped (asynchronous) I/O
operation */
LPTRANSMIT_FILE_BUFFERS lpTransmitBuffers,
/* [in] Contains pointers to data to send before and after
the file data is sent */
DWORD dwFlags) /* [in] Flags */
BOOL WINAPI TransmitFile(SOCKET s, HANDLE file, DWORD total_len,
DWORD chunk_len, LPOVERLAPPED overlapped,
LPTRANSMIT_FILE_BUFFERS buffers, DWORD flags)
{
FIXME("not implemented\n");
if (!initialised)
get_fn_pointers(s);
return FALSE;
if (!transmitfile_fn)
return FALSE;
return transmitfile_fn(s, file, total_len, chunk_len, overlapped, buffers, flags);
}
/***********************************************************************