X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=MdeModulePkg%2FUniversal%2FNetwork%2FMtftp4Dxe%2FMtftp4Impl.c;h=70bd693e4e3a6f172a543421a850e10cf5bebd1d;hp=f3a49523601be666d1fac39e043a7f0a7b2f6cee;hb=c0fd7f734e2d33e22215899b40a47b843129541d;hpb=216f79703b8cb8dc65abdd768bedb2bcdbc1a1f8 diff --git a/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Impl.c b/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Impl.c index f3a4952360..70bd693e4e 100644 --- a/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Impl.c +++ b/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Impl.c @@ -1,14 +1,9 @@ /** @file Interface routine for Mtftp4. - -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 -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. +(C) Copyright 2014 Hewlett-Packard Development Company, L.P.
+Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent **/ @@ -79,6 +74,9 @@ Mtftp4CleanOperation ( Instance->Operation = 0; Instance->BlkSize = MTFTP4_DEFAULT_BLKSIZE; + Instance->WindowSize = 1; + Instance->TotalBlock = 0; + Instance->AckedBlock = 0; Instance->LastBlock = 0; Instance->ServerIp = 0; Instance->ListeningPort = 0; @@ -95,9 +93,9 @@ Mtftp4CleanOperation ( /** - Check packet for GetInfo. - - GetInfo is implemented with EfiMtftp4ReadFile. It use Mtftp4GetInfoCheckPacket + Check packet for GetInfo. + + GetInfo is implemented with EfiMtftp4ReadFile. It use Mtftp4GetInfoCheckPacket to inspect the first packet from server, then abort the session. @param This The MTFTP4 protocol instance @@ -120,6 +118,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); @@ -129,6 +128,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; @@ -159,10 +164,10 @@ Mtftp4GetInfoCheckPacket ( /** - Check whether the override data is valid. - + Check whether the override data is valid. + It will first validate whether the server is a valid unicast. If a gateway - is provided in the Override, it also check that it is a unicast on the + is provided in the Override, it also check that it is a unicast on the connected network. @param Instance The MTFTP instance @@ -170,7 +175,7 @@ Mtftp4GetInfoCheckPacket ( @retval TRUE The override data is valid @retval FALSE The override data is invalid - + **/ BOOLEAN Mtftp4OverrideValid ( @@ -184,7 +189,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; } @@ -200,7 +205,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; } } @@ -211,9 +216,9 @@ Mtftp4OverrideValid ( /** Poll the UDP to get the IP4 default address, which may be retrieved - by DHCP. - - The default time out value is 5 seconds. If IP has retrieved the default address, + by DHCP. + + The default time out value is 5 seconds. If IP has retrieved the default address, the UDP is reconfigured. @param Instance The Mtftp instance @@ -250,7 +255,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)) && @@ -298,13 +303,13 @@ Mtftp4ConfigUnicastPort ( UdpConfig.ReceiveTimeout = 0; UdpConfig.TransmitTimeout = 0; UdpConfig.UseDefaultAddress = Config->UseDefaultSetting; - UdpConfig.StationAddress = Config->StationIp; - UdpConfig.SubnetMask = Config->SubnetMask; - UdpConfig.StationPort = 0; + IP4_COPY_ADDRESS (&UdpConfig.StationAddress, &Config->StationIp); + IP4_COPY_ADDRESS (&UdpConfig.SubnetMask, &Config->SubnetMask); + UdpConfig.StationPort = Config->LocalPort; 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); @@ -358,6 +363,7 @@ Mtftp4Start ( EFI_MTFTP4_CONFIG_DATA *Config; EFI_TPL OldTpl; EFI_STATUS Status; + EFI_STATUS TokenStatus; // // Validate the parameters @@ -385,7 +391,9 @@ Mtftp4Start ( Instance = MTFTP4_PROTOCOL_FROM_THIS (This); - Status = EFI_SUCCESS; + Status = EFI_SUCCESS; + TokenStatus = EFI_SUCCESS; + OldTpl = gBS->RaiseTPL (TPL_CALLBACK); if (Instance->State != MTFTP4_STATE_CONFIGED) { @@ -396,6 +404,10 @@ Mtftp4Start ( Status = EFI_ACCESS_DENIED; } + if ((Token->OverrideData != NULL) && !Mtftp4OverrideValid (Instance, Token->OverrideData)) { + Status = EFI_INVALID_PARAMETER; + } + if (EFI_ERROR (Status)) { gBS->RestoreTPL (OldTpl); return Status; @@ -408,20 +420,17 @@ Mtftp4Start ( Instance->Operation = Operation; Override = Token->OverrideData; - if ((Override != NULL) && !Mtftp4OverrideValid (Instance, Override)) { - Status = EFI_INVALID_PARAMETER; - goto ON_ERROR; - } - if (Token->OptionCount != 0) { Status = Mtftp4ParseOption ( Token->OptionList, Token->OptionCount, TRUE, + Instance->Operation, &Instance->RequestOption ); if (EFI_ERROR (Status)) { + TokenStatus = EFI_DEVICE_ERROR; goto ON_ERROR; } } @@ -432,6 +441,7 @@ Mtftp4Start ( Config = &Instance->Config; Instance->Token = Token; Instance->BlkSize = MTFTP4_DEFAULT_BLKSIZE; + Instance->WindowSize = MTFTP4_DEFAULT_WINDOWSIZE; CopyMem (&Instance->ServerIp, &Config->ServerIp, sizeof (IP4_ADDR)); Instance->ServerIp = NTOHL (Instance->ServerIp); @@ -474,8 +484,8 @@ Mtftp4Start ( // Config the unicast UDP child to send initial request // Status = Mtftp4ConfigUnicastPort (Instance->UnicastPort, Instance); - if (EFI_ERROR (Status)) { + TokenStatus = EFI_DEVICE_ERROR; goto ON_ERROR; } @@ -493,12 +503,13 @@ Mtftp4Start ( Status = Mtftp4RrqStart (Instance, Operation); } - gBS->RestoreTPL (OldTpl); - if (EFI_ERROR (Status)) { + TokenStatus = EFI_DEVICE_ERROR; goto ON_ERROR; } + gBS->RestoreTPL(OldTpl); + if (Token->Event != NULL) { return EFI_SUCCESS; } @@ -514,7 +525,7 @@ Mtftp4Start ( return Token->Status; ON_ERROR: - Mtftp4CleanOperation (Instance, Status); + Mtftp4CleanOperation (Instance, TokenStatus); gBS->RestoreTPL (OldTpl); return Status; @@ -524,17 +535,17 @@ ON_ERROR: /** Reads the current operational settings. - The GetModeData()function reads the current operational settings of this + The GetModeData()function reads the current operational settings of this EFI MTFTPv4 Protocol driver instance. @param This Pointer to the EFI_MTFTP4_PROTOCOL instance. @param ModeData Pointer to storage for the EFI MTFTPv4 Protocol - driver mode data. + driver mode data. @retval EFI_SUCCESS The configuration data was successfully returned. @retval EFI_OUT_OF_RESOURCES The required mode data could not be allocated. @retval EFI_INVALID_PARAMETER This is NULL or ModeData is NULL. - + **/ EFI_STATUS EFIAPI @@ -567,49 +578,49 @@ EfiMtftp4GetModeData ( /** - Initializes, changes, or resets the default operational setting for this + Initializes, changes, or resets the default operational setting for this EFI MTFTPv4 Protocol driver instance. - - The Configure() function is used to set and change the configuration data for - this EFI MTFTPv4 Protocol driver instance. The configuration data can be reset - to startup defaults by calling Configure() with MtftpConfigData set to NULL. - Whenever the instance is reset, any pending operation is aborted. By changing - the EFI MTFTPv4 Protocol driver instance configuration data, the client can - connect to different MTFTPv4 servers. The configuration parameters in - MtftpConfigData are used as the default parameters in later MTFTPv4 operations + + The Configure() function is used to set and change the configuration data for + this EFI MTFTPv4 Protocol driver instance. The configuration data can be reset + to startup defaults by calling Configure() with MtftpConfigData set to NULL. + Whenever the instance is reset, any pending operation is aborted. By changing + the EFI MTFTPv4 Protocol driver instance configuration data, the client can + connect to different MTFTPv4 servers. The configuration parameters in + MtftpConfigData are used as the default parameters in later MTFTPv4 operations and can be overridden in later operations. - + @param This Pointer to the EFI_MTFTP4_PROTOCOL instance - @param ConfigData MtftpConfigDataPointer to the configuration data + @param ConfigData MtftpConfigDataPointer to the configuration data structure - @retval EFI_SUCCESS The EFI MTFTPv4 Protocol driver was configured + @retval EFI_SUCCESS The EFI MTFTPv4 Protocol driver was configured successfully. @retval EFI_INVALID_PARAMETER One or more following conditions are TRUE: 1.This is NULL. - 2.MtftpConfigData.UseDefaultSetting is FALSE and - MtftpConfigData.StationIp is not a valid IPv4 + 2.MtftpConfigData.UseDefaultSetting is FALSE and + MtftpConfigData.StationIp is not a valid IPv4 unicast address. - 3.MtftpCofigData.UseDefaultSetting is FALSE and + 3.MtftpCofigData.UseDefaultSetting is FALSE and MtftpConfigData.SubnetMask is invalid. - 4.MtftpCofigData.ServerIp is not a valid IPv4 + 4.MtftpCofigData.ServerIp is not a valid IPv4 unicast address. - 5.MtftpConfigData.UseDefaultSetting is FALSE and - MtftpConfigData.GatewayIp is not a valid IPv4 - unicast address or is not in the same subnet + 5.MtftpConfigData.UseDefaultSetting is FALSE and + MtftpConfigData.GatewayIp is not a valid IPv4 + unicast address or is not in the same subnet with station address. - @retval EFI_ACCESS_DENIED The EFI configuration could not be changed at this - time because there is one MTFTP background operation + @retval EFI_ACCESS_DENIED The EFI configuration could not be changed at this + time because there is one MTFTP background operation in progress. - @retval EFI_NO_MAPPING When using a default address, configuration + @retval EFI_NO_MAPPING When using a default address, configuration (DHCP, BOOTP, RARP, etc.) has not finished yet. - @retval EFI_UNSUPPORTED A configuration protocol (DHCP, BOOTP, RARP, etc.) - could not be located when clients choose to use + @retval EFI_UNSUPPORTED A configuration protocol (DHCP, BOOTP, RARP, etc.) + could not be located when clients choose to use the default address settings. - @retval EFI_OUT_OF_RESOURCES The EFI MTFTPv4 Protocol driver instance data could + @retval EFI_OUT_OF_RESOURCES The EFI MTFTPv4 Protocol driver instance data could not be allocated. - @retval EFI_DEVICE_ERROR An unexpected system or network error occurred. - The EFI MTFTPv4 Protocol driver instance is not + @retval EFI_DEVICE_ERROR An unexpected system or network error occurred. + The EFI MTFTPv4 Protocol driver instance is not configured. **/ @@ -659,18 +670,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))) { + ((Netmask != 0xFFFFFFFF && !IP4_NET_EQUAL (Gateway, Ip, Netmask)) || (Netmask != 0 && !NetIp4IsUnicast (Gateway, Netmask)))) { return EFI_INVALID_PARAMETER; } @@ -695,21 +706,21 @@ EfiMtftp4Configure ( /** Parses the options in an MTFTPv4 OACK packet. - - The ParseOptions() function parses the option fields in an MTFTPv4 OACK packet - and returns the number of options that were found and optionally a list of + + The ParseOptions() function parses the option fields in an MTFTPv4 OACK packet + and returns the number of options that were found and optionally a list of pointers to the options in the packet. - If one or more of the option fields are not valid, then EFI_PROTOCOL_ERROR is + If one or more of the option fields are not valid, then EFI_PROTOCOL_ERROR is returned and *OptionCount and *OptionList stop at the last valid option. The OptionList is allocated by this function, and caller should free it when used. @param This Pointer to the EFI_MTFTP4_PROTOCOL instance. @param PacketLen Length of the OACK packet to be parsed. - @param Packet Pointer to the OACK packet to be parsed. + @param Packet Pointer to the OACK packet to be parsed. @param OptionCount Pointer to the number of options in following OptionList. - @param OptionList Pointer to EFI_MTFTP4_OPTION storage. Call the + @param OptionList Pointer to EFI_MTFTP4_OPTION storage. Call the EFI Boot Service FreePool() to release theOptionList - if the options in this OptionList are not needed + if the options in this OptionList are not needed any more @retval EFI_SUCCESS The OACK packet was valid and the OptionCount and @@ -757,25 +768,25 @@ EfiMtftp4ParseOptions ( /** Downloads a file from an MTFTPv4 server. - - The ReadFile() function is used to initialize and start an MTFTPv4 download - process and optionally wait for completion. When the download operation completes, - whether successfully or not, the Token.Status field is updated by the EFI MTFTPv4 + + The ReadFile() function is used to initialize and start an MTFTPv4 download + process and optionally wait for completion. When the download operation completes, + whether successfully or not, the Token.Status field is updated by the EFI MTFTPv4 Protocol driver and then Token.Event is signaled (if it is not NULL). Data can be downloaded from the MTFTPv4 server into either of the following locations: 1.A fixed buffer that is pointed to by Token.Buffer 2.A download service function that is pointed to by Token.CheckPacket - If both Token.Buffer and Token.CheckPacket are used, then Token.CheckPacket - will be called first. If the call is successful, the packet will be stored in + If both Token.Buffer and Token.CheckPacket are used, then Token.CheckPacket + will be called first. If the call is successful, the packet will be stored in Token.Buffer. @param This Pointer to the EFI_MTFTP4_PROTOCOL instance - @param Token Pointer to the token structure to provide the + @param Token Pointer to the token structure to provide the parameters that are used in this operation. @retval EFI_SUCCESS The data file has been transferred successfully. @retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated. - @retval EFI_BUFFER_TOO_SMALL BufferSize is not large enough to hold the downloaded + @retval EFI_BUFFER_TOO_SMALL BufferSize is not large enough to hold the downloaded data in downloading process. @retval EFI_ABORTED Current operation is aborted by user. @retval EFI_ICMP_ERROR An ICMP ERROR packet was received. @@ -799,24 +810,24 @@ EfiMtftp4ReadFile ( /** Sends a data file to an MTFTPv4 server. May be unsupported in some EFI implementations - The WriteFile() function is used to initialize an uploading operation with the - given option list and optionally wait for completion. If one or more of the - options is not supported by the server, the unsupported options are ignored and - a standard TFTP process starts instead. When the upload process completes, - whether successfully or not, Token.Event is signaled, and the EFI MTFTPv4 Protocol + The WriteFile() function is used to initialize an uploading operation with the + given option list and optionally wait for completion. If one or more of the + options is not supported by the server, the unsupported options are ignored and + a standard TFTP process starts instead. When the upload process completes, + whether successfully or not, Token.Event is signaled, and the EFI MTFTPv4 Protocol driver updates Token.Status. The caller can supply the data to be uploaded in the following two modes: 1.Through the user-provided buffer 2.Through a callback function With the user-provided buffer, the Token.BufferSize field indicates the length - of the buffer, and the driver will upload the data in the buffer. With an - EFI_MTFTP4_PACKET_NEEDED callback function, the driver will call this callback - function to get more data from the user to upload. See the definition of - EFI_MTFTP4_PACKET_NEEDED for more information. These two modes cannot be used at + of the buffer, and the driver will upload the data in the buffer. With an + EFI_MTFTP4_PACKET_NEEDED callback function, the driver will call this callback + function to get more data from the user to upload. See the definition of + EFI_MTFTP4_PACKET_NEEDED for more information. These two modes cannot be used at the same time. The callback function will be ignored if the user provides the buffer. @param This Pointer to the EFI_MTFTP4_PROTOCOL instance. - @param Token Pointer to the token structure to provide the + @param Token Pointer to the token structure to provide the parameters that are used in this function @retval EFI_SUCCESS The upload session has started. @@ -831,15 +842,15 @@ EfiMtftp4ReadFile ( format. 6. Token.Buffer and Token.PacketNeeded are both NULL. - 7. One or more IPv4 addresses in Token.OverrideData - are not valid unicast IPv4 addresses if + 7. One or more IPv4 addresses in Token.OverrideData + are not valid unicast IPv4 addresses if Token.OverrideData is not NULL. @retval EFI_UNSUPPORTED One or more options in the Token.OptionList are in the unsupported list of structure EFI_MTFTP4_MODE_DATA. @retval EFI_NOT_STARTED The EFI MTFTPv4 Protocol driver has not been started. - @retval EFI_NO_MAPPING When using a default address, configuration (DHCP, + @retval EFI_NO_MAPPING When using a default address, configuration (DHCP, BOOTP, RARP, etc.) is not finished yet. - @retval EFI_ALREADY_STARTED This Token is already being used in another MTFTPv4 + @retval EFI_ALREADY_STARTED This Token is already being used in another MTFTPv4 session. @retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated. @retval EFI_ACCESS_DENIED The previous operation has not completed yet. @@ -858,35 +869,35 @@ EfiMtftp4WriteFile ( /** - Downloads a data file "directory" from an MTFTPv4 server. + Downloads a data file "directory" from an MTFTPv4 server. May be unsupported in some EFI implementations - - The ReadDirectory() function is used to return a list of files on the MTFTPv4 - server that are logically (or operationally) related to Token.Filename. The - directory request packet that is sent to the server is built with the option + + The ReadDirectory() function is used to return a list of files on the MTFTPv4 + server that are logically (or operationally) related to Token.Filename. The + directory request packet that is sent to the server is built with the option list that was provided by caller, if present. - The file information that the server returns is put into either of the following + The file information that the server returns is put into either of the following locations: 1.A fixed buffer that is pointed to by Token.Buffer 2.A download service function that is pointed to by Token.CheckPacket - If both Token.Buffer and Token.CheckPacket are used, then Token.CheckPacket will + If both Token.Buffer and Token.CheckPacket are used, then Token.CheckPacket will be called first. If the call is successful, the packet will be stored in Token.Buffer. - The returned directory listing in the Token.Buffer or EFI_MTFTP4_PACKET consists - of a list of two or three variable-length ASCII strings, each terminated by a - null character, for each file in the directory. If the multicast option is involved, - the first field of each directory entry is the static multicast IP address and - UDP port number that is associated with the file name. The format of the field - is ip:ip:ip:ip:port. If the multicast option is not involved, this field and its + The returned directory listing in the Token.Buffer or EFI_MTFTP4_PACKET consists + of a list of two or three variable-length ASCII strings, each terminated by a + null character, for each file in the directory. If the multicast option is involved, + the first field of each directory entry is the static multicast IP address and + UDP port number that is associated with the file name. The format of the field + is ip:ip:ip:ip:port. If the multicast option is not involved, this field and its terminating null character are not present. - The next field of each directory entry is the file name and the last field is - the file information string. The information string contains the file size and - the create/modify timestamp. The format of the information string is filesize - yyyy-mm-dd hh:mm:ss:ffff. The timestamp is Coordinated Universal Time + The next field of each directory entry is the file name and the last field is + the file information string. The information string contains the file size and + the create/modify timestamp. The format of the information string is filesize + yyyy-mm-dd hh:mm:ss:ffff. The timestamp is Coordinated Universal Time (UTC; also known as Greenwich Mean Time [GMT]). The only difference between ReadFile and ReadDirectory is the opcode used. @param This Pointer to the EFI_MTFTP4_PROTOCOL instance - @param Token Pointer to the token structure to provide the + @param Token Pointer to the token structure to provide the parameters that are used in this function @retval EFI_SUCCESS The MTFTPv4 related file "directory" has been downloaded. @@ -901,15 +912,15 @@ EfiMtftp4WriteFile ( format. 6. Token.Buffer and Token.PacketNeeded are both NULL. - 7. One or more IPv4 addresses in Token.OverrideData - are not valid unicast IPv4 addresses if + 7. One or more IPv4 addresses in Token.OverrideData + are not valid unicast IPv4 addresses if Token.OverrideData is not NULL. @retval EFI_UNSUPPORTED One or more options in the Token.OptionList are in the unsupported list of structure EFI_MTFTP4_MODE_DATA. @retval EFI_NOT_STARTED The EFI MTFTPv4 Protocol driver has not been started. - @retval EFI_NO_MAPPING When using a default address, configuration (DHCP, + @retval EFI_NO_MAPPING When using a default address, configuration (DHCP, BOOTP, RARP, etc.) is not finished yet. - @retval EFI_ALREADY_STARTED This Token is already being used in another MTFTPv4 + @retval EFI_ALREADY_STARTED This Token is already being used in another MTFTPv4 session. @retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated. @retval EFI_ACCESS_DENIED The previous operation has not completed yet. @@ -928,31 +939,31 @@ EfiMtftp4ReadDirectory ( /** - Gets information about a file from an MTFTPv4 server. - - The GetInfo() function assembles an MTFTPv4 request packet with options; - sends it to the MTFTPv4 server; and may return an MTFTPv4 OACK, MTFTPv4 ERROR, - or ICMP ERROR packet. Retries occur only if no response packets are received + Gets information about a file from an MTFTPv4 server. + + The GetInfo() function assembles an MTFTPv4 request packet with options; + sends it to the MTFTPv4 server; and may return an MTFTPv4 OACK, MTFTPv4 ERROR, + or ICMP ERROR packet. Retries occur only if no response packets are received from the MTFTPv4 server before the timeout expires. - It is implemented with EfiMtftp4ReadFile: build a token, then pass it to + It is implemented with EfiMtftp4ReadFile: build a token, then pass it to EfiMtftp4ReadFile. In its check packet callback abort the opertions. @param This Pointer to the EFI_MTFTP4_PROTOCOL instance - @param OverrideData Data that is used to override the existing - parameters. If NULL, the default parameters that - were set in the EFI_MTFTP4_PROTOCOL.Configure() + @param OverrideData Data that is used to override the existing + parameters. If NULL, the default parameters that + were set in the EFI_MTFTP4_PROTOCOL.Configure() function are used @param Filename Pointer to null-terminated ASCII file name string - @param ModeStr Pointer to null-terminated ASCII mode string. If NULL, "octet" + @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. + @param OptionList Pointer to array of option/value string pairs. Ignored if OptionCount is zero @param PacketLength The number of bytes in the returned packet - @param Packet PacketThe pointer to the received packet. This + @param Packet PacketThe pointer to the received packet. This buffer must be freed by the caller. - @retval EFI_SUCCESS An MTFTPv4 OACK packet was received and is in + @retval EFI_SUCCESS An MTFTPv4 OACK packet was received and is in the Buffer. @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE: 1.This is NULL. @@ -960,21 +971,21 @@ EfiMtftp4ReadDirectory ( 3.OptionCount is not zero and OptionList is NULL. 4.One or more options in OptionList have wrong format. 5.PacketLength is NULL. - 6.One or more IPv4 addresses in OverrideData are - not valid unicast IPv4 addresses if OverrideData + 6.One or more IPv4 addresses in OverrideData are + not valid unicast IPv4 addresses if OverrideData is not NULL. @retval EFI_UNSUPPORTED One or more options in the OptionList are in the unsupported list of structure EFI_MTFTP4_MODE_DATA @retval EFI_NOT_STARTED The EFI MTFTPv4 Protocol driver has not been started. - @retval EFI_NO_MAPPING When using a default address, configuration (DHCP, + @retval EFI_NO_MAPPING When using a default address, configuration (DHCP, BOOTP, RARP, etc.) has not finished yet. @retval EFI_ACCESS_DENIED The previous operation has not completed yet. @retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated. - @retval EFI_TFTP_ERROR An MTFTPv4 ERROR packet was received and is in + @retval EFI_TFTP_ERROR An MTFTPv4 ERROR packet was received and is in the Buffer. - @retval EFI_ICMP_ERROR An ICMP ERROR packet was received and the Packet + @retval EFI_ICMP_ERROR An ICMP ERROR packet was received and the Packet is set to NULL. - @retval EFI_PROTOCOL_ERROR An unexpected MTFTPv4 packet was received and is + @retval EFI_PROTOCOL_ERROR An unexpected MTFTPv4 packet was received and is 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. @@ -1041,15 +1052,15 @@ EfiMtftp4GetInfo ( /** Polls for incoming data packets and processes outgoing data packets. - The Poll() function can be used by network drivers and applications to increase - the rate that data packets are moved between the communications device and the + The Poll() function can be used by network drivers and applications to increase + the rate that data packets are moved between the communications device and the transmit and receive queues. - In some systems, the periodic timer event in the managed network driver may not - poll the underlying communications device fast enough to transmit and/or receive - all data packets without missing incoming packets or dropping outgoing packets. - Drivers and applications that are experiencing packet loss should try calling + In some systems, the periodic timer event in the managed network driver may not + poll the underlying communications device fast enough to transmit and/or receive + all data packets without missing incoming packets or dropping outgoing packets. + Drivers and applications that are experiencing packet loss should try calling the Poll() function more often. - + @param This Pointer to the EFI_MTFTP4_PROTOCOL instance @retval EFI_SUCCESS Incoming or outgoing data was processed. @@ -1058,7 +1069,7 @@ EfiMtftp4GetInfo ( BOOTP, RARP, etc.) is not finished yet. @retval EFI_INVALID_PARAMETER This is NULL. @retval EFI_DEVICE_ERROR An unexpected system or network error occurred. - @retval EFI_TIMEOUT Data was dropped out of the transmit and/or receive + @retval EFI_TIMEOUT Data was dropped out of the transmit and/or receive queue. Consider increasing the polling rate. **/ @@ -1070,6 +1081,7 @@ EfiMtftp4Poll ( { MTFTP4_PROTOCOL *Instance; EFI_UDP4_PROTOCOL *Udp; + EFI_STATUS Status; if (This == NULL) { return EFI_INVALID_PARAMETER; @@ -1084,7 +1096,9 @@ EfiMtftp4Poll ( } Udp = Instance->UnicastPort->Protocol.Udp4; - return Udp->Poll (Udp); + Status = Udp->Poll (Udp); + Mtftp4OnTimerTick (NULL, Instance->Service); + return Status; } EFI_MTFTP4_PROTOCOL gMtftp4ProtocolTemplate = {