X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=MdeModulePkg%2FUniversal%2FNetwork%2FMtftp4Dxe%2FMtftp4Impl.c;h=54384e143e2d290668c2d6687a7bc63d38309389;hb=29788f178e48fa5ffe7d3262d73c9548e9285d2d;hp=3d92ba3dd172c4974737f3dabf1f747075f5e5ac;hpb=766c7483c335931b190a78d78d62e5a5e69dc8b9;p=mirror_edk2.git diff --git a/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Impl.c b/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Impl.c index 3d92ba3dd1..54384e143e 100644 --- a/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Impl.c +++ b/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Impl.c @@ -1,8 +1,9 @@ /** @file Interface routine for Mtftp4. -Copyright (c) 2006 - 2009, Intel Corporation
-All rights reserved. This program and the accompanying materials +(C) Copyright 2014 Hewlett-Packard Development Company, L.P.
+Copyright (c) 2006 - 2017, 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
@@ -58,6 +59,12 @@ Mtftp4CleanOperation ( } if (Instance->McastUdpPort != NULL) { + gBS->CloseProtocol ( + Instance->McastUdpPort->UdpHandle, + &gEfiUdp4ProtocolGuid, + gMtftp4DriverBinding.DriverBindingHandle, + Instance->Handle + ); UdpIoFreeIo (Instance->McastUdpPort); Instance->McastUdpPort = NULL; } @@ -114,6 +121,7 @@ Mtftp4GetInfoCheckPacket ( MTFTP4_GETINFO_STATE *State; EFI_STATUS Status; UINT16 OpCode; + EFI_MTFTP4_ERROR_HEADER *ErrorHeader; State = (MTFTP4_GETINFO_STATE *) Token->Context; OpCode = NTOHS (Packet->OpCode); @@ -123,6 +131,12 @@ Mtftp4GetInfoCheckPacket ( // switch (OpCode) { case EFI_MTFTP4_OPCODE_ERROR: + ErrorHeader = (EFI_MTFTP4_ERROR_HEADER *) Packet; + if (ErrorHeader->ErrorCode == EFI_MTFTP4_ERRORCODE_FILE_NOT_FOUND) { + DEBUG ((EFI_D_ERROR, "TFTP error code 1 (File Not Found)\n")); + } else { + DEBUG ((EFI_D_ERROR, "TFTP error code %d\n", ErrorHeader->ErrorCode)); + } State->Status = EFI_TFTP_ERROR; break; @@ -178,7 +192,7 @@ Mtftp4OverrideValid ( IP4_ADDR Gateway; CopyMem (&Ip, &Override->ServerIp, sizeof (IP4_ADDR)); - if (!NetIp4IsUnicast (NTOHL (Ip), 0)) { + if (IP4_IS_UNSPECIFIED (NTOHL (Ip)) || IP4_IS_LOCAL_BROADCAST (NTOHL (Ip))) { return FALSE; } @@ -194,7 +208,7 @@ Mtftp4OverrideValid ( Netmask = NTOHL (Netmask); Ip = NTOHL (Ip); - if (!NetIp4IsUnicast (Gateway, Netmask) || !IP4_NET_EQUAL (Gateway, Ip, Netmask)) { + if ((Netmask != 0 && !NetIp4IsUnicast (Gateway, Netmask)) || !IP4_NET_EQUAL (Gateway, Ip, Netmask)) { return FALSE; } } @@ -244,7 +258,7 @@ Mtftp4GetMapping ( return FALSE; } - while (!EFI_ERROR (gBS->CheckEvent (Service->TimerToGetMap))) { + while (EFI_ERROR (gBS->CheckEvent (Service->TimerToGetMap))) { Udp->Poll (Udp); if (!EFI_ERROR (Udp->GetModeData (Udp, NULL, &Ip4Mode, NULL, NULL)) && @@ -292,13 +306,13 @@ Mtftp4ConfigUnicastPort ( UdpConfig.ReceiveTimeout = 0; UdpConfig.TransmitTimeout = 0; UdpConfig.UseDefaultAddress = Config->UseDefaultSetting; - UdpConfig.StationAddress = Config->StationIp; - UdpConfig.SubnetMask = Config->SubnetMask; + IP4_COPY_ADDRESS (&UdpConfig.StationAddress, &Config->StationIp); + IP4_COPY_ADDRESS (&UdpConfig.SubnetMask, &Config->SubnetMask); UdpConfig.StationPort = 0; UdpConfig.RemotePort = 0; Ip = HTONL (Instance->ServerIp); - CopyMem (&UdpConfig.RemoteAddress, &Ip, sizeof (EFI_IPv4_ADDRESS)); + IP4_COPY_ADDRESS (&UdpConfig.RemoteAddress, &Ip); Status = UdpIo->Protocol.Udp4->Configure (UdpIo->Protocol.Udp4, &UdpConfig); @@ -653,18 +667,18 @@ EfiMtftp4Configure ( Gateway = NTOHL (Gateway); ServerIp = NTOHL (ServerIp); - if (!NetIp4IsUnicast (ServerIp, 0)) { + if (ServerIp == 0 || IP4_IS_LOCAL_BROADCAST (ServerIp)) { return EFI_INVALID_PARAMETER; } if (!ConfigData->UseDefaultSetting && - ((!IP4_IS_VALID_NETMASK (Netmask) || !NetIp4IsUnicast (Ip, Netmask)))) { + ((!IP4_IS_VALID_NETMASK (Netmask) || (Netmask != 0 && !NetIp4IsUnicast (Ip, Netmask))))) { return EFI_INVALID_PARAMETER; } - if ((Gateway != 0) && - (!IP4_NET_EQUAL (Gateway, Ip, Netmask) || !NetIp4IsUnicast (Gateway, Netmask))) { + if ((Gateway != 0) && + (!IP4_NET_EQUAL (Gateway, Ip, Netmask) || (Netmask != 0 && !NetIp4IsUnicast (Gateway, Netmask)))) { return EFI_INVALID_PARAMETER; } @@ -776,6 +790,7 @@ EfiMtftp4ParseOptions ( @retval EFI_TIMEOUT No responses were received from the MTFTPv4 server. @retval EFI_TFTP_ERROR An MTFTPv4 ERROR packet was received. @retval EFI_DEVICE_ERROR An unexpected network error or system error occurred. + @retval EFI_NO_MEDIA There was a media error. **/ EFI_STATUS @@ -935,8 +950,8 @@ EfiMtftp4ReadDirectory ( parameters. If NULL, the default parameters that were set in the EFI_MTFTP4_PROTOCOL.Configure() function are used - @param Filename Pointer to ASCIIZ file name string - @param ModeStr Pointer to ASCIIZ mode string. If NULL, "octet" + @param Filename Pointer to null-terminated ASCII file name string + @param ModeStr Pointer to null-terminated ASCII mode string. If NULL, "octet" will be used @param OptionCount Number of option/value string pairs in OptionList @param OptionList Pointer to array of option/value string pairs. @@ -971,7 +986,8 @@ EfiMtftp4ReadDirectory ( in the Buffer. @retval EFI_TIMEOUT No responses were received from the MTFTPv4 server. @retval EFI_DEVICE_ERROR An unexpected network error or system error occurred. - + @retval EFI_NO_MEDIA There was a media error. + **/ EFI_STATUS EFIAPI @@ -1071,7 +1087,7 @@ EfiMtftp4Poll ( if (Instance->State == MTFTP4_STATE_UNCONFIGED) { return EFI_NOT_STARTED; - } else if (Instance->State == MTFTP4_STATE_DESTORY) { + } else if (Instance->State == MTFTP4_STATE_DESTROY) { return EFI_DEVICE_ERROR; }