]> git.proxmox.com Git - mirror_edk2.git/blobdiff - NetworkPkg/UefiPxeBcDxe/PxeBcDhcp6.c
1. Fix a bug for PXEv6 when Proxy PXE server and DHCP server are located at the same...
[mirror_edk2.git] / NetworkPkg / UefiPxeBcDxe / PxeBcDhcp6.c
index 8715675472076534956f2945572545d7384aef2c..0a2dd6d13ebc1eb6f20fd9491faa860056edcd6b 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Functions implementation related with DHCPv6 for UefiPxeBc Driver.\r
 \r
-  Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2009 - 2012, 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
 #include "PxeBcImpl.h"\r
 \r
+//\r
+// Well-known multi-cast address defined in section-24.1 of rfc-3315\r
+//\r
+//   ALL_DHCP_Relay_Agents_and_Servers address: FF02::1:2\r
+//\r
+EFI_IPv6_ADDRESS   mAllDhcpRelayAndServersAddress = {{0xFF, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 2}};\r
 \r
 /**\r
   Parse out a DHCPv6 option by OptTag, and find the position in buffer.\r
@@ -788,7 +794,7 @@ PxeBcRequestBootService (
     \r
   Status = PxeBc->UdpRead (\r
                     PxeBc,\r
-                    OpFlags,\r
+                    EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_SRC_IP,\r
                     &Private->StationIp,\r
                     &SrcPort,\r
                     &Private->ServerIp,\r
@@ -844,19 +850,29 @@ PxeBcRetryDhcp6Binl (
   Mode                  = Private->PxeBc.Mode;\r
   Private->IsDoDiscover = FALSE;\r
   Offer                 = &Private->OfferBuffer[Index].Dhcp6;\r
-\r
-  ASSERT (Offer->OptList[PXEBC_DHCP6_IDX_BOOT_FILE_URL] != NULL);\r
-  //\r
-  // Parse out the next server address from the last offer, and store it\r
-  //\r
-  Status = PxeBcExtractBootFileUrl (\r
-             &Private->BootFileName,\r
-             &Private->ServerIp.v6,\r
-             (CHAR8 *) (Offer->OptList[PXEBC_DHCP6_IDX_BOOT_FILE_URL]->Data),\r
-             NTOHS (Offer->OptList[PXEBC_DHCP6_IDX_BOOT_FILE_URL]->OpLen)\r
-             );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
+  if (Offer->OfferType == PxeOfferTypeDhcpBinl) {\r
+    //\r
+    // There is no BootFileUrl option in dhcp6 offer, so use servers multi-cast address instead.\r
+    //\r
+    CopyMem (\r
+      &Private->ServerIp.v6,\r
+      &mAllDhcpRelayAndServersAddress,\r
+      sizeof (EFI_IPv6_ADDRESS)\r
+      );\r
+  } else {\r
+    ASSERT (Offer->OptList[PXEBC_DHCP6_IDX_BOOT_FILE_URL] != NULL);\r
+    //\r
+    // Parse out the next server address from the last offer, and store it\r
+    //\r
+    Status = PxeBcExtractBootFileUrl (\r
+               &Private->BootFileName,\r
+               &Private->ServerIp.v6,\r
+               (CHAR8 *) (Offer->OptList[PXEBC_DHCP6_IDX_BOOT_FILE_URL]->Data),\r
+               NTOHS (Offer->OptList[PXEBC_DHCP6_IDX_BOOT_FILE_URL]->OpLen)\r
+               );\r
+    if (EFI_ERROR (Status)) {\r
+      return Status;\r
+    }\r
   }\r
 \r
   //\r