More work on winsock stack (ping is now working)
[reactos.git] / reactos / lib / ws2_32 / misc / sndrcv.c
index d7fc982..2e8871e 100644 (file)
@@ -34,9 +34,18 @@ recvfrom(
     OUT     LPSOCKADDR from,
     IN OUT  INT FAR* fromlen)
 {
-    UNIMPLEMENTED
+    DWORD BytesReceived;
+    WSABUF WSABuf;
 
-    return 0;
+    WS_DbgPrint(MAX_TRACE, ("s (0x%X)  buf (0x%X)  len (0x%X) flags (0x%X).\n",
+        s, buf, len, flags));
+
+    WSABuf.len = len;
+    WSABuf.buf = (CHAR FAR*)buf;
+
+    WSARecvFrom(s, &WSABuf, 1, &BytesReceived, (LPDWORD)&flags, from, fromlen, NULL, NULL);
+
+    return BytesReceived;
 }
 
 
@@ -119,9 +128,29 @@ WSARecvFrom(
     IN      LPWSAOVERLAPPED lpOverlapped,
     IN      LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine)
 {
-    UNIMPLEMENTED
+    PCATALOG_ENTRY Provider;
+    INT Errno;
+    INT Code;
 
-    return 0;
+    WS_DbgPrint(MAX_TRACE, ("Called.\n"));
+
+    if (!ReferenceProviderByHandle((HANDLE)s, &Provider)) {
+        WSASetLastError(WSAENOTSOCK);
+        return SOCKET_ERROR;
+    }
+
+    assert(Provider->ProcTable.lpWSPRecvFrom);
+
+    Code = Provider->ProcTable.lpWSPRecvFrom(s, lpBuffers, dwBufferCount,
+        lpNumberOfBytesRecvd, lpFlags, lpFrom, lpFromlen, lpOverlapped,
+        lpCompletionRoutine, NULL /* lpThreadId */, &Errno);
+
+    DereferenceProviderByPointer(Provider);
+
+    if (Code == SOCKET_ERROR)
+        WSASetLastError(Errno);
+
+    return Code;
 }
 
 
@@ -178,6 +207,8 @@ WSASendTo(
         return SOCKET_ERROR;
     }
 
+    assert(Provider->ProcTable.lpWSPSendTo);
+
     Code = Provider->ProcTable.lpWSPSendTo(s, lpBuffers, dwBufferCount,
         lpNumberOfBytesSent, dwFlags, lpTo, iToLen, lpOverlapped,
         lpCompletionRoutine, NULL /* lpThreadId */, &Errno);