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