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