]> git.proxmox.com Git - mirror_edk2.git/blobdiff - NetworkPkg/HttpBootDxe/HttpBootDhcp4.c
NetworkPkg/HttpBootDxe: Add HTTP Boot Callback protocol support.
[mirror_edk2.git] / NetworkPkg / HttpBootDxe / HttpBootDhcp4.c
index fcea916225aa859acc76a8c6a427c809627ad2db..a8cee04c256c1c5657255dcc02c529e7f46cbe34 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Functions implementation related with DHCPv4 for HTTP boot driver.\r
 \r
-Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials are licensed and made available under \r
 the terms and conditions of the BSD License that accompanies this distribution.  \r
 The full text of the license may be found at\r
@@ -609,8 +609,13 @@ HttpBootDhcp4CallBack (
   EFI_DHCP4_PACKET_OPTION              *MaxMsgSize;\r
   UINT16                               Value;\r
   EFI_STATUS                           Status;\r
+  BOOLEAN                              Received;\r
 \r
-  if ((Dhcp4Event != Dhcp4RcvdOffer) && (Dhcp4Event != Dhcp4SelectOffer)) {\r
+  if ((Dhcp4Event != Dhcp4SendDiscover) && \r
+      (Dhcp4Event != Dhcp4RcvdOffer) && \r
+      (Dhcp4Event != Dhcp4SendRequest) && \r
+      (Dhcp4Event != Dhcp4RcvdAck) && \r
+      (Dhcp4Event != Dhcp4SelectOffer)) {\r
     return EFI_SUCCESS;\r
   }\r
   \r
@@ -628,6 +633,23 @@ HttpBootDhcp4CallBack (
     Value = HTONS (HTTP_BOOT_DHCP4_PACKET_MAX_SIZE);\r
     CopyMem (MaxMsgSize->Data, &Value, sizeof (Value));\r
   }\r
+  \r
+  //\r
+  // Callback to user if any packets sent or received.\r
+  //\r
+  if (Private->HttpBootCallback != NULL && Dhcp4Event != Dhcp4SelectOffer) {\r
+    Received = (BOOLEAN) (Dhcp4Event == Dhcp4RcvdOffer || Dhcp4Event == Dhcp4RcvdAck);\r
+    Status = Private->HttpBootCallback->Callback (\r
+               Private->HttpBootCallback, \r
+               HttpBootDhcp4,\r
+               Received,\r
+               Packet->Length,\r
+               &Packet->Dhcp4\r
+               );\r
+    if (EFI_ERROR (Status)) {\r
+      return EFI_ABORTED;\r
+    }\r
+  }\r
 \r
   Status = EFI_SUCCESS;\r
   switch (Dhcp4Event) {\r