summaryrefslogtreecommitdiffstats
path: root/NetworkPkg/HttpBootDxe/HttpBootClient.c
diff options
context:
space:
mode:
authorFu Siyuan <siyuan.fu@intel.com>2016-02-15 13:55:11 +0800
committerFu Siyuan <siyuan.fu@intel.com>2016-03-07 09:12:14 +0800
commitfa848a4048943251fc057fe8d6c5a82e01d2ffb6 (patch)
tree0ffe9aa44385b2bd9e49c974f3ed52345579e61e /NetworkPkg/HttpBootDxe/HttpBootClient.c
parent9353c60cea6eeedbbe4b336aea02646e2bf25f47 (diff)
downloadedk2-fa848a4048943251fc057fe8d6c5a82e01d2ffb6.tar.gz
edk2-fa848a4048943251fc057fe8d6c5a82e01d2ffb6.tar.bz2
edk2-fa848a4048943251fc057fe8d6c5a82e01d2ffb6.zip
NetworkPkg: Add URI configuration form to HTTP boot driver.
This patch updates the HTTP boot driver to produce a setup page for the boot file URI configuration. A new boot option will be created for the manual configured URI address. This change is made to support the HTTP boot usage in home environment. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Fu Siyuan <siyuan.fu@intel.com> Reviewed-by: Wu Jiaxin <jiaxin.wu@intel.com> Reviewed-by: Ye Ting <ting.ye@intel.com>
Diffstat (limited to 'NetworkPkg/HttpBootDxe/HttpBootClient.c')
-rw-r--r--NetworkPkg/HttpBootDxe/HttpBootClient.c99
1 files changed, 55 insertions, 44 deletions
diff --git a/NetworkPkg/HttpBootDxe/HttpBootClient.c b/NetworkPkg/HttpBootDxe/HttpBootClient.c
index 2ccac8c842..aae452729c 100644
--- a/NetworkPkg/HttpBootDxe/HttpBootClient.c
+++ b/NetworkPkg/HttpBootDxe/HttpBootClient.c
@@ -168,18 +168,35 @@ HttpBootDhcp4ExtractUriInfo (
// HttpOffer contains the boot file URL.
//
SelectOffer = &Private->OfferBuffer[SelectIndex].Dhcp4;
- if ((SelectOffer->OfferType == HttpOfferTypeDhcpIpUri) || (SelectOffer->OfferType == HttpOfferTypeDhcpNameUriDns)) {
- HttpOffer = SelectOffer;
+ if (Private->FilePathUri == NULL) {
+ //
+ // In Corporate environment, we need a HttpOffer.
+ //
+ if ((SelectOffer->OfferType == HttpOfferTypeDhcpIpUri) ||
+ (SelectOffer->OfferType == HttpOfferTypeDhcpIpUriDns) ||
+ (SelectOffer->OfferType == HttpOfferTypeDhcpNameUriDns)) {
+ HttpOffer = SelectOffer;
+ } else {
+ ASSERT (Private->SelectProxyType != HttpOfferTypeMax);
+ ProxyIndex = Private->OfferIndex[Private->SelectProxyType][0];
+ HttpOffer = &Private->OfferBuffer[ProxyIndex].Dhcp4;
+ }
+ Private->BootFileUriParser = HttpOffer->UriParser;
+ Private->BootFileUri = (CHAR8*) HttpOffer->OptList[HTTP_BOOT_DHCP4_TAG_INDEX_BOOTFILE]->Data;
} else {
- ASSERT (Private->SelectProxyType != HttpOfferTypeMax);
- ProxyIndex = Private->OfferIndex[Private->SelectProxyType][0];
- HttpOffer = &Private->OfferBuffer[ProxyIndex].Dhcp4;
+ //
+ // In Home environment the BootFileUri comes from the FilePath.
+ //
+ Private->BootFileUriParser = Private->FilePathUriParser;
+ Private->BootFileUri = Private->FilePathUri;
}
//
// Configure the default DNS server if server assigned.
//
- if ((SelectOffer->OfferType == HttpOfferTypeDhcpNameUriDns) || (SelectOffer->OfferType == HttpOfferTypeDhcpDns)) {
+ if ((SelectOffer->OfferType == HttpOfferTypeDhcpNameUriDns) ||
+ (SelectOffer->OfferType == HttpOfferTypeDhcpDns) ||
+ (SelectOffer->OfferType == HttpOfferTypeDhcpIpUriDns)) {
Option = SelectOffer->OptList[HTTP_BOOT_DHCP4_TAG_INDEX_DNS_SERVER];
ASSERT (Option != NULL);
Status = HttpBootRegisterIp4Dns (
@@ -196,8 +213,8 @@ HttpBootDhcp4ExtractUriInfo (
// Extract the port from URL, and use default HTTP port 80 if not provided.
//
Status = HttpUrlGetPort (
- (CHAR8*) HttpOffer->OptList[HTTP_BOOT_DHCP4_TAG_INDEX_BOOTFILE]->Data,
- HttpOffer->UriParser,
+ Private->BootFileUri,
+ Private->BootFileUriParser,
&Private->Port
);
if (EFI_ERROR (Status) || Private->Port == 0) {
@@ -205,13 +222,6 @@ HttpBootDhcp4ExtractUriInfo (
}
//
- // Record the URI of boot file from the selected HTTP offer.
- //
- Private->BootFileUriParser = HttpOffer->UriParser;
- Private->BootFileUri = (CHAR8*) HttpOffer->OptList[HTTP_BOOT_DHCP4_TAG_INDEX_BOOTFILE]->Data;
-
-
- //
// All boot informations are valid here.
//
AsciiPrint ("\n URI: %a", Private->BootFileUri);
@@ -260,12 +270,27 @@ HttpBootDhcp6ExtractUriInfo (
// HttpOffer contains the boot file URL.
//
SelectOffer = &Private->OfferBuffer[SelectIndex].Dhcp6;
- if ((SelectOffer->OfferType == HttpOfferTypeDhcpIpUri) || (SelectOffer->OfferType == HttpOfferTypeDhcpNameUriDns)) {
- HttpOffer = SelectOffer;
+ if (Private->FilePathUri == NULL) {
+ //
+ // In Corporate environment, we need a HttpOffer.
+ //
+ if ((SelectOffer->OfferType == HttpOfferTypeDhcpIpUri) ||
+ (SelectOffer->OfferType == HttpOfferTypeDhcpIpUriDns) ||
+ (SelectOffer->OfferType == HttpOfferTypeDhcpNameUriDns)) {
+ HttpOffer = SelectOffer;
+ } else {
+ ASSERT (Private->SelectProxyType != HttpOfferTypeMax);
+ ProxyIndex = Private->OfferIndex[Private->SelectProxyType][0];
+ HttpOffer = &Private->OfferBuffer[ProxyIndex].Dhcp6;
+ }
+ Private->BootFileUriParser = HttpOffer->UriParser;
+ Private->BootFileUri = (CHAR8*) HttpOffer->OptList[HTTP_BOOT_DHCP6_IDX_BOOT_FILE_URL]->Data;
} else {
- ASSERT (Private->SelectProxyType != HttpOfferTypeMax);
- ProxyIndex = Private->OfferIndex[Private->SelectProxyType][0];
- HttpOffer = &Private->OfferBuffer[ProxyIndex].Dhcp6;
+ //
+ // In Home environment the BootFileUri comes from the FilePath.
+ //
+ Private->BootFileUriParser = Private->FilePathUriParser;
+ Private->BootFileUri = Private->FilePathUri;
}
//
@@ -279,7 +304,9 @@ HttpBootDhcp6ExtractUriInfo (
//
// Configure the default DNS server if server assigned.
//
- if ((SelectOffer->OfferType == HttpOfferTypeDhcpNameUriDns) || (SelectOffer->OfferType == HttpOfferTypeDhcpDns)) {
+ if ((SelectOffer->OfferType == HttpOfferTypeDhcpNameUriDns) ||
+ (SelectOffer->OfferType == HttpOfferTypeDhcpDns) ||
+ (SelectOffer->OfferType == HttpOfferTypeDhcpIpUriDns)) {
Option = SelectOffer->OptList[HTTP_BOOT_DHCP6_IDX_DNS_SERVER];
ASSERT (Option != NULL);
Status = HttpBootSetIp6Dns (
@@ -297,8 +324,8 @@ HttpBootDhcp6ExtractUriInfo (
// whether can send message to HTTP Server Ip through the GateWay.
//
Status = HttpUrlGetIp6 (
- (CHAR8*) HttpOffer->OptList[HTTP_BOOT_DHCP6_IDX_BOOT_FILE_URL]->Data,
- HttpOffer->UriParser,
+ Private->BootFileUri,
+ Private->BootFileUriParser,
&IpAddr
);
@@ -307,8 +334,8 @@ HttpBootDhcp6ExtractUriInfo (
// The Http server address is expressed by Name Ip, so perform DNS resolution
//
Status = HttpUrlGetHostName (
- (CHAR8*) HttpOffer->OptList[HTTP_BOOT_DHCP6_IDX_BOOT_FILE_URL]->Data,
- HttpOffer->UriParser,
+ Private->BootFileUri,
+ Private->BootFileUriParser,
&HostName
);
if (EFI_ERROR (Status)) {
@@ -343,8 +370,8 @@ HttpBootDhcp6ExtractUriInfo (
// Extract the port from URL, and use default HTTP port 80 if not provided.
//
Status = HttpUrlGetPort (
- (CHAR8*) HttpOffer->OptList[HTTP_BOOT_DHCP6_IDX_BOOT_FILE_URL]->Data,
- HttpOffer->UriParser,
+ Private->BootFileUri,
+ Private->BootFileUriParser,
&Private->Port
);
if (EFI_ERROR (Status) || Private->Port == 0) {
@@ -352,13 +379,6 @@ HttpBootDhcp6ExtractUriInfo (
}
//
- // Record the URI of boot file from the selected HTTP offer.
- //
- Private->BootFileUriParser = HttpOffer->UriParser;
- Private->BootFileUri = (CHAR8*) HttpOffer->OptList[HTTP_BOOT_DHCP6_IDX_BOOT_FILE_URL]->Data;
-
-
- //
// All boot informations are valid here.
//
AsciiPrint ("\n URI: %a", Private->BootFileUri);
@@ -570,10 +590,6 @@ HttpBootGetFileFromCache (
return EFI_INVALID_PARAMETER;
}
- //
- // Search file in the cache list, the cache entry will be released upon a successful
- // match.
- //
NET_LIST_FOR_EACH (Entry, &Private->CacheList) {
Cache = NET_LIST_USER_STRUCT (Entry, HTTP_BOOT_CACHE_CONTENT, Link);
//
@@ -607,12 +623,6 @@ HttpBootGetFileFromCache (
}
}
*BufferSize = CopyedSize;
-
- //
- // On success, free the cached data to release the memory resource.
- //
- RemoveEntryList (&Cache->Link);
- HttpBootFreeCache (Cache);
return EFI_SUCCESS;
}
}
@@ -1083,3 +1093,4 @@ ERROR_1:
return Status;
}
+