]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - MdePkg/Include/Protocol/Mtftp6.h
MdePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdePkg / Include / Protocol / Mtftp6.h
... / ...
CommitLineData
1/** @file\r
2 UEFI Multicast Trivial File Transfer Protocol v6 Definition, which is built upon\r
3 the EFI UDPv6 Protocol and provides basic services for client-side unicast and/or\r
4 multicast TFTP operations.\r
5\r
6 Copyright (c) 2008 - 2011, Intel Corporation. All rights reserved.<BR>\r
7 (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>\r
8\r
9 SPDX-License-Identifier: BSD-2-Clause-Patent\r
10\r
11 @par Revision Reference:\r
12 This Protocol is introduced in UEFI Specification 2.2\r
13\r
14**/\r
15\r
16#ifndef __EFI_MTFTP6_PROTOCOL_H__\r
17#define __EFI_MTFTP6_PROTOCOL_H__\r
18\r
19\r
20#define EFI_MTFTP6_SERVICE_BINDING_PROTOCOL_GUID \\r
21 { \\r
22 0xd9760ff3, 0x3cca, 0x4267, {0x80, 0xf9, 0x75, 0x27, 0xfa, 0xfa, 0x42, 0x23 } \\r
23 }\r
24\r
25#define EFI_MTFTP6_PROTOCOL_GUID \\r
26 { \\r
27 0xbf0a78ba, 0xec29, 0x49cf, {0xa1, 0xc9, 0x7a, 0xe5, 0x4e, 0xab, 0x6a, 0x51 } \\r
28 }\r
29\r
30typedef struct _EFI_MTFTP6_PROTOCOL EFI_MTFTP6_PROTOCOL;\r
31typedef struct _EFI_MTFTP6_TOKEN EFI_MTFTP6_TOKEN;\r
32\r
33///\r
34/// MTFTP Packet OpCodes\r
35///@{\r
36#define EFI_MTFTP6_OPCODE_RRQ 1 ///< The MTFTPv6 packet is a read request.\r
37#define EFI_MTFTP6_OPCODE_WRQ 2 ///< The MTFTPv6 packet is a write request.\r
38#define EFI_MTFTP6_OPCODE_DATA 3 ///< The MTFTPv6 packet is a data packet.\r
39#define EFI_MTFTP6_OPCODE_ACK 4 ///< The MTFTPv6 packet is an acknowledgement packet.\r
40#define EFI_MTFTP6_OPCODE_ERROR 5 ///< The MTFTPv6 packet is an error packet.\r
41#define EFI_MTFTP6_OPCODE_OACK 6 ///< The MTFTPv6 packet is an option acknowledgement packet.\r
42#define EFI_MTFTP6_OPCODE_DIR 7 ///< The MTFTPv6 packet is a directory query packet.\r
43#define EFI_MTFTP6_OPCODE_DATA8 8 ///< The MTFTPv6 packet is a data packet with a big block number.\r
44#define EFI_MTFTP6_OPCODE_ACK8 9 ///< The MTFTPv6 packet is an acknowledgement packet with a big block number.\r
45///@}\r
46\r
47///\r
48/// MTFTP ERROR Packet ErrorCodes\r
49///@{\r
50///\r
51/// The error code is not defined. See the error message in the packet (if any) for details.\r
52///\r
53#define EFI_MTFTP6_ERRORCODE_NOT_DEFINED 0\r
54///\r
55/// The file was not found.\r
56///\r
57#define EFI_MTFTP6_ERRORCODE_FILE_NOT_FOUND 1\r
58///\r
59/// There was an access violation.\r
60///\r
61#define EFI_MTFTP6_ERRORCODE_ACCESS_VIOLATION 2\r
62///\r
63/// The disk was full or its allocation was exceeded.\r
64///\r
65#define EFI_MTFTP6_ERRORCODE_DISK_FULL 3\r
66///\r
67/// The MTFTPv6 operation was illegal.\r
68///\r
69#define EFI_MTFTP6_ERRORCODE_ILLEGAL_OPERATION 4\r
70///\r
71/// The transfer ID is unknown.\r
72///\r
73#define EFI_MTFTP6_ERRORCODE_UNKNOWN_TRANSFER_ID 5\r
74///\r
75/// The file already exists.\r
76///\r
77#define EFI_MTFTP6_ERRORCODE_FILE_ALREADY_EXISTS 6\r
78///\r
79/// There is no such user.\r
80///\r
81#define EFI_MTFTP6_ERRORCODE_NO_SUCH_USER 7\r
82///\r
83/// The request has been denied due to option negotiation.\r
84///\r
85#define EFI_MTFTP6_ERRORCODE_REQUEST_DENIED 8\r
86///@}\r
87\r
88#pragma pack(1)\r
89\r
90///\r
91/// EFI_MTFTP6_REQ_HEADER\r
92///\r
93typedef struct {\r
94 ///\r
95 /// For this packet type, OpCode = EFI_MTFTP6_OPCODE_RRQ for a read request\r
96 /// or OpCode = EFI_MTFTP6_OPCODE_WRQ for a write request.\r
97 ///\r
98 UINT16 OpCode;\r
99 ///\r
100 /// The file name to be downloaded or uploaded.\r
101 ///\r
102 UINT8 Filename[1];\r
103} EFI_MTFTP6_REQ_HEADER;\r
104\r
105///\r
106/// EFI_MTFTP6_OACK_HEADER\r
107///\r
108typedef struct {\r
109 ///\r
110 /// For this packet type, OpCode = EFI_MTFTP6_OPCODE_OACK.\r
111 ///\r
112 UINT16 OpCode;\r
113 ///\r
114 /// The option strings in the option acknowledgement packet.\r
115 ///\r
116 UINT8 Data[1];\r
117} EFI_MTFTP6_OACK_HEADER;\r
118\r
119///\r
120/// EFI_MTFTP6_DATA_HEADER\r
121///\r
122typedef struct {\r
123 ///\r
124 /// For this packet type, OpCode = EFI_MTFTP6_OPCODE_DATA.\r
125 ///\r
126 UINT16 OpCode;\r
127 ///\r
128 /// Block number of this data packet.\r
129 ///\r
130 UINT16 Block;\r
131 ///\r
132 /// The content of this data packet.\r
133 ///\r
134 UINT8 Data[1];\r
135} EFI_MTFTP6_DATA_HEADER;\r
136\r
137///\r
138/// EFI_MTFTP6_ACK_HEADER\r
139///\r
140typedef struct {\r
141 ///\r
142 /// For this packet type, OpCode = EFI_MTFTP6_OPCODE_ACK.\r
143 ///\r
144 UINT16 OpCode;\r
145 ///\r
146 /// The block number of the data packet that is being acknowledged.\r
147 ///\r
148 UINT16 Block[1];\r
149} EFI_MTFTP6_ACK_HEADER;\r
150\r
151///\r
152/// EFI_MTFTP6_DATA8_HEADER\r
153///\r
154typedef struct {\r
155 ///\r
156 /// For this packet type, OpCode = EFI_MTFTP6_OPCODE_DATA8.\r
157 ///\r
158 UINT16 OpCode;\r
159 ///\r
160 /// The block number of data packet.\r
161 ///\r
162 UINT64 Block;\r
163 ///\r
164 /// The content of this data packet.\r
165 ///\r
166 UINT8 Data[1];\r
167} EFI_MTFTP6_DATA8_HEADER;\r
168\r
169///\r
170/// EFI_MTFTP6_ACK8_HEADER\r
171///\r
172typedef struct {\r
173 ///\r
174 /// For this packet type, OpCode = EFI_MTFTP6_OPCODE_ACK8.\r
175 ///\r
176 UINT16 OpCode;\r
177 ///\r
178 /// The block number of the data packet that is being acknowledged.\r
179 ///\r
180 UINT64 Block[1];\r
181} EFI_MTFTP6_ACK8_HEADER;\r
182\r
183///\r
184/// EFI_MTFTP6_ERROR_HEADER\r
185///\r
186typedef struct {\r
187 ///\r
188 /// For this packet type, OpCode = EFI_MTFTP6_OPCODE_ERROR.\r
189 ///\r
190 UINT16 OpCode;\r
191 ///\r
192 /// The error number as defined by the MTFTPv6 packet error codes.\r
193 ///\r
194 UINT16 ErrorCode;\r
195 ///\r
196 /// Error message string.\r
197 ///\r
198 UINT8 ErrorMessage[1];\r
199} EFI_MTFTP6_ERROR_HEADER;\r
200\r
201///\r
202/// EFI_MTFTP6_PACKET\r
203///\r
204typedef union {\r
205 UINT16 OpCode; ///< Type of packets as defined by the MTFTPv6 packet opcodes.\r
206 EFI_MTFTP6_REQ_HEADER Rrq; ///< Read request packet header.\r
207 EFI_MTFTP6_REQ_HEADER Wrq; ///< write request packet header.\r
208 EFI_MTFTP6_OACK_HEADER Oack; ///< Option acknowledge packet header.\r
209 EFI_MTFTP6_DATA_HEADER Data; ///< Data packet header.\r
210 EFI_MTFTP6_ACK_HEADER Ack; ///< Acknowledgement packet header.\r
211 EFI_MTFTP6_DATA8_HEADER Data8; ///< Data packet header with big block number.\r
212 EFI_MTFTP6_ACK8_HEADER Ack8; ///< Acknowledgement header with big block number.\r
213 EFI_MTFTP6_ERROR_HEADER Error; ///< Error packet header.\r
214} EFI_MTFTP6_PACKET;\r
215\r
216#pragma pack()\r
217\r
218///\r
219/// EFI_MTFTP6_CONFIG_DATA\r
220///\r
221typedef struct {\r
222 ///\r
223 /// The local IP address to use. Set to zero to let the underlying IPv6\r
224 /// driver choose a source address. If not zero it must be one of the\r
225 /// configured IP addresses in the underlying IPv6 driver.\r
226 ///\r
227 EFI_IPv6_ADDRESS StationIp;\r
228 ///\r
229 /// Local port number. Set to zero to use the automatically assigned port number.\r
230 ///\r
231 UINT16 LocalPort;\r
232 ///\r
233 /// The IP address of the MTFTPv6 server.\r
234 ///\r
235 EFI_IPv6_ADDRESS ServerIp;\r
236 ///\r
237 /// The initial MTFTPv6 server port number. Request packets are\r
238 /// sent to this port. This number is almost always 69 and using zero\r
239 /// defaults to 69.\r
240 UINT16 InitialServerPort;\r
241 ///\r
242 /// The number of times to transmit MTFTPv6 request packets and wait for a response.\r
243 ///\r
244 UINT16 TryCount;\r
245 ///\r
246 /// The number of seconds to wait for a response after sending the MTFTPv6 request packet.\r
247 ///\r
248 UINT16 TimeoutValue;\r
249} EFI_MTFTP6_CONFIG_DATA;\r
250\r
251///\r
252/// EFI_MTFTP6_MODE_DATA\r
253///\r
254typedef struct {\r
255 ///\r
256 /// The configuration data of this instance.\r
257 ///\r
258 EFI_MTFTP6_CONFIG_DATA ConfigData;\r
259 ///\r
260 /// The number of option strings in the following SupportedOptions array.\r
261 ///\r
262 UINT8 SupportedOptionCount;\r
263 ///\r
264 /// An array of null-terminated ASCII option strings that are recognized and supported by\r
265 /// this EFI MTFTPv6 Protocol driver implementation. The buffer is\r
266 /// read only to the caller and the caller should NOT free the buffer.\r
267 ///\r
268 UINT8 **SupportedOptions;\r
269} EFI_MTFTP6_MODE_DATA;\r
270\r
271///\r
272/// EFI_MTFTP_OVERRIDE_DATA\r
273///\r
274typedef struct {\r
275 ///\r
276 /// IP address of the MTFTPv6 server. If set to all zero, the value that\r
277 /// was set by the EFI_MTFTP6_PROTOCOL.Configure() function will be used.\r
278 ///\r
279 EFI_IPv6_ADDRESS ServerIp;\r
280 ///\r
281 /// MTFTPv6 server port number. If set to zero, it will use the value\r
282 /// that was set by the EFI_MTFTP6_PROTOCOL.Configure() function.\r
283 ///\r
284 UINT16 ServerPort;\r
285 ///\r
286 /// Number of times to transmit MTFTPv6 request packets and wait\r
287 /// for a response. If set to zero, the value that was set by\r
288 /// theEFI_MTFTP6_PROTOCOL.Configure() function will be used.\r
289 ///\r
290 UINT16 TryCount;\r
291 ///\r
292 /// Number of seconds to wait for a response after sending the\r
293 /// MTFTPv6 request packet. If set to zero, the value that was set by\r
294 /// the EFI_MTFTP6_PROTOCOL.Configure() function will be used.\r
295 ///\r
296 UINT16 TimeoutValue;\r
297} EFI_MTFTP6_OVERRIDE_DATA;\r
298\r
299///\r
300/// EFI_MTFTP6_OPTION\r
301///\r
302typedef struct {\r
303 UINT8 *OptionStr; ///< Pointer to the null-terminated ASCII MTFTPv6 option string.\r
304 UINT8 *ValueStr; ///< Pointer to the null-terminated ASCII MTFTPv6 value string.\r
305} EFI_MTFTP6_OPTION;\r
306\r
307/**\r
308 EFI_MTFTP6_TIMEOUT_CALLBACK is a callback function that the caller provides to capture the\r
309 timeout event in the EFI_MTFTP6_PROTOCOL.ReadFile(), EFI_MTFTP6_PROTOCOL.WriteFile() or\r
310 EFI_MTFTP6_PROTOCOL.ReadDirectory() functions.\r
311\r
312 Whenever a timeout occurs, the EFI MTFTPv6 Protocol driver will call the EFI_MTFTP6_TIMEOUT_CALLBACK\r
313 function to notify the caller of the timeout event. Any status code other than EFI_SUCCESS\r
314 that is returned from this function will abort the current download process.\r
315\r
316 @param[in] This Pointer to the EFI_MTFTP6_PROTOCOL instance.\r
317 @param[in] Token The token that the caller provided in the EFI_MTFTP6_PROTOCOl.ReadFile(),\r
318 WriteFile() or ReadDirectory() function.\r
319 @param[in] PacketLen Indicates the length of the packet.\r
320 @param[in] Packet Pointer to an MTFTPv6 packet.\r
321\r
322 @retval EFI_SUCCESS Operation success.\r
323 @retval Others Aborts session.\r
324\r
325**/\r
326typedef\r
327EFI_STATUS\r
328(EFIAPI *EFI_MTFTP6_CHECK_PACKET)(\r
329 IN EFI_MTFTP6_PROTOCOL *This,\r
330 IN EFI_MTFTP6_TOKEN *Token,\r
331 IN UINT16 PacketLen,\r
332 IN EFI_MTFTP6_PACKET *Packet\r
333 );\r
334\r
335/**\r
336 EFI_MTFTP6_TIMEOUT_CALLBACK is a callback function that the caller provides to capture the\r
337 timeout event in the EFI_MTFTP6_PROTOCOL.ReadFile(), EFI_MTFTP6_PROTOCOL.WriteFile() or\r
338 EFI_MTFTP6_PROTOCOL.ReadDirectory() functions.\r
339\r
340 Whenever a timeout occurs, the EFI MTFTPv6 Protocol driver will call the EFI_MTFTP6_TIMEOUT_CALLBACK\r
341 function to notify the caller of the timeout event. Any status code other than EFI_SUCCESS\r
342 that is returned from this function will abort the current download process.\r
343\r
344 @param[in] This Pointer to the EFI_MTFTP6_PROTOCOL instance.\r
345 @param[in] Token The token that is provided in the EFI_MTFTP6_PROTOCOL.ReadFile() or\r
346 EFI_MTFTP6_PROTOCOL.WriteFile() or EFI_MTFTP6_PROTOCOL.ReadDirectory()\r
347 functions by the caller.\r
348\r
349 @retval EFI_SUCCESS Operation success.\r
350 @retval Others Aborts session.\r
351\r
352**/\r
353typedef\r
354EFI_STATUS\r
355(EFIAPI *EFI_MTFTP6_TIMEOUT_CALLBACK)(\r
356 IN EFI_MTFTP6_PROTOCOL *This,\r
357 IN EFI_MTFTP6_TOKEN *Token\r
358 );\r
359\r
360/**\r
361 EFI_MTFTP6_PACKET_NEEDED is a callback function that the caller provides to feed data to the\r
362 EFI_MTFTP6_PROTOCOL.WriteFile() function.\r
363\r
364 EFI_MTFTP6_PACKET_NEEDED provides another mechanism for the caller to provide data to upload\r
365 other than a static buffer. The EFI MTFTP6 Protocol driver always calls EFI_MTFTP6_PACKET_NEEDED\r
366 to get packet data from the caller if no static buffer was given in the initial call to\r
367 EFI_MTFTP6_PROTOCOL.WriteFile() function. Setting *Length to zero signals the end of the session.\r
368 Returning a status code other than EFI_SUCCESS aborts the session.\r
369\r
370 @param[in] This Pointer to the EFI_MTFTP6_PROTOCOL instance.\r
371 @param[in] Token The token provided in the EFI_MTFTP6_PROTOCOL.WriteFile() by the caller.\r
372 @param[in, out] Length Indicates the length of the raw data wanted on input, and the\r
373 length the data available on output.\r
374 @param[out] Buffer Pointer to the buffer where the data is stored.\r
375\r
376 @retval EFI_SUCCESS Operation success.\r
377 @retval Others Aborts session.\r
378\r
379**/\r
380typedef\r
381EFI_STATUS\r
382(EFIAPI *EFI_MTFTP6_PACKET_NEEDED)(\r
383 IN EFI_MTFTP6_PROTOCOL *This,\r
384 IN EFI_MTFTP6_TOKEN *Token,\r
385 IN OUT UINT16 *Length,\r
386 OUT VOID **Buffer\r
387 );\r
388\r
389struct _EFI_MTFTP6_TOKEN {\r
390 ///\r
391 /// The status that is returned to the caller at the end of the operation\r
392 /// to indicate whether this operation completed successfully.\r
393 /// Defined Status values are listed below.\r
394 ///\r
395 EFI_STATUS Status;\r
396 ///\r
397 /// The event that will be signaled when the operation completes. If\r
398 /// set to NULL, the corresponding function will wait until the read or\r
399 /// write operation finishes. The type of Event must be EVT_NOTIFY_SIGNAL.\r
400 ///\r
401 EFI_EVENT Event;\r
402 ///\r
403 /// If not NULL, the data that will be used to override the existing\r
404 /// configure data.\r
405 ///\r
406 EFI_MTFTP6_OVERRIDE_DATA *OverrideData;\r
407 ///\r
408 /// Pointer to the null-terminated ASCII file name string.\r
409 ///\r
410 UINT8 *Filename;\r
411 ///\r
412 /// Pointer to the null-terminated ASCII mode string. If NULL, octet is used.\r
413 ///\r
414 UINT8 *ModeStr;\r
415 ///\r
416 /// Number of option/value string pairs.\r
417 ///\r
418 UINT32 OptionCount;\r
419 ///\r
420 /// Pointer to an array of option/value string pairs. Ignored if\r
421 /// OptionCount is zero. Both a remote server and this driver\r
422 /// implementation should support these options. If one or more\r
423 /// options are unrecognized by this implementation, it is sent to the\r
424 /// remote server without being changed.\r
425 ///\r
426 EFI_MTFTP6_OPTION *OptionList;\r
427 ///\r
428 /// On input, the size, in bytes, of Buffer. On output, the number\r
429 /// of bytes transferred.\r
430 ///\r
431 UINT64 BufferSize;\r
432 ///\r
433 /// Pointer to the data buffer. Data that is downloaded from the\r
434 /// MTFTPv6 server is stored here. Data that is uploaded to the\r
435 /// MTFTPv6 server is read from here. Ignored if BufferSize is zero.\r
436 ///\r
437 VOID *Buffer;\r
438 ///\r
439 /// Pointer to the context that will be used by CheckPacket,\r
440 /// TimeoutCallback and PacketNeeded.\r
441 ///\r
442 VOID *Context;\r
443 ///\r
444 /// Pointer to the callback function to check the contents of the\r
445 /// received packet.\r
446 ///\r
447 EFI_MTFTP6_CHECK_PACKET CheckPacket;\r
448 ///\r
449 /// Pointer to the function to be called when a timeout occurs.\r
450 ///\r
451 EFI_MTFTP6_TIMEOUT_CALLBACK TimeoutCallback;\r
452 ///\r
453 /// Pointer to the function to provide the needed packet contents.\r
454 /// Only used in WriteFile() operation.\r
455 ///\r
456 EFI_MTFTP6_PACKET_NEEDED PacketNeeded;\r
457};\r
458\r
459/**\r
460 Read the current operational settings.\r
461\r
462 The GetModeData() function reads the current operational settings of this EFI MTFTPv6\r
463 Protocol driver instance.\r
464\r
465 @param[in] This Pointer to the EFI_MTFTP6_PROTOCOL instance.\r
466 @param[out] ModeData The buffer in which the EFI MTFTPv6 Protocol driver mode\r
467 data is returned.\r
468\r
469 @retval EFI_SUCCESS The configuration data was successfully returned.\r
470 @retval EFI_OUT_OF_RESOURCES The required mode data could not be allocated.\r
471 @retval EFI_INVALID_PARAMETER This is NULL or ModeData is NULL.\r
472\r
473**/\r
474typedef\r
475EFI_STATUS\r
476(EFIAPI *EFI_MTFTP6_GET_MODE_DATA)(\r
477 IN EFI_MTFTP6_PROTOCOL *This,\r
478 OUT EFI_MTFTP6_MODE_DATA *ModeData\r
479 );\r
480\r
481/**\r
482 Initializes, changes, or resets the default operational setting for this EFI MTFTPv6\r
483 Protocol driver instance.\r
484\r
485 The Configure() function is used to set and change the configuration data for this EFI\r
486 MTFTPv6 Protocol driver instance. The configuration data can be reset to startup defaults by calling\r
487 Configure() with MtftpConfigData set to NULL. Whenever the instance is reset, any\r
488 pending operation is aborted. By changing the EFI MTFTPv6 Protocol driver instance configuration\r
489 data, the client can connect to different MTFTPv6 servers. The configuration parameters in\r
490 MtftpConfigData are used as the default parameters in later MTFTPv6 operations and can be\r
491 overridden in later operations.\r
492\r
493 @param[in] This Pointer to the EFI_MTFTP6_PROTOCOL instance.\r
494 @param[in] MtftpConfigData Pointer to the configuration data structure.\r
495\r
496 @retval EFI_SUCCESS The EFI MTFTPv6 Protocol instance was configured successfully.\r
497 @retval EFI_INVALID_PARAMETER One or more following conditions are TRUE:\r
498 - This is NULL.\r
499 - MtftpConfigData.StationIp is neither zero nor one\r
500 of the configured IP addresses in the underlying IPv6 driver.\r
501 - MtftpCofigData.ServerIp is not a valid IPv6 unicast address.\r
502 @retval EFI_ACCESS_DENIED - The configuration could not be changed at this time because there\r
503 is some MTFTP background operation in progress.\r
504 - MtftpCofigData.LocalPort is already in use.\r
505 @retval EFI_NO_MAPPING The underlying IPv6 driver was responsible for choosing a source\r
506 address for this instance, but no source address was available for use.\r
507 @retval EFI_OUT_OF_RESOURCES The EFI MTFTPv6 Protocol driver instance data could not be\r
508 allocated.\r
509 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred. The EFI\r
510 MTFTPv6 Protocol driver instance is not configured.\r
511\r
512\r
513**/\r
514typedef\r
515EFI_STATUS\r
516(EFIAPI *EFI_MTFTP6_CONFIGURE)(\r
517 IN EFI_MTFTP6_PROTOCOL *This,\r
518 IN EFI_MTFTP6_CONFIG_DATA *MtftpConfigData OPTIONAL\r
519);\r
520\r
521/**\r
522 Get information about a file from an MTFTPv6 server.\r
523\r
524 The GetInfo() function assembles an MTFTPv6 request packet with options, sends it to the\r
525 MTFTPv6 server, and may return an MTFTPv6 OACK, MTFTPv6 ERROR, or ICMP ERROR packet.\r
526 Retries occur only if no response packets are received from the MTFTPv6 server before the\r
527 timeout expires.\r
528\r
529 @param[in] This Pointer to the EFI_MTFTP6_PROTOCOL instance.\r
530 @param[in] OverrideData Data that is used to override the existing parameters. If NULL, the\r
531 default parameters that were set in the EFI_MTFTP6_PROTOCOL.Configure()\r
532 function are used.\r
533 @param[in] Filename Pointer to null-terminated ASCII file name string.\r
534 @param[in] ModeStr Pointer to null-terminated ASCII mode string. If NULL, octet will be used\r
535 @param[in] OptionCount Number of option/value string pairs in OptionList.\r
536 @param[in] OptionList Pointer to array of option/value string pairs. Ignored if\r
537 OptionCount is zero.\r
538 @param[out] PacketLength The number of bytes in the returned packet.\r
539 @param[out] Packet The pointer to the received packet. This buffer must be freed by\r
540 the caller.\r
541\r
542 @retval EFI_SUCCESS An MTFTPv6 OACK packet was received and is in the Packet.\r
543 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:\r
544 - This is NULL.\r
545 - Filename is NULL\r
546 - OptionCount is not zero and OptionList is NULL.\r
547 - One or more options in OptionList have wrong format.\r
548 - PacketLength is NULL.\r
549 - OverrideData.ServerIp is not valid unicast IPv6 addresses.\r
550 @retval EFI_UNSUPPORTED One or more options in the OptionList are unsupported by\r
551 this implementation.\r
552 @retval EFI_NOT_STARTED The EFI MTFTPv6 Protocol driver has not been started.\r
553 @retval EFI_NO_MAPPING The underlying IPv6 driver was responsible for choosing a source\r
554 address for this instance, but no source address was available for use.\r
555 @retval EFI_ACCESS_DENIED The previous operation has not completed yet.\r
556 @retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated.\r
557 @retval EFI_TFTP_ERROR An MTFTPv6 ERROR packet was received and is in the Packet.\r
558 @retval EFI_NETWORK_UNREACHABLE An ICMP network unreachable error packet was received and the Packet is set to NULL.\r
559 @retval EFI_HOST_UNREACHABLE An ICMP host unreachable error packet was received and the Packet is set to NULL.\r
560 @retval EFI_PROTOCOL_UNREACHABLE An ICMP protocol unreachable error packet was received and the Packet is set to NULL.\r
561 @retval EFI_PORT_UNREACHABLE An ICMP port unreachable error packet was received and the Packet is set to NULL.\r
562 @retval EFI_ICMP_ERROR Some other ICMP ERROR packet was received and the Packet is set to NULL.\r
563 @retval EFI_PROTOCOL_ERROR An unexpected MTFTPv6 packet was received and is in the Packet.\r
564 @retval EFI_TIMEOUT No responses were received from the MTFTPv6 server.\r
565 @retval EFI_DEVICE_ERROR An unexpected network error or system error occurred.\r
566 @retval EFI_NO_MEDIA There was a media error.\r
567\r
568**/\r
569typedef\r
570EFI_STATUS\r
571(EFIAPI *EFI_MTFTP6_GET_INFO)(\r
572 IN EFI_MTFTP6_PROTOCOL *This,\r
573 IN EFI_MTFTP6_OVERRIDE_DATA *OverrideData OPTIONAL,\r
574 IN UINT8 *Filename,\r
575 IN UINT8 *ModeStr OPTIONAL,\r
576 IN UINT8 OptionCount,\r
577 IN EFI_MTFTP6_OPTION *OptionList OPTIONAL,\r
578 OUT UINT32 *PacketLength,\r
579 OUT EFI_MTFTP6_PACKET **Packet OPTIONAL\r
580);\r
581\r
582/**\r
583 Parse the options in an MTFTPv6 OACK packet.\r
584\r
585 The ParseOptions() function parses the option fields in an MTFTPv6 OACK packet and\r
586 returns the number of options that were found and optionally a list of pointers to\r
587 the options in the packet.\r
588 If one or more of the option fields are not valid, then EFI_PROTOCOL_ERROR is returned\r
589 and *OptionCount and *OptionList stop at the last valid option.\r
590\r
591 @param[in] This Pointer to the EFI_MTFTP6_PROTOCOL instance.\r
592 @param[in] PacketLen Length of the OACK packet to be parsed.\r
593 @param[in] Packet Pointer to the OACK packet to be parsed.\r
594 @param[out] OptionCount Pointer to the number of options in the following OptionList.\r
595 @param[out] OptionList Pointer to EFI_MTFTP6_OPTION storage. Each pointer in the\r
596 OptionList points to the corresponding MTFTP option buffer\r
597 in the Packet. Call the EFI Boot Service FreePool() to\r
598 release the OptionList if the options in this OptionList\r
599 are not needed any more.\r
600\r
601 @retval EFI_SUCCESS The OACK packet was valid and the OptionCount and\r
602 OptionList parameters have been updated.\r
603 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:\r
604 - PacketLen is 0.\r
605 - Packet is NULL or Packet is not a valid MTFTPv6 packet.\r
606 - OptionCount is NULL.\r
607 @retval EFI_NOT_FOUND No options were found in the OACK packet.\r
608 @retval EFI_OUT_OF_RESOURCES Storage for the OptionList array can not be allocated.\r
609 @retval EFI_PROTOCOL_ERROR One or more of the option fields is invalid.\r
610\r
611**/\r
612typedef\r
613EFI_STATUS\r
614(EFIAPI *EFI_MTFTP6_PARSE_OPTIONS)(\r
615 IN EFI_MTFTP6_PROTOCOL *This,\r
616 IN UINT32 PacketLen,\r
617 IN EFI_MTFTP6_PACKET *Packet,\r
618 OUT UINT32 *OptionCount,\r
619 OUT EFI_MTFTP6_OPTION **OptionList OPTIONAL\r
620 );\r
621\r
622/**\r
623 Download a file from an MTFTPv6 server.\r
624\r
625 The ReadFile() function is used to initialize and start an MTFTPv6 download process and\r
626 optionally wait for completion. When the download operation completes, whether successfully or\r
627 not, the Token.Status field is updated by the EFI MTFTPv6 Protocol driver and then\r
628 Token.Event is signaled if it is not NULL.\r
629\r
630 Data can be downloaded from the MTFTPv6 server into either of the following locations:\r
631 - A fixed buffer that is pointed to by Token.Buffer\r
632 - A download service function that is pointed to by Token.CheckPacket\r
633\r
634 If both Token.Buffer and Token.CheckPacket are used, then Token.CheckPacket\r
635 will be called first. If the call is successful, the packet will be stored in Token.Buffer.\r
636\r
637 @param[in] This Pointer to the EFI_MTFTP6_PROTOCOL instance.\r
638 @param[in] Token Pointer to the token structure to provide the parameters that are\r
639 used in this operation.\r
640\r
641 @retval EFI_SUCCESS The data file has been transferred successfully.\r
642 @retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated.\r
643 @retval EFI_BUFFER_TOO_SMALL BufferSize is not zero but not large enough to hold the\r
644 downloaded data in downloading process.\r
645 @retval EFI_ABORTED Current operation is aborted by user.\r
646 @retval EFI_NETWORK_UNREACHABLE An ICMP network unreachable error packet was received.\r
647 @retval EFI_HOST_UNREACHABLE An ICMP host unreachable error packet was received.\r
648 @retval EFI_PROTOCOL_UNREACHABLE An ICMP protocol unreachable error packet was received.\r
649 @retval EFI_PORT_UNREACHABLE An ICMP port unreachable error packet was received.\r
650 @retval EFI_ICMP_ERROR An ICMP ERROR packet was received.\r
651 @retval EFI_TIMEOUT No responses were received from the MTFTPv6 server.\r
652 @retval EFI_TFTP_ERROR An MTFTPv6 ERROR packet was received.\r
653 @retval EFI_DEVICE_ERROR An unexpected network error or system error occurred.\r
654 @retval EFI_NO_MEDIA There was a media error.\r
655\r
656**/\r
657typedef\r
658EFI_STATUS\r
659(EFIAPI *EFI_MTFTP6_READ_FILE)(\r
660 IN EFI_MTFTP6_PROTOCOL *This,\r
661 IN EFI_MTFTP6_TOKEN *Token\r
662 );\r
663\r
664/**\r
665 Send a file to an MTFTPv6 server. May be unsupported in some implementations.\r
666\r
667 The WriteFile() function is used to initialize an uploading operation with the given option list\r
668 and optionally wait for completion. If one or more of the options is not supported by the server, the\r
669 unsupported options are ignored and a standard TFTP process starts instead. When the upload\r
670 process completes, whether successfully or not, Token.Event is signaled, and the EFI MTFTPv6\r
671 Protocol driver updates Token.Status.\r
672\r
673 The caller can supply the data to be uploaded in the following two modes:\r
674 - Through the user-provided buffer\r
675 - Through a callback function\r
676\r
677 With the user-provided buffer, the Token.BufferSize field indicates the length of the buffer,\r
678 and the driver will upload the data in the buffer. With an EFI_MTFTP6_PACKET_NEEDED\r
679 callback function, the driver will call this callback function to get more data from the user to upload.\r
680 See the definition of EFI_MTFTP6_PACKET_NEEDED for more information. These two modes\r
681 cannot be used at the same time. The callback function will be ignored if the user provides the\r
682 buffer.\r
683\r
684 @param[in] This Pointer to the EFI_MTFTP6_PROTOCOL instance.\r
685 @param[in] Token Pointer to the token structure to provide the parameters that are\r
686 used in this operation.\r
687\r
688 @retval EFI_SUCCESS The upload session has started.\r
689 @retval EFI_UNSUPPORTED The operation is not supported by this implementation.\r
690 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:\r
691 - This is NULL.\r
692 - Token is NULL.\r
693 - Token.Filename is NULL.\r
694 - Token.OptionCount is not zero and Token.OptionList is NULL.\r
695 - One or more options in Token.OptionList have wrong format.\r
696 - Token.Buffer and Token.PacketNeeded are both NULL.\r
697 - Token.OverrideData.ServerIp is not valid unicast IPv6 addresses.\r
698 @retval EFI_UNSUPPORTED One or more options in the Token.OptionList are not\r
699 supported by this implementation.\r
700 @retval EFI_NOT_STARTED The EFI MTFTPv6 Protocol driver has not been started.\r
701 @retval EFI_NO_MAPPING The underlying IPv6 driver was responsible for choosing a source\r
702 address for this instance, but no source address was available for use.\r
703 @retval EFI_ALREADY_STARTED This Token is already being used in another MTFTPv6 session.\r
704 @retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated.\r
705 @retval EFI_ACCESS_DENIED The previous operation has not completed yet.\r
706 @retval EFI_DEVICE_ERROR An unexpected network error or system error occurred.\r
707\r
708**/\r
709typedef\r
710EFI_STATUS\r
711(EFIAPI *EFI_MTFTP6_WRITE_FILE)(\r
712 IN EFI_MTFTP6_PROTOCOL *This,\r
713 IN EFI_MTFTP6_TOKEN *Token\r
714 );\r
715\r
716/**\r
717 Download a data file directory from an MTFTPv6 server. May be unsupported in some implementations.\r
718\r
719 The ReadDirectory() function is used to return a list of files on the MTFTPv6 server that are\r
720 logically (or operationally) related to Token.Filename. The directory request packet that is sent\r
721 to the server is built with the option list that was provided by caller, if present.\r
722\r
723 The file information that the server returns is put into either of the following locations:\r
724 - A fixed buffer that is pointed to by Token.Buffer\r
725 - A download service function that is pointed to by Token.CheckPacket\r
726\r
727 If both Token.Buffer and Token.CheckPacket are used, then Token.CheckPacket\r
728 will be called first. If the call is successful, the packet will be stored in Token.Buffer.\r
729\r
730 The returned directory listing in the Token.Buffer or EFI_MTFTP6_PACKET consists of a list\r
731 of two or three variable-length ASCII strings, each terminated by a null character, for each file in the\r
732 directory. If the multicast option is involved, the first field of each directory entry is the static\r
733 multicast IP address and UDP port number that is associated with the file name. The format of the\r
734 field is ip:ip:ip:ip:port. If the multicast option is not involved, this field and its terminating\r
735 null character are not present.\r
736\r
737 The next field of each directory entry is the file name and the last field is the file information string.\r
738 The information string contains the file size and the create/modify timestamp. The format of the\r
739 information string is filesize yyyy-mm-dd hh:mm:ss:ffff. The timestamp is\r
740 Coordinated Universal Time (UTC; also known as Greenwich Mean Time [GMT]).\r
741\r
742 @param[in] This Pointer to the EFI_MTFTP6_PROTOCOL instance.\r
743 @param[in] Token Pointer to the token structure to provide the parameters that are\r
744 used in this operation.\r
745\r
746 @retval EFI_SUCCESS The MTFTPv6 related file "directory" has been downloaded.\r
747 @retval EFI_UNSUPPORTED The EFI MTFTPv6 Protocol driver does not support this function.\r
748 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:\r
749 - This is NULL.\r
750 - Token is NULL.\r
751 - Token.Filename is NULL.\r
752 - Token.OptionCount is not zero and Token.OptionList is NULL.\r
753 - One or more options in Token.OptionList have wrong format.\r
754 - Token.Buffer and Token.CheckPacket are both NULL.\r
755 - Token.OverrideData.ServerIp is not valid unicast IPv6 addresses.\r
756 @retval EFI_UNSUPPORTED One or more options in the Token.OptionList are not\r
757 supported by this implementation.\r
758 @retval EFI_NOT_STARTED The EFI MTFTPv6 Protocol driver has not been started.\r
759 @retval EFI_NO_MAPPING The underlying IPv6 driver was responsible for choosing a source\r
760 address for this instance, but no source address was available for use.\r
761 @retval EFI_ALREADY_STARTED This Token is already being used in another MTFTPv6 session.\r
762 @retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated.\r
763 @retval EFI_ACCESS_DENIED The previous operation has not completed yet.\r
764 @retval EFI_DEVICE_ERROR An unexpected network error or system error occurred.\r
765\r
766**/\r
767typedef\r
768EFI_STATUS\r
769(EFIAPI *EFI_MTFTP6_READ_DIRECTORY)(\r
770 IN EFI_MTFTP6_PROTOCOL *This,\r
771 IN EFI_MTFTP6_TOKEN *Token\r
772);\r
773\r
774/**\r
775 Polls for incoming data packets and processes outgoing data packets.\r
776\r
777 The Poll() function can be used by network drivers and applications to increase the rate that data\r
778 packets are moved between the communications device and the transmit and receive queues.\r
779 In some systems, the periodic timer event in the managed network driver may not poll the\r
780 underlying communications device fast enough to transmit and/or receive all data packets without\r
781 missing incoming packets or dropping outgoing packets. Drivers and applications that are\r
782 experiencing packet loss should try calling the Poll() function more often.\r
783\r
784 @param[in] This Pointer to the EFI_MTFTP6_PROTOCOL instance.\r
785\r
786 @retval EFI_SUCCESS Incoming or outgoing data was processed.\r
787 @retval EFI_NOT_STARTED This EFI MTFTPv6 Protocol instance has not been started.\r
788 @retval EFI_INVALID_PARAMETER This is NULL.\r
789 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.\r
790 @retval EFI_TIMEOUT Data was dropped out of the transmit and/or receive queue.\r
791 Consider increasing the polling rate.\r
792\r
793**/\r
794typedef\r
795EFI_STATUS\r
796(EFIAPI *EFI_MTFTP6_POLL)(\r
797 IN EFI_MTFTP6_PROTOCOL *This\r
798 );\r
799\r
800///\r
801/// The EFI_MTFTP6_PROTOCOL is designed to be used by UEFI drivers and applications to transmit\r
802/// and receive data files. The EFI MTFTPv6 Protocol driver uses the underlying EFI UDPv6 Protocol\r
803/// driver and EFI IPv6 Protocol driver.\r
804///\r
805struct _EFI_MTFTP6_PROTOCOL {\r
806 EFI_MTFTP6_GET_MODE_DATA GetModeData;\r
807 EFI_MTFTP6_CONFIGURE Configure;\r
808 EFI_MTFTP6_GET_INFO GetInfo;\r
809 EFI_MTFTP6_PARSE_OPTIONS ParseOptions;\r
810 EFI_MTFTP6_READ_FILE ReadFile;\r
811 EFI_MTFTP6_WRITE_FILE WriteFile;\r
812 EFI_MTFTP6_READ_DIRECTORY ReadDirectory;\r
813 EFI_MTFTP6_POLL Poll;\r
814};\r
815\r
816extern EFI_GUID gEfiMtftp6ServiceBindingProtocolGuid;\r
817extern EFI_GUID gEfiMtftp6ProtocolGuid;\r
818\r
819#endif\r
820\r