]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Impl.h
Fix a bug in OpensslLib that PKCS7_verify will use over 8k stack space.
[mirror_edk2.git] / MdeModulePkg / Universal / Network / Mtftp4Dxe / Mtftp4Impl.h
... / ...
CommitLineData
1/** @file\r
2 \r
3 Mtftp4 Implementation.\r
4 \r
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
11 \r
12Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>\r
13This program and the accompanying materials\r
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
16http://opensource.org/licenses/bsd-license.php<BR>\r
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
21**/\r
22\r
23\r
24#ifndef __EFI_MTFTP4_IMPL_H__\r
25#define __EFI_MTFTP4_IMPL_H__\r
26\r
27#include <Uefi.h>\r
28\r
29#include <Protocol/Udp4.h>\r
30#include <Protocol/Mtftp4.h>\r
31\r
32#include <Library/DebugLib.h>\r
33#include <Library/BaseMemoryLib.h>\r
34#include <Library/MemoryAllocationLib.h>\r
35#include <Library/UefiBootServicesTableLib.h>\r
36#include <Library/UdpIoLib.h>\r
37\r
38extern EFI_MTFTP4_PROTOCOL gMtftp4ProtocolTemplate;\r
39\r
40typedef struct _MTFTP4_SERVICE MTFTP4_SERVICE;\r
41typedef struct _MTFTP4_PROTOCOL MTFTP4_PROTOCOL;\r
42\r
43#include "Mtftp4Driver.h"\r
44#include "Mtftp4Option.h"\r
45#include "Mtftp4Support.h"\r
46\r
47\r
48///\r
49/// Some constant value of Mtftp service.\r
50///\r
51#define MTFTP4_SERVICE_SIGNATURE SIGNATURE_32 ('T', 'F', 'T', 'P')\r
52#define MTFTP4_PROTOCOL_SIGNATURE SIGNATURE_32 ('t', 'f', 't', 'p')\r
53\r
54#define MTFTP4_DEFAULT_SERVER_PORT 69\r
55#define MTFTP4_DEFAULT_TIMEOUT 3\r
56#define MTFTP4_DEFAULT_RETRY 5\r
57#define MTFTP4_DEFAULT_BLKSIZE 512\r
58#define MTFTP4_TIME_TO_GETMAP 5\r
59\r
60#define MTFTP4_STATE_UNCONFIGED 0\r
61#define MTFTP4_STATE_CONFIGED 1\r
62#define MTFTP4_STATE_DESTORY 2\r
63\r
64///\r
65/// Mtftp service block\r
66///\r
67struct _MTFTP4_SERVICE {\r
68 UINT32 Signature;\r
69 EFI_SERVICE_BINDING_PROTOCOL ServiceBinding;\r
70\r
71 BOOLEAN InDestory;\r
72\r
73 UINT16 ChildrenNum;\r
74 LIST_ENTRY Children;\r
75\r
76 EFI_EVENT Timer; ///< Ticking timer for all the MTFTP clients\r
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
86 UDP_IO *ConnectUdp;\r
87};\r
88\r
89\r
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
96struct _MTFTP4_PROTOCOL {\r
97 UINT32 Signature;\r
98 LIST_ENTRY Link;\r
99 EFI_MTFTP4_PROTOCOL Mtftp4;\r
100\r
101 INTN State;\r
102 BOOLEAN InDestory;\r
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
122 LIST_ENTRY Blocks;\r
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
132 UDP_IO *UnicastPort;\r
133\r
134 //\r
135 // Timeout and retransmit status\r
136 //\r
137 NET_BUF *LastPacket;\r
138 UINT32 PacketToLive;\r
139 UINT32 CurRetry;\r
140 UINT32 MaxRetry;\r
141 UINT32 Timeout;\r
142\r
143 //\r
144 // Parameter used by RRQ's multicast download.\r
145 //\r
146 IP4_ADDR McastIp;\r
147 UINT16 McastPort;\r
148 BOOLEAN Master;\r
149 UDP_IO *McastUdpPort;\r
150};\r
151\r
152/**\r
153 Clean up the MTFTP session to get ready for new operation.\r
154\r
155 @param Instance The MTFTP session to clean up\r
156 @param Result The result to return to the caller who initiated\r
157 the operation.\r
158**/\r
159VOID\r
160Mtftp4CleanOperation (\r
161 IN OUT MTFTP4_PROTOCOL *Instance,\r
162 IN EFI_STATUS Result\r
163 );\r
164\r
165/**\r
166 Start the MTFTP session for upload.\r
167 \r
168 It will first init some states, then send the WRQ request packet, \r
169 and start receiving the packet.\r
170\r
171 @param Instance The MTFTP session\r
172 @param Operation Redundant parameter, which is always\r
173 EFI_MTFTP4_OPCODE_WRQ here.\r
174\r
175 @retval EFI_SUCCESS The upload process has been started.\r
176 @retval Others Failed to start the upload.\r
177\r
178**/\r
179EFI_STATUS\r
180Mtftp4WrqStart (\r
181 IN MTFTP4_PROTOCOL *Instance,\r
182 IN UINT16 Operation\r
183 );\r
184\r
185/**\r
186 Start the MTFTP session to download. \r
187 \r
188 It will first initialize some of the internal states then build and send a RRQ \r
189 reqeuest packet, at last, it will start receive for the downloading.\r
190\r
191 @param Instance The Mtftp session\r
192 @param Operation The MTFTP opcode, it may be a EFI_MTFTP4_OPCODE_RRQ\r
193 or EFI_MTFTP4_OPCODE_DIR.\r
194\r
195 @retval EFI_SUCCESS The mtftp download session is started.\r
196 @retval Others Failed to start downloading.\r
197\r
198**/\r
199EFI_STATUS\r
200Mtftp4RrqStart (\r
201 IN MTFTP4_PROTOCOL *Instance,\r
202 IN UINT16 Operation\r
203 );\r
204\r
205#define MTFTP4_SERVICE_FROM_THIS(a) \\r
206 CR (a, MTFTP4_SERVICE, ServiceBinding, MTFTP4_SERVICE_SIGNATURE)\r
207\r
208#define MTFTP4_PROTOCOL_FROM_THIS(a) \\r
209 CR (a, MTFTP4_PROTOCOL, Mtftp4, MTFTP4_PROTOCOL_SIGNATURE)\r
210\r
211#endif\r