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