]> git.proxmox.com Git - mirror_edk2.git/blobdiff - NetworkPkg/Mtftp6Dxe/Mtftp6Support.c
NetworkPkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / NetworkPkg / Mtftp6Dxe / Mtftp6Support.c
index e6b4127b785d82e448ac6a24e854e719324b3192..5b10da52c38919deef7a704fa53d0ef805789443 100644 (file)
@@ -1,15 +1,9 @@
 /** @file\r
   Mtftp6 support functions implementation.\r
 \r
-  Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>\r
 \r
-  This program and the accompanying materials\r
-  are licensed and made available under the terms and conditions of the BSD License\r
-  which accompanies this distribution.  The full text of the license may be found at\r
-  http://opensource.org/licenses/bsd-license.php.\r
-\r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+  SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
 \r
@@ -158,8 +152,8 @@ Mtftp6SetLastBlockNum (
 \r
   @param[in]  Head                   The block range list to remove from.\r
   @param[in]  Num                    The block number to remove.\r
-  @param[in]  Completed              Whether Num is the last block number\r
-  @param[out] TotalBlock             The continuous block number in all\r
+  @param[in]  Completed              Whether Num is the last block number.\r
+  @param[out] BlockCounter           The continuous block counter instead of the value after roll-over.\r
 \r
   @retval EFI_NOT_FOUND          The block number isn't in the block range list.\r
   @retval EFI_SUCCESS            The block number has been removed from the list.\r
@@ -171,7 +165,7 @@ Mtftp6RemoveBlockNum (
   IN LIST_ENTRY             *Head,\r
   IN UINT16                 Num,\r
   IN BOOLEAN                Completed,\r
-  OUT UINT64                *TotalBlock\r
+  OUT UINT64                *BlockCounter\r
   )\r
 {\r
   MTFTP6_BLOCK_RANGE        *Range;\r
@@ -220,10 +214,10 @@ Mtftp6RemoveBlockNum (
       // wrap to zero, because this is the simplest to implement. Here we choose\r
       // this solution.\r
       //\r
-      *TotalBlock  = Num;\r
+      *BlockCounter  = Num;\r
 \r
       if (Range->Round > 0) {\r
-        *TotalBlock += Range->Bound +  MultU64x32 (Range->Round - 1, (UINT32)(Range->Bound + 1)) + 1;\r
+        *BlockCounter += Range->Bound +  MultU64x32 (Range->Round - 1, (UINT32)(Range->Bound + 1)) + 1;\r
       }\r
 \r
       if (Range->Start > Range->Bound) {\r
@@ -538,7 +532,7 @@ Mtftp6SendRequest (
 \r
   Packet->OpCode = HTONS (Operation);\r
   BufferLength  -= sizeof (Packet->OpCode);\r
-  \r
+\r
   Cur            = Packet->Rrq.Filename;\r
   Status         = AsciiStrCpyS ((CHAR8 *) Cur, BufferLength, (CHAR8 *) Token->Filename);\r
   ASSERT_EFI_ERROR (Status);\r
@@ -555,17 +549,17 @@ Mtftp6SendRequest (
   for (Index = 0; Index < Token->OptionCount; ++Index) {\r
     OptionStrLength = AsciiStrLen ((CHAR8 *) Options[Index].OptionStr);\r
     ValueStrLength  = AsciiStrLen ((CHAR8 *) Options[Index].ValueStr);\r
-    \r
+\r
     Status          = AsciiStrCpyS ((CHAR8 *) Cur, BufferLength, (CHAR8 *) Options[Index].OptionStr);\r
     ASSERT_EFI_ERROR (Status);\r
     BufferLength   -= (UINT32) (OptionStrLength + 1);\r
     Cur            += OptionStrLength + 1;\r
-    \r
+\r
     Status          = AsciiStrCpyS ((CHAR8 *) Cur, BufferLength, (CHAR8 *) Options[Index].ValueStr);\r
     ASSERT_EFI_ERROR (Status);\r
     BufferLength   -= (UINT32) (ValueStrLength + 1);\r
     Cur            += ValueStrLength + 1;\r
-    \r
+\r
   }\r
 \r
   //\r
@@ -979,6 +973,10 @@ Mtftp6OperationClean (
   Instance->ServerDataPort = 0;\r
   Instance->McastPort      = 0;\r
   Instance->BlkSize        = 0;\r
+  Instance->Operation      = 0;\r
+  Instance->WindowSize     = 1;\r
+  Instance->TotalBlock     = 0;\r
+  Instance->AckedBlock     = 0;\r
   Instance->LastBlk        = 0;\r
   Instance->PacketToLive   = 0;\r
   Instance->MaxRetry       = 0;\r
@@ -1051,6 +1049,8 @@ Mtftp6OperationStart (
   Status           = EFI_SUCCESS;\r
   Instance->OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
 \r
+  Instance->Operation = OpCode;\r
+\r
   //\r
   // Parse the extension options in the request packet.\r
   //\r
@@ -1060,6 +1060,7 @@ Mtftp6OperationStart (
                Token->OptionList,\r
                Token->OptionCount,\r
                TRUE,\r
+               Instance->Operation,\r
                &Instance->ExtInfo\r
                );\r
 \r
@@ -1105,6 +1106,9 @@ Mtftp6OperationStart (
   if (Instance->BlkSize == 0) {\r
     Instance->BlkSize = MTFTP6_DEFAULT_BLK_SIZE;\r
   }\r
+  if (Instance->WindowSize == 0) {\r
+    Instance->WindowSize = MTFTP6_DEFAULT_WINDOWSIZE;\r
+  }\r
   if (Instance->MaxRetry == 0) {\r
     Instance->MaxRetry = MTFTP6_DEFAULT_MAX_RETRY;\r
   }\r