X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;ds=sidebyside;f=MdeModulePkg%2FUniversal%2FNetwork%2FDhcp4Dxe%2FDhcp4Io.c;h=4728b94c5803110d05bb2209032ef28643183841;hb=c0fd7f734e2d33e22215899b40a47b843129541d;hp=037d1cc39e7cdbe3813512d1cfa2a882c5a90aa9;hpb=ac6c3d90edebf1499dac8f4d3c99e94d197ad45e;p=mirror_edk2.git diff --git a/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Io.c b/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Io.c index 037d1cc39e..4728b94c58 100644 --- a/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Io.c +++ b/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Io.c @@ -1,14 +1,8 @@ /** @file EFI DHCP protocol implementation. - -Copyright (c) 2006 - 2016, 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 -http://opensource.org/licenses/bsd-license.php -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent **/ @@ -41,7 +35,7 @@ DhcpInitRequest ( // Clear initial time to make sure that elapsed-time is set to 0 for first Discover or REQUEST message. // DhcpSb->ActiveChild->ElaspedTime= 0; - + if (DhcpSb->DhcpState == Dhcp4Init) { DhcpSetState (DhcpSb, Dhcp4Selecting, FALSE); Status = DhcpSendMessage (DhcpSb, NULL, NULL, DHCP_MSG_DISCOVER, NULL); @@ -393,8 +387,6 @@ DhcpLeaseAcquired ( IN OUT DHCP_SERVICE *DhcpSb ) { - INTN Class; - DhcpSb->ClientAddr = EFI_NTOHL (DhcpSb->Selected->Dhcp4.Header.YourAddr); if (DhcpSb->Para != NULL) { @@ -403,9 +395,7 @@ DhcpLeaseAcquired ( } if (DhcpSb->Netmask == 0) { - Class = NetGetIpClass (DhcpSb->ClientAddr); - ASSERT (Class < IP4_ADDR_CLASSE); - DhcpSb->Netmask = gIp4AllMasks[Class << 3]; + return EFI_ABORTED; } if (DhcpSb->LeaseIoPort != NULL) { @@ -1100,23 +1090,6 @@ RESTART: } } - -/** - Release the packet. - - @param[in] Arg The packet to release - -**/ -VOID -EFIAPI -DhcpReleasePacket ( - IN VOID *Arg - ) -{ - FreePool (Arg); -} - - /** Release the net buffer when packet is sent. @@ -1363,13 +1336,12 @@ DhcpSendMessage ( Packet->Dhcp4.Header.HwAddrLen ); - // // Wrap it into a netbuf then send it. // Frag.Bulk = (UINT8 *) &Packet->Dhcp4.Header; Frag.Len = Packet->Length; - Wrap = NetbufFromExt (&Frag, 1, 0, 0, DhcpReleasePacket, Packet); + Wrap = NetbufFromExt (&Frag, 1, 0, 0, DhcpDummyExtFree, NULL); if (Wrap == NULL) { FreePool (Packet); @@ -1403,19 +1375,18 @@ DhcpSendMessage ( } ASSERT (UdpIo != NULL); - NET_GET_REF (Wrap); - + Status = UdpIoSendDatagram ( - UdpIo, - Wrap, - &EndPoint, - NULL, - DhcpOnPacketSent, + UdpIo, + Wrap, + &EndPoint, + NULL, + DhcpOnPacketSent, DhcpSb ); if (EFI_ERROR (Status)) { - NET_PUT_REF (Wrap); + NetbufFree (Wrap); return EFI_ACCESS_DENIED; } @@ -1458,12 +1429,12 @@ DhcpRetransmit ( // Frag.Bulk = (UINT8 *) &DhcpSb->LastPacket->Dhcp4.Header; Frag.Len = DhcpSb->LastPacket->Length; - Wrap = NetbufFromExt (&Frag, 1, 0, 0, DhcpReleasePacket, DhcpSb->LastPacket); + Wrap = NetbufFromExt (&Frag, 1, 0, 0, DhcpDummyExtFree, NULL); if (Wrap == NULL) { return EFI_OUT_OF_RESOURCES; } - + // // Broadcast the message, unless we know the server address. // @@ -1481,7 +1452,6 @@ DhcpRetransmit ( ASSERT (UdpIo != NULL); - NET_GET_REF (Wrap); Status = UdpIoSendDatagram ( UdpIo, Wrap, @@ -1492,7 +1462,7 @@ DhcpRetransmit ( ); if (EFI_ERROR (Status)) { - NET_PUT_REF (Wrap); + NetbufFree (Wrap); return EFI_ACCESS_DENIED; } @@ -1533,7 +1503,7 @@ DhcpOnTimerTick ( if (Instance != NULL && Instance->ElaspedTime < 0xffff) { Instance->ElaspedTime++; } - + // // Check the retransmit timer // @@ -1555,7 +1525,7 @@ DhcpOnTimerTick ( goto ON_EXIT; } } - + if (++DhcpSb->CurRetry < DhcpSb->MaxRetries) { // // Still has another try @@ -1594,7 +1564,7 @@ DhcpOnTimerTick ( goto END_SESSION; } } - + // // If an address has been acquired, check whether need to // refresh or whether it has expired. @@ -1626,8 +1596,8 @@ DhcpOnTimerTick ( if (Instance != NULL) { Instance->ElaspedTime= 0; - } - + } + Status = DhcpSendMessage ( DhcpSb, DhcpSb->Selected, @@ -1650,7 +1620,7 @@ DhcpOnTimerTick ( if (Instance != NULL) { Instance->ElaspedTime= 0; - } + } Status = DhcpSendMessage ( DhcpSb, @@ -1672,12 +1642,9 @@ ON_EXIT: // NET_LIST_FOR_EACH_SAFE (Entry, Next, &DhcpSb->Children) { Instance = NET_LIST_USER_STRUCT (Entry, DHCP_PROTOCOL, Link); - - if ((Instance != NULL) && (Instance->Token != NULL)) { - Instance->Timeout--; - if (Instance->Timeout == 0) { - PxeDhcpDone (Instance); - } + Instance->Timeout--; + if (Instance->Timeout == 0 && Instance->Token != NULL) { + PxeDhcpDone (Instance); } }