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