]>
git.proxmox.com Git - mirror_edk2.git/blob - NetworkPkg/Mtftp6Dxe/Mtftp6Support.h
2 Mtftp6 support functions declaration.
4 Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>
6 SPDX-License-Identifier: BSD-2-Clause-Patent
10 #ifndef __EFI_MTFTP6_SUPPORT_H__
11 #define __EFI_MTFTP6_SUPPORT_H__
14 // The structure representing a range of block numbers, [Start, End].
15 // It is used to remember the holes in the MTFTP block space. If all
16 // the holes are filled in, then the download or upload has completed.
27 Initialize the block range for either RRQ or WRQ. RRQ and WRQ have
28 different requirements for Start and End. For example, during startup,
29 WRQ initializes its whole valid block range to [0, 0xffff]. This
30 is because the server will send an ACK0 to inform the user to start the
31 upload. When the client receives an ACK0, it will remove 0 from the range,
32 get the next block number, which is 1, then upload the BLOCK1. For RRQ
33 without option negotiation, the server will directly send us the BLOCK1
34 in response to the client's RRQ. When BLOCK1 is received, the client will
35 remove it from the block range and send an ACK. It also works if there
36 is option negotiation.
38 @param[in] Head The block range head to initialize.
39 @param[in] Start The Start block number.
40 @param[in] End The last block number.
42 @retval EFI_OUT_OF_RESOURCES Failed to allocate memory for initial block range.
43 @retval EFI_SUCCESS The initial block range is created.
47 Mtftp6InitBlockRange (
54 Get the first valid block number on the range list.
56 @param[in] Head The block range head.
58 @retval ==-1 If the block range is empty.
59 @retval >-1 The first valid block number.
63 Mtftp6GetNextBlockNum (
68 Set the last block number of the block range list. It
69 removes all the blocks after the Last. MTFTP initialize the
70 block range to the maximum possible range, such as [0, 0xffff]
71 for WRQ. When it gets the last block number, it calls
72 this function to set the last block number.
74 @param[in] Head The block range list.
75 @param[in] Last The last block number.
79 Mtftp6SetLastBlockNum (
85 Remove the block number from the block range list.
87 @param[in] Head The block range list to remove from.
88 @param[in] Num The block number to remove.
89 @param[in] Completed Whether Num is the last block number.
90 @param[out] BlockCounter The continuous block counter instead of the value after roll-over.
92 @retval EFI_NOT_FOUND The block number isn't in the block range list.
93 @retval EFI_SUCCESS The block number has been removed from the list.
94 @retval EFI_OUT_OF_RESOURCES Failed to allocate resources.
98 Mtftp6RemoveBlockNum (
101 IN BOOLEAN Completed
,
102 OUT UINT64
*BlockCounter
106 Build and transmit the request packet for the Mtftp6 instance.
108 @param[in] Instance The pointer to the Mtftp6 instance.
109 @param[in] Operation The operation code of this packet.
111 @retval EFI_OUT_OF_RESOURCES Failed to allocate memory for the request.
112 @retval EFI_SUCCESS The request was built and sent.
113 @retval Others Failed to transmit the packet.
118 IN MTFTP6_INSTANCE
*Instance
,
123 Build and send an error packet.
125 @param[in] Instance The pointer to the Mtftp6 instance.
126 @param[in] ErrCode The error code in the packet.
127 @param[in] ErrInfo The error message in the packet.
129 @retval EFI_OUT_OF_RESOURCES Failed to allocate memory for the error packet.
130 @retval EFI_SUCCESS The error packet was transmitted.
131 @retval Others Failed to transmit the packet.
136 IN MTFTP6_INSTANCE
*Instance
,
142 Send the packet for the Mtftp6 instance.
144 @param[in] Instance The pointer to the Mtftp6 instance.
145 @param[in] Packet The pointer to the packet to be sent.
147 @retval EFI_SUCCESS The packet was sent out
148 @retval Others Failed to transmit the packet.
152 Mtftp6TransmitPacket (
153 IN MTFTP6_INSTANCE
*Instance
,
158 Check packet for GetInfo callback routine.
160 @param[in] This The pointer to the Mtftp6 protocol.
161 @param[in] Token The pointer to the Mtftp6 token.
162 @param[in] PacketLen The length of the packet
163 @param[in] Packet The pointer to the received packet.
165 @retval EFI_SUCCESS The check process passed successfully.
166 @retval EFI_ABORTED Abort the Mtftp6 operation.
172 IN EFI_MTFTP6_PROTOCOL
*This
,
173 IN EFI_MTFTP6_TOKEN
*Token
,
175 IN EFI_MTFTP6_PACKET
*Packet
179 The dummy configure routine for create a new Udp6 Io.
181 @param[in] UdpIo The pointer to the Udp6 Io.
182 @param[in] Context The pointer to the context.
184 @retval EFI_SUCCESS The value is always returned.
189 Mtftp6ConfigDummyUdpIo (
195 The configure routine for the Mtftp6 instance to transmit/receive.
197 @param[in] UdpIo The pointer to the Udp6 Io.
198 @param[in] ServerIp The pointer to the server address.
199 @param[in] ServerPort The pointer to the server port.
200 @param[in] LocalIp The pointer to the local address.
201 @param[in] LocalPort The pointer to the local port.
203 @retval EFI_SUCCESS Configure the Udp6 Io for Mtftp6 successfully.
204 @retval EFI_NO_MAPPING The corresponding Ip6 instance has not been
211 IN EFI_IPv6_ADDRESS
*ServerIp
,
212 IN UINT16 ServerPort
,
213 IN EFI_IPv6_ADDRESS
*LocalIp
,
218 Clean up the current Mtftp6 operation.
220 @param[in] Instance The pointer to the Mtftp6 instance.
221 @param[in] Result The result to be returned to the user.
225 Mtftp6OperationClean (
226 IN MTFTP6_INSTANCE
*Instance
,
231 Start the Mtftp6 instance to perform the operation, such as read file,
232 write file, and read directory.
234 @param[in] This The MTFTP session
235 @param[in] Token The token that encapsulates the user's request.
236 @param[in] OpCode The operation to perform.
238 @retval EFI_INVALID_PARAMETER Some of the parameters are invalid.
239 @retval EFI_NOT_STARTED The MTFTP session hasn't been configured.
240 @retval EFI_ALREADY_STARTED There is pending operation for the session.
241 @retval EFI_SUCCESS The operation was successfully started.
245 Mtftp6OperationStart (
246 IN EFI_MTFTP6_PROTOCOL
*This
,
247 IN EFI_MTFTP6_TOKEN
*Token
,
252 The timer ticking routine for the Mtftp6 instance.
254 @param[in] Event The pointer to the ticking event.
255 @param[in] Context The pointer to the context.
266 The packet process callback for Mtftp6 upload.
268 @param[in] UdpPacket The pointer to the packet received.
269 @param[in] UdpEpt The pointer to the Udp6 access point.
270 @param[in] IoStatus The status from the Udp6 instance.
271 @param[in] Context The pointer to the context.
277 IN NET_BUF
*UdpPacket
,
278 IN UDP_END_POINT
*UdpEpt
,
279 IN EFI_STATUS IoStatus
,
284 Start the Mtftp6 instance to upload. It will first init some states,
285 then send the WRQ request packet, and start to receive the packet.
287 @param[in] Instance The pointer to the Mtftp6 instance.
288 @param[in] Operation The operation code of current packet.
290 @retval EFI_SUCCESS The Mtftp6 was started to upload.
291 @retval Others Failed to start to upload.
296 IN MTFTP6_INSTANCE
*Instance
,
301 The packet process callback for Mtftp6 download.
303 @param[in] UdpPacket The pointer to the packet received.
304 @param[in] UdpEpt The pointer to the Udp6 access point.
305 @param[in] IoStatus The status from Udp6 instance.
306 @param[in] Context The pointer to the context.
312 IN NET_BUF
*UdpPacket
,
313 IN UDP_END_POINT
*UdpEpt
,
314 IN EFI_STATUS IoStatus
,
319 Start the Mtftp6 instance to download. It first initializes some
320 of the internal states then builds and sends an RRQ request packet.
321 Finally, it starts receive for the downloading.
323 @param[in] Instance The pointer to the Mtftp6 instance.
324 @param[in] Operation The operation code of current packet.
326 @retval EFI_SUCCESS The Mtftp6 was started to download.
327 @retval Others Failed to start to download.
332 IN MTFTP6_INSTANCE
*Instance
,