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
18 #ifndef __EFI_MTFTP4_IMPL_H__
19 #define __EFI_MTFTP4_IMPL_H__
23 #include <Protocol/Udp4.h>
24 #include <Protocol/Mtftp4.h>
26 #include <Library/DebugLib.h>
27 #include <Library/BaseMemoryLib.h>
28 #include <Library/MemoryAllocationLib.h>
29 #include <Library/UefiBootServicesTableLib.h>
30 #include <Library/UdpIoLib.h>
31 #include <Library/PrintLib.h>
33 extern EFI_MTFTP4_PROTOCOL gMtftp4ProtocolTemplate
;
35 typedef struct _MTFTP4_SERVICE MTFTP4_SERVICE
;
36 typedef struct _MTFTP4_PROTOCOL MTFTP4_PROTOCOL
;
38 #include "Mtftp4Driver.h"
39 #include "Mtftp4Option.h"
40 #include "Mtftp4Support.h"
43 /// Some constant value of Mtftp service.
45 #define MTFTP4_SERVICE_SIGNATURE SIGNATURE_32 ('T', 'F', 'T', 'P')
46 #define MTFTP4_PROTOCOL_SIGNATURE SIGNATURE_32 ('t', 'f', 't', 'p')
48 #define MTFTP4_DEFAULT_SERVER_PORT 69
49 #define MTFTP4_DEFAULT_TIMEOUT 3
50 #define MTFTP4_DEFAULT_RETRY 5
51 #define MTFTP4_DEFAULT_BLKSIZE 512
52 #define MTFTP4_DEFAULT_WINDOWSIZE 1
53 #define MTFTP4_TIME_TO_GETMAP 5
55 #define MTFTP4_STATE_UNCONFIGED 0
56 #define MTFTP4_STATE_CONFIGED 1
57 #define MTFTP4_STATE_DESTROY 2
60 /// Mtftp service block
62 struct _MTFTP4_SERVICE
{
64 EFI_SERVICE_BINDING_PROTOCOL ServiceBinding
;
69 EFI_EVENT Timer
; ///< Ticking timer for all the MTFTP clients to handle the packet timeout case.
70 EFI_EVENT TimerNotifyLevel
; ///< Ticking timer for all the MTFTP clients to calculate the packet live time.
71 EFI_EVENT TimerToGetMap
;
73 EFI_HANDLE Controller
;
77 // This UDP child is used to keep the connection between the UDP
78 // and MTFTP, so MTFTP will be notified when UDP is uninstalled.
84 EFI_MTFTP4_PACKET
**Packet
;
87 } MTFTP4_GETINFO_STATE
;
89 struct _MTFTP4_PROTOCOL
{
92 EFI_MTFTP4_PROTOCOL Mtftp4
;
97 MTFTP4_SERVICE
*Service
;
100 EFI_MTFTP4_CONFIG_DATA Config
;
103 // Operation parameters: token and requested options.
105 EFI_MTFTP4_TOKEN
*Token
;
106 MTFTP4_OPTION RequestOption
;
110 // Blocks is a list of MTFTP4_BLOCK_RANGE which contains
120 // Record the total received and saved block number.
125 // Record the acked block number.
130 // The server's communication end point: IP and two ports. one for
131 // initial request, one for its selected port.
134 UINT16 ListeningPort
;
135 UINT16 ConnectedPort
;
140 // Timeout and retransmit status
150 // Parameter used by RRQ's multicast download.
155 UDP_IO
*McastUdpPort
;
159 EFI_SERVICE_BINDING_PROTOCOL
*ServiceBinding
;
160 UINTN NumberOfChildren
;
161 EFI_HANDLE
*ChildHandleBuffer
;
162 } MTFTP4_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT
;
165 Clean up the MTFTP session to get ready for new operation.
167 @param Instance The MTFTP session to clean up
168 @param Result The result to return to the caller who initiated
172 Mtftp4CleanOperation (
173 IN OUT MTFTP4_PROTOCOL
*Instance
,
178 Start the MTFTP session for upload.
180 It will first init some states, then send the WRQ request packet,
181 and start receiving the packet.
183 @param Instance The MTFTP session
184 @param Operation Redundant parameter, which is always
185 EFI_MTFTP4_OPCODE_WRQ here.
187 @retval EFI_SUCCESS The upload process has been started.
188 @retval Others Failed to start the upload.
193 IN MTFTP4_PROTOCOL
*Instance
,
198 Start the MTFTP session to download.
200 It will first initialize some of the internal states then build and send a RRQ
201 request packet, at last, it will start receive for the downloading.
203 @param Instance The Mtftp session
204 @param Operation The MTFTP opcode, it may be a EFI_MTFTP4_OPCODE_RRQ
205 or EFI_MTFTP4_OPCODE_DIR.
207 @retval EFI_SUCCESS The mtftp download session is started.
208 @retval Others Failed to start downloading.
213 IN MTFTP4_PROTOCOL
*Instance
,
217 #define MTFTP4_SERVICE_FROM_THIS(a) \
218 CR (a, MTFTP4_SERVICE, ServiceBinding, MTFTP4_SERVICE_SIGNATURE)
220 #define MTFTP4_PROTOCOL_FROM_THIS(a) \
221 CR (a, MTFTP4_PROTOCOL, Mtftp4, MTFTP4_PROTOCOL_SIGNATURE)