2 Interface routines for PxeBc.
4 Copyright (c) 2007 - 2008, Intel Corporation.<BR>
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16 #include "PxeBcImpl.h"
18 EFI_LOAD_FILE_PROTOCOL mLoadFileProtocolTemplate
= { EfiPxeLoadFile
};
21 Get and record the arp cache.
23 @param This Pointer to EFI_PXE_BC_PROTOCOL
25 @retval EFI_SUCCESS Arp cache updated successfully
26 @retval others If error occurs when getting arp cache
31 IN EFI_PXE_BASE_CODE_PROTOCOL
* This
34 PXEBC_PRIVATE_DATA
*Private
;
35 EFI_PXE_BASE_CODE_MODE
*Mode
;
39 EFI_ARP_FIND_DATA
*Entries
;
42 Private
= PXEBC_PRIVATE_DATA_FROM_PXEBC (This
);
43 Mode
= Private
->PxeBc
.Mode
;
45 Status
= Private
->Arp
->Find (
54 if (EFI_ERROR (Status
)) {
58 Mode
->ArpCacheEntries
= MIN (
60 EFI_PXE_BASE_CODE_MAX_ARP_ENTRIES
62 for (Index
= 0; Index
< Mode
->ArpCacheEntries
; Index
++) {
64 &Mode
->ArpCache
[Index
].IpAddr
,
66 Entries
->SwAddressLength
69 &Mode
->ArpCache
[Index
].MacAddr
,
70 (UINT8
*) (Entries
+ 1) + Entries
->SwAddressLength
,
71 Entries
->HwAddressLength
74 // Slip to the next FindData.
76 Entries
= (EFI_ARP_FIND_DATA
*) ((UINT8
*) Entries
+ EntryLength
);
83 Timeout routine to update arp cache.
85 @param Event Pointer to EFI_PXE_BC_PROTOCOL
86 @param Context Context of the timer event
93 ArpCacheUpdateTimeout (
98 UpdateArpCache ((EFI_PXE_BASE_CODE_PROTOCOL
*) Context
);
102 Do arp resolution from arp cache in PxeBcMode.
104 @param PxeBcMode The PXE BC mode to look into.
105 @param Ip4Addr The Ip4 address for resolution.
106 @param MacAddress The resoluted MAC address if the resolution is successful.
107 The value is undefined if resolution fails.
109 @retval TRUE The resolution is successful.
110 @retval FALSE Otherwise.
115 IN EFI_PXE_BASE_CODE_MODE
*PxeBcMode
,
116 IN EFI_IPv4_ADDRESS
*Ip4Addr
,
117 OUT EFI_MAC_ADDRESS
*MacAddress
122 for (Index
= 0; Index
< PxeBcMode
->ArpCacheEntries
; Index
++) {
123 if (EFI_IP4_EQUAL (&PxeBcMode
->ArpCache
[Index
].IpAddr
.v4
, Ip4Addr
)) {
126 &PxeBcMode
->ArpCache
[Index
].MacAddr
,
127 sizeof (EFI_MAC_ADDRESS
)
137 Notify function for the ICMP receive token, used to process
138 the received ICMP packets.
140 @param Context The PXEBC private data.
147 IcmpErrorListenHandlerDpc (
152 EFI_IP4_RECEIVE_DATA
*RxData
;
153 EFI_IP4_PROTOCOL
*Ip4
;
154 PXEBC_PRIVATE_DATA
*Private
;
155 EFI_PXE_BASE_CODE_MODE
*Mode
;
158 UINT8
*CopiedPointer
;
160 Private
= (PXEBC_PRIVATE_DATA
*) Context
;
161 Mode
= &Private
->Mode
;
162 Status
= Private
->IcmpErrorRcvToken
.Status
;
163 RxData
= Private
->IcmpErrorRcvToken
.Packet
.RxData
;
166 if (Status
== EFI_ABORTED
) {
168 // The reception is actively aborted by the consumer, directly return.
173 if (EFI_ERROR (Status
) || (RxData
== NULL
)) {
175 // Only process the normal packets and the icmp error packets, if RxData is NULL
176 // with Status == EFI_SUCCESS or EFI_ICMP_ERROR, just resume the receive although
177 // this should be a bug of the low layer (IP).
182 if (EFI_IP4 (RxData
->Header
->SourceAddress
) != 0 &&
183 !Ip4IsUnicast (EFI_NTOHL (RxData
->Header
->SourceAddress
), 0)) {
185 // The source address is not zero and it's not a unicast IP address, discard it.
190 if (!EFI_IP4_EQUAL (&RxData
->Header
->DestinationAddress
, &Mode
->StationIp
.v4
)) {
192 // The dest address is not equal to Station Ip address, discard it.
198 // Constructor ICMP error packet
201 CopiedPointer
= (UINT8
*) &Mode
->IcmpError
;
203 for (Index
= 0; Index
< RxData
->FragmentCount
; Index
++) {
204 CopiedLen
+= RxData
->FragmentTable
[Index
].FragmentLength
;
205 if (CopiedLen
<= sizeof (EFI_PXE_BASE_CODE_ICMP_ERROR
)) {
208 RxData
->FragmentTable
[Index
].FragmentBuffer
,
209 RxData
->FragmentTable
[Index
].FragmentLength
214 RxData
->FragmentTable
[Index
].FragmentBuffer
,
215 CopiedLen
- sizeof (EFI_PXE_BASE_CODE_ICMP_ERROR
)
218 CopiedPointer
+= CopiedLen
;
224 gBS
->SignalEvent (RxData
->RecycleSignal
);
227 Ip4
->Receive (Ip4
, &(Private
->IcmpErrorRcvToken
));
231 Request IcmpErrorListenHandlerDpc as a DPC at TPL_CALLBACK
233 @param Event The event signaled.
234 @param Context The context passed in by the event notifier.
241 IcmpErrorListenHandler (
247 // Request IpIoListenHandlerDpc as a DPC at TPL_CALLBACK
249 NetLibQueueDpc (TPL_CALLBACK
, IcmpErrorListenHandlerDpc
, Context
);
253 Enables the use of the PXE Base Code Protocol functions.
255 This function enables the use of the PXE Base Code Protocol functions. If the
256 Started field of the EFI_PXE_BASE_CODE_MODE structure is already TRUE, then
257 EFI_ALREADY_STARTED will be returned. If UseIpv6 is TRUE, then IPv6 formatted
258 addresses will be used in this session. If UseIpv6 is FALSE, then IPv4 formatted
259 addresses will be used in this session. If UseIpv6 is TRUE, and the Ipv6Supported
260 field of the EFI_PXE_BASE_CODE_MODE structure is FALSE, then EFI_UNSUPPORTED will
261 be returned. If there is not enough memory or other resources to start the PXE
262 Base Code Protocol, then EFI_OUT_OF_RESOURCES will be returned. Otherwise, the
263 PXE Base Code Protocol will be started, and all of the fields of the EFI_PXE_BASE_CODE_MODE
264 structure will be initialized as follows:
266 Ipv6SupportedUnchanged.
267 Ipv6AvailableUnchanged.
268 UsingIpv6Set to UseIpv6.
269 BisSupportedUnchanged.
270 BisDetectedUnchanged.
272 SendGUIDSet to FALSE.
273 TTLSet to DEFAULT_TTL.
274 ToSSet to DEFAULT_ToS.
275 DhcpCompletedSet to FALSE.
276 ProxyOfferReceivedSet to FALSE.
277 StationIpSet to an address of all zeros.
278 SubnetMaskSet to a subnet mask of all zeros.
279 DhcpDiscoverZero-filled.
281 ProxyOfferZero-filled.
282 PxeDiscoverValidSet to FALSE.
283 PxeDiscoverZero-filled.
284 PxeReplyValidSet to FALSE.
286 PxeBisReplyValidSet to FALSE.
287 PxeBisReplyZero-filled.
288 IpFilterSet the Filters field to 0 and the IpCnt field to 0.
289 ArpCacheEntriesSet to 0.
291 RouteTableEntriesSet to 0.
292 RouteTableZero-filled.
293 IcmpErrorReceivedSet to FALSE.
294 IcmpErrorZero-filled.
295 TftpErroReceivedSet to FALSE.
296 TftpErrorZero-filled.
297 MakeCallbacksSet to TRUE if the PXE Base Code Callback Protocol is available.
298 Set to FALSE if the PXE Base Code Callback Protocol is not available.
300 @param This Pointer to the EFI_PXE_BASE_CODE_PROTOCOL instance.
301 @param UseIpv6 Specifies the type of IP addresses that are to be used during the session
302 that is being started. Set to TRUE for IPv6 addresses, and FALSE for
305 @retval EFI_SUCCESS The PXE Base Code Protocol was started.
306 @retval EFI_DEVICE_ERROR The network device encountered an error during this oper
307 @retval EFI_UNSUPPORTED UseIpv6 is TRUE, but the Ipv6Supported field of the
308 EFI_PXE_BASE_CODE_MODE structure is FALSE.
309 @retval EFI_ALREADY_STARTED The PXE Base Code Protocol is already in the started state.
310 @retval EFI_INVALID_PARAMETER The This parameter is NULL or does not point to a valid
311 EFI_PXE_BASE_CODE_PROTOCOL structure.
312 @retval EFI_OUT_OF_RESOURCES Could not allocate enough memory or other resources to start the
313 PXE Base Code Protocol.
319 IN EFI_PXE_BASE_CODE_PROTOCOL
*This
,
323 PXEBC_PRIVATE_DATA
*Private
;
324 EFI_PXE_BASE_CODE_MODE
*Mode
;
328 return EFI_INVALID_PARAMETER
;
331 Private
= PXEBC_PRIVATE_DATA_FROM_PXEBC (This
);
332 Mode
= Private
->PxeBc
.Mode
;
335 return EFI_ALREADY_STARTED
;
340 // IPv6 is not supported now.
342 return EFI_UNSUPPORTED
;
346 // Configure the udp4 instance to let it receive data
348 Status
= Private
->Udp4Read
->Configure (
350 &Private
->Udp4CfgData
352 if (EFI_ERROR (Status
)) {
356 Private
->AddressIsOk
= FALSE
;
358 ZeroMem (Mode
, sizeof (EFI_PXE_BASE_CODE_MODE
));
360 Mode
->Started
= TRUE
;
361 Mode
->TTL
= DEFAULT_TTL
;
362 Mode
->ToS
= DEFAULT_ToS
;
363 Mode
->AutoArp
= TRUE
;
366 // Create the event for Arp Cache checking.
368 Status
= gBS
->CreateEvent (
369 EVT_TIMER
| EVT_NOTIFY_SIGNAL
,
371 ArpCacheUpdateTimeout
,
373 &Private
->GetArpCacheEvent
375 if (EFI_ERROR (Status
)) {
380 // Start the timeout timer event.
382 Status
= gBS
->SetTimer (
383 Private
->GetArpCacheEvent
,
388 if (EFI_ERROR (Status
)) {
393 // Create ICMP error receiving event
395 Status
= gBS
->CreateEvent (
398 IcmpErrorListenHandler
,
400 &(Private
->IcmpErrorRcvToken
.Event
)
402 if (EFI_ERROR (Status
)) {
406 Status
= Private
->Ip4
->Configure (Private
->Ip4
, &Private
->Ip4ConfigData
);
407 if (EFI_ERROR (Status
)) {
412 // start to listen incoming packet
414 Status
= Private
->Ip4
->Receive (Private
->Ip4
, &Private
->IcmpErrorRcvToken
);
415 if (!EFI_ERROR (Status
)) {
420 Private
->Ip4
->Configure (Private
->Ip4
, NULL
);
422 if (Private
->IcmpErrorRcvToken
.Event
!= NULL
) {
423 gBS
->CloseEvent (Private
->IcmpErrorRcvToken
.Event
);
426 if (Private
->GetArpCacheEvent
!= NULL
) {
427 gBS
->SetTimer (Private
->GetArpCacheEvent
, TimerCancel
, 0);
428 gBS
->CloseEvent (Private
->GetArpCacheEvent
);
431 Mode
->Started
= FALSE
;
434 Mode
->AutoArp
= FALSE
;
441 Disables the use of the PXE Base Code Protocol functions.
443 This function stops all activity on the network device. All the resources allocated
444 in Start() are released, the Started field of the EFI_PXE_BASE_CODE_MODE structure is
445 set to FALSE and EFI_SUCCESS is returned. If the Started field of the EFI_PXE_BASE_CODE_MODE
446 structure is already FALSE, then EFI_NOT_STARTED will be returned.
448 @param This Pointer to the EFI_PXE_BASE_CODE_PROTOCOL instance.
450 @retval EFI_SUCCESS The PXE Base Code Protocol was stopped.
451 @retval EFI_NOT_STARTED The PXE Base Code Protocol is already in the stopped state.
452 @retval EFI_INVALID_PARAMETER The This parameter is NULL or does not point to a valid
453 EFI_PXE_BASE_CODE_PROTOCOL structure.
454 @retval EFI_DEVICE_ERROR The network device encountered an error during this operation.
460 IN EFI_PXE_BASE_CODE_PROTOCOL
*This
463 PXEBC_PRIVATE_DATA
*Private
;
464 EFI_PXE_BASE_CODE_MODE
*Mode
;
467 return EFI_INVALID_PARAMETER
;
470 Private
= PXEBC_PRIVATE_DATA_FROM_PXEBC (This
);
471 Mode
= Private
->PxeBc
.Mode
;
473 if (!Mode
->Started
) {
474 return EFI_NOT_STARTED
;
477 Private
->Ip4
->Cancel (Private
->Ip4
, NULL
);
479 // Dispatch the DPCs queued by the NotifyFunction of the canceled rx token's
482 NetLibDispatchDpc ();
484 Private
->Ip4
->Configure (Private
->Ip4
, NULL
);
487 // Close the ICMP error receiving event.
489 gBS
->CloseEvent (Private
->IcmpErrorRcvToken
.Event
);
492 // Cancel the TimeoutEvent timer.
494 gBS
->SetTimer (Private
->GetArpCacheEvent
, TimerCancel
, 0);
497 // Close the TimeoutEvent event.
499 gBS
->CloseEvent (Private
->GetArpCacheEvent
);
501 Mode
->Started
= FALSE
;
503 Private
->CurrentUdpSrcPort
= 0;
504 Private
->Udp4Write
->Configure (Private
->Udp4Write
, NULL
);
505 Private
->Udp4Read
->Configure (Private
->Udp4Read
, NULL
);
507 Private
->Dhcp4
->Stop (Private
->Dhcp4
);
508 Private
->Dhcp4
->Configure (Private
->Dhcp4
, NULL
);
510 Private
->FileSize
= 0;
517 Attempts to complete a DHCPv4 D.O.R.A. (discover / offer / request / acknowledge) or DHCPv6
518 S.A.R.R (solicit / advertise / request / reply) sequence.
520 This function attempts to complete the DHCP sequence. If this sequence is completed,
521 then EFI_SUCCESS is returned, and the DhcpCompleted, ProxyOfferReceived, StationIp,
522 SubnetMask, DhcpDiscover, DhcpAck, and ProxyOffer fields of the EFI_PXE_BASE_CODE_MODE
523 structure are filled in.
524 If SortOffers is TRUE, then the cached DHCP offer packets will be sorted before
525 they are tried. If SortOffers is FALSE, then the cached DHCP offer packets will
526 be tried in the order in which they are received. Please see the Preboot Execution
527 Environment (PXE) Specification for additional details on the implementation of DHCP.
528 This function can take at least 31 seconds to timeout and return control to the
529 caller. If the DHCP sequence does not complete, then EFI_TIMEOUT will be returned.
530 If the Callback Protocol does not return EFI_PXE_BASE_CODE_CALLBACK_STATUS_CONTINUE,
531 then the DHCP sequence will be stopped and EFI_ABORTED will be returned.
533 @param This Pointer to the EFI_PXE_BASE_CODE_PROTOCOL instance.
534 @param SortOffers TRUE if the offers received should be sorted. Set to FALSE to try the
535 offers in the order that they are received.
537 @retval EFI_SUCCESS Valid DHCP has completed.
538 @retval EFI_NOT_STARTED The PXE Base Code Protocol is in the stopped state.
539 @retval EFI_INVALID_PARAMETER The This parameter is NULL or does not point to a valid
540 EFI_PXE_BASE_CODE_PROTOCOL structure.
541 @retval EFI_DEVICE_ERROR The network device encountered an error during this operation.
542 @retval EFI_OUT_OF_RESOURCES Could not allocate enough memory to complete the DHCP Protocol.
543 @retval EFI_ABORTED The callback function aborted the DHCP Protocol.
544 @retval EFI_TIMEOUT The DHCP Protocol timed out.
545 @retval EFI_ICMP_ERROR An ICMP error packet was received during the DHCP session.
546 @retval EFI_NO_RESPONSE Valid PXE offer was not received.
552 IN EFI_PXE_BASE_CODE_PROTOCOL
*This
,
553 IN BOOLEAN SortOffers
556 PXEBC_PRIVATE_DATA
*Private
;
557 EFI_PXE_BASE_CODE_MODE
*Mode
;
558 EFI_DHCP4_PROTOCOL
*Dhcp4
;
559 EFI_DHCP4_CONFIG_DATA Dhcp4CfgData
;
560 EFI_DHCP4_MODE_DATA Dhcp4Mode
;
561 EFI_DHCP4_PACKET_OPTION
*OptList
[PXEBC_DHCP4_MAX_OPTION_NUM
];
563 UINT32 DiscoverTimeout
;
566 EFI_ARP_CONFIG_DATA ArpConfigData
;
569 return EFI_INVALID_PARAMETER
;
572 Status
= EFI_SUCCESS
;
573 Private
= PXEBC_PRIVATE_DATA_FROM_PXEBC (This
);
574 Mode
= Private
->PxeBc
.Mode
;
575 Dhcp4
= Private
->Dhcp4
;
576 Private
->Function
= EFI_PXE_BASE_CODE_FUNCTION_DHCP
;
577 Private
->SortOffers
= SortOffers
;
579 if (!Mode
->Started
) {
580 return EFI_NOT_STARTED
;
583 Mode
->IcmpErrorReceived
= FALSE
;
586 // Initialize the DHCP options and build the option list
588 OptCount
= PxeBcBuildDhcpOptions (Private
, OptList
, TRUE
);
591 // Set the DHCP4 config data.
593 ZeroMem (&Dhcp4CfgData
, sizeof (EFI_DHCP4_CONFIG_DATA
));
594 Dhcp4CfgData
.OptionCount
= OptCount
;
595 Dhcp4CfgData
.OptionList
= OptList
;
596 Dhcp4CfgData
.Dhcp4Callback
= PxeBcDhcpCallBack
;
597 Dhcp4CfgData
.CallbackContext
= Private
;
598 Dhcp4CfgData
.DiscoverTryCount
= 1;
599 Dhcp4CfgData
.DiscoverTimeout
= &DiscoverTimeout
;
601 for (Index
= 0; Index
< PXEBC_DHCP4_DISCOVER_RETRIES
; Index
++) {
603 // The four discovery timeouts are 4, 8, 16, 32 seconds respectively.
605 DiscoverTimeout
= (PXEBC_DHCP4_DISCOVER_INIT_TIMEOUT
<< Index
);
607 Status
= Dhcp4
->Configure (Dhcp4
, &Dhcp4CfgData
);
608 if (EFI_ERROR (Status
)) {
612 // Zero those arrays to record the varies numbers of DHCP OFFERS.
614 Private
->GotProxyOffer
= FALSE
;
615 Private
->NumOffers
= 0;
616 Private
->BootpIndex
= 0;
617 ZeroMem (Private
->ServerCount
, sizeof (Private
->ServerCount
));
618 ZeroMem (Private
->ProxyIndex
, sizeof (Private
->ProxyIndex
));
620 Status
= Dhcp4
->Start (Dhcp4
, NULL
);
621 if (EFI_ERROR (Status
)) {
622 if (Status
== EFI_TIMEOUT
) {
624 // If no response is received or all received offers don't match
625 // the PXE boot requirements, EFI_TIMEOUT will be returned.
629 if (Status
== EFI_ICMP_ERROR
) {
630 Mode
->IcmpErrorReceived
= TRUE
;
633 // Other error status means the DHCP really fails.
638 Status
= Dhcp4
->GetModeData (Dhcp4
, &Dhcp4Mode
);
639 if (EFI_ERROR (Status
)) {
643 ASSERT (Dhcp4Mode
.State
== Dhcp4Bound
);
647 &Dhcp4Mode
.ClientAddress
,
648 sizeof (EFI_IPv4_ADDRESS
)
651 &Private
->SubnetMask
,
652 &Dhcp4Mode
.SubnetMask
,
653 sizeof (EFI_IPv4_ADDRESS
)
657 &Dhcp4Mode
.RouterAddress
,
658 sizeof (EFI_IPv4_ADDRESS
)
662 // Check the selected offer to see whether BINL is required, if no or BINL is
663 // finished, set the various Mode members.
665 Status
= PxeBcCheckSelectedOffer (Private
);
666 if (!EFI_ERROR (Status
)) {
671 if (EFI_ERROR (Status
)) {
673 Dhcp4
->Configure (Dhcp4
, NULL
);
676 // Remove the previously configured option list and callback function
678 ZeroMem (&Dhcp4CfgData
, sizeof (EFI_DHCP4_CONFIG_DATA
));
679 Dhcp4
->Configure (Dhcp4
, &Dhcp4CfgData
);
681 Private
->AddressIsOk
= TRUE
;
683 if (!Mode
->UsingIpv6
) {
685 // If in IPv4 mode, configure the corresponding ARP with this new
686 // station IP address.
688 ZeroMem (&ArpConfigData
, sizeof (EFI_ARP_CONFIG_DATA
));
690 ArpConfigData
.SwAddressType
= 0x0800;
691 ArpConfigData
.SwAddressLength
= sizeof (EFI_IPv4_ADDRESS
);
692 ArpConfigData
.StationAddress
= &Private
->StationIp
.v4
;
694 Private
->Arp
->Configure (Private
->Arp
, NULL
);
695 Private
->Arp
->Configure (Private
->Arp
, &ArpConfigData
);
698 // Updated the route table. Fill the first entry.
700 Mode
->RouteTableEntries
= 1;
701 Mode
->RouteTable
[0].IpAddr
.Addr
[0] = Private
->StationIp
.Addr
[0] & Private
->SubnetMask
.Addr
[0];
702 Mode
->RouteTable
[0].SubnetMask
.Addr
[0] = Private
->SubnetMask
.Addr
[0];
703 Mode
->RouteTable
[0].GwAddr
.Addr
[0] = 0;
706 // Create the default route entry if there is a default router.
708 if (Private
->GatewayIp
.Addr
[0] != 0) {
709 Mode
->RouteTableEntries
= 2;
710 Mode
->RouteTable
[1].IpAddr
.Addr
[0] = 0;
711 Mode
->RouteTable
[1].SubnetMask
.Addr
[0] = 0;
712 Mode
->RouteTable
[1].GwAddr
.Addr
[0] = Private
->GatewayIp
.Addr
[0];
722 Attempts to complete the PXE Boot Server and/or boot image discovery sequence.
724 This function attempts to complete the PXE Boot Server and/or boot image discovery
725 sequence. If this sequence is completed, then EFI_SUCCESS is returned, and the
726 PxeDiscoverValid, PxeDiscover, PxeReplyReceived, and PxeReply fields of the
727 EFI_PXE_BASE_CODE_MODE structure are filled in. If UseBis is TRUE, then the
728 PxeBisReplyReceived and PxeBisReply fields of the EFI_PXE_BASE_CODE_MODE structure
729 will also be filled in. If UseBis is FALSE, then PxeBisReplyValid will be set to FALSE.
730 In the structure referenced by parameter Info, the PXE Boot Server list, SrvList[],
731 has two uses: It is the Boot Server IP address list used for unicast discovery
732 (if the UseUCast field is TRUE), and it is the list used for Boot Server verification
733 (if the MustUseList field is TRUE). Also, if the MustUseList field in that structure
734 is TRUE and the AcceptAnyResponse field in the SrvList[] array is TRUE, any Boot
735 Server reply of that type will be accepted. If the AcceptAnyResponse field is
736 FALSE, only responses from Boot Servers with matching IP addresses will be accepted.
737 This function can take at least 10 seconds to timeout and return control to the
738 caller. If the Discovery sequence does not complete, then EFI_TIMEOUT will be
739 returned. Please see the Preboot Execution Environment (PXE) Specification for
740 additional details on the implementation of the Discovery sequence.
741 If the Callback Protocol does not return EFI_PXE_BASE_CODE_CALLBACK_STATUS_CONTINUE,
742 then the Discovery sequence is stopped and EFI_ABORTED will be returned.
744 @param This Pointer to the EFI_PXE_BASE_CODE_PROTOCOL instance.
745 @param Type The type of bootstrap to perform.
746 @param Layer Pointer to the boot server layer number to discover, which must be
747 PXE_BOOT_LAYER_INITIAL when a new server type is being
749 @param UseBis TRUE if Boot Integrity Services are to be used. FALSE otherwise.
750 @param Info Pointer to a data structure that contains additional information on the
751 type of discovery operation that is to be performed.
753 @retval EFI_SUCCESS The Discovery sequence has been completed.
754 @retval EFI_NOT_STARTED The PXE Base Code Protocol is in the stopped state.
755 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
756 @retval EFI_DEVICE_ERROR The network device encountered an error during this operation.
757 @retval EFI_OUT_OF_RESOURCES Could not allocate enough memory to complete Discovery.
758 @retval EFI_ABORTED The callback function aborted the Discovery sequence.
759 @retval EFI_TIMEOUT The Discovery sequence timed out.
760 @retval EFI_ICMP_ERROR An ICMP error packet was received during the PXE discovery
767 IN EFI_PXE_BASE_CODE_PROTOCOL
*This
,
771 IN EFI_PXE_BASE_CODE_DISCOVER_INFO
*Info OPTIONAL
774 PXEBC_PRIVATE_DATA
*Private
;
775 EFI_PXE_BASE_CODE_MODE
*Mode
;
776 EFI_PXE_BASE_CODE_DISCOVER_INFO DefaultInfo
;
777 EFI_PXE_BASE_CODE_SRVLIST
*SrvList
;
778 EFI_PXE_BASE_CODE_SRVLIST DefaultSrvList
;
779 PXEBC_CACHED_DHCP4_PACKET
*Packet
;
780 PXEBC_VENDOR_OPTION
*VendorOpt
;
783 PXEBC_BOOT_SVR_ENTRY
*BootSvrEntry
;
786 return EFI_INVALID_PARAMETER
;
789 Private
= PXEBC_PRIVATE_DATA_FROM_PXEBC (This
);
790 Mode
= Private
->PxeBc
.Mode
;
793 Status
= EFI_DEVICE_ERROR
;
794 Private
->Function
= EFI_PXE_BASE_CODE_FUNCTION_DISCOVER
;
796 if (!Private
->AddressIsOk
) {
797 return EFI_INVALID_PARAMETER
;
800 if (!Mode
->Started
) {
801 return EFI_NOT_STARTED
;
804 Mode
->IcmpErrorReceived
= FALSE
;
807 // If layer isn't EFI_PXE_BASE_CODE_BOOT_LAYER_INITIAL,
808 // use the previous setting;
809 // If info isn't offered,
810 // use the cached DhcpAck and ProxyOffer packets.
812 if (*Layer
!= EFI_PXE_BASE_CODE_BOOT_LAYER_INITIAL
) {
814 if (!Mode
->PxeDiscoverValid
|| !Mode
->PxeReplyReceived
|| (!Mode
->PxeBisReplyReceived
&& UseBis
)) {
816 return EFI_INVALID_PARAMETER
;
819 DefaultInfo
.IpCnt
= 1;
820 DefaultInfo
.UseUCast
= TRUE
;
822 DefaultSrvList
.Type
= Type
;
823 DefaultSrvList
.AcceptAnyResponse
= FALSE
;
824 DefaultSrvList
.IpAddr
.Addr
[0] = Private
->ServerIp
.Addr
[0];
826 SrvList
= &DefaultSrvList
;
828 } else if (Info
== NULL
) {
830 // Create info by the cached packet before
832 Packet
= (Mode
->ProxyOfferReceived
) ? &Private
->ProxyOffer
: &Private
->Dhcp4Ack
;
833 VendorOpt
= &Packet
->PxeVendorOption
;
835 if (!Mode
->DhcpAckReceived
|| !IS_VALID_DISCOVER_VENDOR_OPTION (VendorOpt
->BitMap
)) {
837 // Address is not acquired or no discovery options.
839 return EFI_INVALID_PARAMETER
;
842 DefaultInfo
.UseMCast
= (BOOLEAN
)!IS_DISABLE_MCAST_DISCOVER (VendorOpt
->DiscoverCtrl
);
843 DefaultInfo
.UseBCast
= (BOOLEAN
)!IS_DISABLE_BCAST_DISCOVER (VendorOpt
->DiscoverCtrl
);
844 DefaultInfo
.MustUseList
= (BOOLEAN
) IS_ENABLE_USE_SERVER_LIST (VendorOpt
->DiscoverCtrl
);
845 DefaultInfo
.UseUCast
= DefaultInfo
.MustUseList
;
847 if (DefaultInfo
.UseMCast
) {
849 // Get the multicast discover ip address from vendor option.
852 &DefaultInfo
.ServerMCastIp
.Addr
,
853 &VendorOpt
->DiscoverMcastIp
,
854 sizeof (EFI_IPv4_ADDRESS
)
858 DefaultInfo
.IpCnt
= 0;
860 if (DefaultInfo
.MustUseList
) {
861 BootSvrEntry
= VendorOpt
->BootSvr
;
862 Status
= EFI_INVALID_PARAMETER
;
864 while (((UINT8
) (BootSvrEntry
- VendorOpt
->BootSvr
)) < VendorOpt
->BootSvrLen
) {
866 if (BootSvrEntry
->Type
== HTONS (Type
)) {
867 Status
= EFI_SUCCESS
;
871 BootSvrEntry
= GET_NEXT_BOOT_SVR_ENTRY (BootSvrEntry
);
874 if (EFI_ERROR (Status
)) {
878 DefaultInfo
.IpCnt
= BootSvrEntry
->IpCnt
;
884 SrvList
= Info
->SrvList
;
886 if (!SrvList
[0].AcceptAnyResponse
) {
888 for (Index
= 1; Index
< Info
->IpCnt
; Index
++) {
889 if (SrvList
[Index
].AcceptAnyResponse
) {
894 if (Index
!= Info
->IpCnt
) {
895 return EFI_INVALID_PARAMETER
;
900 if ((!Info
->UseUCast
&& !Info
->UseBCast
&& !Info
->UseMCast
) || (Info
->MustUseList
&& Info
->IpCnt
== 0)) {
902 return EFI_INVALID_PARAMETER
;
905 // Execute discover by UniCast/BroadCast/MultiCast
907 if (Info
->UseUCast
) {
909 for (Index
= 0; Index
< Info
->IpCnt
; Index
++) {
911 if (BootSvrEntry
== NULL
) {
912 Private
->ServerIp
.Addr
[0] = SrvList
[Index
].IpAddr
.Addr
[0];
916 &BootSvrEntry
->IpAddr
[Index
],
917 sizeof (EFI_IPv4_ADDRESS
)
921 Status
= PxeBcDiscvBootService (
926 &SrvList
[Index
].IpAddr
,
930 &Private
->PxeReply
.Packet
.Ack
934 } else if (Info
->UseMCast
) {
936 Status
= PxeBcDiscvBootService (
941 &Info
->ServerMCastIp
,
945 &Private
->PxeReply
.Packet
.Ack
948 } else if (Info
->UseBCast
) {
950 Status
= PxeBcDiscvBootService (
959 &Private
->PxeReply
.Packet
.Ack
963 if (EFI_ERROR (Status
) || !Mode
->PxeReplyReceived
|| (!Mode
->PxeBisReplyReceived
&& UseBis
)) {
964 if (Status
== EFI_ICMP_ERROR
) {
965 Mode
->IcmpErrorReceived
= TRUE
;
967 Status
= EFI_DEVICE_ERROR
;
970 PxeBcParseCachedDhcpPacket (&Private
->PxeReply
);
973 if (Mode
->PxeBisReplyReceived
) {
976 &Mode
->PxeReply
.Dhcpv4
.BootpSiAddr
,
977 sizeof (EFI_IPv4_ADDRESS
)
986 Used to perform TFTP and MTFTP services.
988 This function is used to perform TFTP and MTFTP services. This includes the
989 TFTP operations to get the size of a file, read a directory, read a file, and
990 write a file. It also includes the MTFTP operations to get the size of a file,
991 read a directory, and read a file. The type of operation is specified by Operation.
992 If the callback function that is invoked during the TFTP/MTFTP operation does
993 not return EFI_PXE_BASE_CODE_CALLBACK_STATUS_CONTINUE, then EFI_ABORTED will
995 For read operations, the return data will be placed in the buffer specified by
996 BufferPtr. If BufferSize is too small to contain the entire downloaded file,
997 then EFI_BUFFER_TOO_SMALL will be returned and BufferSize will be set to zero
998 or the size of the requested file (the size of the requested file is only returned
999 if the TFTP server supports TFTP options). If BufferSize is large enough for the
1000 read operation, then BufferSize will be set to the size of the downloaded file,
1001 and EFI_SUCCESS will be returned. Applications using the PxeBc.Mtftp() services
1002 should use the get-file-size operations to determine the size of the downloaded
1003 file prior to using the read-file operations-especially when downloading large
1004 (greater than 64 MB) files-instead of making two calls to the read-file operation.
1005 Following this recommendation will save time if the file is larger than expected
1006 and the TFTP server does not support TFTP option extensions. Without TFTP option
1007 extension support, the client has to download the entire file, counting and discarding
1008 the received packets, to determine the file size.
1009 For write operations, the data to be sent is in the buffer specified by BufferPtr.
1010 BufferSize specifies the number of bytes to send. If the write operation completes
1011 successfully, then EFI_SUCCESS will be returned.
1012 For TFTP "get file size" operations, the size of the requested file or directory
1013 is returned in BufferSize, and EFI_SUCCESS will be returned. If the TFTP server
1014 does not support options, the file will be downloaded into a bit bucket and the
1015 length of the downloaded file will be returned. For MTFTP "get file size" operations,
1016 if the MTFTP server does not support the "get file size" option, EFI_UNSUPPORTED
1018 This function can take up to 10 seconds to timeout and return control to the caller.
1019 If the TFTP sequence does not complete, EFI_TIMEOUT will be returned.
1020 If the Callback Protocol does not return EFI_PXE_BASE_CODE_CALLBACK_STATUS_CONTINUE,
1021 then the TFTP sequence is stopped and EFI_ABORTED will be returned.
1022 The format of the data returned from a TFTP read directory operation is a null-terminated
1023 filename followed by a null-terminated information string, of the form
1024 "size year-month-day hour:minute:second" (i.e. %d %d-%d-%d %d:%d:%f - note that
1025 the seconds field can be a decimal number), where the date and time are UTC. For
1026 an MTFTP read directory command, there is additionally a null-terminated multicast
1027 IP address preceding the filename of the form %d.%d.%d.%d for IP v4. The final
1028 entry is itself null-terminated, so that the final information string is terminated
1029 with two null octets.
1031 @param This Pointer to the EFI_PXE_BASE_CODE_PROTOCOL instance.
1032 @param Operation The type of operation to perform.
1033 @param BufferPtr A pointer to the data buffer.
1034 @param Overwrite Only used on write file operations. TRUE if a file on a remote server can
1036 @param BufferSize For get-file-size operations, *BufferSize returns the size of the
1038 @param BlockSize The requested block size to be used during a TFTP transfer.
1039 @param ServerIp The TFTP / MTFTP server IP address.
1040 @param Filename A Null-terminated ASCII string that specifies a directory name or a file
1042 @param Info Pointer to the MTFTP information.
1043 @param DontUseBuffer Set to FALSE for normal TFTP and MTFTP read file operation.
1045 @retval EFI_SUCCESS The TFTP/MTFTP operation was completed.
1046 @retval EFI_NOT_STARTED The PXE Base Code Protocol is in the stopped state.
1047 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
1048 @retval EFI_DEVICE_ERROR The network device encountered an error during this operation.
1049 @retval EFI_BUFFER_TOO_SMALL The buffer is not large enough to complete the read operation.
1050 @retval EFI_ABORTED The callback function aborted the TFTP/MTFTP operation.
1051 @retval EFI_TIMEOUT The TFTP/MTFTP operation timed out.
1052 @retval EFI_ICMP_ERROR An ICMP error packet was received during the MTFTP session.
1053 @retval EFI_TFTP_ERROR A TFTP error packet was received during the MTFTP session.
1059 IN EFI_PXE_BASE_CODE_PROTOCOL
*This
,
1060 IN EFI_PXE_BASE_CODE_TFTP_OPCODE Operation
,
1061 IN OUT VOID
*BufferPtr
,
1062 IN BOOLEAN Overwrite
,
1063 IN OUT UINT64
*BufferSize
,
1064 IN UINTN
*BlockSize OPTIONAL
,
1065 IN EFI_IP_ADDRESS
*ServerIp
,
1067 IN EFI_PXE_BASE_CODE_MTFTP_INFO
*Info OPTIONAL
,
1068 IN BOOLEAN DontUseBuffer
1071 PXEBC_PRIVATE_DATA
*Private
;
1072 EFI_MTFTP4_CONFIG_DATA Mtftp4Config
;
1074 EFI_PXE_BASE_CODE_MODE
*Mode
;
1075 EFI_MAC_ADDRESS TempMacAddr
;
1077 if ((This
== NULL
) ||
1078 (Filename
== NULL
) ||
1079 (BufferSize
== NULL
) ||
1080 ((ServerIp
== NULL
) || !Ip4IsUnicast (NTOHL (ServerIp
->Addr
[0]), 0)) ||
1081 ((BufferPtr
== NULL
) && DontUseBuffer
) ||
1082 ((BlockSize
!= NULL
) && (*BlockSize
< 512))) {
1084 return EFI_INVALID_PARAMETER
;
1087 Status
= EFI_DEVICE_ERROR
;
1088 Private
= PXEBC_PRIVATE_DATA_FROM_PXEBC (This
);
1089 Mode
= &Private
->Mode
;
1091 if (!Mode
->AutoArp
) {
1093 // If AutoArp is set false, check arp cache
1095 UpdateArpCache (This
);
1096 if (!FindInArpCache (Mode
, &ServerIp
->v4
, &TempMacAddr
)) {
1097 return EFI_DEVICE_ERROR
;
1101 Mode
->TftpErrorReceived
= FALSE
;
1102 Mode
->IcmpErrorReceived
= FALSE
;
1104 Mtftp4Config
.UseDefaultSetting
= FALSE
;
1105 Mtftp4Config
.TimeoutValue
= PXEBC_MTFTP_TIMEOUT
;
1106 Mtftp4Config
.TryCount
= PXEBC_MTFTP_RETRIES
;
1109 &Mtftp4Config
.StationIp
,
1110 &Private
->StationIp
,
1111 sizeof (EFI_IPv4_ADDRESS
)
1114 &Mtftp4Config
.SubnetMask
,
1115 &Private
->SubnetMask
,
1116 sizeof (EFI_IPv4_ADDRESS
)
1119 &Mtftp4Config
.GatewayIp
,
1120 &Private
->GatewayIp
,
1121 sizeof (EFI_IPv4_ADDRESS
)
1124 &Mtftp4Config
.ServerIp
,
1126 sizeof (EFI_IPv4_ADDRESS
)
1129 switch (Operation
) {
1131 case EFI_PXE_BASE_CODE_TFTP_GET_FILE_SIZE
:
1133 Status
= PxeBcTftpGetFileSize (
1141 if (!EFI_ERROR (Status
)) {
1142 Status
= EFI_BUFFER_TOO_SMALL
;
1147 case EFI_PXE_BASE_CODE_TFTP_READ_FILE
:
1149 Status
= PxeBcTftpReadFile (
1161 case EFI_PXE_BASE_CODE_TFTP_WRITE_FILE
:
1163 Status
= PxeBcTftpWriteFile (
1175 case EFI_PXE_BASE_CODE_TFTP_READ_DIRECTORY
:
1177 Status
= PxeBcTftpReadDirectory (
1189 case EFI_PXE_BASE_CODE_MTFTP_GET_FILE_SIZE
:
1190 case EFI_PXE_BASE_CODE_MTFTP_READ_FILE
:
1191 case EFI_PXE_BASE_CODE_MTFTP_READ_DIRECTORY
:
1192 Status
= EFI_UNSUPPORTED
;
1197 Status
= EFI_INVALID_PARAMETER
;
1201 if (Status
== EFI_ICMP_ERROR
) {
1202 Mode
->IcmpErrorReceived
= TRUE
;
1210 Writes a UDP packet to the network interface.
1212 This function writes a UDP packet specified by the (optional HeaderPtr and)
1213 BufferPtr parameters to the network interface. The UDP header is automatically
1214 built by this routine. It uses the parameters OpFlags, DestIp, DestPort, GatewayIp,
1215 SrcIp, and SrcPort to build this header. If the packet is successfully built and
1216 transmitted through the network interface, then EFI_SUCCESS will be returned.
1217 If a timeout occurs during the transmission of the packet, then EFI_TIMEOUT will
1218 be returned. If an ICMP error occurs during the transmission of the packet, then
1219 the IcmpErrorReceived field is set to TRUE, the IcmpError field is filled in and
1220 EFI_ICMP_ERROR will be returned. If the Callback Protocol does not return
1221 EFI_PXE_BASE_CODE_CALLBACK_STATUS_CONTINUE, then EFI_ABORTED will be returned.
1223 @param This Pointer to the EFI_PXE_BASE_CODE_PROTOCOL instance.
1224 @param OpFlags The UDP operation flags.
1225 @param DestIp The destination IP address.
1226 @param DestPort The destination UDP port number.
1227 @param GatewayIp The gateway IP address.
1228 @param SrcIp The source IP address.
1229 @param SrcPort The source UDP port number.
1230 @param HeaderSize An optional field which may be set to the length of a header at
1231 HeaderPtr to be prefixed to the data at BufferPtr.
1232 @param HeaderPtr If HeaderSize is not NULL, a pointer to a header to be prefixed to the
1234 @param BufferSize A pointer to the size of the data at BufferPtr.
1235 @param BufferPtr A pointer to the data to be written.
1237 @retval EFI_SUCCESS The UDP Write operation was completed.
1238 @retval EFI_NOT_STARTED The PXE Base Code Protocol is in the stopped state.
1239 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
1240 @retval EFI_BAD_BUFFER_SIZE The buffer is too long to be transmitted.
1241 @retval EFI_ABORTED The callback function aborted the UDP Write operation.
1242 @retval EFI_TIMEOUT The UDP Write operation timed out.
1243 @retval EFI_ICMP_ERROR An ICMP error packet was received during the UDP write session.
1249 IN EFI_PXE_BASE_CODE_PROTOCOL
*This
,
1251 IN EFI_IP_ADDRESS
*DestIp
,
1252 IN EFI_PXE_BASE_CODE_UDP_PORT
*DestPort
,
1253 IN EFI_IP_ADDRESS
*GatewayIp OPTIONAL
,
1254 IN EFI_IP_ADDRESS
*SrcIp OPTIONAL
,
1255 IN OUT EFI_PXE_BASE_CODE_UDP_PORT
*SrcPort OPTIONAL
,
1256 IN UINTN
*HeaderSize OPTIONAL
,
1257 IN VOID
*HeaderPtr OPTIONAL
,
1258 IN UINTN
*BufferSize
,
1262 PXEBC_PRIVATE_DATA
*Private
;
1263 EFI_UDP4_PROTOCOL
*Udp4
;
1264 EFI_UDP4_COMPLETION_TOKEN Token
;
1265 EFI_UDP4_TRANSMIT_DATA
*Udp4TxData
;
1268 EFI_UDP4_SESSION_DATA Udp4Session
;
1271 EFI_PXE_BASE_CODE_MODE
*Mode
;
1272 EFI_MAC_ADDRESS TempMacAddr
;
1276 if ((This
== NULL
) || (DestIp
== NULL
) || (DestPort
== NULL
)) {
1277 return EFI_INVALID_PARAMETER
;
1280 if ((GatewayIp
!= NULL
) && !Ip4IsUnicast (NTOHL (GatewayIp
->Addr
[0]), 0)) {
1282 // Gateway is provided but it's not a unicast IP address.
1284 return EFI_INVALID_PARAMETER
;
1287 if ((HeaderSize
!= NULL
) && ((*HeaderSize
== 0) || (HeaderPtr
== NULL
))) {
1289 // The HeaderSize ptr isn't NULL and: 1. the value is zero; or 2. the HeaderPtr
1292 return EFI_INVALID_PARAMETER
;
1295 if ((BufferSize
== NULL
) || ((*BufferSize
!= 0) && (BufferPtr
== NULL
))) {
1296 return EFI_INVALID_PARAMETER
;
1299 Private
= PXEBC_PRIVATE_DATA_FROM_PXEBC (This
);
1300 Udp4
= Private
->Udp4Write
;
1301 Mode
= &Private
->Mode
;
1302 if (!Mode
->Started
) {
1303 return EFI_NOT_STARTED
;
1306 if (!Private
->AddressIsOk
&& (SrcIp
== NULL
)) {
1307 return EFI_INVALID_PARAMETER
;
1310 if (!Mode
->AutoArp
) {
1312 // If AutoArp is set false, check arp cache
1314 UpdateArpCache (This
);
1315 if (!FindInArpCache (Mode
, &DestIp
->v4
, &TempMacAddr
)) {
1316 return EFI_DEVICE_ERROR
;
1320 Mode
->IcmpErrorReceived
= FALSE
;
1322 if ((Private
->CurrentUdpSrcPort
== 0) ||
1323 ((SrcPort
!= NULL
) && (*SrcPort
!= Private
->CurrentUdpSrcPort
))) {
1325 // Port is changed, (re)configure the Udp4Write instance
1327 if (SrcPort
!= NULL
) {
1328 Private
->CurrentUdpSrcPort
= *SrcPort
;
1331 Status
= PxeBcConfigureUdpWriteInstance (
1333 &Private
->StationIp
.v4
,
1334 &Private
->SubnetMask
.v4
,
1335 &Private
->GatewayIp
.v4
,
1336 &Private
->CurrentUdpSrcPort
1338 if (EFI_ERROR (Status
)) {
1339 Private
->CurrentUdpSrcPort
= 0;
1340 return EFI_INVALID_PARAMETER
;
1344 ZeroMem (&Token
, sizeof (EFI_UDP4_COMPLETION_TOKEN
));
1345 ZeroMem (&Udp4Session
, sizeof (EFI_UDP4_SESSION_DATA
));
1347 CopyMem (&Udp4Session
.DestinationAddress
, DestIp
, sizeof (EFI_IPv4_ADDRESS
));
1348 Udp4Session
.DestinationPort
= *DestPort
;
1349 if (SrcIp
!= NULL
) {
1350 CopyMem (&Udp4Session
.SourceAddress
, SrcIp
, sizeof (EFI_IPv4_ADDRESS
));
1352 if (SrcPort
!= NULL
) {
1353 Udp4Session
.SourcePort
= *SrcPort
;
1356 FragCount
= (HeaderSize
!= NULL
) ? 2 : 1;
1357 Udp4TxData
= (EFI_UDP4_TRANSMIT_DATA
*) AllocateZeroPool (sizeof (EFI_UDP4_TRANSMIT_DATA
) + (FragCount
- 1) * sizeof (EFI_UDP4_FRAGMENT_DATA
));
1358 if (Udp4TxData
== NULL
) {
1359 return EFI_OUT_OF_RESOURCES
;
1362 Udp4TxData
->FragmentCount
= FragCount
;
1363 Udp4TxData
->FragmentTable
[FragCount
- 1].FragmentLength
= (UINT32
) *BufferSize
;
1364 Udp4TxData
->FragmentTable
[FragCount
- 1].FragmentBuffer
= BufferPtr
;
1365 DataLength
= (UINT32
) *BufferSize
;
1367 if (FragCount
== 2) {
1369 Udp4TxData
->FragmentTable
[0].FragmentLength
= (UINT32
) *HeaderSize
;
1370 Udp4TxData
->FragmentTable
[0].FragmentBuffer
= HeaderPtr
;
1371 DataLength
+= (UINT32
) *HeaderSize
;
1374 if (GatewayIp
!= NULL
) {
1375 Udp4TxData
->GatewayAddress
= (EFI_IPv4_ADDRESS
*) GatewayIp
;
1377 Udp4TxData
->UdpSessionData
= &Udp4Session
;
1378 Udp4TxData
->DataLength
= DataLength
;
1379 Token
.Packet
.TxData
= Udp4TxData
;
1381 Status
= gBS
->CreateEvent (
1388 if (EFI_ERROR (Status
)) {
1392 Status
= Udp4
->Transmit (Udp4
, &Token
);
1393 if (EFI_ERROR (Status
)) {
1394 if (Status
== EFI_ICMP_ERROR
) {
1395 Mode
->IcmpErrorReceived
= TRUE
;
1405 Status
= Token
.Status
;
1409 if (Token
.Event
!= NULL
) {
1410 gBS
->CloseEvent (Token
.Event
);
1413 gBS
->FreePool (Udp4TxData
);
1419 Decide whether the incoming UDP packet is acceptable per IP filter settings
1420 in provided PxeBcMode.
1422 @param PxeBcMode Pointer to EFI_PXE_BASE_CODE_MODE.
1423 @param Session Received UDP session.
1425 @retval TRUE The UDP package matches IP filters.
1426 @retval FALSE The UDP package doesn't matches IP filters.
1431 IN EFI_PXE_BASE_CODE_MODE
*PxeBcMode
,
1432 IN EFI_UDP4_SESSION_DATA
*Session
1436 EFI_IPv4_ADDRESS Ip4Address
;
1437 EFI_IPv4_ADDRESS DestIp4Address
;
1439 if ((PxeBcMode
->IpFilter
.Filters
& EFI_PXE_BASE_CODE_IP_FILTER_PROMISCUOUS
) != 0) {
1443 CopyMem (&DestIp4Address
, &Session
->DestinationAddress
, sizeof (DestIp4Address
));
1444 if ((PxeBcMode
->IpFilter
.Filters
& EFI_PXE_BASE_CODE_IP_FILTER_PROMISCUOUS_MULTICAST
) &&
1445 IP4_IS_MULTICAST (EFI_NTOHL (DestIp4Address
))
1450 if ((PxeBcMode
->IpFilter
.Filters
& EFI_PXE_BASE_CODE_IP_FILTER_BROADCAST
) &&
1451 IP4_IS_LOCAL_BROADCAST (EFI_NTOHL (DestIp4Address
))
1456 CopyMem (&Ip4Address
, &PxeBcMode
->StationIp
.v4
, sizeof (Ip4Address
));
1457 if ((PxeBcMode
->IpFilter
.Filters
& EFI_PXE_BASE_CODE_IP_FILTER_STATION_IP
) &&
1458 EFI_IP4_EQUAL (&Ip4Address
, &DestIp4Address
)
1463 for (Index
= 0; Index
< PxeBcMode
->IpFilter
.IpCnt
; Index
++) {
1466 &PxeBcMode
->IpFilter
.IpList
[Index
].v4
,
1469 if (EFI_IP4_EQUAL (&Ip4Address
, &DestIp4Address
)) {
1478 Reads a UDP packet from the network interface.
1480 This function reads a UDP packet from a network interface. The data contents
1481 are returned in (the optional HeaderPtr and) BufferPtr, and the size of the
1482 buffer received is returned in BufferSize . If the input BufferSize is smaller
1483 than the UDP packet received (less optional HeaderSize), it will be set to the
1484 required size, and EFI_BUFFER_TOO_SMALL will be returned. In this case, the
1485 contents of BufferPtr are undefined, and the packet is lost. If a UDP packet is
1486 successfully received, then EFI_SUCCESS will be returned, and the information
1487 from the UDP header will be returned in DestIp, DestPort, SrcIp, and SrcPort if
1488 they are not NULL. Depending on the values of OpFlags and the DestIp, DestPort,
1489 SrcIp, and SrcPort input values, different types of UDP packet receive filtering
1490 will be performed. The following tables summarize these receive filter operations.
1492 @param This Pointer to the EFI_PXE_BASE_CODE_PROTOCOL instance.
1493 @param OpFlags The UDP operation flags.
1494 @param DestIp The destination IP address.
1495 @param DestPort The destination UDP port number.
1496 @param SrcIp The source IP address.
1497 @param SrcPort The source UDP port number.
1498 @param HeaderSize An optional field which may be set to the length of a header at
1499 HeaderPtr to be prefixed to the data at BufferPtr.
1500 @param HeaderPtr If HeaderSize is not NULL, a pointer to a header to be prefixed to the
1502 @param BufferSize A pointer to the size of the data at BufferPtr.
1503 @param BufferPtr A pointer to the data to be read.
1505 @retval EFI_SUCCESS The UDP Read operation was completed.
1506 @retval EFI_NOT_STARTED The PXE Base Code Protocol is in the stopped state.
1507 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
1508 @retval EFI_DEVICE_ERROR The network device encountered an error during this operation.
1509 @retval EFI_BUFFER_TOO_SMALL The packet is larger than Buffer can hold.
1510 @retval EFI_ABORTED The callback function aborted the UDP Read operation.
1511 @retval EFI_TIMEOUT The UDP Read operation timed out.
1517 IN EFI_PXE_BASE_CODE_PROTOCOL
*This
,
1519 IN OUT EFI_IP_ADDRESS
*DestIp OPTIONAL
,
1520 IN OUT EFI_PXE_BASE_CODE_UDP_PORT
*DestPort OPTIONAL
,
1521 IN OUT EFI_IP_ADDRESS
*SrcIp OPTIONAL
,
1522 IN OUT EFI_PXE_BASE_CODE_UDP_PORT
*SrcPort OPTIONAL
,
1523 IN UINTN
*HeaderSize OPTIONAL
,
1524 IN VOID
*HeaderPtr OPTIONAL
,
1525 IN OUT UINTN
*BufferSize
,
1529 PXEBC_PRIVATE_DATA
*Private
;
1530 EFI_PXE_BASE_CODE_MODE
*Mode
;
1531 EFI_UDP4_PROTOCOL
*Udp4
;
1532 EFI_UDP4_COMPLETION_TOKEN Token
;
1533 EFI_UDP4_RECEIVE_DATA
*RxData
;
1534 EFI_UDP4_SESSION_DATA
*Session
;
1540 if (This
== NULL
|| DestIp
== NULL
|| DestPort
== NULL
) {
1541 return EFI_INVALID_PARAMETER
;
1544 if (((OpFlags
& EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_DEST_PORT
) == 0 && (DestPort
== NULL
)) ||
1545 ((OpFlags
& EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_DEST_PORT
) == 0 && (SrcIp
== NULL
)) ||
1546 ((OpFlags
& EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_SRC_PORT
) == 0 && (SrcPort
== NULL
))) {
1547 return EFI_INVALID_PARAMETER
;
1550 if (((HeaderSize
!= NULL
) && (*HeaderSize
== 0)) || ((HeaderSize
!= NULL
) && (HeaderPtr
== NULL
))) {
1551 return EFI_INVALID_PARAMETER
;
1554 if ((BufferSize
== NULL
) || ((BufferPtr
== NULL
) && (*BufferSize
!= 0))) {
1555 return EFI_INVALID_PARAMETER
;
1558 Private
= PXEBC_PRIVATE_DATA_FROM_PXEBC (This
);
1559 Mode
= Private
->PxeBc
.Mode
;
1560 Udp4
= Private
->Udp4Read
;
1562 if (!Mode
->Started
) {
1563 return EFI_NOT_STARTED
;
1566 Mode
->IcmpErrorReceived
= FALSE
;
1568 Status
= gBS
->CreateEvent (
1575 if (EFI_ERROR (Status
)) {
1576 return EFI_OUT_OF_RESOURCES
;
1582 Status
= Udp4
->Receive (Udp4
, &Token
);
1583 if (EFI_ERROR (Status
)) {
1584 if (Status
== EFI_ICMP_ERROR
) {
1585 Mode
->IcmpErrorReceived
= TRUE
;
1593 Status
= EFI_TIMEOUT
;
1597 // check whether this packet matches the filters
1599 if (EFI_ERROR (Token
.Status
)){
1603 RxData
= Token
.Packet
.RxData
;
1604 Session
= &RxData
->UdpSession
;
1608 if ((OpFlags
& EFI_PXE_BASE_CODE_UDP_OPFLAGS_USE_FILTER
) != 0) {
1610 // Check UDP package by IP filter settings
1612 if (CheckIpByFilter (Mode
, Session
)) {
1621 // Match the destination ip of the received udp dgram
1623 if ((OpFlags
& EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_DEST_IP
) != 0) {
1626 if (DestIp
!= NULL
) {
1627 CopyMem (DestIp
, &Session
->DestinationAddress
, sizeof (EFI_IPv4_ADDRESS
));
1630 if (DestIp
!= NULL
) {
1631 if (EFI_IP4_EQUAL (DestIp
, &Session
->DestinationAddress
)) {
1635 if (EFI_IP4_EQUAL (&Private
->StationIp
, &Session
->DestinationAddress
)) {
1644 // Match the destination port of the received udp dgram
1646 if ((OpFlags
& EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_DEST_PORT
) != 0) {
1648 if (DestPort
!= NULL
) {
1649 *DestPort
= Session
->DestinationPort
;
1653 if (*DestPort
!= Session
->DestinationPort
) {
1661 // Match the source ip of the received udp dgram
1663 if ((OpFlags
& EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_SRC_IP
) != 0) {
1665 if (SrcIp
!= NULL
) {
1666 CopyMem (SrcIp
, &Session
->SourceAddress
, sizeof (EFI_IPv4_ADDRESS
));
1670 if (!EFI_IP4_EQUAL (SrcIp
, &Session
->SourceAddress
)) {
1678 // Match the source port of the received udp dgram
1680 if ((OpFlags
& EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_SRC_PORT
) != 0) {
1682 if (SrcPort
!= NULL
) {
1683 *SrcPort
= Session
->SourcePort
;
1687 if (*SrcPort
!= Session
->SourcePort
) {
1697 if (HeaderSize
!= NULL
) {
1698 CopyLen
= MIN (*HeaderSize
, RxData
->DataLength
);
1699 CopyMem (HeaderPtr
, RxData
->FragmentTable
[0].FragmentBuffer
, CopyLen
);
1700 *HeaderSize
= CopyLen
;
1703 if (RxData
->DataLength
- CopyLen
> *BufferSize
) {
1705 Status
= EFI_BUFFER_TOO_SMALL
;
1708 *BufferSize
= RxData
->DataLength
- CopyLen
;
1711 (UINT8
*) RxData
->FragmentTable
[0].FragmentBuffer
+ CopyLen
,
1717 Status
= EFI_TIMEOUT
;
1721 // Recycle the RxData
1723 gBS
->SignalEvent (RxData
->RecycleSignal
);
1732 Udp4
->Cancel (Udp4
, &Token
);
1734 gBS
->CloseEvent (Token
.Event
);
1740 Updates the IP receive filters of a network device and enables software filtering.
1742 The NewFilter field is used to modify the network device's current IP receive
1743 filter settings and to enable a software filter. This function updates the IpFilter
1744 field of the EFI_PXE_BASE_CODE_MODE structure with the contents of NewIpFilter.
1745 The software filter is used when the USE_FILTER in OpFlags is set to UdpRead().
1746 The current hardware filter remains in effect no matter what the settings of OpFlags
1747 are, so that the meaning of ANY_DEST_IP set in OpFlags to UdpRead() is from those
1748 packets whose reception is enabled in hardware-physical NIC address (unicast),
1749 broadcast address, logical address or addresses (multicast), or all (promiscuous).
1750 UdpRead() does not modify the IP filter settings.
1751 Dhcp(), Discover(), and Mtftp() set the IP filter, and return with the IP receive
1752 filter list emptied and the filter set to EFI_PXE_BASE_CODE_IP_FILTER_STATION_IP.
1753 If an application or driver wishes to preserve the IP receive filter settings,
1754 it will have to preserve the IP receive filter settings before these calls, and
1755 use SetIpFilter() to restore them after the calls. If incompatible filtering is
1756 requested (for example, PROMISCUOUS with anything else) or if the device does not
1757 support a requested filter setting and it cannot be accommodated in software
1758 (for example, PROMISCUOUS not supported), EFI_INVALID_PARAMETER will be returned.
1759 The IPlist field is used to enable IPs other than the StationIP. They may be
1760 multicast or unicast. If IPcnt is set as well as EFI_PXE_BASE_CODE_IP_FILTER_STATION_IP,
1761 then both the StationIP and the IPs from the IPlist will be used.
1763 @param This Pointer to the EFI_PXE_BASE_CODE_PROTOCOL instance.
1764 @param NewFilter Pointer to the new set of IP receive filters.
1766 @retval EFI_SUCCESS The IP receive filter settings were updated.
1767 @retval EFI_NOT_STARTED The PXE Base Code Protocol is in the stopped state.
1768 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
1773 EfiPxeBcSetIpFilter (
1774 IN EFI_PXE_BASE_CODE_PROTOCOL
*This
,
1775 IN EFI_PXE_BASE_CODE_IP_FILTER
*NewFilter
1779 PXEBC_PRIVATE_DATA
*Private
;
1780 EFI_PXE_BASE_CODE_MODE
*Mode
;
1782 BOOLEAN PromiscuousNeed
;
1785 DEBUG ((EFI_D_ERROR
, "BC *This pointer == NULL.\n"));
1786 return EFI_INVALID_PARAMETER
;
1789 Private
= PXEBC_PRIVATE_DATA_FROM_PXEBC (This
);
1790 Mode
= Private
->PxeBc
.Mode
;
1792 if (Private
== NULL
) {
1793 DEBUG ((EFI_D_ERROR
, "PXEBC_PRIVATE_DATA poiner == NULL.\n"));
1794 return EFI_INVALID_PARAMETER
;
1797 if (NewFilter
== NULL
) {
1798 DEBUG ((EFI_D_ERROR
, "IP Filter *NewFilter == NULL.\n"));
1799 return EFI_INVALID_PARAMETER
;
1802 if (!Mode
->Started
) {
1803 DEBUG ((EFI_D_ERROR
, "BC was not started.\n"));
1804 return EFI_NOT_STARTED
;
1807 PromiscuousNeed
= FALSE
;
1808 for (Index
= 0; Index
< NewFilter
->IpCnt
; ++Index
) {
1809 if (IP4_IS_LOCAL_BROADCAST (EFI_IP4 (NewFilter
->IpList
[Index
].v4
))) {
1811 // The IP is a broadcast address.
1813 DEBUG ((EFI_D_ERROR
, "There is broadcast address in NewFilter.\n"));
1814 return EFI_INVALID_PARAMETER
;
1816 if (Ip4IsUnicast (EFI_IP4 (NewFilter
->IpList
[Index
].v4
), 0) &&
1817 (NewFilter
->Filters
& EFI_PXE_BASE_CODE_IP_FILTER_STATION_IP
)
1820 // If EFI_PXE_BASE_CODE_IP_FILTER_STATION_IP is set and IP4 address is in IpList,
1821 // promiscuous mode is needed.
1823 PromiscuousNeed
= TRUE
;
1828 // Clear the UDP instance configuration, all joined groups will be left
1829 // during the operation.
1831 Private
->Udp4Read
->Configure (Private
->Udp4Read
, NULL
);
1832 Private
->Udp4CfgData
.AcceptPromiscuous
= FALSE
;
1833 Private
->Udp4CfgData
.AcceptBroadcast
= FALSE
;
1835 if (PromiscuousNeed
||
1836 NewFilter
->Filters
& EFI_PXE_BASE_CODE_IP_FILTER_PROMISCUOUS
||
1837 NewFilter
->Filters
& EFI_PXE_BASE_CODE_IP_FILTER_PROMISCUOUS_MULTICAST
1840 // Configure the udp4 filter to receive all packages
1842 Private
->Udp4CfgData
.AcceptPromiscuous
= TRUE
;
1845 // Configure the UDP instance with the new configuration.
1847 Status
= Private
->Udp4Read
->Configure (Private
->Udp4Read
, &Private
->Udp4CfgData
);
1848 if (EFI_ERROR (Status
)) {
1854 if (NewFilter
->Filters
& EFI_PXE_BASE_CODE_IP_FILTER_BROADCAST
) {
1856 // Configure the udp4 filter to receive all broadcast packages
1858 Private
->Udp4CfgData
.AcceptBroadcast
= TRUE
;
1862 // Configure the UDP instance with the new configuration.
1864 Status
= Private
->Udp4Read
->Configure (Private
->Udp4Read
, &Private
->Udp4CfgData
);
1865 if (EFI_ERROR (Status
)) {
1869 if (NewFilter
->Filters
& EFI_PXE_BASE_CODE_IP_FILTER_STATION_IP
) {
1871 for (Index
= 0; Index
< NewFilter
->IpCnt
; ++Index
) {
1872 if (IP4_IS_MULTICAST (EFI_NTOHL (NewFilter
->IpList
[Index
].v4
))) {
1874 // Join the mutilcast group
1876 Status
= Private
->Udp4Read
->Groups (Private
->Udp4Read
, TRUE
, &NewFilter
->IpList
[Index
].v4
);
1877 if (EFI_ERROR (Status
)) {
1887 // Save the new filter.
1889 CopyMem (&Mode
->IpFilter
, NewFilter
, sizeof (Mode
->IpFilter
));
1896 Uses the ARP protocol to resolve a MAC address.
1898 This function uses the ARP protocol to resolve a MAC address. The UsingIpv6 field
1899 of the EFI_PXE_BASE_CODE_MODE structure is used to determine if IPv4 or IPv6
1900 addresses are being used. The IP address specified by IpAddr is used to resolve
1901 a MAC address. If the ARP protocol succeeds in resolving the specified address,
1902 then the ArpCacheEntries and ArpCache fields of the EFI_PXE_BASE_CODE_MODE structure
1903 are updated, and EFI_SUCCESS is returned. If MacAddr is not NULL, the resolved
1904 MAC address is placed there as well. If the PXE Base Code protocol is in the
1905 stopped state, then EFI_NOT_STARTED is returned. If the ARP protocol encounters
1906 a timeout condition while attempting to resolve an address, then EFI_TIMEOUT is
1907 returned. If the Callback Protocol does not return EFI_PXE_BASE_CODE_CALLBACK_STATUS_CONTINUE,
1908 then EFI_ABORTED is returned.
1910 @param This Pointer to the EFI_PXE_BASE_CODE_PROTOCOL instance.
1911 @param IpAddr Pointer to the IP address that is used to resolve a MAC address.
1912 @param MacAddr If not NULL, a pointer to the MAC address that was resolved with the
1915 @retval EFI_SUCCESS The IP or MAC address was resolved.
1916 @retval EFI_NOT_STARTED The PXE Base Code Protocol is in the stopped state.
1917 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
1918 @retval EFI_DEVICE_ERROR The network device encountered an error during this operation.
1919 @retval EFI_ICMP_ERROR Something error occur with the ICMP packet message.
1925 IN EFI_PXE_BASE_CODE_PROTOCOL
* This
,
1926 IN EFI_IP_ADDRESS
* IpAddr
,
1927 IN EFI_MAC_ADDRESS
* MacAddr OPTIONAL
1930 PXEBC_PRIVATE_DATA
*Private
;
1931 EFI_PXE_BASE_CODE_MODE
*Mode
;
1933 EFI_MAC_ADDRESS TempMacAddr
;
1935 if (This
== NULL
|| IpAddr
== NULL
) {
1936 return EFI_INVALID_PARAMETER
;
1939 Private
= PXEBC_PRIVATE_DATA_FROM_PXEBC (This
);
1940 Mode
= Private
->PxeBc
.Mode
;
1942 if (!Mode
->Started
) {
1943 return EFI_NOT_STARTED
;
1946 if (!Private
->AddressIsOk
|| Mode
->UsingIpv6
) {
1948 // We can't resolve the IP address if we don't have a local address now.
1949 // Don't have ARP for IPv6.
1951 return EFI_INVALID_PARAMETER
;
1954 Mode
->IcmpErrorReceived
= FALSE
;
1956 if (!Mode
->AutoArp
) {
1958 // If AutoArp is set false, check arp cache
1960 UpdateArpCache (This
);
1961 if (!FindInArpCache (Mode
, &IpAddr
->v4
, &TempMacAddr
)) {
1962 return EFI_DEVICE_ERROR
;
1965 Status
= Private
->Arp
->Request (Private
->Arp
, &IpAddr
->v4
, NULL
, &TempMacAddr
);
1966 if (EFI_ERROR (Status
)) {
1967 if (Status
== EFI_ICMP_ERROR
) {
1968 Mode
->IcmpErrorReceived
= TRUE
;
1974 if (MacAddr
!= NULL
) {
1975 CopyMem (MacAddr
, &TempMacAddr
, sizeof (EFI_MAC_ADDRESS
));
1982 Updates the parameters that affect the operation of the PXE Base Code Protocol.
1984 This function sets parameters that affect the operation of the PXE Base Code Protocol.
1985 The parameter specified by NewAutoArp is used to control the generation of ARP
1986 protocol packets. If NewAutoArp is TRUE, then ARP Protocol packets will be generated
1987 as required by the PXE Base Code Protocol. If NewAutoArp is FALSE, then no ARP
1988 Protocol packets will be generated. In this case, the only mappings that are
1989 available are those stored in the ArpCache of the EFI_PXE_BASE_CODE_MODE structure.
1990 If there are not enough mappings in the ArpCache to perform a PXE Base Code Protocol
1991 service, then the service will fail. This function updates the AutoArp field of
1992 the EFI_PXE_BASE_CODE_MODE structure to NewAutoArp.
1993 The SetParameters() call must be invoked after a Callback Protocol is installed
1994 to enable the use of callbacks.
1996 @param This Pointer to the EFI_PXE_BASE_CODE_PROTOCOL instance.
1997 @param NewAutoArp If not NULL, a pointer to a value that specifies whether to replace the
1998 current value of AutoARP.
1999 @param NewSendGUID If not NULL, a pointer to a value that specifies whether to replace the
2000 current value of SendGUID.
2001 @param NewTTL If not NULL, a pointer to be used in place of the current value of TTL,
2002 the "time to live" field of the IP header.
2003 @param NewToS If not NULL, a pointer to be used in place of the current value of ToS,
2004 the "type of service" field of the IP header.
2005 @param NewMakeCallback If not NULL, a pointer to a value that specifies whether to replace the
2006 current value of the MakeCallback field of the Mode structure.
2008 @retval EFI_SUCCESS The new parameters values were updated.
2009 @retval EFI_NOT_STARTED The PXE Base Code Protocol is in the stopped state.
2010 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
2015 EfiPxeBcSetParameters (
2016 IN EFI_PXE_BASE_CODE_PROTOCOL
*This
,
2017 IN BOOLEAN
*NewAutoArp OPTIONAL
,
2018 IN BOOLEAN
*NewSendGUID OPTIONAL
,
2019 IN UINT8
*NewTTL OPTIONAL
,
2020 IN UINT8
*NewToS OPTIONAL
,
2021 IN BOOLEAN
*NewMakeCallback
// OPTIONAL
2024 PXEBC_PRIVATE_DATA
*Private
;
2025 EFI_PXE_BASE_CODE_MODE
*Mode
;
2028 Status
= EFI_SUCCESS
;
2031 Status
= EFI_INVALID_PARAMETER
;
2035 Private
= PXEBC_PRIVATE_DATA_FROM_PXEBC (This
);
2036 Mode
= Private
->PxeBc
.Mode
;
2038 if (NewSendGUID
!= NULL
&& *NewSendGUID
) {
2040 // FixMe, cann't locate SendGuid
2044 if (NewMakeCallback
!= NULL
&& *NewMakeCallback
) {
2046 Status
= gBS
->HandleProtocol (
2047 Private
->Controller
,
2048 &gEfiPxeBaseCodeCallbackProtocolGuid
,
2049 (VOID
**) &Private
->PxeBcCallback
2051 if (EFI_ERROR (Status
) || (Private
->PxeBcCallback
->Callback
== NULL
)) {
2053 Status
= EFI_INVALID_PARAMETER
;
2058 if (!Mode
->Started
) {
2059 Status
= EFI_NOT_STARTED
;
2063 if (NewMakeCallback
!= NULL
) {
2065 if (*NewMakeCallback
) {
2067 // Update the Callback protocol.
2069 Status
= gBS
->HandleProtocol (
2070 Private
->Controller
,
2071 &gEfiPxeBaseCodeCallbackProtocolGuid
,
2072 (VOID
**) &Private
->PxeBcCallback
2075 if (EFI_ERROR (Status
) || (Private
->PxeBcCallback
->Callback
== NULL
)) {
2076 Status
= EFI_INVALID_PARAMETER
;
2080 Private
->PxeBcCallback
= NULL
;
2083 Mode
->MakeCallbacks
= *NewMakeCallback
;
2086 if (NewAutoArp
!= NULL
) {
2087 Mode
->AutoArp
= *NewAutoArp
;
2090 if (NewSendGUID
!= NULL
) {
2091 Mode
->SendGUID
= *NewSendGUID
;
2094 if (NewTTL
!= NULL
) {
2095 Mode
->TTL
= *NewTTL
;
2098 if (NewToS
!= NULL
) {
2099 Mode
->ToS
= *NewToS
;
2107 Updates the station IP address and/or subnet mask values of a network device.
2109 This function updates the station IP address and/or subnet mask values of a network
2110 device. The NewStationIp field is used to modify the network device's current IP address.
2111 If NewStationIP is NULL, then the current IP address will not be modified. Otherwise,
2112 this function updates the StationIp field of the EFI_PXE_BASE_CODE_MODE structure
2113 with NewStationIp. The NewSubnetMask field is used to modify the network device's current subnet
2114 mask. If NewSubnetMask is NULL, then the current subnet mask will not be modified.
2115 Otherwise, this function updates the SubnetMask field of the EFI_PXE_BASE_CODE_MODE
2116 structure with NewSubnetMask.
2118 @param This Pointer to the EFI_PXE_BASE_CODE_PROTOCOL instance.
2119 @param NewStationIp Pointer to the new IP address to be used by the network device.
2120 @param NewSubnetMask Pointer to the new subnet mask to be used by the network device.
2122 @retval EFI_SUCCESS The new station IP address and/or subnet mask were updated.
2123 @retval EFI_NOT_STARTED The PXE Base Code Protocol is in the stopped state.
2124 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
2129 EfiPxeBcSetStationIP (
2130 IN EFI_PXE_BASE_CODE_PROTOCOL
* This
,
2131 IN EFI_IP_ADDRESS
* NewStationIp OPTIONAL
,
2132 IN EFI_IP_ADDRESS
* NewSubnetMask OPTIONAL
2135 PXEBC_PRIVATE_DATA
*Private
;
2136 EFI_PXE_BASE_CODE_MODE
*Mode
;
2137 EFI_ARP_CONFIG_DATA ArpConfigData
;
2140 return EFI_INVALID_PARAMETER
;
2143 if (NewStationIp
!= NULL
&& !Ip4IsUnicast (NTOHL (NewStationIp
->Addr
[0]), 0)) {
2144 return EFI_INVALID_PARAMETER
;
2147 if (NewSubnetMask
!= NULL
&& !IP4_IS_VALID_NETMASK (NTOHL (NewSubnetMask
->Addr
[0]))) {
2148 return EFI_INVALID_PARAMETER
;
2151 Private
= PXEBC_PRIVATE_DATA_FROM_PXEBC (This
);
2152 Mode
= Private
->PxeBc
.Mode
;
2154 if (!Mode
->Started
) {
2155 return EFI_NOT_STARTED
;
2158 if (NewStationIp
!= NULL
) {
2159 CopyMem (&Mode
->StationIp
, NewStationIp
, sizeof (EFI_IP_ADDRESS
));
2160 CopyMem (&Private
->StationIp
, NewStationIp
, sizeof (EFI_IP_ADDRESS
));
2163 if (NewSubnetMask
!= NULL
) {
2164 CopyMem (&Mode
->SubnetMask
, NewSubnetMask
, sizeof (EFI_IP_ADDRESS
));
2165 CopyMem (&Private
->SubnetMask
,NewSubnetMask
, sizeof (EFI_IP_ADDRESS
));
2168 Private
->AddressIsOk
= TRUE
;
2170 if (!Mode
->UsingIpv6
) {
2172 // If in IPv4 mode, configure the corresponding ARP with this new
2173 // station IP address.
2175 ZeroMem (&ArpConfigData
, sizeof (EFI_ARP_CONFIG_DATA
));
2177 ArpConfigData
.SwAddressType
= 0x0800;
2178 ArpConfigData
.SwAddressLength
= sizeof (EFI_IPv4_ADDRESS
);
2179 ArpConfigData
.StationAddress
= &Private
->StationIp
.v4
;
2181 Private
->Arp
->Configure (Private
->Arp
, NULL
);
2182 Private
->Arp
->Configure (Private
->Arp
, &ArpConfigData
);
2185 // Update the route table.
2187 Mode
->RouteTableEntries
= 1;
2188 Mode
->RouteTable
[0].IpAddr
.Addr
[0] = Private
->StationIp
.Addr
[0] & Private
->SubnetMask
.Addr
[0];
2189 Mode
->RouteTable
[0].SubnetMask
.Addr
[0] = Private
->SubnetMask
.Addr
[0];
2190 Mode
->RouteTable
[0].GwAddr
.Addr
[0] = 0;
2197 Updates the contents of the cached DHCP and Discover packets.
2199 The pointers to the new packets are used to update the contents of the cached
2200 packets in the EFI_PXE_BASE_CODE_MODE structure.
2202 @param This Pointer to the EFI_PXE_BASE_CODE_PROTOCOL instance.
2203 @param NewDhcpDiscoverValid Pointer to a value that will replace the current
2204 DhcpDiscoverValid field.
2205 @param NewDhcpAckReceived Pointer to a value that will replace the current
2206 DhcpAckReceived field.
2207 @param NewProxyOfferReceived Pointer to a value that will replace the current
2208 ProxyOfferReceived field.
2209 @param NewPxeDiscoverValid Pointer to a value that will replace the current
2210 ProxyOfferReceived field.
2211 @param NewPxeReplyReceived Pointer to a value that will replace the current
2212 PxeReplyReceived field.
2213 @param NewPxeBisReplyReceived Pointer to a value that will replace the current
2214 PxeBisReplyReceived field.
2215 @param NewDhcpDiscover Pointer to the new cached DHCP Discover packet contents.
2216 @param NewDhcpAck Pointer to the new cached DHCP Ack packet contents.
2217 @param NewProxyOffer Pointer to the new cached Proxy Offer packet contents.
2218 @param NewPxeDiscover Pointer to the new cached PXE Discover packet contents.
2219 @param NewPxeReply Pointer to the new cached PXE Reply packet contents.
2220 @param NewPxeBisReply Pointer to the new cached PXE BIS Reply packet contents.
2222 @retval EFI_SUCCESS The cached packet contents were updated.
2223 @retval EFI_NOT_STARTED The PXE Base Code Protocol is in the stopped state.
2224 @retval EFI_INVALID_PARAMETER This is NULL or not point to a valid EFI_PXE_BASE_CODE_PROTOCOL structure.
2229 EfiPxeBcSetPackets (
2230 IN EFI_PXE_BASE_CODE_PROTOCOL
* This
,
2231 IN BOOLEAN
* NewDhcpDiscoverValid OPTIONAL
,
2232 IN BOOLEAN
* NewDhcpAckReceived OPTIONAL
,
2233 IN BOOLEAN
* NewProxyOfferReceived OPTIONAL
,
2234 IN BOOLEAN
* NewPxeDiscoverValid OPTIONAL
,
2235 IN BOOLEAN
* NewPxeReplyReceived OPTIONAL
,
2236 IN BOOLEAN
* NewPxeBisReplyReceived OPTIONAL
,
2237 IN EFI_PXE_BASE_CODE_PACKET
* NewDhcpDiscover OPTIONAL
,
2238 IN EFI_PXE_BASE_CODE_PACKET
* NewDhcpAck OPTIONAL
,
2239 IN EFI_PXE_BASE_CODE_PACKET
* NewProxyOffer OPTIONAL
,
2240 IN EFI_PXE_BASE_CODE_PACKET
* NewPxeDiscover OPTIONAL
,
2241 IN EFI_PXE_BASE_CODE_PACKET
* NewPxeReply OPTIONAL
,
2242 IN EFI_PXE_BASE_CODE_PACKET
* NewPxeBisReply OPTIONAL
2245 PXEBC_PRIVATE_DATA
*Private
;
2246 EFI_PXE_BASE_CODE_MODE
*Mode
;
2249 return EFI_INVALID_PARAMETER
;
2252 Private
= PXEBC_PRIVATE_DATA_FROM_PXEBC (This
);
2253 Mode
= Private
->PxeBc
.Mode
;
2255 if (!Mode
->Started
) {
2256 return EFI_NOT_STARTED
;
2259 Private
->FileSize
= 0;
2261 if (NewDhcpDiscoverValid
!= NULL
) {
2262 Mode
->DhcpDiscoverValid
= *NewDhcpDiscoverValid
;
2265 if (NewDhcpAckReceived
!= NULL
) {
2266 Mode
->DhcpAckReceived
= *NewDhcpAckReceived
;
2269 if (NewProxyOfferReceived
!= NULL
) {
2270 Mode
->ProxyOfferReceived
= *NewProxyOfferReceived
;
2273 if (NewPxeDiscoverValid
!= NULL
) {
2274 Mode
->PxeDiscoverValid
= *NewPxeDiscoverValid
;
2277 if (NewPxeReplyReceived
!= NULL
) {
2278 Mode
->PxeReplyReceived
= *NewPxeReplyReceived
;
2281 if (NewPxeBisReplyReceived
!= NULL
) {
2282 Mode
->PxeBisReplyReceived
= *NewPxeBisReplyReceived
;
2285 if (NewDhcpDiscover
!= NULL
) {
2286 CopyMem (&Mode
->DhcpDiscover
, NewDhcpDiscover
, sizeof (EFI_PXE_BASE_CODE_PACKET
));
2289 if (NewDhcpAck
!= NULL
) {
2290 CopyMem (&Mode
->DhcpAck
, NewDhcpAck
, sizeof (EFI_PXE_BASE_CODE_PACKET
));
2293 if (NewProxyOffer
!= NULL
) {
2294 CopyMem (&Mode
->ProxyOffer
, NewProxyOffer
, sizeof (EFI_PXE_BASE_CODE_PACKET
));
2297 if (NewPxeDiscover
!= NULL
) {
2298 CopyMem (&Mode
->PxeDiscover
, NewPxeDiscover
, sizeof (EFI_PXE_BASE_CODE_PACKET
));
2301 if (NewPxeReply
!= NULL
) {
2302 CopyMem (&Mode
->PxeReply
, NewPxeReply
, sizeof (EFI_PXE_BASE_CODE_PACKET
));
2305 if (NewPxeBisReply
!= NULL
) {
2306 CopyMem (&Mode
->PxeBisReply
, NewPxeBisReply
, sizeof (EFI_PXE_BASE_CODE_PACKET
));
2312 EFI_PXE_BASE_CODE_PROTOCOL mPxeBcProtocolTemplate
= {
2313 EFI_PXE_BASE_CODE_PROTOCOL_REVISION
,
2321 EfiPxeBcSetIpFilter
,
2323 EfiPxeBcSetParameters
,
2324 EfiPxeBcSetStationIP
,
2330 Callback function that is invoked when the PXE Base Code Protocol is about to transmit, has
2331 received, or is waiting to receive a packet.
2333 This function is invoked when the PXE Base Code Protocol is about to transmit, has received,
2334 or is waiting to receive a packet. Parameters Function and Received specify the type of event.
2335 Parameters PacketLen and Packet specify the packet that generated the event. If these fields
2336 are zero and NULL respectively, then this is a status update callback. If the operation specified
2337 by Function is to continue, then CALLBACK_STATUS_CONTINUE should be returned. If the operation
2338 specified by Function should be aborted, then CALLBACK_STATUS_ABORT should be returned. Due to
2339 the polling nature of UEFI device drivers, a callback function should not execute for more than 5 ms.
2340 The SetParameters() function must be called after a Callback Protocol is installed to enable the
2343 @param This Pointer to the EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL instance.
2344 @param Function The PXE Base Code Protocol function that is waiting for an event.
2345 @param Received TRUE if the callback is being invoked due to a receive event. FALSE if
2346 the callback is being invoked due to a transmit event.
2347 @param PacketLength The length, in bytes, of Packet. This field will have a value of zero if
2348 this is a wait for receive event.
2349 @param PacketPtr If Received is TRUE, a pointer to the packet that was just received;
2350 otherwise a pointer to the packet that is about to be transmitted.
2352 @retval EFI_PXE_BASE_CODE_CALLBACK_STATUS_CONTINUE if Function specifies a continue operation
2353 @retval EFI_PXE_BASE_CODE_CALLBACK_STATUS_ABORT if Function specifies an abort operation
2356 EFI_PXE_BASE_CODE_CALLBACK_STATUS
2358 EfiPxeLoadFileCallback (
2359 IN EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL
* This
,
2360 IN EFI_PXE_BASE_CODE_FUNCTION Function
,
2361 IN BOOLEAN Received
,
2362 IN UINT32 PacketLength
,
2363 IN EFI_PXE_BASE_CODE_PACKET
* PacketPtr OPTIONAL
2370 // Catch Ctrl-C or ESC to abort.
2372 Status
= gST
->ConIn
->ReadKeyStroke (gST
->ConIn
, &Key
);
2374 if (!EFI_ERROR (Status
)) {
2376 if (Key
.ScanCode
== SCAN_ESC
|| Key
.UnicodeChar
== (0x1F & 'c')) {
2378 return EFI_PXE_BASE_CODE_CALLBACK_STATUS_ABORT
;
2382 // No print if receive packet
2385 return EFI_PXE_BASE_CODE_CALLBACK_STATUS_CONTINUE
;
2388 // Print only for three functions
2392 case EFI_PXE_BASE_CODE_FUNCTION_MTFTP
:
2394 // Print only for open MTFTP packets, not every MTFTP packets
2396 if (PacketLength
!= 0 && PacketPtr
!= NULL
) {
2397 if (PacketPtr
->Raw
[0x1C] != 0x00 || PacketPtr
->Raw
[0x1D] != 0x01) {
2398 return EFI_PXE_BASE_CODE_CALLBACK_STATUS_CONTINUE
;
2403 case EFI_PXE_BASE_CODE_FUNCTION_DHCP
:
2404 case EFI_PXE_BASE_CODE_FUNCTION_DISCOVER
:
2408 return EFI_PXE_BASE_CODE_CALLBACK_STATUS_CONTINUE
;
2411 if (PacketLength
!= 0 && PacketPtr
!= NULL
) {
2413 // Print '.' when transmit a packet
2419 return EFI_PXE_BASE_CODE_CALLBACK_STATUS_CONTINUE
;
2422 EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL mPxeBcCallBackTemplate
= {
2423 EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL_REVISION
,
2424 EfiPxeLoadFileCallback
2431 @param Private Pointer to PxeBc private data.
2432 @param BufferSize Pointer to buffer size.
2433 @param Buffer Pointer to buffer.
2435 @retval EFI_SUCCESS Discover the boot file successfully.
2436 @retval EFI_TIMEOUT The TFTP/MTFTP operation timed out.
2437 @retval EFI_ABORTED PXE bootstrap server, so local boot need abort.
2438 @retval EFI_BUFFER_TOO_SMALL The buffer is too small to load the boot file.
2443 IN PXEBC_PRIVATE_DATA
*Private
,
2444 IN OUT UINT64
*BufferSize
,
2448 EFI_PXE_BASE_CODE_PROTOCOL
*PxeBc
;
2449 EFI_PXE_BASE_CODE_MODE
*Mode
;
2455 PXEBC_CACHED_DHCP4_PACKET
*Packet
;
2458 PxeBc
= &Private
->PxeBc
;
2460 Type
= EFI_PXE_BASE_CODE_BOOT_TYPE_BOOTSTRAP
;
2461 Layer
= EFI_PXE_BASE_CODE_BOOT_LAYER_INITIAL
;
2466 Status
= PxeBc
->Dhcp (PxeBc
, TRUE
);
2467 if (EFI_ERROR (Status
)) {
2472 // Select a boot server
2474 Status
= PxeBcSelectBootPrompt (Private
);
2476 if (Status
== EFI_SUCCESS
) {
2477 Status
= PxeBcSelectBootMenu (Private
, &Type
, TRUE
);
2478 } else if (Status
== EFI_TIMEOUT
) {
2479 Status
= PxeBcSelectBootMenu (Private
, &Type
, FALSE
);
2482 if (!EFI_ERROR (Status
)) {
2484 if (Type
== EFI_PXE_BASE_CODE_BOOT_TYPE_BOOTSTRAP
) {
2486 // Local boot(PXE bootstrap server) need abort
2491 UseBis
= (BOOLEAN
) (Mode
->BisSupported
&& Mode
->BisDetected
);
2492 Status
= PxeBc
->Discover (PxeBc
, Type
, &Layer
, UseBis
, NULL
);
2493 if (EFI_ERROR (Status
)) {
2502 // Get bootfile name and (m)tftp server ip addresss
2504 if (Mode
->PxeReplyReceived
) {
2505 Packet
= &Private
->PxeReply
;
2506 } else if (Mode
->ProxyOfferReceived
) {
2507 Packet
= &Private
->ProxyOffer
;
2509 Packet
= &Private
->Dhcp4Ack
;
2512 CopyMem (&Private
->ServerIp
, &Packet
->Packet
.Offer
.Dhcp4
.Header
.ServerAddr
, sizeof (EFI_IPv4_ADDRESS
));
2513 if (Private
->ServerIp
.Addr
[0] == 0) {
2515 // next server ip address is zero, use option 54 instead
2519 Packet
->Dhcp4Option
[PXEBC_DHCP4_TAG_INDEX_SERVER_ID
]->Data
,
2520 sizeof (EFI_IPv4_ADDRESS
)
2524 ASSERT (Packet
->Dhcp4Option
[PXEBC_DHCP4_TAG_INDEX_BOOTFILE
] != NULL
);
2529 Private
->BootFileName
= (CHAR8
*) (Packet
->Dhcp4Option
[PXEBC_DHCP4_TAG_INDEX_BOOTFILE
]->Data
);
2531 if (Packet
->Dhcp4Option
[PXEBC_DHCP4_TAG_INDEX_BOOTFILE_LEN
] != NULL
) {
2533 // Already have the bootfile length option, compute the file size
2535 CopyMem (&Value
, Packet
->Dhcp4Option
[PXEBC_DHCP4_TAG_INDEX_BOOTFILE_LEN
]->Data
, sizeof (Value
));
2536 Value
= NTOHS (Value
);
2537 *BufferSize
= 512 * Value
;
2538 Status
= EFI_BUFFER_TOO_SMALL
;
2541 // Get the bootfile size from tftp
2543 Status
= PxeBc
->Mtftp (
2545 EFI_PXE_BASE_CODE_TFTP_GET_FILE_SIZE
,
2551 (UINT8
*) Private
->BootFileName
,
2557 Private
->FileSize
= (UINTN
) *BufferSize
;
2563 Causes the driver to load a specified file.
2565 @param This Protocol instance pointer.
2566 @param FilePath The device specific path of the file to load.
2567 @param BootPolicy If TRUE, indicates that the request originates from the
2568 boot manager is attempting to load FilePath as a boot
2569 selection. If FALSE, then FilePath must match as exact file
2571 @param BufferSize On input the size of Buffer in bytes. On output with a return
2572 code of EFI_SUCCESS, the amount of data transferred to
2573 Buffer. On output with a return code of EFI_BUFFER_TOO_SMALL,
2574 the size of Buffer required to retrieve the requested file.
2575 @param Buffer The memory buffer to transfer the file to. IF Buffer is NULL,
2576 then no the size of the requested file is returned in
2579 @retval EFI_SUCCESS The file was loaded.
2580 @retval EFI_UNSUPPORTED The device does not support the provided BootPolicy
2581 @retval EFI_INVALID_PARAMETER FilePath is not a valid device path, or
2583 @retval EFI_NO_MEDIA No medium was present to load the file.
2584 @retval EFI_DEVICE_ERROR The file was not loaded due to a device error.
2585 @retval EFI_NO_RESPONSE The remote system did not respond.
2586 @retval EFI_NOT_FOUND The file was not found.
2587 @retval EFI_ABORTED The file load process was manually cancelled.
2593 IN EFI_LOAD_FILE_PROTOCOL
* This
,
2594 IN EFI_DEVICE_PATH_PROTOCOL
* FilePath
,
2595 IN BOOLEAN BootPolicy
,
2596 IN OUT UINTN
*BufferSize
,
2597 IN VOID
*Buffer OPTIONAL
2600 PXEBC_PRIVATE_DATA
*Private
;
2601 EFI_PXE_BASE_CODE_PROTOCOL
*PxeBc
;
2602 BOOLEAN NewMakeCallback
;
2607 Private
= PXEBC_PRIVATE_DATA_FROM_LOADFILE (This
);
2608 PxeBc
= &Private
->PxeBc
;
2609 NewMakeCallback
= FALSE
;
2611 Status
= EFI_DEVICE_ERROR
;
2613 if (This
== NULL
|| BufferSize
== NULL
) {
2615 return EFI_INVALID_PARAMETER
;
2619 // Only support BootPolicy
2622 return EFI_UNSUPPORTED
;
2625 Status
= PxeBc
->Start (PxeBc
, FALSE
);
2626 if (EFI_ERROR (Status
) && (Status
!= EFI_ALREADY_STARTED
)) {
2630 Status
= gBS
->HandleProtocol (
2631 Private
->Controller
,
2632 &gEfiPxeBaseCodeCallbackProtocolGuid
,
2633 (VOID
**) &Private
->PxeBcCallback
2635 if (Status
== EFI_UNSUPPORTED
) {
2637 CopyMem (&Private
->LoadFileCallback
, &mPxeBcCallBackTemplate
, sizeof (Private
->LoadFileCallback
));
2639 Status
= gBS
->InstallProtocolInterface (
2640 &Private
->Controller
,
2641 &gEfiPxeBaseCodeCallbackProtocolGuid
,
2642 EFI_NATIVE_INTERFACE
,
2643 &Private
->LoadFileCallback
2646 NewMakeCallback
= (BOOLEAN
) (Status
== EFI_SUCCESS
);
2648 Status
= PxeBc
->SetParameters (PxeBc
, NULL
, NULL
, NULL
, NULL
, &NewMakeCallback
);
2649 if (EFI_ERROR (Status
)) {
2650 PxeBc
->Stop (PxeBc
);
2655 if (Private
->FileSize
== 0) {
2657 Status
= DiscoverBootFile (Private
, &TmpBufSize
, Buffer
);
2659 if (sizeof (UINTN
) < sizeof (UINT64
) && (TmpBufSize
> 0xFFFFFFFF)) {
2660 Status
= EFI_DEVICE_ERROR
;
2662 *BufferSize
= (UINTN
) TmpBufSize
;
2664 } else if (Buffer
== NULL
) {
2665 *BufferSize
= Private
->FileSize
;
2666 Status
= EFI_BUFFER_TOO_SMALL
;
2669 // Download the file.
2671 TmpBufSize
= (UINT64
) (*BufferSize
);
2672 Status
= PxeBc
->Mtftp (
2674 EFI_PXE_BASE_CODE_TFTP_READ_FILE
,
2680 (UINT8
*) Private
->BootFileName
,
2686 // If we added a callback protocol, now is the time to remove it.
2688 if (NewMakeCallback
) {
2690 NewMakeCallback
= FALSE
;
2692 PxeBc
->SetParameters (PxeBc
, NULL
, NULL
, NULL
, NULL
, &NewMakeCallback
);
2694 gBS
->UninstallProtocolInterface (
2695 Private
->Controller
,
2696 &gEfiPxeBaseCodeCallbackProtocolGuid
,
2697 &Private
->LoadFileCallback
2702 // Check download status
2704 if (Status
== EFI_SUCCESS
) {
2707 } else if (Status
== EFI_BUFFER_TOO_SMALL
) {
2708 if (Buffer
!= NULL
) {
2709 AsciiPrint ("PXE-E05: Download buffer is smaller than requested file.\n");
2714 } else if (Status
== EFI_DEVICE_ERROR
) {
2715 AsciiPrint ("PXE-E07: Network device error.\n");
2717 } else if (Status
== EFI_OUT_OF_RESOURCES
) {
2718 AsciiPrint ("PXE-E09: Could not allocate I/O buffers.\n");
2720 } else if (Status
== EFI_NO_MEDIA
) {
2721 AsciiPrint ("PXE-E12: Could not detect network connection.\n");
2723 } else if (Status
== EFI_NO_RESPONSE
) {
2724 AsciiPrint ("PXE-E16: No offer received.\n");
2726 } else if (Status
== EFI_TIMEOUT
) {
2727 AsciiPrint ("PXE-E18: Server response timeout.\n");
2729 } else if (Status
== EFI_ABORTED
) {
2730 AsciiPrint ("PXE-E21: Remote boot cancelled.\n");
2732 } else if (Status
== EFI_ICMP_ERROR
) {
2733 AsciiPrint ("PXE-E22: Client received ICMP error from server.\n");
2735 } else if (Status
== EFI_TFTP_ERROR
) {
2736 AsciiPrint ("PXE-E23: Client received TFTP error from server.\n");
2739 AsciiPrint ("PXE-E99: Unexpected network error.\n");
2742 PxeBc
->Stop (PxeBc
);