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 CopyMem(&ModeData
->ConfigData
, &Instance
->Config
, sizeof (Instance
->Config
));
63 ModeData
->SupportedOptionCount
= MTFTP4_SUPPORTED_OPTIONS
;
64 ModeData
->SupportedOptoins
= (UINT8
**) 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 CopyMem(&Instance
->Config
, ConfigData
, sizeof (*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
)) {
588 if (!Config
->UseDefaultSetting
&& !EFI_IP4_EQUAL (&mZeroIp4Addr
, &Config
->GatewayIp
)) {
590 // The station IP address is manually configured and the Gateway IP is not 0.
591 // Add the default route for this UDP instance.
593 Status
= UdpIo
->Udp
->Routes (UdpIo
->Udp
, FALSE
, &mZeroIp4Addr
, &mZeroIp4Addr
, &Config
->GatewayIp
);
594 if (EFI_ERROR (Status
)) {
595 UdpIo
->Udp
->Configure (UdpIo
->Udp
, NULL
);
603 Start the MTFTP session to do the operation, such as read file,
604 write file, and read directory.
606 @param This The MTFTP session
607 @param Token The token than encapsues the user's request.
608 @param Operation The operation to do
610 @retval EFI_INVALID_PARAMETER Some of the parameters are invalid.
611 @retval EFI_NOT_STARTED The MTFTP session hasn't been configured.
612 @retval EFI_ALREADY_STARTED There is pending operation for the session.
613 @retval EFI_SUCCESS The operation is successfully started.
619 IN EFI_MTFTP4_PROTOCOL
*This
,
620 IN EFI_MTFTP4_TOKEN
*Token
,
624 MTFTP4_PROTOCOL
*Instance
;
625 EFI_MTFTP4_OVERRIDE_DATA
*Override
;
626 EFI_MTFTP4_CONFIG_DATA
*Config
;
631 // Validate the parameters
633 if ((This
== NULL
) || (Token
== NULL
) || (Token
->Filename
== NULL
) ||
634 ((Token
->OptionCount
!= 0) && (Token
->OptionList
== NULL
))) {
635 return EFI_INVALID_PARAMETER
;
639 // User must provide at least one method to collect the data for download.
641 if (((Operation
== EFI_MTFTP4_OPCODE_RRQ
) || (Operation
== EFI_MTFTP4_OPCODE_DIR
)) &&
642 ((Token
->Buffer
== NULL
) && (Token
->CheckPacket
== NULL
))) {
643 return EFI_INVALID_PARAMETER
;
647 // User must provide at least one method to provide the data for upload.
649 if ((Operation
== EFI_MTFTP4_OPCODE_WRQ
) &&
650 ((Token
->Buffer
== NULL
) && (Token
->PacketNeeded
== NULL
))) {
651 return EFI_INVALID_PARAMETER
;
654 Instance
= MTFTP4_PROTOCOL_FROM_THIS (This
);
656 Status
= EFI_SUCCESS
;
657 OldTpl
= NET_RAISE_TPL (NET_TPL_LOCK
);
659 if (Instance
->State
!= MTFTP4_STATE_CONFIGED
) {
660 Status
= EFI_NOT_STARTED
;
663 if (Instance
->Operation
!= 0) {
664 Status
= EFI_ACCESS_DENIED
;
667 if (EFI_ERROR (Status
)) {
668 NET_RESTORE_TPL (OldTpl
);
673 // Set the Operation now to prevent the application start other
676 Instance
->Operation
= Operation
;
677 Override
= Token
->OverrideData
;
679 if ((Override
!= NULL
) && !Mtftp4OverrideValid (Instance
, Override
)) {
680 Status
= EFI_INVALID_PARAMETER
;
684 if (Token
->OptionCount
!= 0) {
685 Status
= Mtftp4ParseOption (
689 &Instance
->RequestOption
692 if (EFI_ERROR (Status
)) {
698 // Set the operation parameters from the configuration or override data.
700 Config
= &Instance
->Config
;
701 Instance
->Token
= Token
;
702 Instance
->BlkSize
= MTFTP4_DEFAULT_BLKSIZE
;
704 NetCopyMem (&Instance
->ServerIp
, &Config
->ServerIp
, sizeof (IP4_ADDR
));
705 Instance
->ServerIp
= NTOHL (Instance
->ServerIp
);
707 Instance
->ListeningPort
= Config
->InitialServerPort
;
708 Instance
->ConnectedPort
= 0;
710 NetCopyMem (&Instance
->Gateway
, &Config
->GatewayIp
, sizeof (IP4_ADDR
));
711 Instance
->Gateway
= NTOHL (Instance
->Gateway
);
713 Instance
->MaxRetry
= Config
->TryCount
;
714 Instance
->Timeout
= Config
->TimeoutValue
;
715 Instance
->Master
= TRUE
;
717 if (Override
!= NULL
) {
718 NetCopyMem (&Instance
->ServerIp
, &Override
->ServerIp
, sizeof (IP4_ADDR
));
719 NetCopyMem (&Instance
->Gateway
, &Override
->GatewayIp
, sizeof (IP4_ADDR
));
721 Instance
->ServerIp
= NTOHL (Instance
->ServerIp
);
722 Instance
->Gateway
= NTOHL (Instance
->Gateway
);
724 Instance
->ListeningPort
= Override
->ServerPort
;
725 Instance
->MaxRetry
= Override
->TryCount
;
726 Instance
->Timeout
= Override
->TimeoutValue
;
729 if (Instance
->ListeningPort
== 0) {
730 Instance
->ListeningPort
= MTFTP4_DEFAULT_SERVER_PORT
;
733 if (Instance
->MaxRetry
== 0) {
734 Instance
->MaxRetry
= MTFTP4_DEFAULT_RETRY
;
737 if (Instance
->Timeout
== 0) {
738 Instance
->Timeout
= MTFTP4_DEFAULT_TIMEOUT
;
742 // Config the unicast UDP child to send initial request
744 Status
= Mtftp4ConfigUnicastPort (Instance
->UnicastPort
, Instance
);
746 if (EFI_ERROR (Status
)) {
751 // Build and send an initial requests
753 if (Operation
== EFI_MTFTP4_OPCODE_WRQ
) {
754 Status
= Mtftp4WrqStart (Instance
, Operation
);
756 Status
= Mtftp4RrqStart (Instance
, Operation
);
759 NET_RESTORE_TPL (OldTpl
);
761 if (EFI_ERROR (Status
)) {
765 // Return immediately for asynchronous operation or poll the
766 // instance for synchronous operation.
768 Token
->Status
= EFI_NOT_READY
;
770 if (Token
->Event
!= NULL
) {
774 while (Token
->Status
== EFI_NOT_READY
) {
778 return Token
->Status
;
781 Mtftp4CleanOperation (Instance
, Status
);
782 NET_RESTORE_TPL (OldTpl
);
789 Read a file from the server.
791 @param This The Mtftp protocol instance.
792 @param Token The user's request wrap token.
794 @retval EFI_SUCCESS The ReadFile has finished, the file has been
795 downloaded if it is synchronous operation,
796 otherwise it has been initated.
797 @retval Others Some error happened.
804 IN EFI_MTFTP4_PROTOCOL
*This
,
805 IN EFI_MTFTP4_TOKEN
*Token
808 return Mtftp4Start (This
, Token
, EFI_MTFTP4_OPCODE_RRQ
);
813 Upload a file to the server.
815 @param This The MTFTP protocol session
816 @param Token The user's request wrap token.
818 @retval EFI_SUCCESS The WriteFile has finished, the file has been
819 uploaded if it is synchronous operation, otherwise
820 it has been initated.
821 @retval Others Some error happened.
828 IN EFI_MTFTP4_PROTOCOL
*This
,
829 IN EFI_MTFTP4_TOKEN
*Token
832 return Mtftp4Start (This
, Token
, EFI_MTFTP4_OPCODE_WRQ
);
837 Read a directory from the server. The only difference
838 between ReadFile and ReadDirectory is the opcode used.
840 @param This The MTFTP protocol session
841 @param Token The user's request wrap token.
843 @retval EFI_SUCCESS The ReadDirectory has finished, the directory has
844 been downloaded as a file if it is synchronous
845 operation, otherwise it has been initated.
846 @retval Others Some error happened.
852 EfiMtftp4ReadDirectory (
853 IN EFI_MTFTP4_PROTOCOL
*This
,
854 IN EFI_MTFTP4_TOKEN
*Token
857 return Mtftp4Start (This
, Token
, EFI_MTFTP4_OPCODE_DIR
);
862 Poll the network stack to accelerate the packet process.
864 @param This The MTFTP protocol instance.
866 @retval EFI_INVALID_PARAMETER This is NULL.
867 @retval EFI_NOT_STARTED The MTFTP session hasn't been configured.
868 @retval EFI_DEVICE_ERROR The MTFTP session has been destoried.
875 IN EFI_MTFTP4_PROTOCOL
*This
878 MTFTP4_PROTOCOL
*Instance
;
879 EFI_UDP4_PROTOCOL
*Udp
;
882 return EFI_INVALID_PARAMETER
;
885 Instance
= MTFTP4_PROTOCOL_FROM_THIS (This
);
887 if (Instance
->State
== MTFTP4_STATE_UNCONFIGED
) {
888 return EFI_NOT_STARTED
;
889 } else if (Instance
->State
== MTFTP4_STATE_DESTORY
) {
890 return EFI_DEVICE_ERROR
;
893 Udp
= Instance
->UnicastPort
->Udp
;
894 return Udp
->Poll (Udp
);
897 EFI_MTFTP4_PROTOCOL gMtftp4ProtocolTemplate
= {
898 EfiMtftp4GetModeData
,
901 EfiMtftp4ParseOptions
,
904 EfiMtftp4ReadDirectory
,