Commit in reactos/drivers/net/afd on MAIN
afd/afd.c+2-21.12 -> 1.13
   /dispatch.c+9-101.12 -> 1.13
   /event.c+73-31.5 -> 1.6
   /routines.c+5-31.6 -> 1.7
include/afd.h+3-11.16 -> 1.17
+92-19
5 modified files
Preliminary version of recv.

reactos/drivers/net/afd/afd
afd.c 1.12 -> 1.13
diff -u -r1.12 -r1.13
--- afd.c	10 Feb 2004 17:12:41 -0000	1.12
+++ afd.c	14 Jun 2004 03:22:26 -0000	1.13
@@ -13,8 +13,8 @@
 #ifdef DBG
 
 /* See debug.h for debug/trace constants */
-DWORD DebugTraceLevel = MID_TRACE;
-//DWORD DebugTraceLevel = DEBUG_ULTRA;
+//DWORD DebugTraceLevel = MID_TRACE;
+DWORD DebugTraceLevel = DEBUG_ULTRA;
 
 #endif /* DBG */
 

reactos/drivers/net/afd/afd
dispatch.c 1.12 -> 1.13
diff -u -r1.12 -r1.13
--- dispatch.c	5 Mar 2004 00:48:11 -0000	1.12
+++ dispatch.c	14 Jun 2004 03:22:26 -0000	1.13
@@ -13,7 +13,8 @@
     PIRP Irp,
     PAFDFCB FCB,
     PFILE_REQUEST_RECVFROM Request,
-    PFILE_REPLY_RECVFROM Reply)
+    PFILE_REPLY_RECVFROM Reply,
+    BOOL Continuous)
 /*
  * FUNCTION: Receives data
  * ARGUMENTS:
@@ -64,7 +65,8 @@
       FCB,
       Request->Buffers,
       Request->BufferCount,
-      &Count);
+      &Count,
+      Continuous); /* I.E. Packets are exhausted on short recv if not */
     KeReleaseSpinLock(&FCB->ReceiveQueueLock, OldIrql);
 
     Reply->NumberOfBytesRecvd = Count;
@@ -490,7 +492,8 @@
       Irp,
       FCB,
       Request,
-      Reply);
+      Reply,
+      FALSE);
   } else {
     Status = STATUS_INVALID_PARAMETER;
   }
@@ -761,7 +764,6 @@
  *     Status of operation
  */
 {
-#if 0
   NTSTATUS Status;
   UINT InputBufferLength;
   UINT OutputBufferLength;
@@ -786,9 +788,9 @@
     Status = AfdpDispRecv(
       Irp,
       FCB,
-      Request->Buffers,
-      Request->BufferCount,
-      &NumberOfBytesRecvd);
+      (PFILE_REQUEST_RECVFROM)Request,
+      (PFILE_REPLY_RECVFROM)Reply,
+      TRUE);
     Reply->NumberOfBytesRecvd = NumberOfBytesRecvd;
     Reply->Status = NO_ERROR;
   } else {
@@ -798,9 +800,6 @@
   AFD_DbgPrint(MAX_TRACE, ("Status (0x%X).\n", Status));
 
   return Status;
-#else
-  return STATUS_SUCCESS;
-#endif
 }
 
 

