]> git.proxmox.com Git - mirror_edk2.git/blobdiff - NetworkPkg/HttpBootDxe/HttpBootClient.c
NetworkPkg: Add URI configuration form to HTTP boot driver.
[mirror_edk2.git] / NetworkPkg / HttpBootDxe / HttpBootClient.c
index 2ccac8c842073e16c2697ce6dcf3759370e8e554..aae452729c8ebd4e0c27b7d3bbdc342221158817 100644 (file)
@@ -168,18 +168,35 @@ HttpBootDhcp4ExtractUriInfo (
   // HttpOffer contains the boot file URL.\r
   //\r
   SelectOffer = &Private->OfferBuffer[SelectIndex].Dhcp4;\r
-  if ((SelectOffer->OfferType == HttpOfferTypeDhcpIpUri) || (SelectOffer->OfferType == HttpOfferTypeDhcpNameUriDns)) {\r
-    HttpOffer = SelectOffer;\r
+  if (Private->FilePathUri == NULL) {\r
+    //\r
+    // In Corporate environment, we need a HttpOffer.\r
+    //\r
+    if ((SelectOffer->OfferType == HttpOfferTypeDhcpIpUri) || \r
+        (SelectOffer->OfferType == HttpOfferTypeDhcpIpUriDns) ||\r
+        (SelectOffer->OfferType == HttpOfferTypeDhcpNameUriDns)) {\r
+      HttpOffer = SelectOffer;\r
+    } else {\r
+      ASSERT (Private->SelectProxyType != HttpOfferTypeMax);\r
+      ProxyIndex = Private->OfferIndex[Private->SelectProxyType][0];\r
+      HttpOffer = &Private->OfferBuffer[ProxyIndex].Dhcp4;\r
+    }\r
+    Private->BootFileUriParser = HttpOffer->UriParser;\r
+    Private->BootFileUri = (CHAR8*) HttpOffer->OptList[HTTP_BOOT_DHCP4_TAG_INDEX_BOOTFILE]->Data;\r
   } else {\r
-    ASSERT (Private->SelectProxyType != HttpOfferTypeMax);\r
-    ProxyIndex = Private->OfferIndex[Private->SelectProxyType][0];\r
-    HttpOffer = &Private->OfferBuffer[ProxyIndex].Dhcp4;\r
+    //\r
+    // In Home environment the BootFileUri comes from the FilePath.\r
+    //\r
+    Private->BootFileUriParser = Private->FilePathUriParser;\r
+    Private->BootFileUri = Private->FilePathUri;\r
   }\r
 \r
   //\r
   // Configure the default DNS server if server assigned.\r
   //\r
-  if ((SelectOffer->OfferType == HttpOfferTypeDhcpNameUriDns) || (SelectOffer->OfferType == HttpOfferTypeDhcpDns)) {\r
+  if ((SelectOffer->OfferType == HttpOfferTypeDhcpNameUriDns) || \r
+      (SelectOffer->OfferType == HttpOfferTypeDhcpDns) ||\r
+      (SelectOffer->OfferType == HttpOfferTypeDhcpIpUriDns)) {\r
     Option = SelectOffer->OptList[HTTP_BOOT_DHCP4_TAG_INDEX_DNS_SERVER];\r
     ASSERT (Option != NULL);\r
     Status = HttpBootRegisterIp4Dns (\r
@@ -196,21 +213,14 @@ HttpBootDhcp4ExtractUriInfo (
   // Extract the port from URL, and use default HTTP port 80 if not provided.\r
   //\r
   Status = HttpUrlGetPort (\r
-             (CHAR8*) HttpOffer->OptList[HTTP_BOOT_DHCP4_TAG_INDEX_BOOTFILE]->Data,\r
-             HttpOffer->UriParser,\r
+             Private->BootFileUri,\r
+             Private->BootFileUriParser,\r
              &Private->Port\r
              );\r
   if (EFI_ERROR (Status) || Private->Port == 0) {\r
     Private->Port = 80;\r
   }\r
   \r
-  //\r
-  // Record the URI of boot file from the selected HTTP offer.\r
-  //\r
-  Private->BootFileUriParser = HttpOffer->UriParser;\r
-  Private->BootFileUri = (CHAR8*) HttpOffer->OptList[HTTP_BOOT_DHCP4_TAG_INDEX_BOOTFILE]->Data;\r
-\r
-  \r
   //\r
   // All boot informations are valid here.\r
   //\r
@@ -260,12 +270,27 @@ HttpBootDhcp6ExtractUriInfo (
   // HttpOffer contains the boot file URL.\r
   //\r
   SelectOffer = &Private->OfferBuffer[SelectIndex].Dhcp6;\r
-  if ((SelectOffer->OfferType == HttpOfferTypeDhcpIpUri) || (SelectOffer->OfferType == HttpOfferTypeDhcpNameUriDns)) {\r
-    HttpOffer = SelectOffer;\r
+  if (Private->FilePathUri == NULL) {\r
+    //\r
+    // In Corporate environment, we need a HttpOffer.\r
+    //\r
+    if ((SelectOffer->OfferType == HttpOfferTypeDhcpIpUri) ||\r
+        (SelectOffer->OfferType == HttpOfferTypeDhcpIpUriDns) ||\r
+        (SelectOffer->OfferType == HttpOfferTypeDhcpNameUriDns)) {\r
+      HttpOffer = SelectOffer;\r
+    } else {\r
+      ASSERT (Private->SelectProxyType != HttpOfferTypeMax);\r
+      ProxyIndex = Private->OfferIndex[Private->SelectProxyType][0];\r
+      HttpOffer = &Private->OfferBuffer[ProxyIndex].Dhcp6;\r
+    }\r
+    Private->BootFileUriParser = HttpOffer->UriParser;\r
+    Private->BootFileUri = (CHAR8*) HttpOffer->OptList[HTTP_BOOT_DHCP6_IDX_BOOT_FILE_URL]->Data;\r
   } else {\r
-    ASSERT (Private->SelectProxyType != HttpOfferTypeMax);\r
-    ProxyIndex = Private->OfferIndex[Private->SelectProxyType][0];\r
-    HttpOffer = &Private->OfferBuffer[ProxyIndex].Dhcp6;\r
+    //\r
+    // In Home environment the BootFileUri comes from the FilePath.\r
+    //\r
+    Private->BootFileUriParser = Private->FilePathUriParser;\r
+    Private->BootFileUri = Private->FilePathUri;\r
   }\r
 \r
   //\r
@@ -279,7 +304,9 @@ HttpBootDhcp6ExtractUriInfo (
   //\r
   // Configure the default DNS server if server assigned.\r
   //\r
-  if ((SelectOffer->OfferType == HttpOfferTypeDhcpNameUriDns) || (SelectOffer->OfferType == HttpOfferTypeDhcpDns)) {\r
+  if ((SelectOffer->OfferType == HttpOfferTypeDhcpNameUriDns) || \r
+      (SelectOffer->OfferType == HttpOfferTypeDhcpDns) ||\r
+      (SelectOffer->OfferType == HttpOfferTypeDhcpIpUriDns)) {\r
     Option = SelectOffer->OptList[HTTP_BOOT_DHCP6_IDX_DNS_SERVER];\r
     ASSERT (Option != NULL);\r
     Status = HttpBootSetIp6Dns (\r
@@ -297,8 +324,8 @@ HttpBootDhcp6ExtractUriInfo (
   // whether can send message to HTTP Server Ip through the GateWay.\r
   //\r
   Status = HttpUrlGetIp6 (\r
-             (CHAR8*) HttpOffer->OptList[HTTP_BOOT_DHCP6_IDX_BOOT_FILE_URL]->Data,\r
-             HttpOffer->UriParser,\r
+             Private->BootFileUri,\r
+             Private->BootFileUriParser,\r
              &IpAddr\r
              );\r
   \r
@@ -307,8 +334,8 @@ HttpBootDhcp6ExtractUriInfo (
     // The Http server address is expressed by Name Ip, so perform DNS resolution\r
     //\r
     Status = HttpUrlGetHostName (\r
-               (CHAR8*) HttpOffer->OptList[HTTP_BOOT_DHCP6_IDX_BOOT_FILE_URL]->Data,\r
-               HttpOffer->UriParser,\r
+               Private->BootFileUri,\r
+               Private->BootFileUriParser,\r
                &HostName\r
                );\r
     if (EFI_ERROR (Status)) {\r
@@ -343,21 +370,14 @@ HttpBootDhcp6ExtractUriInfo (
   // Extract the port from URL, and use default HTTP port 80 if not provided.\r
   //\r
   Status = HttpUrlGetPort (\r
-             (CHAR8*) HttpOffer->OptList[HTTP_BOOT_DHCP6_IDX_BOOT_FILE_URL]->Data,\r
-             HttpOffer->UriParser,\r
+             Private->BootFileUri,\r
+             Private->BootFileUriParser,\r
              &Private->Port\r
              );\r
   if (EFI_ERROR (Status) || Private->Port == 0) {\r
     Private->Port = 80;\r
   }\r
   \r
-  //\r
-  // Record the URI of boot file from the selected HTTP offer.\r
-  //\r
-  Private->BootFileUriParser = HttpOffer->UriParser;\r
-  Private->BootFileUri = (CHAR8*) HttpOffer->OptList[HTTP_BOOT_DHCP6_IDX_BOOT_FILE_URL]->Data;\r
-\r
-  \r
   //\r
   // All boot informations are valid here.\r
   //\r
@@ -570,10 +590,6 @@ HttpBootGetFileFromCache (
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
-  //\r
-  // Search file in the cache list, the cache entry will be released upon a successful\r
-  // match.\r
-  //\r
   NET_LIST_FOR_EACH (Entry, &Private->CacheList) {\r
     Cache = NET_LIST_USER_STRUCT (Entry, HTTP_BOOT_CACHE_CONTENT, Link);\r
     //\r
@@ -607,12 +623,6 @@ HttpBootGetFileFromCache (
         }\r
       }\r
       *BufferSize = CopyedSize;\r
-\r
-      //\r
-      // On success, free the cached data to release the memory resource.\r
-      //\r
-      RemoveEntryList (&Cache->Link);\r
-      HttpBootFreeCache (Cache);\r
       return EFI_SUCCESS;\r
     }\r
   }\r
@@ -1083,3 +1093,4 @@ ERROR_1:
 \r
   return Status;\r
 }\r
+\r