summaryrefslogtreecommitdiffstats
path: root/NetworkPkg/HttpBootDxe/HttpBootDhcp4.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/HttpBootDhcp4.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/HttpBootDhcp4.c')
-rw-r--r--NetworkPkg/HttpBootDxe/HttpBootDhcp4.c26
1 files changed, 24 insertions, 2 deletions
diff --git a/NetworkPkg/HttpBootDxe/HttpBootDhcp4.c b/NetworkPkg/HttpBootDxe/HttpBootDhcp4.c
index fcea916225..a8cee04c25 100644
--- a/NetworkPkg/HttpBootDxe/HttpBootDhcp4.c
+++ b/NetworkPkg/HttpBootDxe/HttpBootDhcp4.c
@@ -1,7 +1,7 @@
/** @file
Functions implementation related with DHCPv4 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
@@ -609,8 +609,13 @@ HttpBootDhcp4CallBack (
EFI_DHCP4_PACKET_OPTION *MaxMsgSize;
UINT16 Value;
EFI_STATUS Status;
+ BOOLEAN Received;
- if ((Dhcp4Event != Dhcp4RcvdOffer) && (Dhcp4Event != Dhcp4SelectOffer)) {
+ if ((Dhcp4Event != Dhcp4SendDiscover) &&
+ (Dhcp4Event != Dhcp4RcvdOffer) &&
+ (Dhcp4Event != Dhcp4SendRequest) &&
+ (Dhcp4Event != Dhcp4RcvdAck) &&
+ (Dhcp4Event != Dhcp4SelectOffer)) {
return EFI_SUCCESS;
}
@@ -628,6 +633,23 @@ HttpBootDhcp4CallBack (
Value = HTONS (HTTP_BOOT_DHCP4_PACKET_MAX_SIZE);
CopyMem (MaxMsgSize->Data, &Value, sizeof (Value));
}
+
+ //
+ // Callback to user if any packets sent or received.
+ //
+ if (Private->HttpBootCallback != NULL && Dhcp4Event != Dhcp4SelectOffer) {
+ Received = (BOOLEAN) (Dhcp4Event == Dhcp4RcvdOffer || Dhcp4Event == Dhcp4RcvdAck);
+ Status = Private->HttpBootCallback->Callback (
+ Private->HttpBootCallback,
+ HttpBootDhcp4,
+ Received,
+ Packet->Length,
+ &Packet->Dhcp4
+ );
+ if (EFI_ERROR (Status)) {
+ return EFI_ABORTED;
+ }
+ }
Status = EFI_SUCCESS;
switch (Dhcp4Event) {