]>
Commit | Line | Data |
---|---|---|
dc361cc5 | 1 | /** @file\r |
f737cfb9 | 2 | Interface routines for PxeBc.\r |
e2851998 | 3 | \r |
416211e0 | 4 | Copyright (c) 2007 - 2013, Intel Corporation. All rights reserved.<BR>\r |
e5eed7d3 | 5 | This program and the accompanying materials\r |
dc361cc5 | 6 | are licensed and made available under the terms and conditions of the BSD License\r |
7 | which accompanies this distribution. The full text of the license may be found at\r | |
8 | http://opensource.org/licenses/bsd-license.php\r | |
9 | \r | |
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
12 | \r | |
dc361cc5 | 13 | **/\r |
14 | \r | |
15 | \r | |
16 | #include "PxeBcImpl.h"\r | |
17 | \r | |
434ce3fe | 18 | UINT32 mPxeDhcpTimeout[4] = { 4, 8, 16, 32 };\r |
f737cfb9 | 19 | \r |
982a9eae | 20 | /**\r |
f737cfb9 | 21 | Get and record the arp cache.\r |
982a9eae | 22 | \r |
23 | @param This Pointer to EFI_PXE_BC_PROTOCOL\r | |
24 | \r | |
25 | @retval EFI_SUCCESS Arp cache updated successfully\r | |
f737cfb9 | 26 | @retval others If error occurs when getting arp cache\r |
982a9eae | 27 | \r |
28 | **/\r | |
982a9eae | 29 | EFI_STATUS\r |
30 | UpdateArpCache (\r | |
31 | IN EFI_PXE_BASE_CODE_PROTOCOL * This\r | |
32 | )\r | |
33 | {\r | |
34 | PXEBC_PRIVATE_DATA *Private;\r | |
35 | EFI_PXE_BASE_CODE_MODE *Mode;\r | |
36 | EFI_STATUS Status;\r | |
37 | UINT32 EntryLength;\r | |
38 | UINT32 EntryCount;\r | |
39 | EFI_ARP_FIND_DATA *Entries;\r | |
40 | UINT32 Index;\r | |
41 | \r | |
42 | Private = PXEBC_PRIVATE_DATA_FROM_PXEBC (This);\r | |
43 | Mode = Private->PxeBc.Mode;\r | |
44 | \r | |
f737cfb9 | 45 | Status = Private->Arp->Find (\r |
46 | Private->Arp,\r | |
47 | TRUE,\r | |
48 | NULL,\r | |
49 | &EntryLength,\r | |
50 | &EntryCount,\r | |
51 | &Entries,\r | |
52 | TRUE\r | |
53 | );\r | |
982a9eae | 54 | if (EFI_ERROR (Status)) {\r |
55 | return Status;\r | |
56 | }\r | |
57 | \r | |
f737cfb9 | 58 | Mode->ArpCacheEntries = MIN (\r |
59 | EntryCount,\r | |
60 | EFI_PXE_BASE_CODE_MAX_ARP_ENTRIES\r | |
61 | );\r | |
982a9eae | 62 | for (Index = 0; Index < Mode->ArpCacheEntries; Index ++) {\r |
f737cfb9 | 63 | CopyMem (\r |
e2851998 | 64 | &Mode->ArpCache[Index].IpAddr,\r |
65 | Entries + 1,\r | |
f737cfb9 | 66 | Entries->SwAddressLength\r |
67 | );\r | |
68 | CopyMem (\r | |
69 | &Mode->ArpCache[Index].MacAddr,\r | |
70 | (UINT8 *) (Entries + 1) + Entries->SwAddressLength,\r | |
71 | Entries->HwAddressLength\r | |
72 | );\r | |
982a9eae | 73 | //\r |
74 | // Slip to the next FindData.\r | |
75 | //\r | |
f737cfb9 | 76 | Entries = (EFI_ARP_FIND_DATA *) ((UINT8 *) Entries + EntryLength);\r |
982a9eae | 77 | }\r |
78 | \r | |
79 | return EFI_SUCCESS;\r | |
80 | }\r | |
81 | \r | |
82 | /**\r | |
f737cfb9 | 83 | Timeout routine to update arp cache.\r |
982a9eae | 84 | \r |
85 | @param Event Pointer to EFI_PXE_BC_PROTOCOL\r | |
86 | @param Context Context of the timer event\r | |
87 | \r | |
88 | **/\r | |
982a9eae | 89 | VOID\r |
90 | EFIAPI\r | |
91 | ArpCacheUpdateTimeout (\r | |
92 | IN EFI_EVENT Event,\r | |
93 | IN VOID *Context\r | |
94 | )\r | |
95 | {\r | |
96 | UpdateArpCache ((EFI_PXE_BASE_CODE_PROTOCOL *) Context);\r | |
97 | }\r | |
98 | \r | |
99 | /**\r | |
f737cfb9 | 100 | Do arp resolution from arp cache in PxeBcMode.\r |
e2851998 | 101 | \r |
f737cfb9 | 102 | @param PxeBcMode The PXE BC mode to look into.\r |
103 | @param Ip4Addr The Ip4 address for resolution.\r | |
104 | @param MacAddress The resoluted MAC address if the resolution is successful.\r | |
105 | The value is undefined if resolution fails.\r | |
e2851998 | 106 | \r |
f737cfb9 | 107 | @retval TRUE The resolution is successful.\r |
108 | @retval FALSE Otherwise.\r | |
982a9eae | 109 | \r |
110 | **/\r | |
982a9eae | 111 | BOOLEAN\r |
112 | FindInArpCache (\r | |
f737cfb9 | 113 | IN EFI_PXE_BASE_CODE_MODE *PxeBcMode,\r |
114 | IN EFI_IPv4_ADDRESS *Ip4Addr,\r | |
115 | OUT EFI_MAC_ADDRESS *MacAddress\r | |
982a9eae | 116 | )\r |
117 | {\r | |
118 | UINT32 Index;\r | |
119 | \r | |
120 | for (Index = 0; Index < PxeBcMode->ArpCacheEntries; Index ++) {\r | |
121 | if (EFI_IP4_EQUAL (&PxeBcMode->ArpCache[Index].IpAddr.v4, Ip4Addr)) {\r | |
f737cfb9 | 122 | CopyMem (\r |
123 | MacAddress,\r | |
124 | &PxeBcMode->ArpCache[Index].MacAddr,\r | |
125 | sizeof (EFI_MAC_ADDRESS)\r | |
126 | );\r | |
982a9eae | 127 | return TRUE;\r |
128 | }\r | |
129 | }\r | |
130 | \r | |
131 | return FALSE;\r | |
132 | }\r | |
133 | \r | |
134 | /**\r | |
135 | Notify function for the ICMP receive token, used to process\r | |
136 | the received ICMP packets.\r | |
137 | \r | |
f737cfb9 | 138 | @param Context The PXEBC private data.\r |
982a9eae | 139 | \r |
982a9eae | 140 | **/\r |
982a9eae | 141 | VOID\r |
142 | EFIAPI\r | |
143 | IcmpErrorListenHandlerDpc (\r | |
144 | IN VOID *Context\r | |
145 | )\r | |
146 | {\r | |
147 | EFI_STATUS Status;\r | |
148 | EFI_IP4_RECEIVE_DATA *RxData;\r | |
149 | EFI_IP4_PROTOCOL *Ip4;\r | |
150 | PXEBC_PRIVATE_DATA *Private;\r | |
151 | EFI_PXE_BASE_CODE_MODE *Mode;\r | |
152 | UINTN Index;\r | |
153 | UINT32 CopiedLen;\r | |
154 | UINT8 *CopiedPointer;\r | |
155 | \r | |
156 | Private = (PXEBC_PRIVATE_DATA *) Context;\r | |
157 | Mode = &Private->Mode;\r | |
158 | Status = Private->IcmpErrorRcvToken.Status;\r | |
159 | RxData = Private->IcmpErrorRcvToken.Packet.RxData;\r | |
160 | Ip4 = Private->Ip4;\r | |
161 | \r | |
f737cfb9 | 162 | if (Status == EFI_ABORTED) {\r |
982a9eae | 163 | //\r |
164 | // The reception is actively aborted by the consumer, directly return.\r | |
165 | //\r | |
166 | return;\r | |
167 | }\r | |
168 | \r | |
f737cfb9 | 169 | if (EFI_ERROR (Status) || (RxData == NULL)) {\r |
982a9eae | 170 | //\r |
171 | // Only process the normal packets and the icmp error packets, if RxData is NULL\r | |
172 | // with Status == EFI_SUCCESS or EFI_ICMP_ERROR, just resume the receive although\r | |
173 | // this should be a bug of the low layer (IP).\r | |
174 | //\r | |
175 | goto Resume;\r | |
176 | }\r | |
177 | \r | |
f737cfb9 | 178 | if (EFI_IP4 (RxData->Header->SourceAddress) != 0 &&\r |
f6b7393c | 179 | !NetIp4IsUnicast (EFI_NTOHL (RxData->Header->SourceAddress), 0)) {\r |
982a9eae | 180 | //\r |
181 | // The source address is not zero and it's not a unicast IP address, discard it.\r | |
182 | //\r | |
183 | goto CleanUp;\r | |
184 | }\r | |
185 | \r | |
186 | if (!EFI_IP4_EQUAL (&RxData->Header->DestinationAddress, &Mode->StationIp.v4)) {\r | |
187 | //\r | |
188 | // The dest address is not equal to Station Ip address, discard it.\r | |
189 | //\r | |
190 | goto CleanUp;\r | |
191 | }\r | |
192 | \r | |
193 | //\r | |
194 | // Constructor ICMP error packet\r | |
195 | //\r | |
196 | CopiedLen = 0;\r | |
197 | CopiedPointer = (UINT8 *) &Mode->IcmpError;\r | |
198 | \r | |
199 | for (Index = 0; Index < RxData->FragmentCount; Index ++) {\r | |
200 | CopiedLen += RxData->FragmentTable[Index].FragmentLength;\r | |
201 | if (CopiedLen <= sizeof (EFI_PXE_BASE_CODE_ICMP_ERROR)) {\r | |
f737cfb9 | 202 | CopyMem (\r |
203 | CopiedPointer,\r | |
204 | RxData->FragmentTable[Index].FragmentBuffer,\r | |
205 | RxData->FragmentTable[Index].FragmentLength\r | |
206 | );\r | |
982a9eae | 207 | } else {\r |
f737cfb9 | 208 | CopyMem (\r |
209 | CopiedPointer,\r | |
210 | RxData->FragmentTable[Index].FragmentBuffer,\r | |
211 | CopiedLen - sizeof (EFI_PXE_BASE_CODE_ICMP_ERROR)\r | |
212 | );\r | |
982a9eae | 213 | }\r |
214 | CopiedPointer += CopiedLen;\r | |
215 | }\r | |
216 | \r | |
217 | goto Resume;\r | |
218 | \r | |
219 | CleanUp:\r | |
220 | gBS->SignalEvent (RxData->RecycleSignal);\r | |
221 | \r | |
222 | Resume:\r | |
223 | Ip4->Receive (Ip4, &(Private->IcmpErrorRcvToken));\r | |
224 | }\r | |
225 | \r | |
226 | /**\r | |
227 | Request IcmpErrorListenHandlerDpc as a DPC at TPL_CALLBACK\r | |
228 | \r | |
229 | @param Event The event signaled.\r | |
230 | @param Context The context passed in by the event notifier.\r | |
231 | \r | |
982a9eae | 232 | **/\r |
982a9eae | 233 | VOID\r |
234 | EFIAPI\r | |
235 | IcmpErrorListenHandler (\r | |
236 | IN EFI_EVENT Event,\r | |
237 | IN VOID *Context\r | |
238 | )\r | |
239 | {\r | |
240 | //\r | |
241 | // Request IpIoListenHandlerDpc as a DPC at TPL_CALLBACK\r | |
242 | //\r | |
d8d26fb2 | 243 | QueueDpc (TPL_CALLBACK, IcmpErrorListenHandlerDpc, Context);\r |
982a9eae | 244 | }\r |
dc361cc5 | 245 | \r |
e2851998 | 246 | /**\r |
f737cfb9 | 247 | Enables the use of the PXE Base Code Protocol functions.\r |
248 | \r | |
249 | This function enables the use of the PXE Base Code Protocol functions. If the\r | |
250 | Started field of the EFI_PXE_BASE_CODE_MODE structure is already TRUE, then\r | |
251 | EFI_ALREADY_STARTED will be returned. If UseIpv6 is TRUE, then IPv6 formatted\r | |
252 | addresses will be used in this session. If UseIpv6 is FALSE, then IPv4 formatted\r | |
253 | addresses will be used in this session. If UseIpv6 is TRUE, and the Ipv6Supported\r | |
254 | field of the EFI_PXE_BASE_CODE_MODE structure is FALSE, then EFI_UNSUPPORTED will\r | |
255 | be returned. If there is not enough memory or other resources to start the PXE\r | |
256 | Base Code Protocol, then EFI_OUT_OF_RESOURCES will be returned. Otherwise, the\r | |
257 | PXE Base Code Protocol will be started, and all of the fields of the EFI_PXE_BASE_CODE_MODE\r | |
258 | structure will be initialized as follows:\r | |
259 | StartedSet to TRUE.\r | |
260 | Ipv6SupportedUnchanged.\r | |
261 | Ipv6AvailableUnchanged.\r | |
262 | UsingIpv6Set to UseIpv6.\r | |
263 | BisSupportedUnchanged.\r | |
264 | BisDetectedUnchanged.\r | |
265 | AutoArpSet to TRUE.\r | |
266 | SendGUIDSet to FALSE.\r | |
267 | TTLSet to DEFAULT_TTL.\r | |
268 | ToSSet to DEFAULT_ToS.\r | |
269 | DhcpCompletedSet to FALSE.\r | |
270 | ProxyOfferReceivedSet to FALSE.\r | |
271 | StationIpSet to an address of all zeros.\r | |
272 | SubnetMaskSet to a subnet mask of all zeros.\r | |
273 | DhcpDiscoverZero-filled.\r | |
274 | DhcpAckZero-filled.\r | |
275 | ProxyOfferZero-filled.\r | |
276 | PxeDiscoverValidSet to FALSE.\r | |
277 | PxeDiscoverZero-filled.\r | |
278 | PxeReplyValidSet to FALSE.\r | |
279 | PxeReplyZero-filled.\r | |
280 | PxeBisReplyValidSet to FALSE.\r | |
281 | PxeBisReplyZero-filled.\r | |
282 | IpFilterSet the Filters field to 0 and the IpCnt field to 0.\r | |
283 | ArpCacheEntriesSet to 0.\r | |
284 | ArpCacheZero-filled.\r | |
285 | RouteTableEntriesSet to 0.\r | |
286 | RouteTableZero-filled.\r | |
287 | IcmpErrorReceivedSet to FALSE.\r | |
288 | IcmpErrorZero-filled.\r | |
289 | TftpErroReceivedSet to FALSE.\r | |
290 | TftpErrorZero-filled.\r | |
291 | MakeCallbacksSet to TRUE if the PXE Base Code Callback Protocol is available.\r | |
292 | Set to FALSE if the PXE Base Code Callback Protocol is not available.\r | |
e2851998 | 293 | \r |
f737cfb9 | 294 | @param This Pointer to the EFI_PXE_BASE_CODE_PROTOCOL instance.\r |
295 | @param UseIpv6 Specifies the type of IP addresses that are to be used during the session\r | |
e2851998 | 296 | that is being started. Set to TRUE for IPv6 addresses, and FALSE for\r |
297 | IPv4 addresses.\r | |
298 | \r | |
f737cfb9 | 299 | @retval EFI_SUCCESS The PXE Base Code Protocol was started.\r |
e2851998 | 300 | @retval EFI_DEVICE_ERROR The network device encountered an error during this oper\r |
f737cfb9 | 301 | @retval EFI_UNSUPPORTED UseIpv6 is TRUE, but the Ipv6Supported field of the\r |
e2851998 | 302 | EFI_PXE_BASE_CODE_MODE structure is FALSE.\r |
303 | @retval EFI_ALREADY_STARTED The PXE Base Code Protocol is already in the started state.\r | |
f737cfb9 | 304 | @retval EFI_INVALID_PARAMETER The This parameter is NULL or does not point to a valid\r |
e2851998 | 305 | EFI_PXE_BASE_CODE_PROTOCOL structure.\r |
306 | @retval EFI_OUT_OF_RESOURCES Could not allocate enough memory or other resources to start the\r | |
307 | PXE Base Code Protocol.\r | |
308 | \r | |
dc361cc5 | 309 | **/\r |
310 | EFI_STATUS\r | |
311 | EFIAPI\r | |
312 | EfiPxeBcStart (\r | |
313 | IN EFI_PXE_BASE_CODE_PROTOCOL *This,\r | |
314 | IN BOOLEAN UseIpv6\r | |
315 | )\r | |
316 | {\r | |
317 | PXEBC_PRIVATE_DATA *Private;\r | |
318 | EFI_PXE_BASE_CODE_MODE *Mode;\r | |
319 | EFI_STATUS Status;\r | |
320 | \r | |
321 | if (This == NULL) {\r | |
322 | return EFI_INVALID_PARAMETER;\r | |
323 | }\r | |
324 | \r | |
325 | Private = PXEBC_PRIVATE_DATA_FROM_PXEBC (This);\r | |
326 | Mode = Private->PxeBc.Mode;\r | |
327 | \r | |
328 | if (Mode->Started) {\r | |
329 | return EFI_ALREADY_STARTED;\r | |
330 | }\r | |
331 | \r | |
332 | if (UseIpv6) {\r | |
333 | //\r | |
334 | // IPv6 is not supported now.\r | |
335 | //\r | |
336 | return EFI_UNSUPPORTED;\r | |
337 | }\r | |
338 | \r | |
339 | //\r | |
340 | // Configure the udp4 instance to let it receive data\r | |
341 | //\r | |
f737cfb9 | 342 | Status = Private->Udp4Read->Configure (\r |
e2851998 | 343 | Private->Udp4Read,\r |
f737cfb9 | 344 | &Private->Udp4CfgData\r |
345 | );\r | |
dc361cc5 | 346 | if (EFI_ERROR (Status)) {\r |
347 | return Status;\r | |
348 | }\r | |
349 | \r | |
cfbc1a75 | 350 | \r |
351 | //\r | |
352 | // Configure block size for TFTP as a default value to handle all link layers.\r | |
353 | // \r | |
354 | Private->BlockSize = (UINTN) (MIN (Private->Ip4MaxPacketSize, PXEBC_DEFAULT_PACKET_SIZE) - \r | |
355 | PXEBC_DEFAULT_UDP_OVERHEAD_SIZE - PXEBC_DEFAULT_TFTP_OVERHEAD_SIZE);\r | |
356 | //\r | |
357 | // If PcdTftpBlockSize is set to non-zero, override the default value.\r | |
358 | //\r | |
359 | if (PcdGet64 (PcdTftpBlockSize) != 0) {\r | |
360 | Private->BlockSize = (UINTN) PcdGet64 (PcdTftpBlockSize);\r | |
361 | }\r | |
362 | \r | |
dc361cc5 | 363 | Private->AddressIsOk = FALSE;\r |
364 | \r | |
365 | ZeroMem (Mode, sizeof (EFI_PXE_BASE_CODE_MODE));\r | |
366 | \r | |
367 | Mode->Started = TRUE;\r | |
368 | Mode->TTL = DEFAULT_TTL;\r | |
369 | Mode->ToS = DEFAULT_ToS;\r | |
370 | Mode->AutoArp = TRUE;\r | |
371 | \r | |
982a9eae | 372 | //\r |
373 | // Create the event for Arp Cache checking.\r | |
374 | //\r | |
375 | Status = gBS->CreateEvent (\r | |
376 | EVT_TIMER | EVT_NOTIFY_SIGNAL,\r | |
377 | TPL_CALLBACK,\r | |
378 | ArpCacheUpdateTimeout,\r | |
379 | This,\r | |
380 | &Private->GetArpCacheEvent\r | |
381 | );\r | |
382 | if (EFI_ERROR (Status)) {\r | |
383 | goto ON_EXIT;\r | |
384 | }\r | |
385 | \r | |
386 | //\r | |
387 | // Start the timeout timer event.\r | |
388 | //\r | |
389 | Status = gBS->SetTimer (\r | |
390 | Private->GetArpCacheEvent,\r | |
391 | TimerPeriodic,\r | |
392 | TICKS_PER_SECOND\r | |
393 | );\r | |
394 | \r | |
395 | if (EFI_ERROR (Status)) {\r | |
396 | goto ON_EXIT;\r | |
397 | }\r | |
398 | \r | |
399 | //\r | |
400 | // Create ICMP error receiving event\r | |
401 | //\r | |
402 | Status = gBS->CreateEvent (\r | |
403 | EVT_NOTIFY_SIGNAL,\r | |
404 | TPL_NOTIFY,\r | |
405 | IcmpErrorListenHandler,\r | |
406 | Private,\r | |
407 | &(Private->IcmpErrorRcvToken.Event)\r | |
408 | );\r | |
409 | if (EFI_ERROR (Status)) {\r | |
410 | goto ON_EXIT;\r | |
411 | }\r | |
412 | \r | |
413 | Status = Private->Ip4->Configure (Private->Ip4, &Private->Ip4ConfigData);\r | |
414 | if (EFI_ERROR (Status)) {\r | |
415 | goto ON_EXIT;\r | |
416 | }\r | |
417 | \r | |
418 | //\r | |
419 | // start to listen incoming packet\r | |
420 | //\r | |
421 | Status = Private->Ip4->Receive (Private->Ip4, &Private->IcmpErrorRcvToken);\r | |
422 | if (!EFI_ERROR (Status)) {\r | |
423 | return Status;\r | |
424 | }\r | |
425 | \r | |
426 | ON_EXIT:\r | |
427 | Private->Ip4->Configure (Private->Ip4, NULL);\r | |
428 | \r | |
429 | if (Private->IcmpErrorRcvToken.Event != NULL) {\r | |
430 | gBS->CloseEvent (Private->IcmpErrorRcvToken.Event);\r | |
431 | }\r | |
432 | \r | |
433 | if (Private->GetArpCacheEvent != NULL) {\r | |
434 | gBS->SetTimer (Private->GetArpCacheEvent, TimerCancel, 0);\r | |
435 | gBS->CloseEvent (Private->GetArpCacheEvent);\r | |
436 | }\r | |
437 | \r | |
438 | Mode->Started = FALSE;\r | |
439 | Mode->TTL = 0;\r | |
440 | Mode->ToS = 0;\r | |
441 | Mode->AutoArp = FALSE;\r | |
442 | \r | |
443 | return Status;\r | |
dc361cc5 | 444 | }\r |
445 | \r | |
446 | \r | |
e2851998 | 447 | /**\r |
f737cfb9 | 448 | Disables the use of the PXE Base Code Protocol functions.\r |
449 | \r | |
450 | This function stops all activity on the network device. All the resources allocated\r | |
451 | in Start() are released, the Started field of the EFI_PXE_BASE_CODE_MODE structure is\r | |
452 | set to FALSE and EFI_SUCCESS is returned. If the Started field of the EFI_PXE_BASE_CODE_MODE\r | |
453 | structure is already FALSE, then EFI_NOT_STARTED will be returned.\r | |
e2851998 | 454 | \r |
f737cfb9 | 455 | @param This Pointer to the EFI_PXE_BASE_CODE_PROTOCOL instance.\r |
e2851998 | 456 | \r |
f737cfb9 | 457 | @retval EFI_SUCCESS The PXE Base Code Protocol was stopped.\r |
e2851998 | 458 | @retval EFI_NOT_STARTED The PXE Base Code Protocol is already in the stopped state.\r |
f737cfb9 | 459 | @retval EFI_INVALID_PARAMETER The This parameter is NULL or does not point to a valid\r |
e2851998 | 460 | EFI_PXE_BASE_CODE_PROTOCOL structure.\r |
461 | @retval EFI_DEVICE_ERROR The network device encountered an error during this operation.\r | |
462 | \r | |
dc361cc5 | 463 | **/\r |
464 | EFI_STATUS\r | |
465 | EFIAPI\r | |
466 | EfiPxeBcStop (\r | |
467 | IN EFI_PXE_BASE_CODE_PROTOCOL *This\r | |
468 | )\r | |
469 | {\r | |
470 | PXEBC_PRIVATE_DATA *Private;\r | |
471 | EFI_PXE_BASE_CODE_MODE *Mode;\r | |
472 | \r | |
473 | if (This == NULL) {\r | |
474 | return EFI_INVALID_PARAMETER;\r | |
475 | }\r | |
476 | \r | |
477 | Private = PXEBC_PRIVATE_DATA_FROM_PXEBC (This);\r | |
478 | Mode = Private->PxeBc.Mode;\r | |
479 | \r | |
480 | if (!Mode->Started) {\r | |
481 | return EFI_NOT_STARTED;\r | |
482 | }\r | |
483 | \r | |
982a9eae | 484 | Private->Ip4->Cancel (Private->Ip4, NULL);\r |
485 | //\r | |
486 | // Dispatch the DPCs queued by the NotifyFunction of the canceled rx token's\r | |
487 | // events.\r | |
488 | //\r | |
d8d26fb2 | 489 | DispatchDpc ();\r |
982a9eae | 490 | \r |
491 | Private->Ip4->Configure (Private->Ip4, NULL);\r | |
492 | \r | |
493 | //\r | |
494 | // Close the ICMP error receiving event.\r | |
495 | //\r | |
496 | gBS->CloseEvent (Private->IcmpErrorRcvToken.Event);\r | |
497 | \r | |
498 | //\r | |
499 | // Cancel the TimeoutEvent timer.\r | |
500 | //\r | |
501 | gBS->SetTimer (Private->GetArpCacheEvent, TimerCancel, 0);\r | |
502 | \r | |
503 | //\r | |
504 | // Close the TimeoutEvent event.\r | |
505 | //\r | |
506 | gBS->CloseEvent (Private->GetArpCacheEvent);\r | |
507 | \r | |
dc361cc5 | 508 | Mode->Started = FALSE;\r |
509 | \r | |
8792362f | 510 | Private->CurrentUdpSrcPort = 0;\r |
511 | Private->Udp4Write->Configure (Private->Udp4Write, NULL);\r | |
434ce3fe | 512 | Private->Udp4Read->Groups (Private->Udp4Read, FALSE, NULL);\r |
8792362f | 513 | Private->Udp4Read->Configure (Private->Udp4Read, NULL);\r |
dc361cc5 | 514 | \r |
515 | Private->Dhcp4->Stop (Private->Dhcp4);\r | |
516 | Private->Dhcp4->Configure (Private->Dhcp4, NULL);\r | |
517 | \r | |
518 | Private->FileSize = 0;\r | |
519 | \r | |
520 | return EFI_SUCCESS;\r | |
521 | }\r | |
522 | \r | |
523 | \r | |
e2851998 | 524 | /**\r |
f737cfb9 | 525 | Attempts to complete a DHCPv4 D.O.R.A. (discover / offer / request / acknowledge) or DHCPv6\r |
526 | S.A.R.R (solicit / advertise / request / reply) sequence.\r | |
527 | \r | |
528 | This function attempts to complete the DHCP sequence. If this sequence is completed,\r | |
529 | then EFI_SUCCESS is returned, and the DhcpCompleted, ProxyOfferReceived, StationIp,\r | |
530 | SubnetMask, DhcpDiscover, DhcpAck, and ProxyOffer fields of the EFI_PXE_BASE_CODE_MODE\r | |
531 | structure are filled in.\r | |
532 | If SortOffers is TRUE, then the cached DHCP offer packets will be sorted before\r | |
533 | they are tried. If SortOffers is FALSE, then the cached DHCP offer packets will\r | |
534 | be tried in the order in which they are received. Please see the Preboot Execution\r | |
535 | Environment (PXE) Specification for additional details on the implementation of DHCP.\r | |
536 | This function can take at least 31 seconds to timeout and return control to the\r | |
537 | caller. If the DHCP sequence does not complete, then EFI_TIMEOUT will be returned.\r | |
538 | If the Callback Protocol does not return EFI_PXE_BASE_CODE_CALLBACK_STATUS_CONTINUE,\r | |
539 | then the DHCP sequence will be stopped and EFI_ABORTED will be returned.\r | |
e2851998 | 540 | \r |
f737cfb9 | 541 | @param This Pointer to the EFI_PXE_BASE_CODE_PROTOCOL instance.\r |
542 | @param SortOffers TRUE if the offers received should be sorted. Set to FALSE to try the\r | |
e2851998 | 543 | offers in the order that they are received.\r |
544 | \r | |
f737cfb9 | 545 | @retval EFI_SUCCESS Valid DHCP has completed.\r |
546 | @retval EFI_NOT_STARTED The PXE Base Code Protocol is in the stopped state.\r | |
547 | @retval EFI_INVALID_PARAMETER The This parameter is NULL or does not point to a valid\r | |
e2851998 | 548 | EFI_PXE_BASE_CODE_PROTOCOL structure.\r |
549 | @retval EFI_DEVICE_ERROR The network device encountered an error during this operation.\r | |
f737cfb9 | 550 | @retval EFI_OUT_OF_RESOURCES Could not allocate enough memory to complete the DHCP Protocol.\r |
551 | @retval EFI_ABORTED The callback function aborted the DHCP Protocol.\r | |
552 | @retval EFI_TIMEOUT The DHCP Protocol timed out.\r | |
553 | @retval EFI_ICMP_ERROR An ICMP error packet was received during the DHCP session.\r | |
554 | @retval EFI_NO_RESPONSE Valid PXE offer was not received.\r | |
e2851998 | 555 | \r |
dc361cc5 | 556 | **/\r |
557 | EFI_STATUS\r | |
558 | EFIAPI\r | |
559 | EfiPxeBcDhcp (\r | |
560 | IN EFI_PXE_BASE_CODE_PROTOCOL *This,\r | |
561 | IN BOOLEAN SortOffers\r | |
562 | )\r | |
563 | {\r | |
8730386e | 564 | PXEBC_PRIVATE_DATA *Private;\r |
565 | EFI_PXE_BASE_CODE_MODE *Mode;\r | |
566 | EFI_DHCP4_PROTOCOL *Dhcp4;\r | |
567 | EFI_DHCP4_CONFIG_DATA Dhcp4CfgData;\r | |
568 | EFI_DHCP4_MODE_DATA Dhcp4Mode;\r | |
569 | EFI_DHCP4_PACKET_OPTION *OptList[PXEBC_DHCP4_MAX_OPTION_NUM];\r | |
570 | UINT32 OptCount;\r | |
571 | EFI_STATUS Status;\r | |
572 | EFI_ARP_CONFIG_DATA ArpConfigData;\r | |
573 | EFI_PXE_BASE_CODE_IP_FILTER IpFilter;\r | |
dc361cc5 | 574 | \r |
575 | if (This == NULL) {\r | |
576 | return EFI_INVALID_PARAMETER;\r | |
577 | }\r | |
578 | \r | |
579 | Status = EFI_SUCCESS;\r | |
580 | Private = PXEBC_PRIVATE_DATA_FROM_PXEBC (This);\r | |
581 | Mode = Private->PxeBc.Mode;\r | |
582 | Dhcp4 = Private->Dhcp4;\r | |
583 | Private->Function = EFI_PXE_BASE_CODE_FUNCTION_DHCP;\r | |
584 | Private->SortOffers = SortOffers;\r | |
585 | \r | |
586 | if (!Mode->Started) {\r | |
587 | return EFI_NOT_STARTED;\r | |
588 | }\r | |
982a9eae | 589 | \r |
590 | Mode->IcmpErrorReceived = FALSE;\r | |
591 | \r | |
8730386e | 592 | //\r |
593 | // Stop Udp4Read instance\r | |
594 | //\r | |
595 | Private->Udp4Read->Configure (Private->Udp4Read, NULL);\r | |
596 | \r | |
dc361cc5 | 597 | //\r |
598 | // Initialize the DHCP options and build the option list\r | |
599 | //\r | |
600 | OptCount = PxeBcBuildDhcpOptions (Private, OptList, TRUE);\r | |
601 | \r | |
602 | //\r | |
603 | // Set the DHCP4 config data.\r | |
434ce3fe | 604 | // The four discovery timeouts are 4, 8, 16, 32 seconds respectively.\r |
dc361cc5 | 605 | //\r |
e48e37fc | 606 | ZeroMem (&Dhcp4CfgData, sizeof (EFI_DHCP4_CONFIG_DATA));\r |
dc361cc5 | 607 | Dhcp4CfgData.OptionCount = OptCount;\r |
608 | Dhcp4CfgData.OptionList = OptList;\r | |
609 | Dhcp4CfgData.Dhcp4Callback = PxeBcDhcpCallBack;\r | |
610 | Dhcp4CfgData.CallbackContext = Private;\r | |
434ce3fe | 611 | Dhcp4CfgData.DiscoverTryCount = 4;\r |
612 | Dhcp4CfgData.DiscoverTimeout = mPxeDhcpTimeout;\r | |
dc361cc5 | 613 | \r |
434ce3fe | 614 | Status = Dhcp4->Configure (Dhcp4, &Dhcp4CfgData);\r |
615 | if (EFI_ERROR (Status)) {\r | |
616 | goto ON_EXIT;\r | |
617 | }\r | |
e2851998 | 618 | \r |
434ce3fe | 619 | //\r |
620 | // Zero those arrays to record the varies numbers of DHCP OFFERS.\r | |
621 | //\r | |
622 | Private->GotProxyOffer = FALSE;\r | |
623 | Private->NumOffers = 0;\r | |
624 | Private->BootpIndex = 0;\r | |
625 | ZeroMem (Private->ServerCount, sizeof (Private->ServerCount));\r | |
626 | ZeroMem (Private->ProxyIndex, sizeof (Private->ProxyIndex));\r | |
dc361cc5 | 627 | \r |
434ce3fe | 628 | Status = Dhcp4->Start (Dhcp4, NULL);\r |
629 | if (EFI_ERROR (Status)) {\r | |
630 | if (Status == EFI_ICMP_ERROR) {\r | |
631 | Mode->IcmpErrorReceived = TRUE;\r | |
dc361cc5 | 632 | }\r |
434ce3fe | 633 | goto ON_EXIT;\r |
634 | }\r | |
dc361cc5 | 635 | \r |
434ce3fe | 636 | Status = Dhcp4->GetModeData (Dhcp4, &Dhcp4Mode);\r |
637 | if (EFI_ERROR (Status)) {\r | |
638 | goto ON_EXIT;\r | |
639 | }\r | |
dc361cc5 | 640 | \r |
434ce3fe | 641 | ASSERT (Dhcp4Mode.State == Dhcp4Bound);\r |
dc361cc5 | 642 | \r |
434ce3fe | 643 | CopyMem (&Private->StationIp, &Dhcp4Mode.ClientAddress, sizeof (EFI_IPv4_ADDRESS));\r |
644 | CopyMem (&Private->SubnetMask, &Dhcp4Mode.SubnetMask, sizeof (EFI_IPv4_ADDRESS));\r | |
645 | CopyMem (&Private->GatewayIp, &Dhcp4Mode.RouterAddress, sizeof (EFI_IPv4_ADDRESS));\r | |
319075ff | 646 | \r |
434ce3fe | 647 | CopyMem (&Mode->StationIp, &Private->StationIp, sizeof (EFI_IPv4_ADDRESS));\r |
648 | CopyMem (&Mode->SubnetMask, &Private->SubnetMask, sizeof (EFI_IPv4_ADDRESS));\r | |
dc361cc5 | 649 | \r |
434ce3fe | 650 | //\r |
651 | // Check the selected offer to see whether BINL is required, if no or BINL is\r | |
652 | // finished, set the various Mode members.\r | |
653 | //\r | |
654 | Status = PxeBcCheckSelectedOffer (Private);\r | |
dc361cc5 | 655 | \r |
434ce3fe | 656 | ON_EXIT:\r |
dc361cc5 | 657 | if (EFI_ERROR (Status)) {\r |
658 | Dhcp4->Stop (Dhcp4);\r | |
659 | Dhcp4->Configure (Dhcp4, NULL);\r | |
660 | } else {\r | |
661 | //\r | |
662 | // Remove the previously configured option list and callback function\r | |
663 | //\r | |
e48e37fc | 664 | ZeroMem (&Dhcp4CfgData, sizeof (EFI_DHCP4_CONFIG_DATA));\r |
dc361cc5 | 665 | Dhcp4->Configure (Dhcp4, &Dhcp4CfgData);\r |
666 | \r | |
667 | Private->AddressIsOk = TRUE;\r | |
8d285ec0 | 668 | \r |
669 | if (!Mode->UsingIpv6) {\r | |
670 | //\r | |
671 | // If in IPv4 mode, configure the corresponding ARP with this new\r | |
672 | // station IP address.\r | |
673 | //\r | |
674 | ZeroMem (&ArpConfigData, sizeof (EFI_ARP_CONFIG_DATA));\r | |
675 | \r | |
676 | ArpConfigData.SwAddressType = 0x0800;\r | |
c9325700 | 677 | ArpConfigData.SwAddressLength = (UINT8) sizeof (EFI_IPv4_ADDRESS);\r |
8d285ec0 | 678 | ArpConfigData.StationAddress = &Private->StationIp.v4;\r |
679 | \r | |
680 | Private->Arp->Configure (Private->Arp, NULL);\r | |
681 | Private->Arp->Configure (Private->Arp, &ArpConfigData);\r | |
982a9eae | 682 | \r |
683 | //\r | |
684 | // Updated the route table. Fill the first entry.\r | |
685 | //\r | |
686 | Mode->RouteTableEntries = 1;\r | |
687 | Mode->RouteTable[0].IpAddr.Addr[0] = Private->StationIp.Addr[0] & Private->SubnetMask.Addr[0];\r | |
688 | Mode->RouteTable[0].SubnetMask.Addr[0] = Private->SubnetMask.Addr[0];\r | |
689 | Mode->RouteTable[0].GwAddr.Addr[0] = 0;\r | |
690 | \r | |
691 | //\r | |
692 | // Create the default route entry if there is a default router.\r | |
693 | //\r | |
694 | if (Private->GatewayIp.Addr[0] != 0) {\r | |
695 | Mode->RouteTableEntries = 2;\r | |
696 | Mode->RouteTable[1].IpAddr.Addr[0] = 0;\r | |
697 | Mode->RouteTable[1].SubnetMask.Addr[0] = 0;\r | |
698 | Mode->RouteTable[1].GwAddr.Addr[0] = Private->GatewayIp.Addr[0];\r | |
699 | }\r | |
8730386e | 700 | \r |
701 | //\r | |
702 | // Flush new station IP address into Udp4CfgData and Ip4ConfigData\r | |
703 | //\r | |
704 | CopyMem (&Private->Udp4CfgData.StationAddress, &Private->StationIp, sizeof (EFI_IPv4_ADDRESS));\r | |
705 | CopyMem (&Private->Udp4CfgData.SubnetMask, &Private->SubnetMask, sizeof (EFI_IPv4_ADDRESS));\r | |
706 | CopyMem (&Private->Ip4ConfigData.StationAddress, &Private->StationIp, sizeof (EFI_IPv4_ADDRESS));\r | |
707 | CopyMem (&Private->Ip4ConfigData.SubnetMask, &Private->SubnetMask, sizeof (EFI_IPv4_ADDRESS));\r | |
708 | \r | |
709 | //\r | |
710 | // Reconfigure the Ip4 instance to capture background ICMP packets with new station Ip address.\r | |
711 | //\r | |
712 | Private->Ip4->Cancel (Private->Ip4, &Private->IcmpErrorRcvToken);\r | |
713 | Private->Ip4->Configure (Private->Ip4, NULL);\r | |
714 | \r | |
715 | Status = Private->Ip4->Configure (Private->Ip4, &Private->Ip4ConfigData);\r | |
716 | if (EFI_ERROR (Status)) {\r | |
717 | goto ON_EXIT;\r | |
718 | }\r | |
719 | \r | |
720 | Status = Private->Ip4->Receive (Private->Ip4, &Private->IcmpErrorRcvToken);\r | |
721 | if (EFI_ERROR (Status)) {\r | |
722 | goto ON_EXIT;\r | |
723 | } \r | |
8d285ec0 | 724 | }\r |
dc361cc5 | 725 | }\r |
726 | \r | |
357af285 | 727 | Private->Udp4Read->Configure (Private->Udp4Read, &Private->Udp4CfgData);\r |
c82291bc | 728 | \r |
8730386e | 729 | //\r |
730 | // Dhcp(), Discover(), and Mtftp() set the IP filter, and return with the IP \r | |
731 | // receive filter list emptied and the filter set to EFI_PXE_BASE_CODE_IP_FILTER_STATION_IP.\r | |
732 | //\r | |
733 | ZeroMem(&IpFilter, sizeof (EFI_PXE_BASE_CODE_IP_FILTER));\r | |
734 | IpFilter.Filters = EFI_PXE_BASE_CODE_IP_FILTER_STATION_IP;\r | |
735 | This->SetIpFilter (This, &IpFilter);\r | |
736 | \r | |
dc361cc5 | 737 | return Status;\r |
738 | }\r | |
739 | \r | |
740 | \r | |
e2851998 | 741 | /**\r |
f737cfb9 | 742 | Attempts to complete the PXE Boot Server and/or boot image discovery sequence.\r |
743 | \r | |
744 | This function attempts to complete the PXE Boot Server and/or boot image discovery\r | |
745 | sequence. If this sequence is completed, then EFI_SUCCESS is returned, and the\r | |
746 | PxeDiscoverValid, PxeDiscover, PxeReplyReceived, and PxeReply fields of the\r | |
747 | EFI_PXE_BASE_CODE_MODE structure are filled in. If UseBis is TRUE, then the\r | |
748 | PxeBisReplyReceived and PxeBisReply fields of the EFI_PXE_BASE_CODE_MODE structure\r | |
749 | will also be filled in. If UseBis is FALSE, then PxeBisReplyValid will be set to FALSE.\r | |
750 | In the structure referenced by parameter Info, the PXE Boot Server list, SrvList[],\r | |
751 | has two uses: It is the Boot Server IP address list used for unicast discovery\r | |
752 | (if the UseUCast field is TRUE), and it is the list used for Boot Server verification\r | |
753 | (if the MustUseList field is TRUE). Also, if the MustUseList field in that structure\r | |
754 | is TRUE and the AcceptAnyResponse field in the SrvList[] array is TRUE, any Boot\r | |
755 | Server reply of that type will be accepted. If the AcceptAnyResponse field is\r | |
756 | FALSE, only responses from Boot Servers with matching IP addresses will be accepted.\r | |
757 | This function can take at least 10 seconds to timeout and return control to the\r | |
758 | caller. If the Discovery sequence does not complete, then EFI_TIMEOUT will be\r | |
759 | returned. Please see the Preboot Execution Environment (PXE) Specification for\r | |
760 | additional details on the implementation of the Discovery sequence.\r | |
761 | If the Callback Protocol does not return EFI_PXE_BASE_CODE_CALLBACK_STATUS_CONTINUE,\r | |
762 | then the Discovery sequence is stopped and EFI_ABORTED will be returned.\r | |
e2851998 | 763 | \r |
f737cfb9 | 764 | @param This Pointer to the EFI_PXE_BASE_CODE_PROTOCOL instance.\r |
765 | @param Type The type of bootstrap to perform.\r | |
766 | @param Layer Pointer to the boot server layer number to discover, which must be\r | |
e2851998 | 767 | PXE_BOOT_LAYER_INITIAL when a new server type is being\r |
768 | discovered.\r | |
769 | @param UseBis TRUE if Boot Integrity Services are to be used. FALSE otherwise.\r | |
f737cfb9 | 770 | @param Info Pointer to a data structure that contains additional information on the\r |
e2851998 | 771 | type of discovery operation that is to be performed.\r |
772 | \r | |
f737cfb9 | 773 | @retval EFI_SUCCESS The Discovery sequence has been completed.\r |
774 | @retval EFI_NOT_STARTED The PXE Base Code Protocol is in the stopped state.\r | |
e2851998 | 775 | @retval EFI_INVALID_PARAMETER One or more parameters are invalid.\r |
776 | @retval EFI_DEVICE_ERROR The network device encountered an error during this operation.\r | |
f737cfb9 | 777 | @retval EFI_OUT_OF_RESOURCES Could not allocate enough memory to complete Discovery.\r |
778 | @retval EFI_ABORTED The callback function aborted the Discovery sequence.\r | |
779 | @retval EFI_TIMEOUT The Discovery sequence timed out.\r | |
780 | @retval EFI_ICMP_ERROR An ICMP error packet was received during the PXE discovery\r | |
e2851998 | 781 | session.\r |
782 | \r | |
dc361cc5 | 783 | **/\r |
784 | EFI_STATUS\r | |
785 | EFIAPI\r | |
786 | EfiPxeBcDiscover (\r | |
787 | IN EFI_PXE_BASE_CODE_PROTOCOL *This,\r | |
788 | IN UINT16 Type,\r | |
789 | IN UINT16 *Layer,\r | |
790 | IN BOOLEAN UseBis,\r | |
791 | IN EFI_PXE_BASE_CODE_DISCOVER_INFO *Info OPTIONAL\r | |
792 | )\r | |
793 | {\r | |
794 | PXEBC_PRIVATE_DATA *Private;\r | |
795 | EFI_PXE_BASE_CODE_MODE *Mode;\r | |
796 | EFI_PXE_BASE_CODE_DISCOVER_INFO DefaultInfo;\r | |
29a4f92d | 797 | EFI_PXE_BASE_CODE_DISCOVER_INFO *CreatedInfo;\r |
dc361cc5 | 798 | EFI_PXE_BASE_CODE_SRVLIST *SrvList;\r |
799 | EFI_PXE_BASE_CODE_SRVLIST DefaultSrvList;\r | |
800 | PXEBC_CACHED_DHCP4_PACKET *Packet;\r | |
f737cfb9 | 801 | PXEBC_VENDOR_OPTION *VendorOpt;\r |
dc361cc5 | 802 | UINT16 Index;\r |
803 | EFI_STATUS Status;\r | |
804 | PXEBC_BOOT_SVR_ENTRY *BootSvrEntry;\r | |
8730386e | 805 | EFI_PXE_BASE_CODE_IP_FILTER IpFilter;\r |
dc361cc5 | 806 | \r |
807 | if (This == NULL) {\r | |
808 | return EFI_INVALID_PARAMETER;\r | |
809 | }\r | |
810 | \r | |
811 | Private = PXEBC_PRIVATE_DATA_FROM_PXEBC (This);\r | |
812 | Mode = Private->PxeBc.Mode;\r | |
813 | BootSvrEntry = NULL;\r | |
814 | SrvList = NULL;\r | |
29a4f92d | 815 | CreatedInfo = NULL;\r |
dc361cc5 | 816 | Status = EFI_DEVICE_ERROR;\r |
817 | Private->Function = EFI_PXE_BASE_CODE_FUNCTION_DISCOVER;\r | |
818 | \r | |
819 | if (!Private->AddressIsOk) {\r | |
820 | return EFI_INVALID_PARAMETER;\r | |
821 | }\r | |
822 | \r | |
823 | if (!Mode->Started) {\r | |
824 | return EFI_NOT_STARTED;\r | |
825 | }\r | |
826 | \r | |
8730386e | 827 | //\r |
828 | // Stop Udp4Read instance\r | |
829 | //\r | |
830 | Private->Udp4Read->Configure (Private->Udp4Read, NULL);\r | |
831 | \r | |
982a9eae | 832 | Mode->IcmpErrorReceived = FALSE;\r |
833 | \r | |
dc361cc5 | 834 | //\r |
835 | // If layer isn't EFI_PXE_BASE_CODE_BOOT_LAYER_INITIAL,\r | |
836 | // use the previous setting;\r | |
837 | // If info isn't offered,\r | |
838 | // use the cached DhcpAck and ProxyOffer packets.\r | |
839 | //\r | |
f402291b | 840 | ZeroMem (&DefaultInfo, sizeof (EFI_PXE_BASE_CODE_DISCOVER_INFO));\r |
dc361cc5 | 841 | if (*Layer != EFI_PXE_BASE_CODE_BOOT_LAYER_INITIAL) {\r |
842 | \r | |
843 | if (!Mode->PxeDiscoverValid || !Mode->PxeReplyReceived || (!Mode->PxeBisReplyReceived && UseBis)) {\r | |
844 | \r | |
8730386e | 845 | Status = EFI_INVALID_PARAMETER;\r |
846 | goto ON_EXIT; \r | |
dc361cc5 | 847 | }\r |
848 | \r | |
849 | DefaultInfo.IpCnt = 1;\r | |
850 | DefaultInfo.UseUCast = TRUE;\r | |
851 | \r | |
852 | DefaultSrvList.Type = Type;\r | |
853 | DefaultSrvList.AcceptAnyResponse = FALSE;\r | |
854 | DefaultSrvList.IpAddr.Addr[0] = Private->ServerIp.Addr[0];\r | |
855 | \r | |
856 | SrvList = &DefaultSrvList;\r | |
857 | Info = &DefaultInfo;\r | |
858 | } else if (Info == NULL) {\r | |
859 | //\r | |
860 | // Create info by the cached packet before\r | |
861 | //\r | |
862 | Packet = (Mode->ProxyOfferReceived) ? &Private->ProxyOffer : &Private->Dhcp4Ack;\r | |
863 | VendorOpt = &Packet->PxeVendorOption;\r | |
864 | \r | |
865 | if (!Mode->DhcpAckReceived || !IS_VALID_DISCOVER_VENDOR_OPTION (VendorOpt->BitMap)) {\r | |
866 | //\r | |
867 | // Address is not acquired or no discovery options.\r | |
868 | //\r | |
8730386e | 869 | Status = EFI_INVALID_PARAMETER;\r |
870 | goto ON_EXIT; \r | |
dc361cc5 | 871 | }\r |
872 | \r | |
873 | DefaultInfo.UseMCast = (BOOLEAN)!IS_DISABLE_MCAST_DISCOVER (VendorOpt->DiscoverCtrl);\r | |
874 | DefaultInfo.UseBCast = (BOOLEAN)!IS_DISABLE_BCAST_DISCOVER (VendorOpt->DiscoverCtrl);\r | |
875 | DefaultInfo.MustUseList = (BOOLEAN) IS_ENABLE_USE_SERVER_LIST (VendorOpt->DiscoverCtrl);\r | |
876 | DefaultInfo.UseUCast = DefaultInfo.MustUseList;\r | |
877 | \r | |
878 | if (DefaultInfo.UseMCast) {\r | |
879 | //\r | |
880 | // Get the multicast discover ip address from vendor option.\r | |
881 | //\r | |
f737cfb9 | 882 | CopyMem (\r |
e2851998 | 883 | &DefaultInfo.ServerMCastIp.Addr,\r |
884 | &VendorOpt->DiscoverMcastIp,\r | |
f737cfb9 | 885 | sizeof (EFI_IPv4_ADDRESS)\r |
886 | );\r | |
dc361cc5 | 887 | }\r |
888 | \r | |
889 | DefaultInfo.IpCnt = 0;\r | |
29a4f92d | 890 | Info = &DefaultInfo;\r |
891 | SrvList = Info->SrvList;\r | |
dc361cc5 | 892 | \r |
893 | if (DefaultInfo.MustUseList) {\r | |
894 | BootSvrEntry = VendorOpt->BootSvr;\r | |
895 | Status = EFI_INVALID_PARAMETER;\r | |
896 | \r | |
897 | while (((UINT8) (BootSvrEntry - VendorOpt->BootSvr)) < VendorOpt->BootSvrLen) {\r | |
898 | \r | |
899 | if (BootSvrEntry->Type == HTONS (Type)) {\r | |
900 | Status = EFI_SUCCESS;\r | |
901 | break;\r | |
902 | }\r | |
903 | \r | |
904 | BootSvrEntry = GET_NEXT_BOOT_SVR_ENTRY (BootSvrEntry);\r | |
905 | }\r | |
906 | \r | |
907 | if (EFI_ERROR (Status)) {\r | |
8730386e | 908 | goto ON_EXIT;\r |
dc361cc5 | 909 | }\r |
910 | \r | |
911 | DefaultInfo.IpCnt = BootSvrEntry->IpCnt;\r | |
29a4f92d | 912 | \r |
913 | if (DefaultInfo.IpCnt >= 1) {\r | |
914 | CreatedInfo = AllocatePool (sizeof (DefaultInfo) + (DefaultInfo.IpCnt - 1) * sizeof (*SrvList));\r | |
915 | if (CreatedInfo == NULL) {\r | |
8730386e | 916 | Status = EFI_OUT_OF_RESOURCES;\r |
917 | goto ON_EXIT;\r | |
918 | \r | |
29a4f92d | 919 | } \r |
920 | \r | |
921 | CopyMem (CreatedInfo, &DefaultInfo, sizeof (DefaultInfo));\r | |
922 | Info = CreatedInfo;\r | |
923 | SrvList = Info->SrvList;\r | |
924 | }\r | |
925 | \r | |
926 | for (Index = 0; Index < DefaultInfo.IpCnt; Index++) {\r | |
927 | CopyMem (&SrvList[Index].IpAddr, &BootSvrEntry->IpAddr[Index], sizeof (EFI_IPv4_ADDRESS));\r | |
928 | SrvList[Index].AcceptAnyResponse = FALSE;\r | |
929 | SrvList[Index].Type = BootSvrEntry->Type;\r | |
930 | }\r | |
dc361cc5 | 931 | }\r |
932 | \r | |
dc361cc5 | 933 | } else {\r |
934 | \r | |
935 | SrvList = Info->SrvList;\r | |
936 | \r | |
937 | if (!SrvList[0].AcceptAnyResponse) {\r | |
938 | \r | |
939 | for (Index = 1; Index < Info->IpCnt; Index++) {\r | |
940 | if (SrvList[Index].AcceptAnyResponse) {\r | |
941 | break;\r | |
942 | }\r | |
943 | }\r | |
944 | \r | |
945 | if (Index != Info->IpCnt) {\r | |
8730386e | 946 | Status = EFI_INVALID_PARAMETER;\r |
947 | goto ON_EXIT; \r | |
dc361cc5 | 948 | }\r |
949 | }\r | |
950 | }\r | |
951 | \r | |
952 | if ((!Info->UseUCast && !Info->UseBCast && !Info->UseMCast) || (Info->MustUseList && Info->IpCnt == 0)) {\r | |
953 | \r | |
8730386e | 954 | Status = EFI_INVALID_PARAMETER;\r |
955 | goto ON_EXIT;\r | |
dc361cc5 | 956 | }\r |
957 | //\r | |
958 | // Execute discover by UniCast/BroadCast/MultiCast\r | |
959 | //\r | |
960 | if (Info->UseUCast) {\r | |
961 | \r | |
962 | for (Index = 0; Index < Info->IpCnt; Index++) {\r | |
963 | \r | |
964 | if (BootSvrEntry == NULL) {\r | |
965 | Private->ServerIp.Addr[0] = SrvList[Index].IpAddr.Addr[0];\r | |
966 | } else {\r | |
f737cfb9 | 967 | CopyMem (\r |
e2851998 | 968 | &Private->ServerIp,\r |
969 | &BootSvrEntry->IpAddr[Index],\r | |
f737cfb9 | 970 | sizeof (EFI_IPv4_ADDRESS)\r |
971 | );\r | |
dc361cc5 | 972 | }\r |
973 | \r | |
974 | Status = PxeBcDiscvBootService (\r | |
975 | Private,\r | |
976 | Type,\r | |
977 | Layer,\r | |
978 | UseBis,\r | |
979 | &SrvList[Index].IpAddr,\r | |
980 | 0,\r | |
981 | NULL,\r | |
982 | TRUE,\r | |
983 | &Private->PxeReply.Packet.Ack\r | |
984 | );\r | |
29a4f92d | 985 | if (!EFI_ERROR (Status)) {\r |
986 | break;\r | |
987 | } \r | |
dc361cc5 | 988 | }\r |
989 | \r | |
990 | } else if (Info->UseMCast) {\r | |
991 | \r | |
992 | Status = PxeBcDiscvBootService (\r | |
993 | Private,\r | |
994 | Type,\r | |
995 | Layer,\r | |
996 | UseBis,\r | |
997 | &Info->ServerMCastIp,\r | |
998 | 0,\r | |
999 | NULL,\r | |
1000 | TRUE,\r | |
1001 | &Private->PxeReply.Packet.Ack\r | |
1002 | );\r | |
1003 | \r | |
1004 | } else if (Info->UseBCast) {\r | |
1005 | \r | |
1006 | Status = PxeBcDiscvBootService (\r | |
1007 | Private,\r | |
1008 | Type,\r | |
1009 | Layer,\r | |
1010 | UseBis,\r | |
1011 | NULL,\r | |
1012 | Info->IpCnt,\r | |
1013 | SrvList,\r | |
1014 | TRUE,\r | |
1015 | &Private->PxeReply.Packet.Ack\r | |
1016 | );\r | |
1017 | }\r | |
1018 | \r | |
1019 | if (EFI_ERROR (Status) || !Mode->PxeReplyReceived || (!Mode->PxeBisReplyReceived && UseBis)) {\r | |
982a9eae | 1020 | if (Status == EFI_ICMP_ERROR) {\r |
1021 | Mode->IcmpErrorReceived = TRUE;\r | |
1022 | } else {\r | |
1023 | Status = EFI_DEVICE_ERROR;\r | |
1024 | }\r | |
357af285 | 1025 | goto ON_EXIT;\r |
dc361cc5 | 1026 | } else {\r |
1027 | PxeBcParseCachedDhcpPacket (&Private->PxeReply);\r | |
1028 | }\r | |
1029 | \r | |
1030 | if (Mode->PxeBisReplyReceived) {\r | |
f737cfb9 | 1031 | CopyMem (\r |
e2851998 | 1032 | &Private->ServerIp,\r |
1033 | &Mode->PxeReply.Dhcpv4.BootpSiAddr,\r | |
f737cfb9 | 1034 | sizeof (EFI_IPv4_ADDRESS)\r |
1035 | );\r | |
dc361cc5 | 1036 | }\r |
1037 | \r | |
29a4f92d | 1038 | if (CreatedInfo != NULL) {\r |
1039 | FreePool (CreatedInfo);\r | |
1040 | }\r | |
8730386e | 1041 | \r |
1042 | ON_EXIT:\r | |
1043 | \r | |
357af285 | 1044 | Private->Udp4Read->Configure (Private->Udp4Read, &Private->Udp4CfgData);\r |
c82291bc | 1045 | \r |
8730386e | 1046 | //\r |
1047 | // Dhcp(), Discover(), and Mtftp() set the IP filter, and return with the IP \r | |
1048 | // receive filter list emptied and the filter set to EFI_PXE_BASE_CODE_IP_FILTER_STATION_IP.\r | |
1049 | //\r | |
1050 | ZeroMem(&IpFilter, sizeof (EFI_PXE_BASE_CODE_IP_FILTER));\r | |
1051 | IpFilter.Filters = EFI_PXE_BASE_CODE_IP_FILTER_STATION_IP;\r | |
1052 | This->SetIpFilter (This, &IpFilter);\r | |
29a4f92d | 1053 | \r |
dc361cc5 | 1054 | return Status;\r |
1055 | }\r | |
1056 | \r | |
1057 | \r | |
e2851998 | 1058 | /**\r |
f737cfb9 | 1059 | Used to perform TFTP and MTFTP services.\r |
1060 | \r | |
1061 | This function is used to perform TFTP and MTFTP services. This includes the\r | |
1062 | TFTP operations to get the size of a file, read a directory, read a file, and\r | |
1063 | write a file. It also includes the MTFTP operations to get the size of a file,\r | |
1064 | read a directory, and read a file. The type of operation is specified by Operation.\r | |
1065 | If the callback function that is invoked during the TFTP/MTFTP operation does\r | |
1066 | not return EFI_PXE_BASE_CODE_CALLBACK_STATUS_CONTINUE, then EFI_ABORTED will\r | |
1067 | be returned.\r | |
1068 | For read operations, the return data will be placed in the buffer specified by\r | |
1069 | BufferPtr. If BufferSize is too small to contain the entire downloaded file,\r | |
1070 | then EFI_BUFFER_TOO_SMALL will be returned and BufferSize will be set to zero\r | |
1071 | or the size of the requested file (the size of the requested file is only returned\r | |
1072 | if the TFTP server supports TFTP options). If BufferSize is large enough for the\r | |
1073 | read operation, then BufferSize will be set to the size of the downloaded file,\r | |
1074 | and EFI_SUCCESS will be returned. Applications using the PxeBc.Mtftp() services\r | |
1075 | should use the get-file-size operations to determine the size of the downloaded\r | |
1076 | file prior to using the read-file operations-especially when downloading large\r | |
1077 | (greater than 64 MB) files-instead of making two calls to the read-file operation.\r | |
1078 | Following this recommendation will save time if the file is larger than expected\r | |
1079 | and the TFTP server does not support TFTP option extensions. Without TFTP option\r | |
1080 | extension support, the client has to download the entire file, counting and discarding\r | |
1081 | the received packets, to determine the file size.\r | |
1082 | For write operations, the data to be sent is in the buffer specified by BufferPtr.\r | |
1083 | BufferSize specifies the number of bytes to send. If the write operation completes\r | |
1084 | successfully, then EFI_SUCCESS will be returned.\r | |
1085 | For TFTP "get file size" operations, the size of the requested file or directory\r | |
1086 | is returned in BufferSize, and EFI_SUCCESS will be returned. If the TFTP server\r | |
1087 | does not support options, the file will be downloaded into a bit bucket and the\r | |
1088 | length of the downloaded file will be returned. For MTFTP "get file size" operations,\r | |
1089 | if the MTFTP server does not support the "get file size" option, EFI_UNSUPPORTED\r | |
1090 | will be returned.\r | |
1091 | This function can take up to 10 seconds to timeout and return control to the caller.\r | |
1092 | If the TFTP sequence does not complete, EFI_TIMEOUT will be returned.\r | |
1093 | If the Callback Protocol does not return EFI_PXE_BASE_CODE_CALLBACK_STATUS_CONTINUE,\r | |
1094 | then the TFTP sequence is stopped and EFI_ABORTED will be returned.\r | |
1095 | The format of the data returned from a TFTP read directory operation is a null-terminated\r | |
1096 | filename followed by a null-terminated information string, of the form\r | |
1097 | "size year-month-day hour:minute:second" (i.e. %d %d-%d-%d %d:%d:%f - note that\r | |
1098 | the seconds field can be a decimal number), where the date and time are UTC. For\r | |
1099 | an MTFTP read directory command, there is additionally a null-terminated multicast\r | |
1100 | IP address preceding the filename of the form %d.%d.%d.%d for IP v4. The final\r | |
1101 | entry is itself null-terminated, so that the final information string is terminated\r | |
1102 | with two null octets.\r | |
e2851998 | 1103 | \r |
f737cfb9 | 1104 | @param This Pointer to the EFI_PXE_BASE_CODE_PROTOCOL instance.\r |
1105 | @param Operation The type of operation to perform.\r | |
e2851998 | 1106 | @param BufferPtr A pointer to the data buffer.\r |
f737cfb9 | 1107 | @param Overwrite Only used on write file operations. TRUE if a file on a remote server can\r |
e2851998 | 1108 | be overwritten.\r |
f737cfb9 | 1109 | @param BufferSize For get-file-size operations, *BufferSize returns the size of the\r |
e2851998 | 1110 | requested file.\r |
f737cfb9 | 1111 | @param BlockSize The requested block size to be used during a TFTP transfer.\r |
1112 | @param ServerIp The TFTP / MTFTP server IP address.\r | |
1113 | @param Filename A Null-terminated ASCII string that specifies a directory name or a file\r | |
e2851998 | 1114 | name.\r |
f737cfb9 | 1115 | @param Info Pointer to the MTFTP information.\r |
e2851998 | 1116 | @param DontUseBuffer Set to FALSE for normal TFTP and MTFTP read file operation.\r |
1117 | \r | |
f737cfb9 | 1118 | @retval EFI_SUCCESS The TFTP/MTFTP operation was completed.\r |
1119 | @retval EFI_NOT_STARTED The PXE Base Code Protocol is in the stopped state.\r | |
e2851998 | 1120 | @retval EFI_INVALID_PARAMETER One or more parameters are invalid.\r |
1121 | @retval EFI_DEVICE_ERROR The network device encountered an error during this operation.\r | |
1122 | @retval EFI_BUFFER_TOO_SMALL The buffer is not large enough to complete the read operation.\r | |
f737cfb9 | 1123 | @retval EFI_ABORTED The callback function aborted the TFTP/MTFTP operation.\r |
1124 | @retval EFI_TIMEOUT The TFTP/MTFTP operation timed out.\r | |
1125 | @retval EFI_ICMP_ERROR An ICMP error packet was received during the MTFTP session.\r | |
1126 | @retval EFI_TFTP_ERROR A TFTP error packet was received during the MTFTP session.\r | |
e2851998 | 1127 | \r |
dc361cc5 | 1128 | **/\r |
1129 | EFI_STATUS\r | |
1130 | EFIAPI\r | |
1131 | EfiPxeBcMtftp (\r | |
1132 | IN EFI_PXE_BASE_CODE_PROTOCOL *This,\r | |
1133 | IN EFI_PXE_BASE_CODE_TFTP_OPCODE Operation,\r | |
1134 | IN OUT VOID *BufferPtr,\r | |
1135 | IN BOOLEAN Overwrite,\r | |
1136 | IN OUT UINT64 *BufferSize,\r | |
1137 | IN UINTN *BlockSize OPTIONAL,\r | |
1138 | IN EFI_IP_ADDRESS *ServerIp,\r | |
1139 | IN UINT8 *Filename,\r | |
1140 | IN EFI_PXE_BASE_CODE_MTFTP_INFO *Info OPTIONAL,\r | |
1141 | IN BOOLEAN DontUseBuffer\r | |
1142 | )\r | |
1143 | {\r | |
8730386e | 1144 | PXEBC_PRIVATE_DATA *Private;\r |
1145 | EFI_MTFTP4_CONFIG_DATA Mtftp4Config;\r | |
1146 | EFI_STATUS Status;\r | |
1147 | EFI_PXE_BASE_CODE_MODE *Mode;\r | |
1148 | EFI_MAC_ADDRESS TempMacAddr;\r | |
1149 | EFI_PXE_BASE_CODE_IP_FILTER IpFilter;\r | |
dc361cc5 | 1150 | \r |
f6b7393c | 1151 | if ((This == NULL) ||\r |
1152 | (Filename == NULL) ||\r | |
1153 | (BufferSize == NULL) ||\r | |
1154 | ((ServerIp == NULL) || !NetIp4IsUnicast (NTOHL (ServerIp->Addr[0]), 0)) ||\r | |
1155 | ((BufferPtr == NULL) && DontUseBuffer) ||\r | |
dc361cc5 | 1156 | ((BlockSize != NULL) && (*BlockSize < 512))) {\r |
1157 | \r | |
1158 | return EFI_INVALID_PARAMETER;\r | |
1159 | }\r | |
1160 | \r | |
1161 | Status = EFI_DEVICE_ERROR;\r | |
1162 | Private = PXEBC_PRIVATE_DATA_FROM_PXEBC (This);\r | |
982a9eae | 1163 | Mode = &Private->Mode;\r |
1164 | \r | |
1165 | if (!Mode->AutoArp) {\r | |
1166 | //\r | |
1167 | // If AutoArp is set false, check arp cache\r | |
1168 | //\r | |
1169 | UpdateArpCache (This);\r | |
1170 | if (!FindInArpCache (Mode, &ServerIp->v4, &TempMacAddr)) {\r | |
1171 | return EFI_DEVICE_ERROR;\r | |
1172 | }\r | |
1173 | }\r | |
1174 | \r | |
8730386e | 1175 | //\r |
1176 | // Stop Udp4Read instance\r | |
1177 | //\r | |
1178 | Private->Udp4Read->Configure (Private->Udp4Read, NULL);\r | |
1179 | \r | |
982a9eae | 1180 | Mode->TftpErrorReceived = FALSE;\r |
1181 | Mode->IcmpErrorReceived = FALSE;\r | |
dc361cc5 | 1182 | \r |
1183 | Mtftp4Config.UseDefaultSetting = FALSE;\r | |
1184 | Mtftp4Config.TimeoutValue = PXEBC_MTFTP_TIMEOUT;\r | |
1185 | Mtftp4Config.TryCount = PXEBC_MTFTP_RETRIES;\r | |
1186 | \r | |
f737cfb9 | 1187 | CopyMem (\r |
e2851998 | 1188 | &Mtftp4Config.StationIp,\r |
1189 | &Private->StationIp,\r | |
f737cfb9 | 1190 | sizeof (EFI_IPv4_ADDRESS)\r |
1191 | );\r | |
1192 | CopyMem (\r | |
e2851998 | 1193 | &Mtftp4Config.SubnetMask,\r |
1194 | &Private->SubnetMask,\r | |
f737cfb9 | 1195 | sizeof (EFI_IPv4_ADDRESS)\r |
1196 | );\r | |
1197 | CopyMem (\r | |
e2851998 | 1198 | &Mtftp4Config.GatewayIp,\r |
1199 | &Private->GatewayIp,\r | |
f737cfb9 | 1200 | sizeof (EFI_IPv4_ADDRESS)\r |
1201 | );\r | |
1202 | CopyMem (\r | |
e2851998 | 1203 | &Mtftp4Config.ServerIp,\r |
1204 | ServerIp,\r | |
f737cfb9 | 1205 | sizeof (EFI_IPv4_ADDRESS)\r |
1206 | );\r | |
dc361cc5 | 1207 | \r |
1208 | switch (Operation) {\r | |
1209 | \r | |
1210 | case EFI_PXE_BASE_CODE_TFTP_GET_FILE_SIZE:\r | |
1211 | \r | |
1212 | Status = PxeBcTftpGetFileSize (\r | |
1213 | Private,\r | |
1214 | &Mtftp4Config,\r | |
1215 | Filename,\r | |
1216 | BlockSize,\r | |
1217 | BufferSize\r | |
1218 | );\r | |
1219 | \r | |
dc361cc5 | 1220 | break;\r |
1221 | \r | |
1222 | case EFI_PXE_BASE_CODE_TFTP_READ_FILE:\r | |
1223 | \r | |
1224 | Status = PxeBcTftpReadFile (\r | |
1225 | Private,\r | |
1226 | &Mtftp4Config,\r | |
1227 | Filename,\r | |
1228 | BlockSize,\r | |
1229 | BufferPtr,\r | |
1230 | BufferSize,\r | |
1231 | DontUseBuffer\r | |
1232 | );\r | |
1233 | \r | |
1234 | break;\r | |
1235 | \r | |
1236 | case EFI_PXE_BASE_CODE_TFTP_WRITE_FILE:\r | |
1237 | \r | |
1238 | Status = PxeBcTftpWriteFile (\r | |
1239 | Private,\r | |
1240 | &Mtftp4Config,\r | |
1241 | Filename,\r | |
1242 | Overwrite,\r | |
1243 | BlockSize,\r | |
1244 | BufferPtr,\r | |
1245 | BufferSize\r | |
1246 | );\r | |
1247 | \r | |
1248 | break;\r | |
1249 | \r | |
1250 | case EFI_PXE_BASE_CODE_TFTP_READ_DIRECTORY:\r | |
1251 | \r | |
1252 | Status = PxeBcTftpReadDirectory (\r | |
1253 | Private,\r | |
1254 | &Mtftp4Config,\r | |
1255 | Filename,\r | |
1256 | BlockSize,\r | |
1257 | BufferPtr,\r | |
1258 | BufferSize,\r | |
1259 | DontUseBuffer\r | |
1260 | );\r | |
1261 | \r | |
1262 | break;\r | |
1263 | \r | |
1264 | case EFI_PXE_BASE_CODE_MTFTP_GET_FILE_SIZE:\r | |
1265 | case EFI_PXE_BASE_CODE_MTFTP_READ_FILE:\r | |
1266 | case EFI_PXE_BASE_CODE_MTFTP_READ_DIRECTORY:\r | |
1267 | Status = EFI_UNSUPPORTED;\r | |
1268 | break;\r | |
1269 | \r | |
1270 | default:\r | |
1271 | \r | |
1272 | Status = EFI_INVALID_PARAMETER;\r | |
1273 | break;\r | |
1274 | }\r | |
1275 | \r | |
982a9eae | 1276 | if (Status == EFI_ICMP_ERROR) {\r |
1277 | Mode->IcmpErrorReceived = TRUE;\r | |
1278 | }\r | |
1279 | \r | |
0bc17488 | 1280 | if (EFI_ERROR (Status)) {\r |
357af285 | 1281 | goto ON_EXIT;\r |
0bc17488 | 1282 | }\r |
1283 | \r | |
357af285 | 1284 | ON_EXIT:\r |
1285 | Private->Udp4Read->Configure (Private->Udp4Read, &Private->Udp4CfgData);\r | |
8730386e | 1286 | //\r |
1287 | // Dhcp(), Discover(), and Mtftp() set the IP filter, and return with the IP \r | |
1288 | // receive filter list emptied and the filter set to EFI_PXE_BASE_CODE_IP_FILTER_STATION_IP.\r | |
1289 | //\r | |
1290 | ZeroMem(&IpFilter, sizeof (EFI_PXE_BASE_CODE_IP_FILTER));\r | |
1291 | IpFilter.Filters = EFI_PXE_BASE_CODE_IP_FILTER_STATION_IP;\r | |
1292 | This->SetIpFilter (This, &IpFilter);\r | |
1293 | \r | |
dc361cc5 | 1294 | return Status;\r |
1295 | }\r | |
1296 | \r | |
1297 | \r | |
e2851998 | 1298 | /**\r |
f737cfb9 | 1299 | Writes a UDP packet to the network interface.\r |
1300 | \r | |
1301 | This function writes a UDP packet specified by the (optional HeaderPtr and)\r | |
1302 | BufferPtr parameters to the network interface. The UDP header is automatically\r | |
1303 | built by this routine. It uses the parameters OpFlags, DestIp, DestPort, GatewayIp,\r | |
1304 | SrcIp, and SrcPort to build this header. If the packet is successfully built and\r | |
1305 | transmitted through the network interface, then EFI_SUCCESS will be returned.\r | |
1306 | If a timeout occurs during the transmission of the packet, then EFI_TIMEOUT will\r | |
1307 | be returned. If an ICMP error occurs during the transmission of the packet, then\r | |
1308 | the IcmpErrorReceived field is set to TRUE, the IcmpError field is filled in and\r | |
1309 | EFI_ICMP_ERROR will be returned. If the Callback Protocol does not return\r | |
1310 | EFI_PXE_BASE_CODE_CALLBACK_STATUS_CONTINUE, then EFI_ABORTED will be returned.\r | |
e2851998 | 1311 | \r |
f737cfb9 | 1312 | @param This Pointer to the EFI_PXE_BASE_CODE_PROTOCOL instance.\r |
e2851998 | 1313 | @param OpFlags The UDP operation flags.\r |
f737cfb9 | 1314 | @param DestIp The destination IP address.\r |
e2851998 | 1315 | @param DestPort The destination UDP port number.\r |
1316 | @param GatewayIp The gateway IP address.\r | |
f737cfb9 | 1317 | @param SrcIp The source IP address.\r |
1318 | @param SrcPort The source UDP port number.\r | |
1319 | @param HeaderSize An optional field which may be set to the length of a header at\r | |
e2851998 | 1320 | HeaderPtr to be prefixed to the data at BufferPtr.\r |
f737cfb9 | 1321 | @param HeaderPtr If HeaderSize is not NULL, a pointer to a header to be prefixed to the\r |
e2851998 | 1322 | data at BufferPtr.\r |
f737cfb9 | 1323 | @param BufferSize A pointer to the size of the data at BufferPtr.\r |
1324 | @param BufferPtr A pointer to the data to be written.\r | |
e2851998 | 1325 | \r |
f737cfb9 | 1326 | @retval EFI_SUCCESS The UDP Write operation was completed.\r |
1327 | @retval EFI_NOT_STARTED The PXE Base Code Protocol is in the stopped state.\r | |
e2851998 | 1328 | @retval EFI_INVALID_PARAMETER One or more parameters are invalid.\r |
1329 | @retval EFI_BAD_BUFFER_SIZE The buffer is too long to be transmitted.\r | |
f737cfb9 | 1330 | @retval EFI_ABORTED The callback function aborted the UDP Write operation.\r |
1331 | @retval EFI_TIMEOUT The UDP Write operation timed out.\r | |
e2851998 | 1332 | @retval EFI_ICMP_ERROR An ICMP error packet was received during the UDP write session.\r |
1333 | \r | |
dc361cc5 | 1334 | **/\r |
1335 | EFI_STATUS\r | |
1336 | EFIAPI\r | |
1337 | EfiPxeBcUdpWrite (\r | |
1338 | IN EFI_PXE_BASE_CODE_PROTOCOL *This,\r | |
1339 | IN UINT16 OpFlags,\r | |
1340 | IN EFI_IP_ADDRESS *DestIp,\r | |
1341 | IN EFI_PXE_BASE_CODE_UDP_PORT *DestPort,\r | |
1342 | IN EFI_IP_ADDRESS *GatewayIp OPTIONAL,\r | |
1343 | IN EFI_IP_ADDRESS *SrcIp OPTIONAL,\r | |
1344 | IN OUT EFI_PXE_BASE_CODE_UDP_PORT *SrcPort OPTIONAL,\r | |
1345 | IN UINTN *HeaderSize OPTIONAL,\r | |
1346 | IN VOID *HeaderPtr OPTIONAL,\r | |
1347 | IN UINTN *BufferSize,\r | |
1348 | IN VOID *BufferPtr\r | |
1349 | )\r | |
1350 | {\r | |
1351 | PXEBC_PRIVATE_DATA *Private;\r | |
1352 | EFI_UDP4_PROTOCOL *Udp4;\r | |
1353 | EFI_UDP4_COMPLETION_TOKEN Token;\r | |
1354 | EFI_UDP4_TRANSMIT_DATA *Udp4TxData;\r | |
1355 | UINT32 FragCount;\r | |
1356 | UINT32 DataLength;\r | |
1357 | EFI_UDP4_SESSION_DATA Udp4Session;\r | |
1358 | EFI_STATUS Status;\r | |
1359 | BOOLEAN IsDone;\r | |
982a9eae | 1360 | EFI_PXE_BASE_CODE_MODE *Mode;\r |
1361 | EFI_MAC_ADDRESS TempMacAddr;\r | |
dc361cc5 | 1362 | \r |
1363 | IsDone = FALSE;\r | |
1364 | \r | |
1365 | if ((This == NULL) || (DestIp == NULL) || (DestPort == NULL)) {\r | |
1366 | return EFI_INVALID_PARAMETER;\r | |
1367 | }\r | |
1368 | \r | |
f6b7393c | 1369 | if ((GatewayIp != NULL) && !NetIp4IsUnicast (NTOHL (GatewayIp->Addr[0]), 0)) {\r |
dc361cc5 | 1370 | //\r |
1371 | // Gateway is provided but it's not a unicast IP address.\r | |
1372 | //\r | |
1373 | return EFI_INVALID_PARAMETER;\r | |
1374 | }\r | |
1375 | \r | |
1376 | if ((HeaderSize != NULL) && ((*HeaderSize == 0) || (HeaderPtr == NULL))) {\r | |
1377 | //\r | |
1378 | // The HeaderSize ptr isn't NULL and: 1. the value is zero; or 2. the HeaderPtr\r | |
1379 | // is NULL.\r | |
1380 | //\r | |
1381 | return EFI_INVALID_PARAMETER;\r | |
1382 | }\r | |
1383 | \r | |
1384 | if ((BufferSize == NULL) || ((*BufferSize != 0) && (BufferPtr == NULL))) {\r | |
1385 | return EFI_INVALID_PARAMETER;\r | |
1386 | }\r | |
1387 | \r | |
1388 | Private = PXEBC_PRIVATE_DATA_FROM_PXEBC (This);\r | |
8792362f | 1389 | Udp4 = Private->Udp4Write;\r |
982a9eae | 1390 | Mode = &Private->Mode;\r |
8792362f | 1391 | if (!Mode->Started) {\r |
1392 | return EFI_NOT_STARTED;\r | |
1393 | }\r | |
dc361cc5 | 1394 | \r |
1395 | if (!Private->AddressIsOk && (SrcIp == NULL)) {\r | |
1396 | return EFI_INVALID_PARAMETER;\r | |
1397 | }\r | |
1398 | \r | |
982a9eae | 1399 | if (!Mode->AutoArp) {\r |
1400 | //\r | |
1401 | // If AutoArp is set false, check arp cache\r | |
1402 | //\r | |
1403 | UpdateArpCache (This);\r | |
1404 | if (!FindInArpCache (Mode, &DestIp->v4, &TempMacAddr)) {\r | |
1405 | return EFI_DEVICE_ERROR;\r | |
1406 | }\r | |
1407 | }\r | |
1408 | \r | |
1409 | Mode->IcmpErrorReceived = FALSE;\r | |
1410 | \r | |
8792362f | 1411 | if ((Private->CurrentUdpSrcPort == 0) ||\r |
f737cfb9 | 1412 | ((SrcPort != NULL) && (*SrcPort != Private->CurrentUdpSrcPort))) {\r |
8792362f | 1413 | //\r |
1414 | // Port is changed, (re)configure the Udp4Write instance\r | |
1415 | //\r | |
1416 | if (SrcPort != NULL) {\r | |
1417 | Private->CurrentUdpSrcPort = *SrcPort;\r | |
dc361cc5 | 1418 | }\r |
dc361cc5 | 1419 | }\r |
1420 | \r | |
2e4c2a04 | 1421 | Status = PxeBcConfigureUdpWriteInstance (\r |
1422 | Udp4,\r | |
1423 | &Private->StationIp.v4,\r | |
1424 | &Private->SubnetMask.v4,\r | |
1425 | &Private->GatewayIp.v4,\r | |
1426 | &Private->CurrentUdpSrcPort\r | |
1427 | );\r | |
1428 | if (EFI_ERROR (Status)) {\r | |
1429 | Private->CurrentUdpSrcPort = 0;\r | |
1430 | return EFI_INVALID_PARAMETER;\r | |
1431 | }\r | |
1432 | \r | |
dc361cc5 | 1433 | ZeroMem (&Token, sizeof (EFI_UDP4_COMPLETION_TOKEN));\r |
1434 | ZeroMem (&Udp4Session, sizeof (EFI_UDP4_SESSION_DATA));\r | |
1435 | \r | |
e48e37fc | 1436 | CopyMem (&Udp4Session.DestinationAddress, DestIp, sizeof (EFI_IPv4_ADDRESS));\r |
dc361cc5 | 1437 | Udp4Session.DestinationPort = *DestPort;\r |
8792362f | 1438 | if (SrcIp != NULL) {\r |
1439 | CopyMem (&Udp4Session.SourceAddress, SrcIp, sizeof (EFI_IPv4_ADDRESS));\r | |
1440 | }\r | |
1441 | if (SrcPort != NULL) {\r | |
1442 | Udp4Session.SourcePort = *SrcPort;\r | |
1443 | }\r | |
dc361cc5 | 1444 | \r |
1445 | FragCount = (HeaderSize != NULL) ? 2 : 1;\r | |
05c0e3cb | 1446 | Udp4TxData = (EFI_UDP4_TRANSMIT_DATA *) AllocateZeroPool (sizeof (EFI_UDP4_TRANSMIT_DATA) + (FragCount - 1) * sizeof (EFI_UDP4_FRAGMENT_DATA));\r |
dc361cc5 | 1447 | if (Udp4TxData == NULL) {\r |
1448 | return EFI_OUT_OF_RESOURCES;\r | |
1449 | }\r | |
1450 | \r | |
1451 | Udp4TxData->FragmentCount = FragCount;\r | |
1452 | Udp4TxData->FragmentTable[FragCount - 1].FragmentLength = (UINT32) *BufferSize;\r | |
1453 | Udp4TxData->FragmentTable[FragCount - 1].FragmentBuffer = BufferPtr;\r | |
1454 | DataLength = (UINT32) *BufferSize;\r | |
1455 | \r | |
1456 | if (FragCount == 2) {\r | |
1457 | \r | |
1458 | Udp4TxData->FragmentTable[0].FragmentLength = (UINT32) *HeaderSize;\r | |
1459 | Udp4TxData->FragmentTable[0].FragmentBuffer = HeaderPtr;\r | |
1460 | DataLength += (UINT32) *HeaderSize;\r | |
1461 | }\r | |
1462 | \r | |
8792362f | 1463 | if (GatewayIp != NULL) {\r |
1464 | Udp4TxData->GatewayAddress = (EFI_IPv4_ADDRESS *) GatewayIp;\r | |
1465 | }\r | |
dc361cc5 | 1466 | Udp4TxData->UdpSessionData = &Udp4Session;\r |
1467 | Udp4TxData->DataLength = DataLength;\r | |
1468 | Token.Packet.TxData = Udp4TxData;\r | |
1469 | \r | |
1470 | Status = gBS->CreateEvent (\r | |
1471 | EVT_NOTIFY_SIGNAL,\r | |
e48e37fc | 1472 | TPL_NOTIFY,\r |
dc361cc5 | 1473 | PxeBcCommonNotify,\r |
1474 | &IsDone,\r | |
1475 | &Token.Event\r | |
1476 | );\r | |
1477 | if (EFI_ERROR (Status)) {\r | |
1478 | goto ON_EXIT;\r | |
1479 | }\r | |
1480 | \r | |
1481 | Status = Udp4->Transmit (Udp4, &Token);\r | |
1482 | if (EFI_ERROR (Status)) {\r | |
982a9eae | 1483 | if (Status == EFI_ICMP_ERROR) {\r |
1484 | Mode->IcmpErrorReceived = TRUE;\r | |
1485 | }\r | |
dc361cc5 | 1486 | goto ON_EXIT;\r |
1487 | }\r | |
1488 | \r | |
1489 | while (!IsDone) {\r | |
1490 | \r | |
1491 | Udp4->Poll (Udp4);\r | |
1492 | }\r | |
1493 | \r | |
1494 | Status = Token.Status;\r | |
1495 | \r | |
1496 | ON_EXIT:\r | |
1497 | \r | |
1498 | if (Token.Event != NULL) {\r | |
1499 | gBS->CloseEvent (Token.Event);\r | |
1500 | }\r | |
1501 | \r | |
766c7483 | 1502 | FreePool (Udp4TxData);\r |
dc361cc5 | 1503 | \r |
2e4c2a04 | 1504 | //\r |
1505 | // Reset the instance.\r | |
1506 | //\r | |
1507 | Udp4->Configure (Udp4, NULL);\r | |
dc361cc5 | 1508 | return Status;\r |
1509 | }\r | |
1510 | \r | |
8d285ec0 | 1511 | /**\r |
f737cfb9 | 1512 | Decide whether the incoming UDP packet is acceptable per IP filter settings\r |
1513 | in provided PxeBcMode.\r | |
8d285ec0 | 1514 | \r |
f737cfb9 | 1515 | @param PxeBcMode Pointer to EFI_PXE_BASE_CODE_MODE.\r |
1516 | @param Session Received UDP session.\r | |
8d285ec0 | 1517 | \r |
f737cfb9 | 1518 | @retval TRUE The UDP package matches IP filters.\r |
1519 | @retval FALSE The UDP package doesn't matches IP filters.\r | |
8d285ec0 | 1520 | \r |
1521 | **/\r | |
8d285ec0 | 1522 | BOOLEAN\r |
1523 | CheckIpByFilter (\r | |
f737cfb9 | 1524 | IN EFI_PXE_BASE_CODE_MODE *PxeBcMode,\r |
1525 | IN EFI_UDP4_SESSION_DATA *Session\r | |
8d285ec0 | 1526 | )\r |
1527 | {\r | |
1528 | UINTN Index;\r | |
1529 | EFI_IPv4_ADDRESS Ip4Address;\r | |
1530 | EFI_IPv4_ADDRESS DestIp4Address;\r | |
1531 | \r | |
f737cfb9 | 1532 | if ((PxeBcMode->IpFilter.Filters & EFI_PXE_BASE_CODE_IP_FILTER_PROMISCUOUS) != 0) {\r |
8d285ec0 | 1533 | return TRUE;\r |
1534 | }\r | |
1535 | \r | |
1536 | CopyMem (&DestIp4Address, &Session->DestinationAddress, sizeof (DestIp4Address));\r | |
e2851998 | 1537 | if (((PxeBcMode->IpFilter.Filters & EFI_PXE_BASE_CODE_IP_FILTER_PROMISCUOUS_MULTICAST) != 0) &&\r |
982a9eae | 1538 | IP4_IS_MULTICAST (EFI_NTOHL (DestIp4Address))\r |
8d285ec0 | 1539 | ) {\r |
1540 | return TRUE;\r | |
1541 | }\r | |
1542 | \r | |
e2851998 | 1543 | if (((PxeBcMode->IpFilter.Filters & EFI_PXE_BASE_CODE_IP_FILTER_BROADCAST) != 0) &&\r |
8d285ec0 | 1544 | IP4_IS_LOCAL_BROADCAST (EFI_NTOHL (DestIp4Address))\r |
1545 | ) {\r | |
1546 | return TRUE;\r | |
1547 | }\r | |
1548 | \r | |
1549 | CopyMem (&Ip4Address, &PxeBcMode->StationIp.v4, sizeof (Ip4Address));\r | |
e2851998 | 1550 | if (((PxeBcMode->IpFilter.Filters & EFI_PXE_BASE_CODE_IP_FILTER_STATION_IP) != 0) &&\r |
982a9eae | 1551 | EFI_IP4_EQUAL (&Ip4Address, &DestIp4Address)\r |
8d285ec0 | 1552 | ) {\r |
1553 | return TRUE;\r | |
1554 | }\r | |
1555 | \r | |
894d038a | 1556 | ASSERT (PxeBcMode->IpFilter.IpCnt < EFI_PXE_BASE_CODE_MAX_IPCNT);\r |
1557 | \r | |
f737cfb9 | 1558 | for (Index = 0; Index < PxeBcMode->IpFilter.IpCnt; Index++) {\r |
1559 | CopyMem (\r | |
e2851998 | 1560 | &Ip4Address,\r |
1561 | &PxeBcMode->IpFilter.IpList[Index].v4,\r | |
f737cfb9 | 1562 | sizeof (Ip4Address)\r |
1563 | );\r | |
8d285ec0 | 1564 | if (EFI_IP4_EQUAL (&Ip4Address, &DestIp4Address)) {\r |
1565 | return TRUE;\r | |
1566 | }\r | |
1567 | }\r | |
1568 | \r | |
1569 | return FALSE;\r | |
1570 | }\r | |
dc361cc5 | 1571 | \r |
e2851998 | 1572 | /**\r |
f737cfb9 | 1573 | Reads a UDP packet from the network interface.\r |
1574 | \r | |
1575 | This function reads a UDP packet from a network interface. The data contents\r | |
1576 | are returned in (the optional HeaderPtr and) BufferPtr, and the size of the\r | |
1577 | buffer received is returned in BufferSize . If the input BufferSize is smaller\r | |
1578 | than the UDP packet received (less optional HeaderSize), it will be set to the\r | |
1579 | required size, and EFI_BUFFER_TOO_SMALL will be returned. In this case, the\r | |
1580 | contents of BufferPtr are undefined, and the packet is lost. If a UDP packet is\r | |
1581 | successfully received, then EFI_SUCCESS will be returned, and the information\r | |
1582 | from the UDP header will be returned in DestIp, DestPort, SrcIp, and SrcPort if\r | |
e2851998 | 1583 | they are not NULL. Depending on the values of OpFlags and the DestIp, DestPort,\r |
1584 | SrcIp, and SrcPort input values, different types of UDP packet receive filtering\r | |
f737cfb9 | 1585 | will be performed. The following tables summarize these receive filter operations.\r |
e2851998 | 1586 | \r |
f737cfb9 | 1587 | @param This Pointer to the EFI_PXE_BASE_CODE_PROTOCOL instance.\r |
e2851998 | 1588 | @param OpFlags The UDP operation flags.\r |
f737cfb9 | 1589 | @param DestIp The destination IP address.\r |
1590 | @param DestPort The destination UDP port number.\r | |
1591 | @param SrcIp The source IP address.\r | |
1592 | @param SrcPort The source UDP port number.\r | |
1593 | @param HeaderSize An optional field which may be set to the length of a header at\r | |
e2851998 | 1594 | HeaderPtr to be prefixed to the data at BufferPtr.\r |
f737cfb9 | 1595 | @param HeaderPtr If HeaderSize is not NULL, a pointer to a header to be prefixed to the\r |
e2851998 | 1596 | data at BufferPtr.\r |
f737cfb9 | 1597 | @param BufferSize A pointer to the size of the data at BufferPtr.\r |
1598 | @param BufferPtr A pointer to the data to be read.\r | |
e2851998 | 1599 | \r |
f737cfb9 | 1600 | @retval EFI_SUCCESS The UDP Read operation was completed.\r |
1601 | @retval EFI_NOT_STARTED The PXE Base Code Protocol is in the stopped state.\r | |
e2851998 | 1602 | @retval EFI_INVALID_PARAMETER One or more parameters are invalid.\r |
f737cfb9 | 1603 | @retval EFI_DEVICE_ERROR The network device encountered an error during this operation.\r |
1604 | @retval EFI_BUFFER_TOO_SMALL The packet is larger than Buffer can hold.\r | |
1605 | @retval EFI_ABORTED The callback function aborted the UDP Read operation.\r | |
e2851998 | 1606 | @retval EFI_TIMEOUT The UDP Read operation timed out.\r |
1607 | \r | |
dc361cc5 | 1608 | **/\r |
1609 | EFI_STATUS\r | |
1610 | EFIAPI\r | |
1611 | EfiPxeBcUdpRead (\r | |
f737cfb9 | 1612 | IN EFI_PXE_BASE_CODE_PROTOCOL *This,\r |
1613 | IN UINT16 OpFlags,\r | |
1614 | IN OUT EFI_IP_ADDRESS *DestIp OPTIONAL,\r | |
1615 | IN OUT EFI_PXE_BASE_CODE_UDP_PORT *DestPort OPTIONAL,\r | |
1616 | IN OUT EFI_IP_ADDRESS *SrcIp OPTIONAL,\r | |
1617 | IN OUT EFI_PXE_BASE_CODE_UDP_PORT *SrcPort OPTIONAL,\r | |
1618 | IN UINTN *HeaderSize OPTIONAL,\r | |
1619 | IN VOID *HeaderPtr OPTIONAL,\r | |
1620 | IN OUT UINTN *BufferSize,\r | |
1621 | IN VOID *BufferPtr\r | |
dc361cc5 | 1622 | )\r |
1623 | {\r | |
1624 | PXEBC_PRIVATE_DATA *Private;\r | |
1625 | EFI_PXE_BASE_CODE_MODE *Mode;\r | |
1626 | EFI_UDP4_PROTOCOL *Udp4;\r | |
1627 | EFI_UDP4_COMPLETION_TOKEN Token;\r | |
1628 | EFI_UDP4_RECEIVE_DATA *RxData;\r | |
1629 | EFI_UDP4_SESSION_DATA *Session;\r | |
1630 | EFI_STATUS Status;\r | |
1631 | BOOLEAN IsDone;\r | |
1632 | BOOLEAN Matched;\r | |
c3cd46d4 | 1633 | UINTN CopiedLen;\r |
1634 | UINTN HeaderLen;\r | |
1635 | UINTN HeaderCopiedLen;\r | |
1636 | UINTN BufferCopiedLen;\r | |
1637 | UINT32 FragmentLength;\r | |
1638 | UINTN FragmentIndex;\r | |
1639 | UINT8 *FragmentBuffer;\r | |
dc361cc5 | 1640 | \r |
1641 | if (This == NULL || DestIp == NULL || DestPort == NULL) {\r | |
1642 | return EFI_INVALID_PARAMETER;\r | |
1643 | }\r | |
1644 | \r | |
f737cfb9 | 1645 | if (((OpFlags & EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_DEST_PORT) == 0 && (DestPort == NULL)) ||\r |
1646 | ((OpFlags & EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_DEST_PORT) == 0 && (SrcIp == NULL)) ||\r | |
1647 | ((OpFlags & EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_SRC_PORT) == 0 && (SrcPort == NULL))) {\r | |
dc361cc5 | 1648 | return EFI_INVALID_PARAMETER;\r |
1649 | }\r | |
1650 | \r | |
8792362f | 1651 | if (((HeaderSize != NULL) && (*HeaderSize == 0)) || ((HeaderSize != NULL) && (HeaderPtr == NULL))) {\r |
dc361cc5 | 1652 | return EFI_INVALID_PARAMETER;\r |
1653 | }\r | |
1654 | \r | |
29a4f92d | 1655 | if ((BufferSize == NULL) || (BufferPtr == NULL)) {\r |
dc361cc5 | 1656 | return EFI_INVALID_PARAMETER;\r |
1657 | }\r | |
1658 | \r | |
1659 | Private = PXEBC_PRIVATE_DATA_FROM_PXEBC (This);\r | |
1660 | Mode = Private->PxeBc.Mode;\r | |
8792362f | 1661 | Udp4 = Private->Udp4Read;\r |
dc361cc5 | 1662 | \r |
1663 | if (!Mode->Started) {\r | |
1664 | return EFI_NOT_STARTED;\r | |
1665 | }\r | |
1666 | \r | |
982a9eae | 1667 | Mode->IcmpErrorReceived = FALSE;\r |
1668 | \r | |
dc361cc5 | 1669 | Status = gBS->CreateEvent (\r |
1670 | EVT_NOTIFY_SIGNAL,\r | |
e48e37fc | 1671 | TPL_NOTIFY,\r |
dc361cc5 | 1672 | PxeBcCommonNotify,\r |
1673 | &IsDone,\r | |
1674 | &Token.Event\r | |
1675 | );\r | |
1676 | if (EFI_ERROR (Status)) {\r | |
1677 | return EFI_OUT_OF_RESOURCES;\r | |
1678 | }\r | |
1679 | \r | |
8792362f | 1680 | TRY_AGAIN:\r |
1681 | \r | |
dc361cc5 | 1682 | IsDone = FALSE;\r |
1683 | Status = Udp4->Receive (Udp4, &Token);\r | |
1684 | if (EFI_ERROR (Status)) {\r | |
982a9eae | 1685 | if (Status == EFI_ICMP_ERROR) {\r |
1686 | Mode->IcmpErrorReceived = TRUE;\r | |
1687 | }\r | |
dc361cc5 | 1688 | goto ON_EXIT;\r |
1689 | }\r | |
1690 | \r | |
1691 | Udp4->Poll (Udp4);\r | |
1692 | \r | |
1693 | if (!IsDone) {\r | |
1694 | Status = EFI_TIMEOUT;\r | |
1695 | } else {\r | |
1696 | \r | |
1697 | //\r | |
1698 | // check whether this packet matches the filters\r | |
1699 | //\r | |
1700 | if (EFI_ERROR (Token.Status)){\r | |
1701 | goto ON_EXIT;\r | |
1702 | }\r | |
1703 | \r | |
1704 | RxData = Token.Packet.RxData;\r | |
1705 | Session = &RxData->UdpSession;\r | |
1706 | \r | |
319075ff | 1707 | Matched = TRUE;\r |
dc361cc5 | 1708 | \r |
f737cfb9 | 1709 | if ((OpFlags & EFI_PXE_BASE_CODE_UDP_OPFLAGS_USE_FILTER) != 0) {\r |
319075ff | 1710 | Matched = FALSE;\r |
8d285ec0 | 1711 | //\r |
1712 | // Check UDP package by IP filter settings\r | |
1713 | //\r | |
1714 | if (CheckIpByFilter (Mode, Session)) {\r | |
1715 | Matched = TRUE;\r | |
dc361cc5 | 1716 | }\r |
8d285ec0 | 1717 | }\r |
1718 | \r | |
1719 | if (Matched) {\r | |
8792362f | 1720 | Matched = FALSE;\r |
1721 | \r | |
8d285ec0 | 1722 | //\r |
1723 | // Match the destination ip of the received udp dgram\r | |
1724 | //\r | |
f737cfb9 | 1725 | if ((OpFlags & EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_DEST_IP) != 0) {\r |
8d285ec0 | 1726 | Matched = TRUE;\r |
1727 | \r | |
1728 | if (DestIp != NULL) {\r | |
1729 | CopyMem (DestIp, &Session->DestinationAddress, sizeof (EFI_IPv4_ADDRESS));\r | |
dc361cc5 | 1730 | }\r |
1731 | } else {\r | |
8d285ec0 | 1732 | if (DestIp != NULL) {\r |
1733 | if (EFI_IP4_EQUAL (DestIp, &Session->DestinationAddress)) {\r | |
1734 | Matched = TRUE;\r | |
1735 | }\r | |
1736 | } else {\r | |
1737 | if (EFI_IP4_EQUAL (&Private->StationIp, &Session->DestinationAddress)) {\r | |
1738 | Matched = TRUE;\r | |
1739 | }\r | |
dc361cc5 | 1740 | }\r |
1741 | }\r | |
1742 | }\r | |
1743 | \r | |
1744 | if (Matched) {\r | |
1745 | //\r | |
1746 | // Match the destination port of the received udp dgram\r | |
1747 | //\r | |
f737cfb9 | 1748 | if ((OpFlags & EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_DEST_PORT) != 0) {\r |
dc361cc5 | 1749 | \r |
1750 | if (DestPort != NULL) {\r | |
1751 | *DestPort = Session->DestinationPort;\r | |
1752 | }\r | |
1753 | } else {\r | |
1754 | \r | |
1755 | if (*DestPort != Session->DestinationPort) {\r | |
1756 | Matched = FALSE;\r | |
1757 | }\r | |
1758 | }\r | |
1759 | }\r | |
1760 | \r | |
1761 | if (Matched) {\r | |
1762 | //\r | |
1763 | // Match the source ip of the received udp dgram\r | |
1764 | //\r | |
f737cfb9 | 1765 | if ((OpFlags & EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_SRC_IP) != 0) {\r |
dc361cc5 | 1766 | \r |
1767 | if (SrcIp != NULL) {\r | |
e48e37fc | 1768 | CopyMem (SrcIp, &Session->SourceAddress, sizeof (EFI_IPv4_ADDRESS));\r |
dc361cc5 | 1769 | }\r |
1770 | } else {\r | |
1771 | \r | |
1772 | if (!EFI_IP4_EQUAL (SrcIp, &Session->SourceAddress)) {\r | |
1773 | Matched = FALSE;\r | |
1774 | }\r | |
1775 | }\r | |
1776 | }\r | |
1777 | \r | |
1778 | if (Matched) {\r | |
1779 | //\r | |
1780 | // Match the source port of the received udp dgram\r | |
1781 | //\r | |
f737cfb9 | 1782 | if ((OpFlags & EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_SRC_PORT) != 0) {\r |
dc361cc5 | 1783 | \r |
1784 | if (SrcPort != NULL) {\r | |
1785 | *SrcPort = Session->SourcePort;\r | |
1786 | }\r | |
1787 | } else {\r | |
1788 | \r | |
1789 | if (*SrcPort != Session->SourcePort) {\r | |
1790 | Matched = FALSE;\r | |
1791 | }\r | |
1792 | }\r | |
1793 | }\r | |
1794 | \r | |
1795 | if (Matched) {\r | |
c3cd46d4 | 1796 | ASSERT (RxData != NULL);\r |
dc361cc5 | 1797 | \r |
c3cd46d4 | 1798 | HeaderLen = 0;\r |
dc361cc5 | 1799 | if (HeaderSize != NULL) {\r |
c3cd46d4 | 1800 | HeaderLen = MIN (*HeaderSize, RxData->DataLength);\r |
dc361cc5 | 1801 | }\r |
1802 | \r | |
c3cd46d4 | 1803 | if (RxData->DataLength - HeaderLen > *BufferSize) {\r |
dc361cc5 | 1804 | Status = EFI_BUFFER_TOO_SMALL;\r |
1805 | } else {\r | |
c3cd46d4 | 1806 | *HeaderSize = HeaderLen;\r |
1807 | *BufferSize = RxData->DataLength - HeaderLen;\r | |
1808 | \r | |
1809 | HeaderCopiedLen = 0;\r | |
1810 | BufferCopiedLen = 0;\r | |
1811 | for (FragmentIndex = 0; FragmentIndex < RxData->FragmentCount; FragmentIndex++) {\r | |
1812 | FragmentLength = RxData->FragmentTable[FragmentIndex].FragmentLength;\r | |
1813 | FragmentBuffer = RxData->FragmentTable[FragmentIndex].FragmentBuffer;\r | |
1814 | if (HeaderCopiedLen + FragmentLength < HeaderLen) {\r | |
1815 | //\r | |
1816 | // Copy the header part of received data.\r | |
1817 | //\r | |
1818 | CopyMem ((UINT8 *) HeaderPtr + HeaderCopiedLen, FragmentBuffer, FragmentLength);\r | |
1819 | HeaderCopiedLen += FragmentLength;\r | |
1820 | } else if (HeaderCopiedLen < HeaderLen) {\r | |
1821 | //\r | |
1822 | // Copy the header part of received data.\r | |
1823 | //\r | |
1824 | CopiedLen = HeaderLen - HeaderCopiedLen;\r | |
1825 | CopyMem ((UINT8 *) HeaderPtr + HeaderCopiedLen, FragmentBuffer, CopiedLen);\r | |
1826 | HeaderCopiedLen += CopiedLen;\r | |
1827 | \r | |
1828 | //\r | |
1829 | // Copy the other part of received data.\r | |
1830 | //\r | |
1831 | CopyMem ((UINT8 *) BufferPtr + BufferCopiedLen, FragmentBuffer + CopiedLen, FragmentLength - CopiedLen);\r | |
1832 | BufferCopiedLen += (FragmentLength - CopiedLen);\r | |
1833 | } else {\r | |
1834 | //\r | |
1835 | // Copy the other part of received data.\r | |
1836 | //\r | |
1837 | CopyMem ((UINT8 *) BufferPtr + BufferCopiedLen, FragmentBuffer, FragmentLength);\r | |
1838 | BufferCopiedLen += FragmentLength;\r | |
1839 | }\r | |
1840 | }\r | |
dc361cc5 | 1841 | }\r |
1842 | } else {\r | |
1843 | \r | |
1844 | Status = EFI_TIMEOUT;\r | |
1845 | }\r | |
1846 | \r | |
1847 | //\r | |
1848 | // Recycle the RxData\r | |
1849 | //\r | |
1850 | gBS->SignalEvent (RxData->RecycleSignal);\r | |
8792362f | 1851 | \r |
1852 | if (!Matched) {\r | |
1853 | goto TRY_AGAIN;\r | |
1854 | }\r | |
dc361cc5 | 1855 | }\r |
1856 | \r | |
1857 | ON_EXIT:\r | |
1858 | \r | |
1859 | Udp4->Cancel (Udp4, &Token);\r | |
1860 | \r | |
1861 | gBS->CloseEvent (Token.Event);\r | |
1862 | \r | |
1863 | return Status;\r | |
1864 | }\r | |
1865 | \r | |
e2851998 | 1866 | /**\r |
f737cfb9 | 1867 | Updates the IP receive filters of a network device and enables software filtering.\r |
e2851998 | 1868 | \r |
f737cfb9 | 1869 | The NewFilter field is used to modify the network device's current IP receive\r |
1870 | filter settings and to enable a software filter. This function updates the IpFilter\r | |
1871 | field of the EFI_PXE_BASE_CODE_MODE structure with the contents of NewIpFilter.\r | |
1872 | The software filter is used when the USE_FILTER in OpFlags is set to UdpRead().\r | |
1873 | The current hardware filter remains in effect no matter what the settings of OpFlags\r | |
1874 | are, so that the meaning of ANY_DEST_IP set in OpFlags to UdpRead() is from those\r | |
1875 | packets whose reception is enabled in hardware-physical NIC address (unicast),\r | |
1876 | broadcast address, logical address or addresses (multicast), or all (promiscuous).\r | |
1877 | UdpRead() does not modify the IP filter settings.\r | |
1878 | Dhcp(), Discover(), and Mtftp() set the IP filter, and return with the IP receive\r | |
1879 | filter list emptied and the filter set to EFI_PXE_BASE_CODE_IP_FILTER_STATION_IP.\r | |
1880 | If an application or driver wishes to preserve the IP receive filter settings,\r | |
1881 | it will have to preserve the IP receive filter settings before these calls, and\r | |
1882 | use SetIpFilter() to restore them after the calls. If incompatible filtering is\r | |
1883 | requested (for example, PROMISCUOUS with anything else) or if the device does not\r | |
1884 | support a requested filter setting and it cannot be accommodated in software\r | |
1885 | (for example, PROMISCUOUS not supported), EFI_INVALID_PARAMETER will be returned.\r | |
1886 | The IPlist field is used to enable IPs other than the StationIP. They may be\r | |
1887 | multicast or unicast. If IPcnt is set as well as EFI_PXE_BASE_CODE_IP_FILTER_STATION_IP,\r | |
1888 | then both the StationIP and the IPs from the IPlist will be used.\r | |
e2851998 | 1889 | \r |
f737cfb9 | 1890 | @param This Pointer to the EFI_PXE_BASE_CODE_PROTOCOL instance.\r |
1891 | @param NewFilter Pointer to the new set of IP receive filters.\r | |
e2851998 | 1892 | \r |
f737cfb9 | 1893 | @retval EFI_SUCCESS The IP receive filter settings were updated.\r |
1894 | @retval EFI_NOT_STARTED The PXE Base Code Protocol is in the stopped state.\r | |
e2851998 | 1895 | @retval EFI_INVALID_PARAMETER One or more parameters are invalid.\r |
1896 | \r | |
dc361cc5 | 1897 | **/\r |
1898 | EFI_STATUS\r | |
1899 | EFIAPI\r | |
1900 | EfiPxeBcSetIpFilter (\r | |
1901 | IN EFI_PXE_BASE_CODE_PROTOCOL *This,\r | |
1902 | IN EFI_PXE_BASE_CODE_IP_FILTER *NewFilter\r | |
1903 | )\r | |
1904 | {\r | |
8d285ec0 | 1905 | EFI_STATUS Status;\r |
1906 | PXEBC_PRIVATE_DATA *Private;\r | |
1907 | EFI_PXE_BASE_CODE_MODE *Mode;\r | |
1908 | UINTN Index;\r | |
c82291bc | 1909 | EFI_UDP4_CONFIG_DATA *Udp4Cfg;\r |
8d285ec0 | 1910 | BOOLEAN PromiscuousNeed;\r |
c82291bc | 1911 | BOOLEAN AcceptPromiscuous;\r |
1912 | BOOLEAN AcceptBroadcast;\r | |
1913 | BOOLEAN MultiCastUpdate;\r | |
8d285ec0 | 1914 | \r |
1915 | if (This == NULL) {\r | |
894d038a | 1916 | DEBUG ((EFI_D_ERROR, "This == NULL.\n"));\r |
8d285ec0 | 1917 | return EFI_INVALID_PARAMETER;\r |
1918 | }\r | |
1919 | \r | |
1920 | Private = PXEBC_PRIVATE_DATA_FROM_PXEBC (This);\r | |
1921 | Mode = Private->PxeBc.Mode;\r | |
1922 | \r | |
894d038a | 1923 | if (NewFilter == NULL) {\r |
1924 | DEBUG ((EFI_D_ERROR, "NewFilter == NULL.\n"));\r | |
8d285ec0 | 1925 | return EFI_INVALID_PARAMETER;\r |
1926 | }\r | |
1927 | \r | |
894d038a | 1928 | if (NewFilter->IpCnt > EFI_PXE_BASE_CODE_MAX_IPCNT) {\r |
1929 | DEBUG ((EFI_D_ERROR, "NewFilter->IpCnt > %d.\n", EFI_PXE_BASE_CODE_MAX_IPCNT));\r | |
8d285ec0 | 1930 | return EFI_INVALID_PARAMETER;\r |
1931 | }\r | |
1932 | \r | |
1933 | if (!Mode->Started) {\r | |
1934 | DEBUG ((EFI_D_ERROR, "BC was not started.\n"));\r | |
1935 | return EFI_NOT_STARTED;\r | |
1936 | }\r | |
1937 | \r | |
c82291bc | 1938 | if (Mode->UsingIpv6) {\r |
1939 | DEBUG ((EFI_D_ERROR, "This driver is PXE for IPv4 Only.\n"));\r | |
1940 | return EFI_INVALID_PARAMETER;\r | |
1941 | }\r | |
1942 | \r | |
8d285ec0 | 1943 | PromiscuousNeed = FALSE;\r |
894d038a | 1944 | \r |
8d285ec0 | 1945 | for (Index = 0; Index < NewFilter->IpCnt; ++Index) {\r |
1946 | if (IP4_IS_LOCAL_BROADCAST (EFI_IP4 (NewFilter->IpList[Index].v4))) {\r | |
1947 | //\r | |
1948 | // The IP is a broadcast address.\r | |
1949 | //\r | |
1950 | DEBUG ((EFI_D_ERROR, "There is broadcast address in NewFilter.\n"));\r | |
1951 | return EFI_INVALID_PARAMETER;\r | |
1952 | }\r | |
f6b7393c | 1953 | if (NetIp4IsUnicast (EFI_IP4 (NewFilter->IpList[Index].v4), 0) &&\r |
e2851998 | 1954 | ((NewFilter->Filters & EFI_PXE_BASE_CODE_IP_FILTER_STATION_IP) != 0)\r |
8d285ec0 | 1955 | ) {\r |
1956 | //\r | |
1957 | // If EFI_PXE_BASE_CODE_IP_FILTER_STATION_IP is set and IP4 address is in IpList,\r | |
1958 | // promiscuous mode is needed.\r | |
1959 | //\r | |
1960 | PromiscuousNeed = TRUE;\r | |
1961 | }\r | |
1962 | }\r | |
1963 | \r | |
c82291bc | 1964 | AcceptPromiscuous = FALSE;\r |
1965 | AcceptBroadcast = FALSE;\r | |
1966 | MultiCastUpdate = FALSE;\r | |
8d285ec0 | 1967 | \r |
1968 | if (PromiscuousNeed ||\r | |
e2851998 | 1969 | ((NewFilter->Filters & EFI_PXE_BASE_CODE_IP_FILTER_PROMISCUOUS) != 0) ||\r |
1970 | ((NewFilter->Filters & EFI_PXE_BASE_CODE_IP_FILTER_PROMISCUOUS_MULTICAST) != 0)\r | |
8d285ec0 | 1971 | ) {\r |
1972 | //\r | |
c82291bc | 1973 | // Configure the udp4 filter to receive all packages.\r |
8d285ec0 | 1974 | //\r |
c82291bc | 1975 | AcceptPromiscuous = TRUE;\r |
1976 | } else if ((NewFilter->Filters & EFI_PXE_BASE_CODE_IP_FILTER_BROADCAST) != 0) {\r | |
8d285ec0 | 1977 | //\r |
c82291bc | 1978 | // Configure the udp4 filter to receive all broadcast packages.\r |
8d285ec0 | 1979 | //\r |
c82291bc | 1980 | AcceptBroadcast = TRUE;\r |
1981 | }\r | |
8d285ec0 | 1982 | \r |
c82291bc | 1983 | //\r |
1984 | // In multicast condition when Promiscuous FALSE and IpCnt no-zero.\r | |
1985 | // Here check if there is any update of the multicast ip address. If yes,\r | |
1986 | // we need leave the old multicast group (by Config UDP instance to NULL),\r | |
1987 | // and join the new multicast group.\r | |
1988 | //\r | |
1989 | if (!AcceptPromiscuous) {\r | |
1990 | if ((NewFilter->Filters & EFI_PXE_BASE_CODE_IP_FILTER_STATION_IP) != 0) {\r | |
1991 | if (Mode->IpFilter.IpCnt != NewFilter->IpCnt) {\r | |
1992 | MultiCastUpdate = TRUE;\r | |
1993 | } else if (CompareMem (Mode->IpFilter.IpList, NewFilter->IpList, NewFilter->IpCnt * sizeof (EFI_IP_ADDRESS)) != 0 ) {\r | |
1994 | MultiCastUpdate = TRUE;\r | |
1995 | }\r | |
8d285ec0 | 1996 | }\r |
c82291bc | 1997 | }\r |
1998 | \r | |
1999 | //\r | |
2000 | // Check whether we need reconfigure the UDP instance.\r | |
2001 | //\r | |
2002 | Udp4Cfg = &Private->Udp4CfgData;\r | |
2003 | if ((AcceptPromiscuous != Udp4Cfg->AcceptPromiscuous) ||\r | |
2004 | (AcceptBroadcast != Udp4Cfg->AcceptBroadcast) || MultiCastUpdate) {\r | |
2005 | //\r | |
2006 | // Clear the UDP instance configuration, all joined groups will be left\r | |
2007 | // during the operation.\r | |
2008 | //\r | |
2009 | Private->Udp4Read->Configure (Private->Udp4Read, NULL);\r | |
8d285ec0 | 2010 | \r |
2011 | //\r | |
2012 | // Configure the UDP instance with the new configuration.\r | |
2013 | //\r | |
c82291bc | 2014 | Udp4Cfg->AcceptPromiscuous = AcceptPromiscuous;\r |
2015 | Udp4Cfg->AcceptBroadcast = AcceptBroadcast;\r | |
2016 | Status = Private->Udp4Read->Configure (Private->Udp4Read, Udp4Cfg);\r | |
8d285ec0 | 2017 | if (EFI_ERROR (Status)) {\r |
2018 | return Status;\r | |
2019 | }\r | |
2020 | \r | |
c82291bc | 2021 | //\r |
2022 | // In not Promiscuous mode, need to join the new multicast group.\r | |
2023 | //\r | |
2024 | if (!AcceptPromiscuous) {\r | |
8d285ec0 | 2025 | for (Index = 0; Index < NewFilter->IpCnt; ++Index) {\r |
2026 | if (IP4_IS_MULTICAST (EFI_NTOHL (NewFilter->IpList[Index].v4))) {\r | |
2027 | //\r | |
c82291bc | 2028 | // Join the mutilcast group.\r |
8d285ec0 | 2029 | //\r |
8792362f | 2030 | Status = Private->Udp4Read->Groups (Private->Udp4Read, TRUE, &NewFilter->IpList[Index].v4);\r |
8d285ec0 | 2031 | if (EFI_ERROR (Status)) {\r |
2032 | return Status;\r | |
2033 | }\r | |
2034 | }\r | |
2035 | }\r | |
2036 | }\r | |
2037 | }\r | |
2038 | \r | |
2039 | \r | |
2040 | //\r | |
2041 | // Save the new filter.\r | |
2042 | //\r | |
2043 | CopyMem (&Mode->IpFilter, NewFilter, sizeof (Mode->IpFilter));\r | |
2044 | \r | |
2045 | return EFI_SUCCESS;\r | |
dc361cc5 | 2046 | }\r |
2047 | \r | |
2048 | \r | |
e2851998 | 2049 | /**\r |
f737cfb9 | 2050 | Uses the ARP protocol to resolve a MAC address.\r |
e2851998 | 2051 | \r |
f737cfb9 | 2052 | This function uses the ARP protocol to resolve a MAC address. The UsingIpv6 field\r |
2053 | of the EFI_PXE_BASE_CODE_MODE structure is used to determine if IPv4 or IPv6\r | |
2054 | addresses are being used. The IP address specified by IpAddr is used to resolve\r | |
2055 | a MAC address. If the ARP protocol succeeds in resolving the specified address,\r | |
2056 | then the ArpCacheEntries and ArpCache fields of the EFI_PXE_BASE_CODE_MODE structure\r | |
2057 | are updated, and EFI_SUCCESS is returned. If MacAddr is not NULL, the resolved\r | |
e2851998 | 2058 | MAC address is placed there as well. If the PXE Base Code protocol is in the\r |
2059 | stopped state, then EFI_NOT_STARTED is returned. If the ARP protocol encounters\r | |
2060 | a timeout condition while attempting to resolve an address, then EFI_TIMEOUT is\r | |
2061 | returned. If the Callback Protocol does not return EFI_PXE_BASE_CODE_CALLBACK_STATUS_CONTINUE,\r | |
f737cfb9 | 2062 | then EFI_ABORTED is returned.\r |
e2851998 | 2063 | \r |
f737cfb9 | 2064 | @param This Pointer to the EFI_PXE_BASE_CODE_PROTOCOL instance.\r |
2065 | @param IpAddr Pointer to the IP address that is used to resolve a MAC address.\r | |
2066 | @param MacAddr If not NULL, a pointer to the MAC address that was resolved with the\r | |
e2851998 | 2067 | ARP protocol.\r |
2068 | \r | |
f737cfb9 | 2069 | @retval EFI_SUCCESS The IP or MAC address was resolved.\r |
2070 | @retval EFI_NOT_STARTED The PXE Base Code Protocol is in the stopped state.\r | |
e2851998 | 2071 | @retval EFI_INVALID_PARAMETER One or more parameters are invalid.\r |
2072 | @retval EFI_DEVICE_ERROR The network device encountered an error during this operation.\r | |
2073 | @retval EFI_ICMP_ERROR Something error occur with the ICMP packet message.\r | |
2074 | \r | |
dc361cc5 | 2075 | **/\r |
2076 | EFI_STATUS\r | |
2077 | EFIAPI\r | |
2078 | EfiPxeBcArp (\r | |
2079 | IN EFI_PXE_BASE_CODE_PROTOCOL * This,\r | |
2080 | IN EFI_IP_ADDRESS * IpAddr,\r | |
2081 | IN EFI_MAC_ADDRESS * MacAddr OPTIONAL\r | |
2082 | )\r | |
2083 | {\r | |
8d285ec0 | 2084 | PXEBC_PRIVATE_DATA *Private;\r |
2085 | EFI_PXE_BASE_CODE_MODE *Mode;\r | |
2086 | EFI_STATUS Status;\r | |
2087 | EFI_MAC_ADDRESS TempMacAddr;\r | |
2088 | \r | |
2089 | if (This == NULL || IpAddr == NULL) {\r | |
2090 | return EFI_INVALID_PARAMETER;\r | |
2091 | }\r | |
2092 | \r | |
2093 | Private = PXEBC_PRIVATE_DATA_FROM_PXEBC (This);\r | |
2094 | Mode = Private->PxeBc.Mode;\r | |
2095 | \r | |
2096 | if (!Mode->Started) {\r | |
2097 | return EFI_NOT_STARTED;\r | |
2098 | }\r | |
2099 | \r | |
2100 | if (!Private->AddressIsOk || Mode->UsingIpv6) {\r | |
2101 | //\r | |
2102 | // We can't resolve the IP address if we don't have a local address now.\r | |
2103 | // Don't have ARP for IPv6.\r | |
2104 | //\r | |
2105 | return EFI_INVALID_PARAMETER;\r | |
2106 | }\r | |
2107 | \r | |
982a9eae | 2108 | Mode->IcmpErrorReceived = FALSE;\r |
2109 | \r | |
2110 | if (!Mode->AutoArp) {\r | |
2111 | //\r | |
2112 | // If AutoArp is set false, check arp cache\r | |
2113 | //\r | |
2114 | UpdateArpCache (This);\r | |
2115 | if (!FindInArpCache (Mode, &IpAddr->v4, &TempMacAddr)) {\r | |
2116 | return EFI_DEVICE_ERROR;\r | |
2117 | }\r | |
2118 | } else {\r | |
2119 | Status = Private->Arp->Request (Private->Arp, &IpAddr->v4, NULL, &TempMacAddr);\r | |
2120 | if (EFI_ERROR (Status)) {\r | |
2121 | if (Status == EFI_ICMP_ERROR) {\r | |
2122 | Mode->IcmpErrorReceived = TRUE;\r | |
2123 | }\r | |
2124 | return Status;\r | |
2125 | }\r | |
8d285ec0 | 2126 | }\r |
2127 | \r | |
2128 | if (MacAddr != NULL) {\r | |
2129 | CopyMem (MacAddr, &TempMacAddr, sizeof (EFI_MAC_ADDRESS));\r | |
2130 | }\r | |
2131 | \r | |
2132 | return EFI_SUCCESS;\r | |
dc361cc5 | 2133 | }\r |
2134 | \r | |
e2851998 | 2135 | /**\r |
f737cfb9 | 2136 | Updates the parameters that affect the operation of the PXE Base Code Protocol.\r |
e2851998 | 2137 | \r |
f737cfb9 | 2138 | This function sets parameters that affect the operation of the PXE Base Code Protocol.\r |
2139 | The parameter specified by NewAutoArp is used to control the generation of ARP\r | |
2140 | protocol packets. If NewAutoArp is TRUE, then ARP Protocol packets will be generated\r | |
2141 | as required by the PXE Base Code Protocol. If NewAutoArp is FALSE, then no ARP\r | |
2142 | Protocol packets will be generated. In this case, the only mappings that are\r | |
2143 | available are those stored in the ArpCache of the EFI_PXE_BASE_CODE_MODE structure.\r | |
2144 | If there are not enough mappings in the ArpCache to perform a PXE Base Code Protocol\r | |
2145 | service, then the service will fail. This function updates the AutoArp field of\r | |
2146 | the EFI_PXE_BASE_CODE_MODE structure to NewAutoArp.\r | |
2147 | The SetParameters() call must be invoked after a Callback Protocol is installed\r | |
2148 | to enable the use of callbacks.\r | |
e2851998 | 2149 | \r |
f737cfb9 | 2150 | @param This Pointer to the EFI_PXE_BASE_CODE_PROTOCOL instance.\r |
2151 | @param NewAutoArp If not NULL, a pointer to a value that specifies whether to replace the\r | |
e2851998 | 2152 | current value of AutoARP.\r |
f737cfb9 | 2153 | @param NewSendGUID If not NULL, a pointer to a value that specifies whether to replace the\r |
e2851998 | 2154 | current value of SendGUID.\r |
f737cfb9 | 2155 | @param NewTTL If not NULL, a pointer to be used in place of the current value of TTL,\r |
e2851998 | 2156 | the "time to live" field of the IP header.\r |
f737cfb9 | 2157 | @param NewToS If not NULL, a pointer to be used in place of the current value of ToS,\r |
e2851998 | 2158 | the "type of service" field of the IP header.\r |
f737cfb9 | 2159 | @param NewMakeCallback If not NULL, a pointer to a value that specifies whether to replace the\r |
e2851998 | 2160 | current value of the MakeCallback field of the Mode structure.\r |
2161 | \r | |
f737cfb9 | 2162 | @retval EFI_SUCCESS The new parameters values were updated.\r |
2163 | @retval EFI_NOT_STARTED The PXE Base Code Protocol is in the stopped state.\r | |
e2851998 | 2164 | @retval EFI_INVALID_PARAMETER One or more parameters are invalid.\r |
2165 | \r | |
dc361cc5 | 2166 | **/\r |
2167 | EFI_STATUS\r | |
2168 | EFIAPI\r | |
2169 | EfiPxeBcSetParameters (\r | |
2170 | IN EFI_PXE_BASE_CODE_PROTOCOL *This,\r | |
f737cfb9 | 2171 | IN BOOLEAN *NewAutoArp OPTIONAL,\r |
2172 | IN BOOLEAN *NewSendGUID OPTIONAL,\r | |
2173 | IN UINT8 *NewTTL OPTIONAL,\r | |
2174 | IN UINT8 *NewToS OPTIONAL,\r | |
dc361cc5 | 2175 | IN BOOLEAN *NewMakeCallback // OPTIONAL\r |
2176 | )\r | |
2177 | {\r | |
2178 | PXEBC_PRIVATE_DATA *Private;\r | |
2179 | EFI_PXE_BASE_CODE_MODE *Mode;\r | |
2180 | EFI_STATUS Status;\r | |
2181 | \r | |
2182 | Status = EFI_SUCCESS;\r | |
2183 | \r | |
2184 | if (This == NULL) {\r | |
2185 | Status = EFI_INVALID_PARAMETER;\r | |
2186 | goto ON_EXIT;\r | |
2187 | }\r | |
2188 | \r | |
2189 | Private = PXEBC_PRIVATE_DATA_FROM_PXEBC (This);\r | |
2190 | Mode = Private->PxeBc.Mode;\r | |
2191 | \r | |
f737cfb9 | 2192 | if (NewSendGUID != NULL && *NewSendGUID) {\r |
dc361cc5 | 2193 | //\r |
2194 | // FixMe, cann't locate SendGuid\r | |
2195 | //\r | |
2196 | }\r | |
2197 | \r | |
f737cfb9 | 2198 | if (NewMakeCallback != NULL && *NewMakeCallback) {\r |
dc361cc5 | 2199 | \r |
2200 | Status = gBS->HandleProtocol (\r | |
2201 | Private->Controller,\r | |
2202 | &gEfiPxeBaseCodeCallbackProtocolGuid,\r | |
2203 | (VOID **) &Private->PxeBcCallback\r | |
2204 | );\r | |
2205 | if (EFI_ERROR (Status) || (Private->PxeBcCallback->Callback == NULL)) {\r | |
2206 | \r | |
2207 | Status = EFI_INVALID_PARAMETER;\r | |
2208 | goto ON_EXIT;\r | |
2209 | }\r | |
2210 | }\r | |
2211 | \r | |
2212 | if (!Mode->Started) {\r | |
2213 | Status = EFI_NOT_STARTED;\r | |
2214 | goto ON_EXIT;\r | |
2215 | }\r | |
2216 | \r | |
2217 | if (NewMakeCallback != NULL) {\r | |
2218 | \r | |
2219 | if (*NewMakeCallback) {\r | |
2220 | //\r | |
2221 | // Update the Callback protocol.\r | |
2222 | //\r | |
2223 | Status = gBS->HandleProtocol (\r | |
2224 | Private->Controller,\r | |
2225 | &gEfiPxeBaseCodeCallbackProtocolGuid,\r | |
2226 | (VOID **) &Private->PxeBcCallback\r | |
2227 | );\r | |
2228 | \r | |
2229 | if (EFI_ERROR (Status) || (Private->PxeBcCallback->Callback == NULL)) {\r | |
2230 | Status = EFI_INVALID_PARAMETER;\r | |
2231 | goto ON_EXIT;\r | |
2232 | }\r | |
2233 | } else {\r | |
2234 | Private->PxeBcCallback = NULL;\r | |
2235 | }\r | |
2236 | \r | |
2237 | Mode->MakeCallbacks = *NewMakeCallback;\r | |
2238 | }\r | |
2239 | \r | |
2240 | if (NewAutoArp != NULL) {\r | |
2241 | Mode->AutoArp = *NewAutoArp;\r | |
2242 | }\r | |
2243 | \r | |
2244 | if (NewSendGUID != NULL) {\r | |
2245 | Mode->SendGUID = *NewSendGUID;\r | |
2246 | }\r | |
2247 | \r | |
2248 | if (NewTTL != NULL) {\r | |
2249 | Mode->TTL = *NewTTL;\r | |
2250 | }\r | |
2251 | \r | |
2252 | if (NewToS != NULL) {\r | |
2253 | Mode->ToS = *NewToS;\r | |
2254 | }\r | |
2255 | \r | |
2256 | ON_EXIT:\r | |
2257 | return Status;\r | |
2258 | }\r | |
2259 | \r | |
e2851998 | 2260 | /**\r |
f737cfb9 | 2261 | Updates the station IP address and/or subnet mask values of a network device.\r |
e2851998 | 2262 | \r |
f737cfb9 | 2263 | This function updates the station IP address and/or subnet mask values of a network\r |
2264 | device. The NewStationIp field is used to modify the network device's current IP address.\r | |
2265 | If NewStationIP is NULL, then the current IP address will not be modified. Otherwise,\r | |
2266 | this function updates the StationIp field of the EFI_PXE_BASE_CODE_MODE structure\r | |
2267 | with NewStationIp. The NewSubnetMask field is used to modify the network device's current subnet\r | |
2268 | mask. If NewSubnetMask is NULL, then the current subnet mask will not be modified.\r | |
2269 | Otherwise, this function updates the SubnetMask field of the EFI_PXE_BASE_CODE_MODE\r | |
2270 | structure with NewSubnetMask.\r | |
e2851998 | 2271 | \r |
f737cfb9 | 2272 | @param This Pointer to the EFI_PXE_BASE_CODE_PROTOCOL instance.\r |
e2851998 | 2273 | @param NewStationIp Pointer to the new IP address to be used by the network device.\r |
2274 | @param NewSubnetMask Pointer to the new subnet mask to be used by the network device.\r | |
2275 | \r | |
f737cfb9 | 2276 | @retval EFI_SUCCESS The new station IP address and/or subnet mask were updated.\r |
2277 | @retval EFI_NOT_STARTED The PXE Base Code Protocol is in the stopped state.\r | |
e2851998 | 2278 | @retval EFI_INVALID_PARAMETER One or more parameters are invalid.\r |
2279 | \r | |
dc361cc5 | 2280 | **/\r |
2281 | EFI_STATUS\r | |
2282 | EFIAPI\r | |
2283 | EfiPxeBcSetStationIP (\r | |
2284 | IN EFI_PXE_BASE_CODE_PROTOCOL * This,\r | |
f737cfb9 | 2285 | IN EFI_IP_ADDRESS * NewStationIp OPTIONAL,\r |
dc361cc5 | 2286 | IN EFI_IP_ADDRESS * NewSubnetMask OPTIONAL\r |
2287 | )\r | |
2288 | {\r | |
2289 | PXEBC_PRIVATE_DATA *Private;\r | |
2290 | EFI_PXE_BASE_CODE_MODE *Mode;\r | |
8d285ec0 | 2291 | EFI_ARP_CONFIG_DATA ArpConfigData;\r |
dc361cc5 | 2292 | \r |
2293 | if (This == NULL) {\r | |
2294 | return EFI_INVALID_PARAMETER;\r | |
2295 | }\r | |
2296 | \r | |
f6b7393c | 2297 | if (NewStationIp != NULL && !NetIp4IsUnicast (NTOHL (NewStationIp->Addr[0]), 0)) {\r |
dc361cc5 | 2298 | return EFI_INVALID_PARAMETER;\r |
2299 | }\r | |
2300 | \r | |
2301 | if (NewSubnetMask != NULL && !IP4_IS_VALID_NETMASK (NTOHL (NewSubnetMask->Addr[0]))) {\r | |
2302 | return EFI_INVALID_PARAMETER;\r | |
2303 | }\r | |
2304 | \r | |
2305 | Private = PXEBC_PRIVATE_DATA_FROM_PXEBC (This);\r | |
2306 | Mode = Private->PxeBc.Mode;\r | |
2307 | \r | |
2308 | if (!Mode->Started) {\r | |
2309 | return EFI_NOT_STARTED;\r | |
2310 | }\r | |
2311 | \r | |
2312 | if (NewStationIp != NULL) {\r | |
555e76f8 | 2313 | CopyMem (&Mode->StationIp, NewStationIp, sizeof (EFI_IP_ADDRESS));\r |
2314 | CopyMem (&Private->StationIp, NewStationIp, sizeof (EFI_IP_ADDRESS));\r | |
dc361cc5 | 2315 | }\r |
2316 | \r | |
2317 | if (NewSubnetMask != NULL) {\r | |
555e76f8 | 2318 | CopyMem (&Mode->SubnetMask, NewSubnetMask, sizeof (EFI_IP_ADDRESS));\r |
2319 | CopyMem (&Private->SubnetMask ,NewSubnetMask, sizeof (EFI_IP_ADDRESS));\r | |
dc361cc5 | 2320 | }\r |
2321 | \r | |
2322 | Private->AddressIsOk = TRUE;\r | |
2323 | \r | |
8d285ec0 | 2324 | if (!Mode->UsingIpv6) {\r |
2325 | //\r | |
2326 | // If in IPv4 mode, configure the corresponding ARP with this new\r | |
2327 | // station IP address.\r | |
2328 | //\r | |
2329 | ZeroMem (&ArpConfigData, sizeof (EFI_ARP_CONFIG_DATA));\r | |
2330 | \r | |
2331 | ArpConfigData.SwAddressType = 0x0800;\r | |
c9325700 | 2332 | ArpConfigData.SwAddressLength = (UINT8) sizeof (EFI_IPv4_ADDRESS);\r |
8d285ec0 | 2333 | ArpConfigData.StationAddress = &Private->StationIp.v4;\r |
2334 | \r | |
2335 | Private->Arp->Configure (Private->Arp, NULL);\r | |
2336 | Private->Arp->Configure (Private->Arp, &ArpConfigData);\r | |
982a9eae | 2337 | \r |
2338 | //\r | |
2339 | // Update the route table.\r | |
2340 | //\r | |
2341 | Mode->RouteTableEntries = 1;\r | |
2342 | Mode->RouteTable[0].IpAddr.Addr[0] = Private->StationIp.Addr[0] & Private->SubnetMask.Addr[0];\r | |
2343 | Mode->RouteTable[0].SubnetMask.Addr[0] = Private->SubnetMask.Addr[0];\r | |
2344 | Mode->RouteTable[0].GwAddr.Addr[0] = 0;\r | |
8d285ec0 | 2345 | }\r |
2346 | \r | |
dc361cc5 | 2347 | return EFI_SUCCESS;\r |
2348 | }\r | |
2349 | \r | |
e2851998 | 2350 | /**\r |
f737cfb9 | 2351 | Updates the contents of the cached DHCP and Discover packets.\r |
e2851998 | 2352 | \r |
f737cfb9 | 2353 | The pointers to the new packets are used to update the contents of the cached\r |
2354 | packets in the EFI_PXE_BASE_CODE_MODE structure.\r | |
e2851998 | 2355 | \r |
f737cfb9 | 2356 | @param This Pointer to the EFI_PXE_BASE_CODE_PROTOCOL instance.\r |
2357 | @param NewDhcpDiscoverValid Pointer to a value that will replace the current\r | |
e2851998 | 2358 | DhcpDiscoverValid field.\r |
f737cfb9 | 2359 | @param NewDhcpAckReceived Pointer to a value that will replace the current\r |
e2851998 | 2360 | DhcpAckReceived field.\r |
f737cfb9 | 2361 | @param NewProxyOfferReceived Pointer to a value that will replace the current\r |
e2851998 | 2362 | ProxyOfferReceived field.\r |
2363 | @param NewPxeDiscoverValid Pointer to a value that will replace the current\r | |
2364 | ProxyOfferReceived field.\r | |
f737cfb9 | 2365 | @param NewPxeReplyReceived Pointer to a value that will replace the current\r |
e2851998 | 2366 | PxeReplyReceived field.\r |
f737cfb9 | 2367 | @param NewPxeBisReplyReceived Pointer to a value that will replace the current\r |
e2851998 | 2368 | PxeBisReplyReceived field.\r |
2369 | @param NewDhcpDiscover Pointer to the new cached DHCP Discover packet contents.\r | |
f737cfb9 | 2370 | @param NewDhcpAck Pointer to the new cached DHCP Ack packet contents.\r |
2371 | @param NewProxyOffer Pointer to the new cached Proxy Offer packet contents.\r | |
2372 | @param NewPxeDiscover Pointer to the new cached PXE Discover packet contents.\r | |
2373 | @param NewPxeReply Pointer to the new cached PXE Reply packet contents.\r | |
2374 | @param NewPxeBisReply Pointer to the new cached PXE BIS Reply packet contents.\r | |
e2851998 | 2375 | \r |
f737cfb9 | 2376 | @retval EFI_SUCCESS The cached packet contents were updated.\r |
2377 | @retval EFI_NOT_STARTED The PXE Base Code Protocol is in the stopped state.\r | |
2378 | @retval EFI_INVALID_PARAMETER This is NULL or not point to a valid EFI_PXE_BASE_CODE_PROTOCOL structure.\r | |
e2851998 | 2379 | \r |
dc361cc5 | 2380 | **/\r |
2381 | EFI_STATUS\r | |
2382 | EFIAPI\r | |
2383 | EfiPxeBcSetPackets (\r | |
2384 | IN EFI_PXE_BASE_CODE_PROTOCOL * This,\r | |
f737cfb9 | 2385 | IN BOOLEAN * NewDhcpDiscoverValid OPTIONAL,\r |
2386 | IN BOOLEAN * NewDhcpAckReceived OPTIONAL,\r | |
2387 | IN BOOLEAN * NewProxyOfferReceived OPTIONAL,\r | |
2388 | IN BOOLEAN * NewPxeDiscoverValid OPTIONAL,\r | |
2389 | IN BOOLEAN * NewPxeReplyReceived OPTIONAL,\r | |
2390 | IN BOOLEAN * NewPxeBisReplyReceived OPTIONAL,\r | |
2391 | IN EFI_PXE_BASE_CODE_PACKET * NewDhcpDiscover OPTIONAL,\r | |
2392 | IN EFI_PXE_BASE_CODE_PACKET * NewDhcpAck OPTIONAL,\r | |
2393 | IN EFI_PXE_BASE_CODE_PACKET * NewProxyOffer OPTIONAL,\r | |
2394 | IN EFI_PXE_BASE_CODE_PACKET * NewPxeDiscover OPTIONAL,\r | |
2395 | IN EFI_PXE_BASE_CODE_PACKET * NewPxeReply OPTIONAL,\r | |
dc361cc5 | 2396 | IN EFI_PXE_BASE_CODE_PACKET * NewPxeBisReply OPTIONAL\r |
2397 | )\r | |
2398 | {\r | |
2399 | PXEBC_PRIVATE_DATA *Private;\r | |
2400 | EFI_PXE_BASE_CODE_MODE *Mode;\r | |
2401 | \r | |
2402 | if (This == NULL) {\r | |
2403 | return EFI_INVALID_PARAMETER;\r | |
2404 | }\r | |
2405 | \r | |
2406 | Private = PXEBC_PRIVATE_DATA_FROM_PXEBC (This);\r | |
2407 | Mode = Private->PxeBc.Mode;\r | |
2408 | \r | |
2409 | if (!Mode->Started) {\r | |
2410 | return EFI_NOT_STARTED;\r | |
2411 | }\r | |
2412 | \r | |
dc361cc5 | 2413 | if (NewDhcpDiscoverValid != NULL) {\r |
2414 | Mode->DhcpDiscoverValid = *NewDhcpDiscoverValid;\r | |
2415 | }\r | |
2416 | \r | |
2417 | if (NewDhcpAckReceived != NULL) {\r | |
2418 | Mode->DhcpAckReceived = *NewDhcpAckReceived;\r | |
2419 | }\r | |
2420 | \r | |
2421 | if (NewProxyOfferReceived != NULL) {\r | |
2422 | Mode->ProxyOfferReceived = *NewProxyOfferReceived;\r | |
2423 | }\r | |
2424 | \r | |
2425 | if (NewPxeDiscoverValid != NULL) {\r | |
2426 | Mode->PxeDiscoverValid = *NewPxeDiscoverValid;\r | |
2427 | }\r | |
2428 | \r | |
2429 | if (NewPxeReplyReceived != NULL) {\r | |
2430 | Mode->PxeReplyReceived = *NewPxeReplyReceived;\r | |
2431 | }\r | |
2432 | \r | |
2433 | if (NewPxeBisReplyReceived != NULL) {\r | |
2434 | Mode->PxeBisReplyReceived = *NewPxeBisReplyReceived;\r | |
2435 | }\r | |
2436 | \r | |
2437 | if (NewDhcpDiscover != NULL) {\r | |
e48e37fc | 2438 | CopyMem (&Mode->DhcpDiscover, NewDhcpDiscover, sizeof (EFI_PXE_BASE_CODE_PACKET));\r |
dc361cc5 | 2439 | }\r |
2440 | \r | |
2441 | if (NewDhcpAck != NULL) {\r | |
e48e37fc | 2442 | CopyMem (&Mode->DhcpAck, NewDhcpAck, sizeof (EFI_PXE_BASE_CODE_PACKET));\r |
dc361cc5 | 2443 | }\r |
2444 | \r | |
2445 | if (NewProxyOffer != NULL) {\r | |
e48e37fc | 2446 | CopyMem (&Mode->ProxyOffer, NewProxyOffer, sizeof (EFI_PXE_BASE_CODE_PACKET));\r |
dc361cc5 | 2447 | }\r |
2448 | \r | |
2449 | if (NewPxeDiscover != NULL) {\r | |
e48e37fc | 2450 | CopyMem (&Mode->PxeDiscover, NewPxeDiscover, sizeof (EFI_PXE_BASE_CODE_PACKET));\r |
dc361cc5 | 2451 | }\r |
2452 | \r | |
2453 | if (NewPxeReply != NULL) {\r | |
e48e37fc | 2454 | CopyMem (&Mode->PxeReply, NewPxeReply, sizeof (EFI_PXE_BASE_CODE_PACKET));\r |
dc361cc5 | 2455 | }\r |
2456 | \r | |
2457 | if (NewPxeBisReply != NULL) {\r | |
e48e37fc | 2458 | CopyMem (&Mode->PxeBisReply, NewPxeBisReply, sizeof (EFI_PXE_BASE_CODE_PACKET));\r |
dc361cc5 | 2459 | }\r |
2460 | \r | |
2461 | return EFI_SUCCESS;\r | |
2462 | }\r | |
2463 | \r | |
2464 | EFI_PXE_BASE_CODE_PROTOCOL mPxeBcProtocolTemplate = {\r | |
2465 | EFI_PXE_BASE_CODE_PROTOCOL_REVISION,\r | |
2466 | EfiPxeBcStart,\r | |
2467 | EfiPxeBcStop,\r | |
2468 | EfiPxeBcDhcp,\r | |
2469 | EfiPxeBcDiscover,\r | |
2470 | EfiPxeBcMtftp,\r | |
2471 | EfiPxeBcUdpWrite,\r | |
2472 | EfiPxeBcUdpRead,\r | |
2473 | EfiPxeBcSetIpFilter,\r | |
2474 | EfiPxeBcArp,\r | |
2475 | EfiPxeBcSetParameters,\r | |
2476 | EfiPxeBcSetStationIP,\r | |
2477 | EfiPxeBcSetPackets,\r | |
2478 | NULL\r | |
2479 | };\r | |
2480 | \r | |
e2851998 | 2481 | /**\r |
f737cfb9 | 2482 | Callback function that is invoked when the PXE Base Code Protocol is about to transmit, has\r |
e2851998 | 2483 | received, or is waiting to receive a packet.\r |
2484 | \r | |
f737cfb9 | 2485 | This function is invoked when the PXE Base Code Protocol is about to transmit, has received,\r |
2486 | or is waiting to receive a packet. Parameters Function and Received specify the type of event.\r | |
2487 | Parameters PacketLen and Packet specify the packet that generated the event. If these fields\r | |
2488 | are zero and NULL respectively, then this is a status update callback. If the operation specified\r | |
2489 | by Function is to continue, then CALLBACK_STATUS_CONTINUE should be returned. If the operation\r | |
2490 | specified by Function should be aborted, then CALLBACK_STATUS_ABORT should be returned. Due to\r | |
2491 | the polling nature of UEFI device drivers, a callback function should not execute for more than 5 ms.\r | |
2492 | The SetParameters() function must be called after a Callback Protocol is installed to enable the\r | |
2493 | use of callbacks.\r | |
e2851998 | 2494 | \r |
f737cfb9 | 2495 | @param This Pointer to the EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL instance.\r |
e2851998 | 2496 | @param Function The PXE Base Code Protocol function that is waiting for an event.\r |
f737cfb9 | 2497 | @param Received TRUE if the callback is being invoked due to a receive event. FALSE if\r |
e2851998 | 2498 | the callback is being invoked due to a transmit event.\r |
f737cfb9 | 2499 | @param PacketLength The length, in bytes, of Packet. This field will have a value of zero if\r |
e2851998 | 2500 | this is a wait for receive event.\r |
f737cfb9 | 2501 | @param PacketPtr If Received is TRUE, a pointer to the packet that was just received;\r |
e2851998 | 2502 | otherwise a pointer to the packet that is about to be transmitted.\r |
2503 | \r | |
2504 | @retval EFI_PXE_BASE_CODE_CALLBACK_STATUS_CONTINUE if Function specifies a continue operation\r | |
f737cfb9 | 2505 | @retval EFI_PXE_BASE_CODE_CALLBACK_STATUS_ABORT if Function specifies an abort operation\r |
e2851998 | 2506 | \r |
dc361cc5 | 2507 | **/\r |
2508 | EFI_PXE_BASE_CODE_CALLBACK_STATUS\r | |
2509 | EFIAPI\r | |
2510 | EfiPxeLoadFileCallback (\r | |
2511 | IN EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL * This,\r | |
2512 | IN EFI_PXE_BASE_CODE_FUNCTION Function,\r | |
2513 | IN BOOLEAN Received,\r | |
2514 | IN UINT32 PacketLength,\r | |
2515 | IN EFI_PXE_BASE_CODE_PACKET * PacketPtr OPTIONAL\r | |
2516 | )\r | |
2517 | {\r | |
2518 | EFI_INPUT_KEY Key;\r | |
2519 | EFI_STATUS Status;\r | |
2520 | \r | |
2521 | //\r | |
2522 | // Catch Ctrl-C or ESC to abort.\r | |
2523 | //\r | |
2524 | Status = gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);\r | |
2525 | \r | |
2526 | if (!EFI_ERROR (Status)) {\r | |
2527 | \r | |
2528 | if (Key.ScanCode == SCAN_ESC || Key.UnicodeChar == (0x1F & 'c')) {\r | |
2529 | \r | |
2530 | return EFI_PXE_BASE_CODE_CALLBACK_STATUS_ABORT;\r | |
2531 | }\r | |
2532 | }\r | |
2533 | //\r | |
2534 | // No print if receive packet\r | |
2535 | //\r | |
2536 | if (Received) {\r | |
2537 | return EFI_PXE_BASE_CODE_CALLBACK_STATUS_CONTINUE;\r | |
2538 | }\r | |
2539 | //\r | |
2540 | // Print only for three functions\r | |
2541 | //\r | |
2542 | switch (Function) {\r | |
2543 | \r | |
2544 | case EFI_PXE_BASE_CODE_FUNCTION_MTFTP:\r | |
2545 | //\r | |
2546 | // Print only for open MTFTP packets, not every MTFTP packets\r | |
2547 | //\r | |
2548 | if (PacketLength != 0 && PacketPtr != NULL) {\r | |
2549 | if (PacketPtr->Raw[0x1C] != 0x00 || PacketPtr->Raw[0x1D] != 0x01) {\r | |
2550 | return EFI_PXE_BASE_CODE_CALLBACK_STATUS_CONTINUE;\r | |
2551 | }\r | |
2552 | }\r | |
2553 | break;\r | |
2554 | \r | |
2555 | case EFI_PXE_BASE_CODE_FUNCTION_DHCP:\r | |
2556 | case EFI_PXE_BASE_CODE_FUNCTION_DISCOVER:\r | |
2557 | break;\r | |
2558 | \r | |
2559 | default:\r | |
2560 | return EFI_PXE_BASE_CODE_CALLBACK_STATUS_CONTINUE;\r | |
2561 | }\r | |
2562 | \r | |
2563 | if (PacketLength != 0 && PacketPtr != NULL) {\r | |
2564 | //\r | |
2565 | // Print '.' when transmit a packet\r | |
2566 | //\r | |
2567 | AsciiPrint (".");\r | |
2568 | \r | |
2569 | }\r | |
2570 | \r | |
2571 | return EFI_PXE_BASE_CODE_CALLBACK_STATUS_CONTINUE;\r | |
2572 | }\r | |
2573 | \r | |
2574 | EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL mPxeBcCallBackTemplate = {\r | |
2575 | EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL_REVISION,\r | |
2576 | EfiPxeLoadFileCallback\r | |
2577 | };\r | |
2578 | \r | |
2579 | \r | |
2580 | /**\r | |
f737cfb9 | 2581 | Find the boot file.\r |
dc361cc5 | 2582 | \r |
e2851998 | 2583 | @param Private Pointer to PxeBc private data.\r |
2584 | @param BufferSize Pointer to buffer size.\r | |
2585 | @param Buffer Pointer to buffer.\r | |
dc361cc5 | 2586 | \r |
f737cfb9 | 2587 | @retval EFI_SUCCESS Discover the boot file successfully.\r |
2588 | @retval EFI_TIMEOUT The TFTP/MTFTP operation timed out.\r | |
2589 | @retval EFI_ABORTED PXE bootstrap server, so local boot need abort.\r | |
2590 | @retval EFI_BUFFER_TOO_SMALL The buffer is too small to load the boot file.\r | |
e2851998 | 2591 | \r |
dc361cc5 | 2592 | **/\r |
2593 | EFI_STATUS\r | |
2594 | DiscoverBootFile (\r | |
2595 | IN PXEBC_PRIVATE_DATA *Private,\r | |
2596 | IN OUT UINT64 *BufferSize,\r | |
2597 | IN VOID *Buffer\r | |
2598 | )\r | |
2599 | {\r | |
2600 | EFI_PXE_BASE_CODE_PROTOCOL *PxeBc;\r | |
2601 | EFI_PXE_BASE_CODE_MODE *Mode;\r | |
2602 | EFI_STATUS Status;\r | |
2603 | UINT16 Type;\r | |
2604 | UINT16 Layer;\r | |
2605 | BOOLEAN UseBis;\r | |
dc361cc5 | 2606 | PXEBC_CACHED_DHCP4_PACKET *Packet;\r |
2607 | UINT16 Value;\r | |
2608 | \r | |
2609 | PxeBc = &Private->PxeBc;\r | |
2610 | Mode = PxeBc->Mode;\r | |
2611 | Type = EFI_PXE_BASE_CODE_BOOT_TYPE_BOOTSTRAP;\r | |
2612 | Layer = EFI_PXE_BASE_CODE_BOOT_LAYER_INITIAL;\r | |
2613 | \r | |
2614 | //\r | |
2615 | // do DHCP.\r | |
2616 | //\r | |
2617 | Status = PxeBc->Dhcp (PxeBc, TRUE);\r | |
2618 | if (EFI_ERROR (Status)) {\r | |
2619 | return Status;\r | |
2620 | }\r | |
2621 | \r | |
2622 | //\r | |
2623 | // Select a boot server\r | |
2624 | //\r | |
2625 | Status = PxeBcSelectBootPrompt (Private);\r | |
2626 | \r | |
2627 | if (Status == EFI_SUCCESS) {\r | |
2628 | Status = PxeBcSelectBootMenu (Private, &Type, TRUE);\r | |
2629 | } else if (Status == EFI_TIMEOUT) {\r | |
2630 | Status = PxeBcSelectBootMenu (Private, &Type, FALSE);\r | |
2631 | }\r | |
2632 | \r | |
2633 | if (!EFI_ERROR (Status)) {\r | |
2634 | \r | |
2635 | if (Type == EFI_PXE_BASE_CODE_BOOT_TYPE_BOOTSTRAP) {\r | |
2636 | //\r | |
2637 | // Local boot(PXE bootstrap server) need abort\r | |
2638 | //\r | |
2639 | return EFI_ABORTED;\r | |
2640 | }\r | |
2641 | \r | |
2642 | UseBis = (BOOLEAN) (Mode->BisSupported && Mode->BisDetected);\r | |
2643 | Status = PxeBc->Discover (PxeBc, Type, &Layer, UseBis, NULL);\r | |
2644 | if (EFI_ERROR (Status)) {\r | |
2645 | return Status;\r | |
2646 | }\r | |
2647 | }\r | |
2648 | \r | |
2649 | *BufferSize = 0;\r | |
dc361cc5 | 2650 | \r |
2651 | //\r | |
2652 | // Get bootfile name and (m)tftp server ip addresss\r | |
2653 | //\r | |
2654 | if (Mode->PxeReplyReceived) {\r | |
2655 | Packet = &Private->PxeReply;\r | |
2656 | } else if (Mode->ProxyOfferReceived) {\r | |
2657 | Packet = &Private->ProxyOffer;\r | |
2658 | } else {\r | |
2659 | Packet = &Private->Dhcp4Ack;\r | |
2660 | }\r | |
2661 | \r | |
319075ff | 2662 | //\r |
2ce5c88a | 2663 | // Use siaddr(next server) in DHCPOFFER packet header, if zero, use option 54(server identifier)\r |
2664 | // in DHCPOFFER packet.\r | |
2665 | // (It does not comply with PXE Spec, Ver2.1)\r | |
319075ff | 2666 | //\r |
2ce5c88a | 2667 | if (EFI_IP4_EQUAL (&Packet->Packet.Offer.Dhcp4.Header.ServerAddr, &mZeroIp4Addr)) {\r |
e48e37fc | 2668 | CopyMem (\r |
dc361cc5 | 2669 | &Private->ServerIp,\r |
2670 | Packet->Dhcp4Option[PXEBC_DHCP4_TAG_INDEX_SERVER_ID]->Data,\r | |
2671 | sizeof (EFI_IPv4_ADDRESS)\r | |
2672 | );\r | |
319075ff | 2673 | } else {\r |
2674 | CopyMem (\r | |
e2851998 | 2675 | &Private->ServerIp,\r |
2676 | &Packet->Packet.Offer.Dhcp4.Header.ServerAddr,\r | |
319075ff | 2677 | sizeof (EFI_IPv4_ADDRESS)\r |
2678 | );\r | |
2679 | }\r | |
2680 | if (Private->ServerIp.Addr[0] == 0) {\r | |
2681 | return EFI_DEVICE_ERROR;\r | |
dc361cc5 | 2682 | }\r |
2683 | \r | |
2684 | ASSERT (Packet->Dhcp4Option[PXEBC_DHCP4_TAG_INDEX_BOOTFILE] != NULL);\r | |
2685 | \r | |
2686 | //\r | |
2687 | // bootlfile name\r | |
2688 | //\r | |
2689 | Private->BootFileName = (CHAR8 *) (Packet->Dhcp4Option[PXEBC_DHCP4_TAG_INDEX_BOOTFILE]->Data);\r | |
2690 | \r | |
2691 | if (Packet->Dhcp4Option[PXEBC_DHCP4_TAG_INDEX_BOOTFILE_LEN] != NULL) {\r | |
2692 | //\r | |
2693 | // Already have the bootfile length option, compute the file size\r | |
2694 | //\r | |
e48e37fc | 2695 | CopyMem (&Value, Packet->Dhcp4Option[PXEBC_DHCP4_TAG_INDEX_BOOTFILE_LEN]->Data, sizeof (Value));\r |
dc361cc5 | 2696 | Value = NTOHS (Value);\r |
2697 | *BufferSize = 512 * Value;\r | |
2698 | Status = EFI_BUFFER_TOO_SMALL;\r | |
2699 | } else {\r | |
2700 | //\r | |
2701 | // Get the bootfile size from tftp\r | |
2702 | //\r | |
2703 | Status = PxeBc->Mtftp (\r | |
2704 | PxeBc,\r | |
2705 | EFI_PXE_BASE_CODE_TFTP_GET_FILE_SIZE,\r | |
2706 | Buffer,\r | |
2707 | FALSE,\r | |
2708 | BufferSize,\r | |
fa6d3ee4 | 2709 | &Private->BlockSize,\r |
dc361cc5 | 2710 | &Private->ServerIp,\r |
2711 | (UINT8 *) Private->BootFileName,\r | |
2712 | NULL,\r | |
2713 | FALSE\r | |
2714 | );\r | |
2715 | }\r | |
2716 | \r | |
2717 | Private->FileSize = (UINTN) *BufferSize;\r | |
2718 | \r | |
2719 | return Status;\r | |
2720 | }\r | |
2721 | \r | |
dc361cc5 | 2722 | /**\r |
f737cfb9 | 2723 | Causes the driver to load a specified file.\r |
2724 | \r | |
2725 | @param This Protocol instance pointer.\r | |
2726 | @param FilePath The device specific path of the file to load.\r | |
e2851998 | 2727 | @param BootPolicy If TRUE, indicates that the request originates from the\r |
f737cfb9 | 2728 | boot manager is attempting to load FilePath as a boot\r |
2729 | selection. If FALSE, then FilePath must match as exact file\r | |
2730 | to be loaded.\r | |
2731 | @param BufferSize On input the size of Buffer in bytes. On output with a return\r | |
e2851998 | 2732 | code of EFI_SUCCESS, the amount of data transferred to\r |
f737cfb9 | 2733 | Buffer. On output with a return code of EFI_BUFFER_TOO_SMALL,\r |
2734 | the size of Buffer required to retrieve the requested file.\r | |
2735 | @param Buffer The memory buffer to transfer the file to. IF Buffer is NULL,\r | |
e2851998 | 2736 | then no the size of the requested file is returned in\r |
f737cfb9 | 2737 | BufferSize.\r |
2738 | \r | |
2739 | @retval EFI_SUCCESS The file was loaded.\r | |
2740 | @retval EFI_UNSUPPORTED The device does not support the provided BootPolicy\r | |
e2851998 | 2741 | @retval EFI_INVALID_PARAMETER FilePath is not a valid device path, or\r |
f737cfb9 | 2742 | BufferSize is NULL.\r |
2743 | @retval EFI_NO_MEDIA No medium was present to load the file.\r | |
2744 | @retval EFI_DEVICE_ERROR The file was not loaded due to a device error.\r | |
2745 | @retval EFI_NO_RESPONSE The remote system did not respond.\r | |
2746 | @retval EFI_NOT_FOUND The file was not found.\r | |
2747 | @retval EFI_ABORTED The file load process was manually cancelled.\r | |
dc361cc5 | 2748 | \r |
2749 | **/\r | |
2750 | EFI_STATUS\r | |
2751 | EFIAPI\r | |
2752 | EfiPxeLoadFile (\r | |
2753 | IN EFI_LOAD_FILE_PROTOCOL * This,\r | |
2754 | IN EFI_DEVICE_PATH_PROTOCOL * FilePath,\r | |
2755 | IN BOOLEAN BootPolicy,\r | |
2756 | IN OUT UINTN *BufferSize,\r | |
2757 | IN VOID *Buffer OPTIONAL\r | |
2758 | )\r | |
2759 | {\r | |
2760 | PXEBC_PRIVATE_DATA *Private;\r | |
2761 | EFI_PXE_BASE_CODE_PROTOCOL *PxeBc;\r | |
2762 | BOOLEAN NewMakeCallback;\r | |
dc361cc5 | 2763 | EFI_STATUS Status;\r |
2764 | UINT64 TmpBufSize;\r | |
dd29f3ed | 2765 | BOOLEAN MediaPresent;\r |
dc361cc5 | 2766 | \r |
2767 | Private = PXEBC_PRIVATE_DATA_FROM_LOADFILE (This);\r | |
2768 | PxeBc = &Private->PxeBc;\r | |
2769 | NewMakeCallback = FALSE;\r | |
dc361cc5 | 2770 | Status = EFI_DEVICE_ERROR;\r |
2771 | \r | |
2772 | if (This == NULL || BufferSize == NULL) {\r | |
2773 | \r | |
2774 | return EFI_INVALID_PARAMETER;\r | |
2775 | }\r | |
2776 | \r | |
2777 | //\r | |
2778 | // Only support BootPolicy\r | |
2779 | //\r | |
2780 | if (!BootPolicy) {\r | |
2781 | return EFI_UNSUPPORTED;\r | |
2782 | }\r | |
2783 | \r | |
dd29f3ed | 2784 | //\r |
2785 | // Check media status before PXE start\r | |
2786 | //\r | |
2787 | MediaPresent = TRUE;\r | |
2788 | NetLibDetectMedia (Private->Controller, &MediaPresent);\r | |
2789 | if (!MediaPresent) {\r | |
2790 | return EFI_NO_MEDIA;\r | |
2791 | }\r | |
2792 | \r | |
dc361cc5 | 2793 | Status = PxeBc->Start (PxeBc, FALSE);\r |
2794 | if (EFI_ERROR (Status) && (Status != EFI_ALREADY_STARTED)) {\r | |
2795 | return Status;\r | |
2796 | }\r | |
2797 | \r | |
2798 | Status = gBS->HandleProtocol (\r | |
2799 | Private->Controller,\r | |
2800 | &gEfiPxeBaseCodeCallbackProtocolGuid,\r | |
2801 | (VOID **) &Private->PxeBcCallback\r | |
2802 | );\r | |
2803 | if (Status == EFI_UNSUPPORTED) {\r | |
2804 | \r | |
2805 | CopyMem (&Private->LoadFileCallback, &mPxeBcCallBackTemplate, sizeof (Private->LoadFileCallback));\r | |
2806 | \r | |
2807 | Status = gBS->InstallProtocolInterface (\r | |
2808 | &Private->Controller,\r | |
2809 | &gEfiPxeBaseCodeCallbackProtocolGuid,\r | |
2810 | EFI_NATIVE_INTERFACE,\r | |
2811 | &Private->LoadFileCallback\r | |
2812 | );\r | |
2813 | \r | |
2814 | NewMakeCallback = (BOOLEAN) (Status == EFI_SUCCESS);\r | |
2815 | \r | |
2816 | Status = PxeBc->SetParameters (PxeBc, NULL, NULL, NULL, NULL, &NewMakeCallback);\r | |
2817 | if (EFI_ERROR (Status)) {\r | |
2818 | PxeBc->Stop (PxeBc);\r | |
2819 | return Status;\r | |
2820 | }\r | |
2821 | }\r | |
2822 | \r | |
2823 | if (Private->FileSize == 0) {\r | |
2824 | TmpBufSize = 0;\r | |
2825 | Status = DiscoverBootFile (Private, &TmpBufSize, Buffer);\r | |
2826 | \r | |
2827 | if (sizeof (UINTN) < sizeof (UINT64) && (TmpBufSize > 0xFFFFFFFF)) {\r | |
2828 | Status = EFI_DEVICE_ERROR;\r | |
39941daf | 2829 | } else if (TmpBufSize > 0 && *BufferSize >= (UINTN) TmpBufSize && Buffer != NULL) {\r |
319075ff | 2830 | *BufferSize = (UINTN) TmpBufSize;\r |
2831 | Status = PxeBc->Mtftp (\r | |
2832 | PxeBc,\r | |
2833 | EFI_PXE_BASE_CODE_TFTP_READ_FILE,\r | |
2834 | Buffer,\r | |
2835 | FALSE,\r | |
2836 | &TmpBufSize,\r | |
fa6d3ee4 | 2837 | &Private->BlockSize,\r |
319075ff | 2838 | &Private->ServerIp,\r |
2839 | (UINT8 *) Private->BootFileName,\r | |
2840 | NULL,\r | |
2841 | FALSE\r | |
2842 | );\r | |
39941daf | 2843 | } else if (TmpBufSize > 0) {\r |
dc361cc5 | 2844 | *BufferSize = (UINTN) TmpBufSize;\r |
319075ff | 2845 | Status = EFI_BUFFER_TOO_SMALL;\r |
dc361cc5 | 2846 | }\r |
319075ff | 2847 | } else if (Buffer == NULL || Private->FileSize > *BufferSize) {\r |
dc361cc5 | 2848 | *BufferSize = Private->FileSize;\r |
2849 | Status = EFI_BUFFER_TOO_SMALL;\r | |
2850 | } else {\r | |
2851 | //\r | |
2852 | // Download the file.\r | |
2853 | //\r | |
2854 | TmpBufSize = (UINT64) (*BufferSize);\r | |
2855 | Status = PxeBc->Mtftp (\r | |
2856 | PxeBc,\r | |
2857 | EFI_PXE_BASE_CODE_TFTP_READ_FILE,\r | |
2858 | Buffer,\r | |
2859 | FALSE,\r | |
2860 | &TmpBufSize,\r | |
fa6d3ee4 | 2861 | &Private->BlockSize,\r |
dc361cc5 | 2862 | &Private->ServerIp,\r |
2863 | (UINT8 *) Private->BootFileName,\r | |
2864 | NULL,\r | |
2865 | FALSE\r | |
2866 | );\r | |
2867 | }\r | |
2868 | //\r | |
2869 | // If we added a callback protocol, now is the time to remove it.\r | |
2870 | //\r | |
2871 | if (NewMakeCallback) {\r | |
2872 | \r | |
2873 | NewMakeCallback = FALSE;\r | |
2874 | \r | |
2875 | PxeBc->SetParameters (PxeBc, NULL, NULL, NULL, NULL, &NewMakeCallback);\r | |
2876 | \r | |
2877 | gBS->UninstallProtocolInterface (\r | |
2878 | Private->Controller,\r | |
2879 | &gEfiPxeBaseCodeCallbackProtocolGuid,\r | |
2880 | &Private->LoadFileCallback\r | |
2881 | );\r | |
2882 | }\r | |
619eff3f | 2883 | \r |
dc361cc5 | 2884 | //\r |
2885 | // Check download status\r | |
2886 | //\r | |
619eff3f | 2887 | if (Status == EFI_SUCCESS) {\r |
6ee21b60 | 2888 | //\r |
2889 | // The functionality of PXE Base Code protocol will not be stopped,\r | |
2890 | // when downloading is successfully.\r | |
2891 | //\r | |
8792362f | 2892 | return EFI_SUCCESS;\r |
dc361cc5 | 2893 | \r |
619eff3f | 2894 | } else if (Status == EFI_BUFFER_TOO_SMALL) {\r |
dc361cc5 | 2895 | if (Buffer != NULL) {\r |
2896 | AsciiPrint ("PXE-E05: Download buffer is smaller than requested file.\n");\r | |
2897 | } else {\r | |
ee6e8714 | 2898 | //\r |
2899 | // The functionality of PXE Base Code protocol will not be stopped.\r | |
2900 | //\r | |
dc361cc5 | 2901 | return Status;\r |
2902 | }\r | |
dc361cc5 | 2903 | \r |
619eff3f | 2904 | } else if (Status == EFI_DEVICE_ERROR) {\r |
dc361cc5 | 2905 | AsciiPrint ("PXE-E07: Network device error.\n");\r |
dc361cc5 | 2906 | \r |
619eff3f | 2907 | } else if (Status == EFI_OUT_OF_RESOURCES) {\r |
dc361cc5 | 2908 | AsciiPrint ("PXE-E09: Could not allocate I/O buffers.\n");\r |
dc361cc5 | 2909 | \r |
619eff3f | 2910 | } else if (Status == EFI_NO_MEDIA) {\r |
dc361cc5 | 2911 | AsciiPrint ("PXE-E12: Could not detect network connection.\n");\r |
dc361cc5 | 2912 | \r |
619eff3f | 2913 | } else if (Status == EFI_NO_RESPONSE) {\r |
dc361cc5 | 2914 | AsciiPrint ("PXE-E16: No offer received.\n");\r |
dc361cc5 | 2915 | \r |
619eff3f | 2916 | } else if (Status == EFI_TIMEOUT) {\r |
dc361cc5 | 2917 | AsciiPrint ("PXE-E18: Server response timeout.\n");\r |
dc361cc5 | 2918 | \r |
619eff3f | 2919 | } else if (Status == EFI_ABORTED) {\r |
dc361cc5 | 2920 | AsciiPrint ("PXE-E21: Remote boot cancelled.\n");\r |
dc361cc5 | 2921 | \r |
619eff3f | 2922 | } else if (Status == EFI_ICMP_ERROR) {\r |
dc361cc5 | 2923 | AsciiPrint ("PXE-E22: Client received ICMP error from server.\n");\r |
dc361cc5 | 2924 | \r |
619eff3f | 2925 | } else if (Status == EFI_TFTP_ERROR) {\r |
dc361cc5 | 2926 | AsciiPrint ("PXE-E23: Client received TFTP error from server.\n");\r |
dc361cc5 | 2927 | \r |
619eff3f | 2928 | } else {\r |
dc361cc5 | 2929 | AsciiPrint ("PXE-E99: Unexpected network error.\n");\r |
dc361cc5 | 2930 | }\r |
2931 | \r | |
2932 | PxeBc->Stop (PxeBc);\r | |
2933 | \r | |
2934 | return Status;\r | |
2935 | }\r | |
2936 | \r | |
434ce3fe | 2937 | EFI_LOAD_FILE_PROTOCOL mLoadFileProtocolTemplate = { EfiPxeLoadFile };\r |
2938 | \r |