Implement support for MSG_PEEK.
authorColin Finck <colin@reactos.org>
Sat, 31 May 2008 12:51:22 +0000 (12:51 +0000)
committerColin Finck <colin@reactos.org>
Sat, 31 May 2008 12:51:22 +0000 (12:51 +0000)
Patch by Art Yerkes with small fix by me to make it working correctly. (verified with a test app)

svn path=/trunk/; revision=33786

reactos/drivers/network/afd/afd/read.c

index 039a8ec..a4b8bc8 100644 (file)
@@ -85,9 +85,12 @@ static NTSTATUS TryToSatisfyRecvRequestFromBuffer( PAFD_FCB FCB,
 
            MmUnmapLockedPages( Map[i].BufferAddress, Map[i].Mdl );
 
-           FCB->Recv.BytesUsed += BytesToCopy;
-           *TotalBytesCopied += BytesToCopy;
-           BytesAvailable -= BytesToCopy;
+            *TotalBytesCopied += BytesToCopy;
+
+            if (!(RecvReq->TdiFlags & TDI_RECEIVE_PEEK)) {
+                FCB->Recv.BytesUsed += BytesToCopy;
+                BytesAvailable -= BytesToCopy;
+            }
        }
     }
 
@@ -405,8 +408,11 @@ SatisfyPacketRecvRequest( PAFD_FCB FCB, PIRP Irp,
 
        MmUnmapLockedPages( Map[0].BufferAddress, Map[0].Mdl );
 
-       FCB->Recv.BytesUsed = 0;
-       *TotalBytesCopied = BytesToCopy;
+        *TotalBytesCopied = BytesToCopy;
+
+        if (!RecvReq->TdiFlags & TDI_RECEIVE_PEEK) {
+            FCB->Recv.BytesUsed = 0;
+        }
     }
 
     Status = Irp->IoStatus.Status = STATUS_SUCCESS;