mirror of
https://github.com/reactos/reactos.git
synced 2024-10-15 13:45:58 +00:00
[MSAFD][WS2_32]
- Properly return error codes from WSPConnect CORE-12787 #resolve svn path=/trunk/; revision=73849
This commit is contained in:
parent
3499311e18
commit
f78f7b3f31
|
@ -79,16 +79,25 @@ WSPSocket(int AddressFamily,
|
||||||
{
|
{
|
||||||
/* Duplpicating socket from different process */
|
/* Duplpicating socket from different process */
|
||||||
if ((HANDLE)lpProtocolInfo->dwServiceFlags3 == INVALID_HANDLE_VALUE)
|
if ((HANDLE)lpProtocolInfo->dwServiceFlags3 == INVALID_HANDLE_VALUE)
|
||||||
return WSAEINVAL;
|
{
|
||||||
|
Status = WSAEINVAL;
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
if ((HANDLE)lpProtocolInfo->dwServiceFlags4 == INVALID_HANDLE_VALUE)
|
if ((HANDLE)lpProtocolInfo->dwServiceFlags4 == INVALID_HANDLE_VALUE)
|
||||||
return WSAEINVAL;
|
{
|
||||||
|
Status = WSAEINVAL;
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
SharedData = MapViewOfFile((HANDLE)lpProtocolInfo->dwServiceFlags3,
|
SharedData = MapViewOfFile((HANDLE)lpProtocolInfo->dwServiceFlags3,
|
||||||
FILE_MAP_ALL_ACCESS,
|
FILE_MAP_ALL_ACCESS,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
sizeof(SOCK_SHARED_INFO));
|
sizeof(SOCK_SHARED_INFO));
|
||||||
if (!SharedData)
|
if (!SharedData)
|
||||||
return WSAEINVAL;
|
{
|
||||||
|
Status = WSAEINVAL;
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
InterlockedIncrement(&SharedData->RefCount);
|
InterlockedIncrement(&SharedData->RefCount);
|
||||||
AddressFamily = SharedData->AddressFamily;
|
AddressFamily = SharedData->AddressFamily;
|
||||||
SocketType = SharedData->SocketType;
|
SocketType = SharedData->SocketType;
|
||||||
|
@ -96,7 +105,10 @@ WSPSocket(int AddressFamily,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (AddressFamily == AF_UNSPEC && SocketType == 0 && Protocol == 0)
|
if (AddressFamily == AF_UNSPEC && SocketType == 0 && Protocol == 0)
|
||||||
return WSAEINVAL;
|
{
|
||||||
|
Status = WSAEINVAL;
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
/* Set the defaults */
|
/* Set the defaults */
|
||||||
if (AddressFamily == AF_UNSPEC)
|
if (AddressFamily == AF_UNSPEC)
|
||||||
|
@ -167,7 +179,7 @@ WSPSocket(int AddressFamily,
|
||||||
Socket = HeapAlloc(GlobalHeap, 0, sizeof(*Socket));
|
Socket = HeapAlloc(GlobalHeap, 0, sizeof(*Socket));
|
||||||
if (!Socket)
|
if (!Socket)
|
||||||
{
|
{
|
||||||
Status = STATUS_INSUFFICIENT_RESOURCES;
|
Status = WSAENOBUFS;
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
RtlZeroMemory(Socket, sizeof(*Socket));
|
RtlZeroMemory(Socket, sizeof(*Socket));
|
||||||
|
@ -184,7 +196,7 @@ WSPSocket(int AddressFamily,
|
||||||
Socket->SharedData = HeapAlloc(GlobalHeap, 0, sizeof(*Socket->SharedData));
|
Socket->SharedData = HeapAlloc(GlobalHeap, 0, sizeof(*Socket->SharedData));
|
||||||
if (!Socket->SharedData)
|
if (!Socket->SharedData)
|
||||||
{
|
{
|
||||||
Status = STATUS_INSUFFICIENT_RESOURCES;
|
Status = WSAENOBUFS;
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
RtlZeroMemory(Socket->SharedData, sizeof(*Socket->SharedData));
|
RtlZeroMemory(Socket->SharedData, sizeof(*Socket->SharedData));
|
||||||
|
@ -236,7 +248,7 @@ WSPSocket(int AddressFamily,
|
||||||
EABuffer = HeapAlloc(GlobalHeap, 0, SizeOfEA);
|
EABuffer = HeapAlloc(GlobalHeap, 0, SizeOfEA);
|
||||||
if (!EABuffer)
|
if (!EABuffer)
|
||||||
{
|
{
|
||||||
Status = STATUS_INSUFFICIENT_RESOURCES;
|
Status = WSAENOBUFS;
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -263,6 +275,7 @@ WSPSocket(int AddressFamily,
|
||||||
if ((SocketType != SOCK_DGRAM) && (SocketType != SOCK_RAW))
|
if ((SocketType != SOCK_DGRAM) && (SocketType != SOCK_RAW))
|
||||||
{
|
{
|
||||||
/* Only RAW or UDP can be Connectionless */
|
/* Only RAW or UDP can be Connectionless */
|
||||||
|
Status = WSAEINVAL;
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
AfdPacket->EndpointFlags |= AFD_ENDPOINT_CONNECTIONLESS;
|
AfdPacket->EndpointFlags |= AFD_ENDPOINT_CONNECTIONLESS;
|
||||||
|
@ -275,6 +288,7 @@ WSPSocket(int AddressFamily,
|
||||||
if ((Socket->SharedData->ServiceFlags1 & XP1_PSEUDO_STREAM) == 0)
|
if ((Socket->SharedData->ServiceFlags1 & XP1_PSEUDO_STREAM) == 0)
|
||||||
{
|
{
|
||||||
/* The Provider doesn't actually support Message Oriented Streams */
|
/* The Provider doesn't actually support Message Oriented Streams */
|
||||||
|
Status = WSAEINVAL;
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -291,6 +305,7 @@ WSPSocket(int AddressFamily,
|
||||||
if ((Socket->SharedData->ServiceFlags1 & XP1_SUPPORT_MULTIPOINT) == 0)
|
if ((Socket->SharedData->ServiceFlags1 & XP1_SUPPORT_MULTIPOINT) == 0)
|
||||||
{
|
{
|
||||||
/* The Provider doesn't actually support Multipoint */
|
/* The Provider doesn't actually support Multipoint */
|
||||||
|
Status = WSAEINVAL;
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
AfdPacket->EndpointFlags |= AFD_ENDPOINT_MULTIPOINT;
|
AfdPacket->EndpointFlags |= AFD_ENDPOINT_MULTIPOINT;
|
||||||
|
@ -301,6 +316,7 @@ WSPSocket(int AddressFamily,
|
||||||
|| ((dwFlags & WSA_FLAG_MULTIPOINT_C_LEAF) != 0))
|
|| ((dwFlags & WSA_FLAG_MULTIPOINT_C_LEAF) != 0))
|
||||||
{
|
{
|
||||||
/* The Provider doesn't support Control Planes, or you already gave a leaf */
|
/* The Provider doesn't support Control Planes, or you already gave a leaf */
|
||||||
|
Status = WSAEINVAL;
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
AfdPacket->EndpointFlags |= AFD_ENDPOINT_C_ROOT;
|
AfdPacket->EndpointFlags |= AFD_ENDPOINT_C_ROOT;
|
||||||
|
@ -312,6 +328,7 @@ WSPSocket(int AddressFamily,
|
||||||
|| ((dwFlags & WSA_FLAG_MULTIPOINT_D_LEAF) != 0))
|
|| ((dwFlags & WSA_FLAG_MULTIPOINT_D_LEAF) != 0))
|
||||||
{
|
{
|
||||||
/* The Provider doesn't support Data Planes, or you already gave a leaf */
|
/* The Provider doesn't support Data Planes, or you already gave a leaf */
|
||||||
|
Status = WSAEINVAL;
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
AfdPacket->EndpointFlags |= AFD_ENDPOINT_D_ROOT;
|
AfdPacket->EndpointFlags |= AFD_ENDPOINT_D_ROOT;
|
||||||
|
@ -346,6 +363,7 @@ WSPSocket(int AddressFamily,
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
ERR("Failed to open socket. Status 0x%08x\n", Status);
|
ERR("Failed to open socket. Status 0x%08x\n", Status);
|
||||||
|
Status = TranslateNtStatusError(Status);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -566,13 +566,6 @@ DoLookup:
|
||||||
goto DoLookup;
|
goto DoLookup;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check if we got a valid socket */
|
|
||||||
if (Status == WSAEINVAL)
|
|
||||||
{
|
|
||||||
Status = INVALID_SOCKET;
|
|
||||||
ErrorCode = WSAEINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Check if we got a valid socket */
|
/* Check if we got a valid socket */
|
||||||
if (Status != INVALID_SOCKET)
|
if (Status != INVALID_SOCKET)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue