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 SPDX-License-Identifier: BSD-2-Clause-Patent
19 #ifndef __EFI_MTFTP4_IMPL_H__
20 #define __EFI_MTFTP4_IMPL_H__
24 #include <Protocol/Udp4.h>
25 #include <Protocol/Mtftp4.h>
27 #include <Library/DebugLib.h>
28 #include <Library/BaseMemoryLib.h>
29 #include <Library/MemoryAllocationLib.h>
30 #include <Library/UefiBootServicesTableLib.h>
31 #include <Library/UdpIoLib.h>
32 #include <Library/PrintLib.h>
34 extern EFI_MTFTP4_PROTOCOL gMtftp4ProtocolTemplate
;
36 typedef struct _MTFTP4_SERVICE MTFTP4_SERVICE
;
37 typedef struct _MTFTP4_PROTOCOL MTFTP4_PROTOCOL
;
39 #include "Mtftp4Driver.h"
40 #include "Mtftp4Option.h"
41 #include "Mtftp4Support.h"
45 /// Some constant value of Mtftp service.
47 #define MTFTP4_SERVICE_SIGNATURE SIGNATURE_32 ('T', 'F', 'T', 'P')
48 #define MTFTP4_PROTOCOL_SIGNATURE SIGNATURE_32 ('t', 'f', 't', 'p')
50 #define MTFTP4_DEFAULT_SERVER_PORT 69
51 #define MTFTP4_DEFAULT_TIMEOUT 3
52 #define MTFTP4_DEFAULT_RETRY 5
53 #define MTFTP4_DEFAULT_BLKSIZE 512
54 #define MTFTP4_DEFAULT_WINDOWSIZE 1
55 #define MTFTP4_TIME_TO_GETMAP 5
57 #define MTFTP4_STATE_UNCONFIGED 0
58 #define MTFTP4_STATE_CONFIGED 1
59 #define MTFTP4_STATE_DESTROY 2
62 /// Mtftp service block
64 struct _MTFTP4_SERVICE
{
66 EFI_SERVICE_BINDING_PROTOCOL ServiceBinding
;
71 EFI_EVENT Timer
; ///< Ticking timer for all the MTFTP clients to handle the packet timeout case.
72 EFI_EVENT TimerNotifyLevel
; ///< Ticking timer for all the MTFTP clients to calculate the packet live time.
73 EFI_EVENT TimerToGetMap
;
75 EFI_HANDLE Controller
;
79 // This UDP child is used to keep the connection between the UDP
80 // and MTFTP, so MTFTP will be notified when UDP is uninstalled.
87 EFI_MTFTP4_PACKET
**Packet
;
90 } MTFTP4_GETINFO_STATE
;
92 struct _MTFTP4_PROTOCOL
{
95 EFI_MTFTP4_PROTOCOL Mtftp4
;
100 MTFTP4_SERVICE
*Service
;
103 EFI_MTFTP4_CONFIG_DATA Config
;
106 // Operation parameters: token and requested options.
108 EFI_MTFTP4_TOKEN
*Token
;
109 MTFTP4_OPTION RequestOption
;
113 // Blocks is a list of MTFTP4_BLOCK_RANGE which contains
123 // Record the total received and saved block number.
128 // Record the acked block number.
133 // The server's communication end point: IP and two ports. one for
134 // initial request, one for its selected port.
137 UINT16 ListeningPort
;
138 UINT16 ConnectedPort
;
143 // Timeout and retransmit status
153 // Parameter used by RRQ's multicast download.
158 UDP_IO
*McastUdpPort
;
162 EFI_SERVICE_BINDING_PROTOCOL
*ServiceBinding
;
163 UINTN NumberOfChildren
;
164 EFI_HANDLE
*ChildHandleBuffer
;
165 } MTFTP4_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT
;
168 Clean up the MTFTP session to get ready for new operation.
170 @param Instance The MTFTP session to clean up
171 @param Result The result to return to the caller who initiated
175 Mtftp4CleanOperation (
176 IN OUT MTFTP4_PROTOCOL
*Instance
,
181 Start the MTFTP session for upload.
183 It will first init some states, then send the WRQ request packet,
184 and start receiving the packet.
186 @param Instance The MTFTP session
187 @param Operation Redundant parameter, which is always
188 EFI_MTFTP4_OPCODE_WRQ here.
190 @retval EFI_SUCCESS The upload process has been started.
191 @retval Others Failed to start the upload.
196 IN MTFTP4_PROTOCOL
*Instance
,
201 Start the MTFTP session to download.
203 It will first initialize some of the internal states then build and send a RRQ
204 reqeuest packet, at last, it will start receive for the downloading.
206 @param Instance The Mtftp session
207 @param Operation The MTFTP opcode, it may be a EFI_MTFTP4_OPCODE_RRQ
208 or EFI_MTFTP4_OPCODE_DIR.
210 @retval EFI_SUCCESS The mtftp download session is started.
211 @retval Others Failed to start downloading.
216 IN MTFTP4_PROTOCOL
*Instance
,
220 #define MTFTP4_SERVICE_FROM_THIS(a) \
221 CR (a, MTFTP4_SERVICE, ServiceBinding, MTFTP4_SERVICE_SIGNATURE)
223 #define MTFTP4_PROTOCOL_FROM_THIS(a) \
224 CR (a, MTFTP4_PROTOCOL, Mtftp4, MTFTP4_PROTOCOL_SIGNATURE)