]> git.proxmox.com Git - mirror_edk2.git/blob - NetworkPkg/Mtftp6Dxe/Mtftp6Impl.c
1. Fix a bug in PXE driver that the PXE boot do not restart if a new boot option...
[mirror_edk2.git] / NetworkPkg / Mtftp6Dxe / Mtftp6Impl.c
1 /** @file
2 This EFI_MTFTP6_PROTOCOL interface implementation.
3
4 It supports the following RFCs:
5 RFC1350 - THE TFTP PROTOCOL (REVISION 2)
6 RFC2090 - TFTP Multicast Option
7 RFC2347 - TFTP Option Extension
8 RFC2348 - TFTP Blocksize Option
9 RFC2349 - TFTP Timeout Interval and Transfer Size Options
10
11 Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>
12
13 This program and the accompanying materials
14 are licensed and made available under the terms and conditions of the BSD License
15 which accompanies this distribution. The full text of the license may be found at
16 http://opensource.org/licenses/bsd-license.php.
17
18 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
19 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
20
21 **/
22
23 #include "Mtftp6Impl.h"
24
25 EFI_MTFTP6_PROTOCOL gMtftp6ProtocolTemplate = {
26 EfiMtftp6GetModeData,
27 EfiMtftp6Configure,
28 EfiMtftp6GetInfo,
29 EfiMtftp6ParseOptions,
30 EfiMtftp6ReadFile,
31 EfiMtftp6WriteFile,
32 EfiMtftp6ReadDirectory,
33 EfiMtftp6Poll
34 };
35
36 /**
37 Returns the current operating mode data for the MTFTP6 instance.
38
39 The GetModeData() function returns the current operating mode and
40 cached data packet for the MTFTP6 instance.
41
42 @param[in] This Pointer to the EFI_MTFTP6_PROTOCOL instance.
43 @param[out] ModeData The buffer in which the EFI MTFTPv6 Protocol driver mode
44 data is returned.
45
46 @retval EFI_SUCCESS The configuration data was returned successfully.
47 @retval EFI_OUT_OF_RESOURCES The required mode data could not be allocated.
48 @retval EFI_INVALID_PARAMETER This is NULL or ModeData is NULL.
49
50 **/
51 EFI_STATUS
52 EFIAPI
53 EfiMtftp6GetModeData (
54 IN EFI_MTFTP6_PROTOCOL *This,
55 OUT EFI_MTFTP6_MODE_DATA *ModeData
56 )
57 {
58 MTFTP6_INSTANCE *Instance;
59 EFI_TPL OldTpl;
60
61 if (This == NULL || ModeData == NULL) {
62 return EFI_INVALID_PARAMETER;
63 }
64
65 OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
66 Instance = MTFTP6_INSTANCE_FROM_THIS (This);
67
68 //
69 // Copy back the configure data if the instance already configured.
70 //
71 if (Instance->Config != NULL) {
72 CopyMem (
73 &ModeData->ConfigData,
74 Instance->Config,
75 sizeof (EFI_MTFTP6_CONFIG_DATA)
76 );
77 } else {
78 ZeroMem (
79 &ModeData->ConfigData,
80 sizeof (EFI_MTFTP6_CONFIG_DATA)
81 );
82 }
83
84 //
85 // Set the current support options in mode data.
86 //
87 ModeData->SupportedOptionCount = MTFTP6_SUPPORTED_OPTIONS_NUM;
88 ModeData->SupportedOptions = (UINT8 **) mMtftp6SupportedOptions;
89
90 gBS->RestoreTPL (OldTpl);
91
92 return EFI_SUCCESS;
93 }
94
95
96 /**
97 Initializes, changes, or resets the default operational setting for
98 this EFI MTFTPv6 Protocol driver instance.
99
100 The Configure() function is used to set and change the configuration
101 data for this EFI MTFTPv6 Protocol driver instance. The configuration
102 data can be reset to startup defaults by calling Configure() with
103 MtftpConfigData set to NULL. Whenever the instance is reset, any
104 pending operation is aborted. By changing the EFI MTFTPv6 Protocol
105 driver instance configuration data, the client can connect to
106 different MTFTPv6 servers. The configuration parameters in
107 MtftpConfigData are used as the default parameters in later MTFTPv6
108 operations and can be overridden in later operations.
109
110 @param[in] This Pointer to the EFI_MTFTP6_PROTOCOL instance.
111 @param[in] MtftpConfigData Pointer to the configuration data structure.
112
113 @retval EFI_SUCCESS The EFI MTFTPv6 Protocol instance was configured successfully.
114 @retval EFI_INVALID_PARAMETER One or more following conditions are TRUE:
115 - This is NULL.
116 - MtftpConfigData.StationIp is neither zero nor one
117 of the configured IP addresses in the underlying IPv6 driver.
118 - MtftpCofigData.ServerIp is not a valid IPv6 unicast address.
119 Note: It does not match the UEFI 2.3 Specification.
120 @retval EFI_ACCESS_DENIED - The configuration could not be changed at this time because there
121 is some MTFTP background operation in progress.
122 - MtftpCofigData.LocalPort is already in use.
123 Note: It does not match the UEFI 2.3 Specification.
124 @retval EFI_NO_MAPPING The underlying IPv6 driver was responsible for choosing a source
125 address for this instance, but no source address was available for use.
126 @retval EFI_OUT_OF_RESOURCES The EFI MTFTPv6 Protocol driver instance data could not be
127 allocated.
128 Note: It is not defined in the UEFI 2.3 Specification.
129 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred. The EFI
130 MTFTPv6 Protocol driver instance is not configured.
131 Note: It is not defined in the UEFI 2.3 Specification.
132
133 **/
134 EFI_STATUS
135 EFIAPI
136 EfiMtftp6Configure (
137 IN EFI_MTFTP6_PROTOCOL *This,
138 IN EFI_MTFTP6_CONFIG_DATA *MtftpConfigData OPTIONAL
139 )
140 {
141 MTFTP6_SERVICE *Service;
142 MTFTP6_INSTANCE *Instance;
143 EFI_UDP6_PROTOCOL *Udp6;
144 EFI_UDP6_CONFIG_DATA Udp6Cfg;
145 EFI_STATUS Status;
146 EFI_TPL OldTpl;
147
148 if (This == NULL) {
149 return EFI_INVALID_PARAMETER;
150 }
151
152 if (MtftpConfigData != NULL && !NetIp6IsValidUnicast (&MtftpConfigData->ServerIp)) {
153 return EFI_INVALID_PARAMETER;
154 }
155
156 OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
157 Instance = MTFTP6_INSTANCE_FROM_THIS (This);
158 Service = Instance->Service;
159 Status = EFI_SUCCESS;
160
161 if (MtftpConfigData == NULL) {
162 //
163 // Configure the instance as NULL to abort the current session.
164 //
165 Mtftp6OperationClean (Instance, EFI_ABORTED);
166 FreePool (Instance->Config);
167 Instance->Config = NULL;
168 } else {
169 //
170 // It's not allowed to configure one instance twice without configure null.
171 //
172 if (Instance->Config != NULL) {
173 Status = EFI_ACCESS_DENIED;
174 goto ON_EXIT;
175 }
176 //
177 // Allocate the configure buffer of the instance and store the user's data.
178 //
179 Instance->Config = AllocateZeroPool (sizeof (EFI_MTFTP6_CONFIG_DATA));
180
181 if (Instance->Config == NULL) {
182 Status = EFI_OUT_OF_RESOURCES;
183 goto ON_EXIT;
184 }
185
186 CopyMem (Instance->Config, MtftpConfigData, sizeof (EFI_MTFTP6_CONFIG_DATA));
187
188 //
189 // Don't configure the udpio here because each operation might override
190 // the configuration, so delay udpio configuration in each operation.
191 //
192 if (Instance->UdpIo == NULL) {
193 Instance->UdpIo = UdpIoCreateIo (
194 Service->Controller,
195 Service->Image,
196 Mtftp6ConfigDummyUdpIo,
197 UDP_IO_UDP6_VERSION,
198 NULL
199 );
200 }
201
202 if (Instance->UdpIo == NULL) {
203 Status = EFI_OUT_OF_RESOURCES;
204 goto ON_EXIT;
205 }
206
207 //
208 // Continue to configure the downside Udp6 instance by user's data.
209 //
210 ZeroMem (&Udp6Cfg, sizeof (EFI_UDP6_CONFIG_DATA));
211
212 Udp6Cfg.AcceptPromiscuous = FALSE;
213 Udp6Cfg.AcceptAnyPort = FALSE;
214 Udp6Cfg.AllowDuplicatePort = FALSE;
215 Udp6Cfg.TrafficClass = 0;
216 Udp6Cfg.HopLimit = 128;
217 Udp6Cfg.ReceiveTimeout = 0;
218 Udp6Cfg.TransmitTimeout = 0;
219 Udp6Cfg.StationPort = Instance->Config->LocalPort;
220 Udp6Cfg.RemotePort = Instance->Config->InitialServerPort;
221
222 CopyMem (
223 &Udp6Cfg.StationAddress,
224 &Instance->Config->StationIp,
225 sizeof(EFI_IPv6_ADDRESS)
226 );
227
228 CopyMem (
229 &Udp6Cfg.RemoteAddress,
230 &Instance->Config->ServerIp,
231 sizeof (EFI_IPv6_ADDRESS)
232 );
233
234 Udp6 = Instance->UdpIo->Protocol.Udp6;
235 Status = Udp6->Configure (Udp6, &Udp6Cfg);
236
237 if (EFI_ERROR (Status)) {
238 goto ON_EXIT;
239 }
240 }
241
242 ON_EXIT:
243 if (EFI_ERROR (Status)) {
244 if (Instance->Config != NULL) {
245 FreePool (Instance->Config);
246 Instance->Config = NULL;
247 }
248 if (Instance->UdpIo != NULL) {
249 UdpIoFreeIo (Instance->UdpIo);
250 Instance->UdpIo = NULL;
251 }
252 }
253 gBS->RestoreTPL (OldTpl);
254 return Status;
255 }
256
257
258 /**
259 Get the information of the download from the server.
260
261 The GetInfo() function assembles an MTFTPv6 request packet
262 with options, sends it to the MTFTPv6 server, and may return
263 an MTFTPv6 OACK, MTFTPv6 ERROR, or ICMP ERROR packet. Retries
264 occur only if no response packets are received from the MTFTPv6
265 server before the timeout expires.
266
267 @param[in] This Pointer to the EFI_MTFTP6_PROTOCOL instance.
268 @param[in] OverrideData Data that is used to override the existing parameters. If NULL, the
269 default parameters that were set in the EFI_MTFTP6_PROTOCOL.Configure()
270 function are used.
271 @param[in] Filename Pointer to null-terminated ASCII file name string.
272 @param[in] ModeStr Pointer to null-terminated ASCII mode string. If NULL, octet will be used.
273 @param[in] OptionCount Number of option/value string pairs in OptionList.
274 @param[in] OptionList Pointer to array of option/value string pairs. Ignored if
275 OptionCount is zero.
276 @param[out] PacketLength The number of bytes in the returned packet.
277 @param[out] Packet The pointer to the received packet. This buffer must be freed by
278 the caller.
279
280 @retval EFI_SUCCESS An MTFTPv6 OACK packet was received and is in the Packet.
281 Note: It does not match the UEFI 2.3 Specification.
282 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
283 - This is NULL.
284 - Filename is NULL.
285 - OptionCount is not zero and OptionList is NULL.
286 - One or more options in OptionList have wrong format.
287 - PacketLength is NULL.
288 - OverrideData.ServerIp is not valid unicast IPv6 addresses.
289 @retval EFI_UNSUPPORTED One or more options in the OptionList are unsupported by
290 this implementation.
291 @retval EFI_NOT_STARTED The EFI MTFTPv6 Protocol driver has not been started.
292 @retval EFI_NO_MAPPING The underlying IPv6 driver was responsible for choosing a source
293 address for this instance, but no source address was available for use.
294 @retval EFI_ACCESS_DENIED The previous operation has not completed yet.
295 @retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated.
296 @retval EFI_TFTP_ERROR An MTFTPv6 ERROR packet was received and is in the Packet.
297 @retval EFI_NETWORK_UNREACHABLE An ICMP network unreachable error packet was received and the Packet is set to NULL.
298 Note: It is not defined in UEFI 2.3 Specification.
299 @retval EFI_HOST_UNREACHABLE An ICMP host unreachable error packet was received and the Packet is set to NULL.
300 Note: It is not defined in the UEFI 2.3 Specification.
301 @retval EFI_PROTOCOL_UNREACHABLE An ICMP protocol unreachable error packet was received and the Packet is set to NULL.
302 Note: It is not defined in the UEFI 2.3 Specification.
303 @retval EFI_PORT_UNREACHABLE An ICMP port unreachable error packet was received and the Packet is set to NULL.
304 @retval EFI_ICMP_ERROR Some other ICMP ERROR packet was received and the Packet is set to NULL.
305 Note: It does not match the UEFI 2.3 Specification.
306 @retval EFI_PROTOCOL_ERROR An unexpected MTFTPv6 packet was received and is in the Packet.
307 @retval EFI_TIMEOUT No responses were received from the MTFTPv6 server.
308 @retval EFI_DEVICE_ERROR An unexpected network error or system error occurred.
309 @retval EFI_NO_MEDIA There was a media error.
310
311 **/
312 EFI_STATUS
313 EFIAPI
314 EfiMtftp6GetInfo (
315 IN EFI_MTFTP6_PROTOCOL *This,
316 IN EFI_MTFTP6_OVERRIDE_DATA *OverrideData OPTIONAL,
317 IN UINT8 *Filename,
318 IN UINT8 *ModeStr OPTIONAL,
319 IN UINT8 OptionCount,
320 IN EFI_MTFTP6_OPTION *OptionList OPTIONAL,
321 OUT UINT32 *PacketLength,
322 OUT EFI_MTFTP6_PACKET **Packet OPTIONAL
323 )
324 {
325 EFI_STATUS Status;
326 EFI_MTFTP6_TOKEN Token;
327 MTFTP6_GETINFO_CONTEXT Context;
328
329 if (This == NULL ||
330 Filename == NULL ||
331 PacketLength == NULL ||
332 (OptionCount != 0 && OptionList == NULL) ||
333 (OverrideData != NULL && !NetIp6IsValidUnicast (&OverrideData->ServerIp))
334 ) {
335 return EFI_INVALID_PARAMETER;
336 }
337
338 if (Packet != NULL) {
339 *Packet = NULL;
340 }
341
342 *PacketLength = 0;
343
344 Context.Packet = Packet;
345 Context.PacketLen = PacketLength;
346 Context.Status = EFI_SUCCESS;
347
348 //
349 // Fill fields of the Token for GetInfo operation.
350 //
351 Token.Status = EFI_SUCCESS;
352 Token.Event = NULL;
353 Token.OverrideData = OverrideData;
354 Token.Filename = Filename;
355 Token.ModeStr = ModeStr;
356 Token.OptionCount = OptionCount;
357 Token.OptionList = OptionList;
358 Token.BufferSize = 0;
359 Token.Buffer = NULL;
360 Token.Context = &Context;
361 Token.CheckPacket = Mtftp6CheckPacket;
362 Token.TimeoutCallback = NULL;
363 Token.PacketNeeded = NULL;
364
365 //
366 // Start the GetInfo operation by issue the Token.
367 //
368 Status = Mtftp6OperationStart (This, &Token, EFI_MTFTP6_OPCODE_RRQ);
369
370 if (Status == EFI_ABORTED) {
371 //
372 // Return the status if failed to issue.
373 //
374 return Context.Status;
375 }
376
377 return Status;
378 }
379
380
381 /**
382 Parse the options in an MTFTPv6 OACK packet.
383
384 The ParseOptions() function parses the option fields in an MTFTPv6 OACK
385 packet and returns the number of options that were found, and optionally,
386 a list of pointers to the options in the packet. If one or more of the
387 option fields are not valid, then EFI_PROTOCOL_ERROR is returned and
388 *OptionCount and *OptionList stop at the last valid option.
389
390 @param[in] This Pointer to the EFI_MTFTP6_PROTOCOL instance.
391 @param[in] PacketLen Length of the OACK packet to be parsed.
392 @param[in] Packet Pointer to the OACK packet to be parsed.
393 @param[out] OptionCount Pointer to the number of options in the following OptionList.
394 @param[out] OptionList Pointer to EFI_MTFTP6_OPTION storage. Each pointer in the
395 OptionList points to the corresponding MTFTP option buffer
396 in the Packet. Call the EFI Boot Service FreePool() to
397 release the OptionList if the options in this OptionList
398 are not needed anymore.
399
400 @retval EFI_SUCCESS The OACK packet was valid and the OptionCount and
401 OptionList parameters have been updated.
402 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
403 - PacketLen is 0.
404 - Packet is NULL or Packet is not a valid MTFTPv6 packet.
405 - OptionCount is NULL.
406 @retval EFI_NOT_FOUND No options were found in the OACK packet.
407 @retval EFI_OUT_OF_RESOURCES Storage for the OptionList array can not be allocated.
408 @retval EFI_PROTOCOL_ERROR One or more of the option fields is invalid.
409
410 **/
411 EFI_STATUS
412 EFIAPI
413 EfiMtftp6ParseOptions (
414 IN EFI_MTFTP6_PROTOCOL *This,
415 IN UINT32 PacketLen,
416 IN EFI_MTFTP6_PACKET *Packet,
417 OUT UINT32 *OptionCount,
418 OUT EFI_MTFTP6_OPTION **OptionList OPTIONAL
419 )
420 {
421 if (This == NULL) {
422 return EFI_INVALID_PARAMETER;
423 }
424
425 return Mtftp6ParseStart (Packet, PacketLen, OptionCount, OptionList);
426 }
427
428
429 /**
430 Download a file from an MTFTPv6 server.
431
432 The ReadFile() function is used to initialize and start an MTFTPv6 download
433 process, and optionally, wait for completion. When the download operation
434 completes, whether successfully or not, the Token.Status field is updated
435 by the EFI MTFTPv6 Protocol driver, and then Token.Event is signaled if it
436 is not NULL.
437 Data can be downloaded from the MTFTPv6 server into either of the following
438 locations:
439 - A fixed buffer that is pointed to by Token.Buffer
440 - A download service function that is pointed to by Token.CheckPacket.
441 If both Token.Buffer and Token.CheckPacket are used, then Token.CheckPacket
442 will be called first. If the call is successful, the packet will be stored
443 in Token.Buffer.
444
445 @param[in] This Pointer to the EFI_MTFTP6_PROTOCOL instance.
446 @param[in] Token Pointer to the token structure to provide the parameters that are
447 used in this operation.
448
449 @retval EFI_SUCCESS The data file has been transferred successfully.
450 @retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated.
451 @retval EFI_BUFFER_TOO_SMALL BufferSize is not zero but not large enough to hold the
452 downloaded data in downloading process.
453 Note: It does not match the UEFI 2.3 Specification.
454 @retval EFI_ABORTED Current operation is aborted by user.
455 @retval EFI_NETWORK_UNREACHABLE An ICMP network unreachable error packet was received.
456 Note: It is not defined in the UEFI 2.3 Specification.
457 @retval EFI_HOST_UNREACHABLE An ICMP host unreachable error packet was received.
458 Note: It is not defined in the UEFI 2.3 Specification.
459 @retval EFI_PROTOCOL_UNREACHABLE An ICMP protocol unreachable error packet was received.
460 Note: It is not defined in the UEFI 2.3 Specification.
461 @retval EFI_PORT_UNREACHABLE An ICMP port unreachable error packet was received.
462 Note: It is not defined in the UEFI 2.3 Specification.
463 @retval EFI_ICMP_ERROR An ICMP ERROR packet was received.
464 @retval EFI_TIMEOUT No responses were received from the MTFTPv6 server.
465 @retval EFI_TFTP_ERROR An MTFTPv6 ERROR packet was received.
466 @retval EFI_DEVICE_ERROR An unexpected network error or system error occurred.
467 @retval EFI_NO_MEDIA There was a media error.
468
469 **/
470 EFI_STATUS
471 EFIAPI
472 EfiMtftp6ReadFile (
473 IN EFI_MTFTP6_PROTOCOL *This,
474 IN EFI_MTFTP6_TOKEN *Token
475 )
476 {
477 return Mtftp6OperationStart (This, Token, EFI_MTFTP6_OPCODE_RRQ);
478 }
479
480
481 /**
482 Send a file to an MTFTPv6 server.
483
484 The WriteFile() function is used to initialize an uploading operation
485 with the given option list and optionally wait for completion. If one
486 or more of the options is not supported by the server, the unsupported
487 options are ignored and a standard TFTP process starts instead. When
488 the upload process completes, whether successfully or not, Token.Event
489 is signaled, and the EFI MTFTPv6 Protocol driver updates Token.Status.
490 The caller can supply the data to be uploaded in the following two modes:
491 - Through the user-provided buffer
492 - Through a callback function
493 With the user-provided buffer, the Token.BufferSize field indicates
494 the length of the buffer, and the driver will upload the data in the
495 buffer. With an EFI_MTFTP6_PACKET_NEEDED callback function, the driver
496 will call this callback function to get more data from the user to upload.
497
498 @param[in] This Pointer to the EFI_MTFTP6_PROTOCOL instance.
499 @param[in] Token Pointer to the token structure to provide the parameters that are
500 used in this operation.
501
502 @retval EFI_SUCCESS The upload session has started.
503 @retval EFI_UNSUPPORTED The operation is not supported by this implementation.
504 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
505 - This is NULL.
506 - Token is NULL.
507 - Token.Filename is NULL.
508 - Token.OptionCount is not zero and Token.OptionList is NULL.
509 - One or more options in Token.OptionList have wrong format.
510 - Token.Buffer and Token.PacketNeeded are both NULL.
511 - Token.OverrideData.ServerIp is not a valid unicast IPv6 address.
512 @retval EFI_UNSUPPORTED One or more options in the Token.OptionList are not
513 supported by this implementation.
514 @retval EFI_NOT_STARTED The EFI MTFTPv6 Protocol driver has not been started.
515 @retval EFI_NO_MAPPING The underlying IPv6 driver was responsible for choosing a source
516 address for this instance, but no source address was available for use.
517 @retval EFI_ALREADY_STARTED This Token is already being used in another MTFTPv6 session.
518 @retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated.
519 @retval EFI_ACCESS_DENIED The previous operation has not completed yet.
520 @retval EFI_DEVICE_ERROR An unexpected network error or system error occurred.
521
522 **/
523 EFI_STATUS
524 EFIAPI
525 EfiMtftp6WriteFile (
526 IN EFI_MTFTP6_PROTOCOL *This,
527 IN EFI_MTFTP6_TOKEN *Token
528 )
529 {
530 return Mtftp6OperationStart (This, Token, EFI_MTFTP6_OPCODE_WRQ);
531 }
532
533
534 /**
535 Download a data file directory from an MTFTPv6 server.
536
537 The ReadDirectory() function is used to return a list of files on the
538 MTFTPv6 server that are logically (or operationally) related to
539 Token.Filename. The directory request packet that is sent to the server
540 is built with the option list that was provided by the caller, if present.
541 The file information that the server returns is put into either of
542 the following locations:
543 - A fixed buffer that is pointed to by Token.Buffer.
544 - A download service function that is pointed to by Token.CheckPacket.
545 If both Token.Buffer and Token.CheckPacket are used, then Token.CheckPacket
546 will be called first. If the call is successful, the packet will be stored
547 in Token.Buffer.
548
549 @param[in] This Pointer to the EFI_MTFTP6_PROTOCOL instance.
550 @param[in] Token Pointer to the token structure to provide the parameters that are
551 used in this operation.
552
553 @retval EFI_SUCCESS The MTFTPv6 related file "directory" has been downloaded.
554 @retval EFI_UNSUPPORTED The EFI MTFTPv6 Protocol driver does not support this function.
555 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
556 - This is NULL.
557 - Token is NULL.
558 - Token.Filename is NULL.
559 - Token.OptionCount is not zero and Token.OptionList is NULL.
560 - One or more options in Token.OptionList have wrong format.
561 - Token.Buffer and Token.CheckPacket are both NULL.
562 - Token.OverrideData.ServerIp is not valid unicast IPv6 addresses.
563 @retval EFI_UNSUPPORTED One or more options in the Token.OptionList are not
564 supported by this implementation.
565 @retval EFI_NOT_STARTED The EFI MTFTPv6 Protocol driver has not been started.
566 @retval EFI_NO_MAPPING The underlying IPv6 driver was responsible for choosing a source
567 address for this instance, but no source address was available for use.
568 @retval EFI_ALREADY_STARTED This Token is already being used in another MTFTPv6 session.
569 @retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated.
570 @retval EFI_ACCESS_DENIED The previous operation has not completed yet.
571 @retval EFI_DEVICE_ERROR An unexpected network error or system error occurred.
572
573 **/
574 EFI_STATUS
575 EFIAPI
576 EfiMtftp6ReadDirectory (
577 IN EFI_MTFTP6_PROTOCOL *This,
578 IN EFI_MTFTP6_TOKEN *Token
579 )
580 {
581 return Mtftp6OperationStart (This, Token, EFI_MTFTP6_OPCODE_DIR);
582 }
583
584
585 /**
586 Polls for incoming data packets and processes outgoing data packets.
587
588 The Poll() function can be used by network drivers and applications
589 to increase the rate that data packets are moved between the
590 communications device and the transmit and receive queues. In some
591 systems, the periodic timer event in the managed network driver may
592 not poll the underlying communications device fast enough to transmit
593 and/or receive all data packets without missing incoming packets or
594 dropping outgoing packets. Drivers and applications that are
595 experiencing packet loss should try calling the Poll() function
596 more often.
597
598 @param[in] This The MTFTP6 protocol instance.
599
600
601 @retval EFI_SUCCESS Incoming or outgoing data was processed.
602 @retval EFI_NOT_STARTED This EFI MTFTPv6 Protocol instance has not been started.
603 @retval EFI_INVALID_PARAMETER This is NULL.
604 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
605 @retval EFI_TIMEOUT Data was dropped out of the transmit and/or receive queue.
606 Consider increasing the polling rate.
607
608 **/
609 EFI_STATUS
610 EFIAPI
611 EfiMtftp6Poll (
612 IN EFI_MTFTP6_PROTOCOL *This
613 )
614 {
615 MTFTP6_INSTANCE *Instance;
616 EFI_UDP6_PROTOCOL *Udp6;
617
618 if (This == NULL) {
619 return EFI_INVALID_PARAMETER;
620 }
621
622 Instance = MTFTP6_INSTANCE_FROM_THIS (This);
623
624 //
625 // Check the instance whether configured or in destroy.
626 //
627 if (Instance->Config == NULL) {
628 return EFI_NOT_STARTED;
629 } else if (Instance->InDestroy) {
630 return EFI_DEVICE_ERROR;
631 }
632
633 Udp6 = Instance->UdpIo->Protocol.Udp6;
634
635 return Udp6->Poll (Udp6);
636 }