reactos/drivers/net/afd/afd
event.c 1.5 -> 1.6
diff -u -r1.5 -r1.6
--- event.c	14 Nov 2003 17:13:28 -0000	1.5
+++ event.c	14 Jun 2004 03:22:27 -0000	1.6
@@ -44,9 +44,77 @@
     IN PVOID Tsdu,
     OUT PIRP *IoRequestPacket)
 {
-    AFD_DbgPrint(MAX_TRACE, ("Called.\n"));
+  PAFDFCB FCB = (PAFDFCB)TdiEventContext;
+  PAFD_READ_REQUEST ReadRequest;
+  PVOID ReceiveBuffer;
+  PAFD_BUFFER Buffer;
+  PLIST_ENTRY Entry;
+  NTSTATUS Status;
+  KIRQL OldIrql;
+  ULONG Count;
 
-    return STATUS_SUCCESS;
+  AFD_DbgPrint(MAX_TRACE, ("Called.\n"));
+
+  AFD_DbgPrint(MID_TRACE, ("Receiving (%d) bytes on socket\n", 
+			   BytesAvailable));
+
+  ReceiveBuffer = ExAllocatePool(NonPagedPool, BytesAvailable);
+  if (!ReceiveBuffer)
+    return STATUS_INSUFFICIENT_RESOURCES;
+
+  /*Buffer = (PAFD_BUFFER)ExAllocateFromNPagedLookasideList(
+    &BufferLookasideList);*/
+  Buffer = (PAFD_BUFFER)ExAllocatePool(NonPagedPool, sizeof(AFD_BUFFER));
+  if (!Buffer) {
+    ExFreePool(ReceiveBuffer);
+    return STATUS_INSUFFICIENT_RESOURCES;
+  }
+
+  /* Copy the data to a local buffer */
+  RtlCopyMemory(ReceiveBuffer, Tsdu, BytesAvailable);
+
+  Buffer->Buffer.len = BytesAvailable;
+  Buffer->Buffer.buf = ReceiveBuffer;
+  Buffer->Offset = 0;
+
+  ExInterlockedInsertTailList(
+    &FCB->ReceiveQueue,
+    &Buffer->ListEntry,
+    &FCB->ReceiveQueueLock);
+
+  KeAcquireSpinLock(&FCB->ReadRequestQueueLock, &OldIrql);
+
+  while (!IsListEmpty(&FCB->ReadRequestQueue) && 
+	 !IsListEmpty(&FCB->ReceiveQueue)) {
+    AFD_DbgPrint(MAX_TRACE, ("Satisfying read request.\n"));
+
+    Entry = RemoveHeadList(&FCB->ReceiveQueue);
+    ReadRequest = CONTAINING_RECORD(Entry, AFD_READ_REQUEST, ListEntry);
+
+    Status = FillWSABuffers(
+      FCB,
+      ReadRequest->RecvFromRequest->Buffers,
+      ReadRequest->RecvFromRequest->BufferCount,
+      &Count,
+      TRUE ); /* Continuous */
+    ReadRequest->RecvFromReply->NumberOfBytesRecvd = Count;
+    ReadRequest->RecvFromReply->Status = NO_ERROR;
+
+    ReadRequest->Irp->IoStatus.Information = 0;
+    ReadRequest->Irp->IoStatus.Status = Status;
+
+    AFD_DbgPrint(MAX_TRACE, ("Completing IRP at (0x%X).\n", ReadRequest->Irp));
+
+    IoCompleteRequest(ReadRequest->Irp, IO_NETWORK_INCREMENT);
+  }
+
+  KeReleaseSpinLock(&FCB->ReadRequestQueueLock, OldIrql);
+
+  *BytesTaken = BytesAvailable;
+
+  AFD_DbgPrint(MAX_TRACE, ("Leaving.\n"));
+
+  return STATUS_SUCCESS;
 }
 
 
@@ -125,6 +193,7 @@
 
   Buffer->Buffer.len = BytesAvailable;
   Buffer->Buffer.buf = ReceiveBuffer;
+  Buffer->Offset = 0;
 
   ExInterlockedInsertTailList(
     &FCB->ReceiveQueue,
@@ -143,7 +212,8 @@
       FCB,
       ReadRequest->RecvFromRequest->Buffers,
       ReadRequest->RecvFromRequest->BufferCount,
-      &Count);
+      &Count,
+      FALSE ); /* Packet oriented */
     ReadRequest->RecvFromReply->NumberOfBytesRecvd = Count;
     ReadRequest->RecvFromReply->Status = NO_ERROR;
 

reactos/drivers/net/afd/afd
routines.c 1.6 -> 1.7
diff -u -r1.6 -r1.7
--- routines.c	11 May 2004 20:52:08 -0000	1.6
+++ routines.c	14 Jun 2004 03:22:27 -0000	1.7
@@ -91,7 +91,8 @@
     PAFDFCB FCB,
     LPWSABUF Buffers,
     DWORD BufferCount,
-    PULONG BytesCopied)
+    PULONG BytesCopied,
+    BOOL Continuous)
 {
   PUCHAR DstData, SrcData;
   UINT DstSize, SrcSize;
@@ -108,8 +109,8 @@
 
   Entry = RemoveHeadList(&FCB->ReceiveQueue);
   SrcBuffer = CONTAINING_RECORD(Entry, AFD_BUFFER, ListEntry);
-  SrcData = SrcBuffer->Buffer.buf;
-  SrcSize = SrcBuffer->Buffer.len;
+  SrcData = SrcBuffer->Buffer.buf + SrcBuffer->Offset;
+  SrcSize = SrcBuffer->Buffer.len - SrcBuffer->Offset;
 
   DstData = Buffers->buf;
   DstSize = Buffers->len;
@@ -169,6 +170,7 @@
     ExFreePool(SrcBuffer);
   }
 
+  SrcBuffer->Offset += Total;
   *BytesCopied = Total;
 
   return STATUS_SUCCESS;

reactos/drivers/net/afd/include
afd.h 1.16 -> 1.17
diff -u -r1.16 -r1.17
--- afd.h	5 Mar 2004 00:48:11 -0000	1.16
+++ afd.h	14 Jun 2004 03:22:27 -0000	1.17
@@ -87,6 +87,7 @@
 typedef struct _AFD_BUFFER {
   LIST_ENTRY ListEntry;
   WSABUF Buffer;
+  UINT   Offset;
 } AFD_BUFFER, *PAFD_BUFFER;
 
 typedef struct _AFD_READ_REQUEST {
@@ -324,7 +325,8 @@
     PAFDFCB FCB,
     LPWSABUF Buffers,
     DWORD BufferCount,
-    PULONG BytesCopied);
+    PULONG BytesCopied,
+    BOOL Continuous);
 
 VOID BuildIPv4Header(
     PIPv4_HEADER IPHeader,
CVSspam 0.2.8