]>
Commit | Line | Data |
---|---|---|
a3bcde70 HT |
1 | /** @file\r |
2 | Mtftp6 support functions declaration.\r | |
3 | \r | |
4 | Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>\r | |
5 | \r | |
6 | This program and the accompanying materials\r | |
7 | are licensed and made available under the terms and conditions of the BSD License\r | |
8 | which accompanies this distribution. The full text of the license may be found at\r | |
9 | http://opensource.org/licenses/bsd-license.php.\r | |
10 | \r | |
11 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
12 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
13 | \r | |
14 | **/\r | |
15 | \r | |
16 | #ifndef __EFI_MTFTP6_SUPPORT_H__\r | |
17 | #define __EFI_MTFTP6_SUPPORT_H__\r | |
18 | \r | |
19 | //\r | |
20 | // The structure representing a range of block numbers, [Start, End].\r | |
21 | // It is used to remember the holes in the MTFTP block space. If all\r | |
22 | // the holes are filled in, then the download or upload has completed.\r | |
23 | //\r | |
24 | typedef struct {\r | |
25 | LIST_ENTRY Link;\r | |
26 | INTN Start;\r | |
27 | INTN End;\r | |
28 | INTN Round;\r | |
29 | INTN Bound;\r | |
30 | } MTFTP6_BLOCK_RANGE;\r | |
31 | \r | |
32 | \r | |
33 | /**\r | |
34 | Initialize the block range for either RRQ or WRQ. RRQ and WRQ have\r | |
35 | different requirements for Start and End. For example, during startup,\r | |
36 | WRQ initializes its whole valid block range to [0, 0xffff]. This\r | |
37 | is because the server will send an ACK0 to inform the user to start the\r | |
38 | upload. When the client receives an ACK0, it will remove 0 from the range,\r | |
39 | get the next block number, which is 1, then upload the BLOCK1. For RRQ\r | |
40 | without option negotiation, the server will directly send us the BLOCK1\r | |
41 | in response to the client's RRQ. When BLOCK1 is received, the client will\r | |
42 | remove it from the block range and send an ACK. It also works if there\r | |
43 | is option negotiation.\r | |
44 | \r | |
45 | @param[in] Head The block range head to initialize.\r | |
46 | @param[in] Start The Start block number.\r | |
47 | @param[in] End The last block number.\r | |
48 | \r | |
49 | @retval EFI_OUT_OF_RESOURCES Failed to allocate memory for initial block range.\r | |
50 | @retval EFI_SUCCESS The initial block range is created.\r | |
51 | \r | |
52 | **/\r | |
53 | EFI_STATUS\r | |
54 | Mtftp6InitBlockRange (\r | |
55 | IN LIST_ENTRY *Head,\r | |
56 | IN UINT16 Start,\r | |
57 | IN UINT16 End\r | |
58 | );\r | |
59 | \r | |
60 | \r | |
61 | /**\r | |
62 | Get the first valid block number on the range list.\r | |
63 | \r | |
64 | @param[in] Head The block range head.\r | |
65 | \r | |
66 | @retval ==-1 If the block range is empty.\r | |
67 | @retval >-1 The first valid block number.\r | |
68 | \r | |
69 | **/\r | |
70 | INTN\r | |
71 | Mtftp6GetNextBlockNum (\r | |
72 | IN LIST_ENTRY *Head\r | |
73 | );\r | |
74 | \r | |
75 | \r | |
76 | /**\r | |
77 | Set the last block number of the block range list. It\r | |
78 | removes all the blocks after the Last. MTFTP initialize the\r | |
79 | block range to the maximum possible range, such as [0, 0xffff]\r | |
80 | for WRQ. When it gets the last block number, it calls\r | |
81 | this function to set the last block number.\r | |
82 | \r | |
83 | @param[in] Head The block range list.\r | |
84 | @param[in] Last The last block number.\r | |
85 | \r | |
86 | **/\r | |
87 | VOID\r | |
88 | Mtftp6SetLastBlockNum (\r | |
89 | IN LIST_ENTRY *Head,\r | |
90 | IN UINT16 Last\r | |
91 | );\r | |
92 | \r | |
93 | \r | |
94 | /**\r | |
95 | Remove the block number from the block range list.\r | |
96 | \r | |
97 | @param[in] Head The block range list to remove from.\r | |
98 | @param[in] Num The block number to remove.\r | |
99 | @param[in] Completed Whether Num is the last block number\r | |
100 | @param[out] TotalBlock The continuous block number in all\r | |
101 | \r | |
102 | @retval EFI_NOT_FOUND The block number isn't in the block range list.\r | |
103 | @retval EFI_SUCCESS The block number has been removed from the list.\r | |
104 | @retval EFI_OUT_OF_RESOURCES Failed to allocate resources.\r | |
105 | \r | |
106 | **/\r | |
107 | EFI_STATUS\r | |
108 | Mtftp6RemoveBlockNum (\r | |
109 | IN LIST_ENTRY *Head,\r | |
110 | IN UINT16 Num,\r | |
111 | IN BOOLEAN Completed,\r | |
112 | OUT UINT64 *TotalBlock\r | |
113 | );\r | |
114 | \r | |
115 | \r | |
116 | /**\r | |
117 | Build and transmit the request packet for the Mtftp6 instance.\r | |
118 | \r | |
119 | @param[in] Instance The pointer to the Mtftp6 instance.\r | |
120 | @param[in] Operation The operation code of this packet.\r | |
121 | \r | |
122 | @retval EFI_OUT_OF_RESOURCES Failed to allocate memory for the request.\r | |
123 | @retval EFI_SUCCESS The request was built and sent.\r | |
124 | @retval Others Failed to transmit the packet.\r | |
125 | \r | |
126 | **/\r | |
127 | EFI_STATUS\r | |
128 | Mtftp6SendRequest (\r | |
129 | IN MTFTP6_INSTANCE *Instance,\r | |
130 | IN UINT16 Operation\r | |
131 | );\r | |
132 | \r | |
133 | \r | |
134 | /**\r | |
135 | Build and send an error packet.\r | |
136 | \r | |
137 | @param[in] Instance The pointer to the Mtftp6 instance.\r | |
138 | @param[in] ErrCode The error code in the packet.\r | |
139 | @param[in] ErrInfo The error message in the packet.\r | |
140 | \r | |
141 | @retval EFI_OUT_OF_RESOURCES Failed to allocate memory for the error packet.\r | |
142 | @retval EFI_SUCCESS The error packet was transmitted.\r | |
143 | @retval Others Failed to transmit the packet.\r | |
144 | \r | |
145 | **/\r | |
146 | EFI_STATUS\r | |
147 | Mtftp6SendError (\r | |
148 | IN MTFTP6_INSTANCE *Instance,\r | |
149 | IN UINT16 ErrCode,\r | |
150 | IN UINT8* ErrInfo\r | |
151 | );\r | |
152 | \r | |
153 | \r | |
154 | /**\r | |
155 | Send the packet for the Mtftp6 instance.\r | |
156 | \r | |
157 | @param[in] Instance The pointer to the Mtftp6 instance.\r | |
158 | @param[in] Packet The pointer to the packet to be sent.\r | |
159 | \r | |
160 | @retval EFI_SUCCESS The packet was sent out\r | |
161 | @retval Others Failed to transmit the packet.\r | |
162 | \r | |
163 | **/\r | |
164 | EFI_STATUS\r | |
165 | Mtftp6TransmitPacket (\r | |
166 | IN MTFTP6_INSTANCE *Instance,\r | |
167 | IN NET_BUF *Packet\r | |
168 | );\r | |
169 | \r | |
170 | \r | |
171 | /**\r | |
172 | Check packet for GetInfo callback routine.\r | |
173 | \r | |
174 | @param[in] This The pointer to the Mtftp6 protocol.\r | |
175 | @param[in] Token The pointer to the Mtftp6 token.\r | |
176 | @param[in] PacketLen The length of the packet\r | |
177 | @param[in] Packet The pointer to the received packet.\r | |
178 | \r | |
179 | @retval EFI_SUCCESS The check process passed successfully.\r | |
180 | @retval EFI_ABORTED Abort the Mtftp6 operation.\r | |
181 | \r | |
182 | **/\r | |
183 | EFI_STATUS\r | |
184 | EFIAPI\r | |
185 | Mtftp6CheckPacket (\r | |
186 | IN EFI_MTFTP6_PROTOCOL *This,\r | |
187 | IN EFI_MTFTP6_TOKEN *Token,\r | |
188 | IN UINT16 PacketLen,\r | |
189 | IN EFI_MTFTP6_PACKET *Packet\r | |
190 | );\r | |
191 | \r | |
192 | \r | |
193 | /**\r | |
194 | The dummy configure routine for create a new Udp6 Io.\r | |
195 | \r | |
196 | @param[in] UdpIo The pointer to the Udp6 Io.\r | |
197 | @param[in] Context The pointer to the context.\r | |
198 | \r | |
199 | @retval EFI_SUCCESS The value is always returned.\r | |
200 | \r | |
201 | **/\r | |
202 | EFI_STATUS\r | |
203 | EFIAPI\r | |
204 | Mtftp6ConfigDummyUdpIo (\r | |
205 | IN UDP_IO *UdpIo,\r | |
206 | IN VOID *Context\r | |
207 | );\r | |
208 | \r | |
209 | \r | |
210 | /**\r | |
211 | The configure routine for the Mtftp6 instance to transmit/receive.\r | |
212 | \r | |
213 | @param[in] UdpIo The pointer to the Udp6 Io.\r | |
214 | @param[in] ServerIp The pointer to the server address.\r | |
215 | @param[in] ServerPort The pointer to the server port.\r | |
216 | @param[in] LocalIp The pointer to the local address.\r | |
217 | @param[in] LocalPort The pointer to the local port.\r | |
218 | \r | |
219 | @retval EFI_SUCCESS Configure the Udp6 Io for Mtftp6 successfully.\r | |
220 | @retval EFI_NO_MAPPING The corresponding Ip6 instance has not been\r | |
221 | configured yet.\r | |
222 | \r | |
223 | **/\r | |
224 | EFI_STATUS\r | |
225 | Mtftp6ConfigUdpIo (\r | |
226 | IN UDP_IO *UdpIo,\r | |
227 | IN EFI_IPv6_ADDRESS *ServerIp,\r | |
228 | IN UINT16 ServerPort,\r | |
229 | IN EFI_IPv6_ADDRESS *LocalIp,\r | |
230 | IN UINT16 LocalPort\r | |
231 | );\r | |
232 | \r | |
233 | \r | |
234 | /**\r | |
235 | Clean up the current Mtftp6 operation.\r | |
236 | \r | |
237 | @param[in] Instance The pointer to the Mtftp6 instance.\r | |
238 | @param[in] Result The result to be returned to the user.\r | |
239 | \r | |
240 | **/\r | |
241 | VOID\r | |
242 | Mtftp6OperationClean (\r | |
243 | IN MTFTP6_INSTANCE *Instance,\r | |
244 | IN EFI_STATUS Result\r | |
245 | );\r | |
246 | \r | |
247 | \r | |
248 | /**\r | |
249 | Start the Mtftp6 instance to perform the operation, such as read file,\r | |
250 | write file, and read directory.\r | |
251 | \r | |
252 | @param[in] This The MTFTP session\r | |
253 | @param[in] Token The token that encapsulates the user's request.\r | |
254 | @param[in] OpCode The operation to perform.\r | |
255 | \r | |
256 | @retval EFI_INVALID_PARAMETER Some of the parameters are invalid.\r | |
257 | @retval EFI_NOT_STARTED The MTFTP session hasn't been configured.\r | |
258 | @retval EFI_ALREADY_STARTED There is pending operation for the session.\r | |
259 | @retval EFI_SUCCESS The operation was successfully started.\r | |
260 | \r | |
261 | **/\r | |
262 | EFI_STATUS\r | |
263 | Mtftp6OperationStart (\r | |
264 | IN EFI_MTFTP6_PROTOCOL *This,\r | |
265 | IN EFI_MTFTP6_TOKEN *Token,\r | |
266 | IN UINT16 OpCode\r | |
267 | );\r | |
268 | \r | |
269 | \r | |
270 | /**\r | |
271 | The timer ticking routine for the Mtftp6 instance.\r | |
272 | \r | |
273 | @param[in] Event The pointer to the ticking event.\r | |
274 | @param[in] Context The pointer to the context.\r | |
275 | \r | |
276 | **/\r | |
277 | VOID\r | |
278 | EFIAPI\r | |
279 | Mtftp6OnTimerTick (\r | |
280 | IN EFI_EVENT Event,\r | |
281 | IN VOID *Context\r | |
282 | );\r | |
283 | \r | |
284 | \r | |
285 | /**\r | |
286 | The packet process callback for Mtftp6 upload.\r | |
287 | \r | |
288 | @param[in] UdpPacket The pointer to the packet received.\r | |
289 | @param[in] UdpEpt The pointer to the Udp6 access point.\r | |
290 | @param[in] IoStatus The status from the Udp6 instance.\r | |
291 | @param[in] Context The pointer to the context.\r | |
292 | \r | |
293 | **/\r | |
294 | VOID\r | |
295 | EFIAPI\r | |
296 | Mtftp6WrqInput (\r | |
297 | IN NET_BUF *UdpPacket,\r | |
298 | IN UDP_END_POINT *UdpEpt,\r | |
299 | IN EFI_STATUS IoStatus,\r | |
300 | IN VOID *Context\r | |
301 | );\r | |
302 | \r | |
303 | \r | |
304 | /**\r | |
305 | Start the Mtftp6 instance to upload. It will first init some states,\r | |
306 | then send the WRQ request packet, and start to receive the packet.\r | |
307 | \r | |
308 | @param[in] Instance The pointer to the Mtftp6 instance.\r | |
309 | @param[in] Operation The operation code of current packet.\r | |
310 | \r | |
311 | @retval EFI_SUCCESS The Mtftp6 was started to upload.\r | |
312 | @retval Others Failed to start to upload.\r | |
313 | \r | |
314 | **/\r | |
315 | EFI_STATUS\r | |
316 | Mtftp6WrqStart (\r | |
317 | IN MTFTP6_INSTANCE *Instance,\r | |
318 | IN UINT16 Operation\r | |
319 | );\r | |
320 | \r | |
321 | \r | |
322 | /**\r | |
323 | The packet process callback for Mtftp6 download.\r | |
324 | \r | |
325 | @param[in] UdpPacket The pointer to the packet received.\r | |
326 | @param[in] UdpEpt The pointer to the Udp6 access point.\r | |
327 | @param[in] IoStatus The status from Udp6 instance.\r | |
328 | @param[in] Context The pointer to the context.\r | |
329 | \r | |
330 | **/\r | |
331 | VOID\r | |
332 | EFIAPI\r | |
333 | Mtftp6RrqInput (\r | |
334 | IN NET_BUF *UdpPacket,\r | |
335 | IN UDP_END_POINT *UdpEpt,\r | |
336 | IN EFI_STATUS IoStatus,\r | |
337 | IN VOID *Context\r | |
338 | );\r | |
339 | \r | |
340 | \r | |
341 | /**\r | |
342 | Start the Mtftp6 instance to download. It first initializes some\r | |
343 | of the internal states then builds and sends an RRQ reqeuest packet.\r | |
344 | Finally, it starts receive for the downloading.\r | |
345 | \r | |
346 | @param[in] Instance The pointer to the Mtftp6 instance.\r | |
347 | @param[in] Operation The operation code of current packet.\r | |
348 | \r | |
349 | @retval EFI_SUCCESS The Mtftp6 was started to download.\r | |
350 | @retval Others Failed to start to download.\r | |
351 | \r | |
352 | **/\r | |
353 | EFI_STATUS\r | |
354 | Mtftp6RrqStart (\r | |
355 | IN MTFTP6_INSTANCE *Instance,\r | |
356 | IN UINT16 Operation\r | |
357 | );\r | |
358 | \r | |
359 | #endif\r |