summaryrefslogtreecommitdiffstats
path: root/NetworkPkg/HttpBootDxe/HttpBootDhcp6.c
diff options
context:
space:
mode:
authorFu Siyuan <siyuan.fu@intel.com>2017-06-14 17:28:48 +0800
committerFu Siyuan <siyuan.fu@intel.com>2017-06-22 10:56:25 +0800
commit95b5c32fb3d6bf677d4cb6471d6c683939014c89 (patch)
tree137594a6db98505b14d74eecb46c22376a0be4c1 /NetworkPkg/HttpBootDxe/HttpBootDhcp6.c
parenta77d109ffa0df3662999598e09e3c1e5fd7a1bfb (diff)
downloadedk2-95b5c32fb3d6bf677d4cb6471d6c683939014c89.tar.gz
edk2-95b5c32fb3d6bf677d4cb6471d6c683939014c89.tar.bz2
edk2-95b5c32fb3d6bf677d4cb6471d6c683939014c89.zip
NetworkPkg/HttpBootDxe: Add HTTP Boot Callback protocol support.
This patch updates the HTTP Boot driver to install a default HTTP Callback protocol if the platform doesn't provide one. This callback implementation will print the boot file download progress in percentage format. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Fu Siyuan <siyuan.fu@intel.com> Reviewed-by: Ye Ting <ting.ye@intel.com> Reviewed-by: Wu Jiaxin <jiaxin.wu@intel.com>
Diffstat (limited to 'NetworkPkg/HttpBootDxe/HttpBootDhcp6.c')
-rw-r--r--NetworkPkg/HttpBootDxe/HttpBootDhcp6.c106
1 files changed, 64 insertions, 42 deletions
diff --git a/NetworkPkg/HttpBootDxe/HttpBootDhcp6.c b/NetworkPkg/HttpBootDxe/HttpBootDhcp6.c
index f2b81957b7..4eea895368 100644
--- a/NetworkPkg/HttpBootDxe/HttpBootDhcp6.c
+++ b/NetworkPkg/HttpBootDxe/HttpBootDhcp6.c
@@ -1,7 +1,7 @@
/** @file
Functions implementation related with DHCPv6 for HTTP boot driver.
-Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available under
the terms and conditions of the BSD License that accompanies this distribution.
The full text of the license may be found at
@@ -431,56 +431,78 @@ HttpBootDhcp6CallBack (
OUT EFI_DHCP6_PACKET **NewPacket OPTIONAL
)
{
- HTTP_BOOT_PRIVATE_DATA *Private;
- EFI_DHCP6_PACKET *SelectAd;
- EFI_STATUS Status;
+ HTTP_BOOT_PRIVATE_DATA *Private;
+ EFI_DHCP6_PACKET *SelectAd;
+ EFI_STATUS Status;
+ BOOLEAN Received;
+
+ if ((Dhcp6Event != Dhcp6SendSolicit) &&
+ (Dhcp6Event != Dhcp6RcvdAdvertise) &&
+ (Dhcp6Event != Dhcp6SendRequest) &&
+ (Dhcp6Event != Dhcp6RcvdReply) &&
+ (Dhcp6Event != Dhcp6SelectAdvertise)) {
+ return EFI_SUCCESS;
+ }
- ASSERT (Packet != NULL);
+ ASSERT (Packet != NULL);
+
+ Private = (HTTP_BOOT_PRIVATE_DATA *) Context;
+ Status = EFI_SUCCESS;
+ if (Private->HttpBootCallback != NULL && Dhcp6Event != Dhcp6SelectAdvertise) {
+ Received = (BOOLEAN) (Dhcp6Event == Dhcp6RcvdAdvertise || Dhcp6Event == Dhcp6RcvdReply);
+ Status = Private->HttpBootCallback->Callback (
+ Private->HttpBootCallback,
+ HttpBootDhcp6,
+ Received,
+ Packet->Length,
+ &Packet->Dhcp6
+ );
+ if (EFI_ERROR (Status)) {
+ return EFI_ABORTED;
+ }
+ }
+ switch (Dhcp6Event) {
- Private = (HTTP_BOOT_PRIVATE_DATA *) Context;
- Status = EFI_SUCCESS;
- switch (Dhcp6Event) {
-
- case Dhcp6RcvdAdvertise:
- Status = EFI_NOT_READY;
+ case Dhcp6RcvdAdvertise:
+ Status = EFI_NOT_READY;
if (Packet->Length > HTTP_BOOT_DHCP6_PACKET_MAX_SIZE) {
//
// Ignore the incoming packets which exceed the maximum length.
//
break;
}
- if (Private->OfferNum < HTTP_BOOT_OFFER_MAX_NUM) {
- //
- // Cache the dhcp offers to OfferBuffer[] for select later, and record
- // the OfferIndex and OfferCount.
- // If error happens, just ignore this packet and continue to wait more offer.
- //
- HttpBootCacheDhcp6Offer (Private, Packet);
- }
- break;
-
- case Dhcp6SelectAdvertise:
- //
- // Select offer by the default policy or by order, and record the SelectIndex
- // and SelectProxyType.
- //
- HttpBootSelectDhcpOffer (Private);
-
- if (Private->SelectIndex == 0) {
- Status = EFI_ABORTED;
- } else {
- ASSERT (NewPacket != NULL);
- SelectAd = &Private->OfferBuffer[Private->SelectIndex - 1].Dhcp6.Packet.Offer;
- *NewPacket = AllocateZeroPool (SelectAd->Size);
- if (*NewPacket == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
- CopyMem (*NewPacket, SelectAd, SelectAd->Size);
- }
- break;
+ if (Private->OfferNum < HTTP_BOOT_OFFER_MAX_NUM) {
+ //
+ // Cache the dhcp offers to OfferBuffer[] for select later, and record
+ // the OfferIndex and OfferCount.
+ // If error happens, just ignore this packet and continue to wait more offer.
+ //
+ HttpBootCacheDhcp6Offer (Private, Packet);
+ }
+ break;
+
+ case Dhcp6SelectAdvertise:
+ //
+ // Select offer by the default policy or by order, and record the SelectIndex
+ // and SelectProxyType.
+ //
+ HttpBootSelectDhcpOffer (Private);
+
+ if (Private->SelectIndex == 0) {
+ Status = EFI_ABORTED;
+ } else {
+ ASSERT (NewPacket != NULL);
+ SelectAd = &Private->OfferBuffer[Private->SelectIndex - 1].Dhcp6.Packet.Offer;
+ *NewPacket = AllocateZeroPool (SelectAd->Size);
+ if (*NewPacket == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+ CopyMem (*NewPacket, SelectAd, SelectAd->Size);
+ }
+ break;
- default:
- break;
+ default:
+ break;
}
return Status;