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"
28 IN EFI_MTFTP4_PROTOCOL
*This
,
29 IN EFI_MTFTP4_TOKEN
*Token
34 Get the current operation parameter for the MTFTP session
36 @param This The MTFTP protocol instance
37 @param ModeData The MTFTP mode data
39 @retval EFI_INVALID_PARAMETER This or ModeData is NULL
40 @retval EFI_SUCCESS The operation parameter is saved in ModeData
45 EfiMtftp4GetModeData (
46 IN EFI_MTFTP4_PROTOCOL
*This
,
47 OUT EFI_MTFTP4_MODE_DATA
*ModeData
50 MTFTP4_PROTOCOL
*Instance
;
53 if ((This
== NULL
) || (ModeData
== NULL
)) {
54 return EFI_INVALID_PARAMETER
;
57 OldTpl
= gBS
->RaiseTPL (TPL_CALLBACK
);
59 Instance
= MTFTP4_PROTOCOL_FROM_THIS (This
);
60 CopyMem(&ModeData
->ConfigData
, &Instance
->Config
, sizeof (Instance
->Config
));
61 ModeData
->SupportedOptionCount
= MTFTP4_SUPPORTED_OPTIONS
;
62 ModeData
->SupportedOptoins
= (UINT8
**) mMtftp4SupportedOptions
;
63 ModeData
->UnsupportedOptionCount
= 0;
64 ModeData
->UnsupportedOptoins
= NULL
;
66 gBS
->RestoreTPL (OldTpl
);
73 Clean up the MTFTP session to get ready for new operation.
75 @param Instance The MTFTP session to clean up
76 @param Result The result to return to the caller who initiated
83 Mtftp4CleanOperation (
84 IN MTFTP4_PROTOCOL
*Instance
,
90 MTFTP4_BLOCK_RANGE
*Block
;
91 EFI_MTFTP4_TOKEN
*Token
;
94 // Free various resources.
96 Token
= Instance
->Token
;
99 Token
->Status
= Result
;
101 if (Token
->Event
!= NULL
) {
102 gBS
->SignalEvent (Token
->Event
);
105 Instance
->Token
= NULL
;
108 ASSERT (Instance
->UnicastPort
!= NULL
);
109 UdpIoCleanPort (Instance
->UnicastPort
);
111 if (Instance
->LastPacket
!= NULL
) {
112 NetbufFree (Instance
->LastPacket
);
113 Instance
->LastPacket
= NULL
;
116 if (Instance
->McastUdpPort
!= NULL
) {
117 UdpIoFreePort (Instance
->McastUdpPort
);
118 Instance
->McastUdpPort
= NULL
;
121 NET_LIST_FOR_EACH_SAFE (Entry
, Next
, &Instance
->Blocks
) {
122 Block
= NET_LIST_USER_STRUCT (Entry
, MTFTP4_BLOCK_RANGE
, Link
);
123 RemoveEntryList (Entry
);
124 gBS
->FreePool (Block
);
127 ZeroMem (&Instance
->RequestOption
, sizeof (MTFTP4_OPTION
));
129 Instance
->Operation
= 0;
131 Instance
->BlkSize
= MTFTP4_DEFAULT_BLKSIZE
;
132 Instance
->LastBlock
= 0;
133 Instance
->ServerIp
= 0;
134 Instance
->ListeningPort
= 0;
135 Instance
->ConnectedPort
= 0;
136 Instance
->Gateway
= 0;
137 Instance
->PacketToLive
= 0;
138 Instance
->MaxRetry
= 0;
139 Instance
->CurRetry
= 0;
140 Instance
->Timeout
= 0;
141 Instance
->McastIp
= 0;
142 Instance
->McastPort
= 0;
143 Instance
->Master
= TRUE
;
148 Configure the MTFTP session for new operation or reset the current
149 operation if ConfigData is NULL.
151 @param This The MTFTP session to configure
152 @param ConfigData The configure parameters
154 @retval EFI_INVALID_PARAMETER Some of the parameter is invalid.
155 @retval EFI_ACCESS_DENIED There is pending operation
156 @retval EFI_SUCCESS The instance is configured for operation.
162 IN EFI_MTFTP4_PROTOCOL
*This
,
163 IN EFI_MTFTP4_CONFIG_DATA
*ConfigData
166 MTFTP4_PROTOCOL
*Instance
;
174 return EFI_INVALID_PARAMETER
;
177 Instance
= MTFTP4_PROTOCOL_FROM_THIS (This
);
179 if (ConfigData
== NULL
) {
181 // Reset the operation if ConfigData is NULL
183 OldTpl
= gBS
->RaiseTPL (TPL_CALLBACK
);
185 Mtftp4CleanOperation (Instance
, EFI_ABORTED
);
186 ZeroMem (&Instance
->Config
, sizeof (EFI_MTFTP4_CONFIG_DATA
));
187 Instance
->State
= MTFTP4_STATE_UNCONFIGED
;
189 gBS
->RestoreTPL (OldTpl
);
193 // Configure the parameters for new operation.
195 CopyMem (&Ip
, &ConfigData
->StationIp
, sizeof (IP4_ADDR
));
196 CopyMem (&Netmask
, &ConfigData
->SubnetMask
, sizeof (IP4_ADDR
));
197 CopyMem (&Gateway
, &ConfigData
->GatewayIp
, sizeof (IP4_ADDR
));
198 CopyMem (&ServerIp
, &ConfigData
->ServerIp
, sizeof (IP4_ADDR
));
201 Netmask
= NTOHL (Netmask
);
202 Gateway
= NTOHL (Gateway
);
203 ServerIp
= NTOHL (ServerIp
);
205 if (!Ip4IsUnicast (ServerIp
, 0)) {
206 return EFI_INVALID_PARAMETER
;
209 if (!ConfigData
->UseDefaultSetting
&&
210 ((!IP4_IS_VALID_NETMASK (Netmask
) || !Ip4IsUnicast (Ip
, Netmask
)))) {
212 return EFI_INVALID_PARAMETER
;
215 if ((Gateway
!= 0) &&
216 (!IP4_NET_EQUAL (Gateway
, Ip
, Netmask
) || !Ip4IsUnicast (Gateway
, Netmask
))) {
218 return EFI_INVALID_PARAMETER
;
221 OldTpl
= gBS
->RaiseTPL (TPL_CALLBACK
);
223 if ((Instance
->State
== MTFTP4_STATE_CONFIGED
) && (Instance
->Operation
!= 0)) {
224 gBS
->RestoreTPL (OldTpl
);
225 return EFI_ACCESS_DENIED
;
228 CopyMem(&Instance
->Config
, ConfigData
, sizeof (*ConfigData
));;
229 Instance
->State
= MTFTP4_STATE_CONFIGED
;
231 gBS
->RestoreTPL (OldTpl
);
239 Check packet for GetInfo. GetInfo is implemented with EfiMtftp4ReadFile.
240 It use Mtftp4GetInfoCheckPacket to inspect the first packet from server,
241 then abort the session.
243 @param This The MTFTP4 protocol instance
244 @param Token The user's token
245 @param PacketLen The length of the packet
246 @param Packet The received packet.
248 @retval EFI_ABORTED Abort the ReadFile operation and return.
252 Mtftp4GetInfoCheckPacket (
253 IN EFI_MTFTP4_PROTOCOL
*This
,
254 IN EFI_MTFTP4_TOKEN
*Token
,
256 IN EFI_MTFTP4_PACKET
*Packet
259 MTFTP4_PROTOCOL
*Instance
;
260 MTFTP4_GETINFO_STATE
*State
;
264 Instance
= MTFTP4_PROTOCOL_FROM_THIS (This
);
265 State
= &Instance
->GetInfoState
;
266 OpCode
= NTOHS (Packet
->OpCode
);
269 // Set the GetInfo's return status according to the OpCode.
272 case EFI_MTFTP4_OPCODE_ERROR
:
273 State
->Status
= EFI_TFTP_ERROR
;
276 case EFI_MTFTP4_OPCODE_OACK
:
277 State
->Status
= EFI_SUCCESS
;
281 State
->Status
= EFI_PROTOCOL_ERROR
;
285 // Allocate buffer then copy the packet over. Use gBS->AllocatePool
286 // in case AllocatePool will implements something tricky.
288 Status
= gBS
->AllocatePool (EfiBootServicesData
, PacketLen
, (VOID
**) State
->Packet
);
290 if (EFI_ERROR (Status
)) {
291 State
->Status
= EFI_OUT_OF_RESOURCES
;
295 *(State
->PacketLen
) = PacketLen
;
296 CopyMem (*(State
->Packet
), Packet
, PacketLen
);
303 Get the information of the download from the server. It is implemented
304 with EfiMtftp4ReadFile: build a token, then pass it to EfiMtftp4ReadFile.
305 In its check packet callback abort the opertions.
307 @param This The MTFTP protocol instance
308 @param OverrideData The MTFTP override data
309 @param Filename The file to get information
310 @param ModeStr The mode to use
311 @param OptionCount The number of options to append
312 @param OptionList The options to append
313 @param PacketLength The variable to receive the packet length
314 @param Packet The variable to receive the packet.
316 @retval EFI_INVALID_PARAMETER The parameter is invaid
317 @retval EFI_SUCCESS The information is got
318 @retval Others Failed to get the information.
324 IN EFI_MTFTP4_PROTOCOL
*This
,
325 IN EFI_MTFTP4_OVERRIDE_DATA
*OverrideData
, OPTIONAL
327 IN UINT8
*ModeStr
, OPTIONAL
328 IN UINT8 OptionCount
,
329 IN EFI_MTFTP4_OPTION
*OptionList
,
330 OUT UINT32
*PacketLength
,
331 OUT EFI_MTFTP4_PACKET
**Packet OPTIONAL
334 EFI_MTFTP4_TOKEN Token
;
335 MTFTP4_PROTOCOL
*Instance
;
336 MTFTP4_GETINFO_STATE
*State
;
339 if ((This
== NULL
) || (Filename
== NULL
) || (PacketLength
== NULL
) ||
340 (OptionCount
&& (OptionList
== NULL
))) {
341 return EFI_INVALID_PARAMETER
;
344 if (Packet
!= NULL
) {
349 Instance
= MTFTP4_PROTOCOL_FROM_THIS (This
);
350 State
= &Instance
->GetInfoState
;
351 State
->Packet
= Packet
;
352 State
->PacketLen
= PacketLength
;
353 State
->Status
= EFI_SUCCESS
;
356 // Fill in the Token to issue an synchronous ReadFile operation
358 Token
.Status
= EFI_SUCCESS
;
360 Token
.OverrideData
= OverrideData
;
361 Token
.Filename
= Filename
;
362 Token
.ModeStr
= ModeStr
;
363 Token
.OptionCount
= OptionCount
;
364 Token
.OptionList
= OptionList
;
365 Token
.BufferSize
= 0;
367 Token
.CheckPacket
= Mtftp4GetInfoCheckPacket
;
368 Token
.TimeoutCallback
= NULL
;
369 Token
.PacketNeeded
= NULL
;
371 Status
= EfiMtftp4ReadFile (This
, &Token
);
373 if (EFI_ABORTED
== Status
) {
374 return State
->Status
;
382 Parse the packet into an array of options. The OptionList is allocated
383 by this function, and caller should free it when used.
385 @param This The MTFTP protocol instance
386 @param PacketLen The length of the packet
387 @param Packet The packet to parse
388 @param OptionCount The size of the OptionList array allocated.
389 @param OptionList The allocated option array to save the option
392 @retval EFI_INVALID_PARAMETER The parameters are invalid.
393 @retval EFI_NOT_FOUND There is no valid option in the packet
394 @retval EFI_SUCCESS The packet is parsed.
399 EfiMtftp4ParseOptions (
400 IN EFI_MTFTP4_PROTOCOL
*This
,
402 IN EFI_MTFTP4_PACKET
*Packet
,
403 IN OUT UINT32
*OptionCount
,
404 OUT EFI_MTFTP4_OPTION
**OptionList OPTIONAL
409 if ((This
== NULL
) || (PacketLen
< MTFTP4_OPCODE_LEN
) ||
410 (Packet
== NULL
) || (OptionCount
== NULL
)) {
412 return EFI_INVALID_PARAMETER
;
415 Status
= Mtftp4ExtractOptions (Packet
, PacketLen
, OptionCount
, OptionList
);
417 if (EFI_ERROR (Status
)) {
421 if (*OptionCount
== 0) {
422 return EFI_NOT_FOUND
;
430 Check whether the override data is valid. It will first
431 validate whether the server is a valid unicast. If a gateway
432 is provided in the Override, it also check that it is a
433 unicast on the connected network.
435 @param Instance The MTFTP instance
436 @param Override The override data to validate.
438 @return TRUE if the override data is valid, otherwise FALSE.
442 Mtftp4OverrideValid (
443 IN MTFTP4_PROTOCOL
*Instance
,
444 IN EFI_MTFTP4_OVERRIDE_DATA
*Override
447 EFI_MTFTP4_CONFIG_DATA
*Config
;
452 CopyMem (&Ip
, &Override
->ServerIp
, sizeof (IP4_ADDR
));
453 if (!Ip4IsUnicast (NTOHL (Ip
), 0)) {
457 Config
= &Instance
->Config
;
459 CopyMem (&Gateway
, &Override
->GatewayIp
, sizeof (IP4_ADDR
));
460 Gateway
= NTOHL (Gateway
);
462 if (!Config
->UseDefaultSetting
&& (Gateway
!= 0)) {
463 CopyMem (&Netmask
, &Config
->SubnetMask
, sizeof (IP4_ADDR
));
464 CopyMem (&Ip
, &Config
->StationIp
, sizeof (IP4_ADDR
));
466 Netmask
= NTOHL (Netmask
);
469 if (!Ip4IsUnicast (Gateway
, Netmask
) || !IP4_NET_EQUAL (Gateway
, Ip
, Netmask
)) {
479 Poll the UDP to get the IP4 default address, which may be retrieved
480 by DHCP. The default time out value is 5 seconds. If IP has retrieved
481 the default address, the UDP is reconfigured.
483 @param Instance The Mtftp instance
484 @param UdpPort The UDP port to poll
485 @param UdpCfgData The UDP configure data to reconfigure the UDP
488 @return TRUE if the default address is retrieved and UDP is reconfigured.
489 @return Otherwise FALSE.
494 IN MTFTP4_PROTOCOL
*Instance
,
495 IN UDP_IO_PORT
*UdpPort
,
496 IN EFI_UDP4_CONFIG_DATA
*UdpCfgData
499 MTFTP4_SERVICE
*Service
;
500 EFI_IP4_MODE_DATA Ip4Mode
;
501 EFI_UDP4_PROTOCOL
*Udp
;
504 ASSERT (Instance
->Config
.UseDefaultSetting
);
506 Service
= Instance
->Service
;
509 Status
= gBS
->SetTimer (
510 Service
->TimerToGetMap
,
512 MTFTP4_TIME_TO_GETMAP
* TICKS_PER_SECOND
514 if (EFI_ERROR (Status
)) {
518 while (!EFI_ERROR (gBS
->CheckEvent (Service
->TimerToGetMap
))) {
521 if (!EFI_ERROR (Udp
->GetModeData (Udp
, NULL
, &Ip4Mode
, NULL
, NULL
)) &&
522 Ip4Mode
.IsConfigured
) {
524 Udp
->Configure (Udp
, NULL
);
525 return (BOOLEAN
) (Udp
->Configure (Udp
, UdpCfgData
) == EFI_SUCCESS
);
534 Configure the UDP port for unicast receiving.
536 @param UdpIo The UDP port
537 @param Instance The MTFTP session
539 @retval EFI_SUCCESS The UDP port is successfully configured for the
540 session to unicast receive.
544 Mtftp4ConfigUnicastPort (
545 IN UDP_IO_PORT
*UdpIo
,
546 IN MTFTP4_PROTOCOL
*Instance
549 EFI_MTFTP4_CONFIG_DATA
*Config
;
550 EFI_UDP4_CONFIG_DATA UdpConfig
;
554 Config
= &Instance
->Config
;
556 UdpConfig
.AcceptBroadcast
= FALSE
;
557 UdpConfig
.AcceptPromiscuous
= FALSE
;
558 UdpConfig
.AcceptAnyPort
= FALSE
;
559 UdpConfig
.AllowDuplicatePort
= FALSE
;
560 UdpConfig
.TypeOfService
= 0;
561 UdpConfig
.TimeToLive
= 64;
562 UdpConfig
.DoNotFragment
= FALSE
;
563 UdpConfig
.ReceiveTimeout
= 0;
564 UdpConfig
.TransmitTimeout
= 0;
565 UdpConfig
.UseDefaultAddress
= Config
->UseDefaultSetting
;
566 UdpConfig
.StationAddress
= Config
->StationIp
;
567 UdpConfig
.SubnetMask
= Config
->SubnetMask
;
568 UdpConfig
.StationPort
= 0;
569 UdpConfig
.RemotePort
= 0;
571 Ip
= HTONL (Instance
->ServerIp
);
572 CopyMem (&UdpConfig
.RemoteAddress
, &Ip
, sizeof (EFI_IPv4_ADDRESS
));
574 Status
= UdpIo
->Udp
->Configure (UdpIo
->Udp
, &UdpConfig
);
576 if ((Status
== EFI_NO_MAPPING
) && Mtftp4GetMapping (Instance
, UdpIo
, &UdpConfig
)) {
580 if (!Config
->UseDefaultSetting
&& !EFI_IP4_EQUAL (&mZeroIp4Addr
, &Config
->GatewayIp
)) {
582 // The station IP address is manually configured and the Gateway IP is not 0.
583 // Add the default route for this UDP instance.
585 Status
= UdpIo
->Udp
->Routes (UdpIo
->Udp
, FALSE
, &mZeroIp4Addr
, &mZeroIp4Addr
, &Config
->GatewayIp
);
586 if (EFI_ERROR (Status
)) {
587 UdpIo
->Udp
->Configure (UdpIo
->Udp
, NULL
);
595 Start the MTFTP session to do the operation, such as read file,
596 write file, and read directory.
598 @param This The MTFTP session
599 @param Token The token than encapsues the user's request.
600 @param Operation The operation to do
602 @retval EFI_INVALID_PARAMETER Some of the parameters are invalid.
603 @retval EFI_NOT_STARTED The MTFTP session hasn't been configured.
604 @retval EFI_ALREADY_STARTED There is pending operation for the session.
605 @retval EFI_SUCCESS The operation is successfully started.
610 IN EFI_MTFTP4_PROTOCOL
*This
,
611 IN EFI_MTFTP4_TOKEN
*Token
,
615 MTFTP4_PROTOCOL
*Instance
;
616 EFI_MTFTP4_OVERRIDE_DATA
*Override
;
617 EFI_MTFTP4_CONFIG_DATA
*Config
;
622 // Validate the parameters
624 if ((This
== NULL
) || (Token
== NULL
) || (Token
->Filename
== NULL
) ||
625 ((Token
->OptionCount
!= 0) && (Token
->OptionList
== NULL
))) {
626 return EFI_INVALID_PARAMETER
;
630 // User must provide at least one method to collect the data for download.
632 if (((Operation
== EFI_MTFTP4_OPCODE_RRQ
) || (Operation
== EFI_MTFTP4_OPCODE_DIR
)) &&
633 ((Token
->Buffer
== NULL
) && (Token
->CheckPacket
== NULL
))) {
634 return EFI_INVALID_PARAMETER
;
638 // User must provide at least one method to provide the data for upload.
640 if ((Operation
== EFI_MTFTP4_OPCODE_WRQ
) &&
641 ((Token
->Buffer
== NULL
) && (Token
->PacketNeeded
== NULL
))) {
642 return EFI_INVALID_PARAMETER
;
645 Instance
= MTFTP4_PROTOCOL_FROM_THIS (This
);
647 Status
= EFI_SUCCESS
;
648 OldTpl
= gBS
->RaiseTPL (TPL_CALLBACK
);
650 if (Instance
->State
!= MTFTP4_STATE_CONFIGED
) {
651 Status
= EFI_NOT_STARTED
;
654 if (Instance
->Operation
!= 0) {
655 Status
= EFI_ACCESS_DENIED
;
658 if (EFI_ERROR (Status
)) {
659 gBS
->RestoreTPL (OldTpl
);
664 // Set the Operation now to prevent the application start other
667 Instance
->Operation
= Operation
;
668 Override
= Token
->OverrideData
;
670 if ((Override
!= NULL
) && !Mtftp4OverrideValid (Instance
, Override
)) {
671 Status
= EFI_INVALID_PARAMETER
;
675 if (Token
->OptionCount
!= 0) {
676 Status
= Mtftp4ParseOption (
680 &Instance
->RequestOption
683 if (EFI_ERROR (Status
)) {
689 // Set the operation parameters from the configuration or override data.
691 Config
= &Instance
->Config
;
692 Instance
->Token
= Token
;
693 Instance
->BlkSize
= MTFTP4_DEFAULT_BLKSIZE
;
695 CopyMem (&Instance
->ServerIp
, &Config
->ServerIp
, sizeof (IP4_ADDR
));
696 Instance
->ServerIp
= NTOHL (Instance
->ServerIp
);
698 Instance
->ListeningPort
= Config
->InitialServerPort
;
699 Instance
->ConnectedPort
= 0;
701 CopyMem (&Instance
->Gateway
, &Config
->GatewayIp
, sizeof (IP4_ADDR
));
702 Instance
->Gateway
= NTOHL (Instance
->Gateway
);
704 Instance
->MaxRetry
= Config
->TryCount
;
705 Instance
->Timeout
= Config
->TimeoutValue
;
706 Instance
->Master
= TRUE
;
708 if (Override
!= NULL
) {
709 CopyMem (&Instance
->ServerIp
, &Override
->ServerIp
, sizeof (IP4_ADDR
));
710 CopyMem (&Instance
->Gateway
, &Override
->GatewayIp
, sizeof (IP4_ADDR
));
712 Instance
->ServerIp
= NTOHL (Instance
->ServerIp
);
713 Instance
->Gateway
= NTOHL (Instance
->Gateway
);
715 Instance
->ListeningPort
= Override
->ServerPort
;
716 Instance
->MaxRetry
= Override
->TryCount
;
717 Instance
->Timeout
= Override
->TimeoutValue
;
720 if (Instance
->ListeningPort
== 0) {
721 Instance
->ListeningPort
= MTFTP4_DEFAULT_SERVER_PORT
;
724 if (Instance
->MaxRetry
== 0) {
725 Instance
->MaxRetry
= MTFTP4_DEFAULT_RETRY
;
728 if (Instance
->Timeout
== 0) {
729 Instance
->Timeout
= MTFTP4_DEFAULT_TIMEOUT
;
733 // Config the unicast UDP child to send initial request
735 Status
= Mtftp4ConfigUnicastPort (Instance
->UnicastPort
, Instance
);
737 if (EFI_ERROR (Status
)) {
742 // Set initial status.
744 Token
->Status
= EFI_NOT_READY
;
747 // Build and send an initial requests
749 if (Operation
== EFI_MTFTP4_OPCODE_WRQ
) {
750 Status
= Mtftp4WrqStart (Instance
, Operation
);
752 Status
= Mtftp4RrqStart (Instance
, Operation
);
755 gBS
->RestoreTPL (OldTpl
);
757 if (EFI_ERROR (Status
)) {
761 if (Token
->Event
!= NULL
) {
766 // Return immediately for asynchronous operation or poll the
767 // instance for synchronous operation.
769 while (Token
->Status
== EFI_NOT_READY
) {
773 return Token
->Status
;
776 Mtftp4CleanOperation (Instance
, Status
);
777 gBS
->RestoreTPL (OldTpl
);
784 Read a file from the server.
786 @param This The Mtftp protocol instance.
787 @param Token The user's request wrap token.
789 @retval EFI_SUCCESS The ReadFile has finished, the file has been
790 downloaded if it is synchronous operation,
791 otherwise it has been initated.
792 @retval Others Some error happened.
798 IN EFI_MTFTP4_PROTOCOL
*This
,
799 IN EFI_MTFTP4_TOKEN
*Token
802 return Mtftp4Start (This
, Token
, EFI_MTFTP4_OPCODE_RRQ
);
807 Upload a file to the server.
809 @param This The MTFTP protocol session
810 @param Token The user's request wrap token.
812 @retval EFI_SUCCESS The WriteFile has finished, the file has been
813 uploaded if it is synchronous operation, otherwise
814 it has been initated.
815 @retval Others Some error happened.
821 IN EFI_MTFTP4_PROTOCOL
*This
,
822 IN EFI_MTFTP4_TOKEN
*Token
825 return Mtftp4Start (This
, Token
, EFI_MTFTP4_OPCODE_WRQ
);
830 Read a directory from the server. The only difference
831 between ReadFile and ReadDirectory is the opcode used.
833 @param This The MTFTP protocol session
834 @param Token The user's request wrap token.
836 @retval EFI_SUCCESS The ReadDirectory has finished, the directory has
837 been downloaded as a file if it is synchronous
838 operation, otherwise it has been initated.
839 @retval Others Some error happened.
844 EfiMtftp4ReadDirectory (
845 IN EFI_MTFTP4_PROTOCOL
*This
,
846 IN EFI_MTFTP4_TOKEN
*Token
849 return Mtftp4Start (This
, Token
, EFI_MTFTP4_OPCODE_DIR
);
854 Poll the network stack to accelerate the packet process.
856 @param This The MTFTP protocol instance.
858 @retval EFI_INVALID_PARAMETER This is NULL.
859 @retval EFI_NOT_STARTED The MTFTP session hasn't been configured.
860 @retval EFI_DEVICE_ERROR The MTFTP session has been destoried.
866 IN EFI_MTFTP4_PROTOCOL
*This
869 MTFTP4_PROTOCOL
*Instance
;
870 EFI_UDP4_PROTOCOL
*Udp
;
873 return EFI_INVALID_PARAMETER
;
876 Instance
= MTFTP4_PROTOCOL_FROM_THIS (This
);
878 if (Instance
->State
== MTFTP4_STATE_UNCONFIGED
) {
879 return EFI_NOT_STARTED
;
880 } else if (Instance
->State
== MTFTP4_STATE_DESTORY
) {
881 return EFI_DEVICE_ERROR
;
884 Udp
= Instance
->UnicastPort
->Udp
;
885 return Udp
->Poll (Udp
);
888 EFI_MTFTP4_PROTOCOL gMtftp4ProtocolTemplate
= {
889 EfiMtftp4GetModeData
,
892 EfiMtftp4ParseOptions
,
895 EfiMtftp4ReadDirectory
,