]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Impl.h
1. Update the UdpIo to a combined UdpIo to support both v4 and v6 stack.
[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<BR>\r
13All rights reserved. This 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
51typedef enum {\r
52 MTFTP4_SERVICE_SIGNATURE = SIGNATURE_32 ('T', 'F', 'T', 'P'),\r
53 MTFTP4_PROTOCOL_SIGNATURE = SIGNATURE_32 ('t', 'f', 't', 'p'),\r
54\r
55 MTFTP4_DEFAULT_SERVER_PORT = 69,\r
56 MTFTP4_DEFAULT_TIMEOUT = 3,\r
57 MTFTP4_DEFAULT_RETRY = 5,\r
58 MTFTP4_DEFAULT_BLKSIZE = 512,\r
59 MTFTP4_TIME_TO_GETMAP = 5,\r
60\r
61 MTFTP4_STATE_UNCONFIGED = 0,\r
62 MTFTP4_STATE_CONFIGED,\r
63 MTFTP4_STATE_DESTORY\r
64} MTFTP4_SERVICE_CONST_VALUE;\r
65\r
66///\r
67/// Mtftp service block\r
68///\r
69struct _MTFTP4_SERVICE {\r
70 UINT32 Signature;\r
71 EFI_SERVICE_BINDING_PROTOCOL ServiceBinding;\r
72\r
73 BOOLEAN InDestory;\r
74\r
75 UINT16 ChildrenNum;\r
76 LIST_ENTRY Children;\r
77\r
78 EFI_EVENT Timer; ///< Ticking timer for all the MTFTP clients\r
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
88 UDP_IO *ConnectUdp;\r
89};\r
90\r
91\r
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
98struct _MTFTP4_PROTOCOL {\r
99 UINT32 Signature;\r
100 LIST_ENTRY Link;\r
101 EFI_MTFTP4_PROTOCOL Mtftp4;\r
102\r
103 INTN State;\r
104 BOOLEAN InDestory;\r
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
124 LIST_ENTRY Blocks;\r
125\r
126 //\r
127 // The server's communication end point: IP and two ports. one for\r
128 // initial request, one for its selected port.\r
129 //\r
130 IP4_ADDR ServerIp;\r
131 UINT16 ListeningPort;\r
132 UINT16 ConnectedPort;\r
133 IP4_ADDR Gateway;\r
134 UDP_IO *UnicastPort;\r
135\r
136 //\r
137 // Timeout and retransmit status\r
138 //\r
139 NET_BUF *LastPacket;\r
140 UINT32 PacketToLive;\r
141 UINT32 CurRetry;\r
142 UINT32 MaxRetry;\r
143 UINT32 Timeout;\r
144\r
145 //\r
146 // Parameter used by RRQ's multicast download.\r
147 //\r
148 IP4_ADDR McastIp;\r
149 UINT16 McastPort;\r
150 BOOLEAN Master;\r
151 UDP_IO *McastUdpPort;\r
152};\r
153\r
154/**\r
155 Clean up the MTFTP session to get ready for new operation.\r
156\r
157 @param Instance The MTFTP session to clean up\r
158 @param Result The result to return to the caller who initiated\r
159 the operation.\r
160**/\r
161VOID\r
162Mtftp4CleanOperation (\r
163 IN OUT MTFTP4_PROTOCOL *Instance,\r
164 IN EFI_STATUS Result\r
165 );\r
166\r
167/**\r
168 Start the MTFTP session for upload.\r
169 \r
170 It will first init some states, then send the WRQ request packet, \r
171 and start receiving the packet.\r
172\r
173 @param Instance The MTFTP session\r
174 @param Operation Redundant parameter, which is always\r
175 EFI_MTFTP4_OPCODE_WRQ here.\r
176\r
177 @retval EFI_SUCCESS The upload process has been started.\r
178 @retval Others Failed to start the upload.\r
179\r
180**/\r
181EFI_STATUS\r
182Mtftp4WrqStart (\r
183 IN MTFTP4_PROTOCOL *Instance,\r
184 IN UINT16 Operation\r
185 );\r
186\r
187/**\r
188 Start the MTFTP session to download. \r
189 \r
190 It will first initialize some of the internal states then build and send a RRQ \r
191 reqeuest packet, at last, it will start receive for the downloading.\r
192\r
193 @param Instance The Mtftp session\r
194 @param Operation The MTFTP opcode, it may be a EFI_MTFTP4_OPCODE_RRQ\r
195 or EFI_MTFTP4_OPCODE_DIR.\r
196\r
197 @retval EFI_SUCCESS The mtftp download session is started.\r
198 @retval Others Failed to start downloading.\r
199\r
200**/\r
201EFI_STATUS\r
202Mtftp4RrqStart (\r
203 IN MTFTP4_PROTOCOL *Instance,\r
204 IN UINT16 Operation\r
205 );\r
206\r
207#define MTFTP4_SERVICE_FROM_THIS(a) \\r
208 CR (a, MTFTP4_SERVICE, ServiceBinding, MTFTP4_SERVICE_SIGNATURE)\r
209\r
210#define MTFTP4_PROTOCOL_FROM_THIS(a) \\r
211 CR (a, MTFTP4_PROTOCOL, Mtftp4, MTFTP4_PROTOCOL_SIGNATURE)\r
212\r
213#endif\r