3 Copyright (c) 2006 - 2007, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
18 Interface routine for Mtftp4
23 #include "Mtftp4Impl.h"
29 IN EFI_MTFTP4_PROTOCOL
*This
,
30 IN EFI_MTFTP4_TOKEN
*Token
35 Get the current operation parameter for the MTFTP session
37 @param This The MTFTP protocol instance
38 @param ModeData The MTFTP mode data
40 @retval EFI_INVALID_PARAMETER This or ModeData is NULL
41 @retval EFI_SUCCESS The operation parameter is saved in ModeData
47 EfiMtftp4GetModeData (
48 IN EFI_MTFTP4_PROTOCOL
*This
,
49 OUT EFI_MTFTP4_MODE_DATA
*ModeData
52 MTFTP4_PROTOCOL
*Instance
;
55 if ((This
== NULL
) || (ModeData
== NULL
)) {
56 return EFI_INVALID_PARAMETER
;
59 OldTpl
= NET_RAISE_TPL (NET_TPL_LOCK
);
61 Instance
= MTFTP4_PROTOCOL_FROM_THIS (This
);
62 ModeData
->ConfigData
= Instance
->Config
;
63 ModeData
->SupportedOptionCount
= MTFTP4_SUPPORTED_OPTIONS
;
64 ModeData
->SupportedOptoins
= mMtftp4SupportedOptions
;
65 ModeData
->UnsupportedOptionCount
= 0;
66 ModeData
->UnsupportedOptoins
= NULL
;
68 NET_RESTORE_TPL (OldTpl
);
75 Clean up the MTFTP session to get ready for new operation.
77 @param Instance The MTFTP session to clean up
78 @param Result The result to return to the caller who initiated
85 Mtftp4CleanOperation (
86 IN MTFTP4_PROTOCOL
*Instance
,
90 NET_LIST_ENTRY
*Entry
;
92 MTFTP4_BLOCK_RANGE
*Block
;
93 EFI_MTFTP4_TOKEN
*Token
;
96 // Free various resources.
98 Token
= Instance
->Token
;
101 Token
->Status
= Result
;
103 if (Token
->Event
!= NULL
) {
104 gBS
->SignalEvent (Token
->Event
);
107 Instance
->Token
= NULL
;
110 ASSERT (Instance
->UnicastPort
!= NULL
);
111 UdpIoCleanPort (Instance
->UnicastPort
);
113 if (Instance
->LastPacket
!= NULL
) {
114 NetbufFree (Instance
->LastPacket
);
115 Instance
->LastPacket
= NULL
;
118 if (Instance
->McastUdpPort
!= NULL
) {
119 UdpIoFreePort (Instance
->McastUdpPort
);
120 Instance
->McastUdpPort
= NULL
;
123 NET_LIST_FOR_EACH_SAFE (Entry
, Next
, &Instance
->Blocks
) {
124 Block
= NET_LIST_USER_STRUCT (Entry
, MTFTP4_BLOCK_RANGE
, Link
);
125 NetListRemoveEntry (Entry
);
129 NetZeroMem (&Instance
->RequestOption
, sizeof (MTFTP4_OPTION
));
131 Instance
->Operation
= 0;
133 Instance
->BlkSize
= MTFTP4_DEFAULT_BLKSIZE
;
134 Instance
->LastBlock
= 0;
135 Instance
->ServerIp
= 0;
136 Instance
->ListeningPort
= 0;
137 Instance
->ConnectedPort
= 0;
138 Instance
->Gateway
= 0;
139 Instance
->PacketToLive
= 0;
140 Instance
->MaxRetry
= 0;
141 Instance
->CurRetry
= 0;
142 Instance
->Timeout
= 0;
143 Instance
->McastIp
= 0;
144 Instance
->McastPort
= 0;
145 Instance
->Master
= TRUE
;
150 Configure the MTFTP session for new operation or reset the current
151 operation if ConfigData is NULL.
153 @param This The MTFTP session to configure
154 @param ConfigData The configure parameters
156 @retval EFI_INVALID_PARAMETER Some of the parameter is invalid.
157 @retval EFI_ACCESS_DENIED There is pending operation
158 @retval EFI_SUCCESS The instance is configured for operation.
165 IN EFI_MTFTP4_PROTOCOL
*This
,
166 IN EFI_MTFTP4_CONFIG_DATA
*ConfigData
169 MTFTP4_PROTOCOL
*Instance
;
177 return EFI_INVALID_PARAMETER
;
180 Instance
= MTFTP4_PROTOCOL_FROM_THIS (This
);
182 if (ConfigData
== NULL
) {
184 // Reset the operation if ConfigData is NULL
186 OldTpl
= NET_RAISE_TPL (NET_TPL_LOCK
);
188 Mtftp4CleanOperation (Instance
, EFI_ABORTED
);
189 NetZeroMem (&Instance
->Config
, sizeof (EFI_MTFTP4_CONFIG_DATA
));
190 Instance
->State
= MTFTP4_STATE_UNCONFIGED
;
192 NET_RESTORE_TPL (OldTpl
);
196 // Configure the parameters for new operation.
198 NetCopyMem (&Ip
, &ConfigData
->StationIp
, sizeof (IP4_ADDR
));
199 NetCopyMem (&Netmask
, &ConfigData
->SubnetMask
, sizeof (IP4_ADDR
));
200 NetCopyMem (&Gateway
, &ConfigData
->GatewayIp
, sizeof (IP4_ADDR
));
201 NetCopyMem (&ServerIp
, &ConfigData
->ServerIp
, sizeof (IP4_ADDR
));
204 Netmask
= NTOHL (Netmask
);
205 Gateway
= NTOHL (Gateway
);
206 ServerIp
= NTOHL (ServerIp
);
208 if (!Ip4IsUnicast (ServerIp
, 0)) {
209 return EFI_INVALID_PARAMETER
;
212 if (!ConfigData
->UseDefaultSetting
&&
213 ((!IP4_IS_VALID_NETMASK (Netmask
) || !Ip4IsUnicast (Ip
, Netmask
)))) {
215 return EFI_INVALID_PARAMETER
;
218 if ((Gateway
!= 0) &&
219 (!IP4_NET_EQUAL (Gateway
, Ip
, Netmask
) || !Ip4IsUnicast (Gateway
, Netmask
))) {
221 return EFI_INVALID_PARAMETER
;
224 OldTpl
= NET_RAISE_TPL (NET_TPL_LOCK
);
226 if ((Instance
->State
== MTFTP4_STATE_CONFIGED
) && (Instance
->Operation
!= 0)) {
227 NET_RESTORE_TPL (OldTpl
);
228 return EFI_ACCESS_DENIED
;
231 Instance
->Config
= *ConfigData
;
232 Instance
->State
= MTFTP4_STATE_CONFIGED
;
234 NET_RESTORE_TPL (OldTpl
);
242 Check packet for GetInfo. GetInfo is implemented with EfiMtftp4ReadFile.
243 It use Mtftp4GetInfoCheckPacket to inspect the first packet from server,
244 then abort the session.
246 @param This The MTFTP4 protocol instance
247 @param Token The user's token
248 @param PacketLen The length of the packet
249 @param Packet The received packet.
251 @retval EFI_ABORTED Abort the ReadFile operation and return.
256 Mtftp4GetInfoCheckPacket (
257 IN EFI_MTFTP4_PROTOCOL
*This
,
258 IN EFI_MTFTP4_TOKEN
*Token
,
260 IN EFI_MTFTP4_PACKET
*Packet
263 MTFTP4_PROTOCOL
*Instance
;
264 MTFTP4_GETINFO_STATE
*State
;
268 Instance
= MTFTP4_PROTOCOL_FROM_THIS (This
);
269 State
= &Instance
->GetInfoState
;
270 OpCode
= NTOHS (Packet
->OpCode
);
273 // Set the GetInfo's return status according to the OpCode.
276 case EFI_MTFTP4_OPCODE_ERROR
:
277 State
->Status
= EFI_TFTP_ERROR
;
280 case EFI_MTFTP4_OPCODE_OACK
:
281 State
->Status
= EFI_SUCCESS
;
285 State
->Status
= EFI_PROTOCOL_ERROR
;
289 // Allocate buffer then copy the packet over. Use gBS->AllocatePool
290 // in case NetAllocatePool will implements something tricky.
292 Status
= gBS
->AllocatePool (EfiBootServicesData
, PacketLen
, (VOID
**) State
->Packet
);
294 if (EFI_ERROR (Status
)) {
295 State
->Status
= EFI_OUT_OF_RESOURCES
;
299 *(State
->PacketLen
) = PacketLen
;
300 NetCopyMem (*(State
->Packet
), Packet
, PacketLen
);
307 Get the information of the download from the server. It is implemented
308 with EfiMtftp4ReadFile: build a token, then pass it to EfiMtftp4ReadFile.
309 In its check packet callback abort the opertions.
311 @param This The MTFTP protocol instance
312 @param OverrideData The MTFTP override data
313 @param Filename The file to get information
314 @param ModeStr The mode to use
315 @param OptionCount The number of options to append
316 @param OptionList The options to append
317 @param PacketLength The variable to receive the packet length
318 @param Packet The variable to receive the packet.
320 @retval EFI_INVALID_PARAMETER The parameter is invaid
321 @retval EFI_SUCCESS The information is got
322 @retval Others Failed to get the information.
329 IN EFI_MTFTP4_PROTOCOL
*This
,
330 IN EFI_MTFTP4_OVERRIDE_DATA
*OverrideData
, OPTIONAL
332 IN UINT8
*ModeStr
, OPTIONAL
333 IN UINT8 OptionCount
,
334 IN EFI_MTFTP4_OPTION
*OptionList
,
335 OUT UINT32
*PacketLength
,
336 OUT EFI_MTFTP4_PACKET
**Packet OPTIONAL
339 EFI_MTFTP4_TOKEN Token
;
340 MTFTP4_PROTOCOL
*Instance
;
341 MTFTP4_GETINFO_STATE
*State
;
344 if ((This
== NULL
) || (Filename
== NULL
) || (PacketLength
== NULL
) ||
345 (OptionCount
&& (OptionList
== NULL
))) {
346 return EFI_INVALID_PARAMETER
;
349 if (Packet
!= NULL
) {
354 Instance
= MTFTP4_PROTOCOL_FROM_THIS (This
);
355 State
= &Instance
->GetInfoState
;
356 State
->Packet
= Packet
;
357 State
->PacketLen
= PacketLength
;
358 State
->Status
= EFI_SUCCESS
;
361 // Fill in the Token to issue an synchronous ReadFile operation
363 Token
.Status
= EFI_SUCCESS
;
365 Token
.OverrideData
= OverrideData
;
366 Token
.Filename
= Filename
;
367 Token
.ModeStr
= ModeStr
;
368 Token
.OptionCount
= OptionCount
;
369 Token
.OptionList
= OptionList
;
370 Token
.BufferSize
= 0;
372 Token
.CheckPacket
= Mtftp4GetInfoCheckPacket
;
373 Token
.TimeoutCallback
= NULL
;
374 Token
.PacketNeeded
= NULL
;
376 Status
= EfiMtftp4ReadFile (This
, &Token
);
378 if (EFI_ABORTED
== Status
) {
379 return State
->Status
;
387 Parse the packet into an array of options. The OptionList is allocated
388 by this function, and caller should free it when used.
390 @param This The MTFTP protocol instance
391 @param PacketLen The length of the packet
392 @param Packet The packet to parse
393 @param OptionCount The size of the OptionList array allocated.
394 @param OptionList The allocated option array to save the option
397 @retval EFI_INVALID_PARAMETER The parameters are invalid.
398 @retval EFI_NOT_FOUND There is no valid option in the packet
399 @retval EFI_SUCCESS The packet is parsed.
405 EfiMtftp4ParseOptions (
406 IN EFI_MTFTP4_PROTOCOL
*This
,
408 IN EFI_MTFTP4_PACKET
*Packet
,
409 IN OUT UINT32
*OptionCount
,
410 OUT EFI_MTFTP4_OPTION
**OptionList OPTIONAL
415 if ((This
== NULL
) || (PacketLen
< MTFTP4_OPCODE_LEN
) ||
416 (Packet
== NULL
) || (OptionCount
== NULL
)) {
418 return EFI_INVALID_PARAMETER
;
421 Status
= Mtftp4ExtractOptions (Packet
, PacketLen
, OptionCount
, OptionList
);
423 if (EFI_ERROR (Status
)) {
427 if (*OptionCount
== 0) {
428 return EFI_NOT_FOUND
;
436 Check whether the override data is valid. It will first
437 validate whether the server is a valid unicast. If a gateway
438 is provided in the Override, it also check that it is a
439 unicast on the connected network.
441 @param Instance The MTFTP instance
442 @param Override The override data to validate.
444 @return TRUE if the override data is valid, otherwise FALSE.
449 Mtftp4OverrideValid (
450 IN MTFTP4_PROTOCOL
*Instance
,
451 IN EFI_MTFTP4_OVERRIDE_DATA
*Override
454 EFI_MTFTP4_CONFIG_DATA
*Config
;
459 NetCopyMem (&Ip
, &Override
->ServerIp
, sizeof (IP4_ADDR
));
460 if (!Ip4IsUnicast (NTOHL (Ip
), 0)) {
464 Config
= &Instance
->Config
;
466 NetCopyMem (&Gateway
, &Override
->GatewayIp
, sizeof (IP4_ADDR
));
467 Gateway
= NTOHL (Gateway
);
469 if (!Config
->UseDefaultSetting
&& (Gateway
!= 0)) {
470 NetCopyMem (&Netmask
, &Config
->SubnetMask
, sizeof (IP4_ADDR
));
471 NetCopyMem (&Ip
, &Config
->StationIp
, sizeof (IP4_ADDR
));
473 Netmask
= NTOHL (Netmask
);
476 if (!Ip4IsUnicast (Gateway
, Netmask
) || !IP4_NET_EQUAL (Gateway
, Ip
, Netmask
)) {
486 Poll the UDP to get the IP4 default address, which may be retrieved
487 by DHCP. The default time out value is 5 seconds. If IP has retrieved
488 the default address, the UDP is reconfigured.
490 @param Instance The Mtftp instance
491 @param UdpPort The UDP port to poll
492 @param UdpCfgData The UDP configure data to reconfigure the UDP
495 @return TRUE if the default address is retrieved and UDP is reconfigured.
496 @return Otherwise FALSE.
501 IN MTFTP4_PROTOCOL
*Instance
,
502 IN UDP_IO_PORT
*UdpPort
,
503 IN EFI_UDP4_CONFIG_DATA
*UdpCfgData
506 MTFTP4_SERVICE
*Service
;
507 EFI_IP4_MODE_DATA Ip4Mode
;
508 EFI_UDP4_PROTOCOL
*Udp
;
511 ASSERT (Instance
->Config
.UseDefaultSetting
);
513 Service
= Instance
->Service
;
516 Status
= gBS
->SetTimer (
517 Service
->TimerToGetMap
,
519 MTFTP4_TIME_TO_GETMAP
* TICKS_PER_SECOND
521 if (EFI_ERROR (Status
)) {
525 while (!EFI_ERROR (gBS
->CheckEvent (Service
->TimerToGetMap
))) {
528 if (!EFI_ERROR (Udp
->GetModeData (Udp
, NULL
, &Ip4Mode
, NULL
, NULL
)) &&
529 Ip4Mode
.IsConfigured
) {
531 Udp
->Configure (Udp
, NULL
);
532 return (BOOLEAN
) (Udp
->Configure (Udp
, UdpCfgData
) == EFI_SUCCESS
);
541 Configure the UDP port for unicast receiving.
543 @param UdpIo The UDP port
544 @param Instance The MTFTP session
546 @retval EFI_SUCCESS The UDP port is successfully configured for the
547 session to unicast receive.
552 Mtftp4ConfigUnicastPort (
553 IN UDP_IO_PORT
*UdpIo
,
554 IN MTFTP4_PROTOCOL
*Instance
557 EFI_MTFTP4_CONFIG_DATA
*Config
;
558 EFI_UDP4_CONFIG_DATA UdpConfig
;
562 Config
= &Instance
->Config
;
564 UdpConfig
.AcceptBroadcast
= FALSE
;
565 UdpConfig
.AcceptPromiscuous
= FALSE
;
566 UdpConfig
.AcceptAnyPort
= FALSE
;
567 UdpConfig
.AllowDuplicatePort
= FALSE
;
568 UdpConfig
.TypeOfService
= 0;
569 UdpConfig
.TimeToLive
= 64;
570 UdpConfig
.DoNotFragment
= FALSE
;
571 UdpConfig
.ReceiveTimeout
= 0;
572 UdpConfig
.TransmitTimeout
= 0;
573 UdpConfig
.UseDefaultAddress
= Config
->UseDefaultSetting
;
574 UdpConfig
.StationAddress
= Config
->StationIp
;
575 UdpConfig
.SubnetMask
= Config
->SubnetMask
;
576 UdpConfig
.StationPort
= 0;
577 UdpConfig
.RemotePort
= 0;
579 Ip
= HTONL (Instance
->ServerIp
);
580 NetCopyMem (&UdpConfig
.RemoteAddress
, &Ip
, sizeof (EFI_IPv4_ADDRESS
));
582 Status
= UdpIo
->Udp
->Configure (UdpIo
->Udp
, &UdpConfig
);
584 if ((Status
== EFI_NO_MAPPING
) && Mtftp4GetMapping (Instance
, UdpIo
, &UdpConfig
)) {
593 Start the MTFTP session to do the operation, such as read file,
594 write file, and read directory.
596 @param This The MTFTP session
597 @param Token The token than encapsues the user's request.
598 @param Operation The operation to do
600 @retval EFI_INVALID_PARAMETER Some of the parameters are invalid.
601 @retval EFI_NOT_STARTED The MTFTP session hasn't been configured.
602 @retval EFI_ALREADY_STARTED There is pending operation for the session.
603 @retval EFI_SUCCESS The operation is successfully started.
609 IN EFI_MTFTP4_PROTOCOL
*This
,
610 IN EFI_MTFTP4_TOKEN
*Token
,
614 MTFTP4_PROTOCOL
*Instance
;
615 EFI_MTFTP4_OVERRIDE_DATA
*Override
;
616 EFI_MTFTP4_CONFIG_DATA
*Config
;
621 // Validate the parameters
623 if ((This
== NULL
) || (Token
== NULL
) || (Token
->Filename
== NULL
) ||
624 ((Token
->OptionCount
!= 0) && (Token
->OptionList
== NULL
))) {
625 return EFI_INVALID_PARAMETER
;
629 // User must provide at least one method to collect the data for download.
631 if (((Operation
== EFI_MTFTP4_OPCODE_RRQ
) || (Operation
== EFI_MTFTP4_OPCODE_DIR
)) &&
632 ((Token
->Buffer
== NULL
) && (Token
->CheckPacket
== NULL
))) {
633 return EFI_INVALID_PARAMETER
;
637 // User must provide at least one method to provide the data for upload.
639 if ((Operation
== EFI_MTFTP4_OPCODE_WRQ
) &&
640 ((Token
->Buffer
== NULL
) && (Token
->PacketNeeded
== NULL
))) {
641 return EFI_INVALID_PARAMETER
;
644 Instance
= MTFTP4_PROTOCOL_FROM_THIS (This
);
646 Status
= EFI_SUCCESS
;
647 OldTpl
= NET_RAISE_TPL (NET_TPL_LOCK
);
649 if (Instance
->State
!= MTFTP4_STATE_CONFIGED
) {
650 Status
= EFI_NOT_STARTED
;
653 if (Instance
->Operation
!= 0) {
654 Status
= EFI_ACCESS_DENIED
;
657 if (EFI_ERROR (Status
)) {
658 NET_RESTORE_TPL (OldTpl
);
663 // Set the Operation now to prevent the application start other
666 Instance
->Operation
= Operation
;
667 Override
= Token
->OverrideData
;
669 if ((Override
!= NULL
) && !Mtftp4OverrideValid (Instance
, Override
)) {
670 Status
= EFI_INVALID_PARAMETER
;
674 if (Token
->OptionCount
!= 0) {
675 Status
= Mtftp4ParseOption (
679 &Instance
->RequestOption
682 if (EFI_ERROR (Status
)) {
688 // Set the operation parameters from the configuration or override data.
690 Config
= &Instance
->Config
;
691 Instance
->Token
= Token
;
692 Instance
->BlkSize
= MTFTP4_DEFAULT_BLKSIZE
;
694 NetCopyMem (&Instance
->ServerIp
, &Config
->ServerIp
, sizeof (IP4_ADDR
));
695 Instance
->ServerIp
= NTOHL (Instance
->ServerIp
);
697 Instance
->ListeningPort
= Config
->InitialServerPort
;
698 Instance
->ConnectedPort
= 0;
700 NetCopyMem (&Instance
->Gateway
, &Config
->GatewayIp
, sizeof (IP4_ADDR
));
701 Instance
->Gateway
= NTOHL (Instance
->Gateway
);
703 Instance
->MaxRetry
= Config
->TryCount
;
704 Instance
->Timeout
= Config
->TimeoutValue
;
705 Instance
->Master
= TRUE
;
707 if (Override
!= NULL
) {
708 NetCopyMem (&Instance
->ServerIp
, &Override
->ServerIp
, sizeof (IP4_ADDR
));
709 NetCopyMem (&Instance
->Gateway
, &Override
->GatewayIp
, sizeof (IP4_ADDR
));
711 Instance
->ServerIp
= NTOHL (Instance
->ServerIp
);
712 Instance
->Gateway
= NTOHL (Instance
->Gateway
);
714 Instance
->ListeningPort
= Override
->ServerPort
;
715 Instance
->MaxRetry
= Override
->TryCount
;
716 Instance
->Timeout
= Override
->TimeoutValue
;
719 if (Instance
->ListeningPort
== 0) {
720 Instance
->ListeningPort
= MTFTP4_DEFAULT_SERVER_PORT
;
723 if (Instance
->MaxRetry
== 0) {
724 Instance
->MaxRetry
= MTFTP4_DEFAULT_RETRY
;
727 if (Instance
->Timeout
== 0) {
728 Instance
->Timeout
= MTFTP4_DEFAULT_TIMEOUT
;
732 // Config the unicast UDP child to send initial request
734 Status
= Mtftp4ConfigUnicastPort (Instance
->UnicastPort
, Instance
);
736 if (EFI_ERROR (Status
)) {
741 // Build and send an initial requests
743 if (Operation
== EFI_MTFTP4_OPCODE_WRQ
) {
744 Status
= Mtftp4WrqStart (Instance
, Operation
);
746 Status
= Mtftp4RrqStart (Instance
, Operation
);
749 NET_RESTORE_TPL (OldTpl
);
751 if (EFI_ERROR (Status
)) {
755 // Return immediately for asynchronous operation or poll the
756 // instance for synchronous operation.
758 Token
->Status
= EFI_NOT_READY
;
760 if (Token
->Event
!= NULL
) {
764 while (Token
->Status
== EFI_NOT_READY
) {
768 return Token
->Status
;
771 Mtftp4CleanOperation (Instance
, Status
);
772 NET_RESTORE_TPL (OldTpl
);
779 Read a file from the server.
781 @param This The Mtftp protocol instance.
782 @param Token The user's request wrap token.
784 @retval EFI_SUCCESS The ReadFile has finished, the file has been
785 downloaded if it is synchronous operation,
786 otherwise it has been initated.
787 @retval Others Some error happened.
794 IN EFI_MTFTP4_PROTOCOL
*This
,
795 IN EFI_MTFTP4_TOKEN
*Token
798 return Mtftp4Start (This
, Token
, EFI_MTFTP4_OPCODE_RRQ
);
803 Upload a file to the server.
805 @param This The MTFTP protocol session
806 @param Token The user's request wrap token.
808 @retval EFI_SUCCESS The WriteFile has finished, the file has been
809 uploaded if it is synchronous operation, otherwise
810 it has been initated.
811 @retval Others Some error happened.
818 IN EFI_MTFTP4_PROTOCOL
*This
,
819 IN EFI_MTFTP4_TOKEN
*Token
822 return Mtftp4Start (This
, Token
, EFI_MTFTP4_OPCODE_WRQ
);
827 Read a directory from the server. The only difference
828 between ReadFile and ReadDirectory is the opcode used.
830 @param This The MTFTP protocol session
831 @param Token The user's request wrap token.
833 @retval EFI_SUCCESS The ReadDirectory has finished, the directory has
834 been downloaded as a file if it is synchronous
835 operation, otherwise it has been initated.
836 @retval Others Some error happened.
842 EfiMtftp4ReadDirectory (
843 IN EFI_MTFTP4_PROTOCOL
*This
,
844 IN EFI_MTFTP4_TOKEN
*Token
847 return Mtftp4Start (This
, Token
, EFI_MTFTP4_OPCODE_DIR
);
852 Poll the network stack to accelerate the packet process.
854 @param This The MTFTP protocol instance.
856 @retval EFI_INVALID_PARAMETER This is NULL.
857 @retval EFI_NOT_STARTED The MTFTP session hasn't been configured.
858 @retval EFI_DEVICE_ERROR The MTFTP session has been destoried.
865 IN EFI_MTFTP4_PROTOCOL
*This
868 MTFTP4_PROTOCOL
*Instance
;
869 EFI_UDP4_PROTOCOL
*Udp
;
872 return EFI_INVALID_PARAMETER
;
875 Instance
= MTFTP4_PROTOCOL_FROM_THIS (This
);
877 if (Instance
->State
== MTFTP4_STATE_UNCONFIGED
) {
878 return EFI_NOT_STARTED
;
879 } else if (Instance
->State
== MTFTP4_STATE_DESTORY
) {
880 return EFI_DEVICE_ERROR
;
883 Udp
= Instance
->UnicastPort
->Udp
;
884 return Udp
->Poll (Udp
);
887 EFI_MTFTP4_PROTOCOL gMtftp4ProtocolTemplate
= {
888 EfiMtftp4GetModeData
,
891 EfiMtftp4ParseOptions
,
894 EfiMtftp4ReadDirectory
,