]> git.proxmox.com Git - mirror_edk2.git/blobdiff - NetworkPkg/Mtftp6Dxe/Mtftp6Rrq.c
MdeModulePkg/PciSioSerial: Fix bad EOL
[mirror_edk2.git] / NetworkPkg / Mtftp6Dxe / Mtftp6Rrq.c
index da364329fcf721c9e508aa9e6dad77a0256dd843..2aadef076cf0d55fe81a8ea71b7171d794e67be3 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Mtftp6 Rrq process functions implementation.\r
 \r
 /** @file\r
   Mtftp6 Rrq process functions implementation.\r
 \r
-  Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2009 - 2014, 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
 \r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
@@ -59,6 +59,7 @@ Mtftp6RrqSendAck (
   // Reset current retry count of the instance.\r
   //\r
   Instance->CurRetry = 0;\r
   // Reset current retry count of the instance.\r
   //\r
   Instance->CurRetry = 0;\r
+  Instance->LastPacket = Packet;\r
 \r
   return Mtftp6TransmitPacket (Instance, Packet);\r
 }\r
 \r
   return Mtftp6TransmitPacket (Instance, Packet);\r
 }\r
@@ -105,7 +106,7 @@ Mtftp6RrqSaveBlock (
   // This is the last block, save the block num\r
   //\r
   if (DataLen < Instance->BlkSize) {\r
   // This is the last block, save the block num\r
   //\r
   if (DataLen < Instance->BlkSize) {\r
-       Completed = TRUE;\r
+    Completed = TRUE;\r
     Instance->LastBlk = Block;\r
     Mtftp6SetLastBlockNum (&Instance->BlkList, Block);\r
   }\r
     Instance->LastBlk = Block;\r
     Mtftp6SetLastBlockNum (&Instance->BlkList, Block);\r
   }\r
@@ -453,8 +454,10 @@ Mtftp6RrqHandleOack (
   MTFTP6_EXT_OPTION_INFO    ExtInfo;\r
   EFI_STATUS                Status;\r
   INTN                      Expected;\r
   MTFTP6_EXT_OPTION_INFO    ExtInfo;\r
   EFI_STATUS                Status;\r
   INTN                      Expected;\r
+  EFI_UDP6_PROTOCOL         *Udp6;\r
 \r
   *IsCompleted = FALSE;\r
 \r
   *IsCompleted = FALSE;\r
+  Options = NULL;\r
 \r
   //\r
   // If already started the master download, don't change the\r
 \r
   //\r
   // If already started the master download, don't change the\r
@@ -477,6 +480,7 @@ Mtftp6RrqHandleOack (
   if (EFI_ERROR (Status)) {\r
     return Status;\r
   }\r
   if (EFI_ERROR (Status)) {\r
     return Status;\r
   }\r
+  ASSERT (Options != NULL);\r
 \r
   //\r
   // Parse the extensive options in the packet.\r
 \r
   //\r
   // Parse the extensive options in the packet.\r
@@ -546,13 +550,30 @@ Mtftp6RrqHandleOack (
         );\r
 \r
       Instance->McastPort  = ExtInfo.McastPort;\r
         );\r
 \r
       Instance->McastPort  = ExtInfo.McastPort;\r
-      Instance->McastUdpIo = UdpIoCreateIo (\r
-                               Instance->Service->Controller,\r
-                               Instance->Service->Image,\r
-                               Mtftp6RrqConfigMcastUdpIo,\r
-                               UDP_IO_UDP6_VERSION,\r
-                               Instance\r
-                               );\r
+      if (Instance->McastUdpIo == NULL) {\r
+        Instance->McastUdpIo = UdpIoCreateIo (\r
+                                 Instance->Service->Controller,\r
+                                 Instance->Service->Image,\r
+                                 Mtftp6RrqConfigMcastUdpIo,\r
+                                 UDP_IO_UDP6_VERSION,\r
+                                 Instance\r
+                                 );\r
+        if (Instance->McastUdpIo != NULL) {\r
+          Status = gBS->OpenProtocol (\r
+                          Instance->McastUdpIo->UdpHandle,\r
+                          &gEfiUdp6ProtocolGuid,\r
+                          (VOID **) &Udp6,\r
+                          Instance->Service->Image,\r
+                          Instance->Handle,\r
+                          EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER\r
+                          );\r
+          if (EFI_ERROR (Status)) {\r
+            UdpIoFreeIo (Instance->McastUdpIo);\r
+            Instance->McastUdpIo = NULL;\r
+            return EFI_DEVICE_ERROR;\r
+          }\r
+        }\r
+      }\r
 \r
       if (Instance->McastUdpIo == NULL) {\r
         return EFI_DEVICE_ERROR;\r
 \r
       if (Instance->McastUdpIo == NULL) {\r
         return EFI_DEVICE_ERROR;\r