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