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