]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Impl.c
Update modules to show real dependencies on the BaseMemoryLib and MemoryAllocationLib
[mirror_edk2.git] / MdeModulePkg / Universal / Network / Mtftp4Dxe / Mtftp4Impl.c
CommitLineData
772db4bb 1/** @file\r
dab714aa 2 Interface routine for Mtftp4.\r
3 \r
6d3ea23f 4Copyright (c) 2006 - 2007, 2009, Intel Corporation<BR>\r
772db4bb 5All rights reserved. This program and the accompanying materials\r
6are licensed and made available under the terms and conditions of the BSD License\r
7which accompanies this distribution. The full text of the license may be found at\r
dab714aa 8http://opensource.org/licenses/bsd-license.php<BR>\r
772db4bb 9\r
10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
772db4bb 13**/\r
14\r
772db4bb 15\r
dab714aa 16#include "Mtftp4Impl.h"\r
772db4bb 17\r
18\r
772db4bb 19/**\r
20 Clean up the MTFTP session to get ready for new operation.\r
21\r
22 @param Instance The MTFTP session to clean up\r
23 @param Result The result to return to the caller who initiated\r
24 the operation.\r
772db4bb 25**/\r
26VOID\r
27Mtftp4CleanOperation (\r
dab714aa 28 IN OUT MTFTP4_PROTOCOL *Instance,\r
29 IN EFI_STATUS Result\r
772db4bb 30 )\r
31{\r
e48e37fc 32 LIST_ENTRY *Entry;\r
33 LIST_ENTRY *Next;\r
772db4bb 34 MTFTP4_BLOCK_RANGE *Block;\r
35 EFI_MTFTP4_TOKEN *Token;\r
36\r
37 //\r
38 // Free various resources.\r
39 //\r
40 Token = Instance->Token;\r
41\r
42 if (Token != NULL) {\r
43 Token->Status = Result;\r
44\r
45 if (Token->Event != NULL) {\r
46 gBS->SignalEvent (Token->Event);\r
47 }\r
48\r
49 Instance->Token = NULL;\r
50 }\r
51\r
52 ASSERT (Instance->UnicastPort != NULL);\r
53 UdpIoCleanPort (Instance->UnicastPort);\r
54\r
55 if (Instance->LastPacket != NULL) {\r
56 NetbufFree (Instance->LastPacket);\r
57 Instance->LastPacket = NULL;\r
58 }\r
59\r
60 if (Instance->McastUdpPort != NULL) {\r
61 UdpIoFreePort (Instance->McastUdpPort);\r
62 Instance->McastUdpPort = NULL;\r
63 }\r
64\r
65 NET_LIST_FOR_EACH_SAFE (Entry, Next, &Instance->Blocks) {\r
66 Block = NET_LIST_USER_STRUCT (Entry, MTFTP4_BLOCK_RANGE, Link);\r
e48e37fc 67 RemoveEntryList (Entry);\r
68 gBS->FreePool (Block);\r
772db4bb 69 }\r
70\r
e48e37fc 71 ZeroMem (&Instance->RequestOption, sizeof (MTFTP4_OPTION));\r
772db4bb 72\r
73 Instance->Operation = 0;\r
74\r
75 Instance->BlkSize = MTFTP4_DEFAULT_BLKSIZE;\r
76 Instance->LastBlock = 0;\r
77 Instance->ServerIp = 0;\r
78 Instance->ListeningPort = 0;\r
79 Instance->ConnectedPort = 0;\r
80 Instance->Gateway = 0;\r
81 Instance->PacketToLive = 0;\r
82 Instance->MaxRetry = 0;\r
83 Instance->CurRetry = 0;\r
84 Instance->Timeout = 0;\r
85 Instance->McastIp = 0;\r
86 Instance->McastPort = 0;\r
87 Instance->Master = TRUE;\r
88}\r
89\r
90\r
772db4bb 91/**\r
dab714aa 92 Check packet for GetInfo. \r
93 \r
94 GetInfo is implemented with EfiMtftp4ReadFile. It use Mtftp4GetInfoCheckPacket \r
95 to inspect the first packet from server, then abort the session.\r
772db4bb 96\r
97 @param This The MTFTP4 protocol instance\r
98 @param Token The user's token\r
99 @param PacketLen The length of the packet\r
100 @param Packet The received packet.\r
101\r
102 @retval EFI_ABORTED Abort the ReadFile operation and return.\r
103\r
104**/\r
772db4bb 105EFI_STATUS\r
6d3ea23f 106EFIAPI\r
772db4bb 107Mtftp4GetInfoCheckPacket (\r
108 IN EFI_MTFTP4_PROTOCOL *This,\r
109 IN EFI_MTFTP4_TOKEN *Token,\r
110 IN UINT16 PacketLen,\r
111 IN EFI_MTFTP4_PACKET *Packet\r
112 )\r
113{\r
61066b8d 114 MTFTP4_PROTOCOL *Instance;\r
772db4bb 115 MTFTP4_GETINFO_STATE *State;\r
116 EFI_STATUS Status;\r
117 UINT16 OpCode;\r
118\r
61066b8d 119 Instance = MTFTP4_PROTOCOL_FROM_THIS (This);\r
120 State = &Instance->GetInfoState;\r
a5867703 121 OpCode = NTOHS (Packet->OpCode);\r
772db4bb 122\r
123 //\r
124 // Set the GetInfo's return status according to the OpCode.\r
125 //\r
126 switch (OpCode) {\r
127 case EFI_MTFTP4_OPCODE_ERROR:\r
128 State->Status = EFI_TFTP_ERROR;\r
129 break;\r
130\r
131 case EFI_MTFTP4_OPCODE_OACK:\r
132 State->Status = EFI_SUCCESS;\r
133 break;\r
134\r
135 default:\r
136 State->Status = EFI_PROTOCOL_ERROR;\r
137 }\r
138\r
139 //\r
140 // Allocate buffer then copy the packet over. Use gBS->AllocatePool\r
e48e37fc 141 // in case AllocatePool will implements something tricky.\r
772db4bb 142 //\r
143 Status = gBS->AllocatePool (EfiBootServicesData, PacketLen, (VOID **) State->Packet);\r
144\r
145 if (EFI_ERROR (Status)) {\r
146 State->Status = EFI_OUT_OF_RESOURCES;\r
147 return EFI_ABORTED;\r
148 }\r
149\r
150 *(State->PacketLen) = PacketLen;\r
e48e37fc 151 CopyMem (*(State->Packet), Packet, PacketLen);\r
772db4bb 152\r
153 return EFI_ABORTED;\r
154}\r
155\r
156\r
772db4bb 157/**\r
dab714aa 158 Check whether the override data is valid. \r
159 \r
160 It will first validate whether the server is a valid unicast. If a gateway\r
161 is provided in the Override, it also check that it is a unicast on the \r
162 connected network.\r
772db4bb 163\r
164 @param Instance The MTFTP instance\r
165 @param Override The override data to validate.\r
166\r
dab714aa 167 @retval TRUE The override data is valid\r
168 @retval FALSE The override data is invalid\r
169 \r
772db4bb 170**/\r
772db4bb 171BOOLEAN\r
172Mtftp4OverrideValid (\r
173 IN MTFTP4_PROTOCOL *Instance,\r
174 IN EFI_MTFTP4_OVERRIDE_DATA *Override\r
175 )\r
176{\r
177 EFI_MTFTP4_CONFIG_DATA *Config;\r
178 IP4_ADDR Ip;\r
179 IP4_ADDR Netmask;\r
180 IP4_ADDR Gateway;\r
181\r
e48e37fc 182 CopyMem (&Ip, &Override->ServerIp, sizeof (IP4_ADDR));\r
772db4bb 183 if (!Ip4IsUnicast (NTOHL (Ip), 0)) {\r
184 return FALSE;\r
185 }\r
186\r
187 Config = &Instance->Config;\r
188\r
e48e37fc 189 CopyMem (&Gateway, &Override->GatewayIp, sizeof (IP4_ADDR));\r
772db4bb 190 Gateway = NTOHL (Gateway);\r
191\r
192 if (!Config->UseDefaultSetting && (Gateway != 0)) {\r
e48e37fc 193 CopyMem (&Netmask, &Config->SubnetMask, sizeof (IP4_ADDR));\r
194 CopyMem (&Ip, &Config->StationIp, sizeof (IP4_ADDR));\r
772db4bb 195\r
196 Netmask = NTOHL (Netmask);\r
197 Ip = NTOHL (Ip);\r
198\r
199 if (!Ip4IsUnicast (Gateway, Netmask) || !IP4_NET_EQUAL (Gateway, Ip, Netmask)) {\r
200 return FALSE;\r
201 }\r
202 }\r
203\r
204 return TRUE;\r
205}\r
206\r
207\r
208/**\r
209 Poll the UDP to get the IP4 default address, which may be retrieved\r
dab714aa 210 by DHCP. \r
211 \r
212 The default time out value is 5 seconds. If IP has retrieved the default address, \r
213 the UDP is reconfigured.\r
772db4bb 214\r
215 @param Instance The Mtftp instance\r
216 @param UdpPort The UDP port to poll\r
217 @param UdpCfgData The UDP configure data to reconfigure the UDP\r
218 port.\r
219\r
dab714aa 220 @retval TRUE The default address is retrieved and UDP is reconfigured.\r
221 @retval FALSE Some error occured.\r
772db4bb 222\r
223**/\r
224BOOLEAN\r
225Mtftp4GetMapping (\r
226 IN MTFTP4_PROTOCOL *Instance,\r
227 IN UDP_IO_PORT *UdpPort,\r
228 IN EFI_UDP4_CONFIG_DATA *UdpCfgData\r
229 )\r
230{\r
231 MTFTP4_SERVICE *Service;\r
232 EFI_IP4_MODE_DATA Ip4Mode;\r
233 EFI_UDP4_PROTOCOL *Udp;\r
234 EFI_STATUS Status;\r
235\r
236 ASSERT (Instance->Config.UseDefaultSetting);\r
237\r
238 Service = Instance->Service;\r
239 Udp = UdpPort->Udp;\r
240\r
241 Status = gBS->SetTimer (\r
242 Service->TimerToGetMap,\r
243 TimerRelative,\r
244 MTFTP4_TIME_TO_GETMAP * TICKS_PER_SECOND\r
245 );\r
246 if (EFI_ERROR (Status)) {\r
247 return FALSE;\r
248 }\r
249\r
250 while (!EFI_ERROR (gBS->CheckEvent (Service->TimerToGetMap))) {\r
251 Udp->Poll (Udp);\r
252\r
253 if (!EFI_ERROR (Udp->GetModeData (Udp, NULL, &Ip4Mode, NULL, NULL)) &&\r
254 Ip4Mode.IsConfigured) {\r
255\r
256 Udp->Configure (Udp, NULL);\r
257 return (BOOLEAN) (Udp->Configure (Udp, UdpCfgData) == EFI_SUCCESS);\r
258 }\r
259 }\r
260\r
261 return FALSE;\r
262}\r
263\r
264\r
265/**\r
266 Configure the UDP port for unicast receiving.\r
267\r
268 @param UdpIo The UDP port\r
269 @param Instance The MTFTP session\r
270\r
271 @retval EFI_SUCCESS The UDP port is successfully configured for the\r
272 session to unicast receive.\r
273\r
274**/\r
772db4bb 275EFI_STATUS\r
276Mtftp4ConfigUnicastPort (\r
277 IN UDP_IO_PORT *UdpIo,\r
278 IN MTFTP4_PROTOCOL *Instance\r
279 )\r
280{\r
281 EFI_MTFTP4_CONFIG_DATA *Config;\r
282 EFI_UDP4_CONFIG_DATA UdpConfig;\r
283 EFI_STATUS Status;\r
284 IP4_ADDR Ip;\r
285\r
286 Config = &Instance->Config;\r
287\r
288 UdpConfig.AcceptBroadcast = FALSE;\r
289 UdpConfig.AcceptPromiscuous = FALSE;\r
290 UdpConfig.AcceptAnyPort = FALSE;\r
291 UdpConfig.AllowDuplicatePort = FALSE;\r
292 UdpConfig.TypeOfService = 0;\r
293 UdpConfig.TimeToLive = 64;\r
294 UdpConfig.DoNotFragment = FALSE;\r
295 UdpConfig.ReceiveTimeout = 0;\r
296 UdpConfig.TransmitTimeout = 0;\r
297 UdpConfig.UseDefaultAddress = Config->UseDefaultSetting;\r
298 UdpConfig.StationAddress = Config->StationIp;\r
299 UdpConfig.SubnetMask = Config->SubnetMask;\r
300 UdpConfig.StationPort = 0;\r
301 UdpConfig.RemotePort = 0;\r
302\r
303 Ip = HTONL (Instance->ServerIp);\r
e48e37fc 304 CopyMem (&UdpConfig.RemoteAddress, &Ip, sizeof (EFI_IPv4_ADDRESS));\r
772db4bb 305\r
306 Status = UdpIo->Udp->Configure (UdpIo->Udp, &UdpConfig);\r
307\r
308 if ((Status == EFI_NO_MAPPING) && Mtftp4GetMapping (Instance, UdpIo, &UdpConfig)) {\r
309 return EFI_SUCCESS;\r
310 }\r
311\r
c4a62a12 312 if (!Config->UseDefaultSetting && !EFI_IP4_EQUAL (&mZeroIp4Addr, &Config->GatewayIp)) {\r
313 //\r
314 // The station IP address is manually configured and the Gateway IP is not 0.\r
315 // Add the default route for this UDP instance.\r
316 //\r
317 Status = UdpIo->Udp->Routes (UdpIo->Udp, FALSE, &mZeroIp4Addr, &mZeroIp4Addr, &Config->GatewayIp);\r
318 if (EFI_ERROR (Status)) {\r
319 UdpIo->Udp->Configure (UdpIo->Udp, NULL);\r
320 }\r
321 }\r
772db4bb 322 return Status;\r
323}\r
324\r
325\r
326/**\r
327 Start the MTFTP session to do the operation, such as read file,\r
328 write file, and read directory.\r
329\r
330 @param This The MTFTP session\r
331 @param Token The token than encapsues the user's request.\r
332 @param Operation The operation to do\r
333\r
334 @retval EFI_INVALID_PARAMETER Some of the parameters are invalid.\r
335 @retval EFI_NOT_STARTED The MTFTP session hasn't been configured.\r
336 @retval EFI_ALREADY_STARTED There is pending operation for the session.\r
337 @retval EFI_SUCCESS The operation is successfully started.\r
338\r
339**/\r
772db4bb 340EFI_STATUS\r
341Mtftp4Start (\r
342 IN EFI_MTFTP4_PROTOCOL *This,\r
343 IN EFI_MTFTP4_TOKEN *Token,\r
344 IN UINT16 Operation\r
345 )\r
346{\r
347 MTFTP4_PROTOCOL *Instance;\r
348 EFI_MTFTP4_OVERRIDE_DATA *Override;\r
349 EFI_MTFTP4_CONFIG_DATA *Config;\r
350 EFI_TPL OldTpl;\r
351 EFI_STATUS Status;\r
352\r
353 //\r
354 // Validate the parameters\r
355 //\r
356 if ((This == NULL) || (Token == NULL) || (Token->Filename == NULL) ||\r
357 ((Token->OptionCount != 0) && (Token->OptionList == NULL))) {\r
358 return EFI_INVALID_PARAMETER;\r
359 }\r
360\r
361 //\r
362 // User must provide at least one method to collect the data for download.\r
363 //\r
364 if (((Operation == EFI_MTFTP4_OPCODE_RRQ) || (Operation == EFI_MTFTP4_OPCODE_DIR)) &&\r
365 ((Token->Buffer == NULL) && (Token->CheckPacket == NULL))) {\r
366 return EFI_INVALID_PARAMETER;\r
367 }\r
368\r
369 //\r
370 // User must provide at least one method to provide the data for upload.\r
371 //\r
372 if ((Operation == EFI_MTFTP4_OPCODE_WRQ) &&\r
373 ((Token->Buffer == NULL) && (Token->PacketNeeded == NULL))) {\r
374 return EFI_INVALID_PARAMETER;\r
375 }\r
376\r
377 Instance = MTFTP4_PROTOCOL_FROM_THIS (This);\r
378\r
379 Status = EFI_SUCCESS;\r
e48e37fc 380 OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
772db4bb 381\r
382 if (Instance->State != MTFTP4_STATE_CONFIGED) {\r
383 Status = EFI_NOT_STARTED;\r
384 }\r
385\r
386 if (Instance->Operation != 0) {\r
387 Status = EFI_ACCESS_DENIED;\r
388 }\r
389\r
390 if (EFI_ERROR (Status)) {\r
e48e37fc 391 gBS->RestoreTPL (OldTpl);\r
772db4bb 392 return Status;\r
393 }\r
394\r
395 //\r
396 // Set the Operation now to prevent the application start other\r
397 // operations.\r
398 //\r
399 Instance->Operation = Operation;\r
400 Override = Token->OverrideData;\r
401\r
402 if ((Override != NULL) && !Mtftp4OverrideValid (Instance, Override)) {\r
403 Status = EFI_INVALID_PARAMETER;\r
404 goto ON_ERROR;\r
405 }\r
406\r
407 if (Token->OptionCount != 0) {\r
408 Status = Mtftp4ParseOption (\r
409 Token->OptionList,\r
410 Token->OptionCount,\r
411 TRUE,\r
412 &Instance->RequestOption\r
413 );\r
414\r
415 if (EFI_ERROR (Status)) {\r
416 goto ON_ERROR;\r
417 }\r
418 }\r
419\r
420 //\r
421 // Set the operation parameters from the configuration or override data.\r
422 //\r
423 Config = &Instance->Config;\r
424 Instance->Token = Token;\r
425 Instance->BlkSize = MTFTP4_DEFAULT_BLKSIZE;\r
426\r
e48e37fc 427 CopyMem (&Instance->ServerIp, &Config->ServerIp, sizeof (IP4_ADDR));\r
772db4bb 428 Instance->ServerIp = NTOHL (Instance->ServerIp);\r
429\r
430 Instance->ListeningPort = Config->InitialServerPort;\r
431 Instance->ConnectedPort = 0;\r
432\r
e48e37fc 433 CopyMem (&Instance->Gateway, &Config->GatewayIp, sizeof (IP4_ADDR));\r
772db4bb 434 Instance->Gateway = NTOHL (Instance->Gateway);\r
435\r
436 Instance->MaxRetry = Config->TryCount;\r
437 Instance->Timeout = Config->TimeoutValue;\r
438 Instance->Master = TRUE;\r
439\r
440 if (Override != NULL) {\r
e48e37fc 441 CopyMem (&Instance->ServerIp, &Override->ServerIp, sizeof (IP4_ADDR));\r
442 CopyMem (&Instance->Gateway, &Override->GatewayIp, sizeof (IP4_ADDR));\r
772db4bb 443\r
444 Instance->ServerIp = NTOHL (Instance->ServerIp);\r
445 Instance->Gateway = NTOHL (Instance->Gateway);\r
446\r
447 Instance->ListeningPort = Override->ServerPort;\r
448 Instance->MaxRetry = Override->TryCount;\r
449 Instance->Timeout = Override->TimeoutValue;\r
450 }\r
451\r
452 if (Instance->ListeningPort == 0) {\r
453 Instance->ListeningPort = MTFTP4_DEFAULT_SERVER_PORT;\r
454 }\r
455\r
456 if (Instance->MaxRetry == 0) {\r
457 Instance->MaxRetry = MTFTP4_DEFAULT_RETRY;\r
458 }\r
459\r
460 if (Instance->Timeout == 0) {\r
461 Instance->Timeout = MTFTP4_DEFAULT_TIMEOUT;\r
462 }\r
463\r
464 //\r
465 // Config the unicast UDP child to send initial request\r
466 //\r
467 Status = Mtftp4ConfigUnicastPort (Instance->UnicastPort, Instance);\r
468\r
469 if (EFI_ERROR (Status)) {\r
470 goto ON_ERROR;\r
471 }\r
472\r
174f03d2 473 //\r
474 // Set initial status.\r
475 //\r
476 Token->Status = EFI_NOT_READY;\r
477\r
772db4bb 478 //\r
479 // Build and send an initial requests\r
480 //\r
481 if (Operation == EFI_MTFTP4_OPCODE_WRQ) {\r
482 Status = Mtftp4WrqStart (Instance, Operation);\r
483 } else {\r
484 Status = Mtftp4RrqStart (Instance, Operation);\r
485 }\r
486\r
e48e37fc 487 gBS->RestoreTPL (OldTpl);\r
772db4bb 488\r
489 if (EFI_ERROR (Status)) {\r
490 goto ON_ERROR;\r
491 }\r
772db4bb 492\r
493 if (Token->Event != NULL) {\r
494 return EFI_SUCCESS;\r
495 }\r
496\r
174f03d2 497 //\r
498 // Return immediately for asynchronous operation or poll the\r
499 // instance for synchronous operation.\r
500 //\r
772db4bb 501 while (Token->Status == EFI_NOT_READY) {\r
502 This->Poll (This);\r
503 }\r
504\r
505 return Token->Status;\r
506\r
507ON_ERROR:\r
508 Mtftp4CleanOperation (Instance, Status);\r
e48e37fc 509 gBS->RestoreTPL (OldTpl);\r
772db4bb 510\r
511 return Status;\r
512}\r
513\r
514\r
3dc3861a 515/**\r
516 Reads the current operational settings.\r
517\r
518 The GetModeData()function reads the current operational settings of this \r
519 EFI MTFTPv4 Protocol driver instance.\r
520\r
521 @param This Pointer to the EFI_MTFTP4_PROTOCOL instance.\r
522 @param ModeData Pointer to storage for the EFI MTFTPv4 Protocol\r
523 driver mode data. \r
524\r
525 @retval EFI_SUCCESS The configuration data was successfully returned.\r
526 @retval EFI_OUT_OF_RESOURCES The required mode data could not be allocated.\r
527 @retval EFI_INVALID_PARAMETER This is NULL or ModeData is NULL.\r
528 \r
529**/\r
530EFI_STATUS\r
531EFIAPI\r
532EfiMtftp4GetModeData (\r
533 IN EFI_MTFTP4_PROTOCOL *This,\r
534 OUT EFI_MTFTP4_MODE_DATA *ModeData\r
535 )\r
536{\r
537 MTFTP4_PROTOCOL *Instance;\r
538 EFI_TPL OldTpl;\r
539\r
540 if ((This == NULL) || (ModeData == NULL)) {\r
541 return EFI_INVALID_PARAMETER;\r
542 }\r
543\r
544 OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
545\r
546 Instance = MTFTP4_PROTOCOL_FROM_THIS (This);\r
547 CopyMem(&ModeData->ConfigData, &Instance->Config, sizeof (Instance->Config));\r
548 ModeData->SupportedOptionCount = MTFTP4_SUPPORTED_OPTIONS;\r
549 ModeData->SupportedOptoins = (UINT8 **) mMtftp4SupportedOptions;\r
550 ModeData->UnsupportedOptionCount = 0;\r
551 ModeData->UnsupportedOptoins = NULL;\r
552\r
553 gBS->RestoreTPL (OldTpl);\r
554\r
555 return EFI_SUCCESS;\r
556}\r
557\r
558\r
559\r
560/**\r
561 Initializes, changes, or resets the default operational setting for this \r
562 EFI MTFTPv4 Protocol driver instance.\r
563 \r
564 The Configure() function is used to set and change the configuration data for \r
565 this EFI MTFTPv4 Protocol driver instance. The configuration data can be reset \r
566 to startup defaults by calling Configure() with MtftpConfigData set to NULL. \r
567 Whenever the instance is reset, any pending operation is aborted. By changing \r
568 the EFI MTFTPv4 Protocol driver instance configuration data, the client can \r
569 connect to different MTFTPv4 servers. The configuration parameters in \r
570 MtftpConfigData are used as the default parameters in later MTFTPv4 operations \r
571 and can be overridden in later operations.\r
572 \r
573 @param This Pointer to the EFI_MTFTP4_PROTOCOL instance\r
574 @param ConfigData MtftpConfigDataPointer to the configuration data \r
575 structure\r
576\r
577 @retval EFI_SUCCESS The EFI MTFTPv4 Protocol driver was configured \r
578 successfully.\r
579 @retval EFI_INVALID_PARAMETER One or more following conditions are TRUE:\r
580 1.This is NULL.\r
581 2.MtftpConfigData.UseDefaultSetting is FALSE and \r
582 MtftpConfigData.StationIp is not a valid IPv4 \r
583 unicast address.\r
584 3.MtftpCofigData.UseDefaultSetting is FALSE and \r
585 MtftpConfigData.SubnetMask is invalid.\r
586 4.MtftpCofigData.ServerIp is not a valid IPv4 \r
587 unicast address.\r
588 5.MtftpConfigData.UseDefaultSetting is FALSE and \r
589 MtftpConfigData.GatewayIp is not a valid IPv4 \r
590 unicast address or is not in the same subnet \r
591 with station address.\r
592 @retval EFI_ACCESS_DENIED The EFI configuration could not be changed at this \r
593 time because there is one MTFTP background operation \r
594 in progress.\r
595 @retval EFI_NO_MAPPING When using a default address, configuration \r
596 (DHCP, BOOTP, RARP, etc.) has not finished yet.\r
597 @retval EFI_UNSUPPORTED A configuration protocol (DHCP, BOOTP, RARP, etc.) \r
598 could not be located when clients choose to use \r
599 the default address settings.\r
600 @retval EFI_OUT_OF_RESOURCES The EFI MTFTPv4 Protocol driver instance data could \r
601 not be allocated.\r
602 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred. \r
603 The EFI MTFTPv4 Protocol driver instance is not \r
604 configured.\r
605\r
606**/\r
607EFI_STATUS\r
608EFIAPI\r
609EfiMtftp4Configure (\r
610 IN EFI_MTFTP4_PROTOCOL *This,\r
611 IN EFI_MTFTP4_CONFIG_DATA *ConfigData\r
612 )\r
613{\r
614 MTFTP4_PROTOCOL *Instance;\r
615 EFI_TPL OldTpl;\r
616 IP4_ADDR Ip;\r
617 IP4_ADDR Netmask;\r
618 IP4_ADDR Gateway;\r
619 IP4_ADDR ServerIp;\r
620\r
621 if (This == NULL) {\r
622 return EFI_INVALID_PARAMETER;\r
623 }\r
624\r
625 Instance = MTFTP4_PROTOCOL_FROM_THIS (This);\r
626\r
627 if (ConfigData == NULL) {\r
628 //\r
629 // Reset the operation if ConfigData is NULL\r
630 //\r
631 OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
632\r
633 Mtftp4CleanOperation (Instance, EFI_ABORTED);\r
634 ZeroMem (&Instance->Config, sizeof (EFI_MTFTP4_CONFIG_DATA));\r
635 Instance->State = MTFTP4_STATE_UNCONFIGED;\r
636\r
637 gBS->RestoreTPL (OldTpl);\r
638\r
639 } else {\r
640 //\r
641 // Configure the parameters for new operation.\r
642 //\r
643 CopyMem (&Ip, &ConfigData->StationIp, sizeof (IP4_ADDR));\r
644 CopyMem (&Netmask, &ConfigData->SubnetMask, sizeof (IP4_ADDR));\r
645 CopyMem (&Gateway, &ConfigData->GatewayIp, sizeof (IP4_ADDR));\r
646 CopyMem (&ServerIp, &ConfigData->ServerIp, sizeof (IP4_ADDR));\r
647\r
648 Ip = NTOHL (Ip);\r
649 Netmask = NTOHL (Netmask);\r
650 Gateway = NTOHL (Gateway);\r
651 ServerIp = NTOHL (ServerIp);\r
652\r
653 if (!Ip4IsUnicast (ServerIp, 0)) {\r
654 return EFI_INVALID_PARAMETER;\r
655 }\r
656\r
657 if (!ConfigData->UseDefaultSetting &&\r
658 ((!IP4_IS_VALID_NETMASK (Netmask) || !Ip4IsUnicast (Ip, Netmask)))) {\r
659\r
660 return EFI_INVALID_PARAMETER;\r
661 }\r
662\r
663 if ((Gateway != 0) &&\r
664 (!IP4_NET_EQUAL (Gateway, Ip, Netmask) || !Ip4IsUnicast (Gateway, Netmask))) {\r
665\r
666 return EFI_INVALID_PARAMETER;\r
667 }\r
668\r
669 OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
670\r
671 if ((Instance->State == MTFTP4_STATE_CONFIGED) && (Instance->Operation != 0)) {\r
672 gBS->RestoreTPL (OldTpl);\r
673 return EFI_ACCESS_DENIED;\r
674 }\r
675\r
676 CopyMem(&Instance->Config, ConfigData, sizeof (*ConfigData));;\r
677 Instance->State = MTFTP4_STATE_CONFIGED;\r
678\r
679 gBS->RestoreTPL (OldTpl);\r
680 }\r
681\r
682 return EFI_SUCCESS;\r
683}\r
684\r
685\r
686\r
687/**\r
688 Parses the options in an MTFTPv4 OACK packet.\r
689 \r
690 The ParseOptions() function parses the option fields in an MTFTPv4 OACK packet \r
691 and returns the number of options that were found and optionally a list of \r
692 pointers to the options in the packet.\r
693 If one or more of the option fields are not valid, then EFI_PROTOCOL_ERROR is \r
694 returned and *OptionCount and *OptionList stop at the last valid option.\r
695 The OptionList is allocated by this function, and caller should free it when used.\r
696\r
697 @param This Pointer to the EFI_MTFTP4_PROTOCOL instance.\r
698 @param PacketLen Length of the OACK packet to be parsed.\r
699 @param Packet Pointer to the OACK packet to be parsed. \r
700 @param OptionCount Pointer to the number of options in following OptionList.\r
701 @param OptionList Pointer to EFI_MTFTP4_OPTION storage. Call the \r
702 EFI Boot Service FreePool() to release theOptionList\r
703 if the options in this OptionList are not needed \r
704 any more\r
705\r
706 @retval EFI_SUCCESS The OACK packet was valid and the OptionCount and\r
707 OptionList parameters have been updated.\r
708 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:\r
709 1.PacketLen is 0.\r
710 2.Packet is NULL or Packet is not a valid MTFTPv4 packet.\r
711 3.OptionCount is NULL.\r
712 @retval EFI_NOT_FOUND No options were found in the OACK packet.\r
713 @retval EFI_OUT_OF_RESOURCES Storage for the OptionList array cannot be allocated.\r
714 @retval EFI_PROTOCOL_ERROR One or more of the option fields is invalid.\r
715\r
716**/\r
717EFI_STATUS\r
718EFIAPI\r
719EfiMtftp4ParseOptions (\r
720 IN EFI_MTFTP4_PROTOCOL *This,\r
721 IN UINT32 PacketLen,\r
722 IN EFI_MTFTP4_PACKET *Packet,\r
723 OUT UINT32 *OptionCount,\r
724 OUT EFI_MTFTP4_OPTION **OptionList OPTIONAL\r
725 )\r
726{\r
727 EFI_STATUS Status;\r
728\r
729 if ((This == NULL) || (PacketLen < MTFTP4_OPCODE_LEN) ||\r
730 (Packet == NULL) || (OptionCount == NULL)) {\r
731\r
732 return EFI_INVALID_PARAMETER;\r
733 }\r
734\r
735 Status = Mtftp4ExtractOptions (Packet, PacketLen, OptionCount, OptionList);\r
736\r
737 if (EFI_ERROR (Status)) {\r
738 return Status;\r
739 }\r
740\r
741 if (*OptionCount == 0) {\r
742 return EFI_NOT_FOUND;\r
743 }\r
744\r
745 return EFI_SUCCESS;\r
746}\r
747\r
748\r
772db4bb 749/**\r
dab714aa 750 Downloads a file from an MTFTPv4 server.\r
751 \r
752 The ReadFile() function is used to initialize and start an MTFTPv4 download \r
753 process and optionally wait for completion. When the download operation completes, \r
754 whether successfully or not, the Token.Status field is updated by the EFI MTFTPv4 \r
755 Protocol driver and then Token.Event is signaled (if it is not NULL).\r
756 Data can be downloaded from the MTFTPv4 server into either of the following locations:\r
757 1.A fixed buffer that is pointed to by Token.Buffer\r
758 2.A download service function that is pointed to by Token.CheckPacket\r
759 If both Token.Buffer and Token.CheckPacket are used, then Token.CheckPacket \r
760 will be called first. If the call is successful, the packet will be stored in \r
761 Token.Buffer.\r
762\r
763 @param This Pointer to the EFI_MTFTP4_PROTOCOL instance\r
764 @param Token Pointer to the token structure to provide the \r
765 parameters that are used in this operation.\r
766\r
767 @retval EFI_SUCCESS The data file has been transferred successfully.\r
768 @retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated.\r
769 @retval EFI_BUFFER_TOO_SMALL BufferSize is not large enough to hold the downloaded \r
770 data in downloading process.\r
771 @retval EFI_ABORTED Current operation is aborted by user.\r
772 @retval EFI_ICMP_ERROR An ICMP ERROR packet was received.\r
773 @retval EFI_TIMEOUT No responses were received from the MTFTPv4 server.\r
774 @retval EFI_TFTP_ERROR An MTFTPv4 ERROR packet was received.\r
775 @retval EFI_DEVICE_ERROR An unexpected network error or system error occurred.\r
772db4bb 776\r
777**/\r
772db4bb 778EFI_STATUS\r
779EFIAPI\r
780EfiMtftp4ReadFile (\r
781 IN EFI_MTFTP4_PROTOCOL *This,\r
782 IN EFI_MTFTP4_TOKEN *Token\r
783 )\r
784{\r
785 return Mtftp4Start (This, Token, EFI_MTFTP4_OPCODE_RRQ);\r
786}\r
787\r
788\r
789/**\r
dab714aa 790 Sends a data file to an MTFTPv4 server. May be unsupported in some EFI implementations\r
791\r
792 The WriteFile() function is used to initialize an uploading operation with the \r
793 given option list and optionally wait for completion. If one or more of the \r
794 options is not supported by the server, the unsupported options are ignored and \r
795 a standard TFTP process starts instead. When the upload process completes, \r
796 whether successfully or not, Token.Event is signaled, and the EFI MTFTPv4 Protocol \r
797 driver updates Token.Status.\r
798 The caller can supply the data to be uploaded in the following two modes:\r
799 1.Through the user-provided buffer\r
800 2.Through a callback function\r
801 With the user-provided buffer, the Token.BufferSize field indicates the length\r
802 of the buffer, and the driver will upload the data in the buffer. With an \r
803 EFI_MTFTP4_PACKET_NEEDED callback function, the driver will call this callback \r
804 function to get more data from the user to upload. See the definition of \r
805 EFI_MTFTP4_PACKET_NEEDED for more information. These two modes cannot be used at \r
806 the same time. The callback function will be ignored if the user provides the buffer.\r
807\r
808 @param This Pointer to the EFI_MTFTP4_PROTOCOL instance.\r
809 @param Token Pointer to the token structure to provide the \r
810 parameters that are used in this function\r
811\r
812 @retval EFI_SUCCESS The upload session has started.\r
813 @retval EFI_UNSUPPORTED The operation is not supported by this implementation.\r
814 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:\r
815 1. This is NULL.\r
816 2. Token is NULL.\r
817 3. Token.Filename is NULL.\r
818 4. Token.OptionCount is not zero and\r
819 Token.OptionList is NULL.\r
820 5. One or more options in Token.OptionList have wrong\r
821 format.\r
822 6. Token.Buffer and Token.PacketNeeded are both\r
823 NULL.\r
824 7. One or more IPv4 addresses in Token.OverrideData \r
825 are not valid unicast IPv4 addresses if \r
826 Token.OverrideData is not NULL.\r
827 @retval EFI_UNSUPPORTED One or more options in the Token.OptionList are in the\r
828 unsupported list of structure EFI_MTFTP4_MODE_DATA.\r
829 @retval EFI_NOT_STARTED The EFI MTFTPv4 Protocol driver has not been started.\r
830 @retval EFI_NO_MAPPING When using a default address, configuration (DHCP, \r
831 BOOTP, RARP, etc.) is not finished yet.\r
832 @retval EFI_ALREADY_STARTED This Token is already being used in another MTFTPv4 \r
833 session.\r
834 @retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated.\r
835 @retval EFI_ACCESS_DENIED The previous operation has not completed yet.\r
836 @retval EFI_DEVICE_ERROR An unexpected network error or system error occurred.\r
772db4bb 837\r
838**/\r
772db4bb 839EFI_STATUS\r
840EFIAPI\r
841EfiMtftp4WriteFile (\r
842 IN EFI_MTFTP4_PROTOCOL *This,\r
843 IN EFI_MTFTP4_TOKEN *Token\r
844 )\r
845{\r
846 return Mtftp4Start (This, Token, EFI_MTFTP4_OPCODE_WRQ);\r
847}\r
848\r
849\r
850/**\r
dab714aa 851 Downloads a data file "directory" from an MTFTPv4 server. \r
852 May be unsupported in some EFI implementations\r
853 \r
854 The ReadDirectory() function is used to return a list of files on the MTFTPv4 \r
855 server that are logically (or operationally) related to Token.Filename. The \r
856 directory request packet that is sent to the server is built with the option \r
857 list that was provided by caller, if present.\r
858 The file information that the server returns is put into either of the following \r
859 locations:\r
860 1.A fixed buffer that is pointed to by Token.Buffer\r
861 2.A download service function that is pointed to by Token.CheckPacket\r
862 If both Token.Buffer and Token.CheckPacket are used, then Token.CheckPacket will \r
863 be called first. If the call is successful, the packet will be stored in Token.Buffer.\r
864 The returned directory listing in the Token.Buffer or EFI_MTFTP4_PACKET consists \r
865 of a list of two or three variable-length ASCII strings, each terminated by a \r
866 null character, for each file in the directory. If the multicast option is involved, \r
867 the first field of each directory entry is the static multicast IP address and \r
868 UDP port number that is associated with the file name. The format of the field \r
869 is ip:ip:ip:ip:port. If the multicast option is not involved, this field and its \r
870 terminating null character are not present.\r
871 The next field of each directory entry is the file name and the last field is \r
872 the file information string. The information string contains the file size and \r
873 the create/modify timestamp. The format of the information string is filesize \r
874 yyyy-mm-dd hh:mm:ss:ffff. The timestamp is Coordinated Universal Time \r
875 (UTC; also known as Greenwich Mean Time [GMT]).\r
876 The only difference between ReadFile and ReadDirectory is the opcode used.\r
877\r
878 @param This Pointer to the EFI_MTFTP4_PROTOCOL instance\r
879 @param Token Pointer to the token structure to provide the \r
880 parameters that are used in this function\r
881\r
882 @retval EFI_SUCCESS The MTFTPv4 related file "directory" has been downloaded.\r
883 @retval EFI_UNSUPPORTED The operation is not supported by this implementation.\r
884 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:\r
885 1. This is NULL.\r
886 2. Token is NULL.\r
887 3. Token.Filename is NULL.\r
888 4. Token.OptionCount is not zero and\r
889 Token.OptionList is NULL.\r
890 5. One or more options in Token.OptionList have wrong\r
891 format.\r
892 6. Token.Buffer and Token.PacketNeeded are both\r
893 NULL.\r
894 7. One or more IPv4 addresses in Token.OverrideData \r
895 are not valid unicast IPv4 addresses if \r
896 Token.OverrideData is not NULL.\r
897 @retval EFI_UNSUPPORTED One or more options in the Token.OptionList are in the\r
898 unsupported list of structure EFI_MTFTP4_MODE_DATA.\r
899 @retval EFI_NOT_STARTED The EFI MTFTPv4 Protocol driver has not been started.\r
900 @retval EFI_NO_MAPPING When using a default address, configuration (DHCP, \r
901 BOOTP, RARP, etc.) is not finished yet.\r
902 @retval EFI_ALREADY_STARTED This Token is already being used in another MTFTPv4 \r
903 session.\r
904 @retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated.\r
905 @retval EFI_ACCESS_DENIED The previous operation has not completed yet.\r
906 @retval EFI_DEVICE_ERROR An unexpected network error or system error occurred.\r
772db4bb 907\r
908**/\r
772db4bb 909EFI_STATUS\r
910EFIAPI\r
911EfiMtftp4ReadDirectory (\r
912 IN EFI_MTFTP4_PROTOCOL *This,\r
913 IN EFI_MTFTP4_TOKEN *Token\r
914 )\r
915{\r
916 return Mtftp4Start (This, Token, EFI_MTFTP4_OPCODE_DIR);\r
917}\r
918\r
919\r
920/**\r
dab714aa 921 Gets information about a file from an MTFTPv4 server. \r
922 \r
923 The GetInfo() function assembles an MTFTPv4 request packet with options; \r
924 sends it to the MTFTPv4 server; and may return an MTFTPv4 OACK, MTFTPv4 ERROR, \r
925 or ICMP ERROR packet. Retries occur only if no response packets are received \r
926 from the MTFTPv4 server before the timeout expires.\r
927 It is implemented with EfiMtftp4ReadFile: build a token, then pass it to \r
928 EfiMtftp4ReadFile. In its check packet callback abort the opertions.\r
929\r
930 @param This Pointer to the EFI_MTFTP4_PROTOCOL instance\r
931 @param OverrideData Data that is used to override the existing \r
932 parameters. If NULL, the default parameters that \r
933 were set in the EFI_MTFTP4_PROTOCOL.Configure() \r
934 function are used\r
935 @param Filename Pointer to ASCIIZ file name string\r
936 @param ModeStr Pointer to ASCIIZ mode string. If NULL, "octet" \r
937 will be used\r
938 @param OptionCount Number of option/value string pairs in OptionList\r
939 @param OptionList Pointer to array of option/value string pairs. \r
940 Ignored if OptionCount is zero\r
941 @param PacketLength The number of bytes in the returned packet\r
942 @param Packet PacketThe pointer to the received packet. This \r
943 buffer must be freed by the caller.\r
944\r
945 @retval EFI_SUCCESS An MTFTPv4 OACK packet was received and is in \r
946 the Buffer.\r
947 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:\r
948 1.This is NULL.\r
949 2.Filename is NULL.\r
950 3.OptionCount is not zero and OptionList is NULL.\r
951 4.One or more options in OptionList have wrong format.\r
952 5.PacketLength is NULL.\r
953 6.One or more IPv4 addresses in OverrideData are \r
954 not valid unicast IPv4 addresses if OverrideData \r
955 is not NULL.\r
956 @retval EFI_UNSUPPORTED One or more options in the OptionList are in the\r
957 unsupported list of structure EFI_MTFTP4_MODE_DATA\r
958 @retval EFI_NOT_STARTED The EFI MTFTPv4 Protocol driver has not been started.\r
959 @retval EFI_NO_MAPPING When using a default address, configuration (DHCP, \r
960 BOOTP, RARP, etc.) has not finished yet.\r
961 @retval EFI_ACCESS_DENIED The previous operation has not completed yet.\r
962 @retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated.\r
963 @retval EFI_TFTP_ERROR An MTFTPv4 ERROR packet was received and is in \r
964 the Buffer.\r
965 @retval EFI_ICMP_ERROR An ICMP ERROR packet was received and the Packet \r
966 is set to NULL.\r
967 @retval EFI_PROTOCOL_ERROR An unexpected MTFTPv4 packet was received and is \r
968 in the Buffer.\r
969 @retval EFI_TIMEOUT No responses were received from the MTFTPv4 server.\r
970 @retval EFI_DEVICE_ERROR An unexpected network error or system error occurred.\r
971 \r
972**/\r
973EFI_STATUS\r
974EFIAPI\r
975EfiMtftp4GetInfo (\r
976 IN EFI_MTFTP4_PROTOCOL *This,\r
977 IN EFI_MTFTP4_OVERRIDE_DATA *OverrideData OPTIONAL,\r
978 IN UINT8 *Filename,\r
979 IN UINT8 *ModeStr OPTIONAL,\r
980 IN UINT8 OptionCount,\r
981 IN EFI_MTFTP4_OPTION *OptionList OPTIONAL,\r
982 OUT UINT32 *PacketLength,\r
983 OUT EFI_MTFTP4_PACKET **Packet OPTIONAL\r
984 )\r
985{\r
986 EFI_MTFTP4_TOKEN Token;\r
987 MTFTP4_PROTOCOL *Instance;\r
988 MTFTP4_GETINFO_STATE *State;\r
989 EFI_STATUS Status;\r
990\r
991 if ((This == NULL) || (Filename == NULL) || (PacketLength == NULL) ||\r
992 ((OptionCount != 0) && (OptionList == NULL))) {\r
993 return EFI_INVALID_PARAMETER;\r
994 }\r
995\r
996 if (Packet != NULL) {\r
997 *Packet = NULL;\r
998 }\r
999\r
1000 *PacketLength = 0;\r
1001 Instance = MTFTP4_PROTOCOL_FROM_THIS (This);\r
1002 State = &Instance->GetInfoState;\r
1003 State->Packet = Packet;\r
1004 State->PacketLen = PacketLength;\r
1005 State->Status = EFI_SUCCESS;\r
1006\r
1007 //\r
1008 // Fill in the Token to issue an synchronous ReadFile operation\r
1009 //\r
1010 Token.Status = EFI_SUCCESS;\r
1011 Token.Event = NULL;\r
1012 Token.OverrideData = OverrideData;\r
1013 Token.Filename = Filename;\r
1014 Token.ModeStr = ModeStr;\r
1015 Token.OptionCount = OptionCount;\r
1016 Token.OptionList = OptionList;\r
1017 Token.BufferSize = 0;\r
1018 Token.Buffer = NULL;\r
1019 Token.CheckPacket = Mtftp4GetInfoCheckPacket;\r
1020 Token.TimeoutCallback = NULL;\r
1021 Token.PacketNeeded = NULL;\r
1022\r
1023 Status = EfiMtftp4ReadFile (This, &Token);\r
772db4bb 1024\r
dab714aa 1025 if (EFI_ABORTED == Status) {\r
1026 return State->Status;\r
1027 }\r
1028\r
1029 return Status;\r
1030}\r
772db4bb 1031\r
dab714aa 1032/**\r
1033 Polls for incoming data packets and processes outgoing data packets.\r
1034\r
1035 The Poll() function can be used by network drivers and applications to increase \r
1036 the rate that data packets are moved between the communications device and the \r
1037 transmit and receive queues.\r
1038 In some systems, the periodic timer event in the managed network driver may not \r
1039 poll the underlying communications device fast enough to transmit and/or receive \r
1040 all data packets without missing incoming packets or dropping outgoing packets. \r
1041 Drivers and applications that are experiencing packet loss should try calling \r
1042 the Poll() function more often.\r
1043 \r
1044 @param This Pointer to the EFI_MTFTP4_PROTOCOL instance\r
1045\r
1046 @retval EFI_SUCCESS Incoming or outgoing data was processed.\r
1047 @retval EFI_NOT_STARTED This EFI MTFTPv4 Protocol instance has not been started.\r
1048 @retval EFI_NO_MAPPING When using a default address, configuration (DHCP,\r
1049 BOOTP, RARP, etc.) is not finished yet.\r
772db4bb 1050 @retval EFI_INVALID_PARAMETER This is NULL.\r
dab714aa 1051 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.\r
1052 @retval EFI_TIMEOUT Data was dropped out of the transmit and/or receive \r
1053 queue. Consider increasing the polling rate.\r
772db4bb 1054\r
1055**/\r
772db4bb 1056EFI_STATUS\r
1057EFIAPI\r
1058EfiMtftp4Poll (\r
1059 IN EFI_MTFTP4_PROTOCOL *This\r
1060 )\r
1061{\r
1062 MTFTP4_PROTOCOL *Instance;\r
1063 EFI_UDP4_PROTOCOL *Udp;\r
1064\r
1065 if (This == NULL) {\r
1066 return EFI_INVALID_PARAMETER;\r
1067 }\r
1068\r
1069 Instance = MTFTP4_PROTOCOL_FROM_THIS (This);\r
1070\r
1071 if (Instance->State == MTFTP4_STATE_UNCONFIGED) {\r
1072 return EFI_NOT_STARTED;\r
1073 } else if (Instance->State == MTFTP4_STATE_DESTORY) {\r
1074 return EFI_DEVICE_ERROR;\r
1075 }\r
1076\r
1077 Udp = Instance->UnicastPort->Udp;\r
1078 return Udp->Poll (Udp);\r
1079}\r
1080\r
1081EFI_MTFTP4_PROTOCOL gMtftp4ProtocolTemplate = {\r
1082 EfiMtftp4GetModeData,\r
1083 EfiMtftp4Configure,\r
1084 EfiMtftp4GetInfo,\r
1085 EfiMtftp4ParseOptions,\r
1086 EfiMtftp4ReadFile,\r
1087 EfiMtftp4WriteFile,\r
1088 EfiMtftp4ReadDirectory,\r
1089 EfiMtftp4Poll\r
1090};\r