]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Impl.h
MdeModulePkg: Remove the trailing space in three source files.
[mirror_edk2.git] / MdeModulePkg / Universal / Network / Mtftp4Dxe / Mtftp4Impl.h
CommitLineData
83cbd279 1/** @file\r
d1102dba 2\r
dab714aa 3 Mtftp4 Implementation.\r
d1102dba 4\r
dab714aa 5 Mtftp4 Implementation, it supports the following RFCs:\r
6 RFC1350 - THE TFTP PROTOCOL (REVISION 2)\r
7 RFC2090 - TFTP Multicast Option\r
8 RFC2347 - TFTP Option Extension\r
9 RFC2348 - TFTP Blocksize Option\r
10 RFC2349 - TFTP Timeout Interval and Transfer Size Options\r
6c047cfa 11 RFC7440 - TFTP Windowsize Option\r
d1102dba 12\r
0e2a5749 13Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
e5eed7d3 14This program and the accompanying materials\r
83cbd279 15are licensed and made available under the terms and conditions of the BSD License\r
16which accompanies this distribution. The full text of the license may be found at\r
dab714aa 17http://opensource.org/licenses/bsd-license.php<BR>\r
83cbd279 18\r
19THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
20WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
21\r
83cbd279 22**/\r
23\r
dab714aa 24\r
83cbd279 25#ifndef __EFI_MTFTP4_IMPL_H__\r
26#define __EFI_MTFTP4_IMPL_H__\r
27\r
dab714aa 28#include <Uefi.h>\r
772db4bb 29\r
30#include <Protocol/Udp4.h>\r
31#include <Protocol/Mtftp4.h>\r
32\r
33#include <Library/DebugLib.h>\r
cfb1461b 34#include <Library/BaseMemoryLib.h>\r
35#include <Library/MemoryAllocationLib.h>\r
772db4bb 36#include <Library/UefiBootServicesTableLib.h>\r
83cbd279 37#include <Library/UdpIoLib.h>\r
1f7eb561 38#include <Library/PrintLib.h>\r
dab714aa 39\r
40extern EFI_MTFTP4_PROTOCOL gMtftp4ProtocolTemplate;\r
83cbd279 41\r
42typedef struct _MTFTP4_SERVICE MTFTP4_SERVICE;\r
43typedef struct _MTFTP4_PROTOCOL MTFTP4_PROTOCOL;\r
44\r
45#include "Mtftp4Driver.h"\r
46#include "Mtftp4Option.h"\r
47#include "Mtftp4Support.h"\r
48\r
dab714aa 49\r
50///\r
51/// Some constant value of Mtftp service.\r
52///\r
f6b7393c 53#define MTFTP4_SERVICE_SIGNATURE SIGNATURE_32 ('T', 'F', 'T', 'P')\r
54#define MTFTP4_PROTOCOL_SIGNATURE SIGNATURE_32 ('t', 'f', 't', 'p')\r
55\r
56#define MTFTP4_DEFAULT_SERVER_PORT 69\r
57#define MTFTP4_DEFAULT_TIMEOUT 3\r
58#define MTFTP4_DEFAULT_RETRY 5\r
59#define MTFTP4_DEFAULT_BLKSIZE 512\r
6c047cfa 60#define MTFTP4_DEFAULT_WINDOWSIZE 1\r
f6b7393c 61#define MTFTP4_TIME_TO_GETMAP 5\r
62\r
63#define MTFTP4_STATE_UNCONFIGED 0\r
64#define MTFTP4_STATE_CONFIGED 1\r
75dce340 65#define MTFTP4_STATE_DESTROY 2\r
83cbd279 66\r
dab714aa 67///\r
68/// Mtftp service block\r
69///\r
83cbd279 70struct _MTFTP4_SERVICE {\r
71 UINT32 Signature;\r
72 EFI_SERVICE_BINDING_PROTOCOL ServiceBinding;\r
73\r
83cbd279 74 UINT16 ChildrenNum;\r
e48e37fc 75 LIST_ENTRY Children;\r
83cbd279 76\r
0e2a5749
FS
77 EFI_EVENT Timer; ///< Ticking timer for all the MTFTP clients to handle the packet timeout case.\r
78 EFI_EVENT TimerNotifyLevel; ///< Ticking timer for all the MTFTP clients to calculate the packet live time.\r
83cbd279 79 EFI_EVENT TimerToGetMap;\r
80\r
81 EFI_HANDLE Controller;\r
82 EFI_HANDLE Image;\r
83\r
84 //\r
85 // This UDP child is used to keep the connection between the UDP\r
86 // and MTFTP, so MTFTP will be notified when UDP is uninstalled.\r
87 //\r
b45b45b2 88 UDP_IO *ConnectUdp;\r
83cbd279 89};\r
90\r
dab714aa 91\r
61066b8d 92typedef struct {\r
93 EFI_MTFTP4_PACKET **Packet;\r
94 UINT32 *PacketLen;\r
95 EFI_STATUS Status;\r
96} MTFTP4_GETINFO_STATE;\r
97\r
83cbd279 98struct _MTFTP4_PROTOCOL {\r
99 UINT32 Signature;\r
e48e37fc 100 LIST_ENTRY Link;\r
83cbd279 101 EFI_MTFTP4_PROTOCOL Mtftp4;\r
102\r
103 INTN State;\r
75dce340 104 BOOLEAN InDestroy;\r
83cbd279 105\r
106 MTFTP4_SERVICE *Service;\r
107 EFI_HANDLE Handle;\r
108\r
109 EFI_MTFTP4_CONFIG_DATA Config;\r
110\r
111 //\r
112 // Operation parameters: token and requested options.\r
113 //\r
114 EFI_MTFTP4_TOKEN *Token;\r
115 MTFTP4_OPTION RequestOption;\r
116 UINT16 Operation;\r
117\r
118 //\r
119 // Blocks is a list of MTFTP4_BLOCK_RANGE which contains\r
120 // holes in the file\r
121 //\r
122 UINT16 BlkSize;\r
123 UINT16 LastBlock;\r
e48e37fc 124 LIST_ENTRY Blocks;\r
83cbd279 125\r
6c047cfa
JW
126 UINT16 WindowSize;\r
127\r
128 //\r
9202304c 129 // Record the total received and saved block number.\r
6c047cfa
JW
130 //\r
131 UINT64 TotalBlock;\r
dbeaf585 132\r
9202304c
JW
133 //\r
134 // Record the acked block number.\r
135 //\r
6c047cfa
JW
136 UINT64 AckedBlock;\r
137\r
83cbd279 138 //\r
139 // The server's communication end point: IP and two ports. one for\r
140 // initial request, one for its selected port.\r
141 //\r
142 IP4_ADDR ServerIp;\r
143 UINT16 ListeningPort;\r
144 UINT16 ConnectedPort;\r
145 IP4_ADDR Gateway;\r
b45b45b2 146 UDP_IO *UnicastPort;\r
83cbd279 147\r
148 //\r
149 // Timeout and retransmit status\r
150 //\r
151 NET_BUF *LastPacket;\r
152 UINT32 PacketToLive;\r
0e2a5749 153 BOOLEAN HasTimeout;\r
83cbd279 154 UINT32 CurRetry;\r
155 UINT32 MaxRetry;\r
156 UINT32 Timeout;\r
157\r
158 //\r
159 // Parameter used by RRQ's multicast download.\r
160 //\r
161 IP4_ADDR McastIp;\r
162 UINT16 McastPort;\r
163 BOOLEAN Master;\r
b45b45b2 164 UDP_IO *McastUdpPort;\r
61066b8d 165};\r
36ee91ca 166\r
216f7970 167typedef struct {\r
168 EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding;\r
169 UINTN NumberOfChildren;\r
170 EFI_HANDLE *ChildHandleBuffer;\r
171} MTFTP4_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT;\r
172\r
dab714aa 173/**\r
174 Clean up the MTFTP session to get ready for new operation.\r
175\r
176 @param Instance The MTFTP session to clean up\r
177 @param Result The result to return to the caller who initiated\r
178 the operation.\r
179**/\r
83cbd279 180VOID\r
181Mtftp4CleanOperation (\r
dab714aa 182 IN OUT MTFTP4_PROTOCOL *Instance,\r
183 IN EFI_STATUS Result\r
83cbd279 184 );\r
185\r
dab714aa 186/**\r
187 Start the MTFTP session for upload.\r
d1102dba
LG
188\r
189 It will first init some states, then send the WRQ request packet,\r
dab714aa 190 and start receiving the packet.\r
191\r
192 @param Instance The MTFTP session\r
193 @param Operation Redundant parameter, which is always\r
194 EFI_MTFTP4_OPCODE_WRQ here.\r
195\r
196 @retval EFI_SUCCESS The upload process has been started.\r
197 @retval Others Failed to start the upload.\r
198\r
199**/\r
83cbd279 200EFI_STATUS\r
201Mtftp4WrqStart (\r
dab714aa 202 IN MTFTP4_PROTOCOL *Instance,\r
203 IN UINT16 Operation\r
83cbd279 204 );\r
205\r
dab714aa 206/**\r
d1102dba
LG
207 Start the MTFTP session to download.\r
208\r
209 It will first initialize some of the internal states then build and send a RRQ\r
dab714aa 210 reqeuest packet, at last, it will start receive for the downloading.\r
211\r
212 @param Instance The Mtftp session\r
213 @param Operation The MTFTP opcode, it may be a EFI_MTFTP4_OPCODE_RRQ\r
214 or EFI_MTFTP4_OPCODE_DIR.\r
215\r
216 @retval EFI_SUCCESS The mtftp download session is started.\r
217 @retval Others Failed to start downloading.\r
218\r
219**/\r
83cbd279 220EFI_STATUS\r
221Mtftp4RrqStart (\r
dab714aa 222 IN MTFTP4_PROTOCOL *Instance,\r
223 IN UINT16 Operation\r
83cbd279 224 );\r
225\r
226#define MTFTP4_SERVICE_FROM_THIS(a) \\r
227 CR (a, MTFTP4_SERVICE, ServiceBinding, MTFTP4_SERVICE_SIGNATURE)\r
228\r
229#define MTFTP4_PROTOCOL_FROM_THIS(a) \\r
230 CR (a, MTFTP4_PROTOCOL, Mtftp4, MTFTP4_PROTOCOL_SIGNATURE)\r
231\r
83cbd279 232#endif\r