mirror of
https://github.com/reactos/reactos.git
synced 2025-05-29 22:18:13 +00:00
Revert r73068 and r73070
Current tests are obviously not enough to declare them OK. I'll add more tests first svn path=/trunk/; revision=73074
This commit is contained in:
parent
78ad433718
commit
55d4688b34
3 changed files with 25 additions and 132 deletions
|
@ -95,33 +95,13 @@ WSPSocket(int AddressFamily,
|
|||
Protocol = SharedData->Protocol;
|
||||
}
|
||||
|
||||
if (lpProtocolInfo)
|
||||
{
|
||||
if (lpProtocolInfo->iAddressFamily && AddressFamily <= 0)
|
||||
AddressFamily = lpProtocolInfo->iAddressFamily;
|
||||
if (lpProtocolInfo->iSocketType && SocketType <= 0)
|
||||
SocketType = lpProtocolInfo->iSocketType;
|
||||
if (lpProtocolInfo->iProtocol && Protocol <= 0)
|
||||
Protocol = lpProtocolInfo->iProtocol;
|
||||
}
|
||||
|
||||
/* FIXME: AF_NETDES should be AF_MAX */
|
||||
if (AddressFamily < AF_UNSPEC || AddressFamily > AF_NETDES)
|
||||
return WSAEINVAL;
|
||||
|
||||
if (SocketType < 0 && SocketType > SOCK_SEQPACKET)
|
||||
return WSAEINVAL;
|
||||
|
||||
if (Protocol < 0 && Protocol > IPPROTO_MAX)
|
||||
return WSAEINVAL;
|
||||
|
||||
/* when no protocol and socket type are specified the first entry
|
||||
* from WSAEnumProtocols that has the flag PFL_MATCHES_PROTOCOL_ZERO
|
||||
* is returned */
|
||||
if (SocketType == 0 && Protocol == 0 && lpProtocolInfo && (lpProtocolInfo->dwProviderFlags & PFL_MATCHES_PROTOCOL_ZERO) == 0)
|
||||
if (AddressFamily == AF_UNSPEC && SocketType == 0 && Protocol == 0)
|
||||
return WSAEINVAL;
|
||||
|
||||
/* Set the defaults */
|
||||
if (AddressFamily == AF_UNSPEC)
|
||||
AddressFamily = AF_INET;
|
||||
|
||||
if (SocketType == 0)
|
||||
{
|
||||
switch (Protocol)
|
||||
|
@ -137,7 +117,8 @@ WSPSocket(int AddressFamily,
|
|||
break;
|
||||
default:
|
||||
TRACE("Unknown Protocol (%d). We will try SOCK_STREAM.\n", Protocol);
|
||||
return WSAEINVAL;
|
||||
SocketType = SOCK_STREAM;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -156,13 +137,11 @@ WSPSocket(int AddressFamily,
|
|||
break;
|
||||
default:
|
||||
TRACE("Unknown SocketType (%d). We will try IPPROTO_TCP.\n", SocketType);
|
||||
return WSAEINVAL;
|
||||
Protocol = IPPROTO_TCP;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (AddressFamily == AF_UNSPEC)
|
||||
return WSAEINVAL;
|
||||
|
||||
/* Get Helper Data and Transport */
|
||||
Status = SockGetTdiName (&AddressFamily,
|
||||
&SocketType,
|
||||
|
@ -1719,46 +1698,6 @@ WSPAccept(SOCKET Handle,
|
|||
return AcceptSocket;
|
||||
}
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
AfdConnectAPC(PVOID ApcContext,
|
||||
PIO_STATUS_BLOCK IoStatusBlock,
|
||||
ULONG Reserved)
|
||||
{
|
||||
PAFDCONNECTAPCCONTEXT Context = ApcContext;
|
||||
|
||||
if (IoStatusBlock->Status == STATUS_SUCCESS)
|
||||
{
|
||||
Context->lpSocket->SharedData->State = SocketConnected;
|
||||
Context->lpSocket->TdiConnectionHandle = (HANDLE)IoStatusBlock->Information;
|
||||
}
|
||||
|
||||
if (Context->lpConnectInfo) HeapFree(GetProcessHeap(), 0, Context->lpConnectInfo);
|
||||
|
||||
/* Re-enable Async Event */
|
||||
SockReenableAsyncSelectEvent(Context->lpSocket, FD_WRITE);
|
||||
|
||||
/* FIXME: THIS IS NOT RIGHT!!! HACK HACK HACK! */
|
||||
SockReenableAsyncSelectEvent(Context->lpSocket, FD_CONNECT);
|
||||
|
||||
if (IoStatusBlock->Status == STATUS_SUCCESS && (Context->lpSocket->HelperEvents & WSH_NOTIFY_CONNECT))
|
||||
{
|
||||
Context->lpSocket->HelperData->WSHNotify(Context->lpSocket->HelperContext,
|
||||
Context->lpSocket->Handle,
|
||||
Context->lpSocket->TdiAddressHandle,
|
||||
Context->lpSocket->TdiConnectionHandle,
|
||||
WSH_NOTIFY_CONNECT);
|
||||
}
|
||||
else if (IoStatusBlock->Status != STATUS_SUCCESS && (Context->lpSocket->HelperEvents & WSH_NOTIFY_CONNECT_ERROR))
|
||||
{
|
||||
Context->lpSocket->HelperData->WSHNotify(Context->lpSocket->HelperContext,
|
||||
Context->lpSocket->Handle,
|
||||
Context->lpSocket->TdiAddressHandle,
|
||||
Context->lpSocket->TdiConnectionHandle,
|
||||
WSH_NOTIFY_CONNECT_ERROR);
|
||||
}
|
||||
HeapFree(GlobalHeap, 0, ApcContext);
|
||||
}
|
||||
int
|
||||
WSPAPI
|
||||
WSPConnect(SOCKET Handle,
|
||||
|
@ -1781,18 +1720,6 @@ WSPConnect(SOCKET Handle,
|
|||
PSOCKADDR BindAddress;
|
||||
HANDLE SockEvent;
|
||||
int SocketDataLength;
|
||||
PVOID APCContext = NULL;
|
||||
PVOID APCFunction = NULL;
|
||||
|
||||
TRACE("Called\n");
|
||||
|
||||
/* Get the Socket Structure associate to this Socket*/
|
||||
Socket = GetSocketStructure(Handle);
|
||||
if (!Socket)
|
||||
{
|
||||
if (lpErrno) *lpErrno = WSAENOTSOCK;
|
||||
return SOCKET_ERROR;
|
||||
}
|
||||
|
||||
Status = NtCreateEvent(&SockEvent,
|
||||
EVENT_ALL_ACCESS,
|
||||
|
@ -1803,6 +1730,17 @@ WSPConnect(SOCKET Handle,
|
|||
if (!NT_SUCCESS(Status))
|
||||
return MsafdReturnWithErrno(Status, lpErrno, 0, NULL);
|
||||
|
||||
TRACE("Called\n");
|
||||
|
||||
/* Get the Socket Structure associate to this Socket*/
|
||||
Socket = GetSocketStructure(Handle);
|
||||
if (!Socket)
|
||||
{
|
||||
NtClose(SockEvent);
|
||||
if (lpErrno) *lpErrno = WSAENOTSOCK;
|
||||
return SOCKET_ERROR;
|
||||
}
|
||||
|
||||
/* Bind us First */
|
||||
if (Socket->SharedData->State == SocketOpen)
|
||||
{
|
||||
|
@ -1913,22 +1851,14 @@ WSPConnect(SOCKET Handle,
|
|||
/* FIXME: Handle Async Connect */
|
||||
if (Socket->SharedData->NonBlocking)
|
||||
{
|
||||
APCFunction = &AfdConnectAPC; // should be a private io completition function inside us
|
||||
APCContext = HeapAlloc(GlobalHeap, 0, sizeof(AFDCONNECTAPCCONTEXT));
|
||||
if (!APCContext)
|
||||
{
|
||||
ERR("Not enough memory for APC Context\n");
|
||||
return MsafdReturnWithErrno(STATUS_INSUFFICIENT_RESOURCES, lpErrno, 0, NULL);
|
||||
}
|
||||
((PAFDCONNECTAPCCONTEXT)APCContext)->lpConnectInfo = ConnectInfo;
|
||||
((PAFDCONNECTAPCCONTEXT)APCContext)->lpSocket = Socket;
|
||||
ERR("Async Connect UNIMPLEMENTED!\n");
|
||||
}
|
||||
|
||||
/* Send IOCTL */
|
||||
Status = NtDeviceIoControlFile((HANDLE)Handle,
|
||||
SockEvent,
|
||||
APCFunction,
|
||||
APCContext,
|
||||
NULL,
|
||||
NULL,
|
||||
&IOSB,
|
||||
IOCTL_AFD_CONNECT,
|
||||
ConnectInfo,
|
||||
|
@ -1936,20 +1866,12 @@ WSPConnect(SOCKET Handle,
|
|||
NULL,
|
||||
0);
|
||||
/* Wait for return */
|
||||
if (Status == STATUS_PENDING && !Socket->SharedData->NonBlocking)
|
||||
if (Status == STATUS_PENDING)
|
||||
{
|
||||
WaitForSingleObject(SockEvent, INFINITE);
|
||||
Status = IOSB.Status;
|
||||
}
|
||||
|
||||
if (Status == STATUS_PENDING)
|
||||
{
|
||||
TRACE("Leaving (Pending)\n");
|
||||
return MsafdReturnWithErrno(STATUS_CANT_WAIT, lpErrno, 0, NULL);
|
||||
}
|
||||
|
||||
if (APCContext) HeapFree(GetProcessHeap(), 0, APCContext);
|
||||
|
||||
if (Status != STATUS_SUCCESS)
|
||||
goto notify;
|
||||
|
||||
|
|
|
@ -135,12 +135,6 @@ typedef struct _AFDAPCCONTEXT
|
|||
PSOCKET_INFORMATION lpSocket;
|
||||
} AFDAPCCONTEXT, *PAFDAPCCONTEXT;
|
||||
|
||||
typedef struct _AFDCONNECTAPCCONTEXT
|
||||
{
|
||||
PAFD_CONNECT_INFO lpConnectInfo;
|
||||
PSOCKET_INFORMATION lpSocket;
|
||||
} AFDCONNECTAPCCONTEXT, *PAFDCONNECTAPCCONTEXT;
|
||||
|
||||
SOCKET
|
||||
WSPAPI
|
||||
WSPAccept(
|
||||
|
|
|
@ -490,20 +490,6 @@ WsTcGetEntryFromTriplet(IN PTCATALOG Catalog,
|
|||
/* Assume failure */
|
||||
*CatalogEntry = NULL;
|
||||
|
||||
/* Params can't be all wildcards */
|
||||
if (af == AF_UNSPEC && type == 0 && protocol == 0)
|
||||
return WSAEINVAL;
|
||||
|
||||
/* FIXME: AF_NETDES should be AF_MAX */
|
||||
if (af < AF_UNSPEC || af > AF_NETDES)
|
||||
return WSAEINVAL;
|
||||
|
||||
if (type < 0 && type > SOCK_SEQPACKET)
|
||||
return WSAEINVAL;
|
||||
|
||||
if (protocol < 0 && protocol > IPPROTO_MAX)
|
||||
return WSAEINVAL;
|
||||
|
||||
/* Lock the catalog */
|
||||
WsTcLock();
|
||||
|
||||
|
@ -541,13 +527,6 @@ WsTcGetEntryFromTriplet(IN PTCATALOG Catalog,
|
|||
Entry->ProtocolInfo.iProtocolMaxOffset) >= protocol)) ||
|
||||
(protocol == 0))
|
||||
{
|
||||
/* Check that if type and protocol are 0 provider entry has PFL_MATCHES_PROTOCOL_ZERO flag set */
|
||||
if (type == 0 && protocol == 0 && (Entry->ProtocolInfo.dwProviderFlags & PFL_MATCHES_PROTOCOL_ZERO) == 0)
|
||||
{
|
||||
ErrorCode = WSAEPROTONOSUPPORT;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Check if it doesn't already have a provider */
|
||||
if (!Entry->Provider)
|
||||
{
|
||||
|
@ -571,14 +550,12 @@ WsTcGetEntryFromTriplet(IN PTCATALOG Catalog,
|
|||
}
|
||||
else
|
||||
{
|
||||
if (ErrorCode != WSAEPROTONOSUPPORT)
|
||||
ErrorCode = WSAESOCKTNOSUPPORT;
|
||||
ErrorCode = WSAESOCKTNOSUPPORT;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ErrorCode != WSAEPROTONOSUPPORT && ErrorCode != WSAESOCKTNOSUPPORT)
|
||||
ErrorCode = WSAEAFNOSUPPORT;
|
||||
ErrorCode = WSAEAFNOSUPPORT;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue