5 Mtftp4 Implementation, it supports the following RFCs:
6 RFC1350 - THE TFTP PROTOCOL (REVISION 2)
7 RFC2090 - TFTP Multicast Option
8 RFC2347 - TFTP Option Extension
9 RFC2348 - TFTP Blocksize Option
10 RFC2349 - TFTP Timeout Interval and Transfer Size Options
11 RFC7440 - TFTP Windowsize Option
13 Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
14 This program and the accompanying materials
15 are licensed and made available under the terms and conditions of the BSD License
16 which accompanies this distribution. The full text of the license may be found at
17 http://opensource.org/licenses/bsd-license.php<BR>
19 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
20 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
25 #ifndef __EFI_MTFTP4_IMPL_H__
26 #define __EFI_MTFTP4_IMPL_H__
30 #include <Protocol/Udp4.h>
31 #include <Protocol/Mtftp4.h>
33 #include <Library/DebugLib.h>
34 #include <Library/BaseMemoryLib.h>
35 #include <Library/MemoryAllocationLib.h>
36 #include <Library/UefiBootServicesTableLib.h>
37 #include <Library/UdpIoLib.h>
38 #include <Library/PrintLib.h>
40 extern EFI_MTFTP4_PROTOCOL gMtftp4ProtocolTemplate
;
42 typedef struct _MTFTP4_SERVICE MTFTP4_SERVICE
;
43 typedef struct _MTFTP4_PROTOCOL MTFTP4_PROTOCOL
;
45 #include "Mtftp4Driver.h"
46 #include "Mtftp4Option.h"
47 #include "Mtftp4Support.h"
51 /// Some constant value of Mtftp service.
53 #define MTFTP4_SERVICE_SIGNATURE SIGNATURE_32 ('T', 'F', 'T', 'P')
54 #define MTFTP4_PROTOCOL_SIGNATURE SIGNATURE_32 ('t', 'f', 't', 'p')
56 #define MTFTP4_DEFAULT_SERVER_PORT 69
57 #define MTFTP4_DEFAULT_TIMEOUT 3
58 #define MTFTP4_DEFAULT_RETRY 5
59 #define MTFTP4_DEFAULT_BLKSIZE 512
60 #define MTFTP4_DEFAULT_WINDOWSIZE 1
61 #define MTFTP4_TIME_TO_GETMAP 5
63 #define MTFTP4_STATE_UNCONFIGED 0
64 #define MTFTP4_STATE_CONFIGED 1
65 #define MTFTP4_STATE_DESTROY 2
68 /// Mtftp service block
70 struct _MTFTP4_SERVICE
{
72 EFI_SERVICE_BINDING_PROTOCOL ServiceBinding
;
77 EFI_EVENT Timer
; ///< Ticking timer for all the MTFTP clients to handle the packet timeout case.
78 EFI_EVENT TimerNotifyLevel
; ///< Ticking timer for all the MTFTP clients to calculate the packet live time.
79 EFI_EVENT TimerToGetMap
;
81 EFI_HANDLE Controller
;
85 // This UDP child is used to keep the connection between the UDP
86 // and MTFTP, so MTFTP will be notified when UDP is uninstalled.
93 EFI_MTFTP4_PACKET
**Packet
;
96 } MTFTP4_GETINFO_STATE
;
98 struct _MTFTP4_PROTOCOL
{
101 EFI_MTFTP4_PROTOCOL Mtftp4
;
106 MTFTP4_SERVICE
*Service
;
109 EFI_MTFTP4_CONFIG_DATA Config
;
112 // Operation parameters: token and requested options.
114 EFI_MTFTP4_TOKEN
*Token
;
115 MTFTP4_OPTION RequestOption
;
119 // Blocks is a list of MTFTP4_BLOCK_RANGE which contains
129 // Record the total received and saved block number.
134 // Record the acked block number.
139 // The server's communication end point: IP and two ports. one for
140 // initial request, one for its selected port.
143 UINT16 ListeningPort
;
144 UINT16 ConnectedPort
;
149 // Timeout and retransmit status
159 // Parameter used by RRQ's multicast download.
164 UDP_IO
*McastUdpPort
;
168 EFI_SERVICE_BINDING_PROTOCOL
*ServiceBinding
;
169 UINTN NumberOfChildren
;
170 EFI_HANDLE
*ChildHandleBuffer
;
171 } MTFTP4_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT
;
174 Clean up the MTFTP session to get ready for new operation.
176 @param Instance The MTFTP session to clean up
177 @param Result The result to return to the caller who initiated
181 Mtftp4CleanOperation (
182 IN OUT MTFTP4_PROTOCOL
*Instance
,
187 Start the MTFTP session for upload.
189 It will first init some states, then send the WRQ request packet,
190 and start receiving the packet.
192 @param Instance The MTFTP session
193 @param Operation Redundant parameter, which is always
194 EFI_MTFTP4_OPCODE_WRQ here.
196 @retval EFI_SUCCESS The upload process has been started.
197 @retval Others Failed to start the upload.
202 IN MTFTP4_PROTOCOL
*Instance
,
207 Start the MTFTP session to download.
209 It will first initialize some of the internal states then build and send a RRQ
210 reqeuest packet, at last, it will start receive for the downloading.
212 @param Instance The Mtftp session
213 @param Operation The MTFTP opcode, it may be a EFI_MTFTP4_OPCODE_RRQ
214 or EFI_MTFTP4_OPCODE_DIR.
216 @retval EFI_SUCCESS The mtftp download session is started.
217 @retval Others Failed to start downloading.
222 IN MTFTP4_PROTOCOL
*Instance
,
226 #define MTFTP4_SERVICE_FROM_THIS(a) \
227 CR (a, MTFTP4_SERVICE, ServiceBinding, MTFTP4_SERVICE_SIGNATURE)
229 #define MTFTP4_PROTOCOL_FROM_THIS(a) \
230 CR (a, MTFTP4_PROTOCOL, Mtftp4, MTFTP4_PROTOCOL_SIGNATURE)