Commit in reactos/lib/msafd on MAIN
include/msafd.h+4-41.13 -> 1.14
misc/dllmain.c+121-151.32 -> 1.33
    /sndrcv.c+1-11.18 -> 1.19
    /stubs.c+1-171.5 -> 1.6
+127-37
4 modified files
- Fix WSPSelect.
- Partial implementation of WSPGetSockOpt.

reactos/lib/msafd/include
msafd.h 1.13 -> 1.14
diff -u -r1.13 -r1.14
--- msafd.h	27 Dec 2004 21:18:05 -0000	1.13
+++ msafd.h	28 Dec 2004 11:39:03 -0000	1.14
@@ -154,7 +154,7 @@
 INT
 WSPAPI WSPBind(
     IN  SOCKET s,
-    IN  CONST LPSOCKADDR name, 
+    IN  CONST SOCKADDR *name, 
     IN  INT namelen, 
     OUT LPINT lpErrno);
 
@@ -178,7 +178,7 @@
 WSPAPI
 WSPConnect(
     IN  SOCKET s,
-    IN  CONST LPSOCKADDR name,
+    IN  CONST SOCKADDR *name,
     IN  INT namelen,
     IN  LPWSABUF lpCallerData,
     OUT LPWSABUF lpCalleeData,
@@ -273,7 +273,7 @@
 WSPAPI
 WSPJoinLeaf(
     IN  SOCKET s,
-    IN  CONST LPSOCKADDR name,
+    IN  CONST SOCKADDR *name,
     IN  INT namelen,
     IN  LPWSABUF lpCallerData,
     OUT LPWSABUF lpCalleeData,
@@ -362,7 +362,7 @@
     IN  DWORD dwBufferCount,
     OUT LPDWORD lpNumberOfBytesSent,
     IN  DWORD dwFlags,
-    IN  CONST LPSOCKADDR lpTo,
+    IN  CONST SOCKADDR *lpTo,
     IN  INT iTolen,
     IN  LPWSAOVERLAPPED lpOverlapped,
     IN  LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine,

reactos/lib/msafd/misc
dllmain.c 1.32 -> 1.33
diff -u -r1.32 -r1.33
--- dllmain.c	27 Dec 2004 21:18:07 -0000	1.32
+++ dllmain.c	28 Dec 2004 11:39:05 -0000	1.33
@@ -23,7 +23,7 @@
 HANDLE GlobalHeap;
 WSPUPCALLTABLE Upcalls;
 LPWPUCOMPLETEOVERLAPPEDREQUEST lpWPUCompleteOverlappedRequest;
-ULONG SocketCount;
+ULONG SocketCount = 0;
 PSOCKET_INFORMATION *Sockets = NULL;
 LIST_ENTRY SockHelpersListHead = {NULL};
 ULONG SockAsyncThreadRefCount;
@@ -271,7 +271,7 @@
     case STATUS_PENDING: *Errno = WSA_IO_PENDING; break;
     case STATUS_BUFFER_OVERFLOW: *Errno = WSAEMSGSIZE; break;
     default: {
-	DbgPrint("MSAFD: Error %d is unknown\n", Errno);
+	DbgPrint("MSAFD: Error %x is unknown\n", Status);
 	*Errno = WSAEINVAL; break;
     } break;
     }
@@ -421,7 +421,7 @@
 WSPAPI
 WSPBind(
 	SOCKET Handle, 
-	struct sockaddr *SocketAddress, 
+	const struct sockaddr *SocketAddress, 
 	int SocketAddressLength, 
 	LPINT lpErrno)
 /*
@@ -608,26 +608,29 @@
     if (readfds != NULL) {
 	for (i = 0; i < readfds->fd_count; i++, j++) {
 	    PollInfo->Handles[j].Handle = readfds->fd_array[i];
-	    PollInfo->Handles[j].Events = AFD_EVENT_RECEIVE | AFD_EVENT_DISCONNECT | AFD_EVENT_ABORT;
+	    PollInfo->Handles[j].Events = AFD_EVENT_RECEIVE | 
+	                                  AFD_EVENT_DISCONNECT |
+	                                  AFD_EVENT_ABORT |
+	                                  AFD_EVENT_ACCEPT;
 	} 
     }
     if (writefds != NULL) {
 	for (i = 0; i < writefds->fd_count; i++, j++) {
 	    PollInfo->Handles[j].Handle = writefds->fd_array[i];
-	    PollInfo->Handles[j].Events |= AFD_EVENT_SEND;
-	}
-	
+	    PollInfo->Handles[j].Events = AFD_EVENT_SEND |
+	                                  AFD_EVENT_CONNECT;
+	}	
     }
     if (exceptfds != NULL) {
 	for (i = 0; i < exceptfds->fd_count; i++, j++) {
 	    PollInfo->Handles[j].Handle = exceptfds->fd_array[i];
-	    PollInfo->Handles[j].Events |= 
-		AFD_EVENT_OOB_RECEIVE | AFD_EVENT_CONNECT_FAIL;
+	    PollInfo->Handles[j].Events = AFD_EVENT_OOB_RECEIVE |
+	                                  AFD_EVENT_CONNECT_FAIL;
 	}
     }
     
     /* Send IOCTL */
-    Status = NtDeviceIoControlFile( (HANDLE)Sockets[0]->Handle,
+    Status = NtDeviceIoControlFile( (HANDLE)PollInfo->Handles[0].Handle,
 				    SockEvent,
 				    NULL,
 				    NULL,
@@ -988,7 +991,7 @@
 WSPAPI 
 WSPConnect(
 	SOCKET Handle, 
-	struct sockaddr * SocketAddress, 
+	const struct sockaddr * SocketAddress, 
 	int SocketAddressLength, 
 	LPWSABUF lpCallerData, 
 	LPWSABUF lpCalleeData, 
@@ -1318,7 +1321,9 @@
 	AFD_DbgPrint(MID_TRACE,("[%x] Set nonblocking %d\n",
 				Handle, Socket->SharedData.NonBlocking));
 	return 0;
+
     default:
+	*lpErrno = WSAEINVAL;
 	return SOCKET_ERROR;
     }
 }
@@ -1326,6 +1331,107 @@
 
 INT
 WSPAPI
+WSPGetSockOpt(
+    IN      SOCKET Handle,
+    IN      INT Level,
+    IN      INT OptionName,
+    OUT	    CHAR FAR* OptionValue,
+    IN OUT  LPINT OptionLength,
+    OUT     LPINT lpErrno)
+{
+    PSOCKET_INFORMATION Socket = NULL;
+    PVOID Buffer;
+    INT BufferSize;
+    BOOLEAN BoolBuffer;
+
+    /* Get the Socket Structure associate to this Socket*/
+    Socket = GetSocketStructure(Handle);
+    if (Socket == NULL)
+    {
+        *lpErrno = WSAENOTSOCK;
+        return SOCKET_ERROR;
+    }
+
+    AFD_DbgPrint(MID_TRACE, ("Called\n"));
+
+    switch (Level)
+    {
+        case SOL_SOCKET:
+            switch (OptionName)
+            {
+                case SO_TYPE:
+                    Buffer = &Socket->SharedData.SocketType;
+                    BufferSize = sizeof(INT);
+                    break;
+
+                case SO_RCVBUF:
+                    Buffer = &Socket->SharedData.SizeOfRecvBuffer;
+                    BufferSize = sizeof(INT);
+                    break;
+
+                case SO_SNDBUF:
+                    Buffer = &Socket->SharedData.SizeOfSendBuffer;
+                    BufferSize = sizeof(INT);
+                    break;
+
+                case SO_ACCEPTCONN:
+                    BoolBuffer = Socket->SharedData.Listening;
+                    Buffer = &BoolBuffer;
+                    BufferSize = sizeof(BOOLEAN);
+                    break;
+
+                case SO_BROADCAST:
+                    BoolBuffer = Socket->SharedData.Broadcast;
+                    Buffer = &BoolBuffer;
+                    BufferSize = sizeof(BOOLEAN);
+                    break;
+
+                case SO_DEBUG:
+                    BoolBuffer = Socket->SharedData.Debug;
+                    Buffer = &BoolBuffer;
+                    BufferSize = sizeof(BOOLEAN);
+                    break;
+
+                /* case SO_CONDITIONAL_ACCEPT: */
+                case SO_DONTLINGER:
+                case SO_DONTROUTE:
+                case SO_ERROR:
+                case SO_GROUP_ID:
+                case SO_GROUP_PRIORITY:
+                case SO_KEEPALIVE:
+                case SO_LINGER:
+                case SO_MAX_MSG_SIZE:
+                case SO_OOBINLINE:
+                case SO_PROTOCOL_INFO:
+                case SO_REUSEADDR:
+                    AFD_DbgPrint(MID_TRACE, ("Unimplemented option (%x)\n",
+                                 OptionName));
+
+                default:
+                    *lpErrno = WSAEINVAL;
+                    return SOCKET_ERROR;
+            }
+            
+            if (*OptionLength < BufferSize)
+            {
+                *lpErrno = WSAEFAULT;
+                *OptionLength = BufferSize;
+                return SOCKET_ERROR;
+            }
+            RtlCopyMemory(OptionValue, Buffer, BufferSize);
+
+            return 0;
+
+        case IPPROTO_TCP: /* FIXME */
+        default:
+            *lpErrno = WSAEINVAL;
+            return SOCKET_ERROR;
+    }
+}
+
+
+INT
+WSPAPI
 WSPStartup(
   IN  WORD wVersionRequested,
   OUT LPWSPDATA lpWSPData,
@@ -1356,11 +1462,11 @@
     lpProcTable->lpWSPAccept = WSPAccept;
     lpProcTable->lpWSPAddressToString = WSPAddressToString;
     lpProcTable->lpWSPAsyncSelect = WSPAsyncSelect;
-    lpProcTable->lpWSPBind = (LPWSPBIND)WSPBind;
+    lpProcTable->lpWSPBind = WSPBind;
     lpProcTable->lpWSPCancelBlockingCall = WSPCancelBlockingCall;
     lpProcTable->lpWSPCleanup = WSPCleanup;
     lpProcTable->lpWSPCloseSocket = WSPCloseSocket;
-    lpProcTable->lpWSPConnect = (LPWSPCONNECT)WSPConnect;
+    lpProcTable->lpWSPConnect = WSPConnect;
     lpProcTable->lpWSPDuplicateSocket = WSPDuplicateSocket;
     lpProcTable->lpWSPEnumNetworkEvents = WSPEnumNetworkEvents;
     lpProcTable->lpWSPEventSelect = WSPEventSelect;
@@ -1370,7 +1476,7 @@
     lpProcTable->lpWSPGetSockOpt = WSPGetSockOpt;
     lpProcTable->lpWSPGetQOSByName = WSPGetQOSByName;
     lpProcTable->lpWSPIoctl = WSPIoctl;
-    lpProcTable->lpWSPJoinLeaf = (LPWSPJOINLEAF)WSPJoinLeaf;
+    lpProcTable->lpWSPJoinLeaf = WSPJoinLeaf;
     lpProcTable->lpWSPListen = WSPListen;
     lpProcTable->lpWSPRecv = WSPRecv;
     lpProcTable->lpWSPRecvDisconnect = WSPRecvDisconnect;
@@ -1378,7 +1484,7 @@
     lpProcTable->lpWSPSelect = WSPSelect;
     lpProcTable->lpWSPSend = WSPSend;
     lpProcTable->lpWSPSendDisconnect = WSPSendDisconnect;
-    lpProcTable->lpWSPSendTo = (LPWSPSENDTO)WSPSendTo;
+    lpProcTable->lpWSPSendTo = WSPSendTo;
     lpProcTable->lpWSPSetSockOpt = WSPSetSockOpt;
     lpProcTable->lpWSPShutdown = WSPShutdown;
     lpProcTable->lpWSPSocket = WSPSocket;

reactos/lib/msafd/misc
sndrcv.c 1.18 -> 1.19
diff -u -r1.18 -r1.19
--- sndrcv.c	27 Dec 2004 21:18:07 -0000	1.18
+++ sndrcv.c	28 Dec 2004 11:39:05 -0000	1.19
@@ -475,7 +475,7 @@
 	DWORD dwBufferCount, 
 	LPDWORD lpNumberOfBytesSent, 
 	DWORD iFlags, 
-	struct sockaddr *SocketAddress, 
+	const struct sockaddr *SocketAddress, 
 	int SocketAddressLength, 
 	LPWSAOVERLAPPED lpOverlapped, 
 	LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine, 

reactos/lib/msafd/misc
stubs.c 1.5 -> 1.6
diff -u -r1.5 -r1.6
--- stubs.c	15 Nov 2004 18:24:56 -0000	1.5
+++ stubs.c	28 Dec 2004 11:39:05 -0000	1.6
@@ -81,27 +81,11 @@
 }
 
 
-INT
-WSPAPI
-WSPGetSockOpt(
-    IN      SOCKET s,
-    IN      INT level,
-    IN      INT optname,
-    OUT	    CHAR FAR* optval,
-    IN OUT  LPINT optlen,
-    OUT     LPINT lpErrno)
-{
-    UNIMPLEMENTED
-
-    return 0;
-}
-
-
 SOCKET
 WSPAPI
 WSPJoinLeaf(
     IN  SOCKET s,
-    IN  CONST LPSOCKADDR name,
+    IN  CONST SOCKADDR *name,
     IN  INT namelen,
     IN  LPWSABUF lpCallerData,
     OUT LPWSABUF lpCalleeData,
CVSspam 0.2.8