mirror of
https://github.com/reactos/reactos.git
synced 2025-08-03 17:56:00 +00:00
[MSAFD] Implement SOL_SOCKET/SO_ERROR. CORE-12104
svn path=/trunk/; revision=73165
This commit is contained in:
parent
f197af7358
commit
09207124de
1 changed files with 35 additions and 8 deletions
|
@ -914,6 +914,7 @@ WSPBind(SOCKET Handle,
|
||||||
NtClose( SockEvent );
|
NtClose( SockEvent );
|
||||||
HeapFree(GlobalHeap, 0, BindData);
|
HeapFree(GlobalHeap, 0, BindData);
|
||||||
|
|
||||||
|
Socket->SharedData->SocketLastError = TranslateNtStatusError(Status);
|
||||||
if (Status != STATUS_SUCCESS)
|
if (Status != STATUS_SUCCESS)
|
||||||
return MsafdReturnWithErrno ( Status, lpErrno, 0, NULL );
|
return MsafdReturnWithErrno ( Status, lpErrno, 0, NULL );
|
||||||
|
|
||||||
|
@ -997,6 +998,7 @@ WSPListen(SOCKET Handle,
|
||||||
|
|
||||||
NtClose( SockEvent );
|
NtClose( SockEvent );
|
||||||
|
|
||||||
|
Socket->SharedData->SocketLastError = TranslateNtStatusError(Status);
|
||||||
if (Status != STATUS_SUCCESS)
|
if (Status != STATUS_SUCCESS)
|
||||||
return MsafdReturnWithErrno ( Status, lpErrno, 0, NULL );
|
return MsafdReturnWithErrno ( Status, lpErrno, 0, NULL );
|
||||||
|
|
||||||
|
@ -1250,6 +1252,10 @@ WSPSelect(IN int nfds,
|
||||||
TRACE("Event %x on handle %x\n",
|
TRACE("Event %x on handle %x\n",
|
||||||
Events,
|
Events,
|
||||||
Handle);
|
Handle);
|
||||||
|
if ((Events & x) == AFD_EVENT_DISCONNECT || (Events & x) == AFD_EVENT_CLOSE)
|
||||||
|
Socket->SharedData->SocketLastError = WSAECONNRESET;
|
||||||
|
if ((Events & x) == AFD_EVENT_ABORT)
|
||||||
|
Socket->SharedData->SocketLastError = WSAECONNABORTED;
|
||||||
if( readfds )
|
if( readfds )
|
||||||
FD_SET(Handle, readfds);
|
FD_SET(Handle, readfds);
|
||||||
break;
|
break;
|
||||||
|
@ -1643,6 +1649,7 @@ WSPAccept(SOCKET Handle,
|
||||||
Status = IOSB.Status;
|
Status = IOSB.Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Socket->SharedData->SocketLastError = TranslateNtStatusError(Status);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
NtClose(SockEvent);
|
NtClose(SockEvent);
|
||||||
|
@ -1871,6 +1878,7 @@ WSPConnect(SOCKET Handle,
|
||||||
Status = IOSB.Status;
|
Status = IOSB.Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Socket->SharedData->SocketLastError = TranslateNtStatusError(Status);
|
||||||
if (Status != STATUS_SUCCESS)
|
if (Status != STATUS_SUCCESS)
|
||||||
goto notify;
|
goto notify;
|
||||||
|
|
||||||
|
@ -2017,6 +2025,7 @@ WSPShutdown(SOCKET Handle,
|
||||||
|
|
||||||
NtClose( SockEvent );
|
NtClose( SockEvent );
|
||||||
|
|
||||||
|
Socket->SharedData->SocketLastError = TranslateNtStatusError(Status);
|
||||||
return MsafdReturnWithErrno( Status, lpErrno, 0, NULL );
|
return MsafdReturnWithErrno( Status, lpErrno, 0, NULL );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2428,9 +2437,10 @@ WSPGetSockOpt(IN SOCKET Handle,
|
||||||
PVOID Buffer;
|
PVOID Buffer;
|
||||||
INT BufferSize;
|
INT BufferSize;
|
||||||
BOOL BoolBuffer;
|
BOOL BoolBuffer;
|
||||||
INT IntBuffer;
|
|
||||||
INT Errno;
|
INT Errno;
|
||||||
|
|
||||||
|
TRACE("Called\n");
|
||||||
|
|
||||||
/* Get the Socket Structure associate to this Socket*/
|
/* Get the Socket Structure associate to this Socket*/
|
||||||
Socket = GetSocketStructure(Handle);
|
Socket = GetSocketStructure(Handle);
|
||||||
if (Socket == NULL)
|
if (Socket == NULL)
|
||||||
|
@ -2438,8 +2448,11 @@ WSPGetSockOpt(IN SOCKET Handle,
|
||||||
if (lpErrno) *lpErrno = WSAENOTSOCK;
|
if (lpErrno) *lpErrno = WSAENOTSOCK;
|
||||||
return SOCKET_ERROR;
|
return SOCKET_ERROR;
|
||||||
}
|
}
|
||||||
|
if (!OptionLength || !OptionValue)
|
||||||
TRACE("Called\n");
|
{
|
||||||
|
if (lpErrno) *lpErrno = WSAEFAULT;
|
||||||
|
return SOCKET_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
switch (Level)
|
switch (Level)
|
||||||
{
|
{
|
||||||
|
@ -2525,13 +2538,10 @@ WSPGetSockOpt(IN SOCKET Handle,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SO_ERROR:
|
case SO_ERROR:
|
||||||
/* HACK: This needs to be properly tracked */
|
Buffer = &Socket->SharedData->SocketLastError;
|
||||||
IntBuffer = 0;
|
|
||||||
DbgPrint("MSAFD: Hacked SO_ERROR returning error %d\n", IntBuffer);
|
|
||||||
|
|
||||||
Buffer = &IntBuffer;
|
|
||||||
BufferSize = sizeof(INT);
|
BufferSize = sizeof(INT);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SO_SNDTIMEO:
|
case SO_SNDTIMEO:
|
||||||
Buffer = &Socket->SharedData->SendTimeout;
|
Buffer = &Socket->SharedData->SendTimeout;
|
||||||
BufferSize = sizeof(DWORD);
|
BufferSize = sizeof(DWORD);
|
||||||
|
@ -2603,6 +2613,11 @@ WSPSetSockOpt(
|
||||||
if (lpErrno) *lpErrno = WSAENOTSOCK;
|
if (lpErrno) *lpErrno = WSAENOTSOCK;
|
||||||
return SOCKET_ERROR;
|
return SOCKET_ERROR;
|
||||||
}
|
}
|
||||||
|
if (!optval)
|
||||||
|
{
|
||||||
|
if (lpErrno) *lpErrno = WSAEFAULT;
|
||||||
|
return SOCKET_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* FIXME: We should handle some more cases here */
|
/* FIXME: We should handle some more cases here */
|
||||||
|
@ -2677,6 +2692,18 @@ WSPSetSockOpt(
|
||||||
ERR("Setting send buf to %x is not implemented yet\n", optval);
|
ERR("Setting send buf to %x is not implemented yet\n", optval);
|
||||||
return NO_ERROR;
|
return NO_ERROR;
|
||||||
|
|
||||||
|
case SO_ERROR:
|
||||||
|
if (optlen < sizeof(INT))
|
||||||
|
{
|
||||||
|
if (lpErrno) *lpErrno = WSAEFAULT;
|
||||||
|
return SOCKET_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
RtlCopyMemory(&Socket->SharedData->SocketLastError,
|
||||||
|
optval,
|
||||||
|
sizeof(INT));
|
||||||
|
return NO_ERROR;
|
||||||
|
|
||||||
case SO_SNDTIMEO:
|
case SO_SNDTIMEO:
|
||||||
if (optlen < sizeof(DWORD))
|
if (optlen < sizeof(DWORD))
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue