--- /dev/null
+/** @file\r
+ This EFI_MTFTP6_PROTOCOL interface implementation.\r
+\r
+ It supports the following RFCs:\r
+ RFC1350 - THE TFTP PROTOCOL (REVISION 2)\r
+ RFC2090 - TFTP Multicast Option\r
+ RFC2347 - TFTP Option Extension\r
+ RFC2348 - TFTP Blocksize Option\r
+ RFC2349 - TFTP Timeout Interval and Transfer Size Options\r
+\r
+ Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>\r
+\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
+\r
+ 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
+**/\r
+\r
+#include "Mtftp6Impl.h"\r
+\r
+EFI_MTFTP6_PROTOCOL gMtftp6ProtocolTemplate = {\r
+ EfiMtftp6GetModeData,\r
+ EfiMtftp6Configure,\r
+ EfiMtftp6GetInfo,\r
+ EfiMtftp6ParseOptions,\r
+ EfiMtftp6ReadFile,\r
+ EfiMtftp6WriteFile,\r
+ EfiMtftp6ReadDirectory,\r
+ EfiMtftp6Poll\r
+ };\r
+\r
+/**\r
+ Returns the current operating mode data for the MTFTP6 instance.\r
+\r
+ The GetModeData() function returns the current operating mode and\r
+ cached data packet for the MTFTP6 instance.\r
+\r
+ @param[in] This Pointer to the EFI_MTFTP6_PROTOCOL instance.\r
+ @param[out] ModeData The buffer in which the EFI MTFTPv6 Protocol driver mode\r
+ data is returned.\r
+\r
+ @retval EFI_SUCCESS The configuration data was returned successfully.\r
+ @retval EFI_OUT_OF_RESOURCES The required mode data could not be allocated.\r
+ @retval EFI_INVALID_PARAMETER This is NULL or ModeData is NULL.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiMtftp6GetModeData (\r
+ IN EFI_MTFTP6_PROTOCOL *This,\r
+ OUT EFI_MTFTP6_MODE_DATA *ModeData\r
+ )\r
+{\r
+ MTFTP6_INSTANCE *Instance;\r
+ EFI_TPL OldTpl;\r
+\r
+ if (This == NULL || ModeData == NULL) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
+ Instance = MTFTP6_INSTANCE_FROM_THIS (This);\r
+\r
+ //\r
+ // Copy back the configure data if the instance already configured.\r
+ //\r
+ if (Instance->Config != NULL) {\r
+ CopyMem (\r
+ &ModeData->ConfigData,\r
+ Instance->Config,\r
+ sizeof (EFI_MTFTP6_CONFIG_DATA)\r
+ );\r
+ } else {\r
+ ZeroMem (\r
+ &ModeData->ConfigData,\r
+ sizeof (EFI_MTFTP6_CONFIG_DATA)\r
+ );\r
+ }\r
+\r
+ //\r
+ // Set the current support options in mode data.\r
+ //\r
+ ModeData->SupportedOptionCount = MTFTP6_SUPPORTED_OPTIONS_NUM;\r
+ ModeData->SupportedOptions = (UINT8 **) mMtftp6SupportedOptions;\r
+\r
+ gBS->RestoreTPL (OldTpl);\r
+\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+\r
+/**\r
+ Initializes, changes, or resets the default operational setting for\r
+ this EFI MTFTPv6 Protocol driver instance.\r
+\r
+ The Configure() function is used to set and change the configuration\r
+ data for this EFI MTFTPv6 Protocol driver instance. The configuration\r
+ data can be reset to startup defaults by calling Configure() with\r
+ MtftpConfigData set to NULL. Whenever the instance is reset, any\r
+ pending operation is aborted. By changing the EFI MTFTPv6 Protocol\r
+ driver instance configuration data, the client can connect to\r
+ different MTFTPv6 servers. The configuration parameters in\r
+ MtftpConfigData are used as the default parameters in later MTFTPv6\r
+ operations and can be overridden in later operations.\r
+\r
+ @param[in] This Pointer to the EFI_MTFTP6_PROTOCOL instance.\r
+ @param[in] MtftpConfigData Pointer to the configuration data structure.\r
+\r
+ @retval EFI_SUCCESS The EFI MTFTPv6 Protocol instance was configured successfully.\r
+ @retval EFI_INVALID_PARAMETER One or more following conditions are TRUE:\r
+ - This is NULL.\r
+ - MtftpConfigData.StationIp is neither zero nor one\r
+ of the configured IP addresses in the underlying IPv6 driver.\r
+ - MtftpCofigData.ServerIp is not a valid IPv6 unicast address.\r
+ Note: It does not match the UEFI 2.3 Specification.\r
+ @retval EFI_ACCESS_DENIED - The configuration could not be changed at this time because there\r
+ is some MTFTP background operation in progress.\r
+ - MtftpCofigData.LocalPort is already in use.\r
+ Note: It does not match the UEFI 2.3 Specification.\r
+ @retval EFI_NO_MAPPING The underlying IPv6 driver was responsible for choosing a source\r
+ address for this instance, but no source address was available for use.\r
+ @retval EFI_OUT_OF_RESOURCES The EFI MTFTPv6 Protocol driver instance data could not be\r
+ allocated.\r
+ Note: It is not defined in the UEFI 2.3 Specification.\r
+ @retval EFI_DEVICE_ERROR An unexpected system or network error occurred. The EFI\r
+ MTFTPv6 Protocol driver instance is not configured.\r
+ Note: It is not defined in the UEFI 2.3 Specification.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiMtftp6Configure (\r
+ IN EFI_MTFTP6_PROTOCOL *This,\r
+ IN EFI_MTFTP6_CONFIG_DATA *MtftpConfigData OPTIONAL\r
+ )\r
+{\r
+ MTFTP6_SERVICE *Service;\r
+ MTFTP6_INSTANCE *Instance;\r
+ EFI_UDP6_PROTOCOL *Udp6;\r
+ EFI_UDP6_CONFIG_DATA Udp6Cfg;\r
+ EFI_STATUS Status;\r
+ EFI_TPL OldTpl;\r
+\r
+ if (This == NULL) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ if (MtftpConfigData != NULL && !NetIp6IsValidUnicast (&MtftpConfigData->ServerIp)) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
+ Instance = MTFTP6_INSTANCE_FROM_THIS (This);\r
+ Service = Instance->Service;\r
+ Status = EFI_SUCCESS;\r
+\r
+ if (MtftpConfigData == NULL) {\r
+ //\r
+ // Configure the instance as NULL to abort the current session.\r
+ //\r
+ Mtftp6OperationClean (Instance, EFI_ABORTED);\r
+ FreePool (Instance->Config);\r
+ Instance->Config = NULL;\r
+ } else {\r
+ //\r
+ // It's not allowed to configure one instance twice without configure null.\r
+ //\r
+ if (Instance->Config != NULL) {\r
+ Status = EFI_ACCESS_DENIED;\r
+ goto ON_EXIT;\r
+ }\r
+ //\r
+ // Allocate the configure buffer of the instance and store the user's data.\r
+ //\r
+ Instance->Config = AllocateZeroPool (sizeof (EFI_MTFTP6_CONFIG_DATA));\r
+\r
+ if (Instance->Config == NULL) {\r
+ Status = EFI_OUT_OF_RESOURCES;\r
+ goto ON_EXIT;\r
+ }\r
+\r
+ CopyMem (Instance->Config, MtftpConfigData, sizeof (EFI_MTFTP6_CONFIG_DATA));\r
+\r
+ //\r
+ // Don't configure the udpio here because each operation might override\r
+ // the configuration, so delay udpio configuration in each operation.\r
+ //\r
+ Instance->UdpIo = UdpIoCreateIo (\r
+ Service->Controller,\r
+ Service->Image,\r
+ Mtftp6ConfigDummyUdpIo,\r
+ UDP_IO_UDP6_VERSION,\r
+ NULL\r
+ );\r
+\r
+ if (Instance->UdpIo == NULL) {\r
+ Status = EFI_OUT_OF_RESOURCES;\r
+ goto ON_EXIT;\r
+ }\r
+\r
+ //\r
+ // Continue to configure the downside Udp6 instance by user's data.\r
+ //\r
+ ZeroMem (&Udp6Cfg, sizeof (EFI_UDP6_CONFIG_DATA));\r
+\r
+ Udp6Cfg.AcceptPromiscuous = FALSE;\r
+ Udp6Cfg.AcceptAnyPort = FALSE;\r
+ Udp6Cfg.AllowDuplicatePort = FALSE;\r
+ Udp6Cfg.TrafficClass = 0;\r
+ Udp6Cfg.HopLimit = 128;\r
+ Udp6Cfg.ReceiveTimeout = 0;\r
+ Udp6Cfg.TransmitTimeout = 0;\r
+ Udp6Cfg.StationPort = Instance->Config->LocalPort;\r
+ Udp6Cfg.RemotePort = Instance->Config->InitialServerPort;\r
+\r
+ CopyMem (\r
+ &Udp6Cfg.StationAddress,\r
+ &Instance->Config->StationIp,\r
+ sizeof(EFI_IPv6_ADDRESS)\r
+ );\r
+\r
+ CopyMem (\r
+ &Udp6Cfg.RemoteAddress,\r
+ &Instance->Config->ServerIp,\r
+ sizeof (EFI_IPv6_ADDRESS)\r
+ );\r
+\r
+ Udp6 = Instance->UdpIo->Protocol.Udp6;\r
+ Status = Udp6->Configure (Udp6, &Udp6Cfg);\r
+\r
+ if (EFI_ERROR (Status)) {\r
+ goto ON_EXIT;\r
+ }\r
+ }\r
+\r
+ON_EXIT:\r
+ if (EFI_ERROR (Status)) {\r
+ if (Instance->Config != NULL) {\r
+ FreePool (Instance->Config);\r
+ Instance->Config = NULL;\r
+ }\r
+ if (Instance->UdpIo != NULL) {\r
+ UdpIoFreeIo (Instance->UdpIo);\r
+ Instance->UdpIo = NULL;\r
+ }\r
+ }\r
+ gBS->RestoreTPL (OldTpl);\r
+ return Status;\r
+}\r
+\r
+\r
+/**\r
+ Get the information of the download from the server.\r
+\r
+ The GetInfo() function assembles an MTFTPv6 request packet\r
+ with options, sends it to the MTFTPv6 server, and may return\r
+ an MTFTPv6 OACK, MTFTPv6 ERROR, or ICMP ERROR packet. Retries\r
+ occur only if no response packets are received from the MTFTPv6\r
+ server before the timeout expires.\r
+\r
+ @param[in] This Pointer to the EFI_MTFTP6_PROTOCOL instance.\r
+ @param[in] OverrideData Data that is used to override the existing parameters. If NULL, the\r
+ default parameters that were set in the EFI_MTFTP6_PROTOCOL.Configure()\r
+ function are used.\r
+ @param[in] Filename Pointer to ASCIIZ file name string.\r
+ @param[in] ModeStr Pointer to ASCIIZ mode string. If NULL, octet will be used.\r
+ @param[in] OptionCount Number of option/value string pairs in OptionList.\r
+ @param[in] OptionList Pointer to array of option/value string pairs. Ignored if\r
+ OptionCount is zero.\r
+ @param[out] PacketLength The number of bytes in the returned packet.\r
+ @param[out] Packet The pointer to the received packet. This buffer must be freed by\r
+ the caller.\r
+\r
+ @retval EFI_SUCCESS An MTFTPv6 OACK packet was received and is in the Packet.\r
+ Note: It does not match the UEFI 2.3 Specification.\r
+ @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:\r
+ - This is NULL.\r
+ - Filename is NULL.\r
+ - OptionCount is not zero and OptionList is NULL.\r
+ - One or more options in OptionList have wrong format.\r
+ - PacketLength is NULL.\r
+ - OverrideData.ServerIp is not valid unicast IPv6 addresses.\r
+ @retval EFI_UNSUPPORTED One or more options in the OptionList are unsupported by\r
+ this implementation.\r
+ @retval EFI_NOT_STARTED The EFI MTFTPv6 Protocol driver has not been started.\r
+ @retval EFI_NO_MAPPING The underlying IPv6 driver was responsible for choosing a source\r
+ address for this instance, but no source address was available for use.\r
+ @retval EFI_ACCESS_DENIED The previous operation has not completed yet.\r
+ @retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated.\r
+ @retval EFI_TFTP_ERROR An MTFTPv6 ERROR packet was received and is in the Packet.\r
+ @retval EFI_NETWORK_UNREACHABLE An ICMP network unreachable error packet was received and the Packet is set to NULL.\r
+ Note: It is not defined in UEFI 2.3 Specification.\r
+ @retval EFI_HOST_UNREACHABLE An ICMP host unreachable error packet was received and the Packet is set to NULL.\r
+ Note: It is not defined in the UEFI 2.3 Specification.\r
+ @retval EFI_PROTOCOL_UNREACHABLE An ICMP protocol unreachable error packet was received and the Packet is set to NULL.\r
+ Note: It is not defined in the UEFI 2.3 Specification.\r
+ @retval EFI_PORT_UNREACHABLE An ICMP port unreachable error packet was received and the Packet is set to NULL.\r
+ @retval EFI_ICMP_ERROR Some other ICMP ERROR packet was received and the Packet is set to NULL.\r
+ Note: It does not match the UEFI 2.3 Specification.\r
+ @retval EFI_PROTOCOL_ERROR An unexpected MTFTPv6 packet was received and is in the Packet.\r
+ @retval EFI_TIMEOUT No responses were received from the MTFTPv6 server.\r
+ @retval EFI_DEVICE_ERROR An unexpected network error or system error occurred.\r
+ @retval EFI_NO_MEDIA There was a media error.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiMtftp6GetInfo (\r
+ IN EFI_MTFTP6_PROTOCOL *This,\r
+ IN EFI_MTFTP6_OVERRIDE_DATA *OverrideData OPTIONAL,\r
+ IN UINT8 *Filename,\r
+ IN UINT8 *ModeStr OPTIONAL,\r
+ IN UINT8 OptionCount,\r
+ IN EFI_MTFTP6_OPTION *OptionList OPTIONAL,\r
+ OUT UINT32 *PacketLength,\r
+ OUT EFI_MTFTP6_PACKET **Packet OPTIONAL\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ EFI_MTFTP6_TOKEN Token;\r
+ MTFTP6_GETINFO_CONTEXT Context;\r
+\r
+ if (This == NULL ||\r
+ Filename == NULL ||\r
+ PacketLength == NULL ||\r
+ (OptionCount != 0 && OptionList == NULL) ||\r
+ (OverrideData != NULL && !NetIp6IsValidUnicast (&OverrideData->ServerIp))\r
+ ) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ if (Packet != NULL) {\r
+ *Packet = NULL;\r
+ }\r
+\r
+ *PacketLength = 0;\r
+\r
+ Context.Packet = Packet;\r
+ Context.PacketLen = PacketLength;\r
+ Context.Status = EFI_SUCCESS;\r
+\r
+ //\r
+ // Fill fields of the Token for GetInfo operation.\r
+ //\r
+ Token.Status = EFI_SUCCESS;\r
+ Token.Event = NULL;\r
+ Token.OverrideData = OverrideData;\r
+ Token.Filename = Filename;\r
+ Token.ModeStr = ModeStr;\r
+ Token.OptionCount = OptionCount;\r
+ Token.OptionList = OptionList;\r
+ Token.BufferSize = 0;\r
+ Token.Buffer = NULL;\r
+ Token.Context = &Context;\r
+ Token.CheckPacket = Mtftp6CheckPacket;\r
+ Token.TimeoutCallback = NULL;\r
+ Token.PacketNeeded = NULL;\r
+\r
+ //\r
+ // Start the GetInfo operation by issue the Token.\r
+ //\r
+ Status = Mtftp6OperationStart (This, &Token, EFI_MTFTP6_OPCODE_RRQ);\r
+\r
+ if (Status == EFI_ABORTED) {\r
+ //\r
+ // Return the status if failed to issue.\r
+ //\r
+ return Context.Status;\r
+ }\r
+\r
+ return Status;\r
+}\r
+\r
+\r
+/**\r
+ Parse the options in an MTFTPv6 OACK packet.\r
+\r
+ The ParseOptions() function parses the option fields in an MTFTPv6 OACK\r
+ packet and returns the number of options that were found, and optionally,\r
+ a list of pointers to the options in the packet. If one or more of the\r
+ option fields are not valid, then EFI_PROTOCOL_ERROR is returned and\r
+ *OptionCount and *OptionList stop at the last valid option.\r
+\r
+ @param[in] This Pointer to the EFI_MTFTP6_PROTOCOL instance.\r
+ @param[in] PacketLen Length of the OACK packet to be parsed.\r
+ @param[in] Packet Pointer to the OACK packet to be parsed.\r
+ @param[out] OptionCount Pointer to the number of options in the following OptionList.\r
+ @param[out] OptionList Pointer to EFI_MTFTP6_OPTION storage. Each pointer in the\r
+ OptionList points to the corresponding MTFTP option buffer\r
+ in the Packet. Call the EFI Boot Service FreePool() to\r
+ release the OptionList if the options in this OptionList\r
+ are not needed anymore.\r
+\r
+ @retval EFI_SUCCESS The OACK packet was valid and the OptionCount and\r
+ OptionList parameters have been updated.\r
+ @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:\r
+ - PacketLen is 0.\r
+ - Packet is NULL or Packet is not a valid MTFTPv6 packet.\r
+ - OptionCount is NULL.\r
+ @retval EFI_NOT_FOUND No options were found in the OACK packet.\r
+ @retval EFI_OUT_OF_RESOURCES Storage for the OptionList array can not be allocated.\r
+ @retval EFI_PROTOCOL_ERROR One or more of the option fields is invalid.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiMtftp6ParseOptions (\r
+ IN EFI_MTFTP6_PROTOCOL *This,\r
+ IN UINT32 PacketLen,\r
+ IN EFI_MTFTP6_PACKET *Packet,\r
+ OUT UINT32 *OptionCount,\r
+ OUT EFI_MTFTP6_OPTION **OptionList OPTIONAL\r
+ )\r
+{\r
+ if (This == NULL) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ return Mtftp6ParseStart (Packet, PacketLen, OptionCount, OptionList);\r
+}\r
+\r
+\r
+/**\r
+ Download a file from an MTFTPv6 server.\r
+\r
+ The ReadFile() function is used to initialize and start an MTFTPv6 download\r
+ process, and optionally, wait for completion. When the download operation\r
+ completes, whether successfully or not, the Token.Status field is updated\r
+ by the EFI MTFTPv6 Protocol driver, and then Token.Event is signaled if it\r
+ is not NULL.\r
+ Data can be downloaded from the MTFTPv6 server into either of the following\r
+ locations:\r
+ - A fixed buffer that is pointed to by Token.Buffer\r
+ - A download service function that is pointed to by Token.CheckPacket.\r
+ If both Token.Buffer and Token.CheckPacket are used, then Token.CheckPacket\r
+ will be called first. If the call is successful, the packet will be stored\r
+ in Token.Buffer.\r
+\r
+ @param[in] This Pointer to the EFI_MTFTP6_PROTOCOL instance.\r
+ @param[in] Token Pointer to the token structure to provide the parameters that are\r
+ used in this operation.\r
+\r
+ @retval EFI_SUCCESS The data file has been transferred successfully.\r
+ @retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated.\r
+ @retval EFI_BUFFER_TOO_SMALL BufferSize is not zero but not large enough to hold the\r
+ downloaded data in downloading process.\r
+ Note: It does not match the UEFI 2.3 Specification.\r
+ @retval EFI_ABORTED Current operation is aborted by user.\r
+ @retval EFI_NETWORK_UNREACHABLE An ICMP network unreachable error packet was received.\r
+ Note: It is not defined in the UEFI 2.3 Specification.\r
+ @retval EFI_HOST_UNREACHABLE An ICMP host unreachable error packet was received.\r
+ Note: It is not defined in the UEFI 2.3 Specification.\r
+ @retval EFI_PROTOCOL_UNREACHABLE An ICMP protocol unreachable error packet was received.\r
+ Note: It is not defined in the UEFI 2.3 Specification.\r
+ @retval EFI_PORT_UNREACHABLE An ICMP port unreachable error packet was received.\r
+ Note: It is not defined in the UEFI 2.3 Specification.\r
+ @retval EFI_ICMP_ERROR An ICMP ERROR packet was received.\r
+ @retval EFI_TIMEOUT No responses were received from the MTFTPv6 server.\r
+ @retval EFI_TFTP_ERROR An MTFTPv6 ERROR packet was received.\r
+ @retval EFI_DEVICE_ERROR An unexpected network error or system error occurred.\r
+ @retval EFI_NO_MEDIA There was a media error.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiMtftp6ReadFile (\r
+ IN EFI_MTFTP6_PROTOCOL *This,\r
+ IN EFI_MTFTP6_TOKEN *Token\r
+ )\r
+{\r
+ return Mtftp6OperationStart (This, Token, EFI_MTFTP6_OPCODE_RRQ);\r
+}\r
+\r
+\r
+/**\r
+ Send a file to an MTFTPv6 server.\r
+\r
+ The WriteFile() function is used to initialize an uploading operation\r
+ with the given option list and optionally wait for completion. If one\r
+ or more of the options is not supported by the server, the unsupported\r
+ options are ignored and a standard TFTP process starts instead. When\r
+ the upload process completes, whether successfully or not, Token.Event\r
+ is signaled, and the EFI MTFTPv6 Protocol driver updates Token.Status.\r
+ The caller can supply the data to be uploaded in the following two modes:\r
+ - Through the user-provided buffer\r
+ - Through a callback function\r
+ With the user-provided buffer, the Token.BufferSize field indicates\r
+ the length of the buffer, and the driver will upload the data in the\r
+ buffer. With an EFI_MTFTP6_PACKET_NEEDED callback function, the driver\r
+ will call this callback function to get more data from the user to upload.\r
+\r
+ @param[in] This Pointer to the EFI_MTFTP6_PROTOCOL instance.\r
+ @param[in] Token Pointer to the token structure to provide the parameters that are\r
+ used in this operation.\r
+\r
+ @retval EFI_SUCCESS The upload session has started.\r
+ @retval EFI_UNSUPPORTED The operation is not supported by this implementation.\r
+ @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:\r
+ - This is NULL.\r
+ - Token is NULL.\r
+ - Token.Filename is NULL.\r
+ - Token.OptionCount is not zero and Token.OptionList is NULL.\r
+ - One or more options in Token.OptionList have wrong format.\r
+ - Token.Buffer and Token.PacketNeeded are both NULL.\r
+ - Token.OverrideData.ServerIp is not a valid unicast IPv6 address.\r
+ @retval EFI_UNSUPPORTED One or more options in the Token.OptionList are not\r
+ supported by this implementation.\r
+ @retval EFI_NOT_STARTED The EFI MTFTPv6 Protocol driver has not been started.\r
+ @retval EFI_NO_MAPPING The underlying IPv6 driver was responsible for choosing a source\r
+ address for this instance, but no source address was available for use.\r
+ @retval EFI_ALREADY_STARTED This Token is already being used in another MTFTPv6 session.\r
+ @retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated.\r
+ @retval EFI_ACCESS_DENIED The previous operation has not completed yet.\r
+ @retval EFI_DEVICE_ERROR An unexpected network error or system error occurred.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiMtftp6WriteFile (\r
+ IN EFI_MTFTP6_PROTOCOL *This,\r
+ IN EFI_MTFTP6_TOKEN *Token\r
+ )\r
+{\r
+ return Mtftp6OperationStart (This, Token, EFI_MTFTP6_OPCODE_WRQ);\r
+}\r
+\r
+\r
+/**\r
+ Download a data file directory from an MTFTPv6 server.\r
+\r
+ The ReadDirectory() function is used to return a list of files on the\r
+ MTFTPv6 server that are logically (or operationally) related to\r
+ Token.Filename. The directory request packet that is sent to the server\r
+ is built with the option list that was provided by the caller, if present.\r
+ The file information that the server returns is put into either of\r
+ the following locations:\r
+ - A fixed buffer that is pointed to by Token.Buffer.\r
+ - A download service function that is pointed to by Token.CheckPacket.\r
+ If both Token.Buffer and Token.CheckPacket are used, then Token.CheckPacket\r
+ will be called first. If the call is successful, the packet will be stored\r
+ in Token.Buffer.\r
+\r
+ @param[in] This Pointer to the EFI_MTFTP6_PROTOCOL instance.\r
+ @param[in] Token Pointer to the token structure to provide the parameters that are\r
+ used in this operation.\r
+\r
+ @retval EFI_SUCCESS The MTFTPv6 related file "directory" has been downloaded.\r
+ @retval EFI_UNSUPPORTED The EFI MTFTPv6 Protocol driver does not support this function.\r
+ @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:\r
+ - This is NULL.\r
+ - Token is NULL.\r
+ - Token.Filename is NULL.\r
+ - Token.OptionCount is not zero and Token.OptionList is NULL.\r
+ - One or more options in Token.OptionList have wrong format.\r
+ - Token.Buffer and Token.CheckPacket are both NULL.\r
+ - Token.OverrideData.ServerIp is not valid unicast IPv6 addresses.\r
+ @retval EFI_UNSUPPORTED One or more options in the Token.OptionList are not\r
+ supported by this implementation.\r
+ @retval EFI_NOT_STARTED The EFI MTFTPv6 Protocol driver has not been started.\r
+ @retval EFI_NO_MAPPING The underlying IPv6 driver was responsible for choosing a source\r
+ address for this instance, but no source address was available for use.\r
+ @retval EFI_ALREADY_STARTED This Token is already being used in another MTFTPv6 session.\r
+ @retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated.\r
+ @retval EFI_ACCESS_DENIED The previous operation has not completed yet.\r
+ @retval EFI_DEVICE_ERROR An unexpected network error or system error occurred.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiMtftp6ReadDirectory (\r
+ IN EFI_MTFTP6_PROTOCOL *This,\r
+ IN EFI_MTFTP6_TOKEN *Token\r
+ )\r
+{\r
+ return Mtftp6OperationStart (This, Token, EFI_MTFTP6_OPCODE_DIR);\r
+}\r
+\r
+\r
+/**\r
+ Polls for incoming data packets and processes outgoing data packets.\r
+\r
+ The Poll() function can be used by network drivers and applications\r
+ to increase the rate that data packets are moved between the\r
+ communications device and the transmit and receive queues. In some\r
+ systems, the periodic timer event in the managed network driver may\r
+ not poll the underlying communications device fast enough to transmit\r
+ and/or receive all data packets without missing incoming packets or\r
+ dropping outgoing packets. Drivers and applications that are\r
+ experiencing packet loss should try calling the Poll() function\r
+ more often.\r
+\r
+ @param[in] This The MTFTP6 protocol instance.\r
+\r
+\r
+ @retval EFI_SUCCESS Incoming or outgoing data was processed.\r
+ @retval EFI_NOT_STARTED This EFI MTFTPv6 Protocol instance has not been started.\r
+ @retval EFI_INVALID_PARAMETER This is NULL.\r
+ @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.\r
+ @retval EFI_TIMEOUT Data was dropped out of the transmit and/or receive queue.\r
+ Consider increasing the polling rate.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiMtftp6Poll (\r
+ IN EFI_MTFTP6_PROTOCOL *This\r
+ )\r
+{\r
+ MTFTP6_INSTANCE *Instance;\r
+ EFI_UDP6_PROTOCOL *Udp6;\r
+\r
+ if (This == NULL) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ Instance = MTFTP6_INSTANCE_FROM_THIS (This);\r
+\r
+ //\r
+ // Check the instance whether configured or in destory.\r
+ //\r
+ if (Instance->Config == NULL) {\r
+ return EFI_NOT_STARTED;\r
+ } else if (Instance->InDestory) {\r
+ return EFI_DEVICE_ERROR;\r
+ }\r
+\r
+ Udp6 = Instance->UdpIo->Protocol.Udp6;\r
+\r
+ return Udp6->Poll (Udp6);\r
+}\r