]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Rrq.c
MdeModulePke/Mtftp4Dxe: Correct the total received and saved block number.
[mirror_edk2.git] / MdeModulePkg / Universal / Network / Mtftp4Dxe / Mtftp4Rrq.c
index fedf1cde460bf1dec3f8864ff417e2aaab256a53..6960e322a5433a1d06c1f7a1bba033198441af90 100644 (file)
@@ -154,6 +154,7 @@ Mtftp4RrqSaveBlock (
   UINT16                    Block;\r
   UINT64                    Start;\r
   UINT32                    DataLen;\r
+  UINT64                    BlockCounter;\r
   BOOLEAN                   Completed;\r
 \r
   Completed = FALSE;\r
@@ -174,10 +175,10 @@ Mtftp4RrqSaveBlock (
   // Remove this block number from the file hole. If Mtftp4RemoveBlockNum\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 = Mtftp4RemoveBlockNum (&Instance->Blocks, Block, Completed, &Instance->TotalBlock);\r
+  Status = Mtftp4RemoveBlockNum (&Instance->Blocks, Block, Completed, &BlockCounter);\r
 \r
   if (Status == EFI_NOT_FOUND) {\r
     return EFI_SUCCESS;\r
@@ -200,7 +201,7 @@ Mtftp4RrqSaveBlock (
   }\r
 \r
   if (Token->Buffer != NULL) {\r
-     Start = MultU64x32 (Instance->TotalBlock - 1, Instance->BlkSize);\r
+     Start = MultU64x32 (BlockCounter - 1, Instance->BlkSize);\r
 \r
     if (Start + DataLen <= Token->BufferSize) {\r
       CopyMem ((UINT8 *) Token->Buffer + Start, Packet->Data.Data, DataLen);\r
@@ -271,9 +272,9 @@ Mtftp4RrqHandleData (
   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->Master && (Expected != BlockNum)) {\r
     //\r
@@ -288,6 +289,11 @@ Mtftp4RrqHandleData (
     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\r
   // valid data packet.\r