X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=MdeModulePkg%2FUniversal%2FNetwork%2FDhcp4Dxe%2FDhcp4Impl.c;h=41b5e9599775c54c6db7e71d0a3356c978fdc475;hp=e8e127da480ca8c04512dd408d7d3ae127b0052a;hb=216f79703b8cb8dc65abdd768bedb2bcdbc1a1f8;hpb=ae0a0b06af78f698df71b18a1defb5aece2f21b4 diff --git a/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Impl.c b/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Impl.c index e8e127da48..41b5e95997 100644 --- a/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Impl.c +++ b/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Impl.c @@ -1,7 +1,7 @@ /** @file This file implement the EFI_DHCP4_PROTOCOL interface. -Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -467,7 +467,7 @@ DhcpCopyConfigure ( { EFI_DHCP4_PACKET_OPTION **DstOptions; EFI_DHCP4_PACKET_OPTION **SrcOptions; - INTN Len; + UINTN Len; UINT32 Index; CopyMem (Dst, Src, sizeof (*Dst)); @@ -932,6 +932,12 @@ EfiDhcp4RenewRebind ( DhcpSetState (DhcpSb, Dhcp4Rebinding, FALSE); } + // + // Clear initial time to make sure that elapsed-time + // is set to 0 for first REQUEST in renewal process. + // + Instance->ElaspedTime = 0; + Status = DhcpSendMessage ( DhcpSb, DhcpSb->Selected, @@ -1228,6 +1234,8 @@ Dhcp4InstanceCreateUdpIo ( ) { DHCP_SERVICE *DhcpSb; + EFI_STATUS Status; + VOID *Udp4; ASSERT (Instance->Token != NULL); @@ -1242,7 +1250,19 @@ Dhcp4InstanceCreateUdpIo ( if (Instance->UdpIo == NULL) { return EFI_OUT_OF_RESOURCES; } else { - return EFI_SUCCESS; + Status = gBS->OpenProtocol ( + Instance->UdpIo->UdpHandle, + &gEfiUdp4ProtocolGuid, + (VOID **) &Udp4, + Instance->Service->Image, + Instance->Handle, + EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER + ); + if (EFI_ERROR (Status)) { + UdpIoFreeIo (Instance->UdpIo); + Instance->UdpIo = NULL; + } + return Status; } } @@ -1410,6 +1430,12 @@ SIGNAL_USER: // NetbufQueFlush (&Instance->ResponseQueue); UdpIoCleanIo (Instance->UdpIo); + gBS->CloseProtocol ( + Instance->UdpIo->UdpHandle, + &gEfiUdp4ProtocolGuid, + Instance->Service->Image, + Instance->Handle + ); UdpIoFreeIo (Instance->UdpIo); Instance->UdpIo = NULL; Instance->Token = NULL; @@ -1575,6 +1601,12 @@ ON_ERROR: if (EFI_ERROR (Status) && (Instance->UdpIo != NULL)) { UdpIoCleanIo (Instance->UdpIo); + gBS->CloseProtocol ( + Instance->UdpIo->UdpHandle, + &gEfiUdp4ProtocolGuid, + Instance->Service->Image, + Instance->Handle + ); UdpIoFreeIo (Instance->UdpIo); Instance->UdpIo = NULL; Instance->Token = NULL; @@ -1723,3 +1755,19 @@ EfiDhcp4Parse ( return EFI_SUCCESS; } + +/** + Set the elapsed time based on the given instance and the pointer to the + elapsed time option. + + @param[in] Elapsed The pointer to the position to append. + @param[in] Instance The pointer to the Dhcp4 instance. +**/ +VOID +SetElapsedTime ( + IN UINT16 *Elapsed, + IN DHCP_PROTOCOL *Instance + ) +{ + WriteUnaligned16 (Elapsed, HTONS(Instance->ElaspedTime)); +}