]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Impl.c
MdeModulePkg: Remove DHCP4.TransmitReceive()and DORA process dependency.
[mirror_edk2.git] / MdeModulePkg / Universal / Network / Dhcp4Dxe / Dhcp4Impl.c
index d4ca364555c15e67607bfba4d16dc22da1704daa..ac4b11f09402a1cadc793db6038c5fb1c01c8574 100644 (file)
@@ -1,7 +1,8 @@
 /** @file\r
+  This file implement the EFI_DHCP4_PROTOCOL interface.\r
 \r
-Copyright (c) 2006 - 2008, Intel Corporation\r
-All rights reserved. This program and the accompanying materials\r
+Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
 http://opensource.org/licenses/bsd-license.php\r
@@ -9,15 +10,6 @@ http://opensource.org/licenses/bsd-license.php
 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
 \r
-Module Name:\r
-\r
-  Dhcp4Impl.c\r
-\r
-Abstract:\r
-\r
-  This file implement the EFI_DHCP4_PROTOCOL interface.\r
-\r
-\r
 **/\r
 \r
 \r
@@ -25,12 +17,12 @@ Abstract:
 \r
 /**\r
   Returns the current operating mode and cached data packet for the EFI DHCPv4 Protocol driver.\r
-  \r
+\r
   The GetModeData() function returns the current operating mode and cached data\r
   packet for the EFI DHCPv4 Protocol driver.\r
 \r
-  @param  This          Pointer to the EFI_DHCP4_PROTOCOL instance.\r
-  @param  Dhcp4ModeData Pointer to storage for the EFI_DHCP4_MODE_DATA structure.\r
+  @param[in]  This          Pointer to the EFI_DHCP4_PROTOCOL instance.\r
+  @param[out] Dhcp4ModeData Pointer to storage for the EFI_DHCP4_MODE_DATA structure.\r
 \r
   @retval EFI_SUCCESS           The mode data was returned.\r
   @retval EFI_INVALID_PARAMETER This is NULL.\r
@@ -69,8 +61,8 @@ EfiDhcp4GetModeData (
   wants to make it possible for another instance to configure the EFI DHCPv4 Protocol\r
   driver, it must call this function with Dhcp4CfgData set to NULL.\r
 \r
-  @param  This                   Pointer to the EFI_DHCP4_PROTOCOL instance.\r
-  @param  Dhcp4CfgData           Pointer to the EFI_DHCP4_CONFIG_DATA.\r
+  @param[in]  This                   Pointer to the EFI_DHCP4_PROTOCOL instance.\r
+  @param[in]  Dhcp4CfgData           Pointer to the EFI_DHCP4_CONFIG_DATA.\r
 \r
   @retval EFI_SUCCESS           The EFI DHCPv4 Protocol driver is now in the Dhcp4Init or\r
                                 Dhcp4InitReboot state, if the original state of this driver\r
@@ -90,7 +82,7 @@ EFIAPI
 EfiDhcp4Configure (\r
   IN EFI_DHCP4_PROTOCOL     *This,\r
   IN EFI_DHCP4_CONFIG_DATA  *Dhcp4CfgData       OPTIONAL\r
-  );  \r
+  );\r
 \r
 /**\r
   Starts the DHCP configuration process.\r
@@ -108,15 +100,15 @@ EfiDhcp4Configure (
   time when each event occurs in this process, the callback function that was set\r
   by EFI_DHCP4_PROTOCOL.Configure() will be called and the user can take this\r
   opportunity to control the process.\r
-  \r
-  @param  This            Pointer to the EFI_DHCP4_PROTOCOL instance.\r
-  @param  CompletionEvent If not NULL, indicates the event that will be signaled when the\r
-                          EFI DHCPv4 Protocol driver is transferred into the\r
-                          Dhcp4Bound state or when the DHCP process is aborted.\r
-                          EFI_DHCP4_PROTOCOL.GetModeData() can be called to\r
-                          check the completion status. If NULL,\r
-                          EFI_DHCP4_PROTOCOL.Start() will wait until the driver\r
-                          is transferred into the Dhcp4Bound state or the process fails.\r
+\r
+  @param[in]  This            Pointer to the EFI_DHCP4_PROTOCOL instance.\r
+  @param[in]  CompletionEvent If not NULL, indicates the event that will be signaled when the\r
+                              EFI DHCPv4 Protocol driver is transferred into the\r
+                              Dhcp4Bound state or when the DHCP process is aborted.\r
+                              EFI_DHCP4_PROTOCOL.GetModeData() can be called to\r
+                              check the completion status. If NULL,\r
+                              EFI_DHCP4_PROTOCOL.Start() will wait until the driver\r
+                              is transferred into the Dhcp4Bound state or the process fails.\r
 \r
   @retval EFI_SUCCESS           The DHCP configuration process has started, or it has completed\r
                                 when CompletionEvent is NULL.\r
@@ -141,7 +133,7 @@ EfiDhcp4Start (
 \r
 /**\r
   Extends the lease time by sending a request packet.\r
-  \r
+\r
   The RenewRebind() function is used to manually extend the lease time when the\r
   EFI DHCPv4 Protocol driver is in the Dhcp4Bound state and the lease time has\r
   not expired yet. This function will send a request packet to the previously\r
@@ -154,16 +146,16 @@ EfiDhcp4Start (
   state and the previous configuration is restored. The outgoing and incoming packets\r
   can be captured by the EFI_DHCP4_CALLBACK function.\r
 \r
-  @param  This            Pointer to the EFI_DHCP4_PROTOCOL instance.\r
-  @param  RebindRequest   If TRUE, this function broadcasts the request packets and enters\r
-                          the Dhcp4Rebinding state. Otherwise, it sends a unicast\r
-                          request packet and enters the Dhcp4Renewing state.\r
-  @param  CompletionEvent If not NULL, this event is signaled when the renew/rebind phase\r
-                          completes or some error occurs.\r
-                          EFI_DHCP4_PROTOCOL.GetModeData() can be called to\r
-                          check the completion status. If NULL,\r
-                          EFI_DHCP4_PROTOCOL.RenewRebind() will busy-wait\r
-                          until the DHCP process finishes.\r
+  @param[in]  This            Pointer to the EFI_DHCP4_PROTOCOL instance.\r
+  @param[in]  RebindRequest   If TRUE, this function broadcasts the request packets and enters\r
+                              the Dhcp4Rebinding state. Otherwise, it sends a unicast\r
+                              request packet and enters the Dhcp4Renewing state.\r
+  @param[in]  CompletionEvent If not NULL, this event is signaled when the renew/rebind phase\r
+                              completes or some error occurs.\r
+                              EFI_DHCP4_PROTOCOL.GetModeData() can be called to\r
+                              check the completion status. If NULL,\r
+                              EFI_DHCP4_PROTOCOL.RenewRebind() will busy-wait\r
+                              until the DHCP process finishes.\r
 \r
   @retval EFI_SUCCESS           The EFI DHCPv4 Protocol driver is now in the\r
                                 Dhcp4Renewing state or is back to the Dhcp4Bound state.\r
@@ -198,7 +190,7 @@ EfiDhcp4RenewRebind (
   After a successful call to this function, the EFI DHCPv4 Protocol driver returns\r
   to the Dhcp4Init state and any subsequent incoming packets will be discarded silently.\r
 \r
-  @param  This                  Pointer to the EFI_DHCP4_PROTOCOL instance.\r
+  @param[in]  This                  Pointer to the EFI_DHCP4_PROTOCOL instance.\r
 \r
   @retval EFI_SUCCESS           The EFI DHCPv4 Protocol driver is now in the Dhcp4Init phase.\r
   @retval EFI_INVALID_PARAMETER This is NULL.\r
@@ -214,14 +206,14 @@ EfiDhcp4Release (
 \r
 /**\r
   Stops the current address configuration.\r
-  \r
+\r
   The Stop() function is used to stop the DHCP configuration process. After this\r
   function is called successfully, the EFI DHCPv4 Protocol driver is transferred\r
   into the Dhcp4Stopped state. EFI_DHCP4_PROTOCOL.Configure() needs to be called\r
   before DHCP configuration process can be started again. This function can be\r
   called when the EFI DHCPv4 Protocol driver is in any state.\r
 \r
-  @param  This                  Pointer to the EFI_DHCP4_PROTOCOL instance.\r
+  @param[in]  This                  Pointer to the EFI_DHCP4_PROTOCOL instance.\r
 \r
   @retval EFI_SUCCESS           The EFI DHCPv4 Protocol driver is now in the Dhcp4Stopped phase.\r
   @retval EFI_INVALID_PARAMETER This is NULL.\r
@@ -241,19 +233,19 @@ EfiDhcp4Stop (
   does not change any state of the EFI DHCPv4 Protocol driver and can be used at\r
   any time.\r
 \r
-  @param  This        Pointer to the EFI_DHCP4_PROTOCOL instance.\r
-  @param  SeedPacket  Initial packet to be used as a base for building new packet.\r
-  @param  DeleteCount Number of opcodes in the DeleteList.\r
-  @param  DeleteList  List of opcodes to be deleted from the seed packet.\r
-                      Ignored if DeleteCount is zero.\r
-  @param  AppendCount Number of entries in the OptionList.\r
-  @param  AppendList  Pointer to a DHCP option list to be appended to SeedPacket.\r
-                      If SeedPacket also contains options in this list, they are\r
-                      replaced by new options (except pad option). Ignored if\r
-                      AppendCount is zero. Type EFI_DHCP4_PACKET_OPTION\r
-  @param  NewPacket   Pointer to storage for the pointer to the new allocated packet.\r
-                      Use the EFI Boot Service FreePool() on the resulting pointer\r
-                      when done with the packet.\r
+  @param[in]  This        Pointer to the EFI_DHCP4_PROTOCOL instance.\r
+  @param[in]  SeedPacket  Initial packet to be used as a base for building new packet.\r
+  @param[in]  DeleteCount Number of opcodes in the DeleteList.\r
+  @param[in]  DeleteList  List of opcodes to be deleted from the seed packet.\r
+                          Ignored if DeleteCount is zero.\r
+  @param[in]  AppendCount Number of entries in the OptionList.\r
+  @param[in]  AppendList  Pointer to a DHCP option list to be appended to SeedPacket.\r
+                          If SeedPacket also contains options in this list, they are\r
+                          replaced by new options (except pad option). Ignored if\r
+                          AppendCount is zero. Type EFI_DHCP4_PACKET_OPTION\r
+  @param[out] NewPacket   Pointer to storage for the pointer to the new allocated packet.\r
+                          Use the EFI Boot Service FreePool() on the resulting pointer\r
+                          when done with the packet.\r
 \r
   @retval EFI_SUCCESS           The new packet was built.\r
   @retval EFI_OUT_OF_RESOURCES  Storage for the new packet could not be allocated.\r
@@ -271,16 +263,16 @@ EfiDhcp4Build (
   IN EFI_DHCP4_PACKET_OPTION  *AppendList[] OPTIONAL,\r
   OUT EFI_DHCP4_PACKET        **NewPacket\r
   );\r
-  \r
-  /**\r
+\r
+/**\r
   Transmits a DHCP formatted packet and optionally waits for responses.\r
-  \r
+\r
   The TransmitReceive() function is used to transmit a DHCP packet and optionally\r
   wait for the response from servers. This function does not change the state of\r
   the EFI DHCPv4 Protocol driver and thus can be used at any time.\r
 \r
-  @param  This    Pointer to the EFI_DHCP4_PROTOCOL instance.\r
-  @param  Token   Pointer to the EFI_DHCP4_TRANSMIT_RECEIVE_TOKEN structure.\r
+  @param[in]  This    Pointer to the EFI_DHCP4_PROTOCOL instance.\r
+  @param[in]  Token   Pointer to the EFI_DHCP4_TRANSMIT_RECEIVE_TOKEN structure.\r
 \r
   @retval EFI_SUCCESS           The packet was successfully queued for transmission.\r
   @retval EFI_INVALID_PARAMETER Some parameter is NULL.\r
@@ -300,13 +292,13 @@ EfiDhcp4TransmitReceive (
 \r
 /**\r
   Parses the packed DHCP option data.\r
-  \r
+\r
   The Parse() function is used to retrieve the option list from a DHCP packet.\r
-  If *OptionCount isnt zero, and there is enough space for all the DHCP options\r
+  If *OptionCount isn't zero, and there is enough space for all the DHCP options\r
   in the Packet, each element of PacketOptionList is set to point to somewhere in\r
   the Packet->Dhcp4.Option where a new DHCP option begins. If RFC3396 is supported,\r
   the caller should reassemble the parsed DHCP options to get the finial result.\r
-  If *OptionCount is zero or there isnt enough space for all of them, the number\r
+  If *OptionCount is zero or there isn't enough space for all of them, the number\r
   of DHCP options in the Packet is returned in OptionCount.\r
 \r
   @param  This             Pointer to the EFI_DHCP4_PROTOCOL instance.\r
@@ -348,12 +340,12 @@ EFI_DHCP4_PROTOCOL  mDhcp4ProtocolTemplate = {
 \r
 /**\r
   Returns the current operating mode and cached data packet for the EFI DHCPv4 Protocol driver.\r
-  \r
+\r
   The GetModeData() function returns the current operating mode and cached data\r
   packet for the EFI DHCPv4 Protocol driver.\r
 \r
-  @param  This          Pointer to the EFI_DHCP4_PROTOCOL instance.\r
-  @param  Dhcp4ModeData Pointer to storage for the EFI_DHCP4_MODE_DATA structure.\r
+  @param[in]  This          Pointer to the EFI_DHCP4_PROTOCOL instance.\r
+  @param[out] Dhcp4ModeData Pointer to storage for the EFI_DHCP4_MODE_DATA structure.\r
 \r
   @retval EFI_SUCCESS           The mode data was returned.\r
   @retval EFI_INVALID_PARAMETER This is NULL.\r
@@ -426,8 +418,6 @@ EfiDhcp4GetModeData (
 \r
   @param  Config                 The DHCP configure data\r
 \r
-  @return None\r
-\r
 **/\r
 VOID\r
 DhcpCleanConfigure (\r
@@ -437,21 +427,21 @@ DhcpCleanConfigure (
   UINT32                    Index;\r
 \r
   if (Config->DiscoverTimeout != NULL) {\r
-    gBS->FreePool (Config->DiscoverTimeout);\r
+    FreePool (Config->DiscoverTimeout);\r
   }\r
 \r
   if (Config->RequestTimeout != NULL) {\r
-    gBS->FreePool (Config->RequestTimeout);\r
+    FreePool (Config->RequestTimeout);\r
   }\r
 \r
   if (Config->OptionList != NULL) {\r
     for (Index = 0; Index < Config->OptionCount; Index++) {\r
       if (Config->OptionList[Index] != NULL) {\r
-        gBS->FreePool (Config->OptionList[Index]);\r
+        FreePool (Config->OptionList[Index]);\r
       }\r
     }\r
 \r
-    gBS->FreePool (Config->OptionList);\r
+    FreePool (Config->OptionList);\r
   }\r
 \r
   ZeroMem (Config, sizeof (EFI_DHCP4_CONFIG_DATA));\r
@@ -462,8 +452,8 @@ DhcpCleanConfigure (
   Allocate memory for configure parameter such as timeout value for Dst,\r
   then copy the configure parameter from Src to Dst.\r
 \r
-  @param  Dst                    The destination DHCP configure data.\r
-  @param  Src                    The source DHCP configure data.\r
+  @param[out]  Dst                    The destination DHCP configure data.\r
+  @param[in]   Src                    The source DHCP configure data.\r
 \r
   @retval EFI_OUT_OF_RESOURCES   Failed to allocate memory.\r
   @retval EFI_SUCCESS            The configure is copied.\r
@@ -477,7 +467,7 @@ DhcpCopyConfigure (
 {\r
   EFI_DHCP4_PACKET_OPTION   **DstOptions;\r
   EFI_DHCP4_PACKET_OPTION   **SrcOptions;\r
-  INTN                      Len;\r
+  UINTN                     Len;\r
   UINT32                    Index;\r
 \r
   CopyMem (Dst, Src, sizeof (*Dst));\r
@@ -560,8 +550,6 @@ ON_ERROR:
 \r
   @param  DhcpSb                 The DHCP service instance.\r
 \r
-  @return None\r
-\r
 **/\r
 VOID\r
 DhcpYieldControl (\r
@@ -576,14 +564,14 @@ DhcpYieldControl (
   DhcpSb->ActiveChild   = NULL;\r
 \r
   if (Config->DiscoverTimeout != NULL) {\r
-    gBS->FreePool (Config->DiscoverTimeout);\r
+    FreePool (Config->DiscoverTimeout);\r
 \r
     Config->DiscoverTryCount  = 0;\r
     Config->DiscoverTimeout   = NULL;\r
   }\r
 \r
   if (Config->RequestTimeout != NULL) {\r
-    gBS->FreePool (Config->RequestTimeout);\r
+    FreePool (Config->RequestTimeout);\r
 \r
     Config->RequestTryCount = 0;\r
     Config->RequestTimeout  = NULL;\r
@@ -620,8 +608,8 @@ DhcpYieldControl (
   wants to make it possible for another instance to configure the EFI DHCPv4 Protocol\r
   driver, it must call this function with Dhcp4CfgData set to NULL.\r
 \r
-  @param  This                   Pointer to the EFI_DHCP4_PROTOCOL instance.\r
-  @param  Dhcp4CfgData           Pointer to the EFI_DHCP4_CONFIG_DATA.\r
+  @param[in]  This                   Pointer to the EFI_DHCP4_PROTOCOL instance.\r
+  @param[in]  Dhcp4CfgData           Pointer to the EFI_DHCP4_CONFIG_DATA.\r
 \r
   @retval EFI_SUCCESS           The EFI DHCPv4 Protocol driver is now in the Dhcp4Init or\r
                                 Dhcp4InitReboot state, if the original state of this driver\r
@@ -659,21 +647,21 @@ EfiDhcp4Configure (
   }\r
 \r
   if (Dhcp4CfgData != NULL) {\r
-    if (Dhcp4CfgData->DiscoverTryCount && (Dhcp4CfgData->DiscoverTimeout == NULL)) {\r
+    if ((Dhcp4CfgData->DiscoverTryCount != 0) && (Dhcp4CfgData->DiscoverTimeout == NULL)) {\r
       return EFI_INVALID_PARAMETER;\r
     }\r
 \r
-    if (Dhcp4CfgData->RequestTryCount && (Dhcp4CfgData->RequestTimeout == NULL)) {\r
+    if ((Dhcp4CfgData->RequestTryCount != 0) && (Dhcp4CfgData->RequestTimeout == NULL)) {\r
       return EFI_INVALID_PARAMETER;\r
     }\r
 \r
-    if (Dhcp4CfgData->OptionCount && (Dhcp4CfgData->OptionList == NULL)) {\r
+    if ((Dhcp4CfgData->OptionCount != 0) && (Dhcp4CfgData->OptionList == NULL)) {\r
       return EFI_INVALID_PARAMETER;\r
     }\r
 \r
     CopyMem (&Ip, &Dhcp4CfgData->ClientAddress, sizeof (IP4_ADDR));\r
 \r
-    if ((Ip != 0) && !Ip4IsUnicast (NTOHL (Ip), 0)) {\r
+    if ((Ip != 0) && !NetIp4IsUnicast (NTOHL (Ip), 0)) {\r
 \r
       return EFI_INVALID_PARAMETER;\r
     }\r
@@ -760,15 +748,15 @@ ON_EXIT:
   time when each event occurs in this process, the callback function that was set\r
   by EFI_DHCP4_PROTOCOL.Configure() will be called and the user can take this\r
   opportunity to control the process.\r
-  \r
-  @param  This            Pointer to the EFI_DHCP4_PROTOCOL instance.\r
-  @param  CompletionEvent If not NULL, indicates the event that will be signaled when the\r
-                          EFI DHCPv4 Protocol driver is transferred into the\r
-                          Dhcp4Bound state or when the DHCP process is aborted.\r
-                          EFI_DHCP4_PROTOCOL.GetModeData() can be called to\r
-                          check the completion status. If NULL,\r
-                          EFI_DHCP4_PROTOCOL.Start() will wait until the driver\r
-                          is transferred into the Dhcp4Bound state or the process fails.\r
+\r
+  @param[in]  This            Pointer to the EFI_DHCP4_PROTOCOL instance.\r
+  @param[in]  CompletionEvent If not NULL, indicates the event that will be signaled when the\r
+                              EFI DHCPv4 Protocol driver is transferred into the\r
+                              Dhcp4Bound state or when the DHCP process is aborted.\r
+                              EFI_DHCP4_PROTOCOL.GetModeData() can be called to\r
+                              check the completion status. If NULL,\r
+                              EFI_DHCP4_PROTOCOL.Start() will wait until the driver\r
+                              is transferred into the Dhcp4Bound state or the process fails.\r
 \r
   @retval EFI_SUCCESS           The DHCP configuration process has started, or it has completed\r
                                 when CompletionEvent is NULL.\r
@@ -782,6 +770,7 @@ ON_EXIT:
   @retval EFI_ALREADY_STARTED   Some other EFI DHCPv4 Protocol instance already started the\r
                                 DHCP process.\r
   @retval EFI_DEVICE_ERROR      An unexpected system or network error occurred.\r
+  @retval EFI_NO_MEDIA          There was a media error.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -828,14 +817,6 @@ EfiDhcp4Start (
     goto ON_ERROR;\r
   }\r
 \r
-  //\r
-  // Start/Restart the receiving.\r
-  //\r
-  Status = UdpIoRecvDatagram (DhcpSb->UdpIo, DhcpInput, DhcpSb, 0);\r
-\r
-  if (EFI_ERROR (Status) && (Status != EFI_ALREADY_STARTED)) {\r
-    goto ON_ERROR;\r
-  }\r
 \r
   Instance->CompletionEvent = CompletionEvent;\r
 \r
@@ -846,7 +827,7 @@ EfiDhcp4Start (
 \r
   if (CompletionEvent == NULL) {\r
     while (DhcpSb->IoStatus == EFI_ALREADY_STARTED) {\r
-      DhcpSb->UdpIo->Udp->Poll (DhcpSb->UdpIo->Udp);\r
+      DhcpSb->UdpIo->Protocol.Udp4->Poll (DhcpSb->UdpIo->Protocol.Udp4);\r
     }\r
 \r
     return DhcpSb->IoStatus;\r
@@ -862,7 +843,7 @@ ON_ERROR:
 \r
 /**\r
   Extends the lease time by sending a request packet.\r
-  \r
+\r
   The RenewRebind() function is used to manually extend the lease time when the\r
   EFI DHCPv4 Protocol driver is in the Dhcp4Bound state and the lease time has\r
   not expired yet. This function will send a request packet to the previously\r
@@ -875,16 +856,16 @@ ON_ERROR:
   state and the previous configuration is restored. The outgoing and incoming packets\r
   can be captured by the EFI_DHCP4_CALLBACK function.\r
 \r
-  @param  This            Pointer to the EFI_DHCP4_PROTOCOL instance.\r
-  @param  RebindRequest   If TRUE, this function broadcasts the request packets and enters\r
-                          the Dhcp4Rebinding state. Otherwise, it sends a unicast\r
-                          request packet and enters the Dhcp4Renewing state.\r
-  @param  CompletionEvent If not NULL, this event is signaled when the renew/rebind phase\r
-                          completes or some error occurs.\r
-                          EFI_DHCP4_PROTOCOL.GetModeData() can be called to\r
-                          check the completion status. If NULL,\r
-                          EFI_DHCP4_PROTOCOL.RenewRebind() will busy-wait\r
-                          until the DHCP process finishes.\r
+  @param[in]  This            Pointer to the EFI_DHCP4_PROTOCOL instance.\r
+  @param[in]  RebindRequest   If TRUE, this function broadcasts the request packets and enters\r
+                              the Dhcp4Rebinding state. Otherwise, it sends a unicast\r
+                              request packet and enters the Dhcp4Renewing state.\r
+  @param[in]  CompletionEvent If not NULL, this event is signaled when the renew/rebind phase\r
+                              completes or some error occurs.\r
+                              EFI_DHCP4_PROTOCOL.GetModeData() can be called to\r
+                              check the completion status. If NULL,\r
+                              EFI_DHCP4_PROTOCOL.RenewRebind() will busy-wait\r
+                              until the DHCP process finishes.\r
 \r
   @retval EFI_SUCCESS           The EFI DHCPv4 Protocol driver is now in the\r
                                 Dhcp4Renewing state or is back to the Dhcp4Bound state.\r
@@ -929,16 +910,17 @@ EfiDhcp4RenewRebind (
 \r
   if (DhcpSb->DhcpState == Dhcp4Stopped) {\r
     Status = EFI_NOT_STARTED;\r
-    goto ON_ERROR;\r
+    goto ON_EXIT;\r
   }\r
 \r
   if (DhcpSb->DhcpState != Dhcp4Bound) {\r
     Status = EFI_ACCESS_DENIED;\r
-    goto ON_ERROR;\r
+    goto ON_EXIT;\r
   }\r
 \r
   if (DHCP_IS_BOOTP (DhcpSb->Para)) {\r
-    return EFI_SUCCESS;\r
+    Status = EFI_SUCCESS;\r
+    goto ON_EXIT;\r
   }\r
 \r
   //\r
@@ -950,6 +932,12 @@ EfiDhcp4RenewRebind (
     DhcpSetState (DhcpSb, Dhcp4Rebinding, FALSE);\r
   }\r
 \r
+  //\r
+  // Clear initial time to make sure that elapsed-time\r
+  // is set to 0 for first REQUEST in renewal process.\r
+  //\r
+  Instance->ElaspedTime = 0;\r
+\r
   Status = DhcpSendMessage (\r
              DhcpSb,\r
              DhcpSb->Selected,\r
@@ -960,7 +948,7 @@ EfiDhcp4RenewRebind (
 \r
   if (EFI_ERROR (Status)) {\r
     DhcpSetState (DhcpSb, Dhcp4Bound, FALSE);\r
-    goto ON_ERROR;\r
+    goto ON_EXIT;\r
   }\r
 \r
   DhcpSb->ExtraRefresh        = TRUE;\r
@@ -971,7 +959,8 @@ EfiDhcp4RenewRebind (
 \r
   if (CompletionEvent == NULL) {\r
     while (DhcpSb->IoStatus == EFI_ALREADY_STARTED) {\r
-      DhcpSb->UdpIo->Udp->Poll (DhcpSb->UdpIo->Udp);\r
+      DhcpSb->UdpIo->Protocol.Udp4->Poll (DhcpSb->UdpIo->Protocol.Udp4);\r
+\r
     }\r
 \r
     return DhcpSb->IoStatus;\r
@@ -979,7 +968,7 @@ EfiDhcp4RenewRebind (
 \r
   return EFI_SUCCESS;\r
 \r
-ON_ERROR:\r
+ON_EXIT:\r
   gBS->RestoreTPL (OldTpl);\r
   return Status;\r
 }\r
@@ -998,7 +987,7 @@ ON_ERROR:
   After a successful call to this function, the EFI DHCPv4 Protocol driver returns\r
   to the Dhcp4Init state and any subsequent incoming packets will be discarded silently.\r
 \r
-  @param  This                  Pointer to the EFI_DHCP4_PROTOCOL instance.\r
+  @param[in]  This                  Pointer to the EFI_DHCP4_PROTOCOL instance.\r
 \r
   @retval EFI_SUCCESS           The EFI DHCPv4 Protocol driver is now in the Dhcp4Init phase.\r
   @retval EFI_INVALID_PARAMETER This is NULL.\r
@@ -1064,14 +1053,14 @@ ON_EXIT:
 \r
 /**\r
   Stops the current address configuration.\r
-  \r
+\r
   The Stop() function is used to stop the DHCP configuration process. After this\r
   function is called successfully, the EFI DHCPv4 Protocol driver is transferred\r
   into the Dhcp4Stopped state. EFI_DHCP4_PROTOCOL.Configure() needs to be called\r
   before DHCP configuration process can be started again. This function can be\r
   called when the EFI DHCPv4 Protocol driver is in any state.\r
 \r
-  @param  This                  Pointer to the EFI_DHCP4_PROTOCOL instance.\r
+  @param[in]  This                  Pointer to the EFI_DHCP4_PROTOCOL instance.\r
 \r
   @retval EFI_SUCCESS           The EFI DHCPv4 Protocol driver is now in the Dhcp4Stopped phase.\r
   @retval EFI_INVALID_PARAMETER This is NULL.\r
@@ -1121,19 +1110,19 @@ EfiDhcp4Stop (
   does not change any state of the EFI DHCPv4 Protocol driver and can be used at\r
   any time.\r
 \r
-  @param  This        Pointer to the EFI_DHCP4_PROTOCOL instance.\r
-  @param  SeedPacket  Initial packet to be used as a base for building new packet.\r
-  @param  DeleteCount Number of opcodes in the DeleteList.\r
-  @param  DeleteList  List of opcodes to be deleted from the seed packet.\r
-                      Ignored if DeleteCount is zero.\r
-  @param  AppendCount Number of entries in the OptionList.\r
-  @param  AppendList  Pointer to a DHCP option list to be appended to SeedPacket.\r
-                      If SeedPacket also contains options in this list, they are\r
-                      replaced by new options (except pad option). Ignored if\r
-                      AppendCount is zero. Type EFI_DHCP4_PACKET_OPTION\r
-  @param  NewPacket   Pointer to storage for the pointer to the new allocated packet.\r
-                      Use the EFI Boot Service FreePool() on the resulting pointer\r
-                      when done with the packet.\r
+  @param[in]  This        Pointer to the EFI_DHCP4_PROTOCOL instance.\r
+  @param[in]  SeedPacket  Initial packet to be used as a base for building new packet.\r
+  @param[in]  DeleteCount Number of opcodes in the DeleteList.\r
+  @param[in]  DeleteList  List of opcodes to be deleted from the seed packet.\r
+                          Ignored if DeleteCount is zero.\r
+  @param[in]  AppendCount Number of entries in the OptionList.\r
+  @param[in]  AppendList  Pointer to a DHCP option list to be appended to SeedPacket.\r
+                          If SeedPacket also contains options in this list, they are\r
+                          replaced by new options (except pad option). Ignored if\r
+                          AppendCount is zero. Type EFI_DHCP4_PACKET_OPTION\r
+  @param[out] NewPacket   Pointer to storage for the pointer to the new allocated packet.\r
+                          Use the EFI Boot Service FreePool() on the resulting pointer\r
+                          when done with the packet.\r
 \r
   @retval EFI_SUCCESS           The new packet was built.\r
   @retval EFI_OUT_OF_RESOURCES  Storage for the new packet could not be allocated.\r
@@ -1184,16 +1173,17 @@ EfiDhcp4Build (
 \r
 /**\r
   Callback by UdpIoCreatePort() when creating UdpIo for this Dhcp4 instance.\r
-  \r
-  @param UdpIo      The UdpIo being created.\r
-  @param Context    Dhcp4 instance.\r
-  \r
+\r
+  @param[in] UdpIo      The UdpIo being created.\r
+  @param[in] Context    Dhcp4 instance.\r
+\r
   @retval EFI_SUCCESS   UdpIo is configured successfully.\r
   @retval other         Other error occurs.\r
 **/\r
 EFI_STATUS\r
+EFIAPI\r
 Dhcp4InstanceConfigUdpIo (\r
-  IN UDP_IO_PORT  *UdpIo,\r
+  IN UDP_IO       *UdpIo,\r
   IN VOID         *Context\r
   )\r
 {\r
@@ -1201,7 +1191,10 @@ Dhcp4InstanceConfigUdpIo (
   DHCP_SERVICE                      *DhcpSb;\r
   EFI_DHCP4_TRANSMIT_RECEIVE_TOKEN  *Token;\r
   EFI_UDP4_CONFIG_DATA              UdpConfigData;\r
-  IP4_ADDR                          Ip;\r
+  IP4_ADDR                          ClientAddr;\r
+  IP4_ADDR                          Ip;   \r
+  INTN                              Class; \r
+  IP4_ADDR                          SubnetMask;\r
 \r
   Instance = (DHCP_PROTOCOL *) Context;\r
   DhcpSb   = Instance->Service;\r
@@ -1214,10 +1207,14 @@ Dhcp4InstanceConfigUdpIo (
   UdpConfigData.TimeToLive         = 64;\r
   UdpConfigData.DoNotFragment      = TRUE;\r
 \r
-  Ip = HTONL (DhcpSb->ClientAddr);\r
+  ClientAddr = EFI_NTOHL (Token->Packet->Dhcp4.Header.ClientAddr);\r
+  Ip = HTONL (ClientAddr);\r
   CopyMem (&UdpConfigData.StationAddress, &Ip, sizeof (EFI_IPv4_ADDRESS));\r
-\r
-  Ip = HTONL (DhcpSb->Netmask);\r
+  \r
+  Class = NetGetIpClass (ClientAddr);\r
+  ASSERT (Class < IP4_ADDR_CLASSE);\r
+  SubnetMask = gIp4AllMasks[Class << 3];\r
+  Ip = HTONL (SubnetMask);\r
   CopyMem (&UdpConfigData.SubnetMask, &Ip, sizeof (EFI_IPv4_ADDRESS));\r
 \r
   if ((Token->ListenPointCount == 0) || (Token->ListenPoints[0].ListenPort == 0)) {\r
@@ -1226,14 +1223,14 @@ Dhcp4InstanceConfigUdpIo (
     UdpConfigData.StationPort = Token->ListenPoints[0].ListenPort;\r
   }\r
 \r
-  return UdpIo->Udp->Configure (UdpIo->Udp, &UdpConfigData);\r
+  return UdpIo->Protocol.Udp4->Configure (UdpIo->Protocol.Udp4, &UdpConfigData);\r
 }\r
 \r
 /**\r
   Create UdpIo for this Dhcp4 instance.\r
-  \r
+\r
   @param Instance   The Dhcp4 instance.\r
-  \r
+\r
   @retval EFI_SUCCESS                UdpIo is created successfully.\r
   @retval EFI_OUT_OF_RESOURCES       Fails to create UdpIo because of limited\r
                                      resources or configuration failure.\r
@@ -1244,26 +1241,46 @@ Dhcp4InstanceCreateUdpIo (
   )\r
 {\r
   DHCP_SERVICE  *DhcpSb;\r
+  EFI_STATUS    Status;\r
+  VOID          *Udp4;\r
 \r
   ASSERT (Instance->Token != NULL);\r
 \r
   DhcpSb          = Instance->Service;\r
-  Instance->UdpIo = UdpIoCreatePort (DhcpSb->Controller, DhcpSb->Image, Dhcp4InstanceConfigUdpIo, Instance);\r
+  Instance->UdpIo = UdpIoCreateIo (\r
+                      DhcpSb->Controller,\r
+                      DhcpSb->Image,\r
+                      Dhcp4InstanceConfigUdpIo,\r
+                      UDP_IO_UDP4_VERSION,\r
+                      Instance\r
+                      );\r
   if (Instance->UdpIo == NULL) {\r
     return EFI_OUT_OF_RESOURCES;\r
   } else {\r
-    return EFI_SUCCESS;\r
+    Status = gBS->OpenProtocol (\r
+                    Instance->UdpIo->UdpHandle,\r
+                    &gEfiUdp4ProtocolGuid,\r
+                    (VOID **) &Udp4,\r
+                    Instance->Service->Image,\r
+                    Instance->Handle,\r
+                    EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER\r
+                    );\r
+    if (EFI_ERROR (Status)) {\r
+      UdpIoFreeIo (Instance->UdpIo);\r
+      Instance->UdpIo = NULL;\r
+    }\r
+    return Status;\r
   }\r
 }\r
 \r
 /**\r
   Callback of Dhcp packet. Does nothing.\r
-  \r
+\r
   @param Arg           The context.\r
-  \r
-  @return  None.\r
+\r
 **/\r
 VOID\r
+EFIAPI\r
 DhcpDummyExtFree (\r
   IN VOID                   *Arg\r
   )\r
@@ -1272,22 +1289,21 @@ DhcpDummyExtFree (
 \r
 /**\r
   Callback of UdpIoRecvDatagram() that handles a Dhcp4 packet.\r
-  \r
+\r
   Only BOOTP responses will be handled that correspond to the Xid of the request\r
   sent out. The packet will be queued to the response queue.\r
-  \r
+\r
   @param UdpPacket        The Dhcp4 packet.\r
-  @param Points           Udp4 address pair.\r
+  @param EndPoint         Udp4 address pair.\r
   @param IoStatus         Status of the input.\r
   @param Context          Extra info for the input.\r
-  \r
-  @return None.\r
-  \r
+\r
 **/\r
 VOID\r
+EFIAPI\r
 PxeDhcpInput (\r
   NET_BUF                   *UdpPacket,\r
-  UDP_POINTS                *Points,\r
+  UDP_END_POINT             *EndPoint,\r
   EFI_STATUS                IoStatus,\r
   VOID                      *Context\r
   )\r
@@ -1328,12 +1344,13 @@ PxeDhcpInput (
   //\r
   Len  = NET_ROUNDUP (sizeof (EFI_DHCP4_PACKET) + UdpPacket->TotalSize - sizeof (EFI_DHCP4_HEADER), 4);\r
   Wrap = NetbufAlloc (Len);\r
-\r
   if (Wrap == NULL) {\r
     goto RESTART;\r
   }\r
 \r
   Packet         = (EFI_DHCP4_PACKET *) NetbufAllocSpace (Wrap, Len, NET_BUF_TAIL);\r
+  ASSERT (Packet != NULL);\r
+\r
   Packet->Size   = Len;\r
   Head           = &Packet->Dhcp4.Header;\r
   Packet->Length = NetbufCopy (UdpPacket, 0, UdpPacket->TotalSize, (UINT8 *) Head);\r
@@ -1347,7 +1364,7 @@ PxeDhcpInput (
   //\r
   if ((Head->OpCode != BOOTP_REPLY) ||\r
       (Head->Xid != Token->Packet->Dhcp4.Header.Xid) ||\r
-      (CompareMem (DhcpSb->ClientAddressSendOut, Head->ClientHwAddr, Head->HwAddrLen) != 0)) {\r
+      (CompareMem (&Token->Packet->Dhcp4.Header.ClientHwAddr[0], Head->ClientHwAddr, Head->HwAddrLen) != 0)) {\r
     goto RESTART;\r
   }\r
 \r
@@ -1383,10 +1400,8 @@ RESTART:
 \r
 /**\r
   Complete a Dhcp4 transaction and signal the upper layer.\r
-  \r
+\r
   @param Instance      Dhcp4 instance.\r
-  \r
-  @return None.\r
 \r
 **/\r
 VOID\r
@@ -1421,8 +1436,14 @@ SIGNAL_USER:
   // Clean up the resources dedicated for this transmit receive transaction.\r
   //\r
   NetbufQueFlush (&Instance->ResponseQueue);\r
-  UdpIoCleanPort (Instance->UdpIo);\r
-  UdpIoFreePort (Instance->UdpIo);\r
+  UdpIoCleanIo (Instance->UdpIo);\r
+  gBS->CloseProtocol (\r
+         Instance->UdpIo->UdpHandle,\r
+         &gEfiUdp4ProtocolGuid,\r
+         Instance->Service->Image,\r
+         Instance->Handle\r
+         );\r
+  UdpIoFreeIo (Instance->UdpIo);\r
   Instance->UdpIo = NULL;\r
   Instance->Token = NULL;\r
 \r
@@ -1434,13 +1455,13 @@ SIGNAL_USER:
 \r
 /**\r
   Transmits a DHCP formatted packet and optionally waits for responses.\r
-  \r
+\r
   The TransmitReceive() function is used to transmit a DHCP packet and optionally\r
   wait for the response from servers. This function does not change the state of\r
   the EFI DHCPv4 Protocol driver and thus can be used at any time.\r
 \r
-  @param  This    Pointer to the EFI_DHCP4_PROTOCOL instance.\r
-  @param  Token   Pointer to the EFI_DHCP4_TRANSMIT_RECEIVE_TOKEN structure.\r
+  @param[in]  This    Pointer to the EFI_DHCP4_PROTOCOL instance.\r
+  @param[in]  Token   Pointer to the EFI_DHCP4_TRANSMIT_RECEIVE_TOKEN structure.\r
 \r
   @retval EFI_SUCCESS           The packet was successfully queued for transmission.\r
   @retval EFI_INVALID_PARAMETER Some parameter is NULL.\r
@@ -1463,10 +1484,12 @@ EfiDhcp4TransmitReceive (
   EFI_STATUS     Status;\r
   NET_FRAGMENT   Frag;\r
   NET_BUF        *Wrap;\r
-  UDP_POINTS     EndPoint;\r
+  UDP_END_POINT  EndPoint;\r
   IP4_ADDR       Ip;\r
   DHCP_SERVICE   *DhcpSb;\r
-  IP4_ADDR       Gateway;\r
+  EFI_IP_ADDRESS Gateway;\r
+  IP4_ADDR       ClientAddr;\r
+  INTN           Class;\r
   IP4_ADDR       SubnetMask;\r
 \r
   if ((This == NULL) || (Token == NULL) || (Token->Packet == NULL)) {\r
@@ -1475,6 +1498,7 @@ EfiDhcp4TransmitReceive (
 \r
   Instance = DHCP_INSTANCE_FROM_THIS (This);\r
   DhcpSb   = Instance->Service;\r
+  DhcpSb->ActiveChild = Instance;\r
 \r
   if (Instance->Token != NULL) {\r
     //\r
@@ -1498,8 +1522,9 @@ EfiDhcp4TransmitReceive (
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
-  if (DhcpSb->ClientAddr == 0) {\r
-\r
+  ClientAddr = EFI_NTOHL (Token->Packet->Dhcp4.Header.ClientAddr);\r
+  \r
+  if (ClientAddr == 0) {\r
     return EFI_NO_MAPPING;\r
   }\r
 \r
@@ -1540,16 +1565,15 @@ EfiDhcp4TransmitReceive (
   }\r
 \r
   //\r
-  // Set the local address and local port.\r
+  // Set the local address and local port to ZERO.\r
   //\r
-  EndPoint.LocalAddr = 0;\r
-  EndPoint.LocalPort = 0;\r
+  ZeroMem (&EndPoint, sizeof (UDP_END_POINT));\r
 \r
   //\r
   // Set the destination address and destination port.\r
   //\r
   CopyMem (&Ip, &Token->RemoteAddress, sizeof (EFI_IPv4_ADDRESS));\r
-  EndPoint.RemoteAddr = NTOHL (Ip);\r
+  EndPoint.RemoteAddr.Addr[0] = NTOHL (Ip);\r
 \r
   if (Token->RemotePort == 0) {\r
     EndPoint.RemotePort = DHCP_SERVER_PORT;\r
@@ -1560,17 +1584,19 @@ EfiDhcp4TransmitReceive (
   //\r
   // Get the gateway.\r
   //\r
-  SubnetMask = DhcpSb->Netmask;\r
-  Gateway    = 0;\r
-  if (!IP4_NET_EQUAL (DhcpSb->ClientAddr, EndPoint.RemoteAddr, SubnetMask)) {\r
-    CopyMem (&Gateway, &Token->GatewayAddress, sizeof (EFI_IPv4_ADDRESS));\r
-    Gateway = NTOHL (Gateway);\r
+  Class = NetGetIpClass (ClientAddr);\r
+  ASSERT (Class < IP4_ADDR_CLASSE);\r
+  SubnetMask = gIp4AllMasks[Class << 3];\r
+  ZeroMem (&Gateway, sizeof (Gateway));\r
+  if (!IP4_NET_EQUAL (ClientAddr, EndPoint.RemoteAddr.Addr[0], SubnetMask)) {\r
+    CopyMem (&Gateway.v4, &Token->GatewayAddress, sizeof (EFI_IPv4_ADDRESS));\r
+    Gateway.Addr[0] = NTOHL (Gateway.Addr[0]);\r
   }\r
 \r
   //\r
   // Transmit the DHCP packet.\r
   //\r
-  Status = UdpIoSendDatagram (Instance->UdpIo, Wrap, &EndPoint, Gateway, DhcpOnPacketSent, NULL);\r
+  Status = UdpIoSendDatagram (Instance->UdpIo, Wrap, &EndPoint, &Gateway, DhcpOnPacketSent, NULL);\r
   if (EFI_ERROR (Status)) {\r
     NetbufFree (Wrap);\r
     goto ON_ERROR;\r
@@ -1587,8 +1613,14 @@ EfiDhcp4TransmitReceive (
 ON_ERROR:\r
 \r
   if (EFI_ERROR (Status) && (Instance->UdpIo != NULL)) {\r
-    UdpIoCleanPort (Instance->UdpIo);\r
-    UdpIoFreePort (Instance->UdpIo);\r
+    UdpIoCleanIo (Instance->UdpIo);\r
+    gBS->CloseProtocol (\r
+           Instance->UdpIo->UdpHandle,\r
+           &gEfiUdp4ProtocolGuid,\r
+           Instance->Service->Image,\r
+           Instance->Handle\r
+           );\r
+    UdpIoFreeIo (Instance->UdpIo);\r
     Instance->UdpIo = NULL;\r
     Instance->Token = NULL;\r
   }\r
@@ -1600,8 +1632,19 @@ ON_ERROR:
     // Keep polling until timeout if no error happens and the CompletionEvent\r
     // is NULL.\r
     //\r
-    while (Instance->Timeout != 0) {\r
-      Instance->UdpIo->Udp->Poll (Instance->UdpIo->Udp);\r
+    while (TRUE) {\r
+      OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
+      //\r
+      // Raise TPL to protect the UDPIO in instance, in case that DhcpOnTimerTick\r
+      // free it when timeout.\r
+      //\r
+      if (Instance->Timeout > 0) {\r
+        Instance->UdpIo->Protocol.Udp4->Poll (Instance->UdpIo->Protocol.Udp4);\r
+        gBS->RestoreTPL (OldTpl);\r
+      } else {\r
+        gBS->RestoreTPL (OldTpl);\r
+        break;\r
+      }\r
     }\r
   }\r
 \r
@@ -1614,10 +1657,10 @@ ON_ERROR:
   EFI_DHCP4_PACKET_OPTION array in the DHCP_PARSE_CONTEXT to point\r
   the individual DHCP option in the packet.\r
 \r
-  @param  Tag                    The DHCP option type\r
-  @param  Len                    Length of the DHCP option data\r
-  @param  Data                   The DHCP option data\r
-  @param  Context                The context, to pass several parameters in.\r
+  @param[in]  Tag                    The DHCP option type\r
+  @param[in]  Len                    Length of the DHCP option data\r
+  @param[in]  Data                   The DHCP option data\r
+  @param[in]  Context                The context, to pass several parameters in.\r
 \r
   @retval EFI_SUCCESS            It always returns EFI_SUCCESS\r
 \r
@@ -1637,11 +1680,11 @@ Dhcp4ParseCheckOption (
 \r
   if (Parse->Index <= Parse->OptionCount) {\r
     //\r
-    // Use _CR to get the memory position of EFI_DHCP4_PACKET_OPTION for\r
+    // Use BASE_CR to get the memory position of EFI_DHCP4_PACKET_OPTION for\r
     // the EFI_DHCP4_PACKET_OPTION->Data because DhcpIterateOptions only\r
     // pass in the point to option data.\r
     //\r
-    Parse->Option[Parse->Index - 1] = _CR (Data, EFI_DHCP4_PACKET_OPTION, Data);\r
+    Parse->Option[Parse->Index - 1] = BASE_CR (Data, EFI_DHCP4_PACKET_OPTION, Data);\r
   }\r
 \r
   return EFI_SUCCESS;\r
@@ -1650,13 +1693,13 @@ Dhcp4ParseCheckOption (
 \r
 /**\r
   Parses the packed DHCP option data.\r
-  \r
+\r
   The Parse() function is used to retrieve the option list from a DHCP packet.\r
-  If *OptionCount isnt zero, and there is enough space for all the DHCP options\r
+  If *OptionCount isn't zero, and there is enough space for all the DHCP options\r
   in the Packet, each element of PacketOptionList is set to point to somewhere in\r
   the Packet->Dhcp4.Option where a new DHCP option begins. If RFC3396 is supported,\r
   the caller should reassemble the parsed DHCP options to get the finial result.\r
-  If *OptionCount is zero or there isnt enough space for all of them, the number\r
+  If *OptionCount is zero or there isn't enough space for all of them, the number\r
   of DHCP options in the Packet is returned in OptionCount.\r
 \r
   @param  This             Pointer to the EFI_DHCP4_PROTOCOL instance.\r
@@ -1725,3 +1768,19 @@ EfiDhcp4Parse (
 \r
   return EFI_SUCCESS;\r
 }\r
+\r
+/**\r
+  Set the elapsed time based on the given instance and the pointer to the\r
+  elapsed time option.\r
+\r
+  @param[in]      Elapsed       The pointer to the position to append.\r
+  @param[in]      Instance      The pointer to the Dhcp4 instance.\r
+**/\r
+VOID\r
+SetElapsedTime (\r
+  IN     UINT16                 *Elapsed,\r
+  IN     DHCP_PROTOCOL          *Instance\r
+  )\r
+{\r
+  WriteUnaligned16 (Elapsed, HTONS(Instance->ElaspedTime));\r
+}\r