]> git.proxmox.com Git - mirror_edk2.git/blobdiff - NetworkPkg/Mtftp6Dxe/Mtftp6Rrq.c
NetworkPkg/Mtftp6Dxe: Correct the total received and saved block number.
[mirror_edk2.git] / NetworkPkg / Mtftp6Dxe / Mtftp6Rrq.c
index 1f685b2bfe7360d1ed01da48070c42800764abb0..d60b26f6524d4933c8fdfc5b5bc4271f9c27e9b5 100644 (file)
@@ -102,6 +102,7 @@ Mtftp6RrqSaveBlock (
   UINT16                    Block;\r
   UINT64                    Start;\r
   UINT32                    DataLen;\r
+  UINT64                    BlockCounter;\r
   BOOLEAN                   Completed;\r
 \r
   Completed = FALSE;\r
@@ -122,10 +123,10 @@ Mtftp6RrqSaveBlock (
   // Remove this block number from the file hole. If Mtftp6RemoveBlockNum\r
   // returns EFI_NOT_FOUND, the block has been saved, don't save it again.\r
   // Note that : For bigger files, allowing the block counter to roll over\r
-  // to accept transfers of unlimited size. So TotalBlock is memorised as\r
+  // to accept transfers of unlimited size. So BlockCounter is memorised as\r
   // continuous block counter.\r
   //\r
-  Status = Mtftp6RemoveBlockNum (&Instance->BlkList, Block, Completed, &Instance->TotalBlock);\r
+  Status = Mtftp6RemoveBlockNum (&Instance->BlkList, Block, Completed, &BlockCounter);\r
 \r
   if (Status == EFI_NOT_FOUND) {\r
     return EFI_SUCCESS;\r
@@ -161,7 +162,7 @@ Mtftp6RrqSaveBlock (
 \r
   if (Token->Buffer != NULL) {\r
 \r
-    Start = MultU64x32 (Instance->TotalBlock - 1, Instance->BlkSize);\r
+    Start = MultU64x32 (BlockCounter - 1, Instance->BlkSize);\r
     if (Start + DataLen <= Token->BufferSize) {\r
       CopyMem ((UINT8 *) Token->Buffer + Start, Packet->Data.Data, DataLen);\r
       //\r
@@ -238,9 +239,9 @@ Mtftp6RrqHandleData (
   ASSERT (Expected >= 0);\r
 \r
   //\r
-  // If we are active and received an unexpected packet, transmit\r
+  // If we are active (Master) and received an unexpected packet, transmit\r
   // the ACK for the block we received, then restart receiving the\r
-  // expected one. If we are passive, save the block.\r
+  // expected one. If we are passive (Slave), save the block.\r
   //\r
   if (Instance->IsMaster && (Expected != BlockNum)) {\r
     //\r
@@ -262,6 +263,11 @@ Mtftp6RrqHandleData (
     return Status;\r
   }\r
 \r
+  //\r
+  // Record the total received and saved block number.\r
+  //\r
+  Instance->TotalBlock ++;\r
+\r
   //\r
   // Reset the passive client's timer whenever it received a valid data packet.\r
   //\r