1 /** @file 2 This EFI_MTFTP6_PROTOCOL interface implementation. 3 4 It supports the following RFCs: 5 RFC1350 - THE TFTP PROTOCOL (REVISION 2) 6 RFC2090 - TFTP Multicast Option 7 RFC2347 - TFTP Option Extension 8 RFC2348 - TFTP Blocksize Option 9 RFC2349 - TFTP Timeout Interval and Transfer Size Options 10 11 Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR> 12 13 This program and the accompanying materials 14 are licensed and made available under the terms and conditions of the BSD License 15 which accompanies this distribution. The full text of the license may be found at 16 http://opensource.org/licenses/bsd-license.php. 17 18 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 19 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 20 21 **/ 22 23 #include "Mtftp6Impl.h" 24 25 EFI_MTFTP6_PROTOCOL gMtftp6ProtocolTemplate = { 26 EfiMtftp6GetModeData, 27 EfiMtftp6Configure, 28 EfiMtftp6GetInfo, 29 EfiMtftp6ParseOptions, 30 EfiMtftp6ReadFile, 31 EfiMtftp6WriteFile, 32 EfiMtftp6ReadDirectory, 33 EfiMtftp6Poll 34 }; 35 36 /** 37 Returns the current operating mode data for the MTFTP6 instance. 38 39 The GetModeData() function returns the current operating mode and 40 cached data packet for the MTFTP6 instance. 41 42 @param[in] This Pointer to the EFI_MTFTP6_PROTOCOL instance. 43 @param[out] ModeData The buffer in which the EFI MTFTPv6 Protocol driver mode 44 data is returned. 45 46 @retval EFI_SUCCESS The configuration data was returned successfully. 47 @retval EFI_OUT_OF_RESOURCES The required mode data could not be allocated. 48 @retval EFI_INVALID_PARAMETER This is NULL or ModeData is NULL. 49 50 **/ 51 EFI_STATUS 52 EFIAPI 53 EfiMtftp6GetModeData ( 54 IN EFI_MTFTP6_PROTOCOL *This, 55 OUT EFI_MTFTP6_MODE_DATA *ModeData 56 ) 57 { 58 MTFTP6_INSTANCE *Instance; 59 EFI_TPL OldTpl; 60 61 if (This == NULL || ModeData == NULL) { 62 return EFI_INVALID_PARAMETER; 63 } 64 65 OldTpl = gBS->RaiseTPL (TPL_CALLBACK); 66 Instance = MTFTP6_INSTANCE_FROM_THIS (This); 67 68 // 69 // Copy back the configure data if the instance already configured. 70 // 71 if (Instance->Config != NULL) { 72 CopyMem ( 73 &ModeData->ConfigData, 74 Instance->Config, 75 sizeof (EFI_MTFTP6_CONFIG_DATA) 76 ); 77 } else { 78 ZeroMem ( 79 &ModeData->ConfigData, 80 sizeof (EFI_MTFTP6_CONFIG_DATA) 81 ); 82 } 83 84 // 85 // Set the current support options in mode data. 86 // 87 ModeData->SupportedOptionCount = MTFTP6_SUPPORTED_OPTIONS_NUM; 88 ModeData->SupportedOptions = (UINT8 **) mMtftp6SupportedOptions; 89 90 gBS->RestoreTPL (OldTpl); 91 92 return EFI_SUCCESS; 93 } 94 95 96 /** 97 Initializes, changes, or resets the default operational setting for 98 this EFI MTFTPv6 Protocol driver instance. 99 100 The Configure() function is used to set and change the configuration 101 data for this EFI MTFTPv6 Protocol driver instance. The configuration 102 data can be reset to startup defaults by calling Configure() with 103 MtftpConfigData set to NULL. Whenever the instance is reset, any 104 pending operation is aborted. By changing the EFI MTFTPv6 Protocol 105 driver instance configuration data, the client can connect to 106 different MTFTPv6 servers. The configuration parameters in 107 MtftpConfigData are used as the default parameters in later MTFTPv6 108 operations and can be overridden in later operations. 109 110 @param[in] This Pointer to the EFI_MTFTP6_PROTOCOL instance. 111 @param[in] MtftpConfigData Pointer to the configuration data structure. 112 113 @retval EFI_SUCCESS The EFI MTFTPv6 Protocol instance was configured successfully. 114 @retval EFI_INVALID_PARAMETER One or more following conditions are TRUE: 115 - This is NULL. 116 - MtftpConfigData.StationIp is neither zero nor one 117 of the configured IP addresses in the underlying IPv6 driver. 118 - MtftpCofigData.ServerIp is not a valid IPv6 unicast address. 119 Note: It does not match the UEFI 2.3 Specification. 120 @retval EFI_ACCESS_DENIED - The configuration could not be changed at this time because there 121 is some MTFTP background operation in progress. 122 - MtftpCofigData.LocalPort is already in use. 123 Note: It does not match the UEFI 2.3 Specification. 124 @retval EFI_NO_MAPPING The underlying IPv6 driver was responsible for choosing a source 125 address for this instance, but no source address was available for use. 126 @retval EFI_OUT_OF_RESOURCES The EFI MTFTPv6 Protocol driver instance data could not be 127 allocated. 128 Note: It is not defined in the UEFI 2.3 Specification. 129 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred. The EFI 130 MTFTPv6 Protocol driver instance is not configured. 131 Note: It is not defined in the UEFI 2.3 Specification. 132 133 **/ 134 EFI_STATUS 135 EFIAPI 136 EfiMtftp6Configure ( 137 IN EFI_MTFTP6_PROTOCOL *This, 138 IN EFI_MTFTP6_CONFIG_DATA *MtftpConfigData OPTIONAL 139 ) 140 { 141 MTFTP6_SERVICE *Service; 142 MTFTP6_INSTANCE *Instance; 143 EFI_UDP6_PROTOCOL *Udp6; 144 EFI_UDP6_CONFIG_DATA Udp6Cfg; 145 EFI_STATUS Status; 146 EFI_TPL OldTpl; 147 148 if (This == NULL) { 149 return EFI_INVALID_PARAMETER; 150 } 151 152 if (MtftpConfigData != NULL && !NetIp6IsValidUnicast (&MtftpConfigData->ServerIp)) { 153 return EFI_INVALID_PARAMETER; 154 } 155 156 OldTpl = gBS->RaiseTPL (TPL_CALLBACK); 157 Instance = MTFTP6_INSTANCE_FROM_THIS (This); 158 Service = Instance->Service; 159 Status = EFI_SUCCESS; 160 161 if (MtftpConfigData == NULL) { 162 // 163 // Configure the instance as NULL to abort the current session. 164 // 165 Mtftp6OperationClean (Instance, EFI_ABORTED); 166 FreePool (Instance->Config); 167 Instance->Config = NULL; 168 } else { 169 // 170 // It's not allowed to configure one instance twice without configure null. 171 // 172 if (Instance->Config != NULL) { 173 Status = EFI_ACCESS_DENIED; 174 goto ON_EXIT; 175 } 176 // 177 // Allocate the configure buffer of the instance and store the user's data. 178 // 179 Instance->Config = AllocateZeroPool (sizeof (EFI_MTFTP6_CONFIG_DATA)); 180 181 if (Instance->Config == NULL) { 182 Status = EFI_OUT_OF_RESOURCES; 183 goto ON_EXIT; 184 } 185 186 CopyMem (Instance->Config, MtftpConfigData, sizeof (EFI_MTFTP6_CONFIG_DATA)); 187 188 // 189 // Don't configure the udpio here because each operation might override 190 // the configuration, so delay udpio configuration in each operation. 191 // 192 if (Instance->UdpIo == NULL) { 193 Instance->UdpIo = UdpIoCreateIo ( 194 Service->Controller, 195 Service->Image, 196 Mtftp6ConfigDummyUdpIo, 197 UDP_IO_UDP6_VERSION, 198 NULL 199 ); 200 if (Instance->UdpIo != NULL) { 201 Status = gBS->OpenProtocol ( 202 Instance->UdpIo->UdpHandle, 203 &gEfiUdp6ProtocolGuid, 204 (VOID **) &Udp6, 205 Service->Image, 206 Instance->Handle, 207 EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER 208 ); 209 if (EFI_ERROR (Status)) { 210 goto ON_EXIT; 211 } 212 } 213 } 214 215 if (Instance->UdpIo == NULL) { 216 Status = EFI_OUT_OF_RESOURCES; 217 goto ON_EXIT; 218 } 219 220 // 221 // Continue to configure the downside Udp6 instance by user's data. 222 // 223 ZeroMem (&Udp6Cfg, sizeof (EFI_UDP6_CONFIG_DATA)); 224 225 Udp6Cfg.AcceptPromiscuous = FALSE; 226 Udp6Cfg.AcceptAnyPort = FALSE; 227 Udp6Cfg.AllowDuplicatePort = FALSE; 228 Udp6Cfg.TrafficClass = 0; 229 Udp6Cfg.HopLimit = 128; 230 Udp6Cfg.ReceiveTimeout = 0; 231 Udp6Cfg.TransmitTimeout = 0; 232 Udp6Cfg.StationPort = Instance->Config->LocalPort; 233 Udp6Cfg.RemotePort = Instance->Config->InitialServerPort; 234 235 CopyMem ( 236 &Udp6Cfg.StationAddress, 237 &Instance->Config->StationIp, 238 sizeof(EFI_IPv6_ADDRESS) 239 ); 240 241 CopyMem ( 242 &Udp6Cfg.RemoteAddress, 243 &Instance->Config->ServerIp, 244 sizeof (EFI_IPv6_ADDRESS) 245 ); 246 247 Udp6 = Instance->UdpIo->Protocol.Udp6; 248 Status = Udp6->Configure (Udp6, &Udp6Cfg); 249 250 if (EFI_ERROR (Status)) { 251 goto ON_EXIT; 252 } 253 } 254 255 ON_EXIT: 256 if (EFI_ERROR (Status)) { 257 if (Instance->Config != NULL) { 258 FreePool (Instance->Config); 259 Instance->Config = NULL; 260 } 261 if (Instance->UdpIo != NULL) { 262 UdpIoFreeIo (Instance->UdpIo); 263 Instance->UdpIo = NULL; 264 } 265 } 266 gBS->RestoreTPL (OldTpl); 267 return Status; 268 } 269 270 271 /** 272 Get the information of the download from the server. 273 274 The GetInfo() function assembles an MTFTPv6 request packet 275 with options, sends it to the MTFTPv6 server, and may return 276 an MTFTPv6 OACK, MTFTPv6 ERROR, or ICMP ERROR packet. Retries 277 occur only if no response packets are received from the MTFTPv6 278 server before the timeout expires. 279 280 @param[in] This Pointer to the EFI_MTFTP6_PROTOCOL instance. 281 @param[in] OverrideData Data that is used to override the existing parameters. If NULL, the 282 default parameters that were set in the EFI_MTFTP6_PROTOCOL.Configure() 283 function are used. 284 @param[in] Filename Pointer to null-terminated ASCII file name string. 285 @param[in] ModeStr Pointer to null-terminated ASCII mode string. If NULL, octet will be used. 286 @param[in] OptionCount Number of option/value string pairs in OptionList. 287 @param[in] OptionList Pointer to array of option/value string pairs. Ignored if 288 OptionCount is zero. 289 @param[out] PacketLength The number of bytes in the returned packet. 290 @param[out] Packet The pointer to the received packet. This buffer must be freed by 291 the caller. 292 293 @retval EFI_SUCCESS An MTFTPv6 OACK packet was received and is in the Packet. 294 Note: It does not match the UEFI 2.3 Specification. 295 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE: 296 - This is NULL. 297 - Filename is NULL. 298 - OptionCount is not zero and OptionList is NULL. 299 - One or more options in OptionList have wrong format. 300 - PacketLength is NULL. 301 - OverrideData.ServerIp is not valid unicast IPv6 addresses. 302 @retval EFI_UNSUPPORTED One or more options in the OptionList are unsupported by 303 this implementation. 304 @retval EFI_NOT_STARTED The EFI MTFTPv6 Protocol driver has not been started. 305 @retval EFI_NO_MAPPING The underlying IPv6 driver was responsible for choosing a source 306 address for this instance, but no source address was available for use. 307 @retval EFI_ACCESS_DENIED The previous operation has not completed yet. 308 @retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated. 309 @retval EFI_TFTP_ERROR An MTFTPv6 ERROR packet was received and is in the Packet. 310 @retval EFI_NETWORK_UNREACHABLE An ICMP network unreachable error packet was received and the Packet is set to NULL. 311 Note: It is not defined in UEFI 2.3 Specification. 312 @retval EFI_HOST_UNREACHABLE An ICMP host unreachable error packet was received and the Packet is set to NULL. 313 Note: It is not defined in the UEFI 2.3 Specification. 314 @retval EFI_PROTOCOL_UNREACHABLE An ICMP protocol unreachable error packet was received and the Packet is set to NULL. 315 Note: It is not defined in the UEFI 2.3 Specification. 316 @retval EFI_PORT_UNREACHABLE An ICMP port unreachable error packet was received and the Packet is set to NULL. 317 @retval EFI_ICMP_ERROR Some other ICMP ERROR packet was received and the Packet is set to NULL. 318 Note: It does not match the UEFI 2.3 Specification. 319 @retval EFI_PROTOCOL_ERROR An unexpected MTFTPv6 packet was received and is in the Packet. 320 @retval EFI_TIMEOUT No responses were received from the MTFTPv6 server. 321 @retval EFI_DEVICE_ERROR An unexpected network error or system error occurred. 322 @retval EFI_NO_MEDIA There was a media error. 323 324 **/ 325 EFI_STATUS 326 EFIAPI 327 EfiMtftp6GetInfo ( 328 IN EFI_MTFTP6_PROTOCOL *This, 329 IN EFI_MTFTP6_OVERRIDE_DATA *OverrideData OPTIONAL, 330 IN UINT8 *Filename, 331 IN UINT8 *ModeStr OPTIONAL, 332 IN UINT8 OptionCount, 333 IN EFI_MTFTP6_OPTION *OptionList OPTIONAL, 334 OUT UINT32 *PacketLength, 335 OUT EFI_MTFTP6_PACKET **Packet OPTIONAL 336 ) 337 { 338 EFI_STATUS Status; 339 EFI_MTFTP6_TOKEN Token; 340 MTFTP6_GETINFO_CONTEXT Context; 341 342 if (This == NULL || 343 Filename == NULL || 344 PacketLength == NULL || 345 (OptionCount != 0 && OptionList == NULL) || 346 (OverrideData != NULL && !NetIp6IsValidUnicast (&OverrideData->ServerIp)) 347 ) { 348 return EFI_INVALID_PARAMETER; 349 } 350 351 if (Packet != NULL) { 352 *Packet = NULL; 353 } 354 355 *PacketLength = 0; 356 357 Context.Packet = Packet; 358 Context.PacketLen = PacketLength; 359 Context.Status = EFI_SUCCESS; 360 361 // 362 // Fill fields of the Token for GetInfo operation. 363 // 364 Token.Status = EFI_SUCCESS; 365 Token.Event = NULL; 366 Token.OverrideData = OverrideData; 367 Token.Filename = Filename; 368 Token.ModeStr = ModeStr; 369 Token.OptionCount = OptionCount; 370 Token.OptionList = OptionList; 371 Token.BufferSize = 0; 372 Token.Buffer = NULL; 373 Token.Context = &Context; 374 Token.CheckPacket = Mtftp6CheckPacket; 375 Token.TimeoutCallback = NULL; 376 Token.PacketNeeded = NULL; 377 378 // 379 // Start the GetInfo operation by issue the Token. 380 // 381 Status = Mtftp6OperationStart (This, &Token, EFI_MTFTP6_OPCODE_RRQ); 382 383 if (Status == EFI_ABORTED) { 384 // 385 // Return the status if failed to issue. 386 // 387 return Context.Status; 388 } 389 390 return Status; 391 } 392 393 394 /** 395 Parse the options in an MTFTPv6 OACK packet. 396 397 The ParseOptions() function parses the option fields in an MTFTPv6 OACK 398 packet and returns the number of options that were found, and optionally, 399 a list of pointers to the options in the packet. If one or more of the 400 option fields are not valid, then EFI_PROTOCOL_ERROR is returned and 401 *OptionCount and *OptionList stop at the last valid option. 402 403 @param[in] This Pointer to the EFI_MTFTP6_PROTOCOL instance. 404 @param[in] PacketLen Length of the OACK packet to be parsed. 405 @param[in] Packet Pointer to the OACK packet to be parsed. 406 @param[out] OptionCount Pointer to the number of options in the following OptionList. 407 @param[out] OptionList Pointer to EFI_MTFTP6_OPTION storage. Each pointer in the 408 OptionList points to the corresponding MTFTP option buffer 409 in the Packet. Call the EFI Boot Service FreePool() to 410 release the OptionList if the options in this OptionList 411 are not needed anymore. 412 413 @retval EFI_SUCCESS The OACK packet was valid and the OptionCount and 414 OptionList parameters have been updated. 415 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE: 416 - PacketLen is 0. 417 - Packet is NULL or Packet is not a valid MTFTPv6 packet. 418 - OptionCount is NULL. 419 @retval EFI_NOT_FOUND No options were found in the OACK packet. 420 @retval EFI_OUT_OF_RESOURCES Storage for the OptionList array can not be allocated. 421 @retval EFI_PROTOCOL_ERROR One or more of the option fields is invalid. 422 423 **/ 424 EFI_STATUS 425 EFIAPI 426 EfiMtftp6ParseOptions ( 427 IN EFI_MTFTP6_PROTOCOL *This, 428 IN UINT32 PacketLen, 429 IN EFI_MTFTP6_PACKET *Packet, 430 OUT UINT32 *OptionCount, 431 OUT EFI_MTFTP6_OPTION **OptionList OPTIONAL 432 ) 433 { 434 if (This == NULL) { 435 return EFI_INVALID_PARAMETER; 436 } 437 438 return Mtftp6ParseStart (Packet, PacketLen, OptionCount, OptionList); 439 } 440 441 442 /** 443 Download a file from an MTFTPv6 server. 444 445 The ReadFile() function is used to initialize and start an MTFTPv6 download 446 process, and optionally, wait for completion. When the download operation 447 completes, whether successfully or not, the Token.Status field is updated 448 by the EFI MTFTPv6 Protocol driver, and then Token.Event is signaled if it 449 is not NULL. 450 Data can be downloaded from the MTFTPv6 server into either of the following 451 locations: 452 - A fixed buffer that is pointed to by Token.Buffer 453 - A download service function that is pointed to by Token.CheckPacket. 454 If both Token.Buffer and Token.CheckPacket are used, then Token.CheckPacket 455 will be called first. If the call is successful, the packet will be stored 456 in Token.Buffer. 457 458 @param[in] This Pointer to the EFI_MTFTP6_PROTOCOL instance. 459 @param[in] Token Pointer to the token structure to provide the parameters that are 460 used in this operation. 461 462 @retval EFI_SUCCESS The data file has been transferred successfully. 463 @retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated. 464 @retval EFI_BUFFER_TOO_SMALL BufferSize is not zero but not large enough to hold the 465 downloaded data in downloading process. 466 Note: It does not match the UEFI 2.3 Specification. 467 @retval EFI_ABORTED Current operation is aborted by user. 468 @retval EFI_NETWORK_UNREACHABLE An ICMP network unreachable error packet was received. 469 Note: It is not defined in the UEFI 2.3 Specification. 470 @retval EFI_HOST_UNREACHABLE An ICMP host unreachable error packet was received. 471 Note: It is not defined in the UEFI 2.3 Specification. 472 @retval EFI_PROTOCOL_UNREACHABLE An ICMP protocol unreachable error packet was received. 473 Note: It is not defined in the UEFI 2.3 Specification. 474 @retval EFI_PORT_UNREACHABLE An ICMP port unreachable error packet was received. 475 Note: It is not defined in the UEFI 2.3 Specification. 476 @retval EFI_ICMP_ERROR An ICMP ERROR packet was received. 477 @retval EFI_TIMEOUT No responses were received from the MTFTPv6 server. 478 @retval EFI_TFTP_ERROR An MTFTPv6 ERROR packet was received. 479 @retval EFI_DEVICE_ERROR An unexpected network error or system error occurred. 480 @retval EFI_NO_MEDIA There was a media error. 481 482 **/ 483 EFI_STATUS 484 EFIAPI 485 EfiMtftp6ReadFile ( 486 IN EFI_MTFTP6_PROTOCOL *This, 487 IN EFI_MTFTP6_TOKEN *Token 488 ) 489 { 490 return Mtftp6OperationStart (This, Token, EFI_MTFTP6_OPCODE_RRQ); 491 } 492 493 494 /** 495 Send a file to an MTFTPv6 server. 496 497 The WriteFile() function is used to initialize an uploading operation 498 with the given option list and optionally wait for completion. If one 499 or more of the options is not supported by the server, the unsupported 500 options are ignored and a standard TFTP process starts instead. When 501 the upload process completes, whether successfully or not, Token.Event 502 is signaled, and the EFI MTFTPv6 Protocol driver updates Token.Status. 503 The caller can supply the data to be uploaded in the following two modes: 504 - Through the user-provided buffer 505 - Through a callback function 506 With the user-provided buffer, the Token.BufferSize field indicates 507 the length of the buffer, and the driver will upload the data in the 508 buffer. With an EFI_MTFTP6_PACKET_NEEDED callback function, the driver 509 will call this callback function to get more data from the user to upload. 510 511 @param[in] This Pointer to the EFI_MTFTP6_PROTOCOL instance. 512 @param[in] Token Pointer to the token structure to provide the parameters that are 513 used in this operation. 514 515 @retval EFI_SUCCESS The upload session has started. 516 @retval EFI_UNSUPPORTED The operation is not supported by this implementation. 517 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE: 518 - This is NULL. 519 - Token is NULL. 520 - Token.Filename is NULL. 521 - Token.OptionCount is not zero and Token.OptionList is NULL. 522 - One or more options in Token.OptionList have wrong format. 523 - Token.Buffer and Token.PacketNeeded are both NULL. 524 - Token.OverrideData.ServerIp is not a valid unicast IPv6 address. 525 @retval EFI_UNSUPPORTED One or more options in the Token.OptionList are not 526 supported by this implementation. 527 @retval EFI_NOT_STARTED The EFI MTFTPv6 Protocol driver has not been started. 528 @retval EFI_NO_MAPPING The underlying IPv6 driver was responsible for choosing a source 529 address for this instance, but no source address was available for use. 530 @retval EFI_ALREADY_STARTED This Token is already being used in another MTFTPv6 session. 531 @retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated. 532 @retval EFI_ACCESS_DENIED The previous operation has not completed yet. 533 @retval EFI_DEVICE_ERROR An unexpected network error or system error occurred. 534 535 **/ 536 EFI_STATUS 537 EFIAPI 538 EfiMtftp6WriteFile ( 539 IN EFI_MTFTP6_PROTOCOL *This, 540 IN EFI_MTFTP6_TOKEN *Token 541 ) 542 { 543 return Mtftp6OperationStart (This, Token, EFI_MTFTP6_OPCODE_WRQ); 544 } 545 546 547 /** 548 Download a data file directory from an MTFTPv6 server. 549 550 The ReadDirectory() function is used to return a list of files on the 551 MTFTPv6 server that are logically (or operationally) related to 552 Token.Filename. The directory request packet that is sent to the server 553 is built with the option list that was provided by the caller, if present. 554 The file information that the server returns is put into either of 555 the following locations: 556 - A fixed buffer that is pointed to by Token.Buffer. 557 - A download service function that is pointed to by Token.CheckPacket. 558 If both Token.Buffer and Token.CheckPacket are used, then Token.CheckPacket 559 will be called first. If the call is successful, the packet will be stored 560 in Token.Buffer. 561 562 @param[in] This Pointer to the EFI_MTFTP6_PROTOCOL instance. 563 @param[in] Token Pointer to the token structure to provide the parameters that are 564 used in this operation. 565 566 @retval EFI_SUCCESS The MTFTPv6 related file "directory" has been downloaded. 567 @retval EFI_UNSUPPORTED The EFI MTFTPv6 Protocol driver does not support this function. 568 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE: 569 - This is NULL. 570 - Token is NULL. 571 - Token.Filename is NULL. 572 - Token.OptionCount is not zero and Token.OptionList is NULL. 573 - One or more options in Token.OptionList have wrong format. 574 - Token.Buffer and Token.CheckPacket are both NULL. 575 - Token.OverrideData.ServerIp is not valid unicast IPv6 addresses. 576 @retval EFI_UNSUPPORTED One or more options in the Token.OptionList are not 577 supported by this implementation. 578 @retval EFI_NOT_STARTED The EFI MTFTPv6 Protocol driver has not been started. 579 @retval EFI_NO_MAPPING The underlying IPv6 driver was responsible for choosing a source 580 address for this instance, but no source address was available for use. 581 @retval EFI_ALREADY_STARTED This Token is already being used in another MTFTPv6 session. 582 @retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated. 583 @retval EFI_ACCESS_DENIED The previous operation has not completed yet. 584 @retval EFI_DEVICE_ERROR An unexpected network error or system error occurred. 585 586 **/ 587 EFI_STATUS 588 EFIAPI 589 EfiMtftp6ReadDirectory ( 590 IN EFI_MTFTP6_PROTOCOL *This, 591 IN EFI_MTFTP6_TOKEN *Token 592 ) 593 { 594 return Mtftp6OperationStart (This, Token, EFI_MTFTP6_OPCODE_DIR); 595 } 596 597 598 /** 599 Polls for incoming data packets and processes outgoing data packets. 600 601 The Poll() function can be used by network drivers and applications 602 to increase the rate that data packets are moved between the 603 communications device and the transmit and receive queues. In some 604 systems, the periodic timer event in the managed network driver may 605 not poll the underlying communications device fast enough to transmit 606 and/or receive all data packets without missing incoming packets or 607 dropping outgoing packets. Drivers and applications that are 608 experiencing packet loss should try calling the Poll() function 609 more often. 610 611 @param[in] This The MTFTP6 protocol instance. 612 613 614 @retval EFI_SUCCESS Incoming or outgoing data was processed. 615 @retval EFI_NOT_STARTED This EFI MTFTPv6 Protocol instance has not been started. 616 @retval EFI_INVALID_PARAMETER This is NULL. 617 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred. 618 @retval EFI_TIMEOUT Data was dropped out of the transmit and/or receive queue. 619 Consider increasing the polling rate. 620 621 **/ 622 EFI_STATUS 623 EFIAPI 624 EfiMtftp6Poll ( 625 IN EFI_MTFTP6_PROTOCOL *This 626 ) 627 { 628 MTFTP6_INSTANCE *Instance; 629 EFI_UDP6_PROTOCOL *Udp6; 630 631 if (This == NULL) { 632 return EFI_INVALID_PARAMETER; 633 } 634 635 Instance = MTFTP6_INSTANCE_FROM_THIS (This); 636 637 // 638 // Check the instance whether configured or in destroy. 639 // 640 if (Instance->Config == NULL) { 641 return EFI_NOT_STARTED; 642 } 643 644 Udp6 = Instance->UdpIo->Protocol.Udp6; 645 646 return Udp6->Poll (Udp6); 647 } 648