]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/Network/ArpDxe/ArpMain.c
46aa19226b3914c1e8abb9099d7a21c3e88e5938
[mirror_edk2.git] / MdeModulePkg / Universal / Network / ArpDxe / ArpMain.c
1 /** @file
2
3 Copyright (c) 2006, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
8
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
11
12 Module Name:
13
14 ArpMain.c
15
16 Abstract:
17
18
19 **/
20
21 #include "ArpImpl.h"
22
23
24 /**
25 This function is used to assign a station address to the ARP cache for this instance
26 of the ARP driver. A call to this function with the ConfigData field set to NULL
27 will reset this ARP instance.
28
29 @param This Pointer to the EFI_ARP_PROTOCOL instance.
30 @param ConfigData Pointer to the EFI_ARP_CONFIG_DATA structure.
31
32 @retval EFI_SUCCESS The new station address was successfully
33 registered.
34 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
35 This is NULL. SwAddressLength is zero when
36 ConfigData is not NULL. StationAddress is NULL
37 when ConfigData is not NULL.
38 @retval EFI_ACCESS_DENIED The SwAddressType, SwAddressLength, or
39 StationAddress is different from the one that is
40 already registered.
41 @retval EFI_OUT_OF_RESOURCES Storage for the new StationAddress could not be
42 allocated.
43
44 **/
45 EFI_STATUS
46 EFIAPI
47 ArpConfigure (
48 IN EFI_ARP_PROTOCOL *This,
49 IN EFI_ARP_CONFIG_DATA *ConfigData OPTIONAL
50 )
51 {
52 EFI_STATUS Status;
53 ARP_INSTANCE_DATA *Instance;
54 EFI_TPL OldTpl;
55
56 if (This == NULL) {
57 return EFI_INVALID_PARAMETER;
58 }
59
60 if ((ConfigData != NULL) &&
61 ((ConfigData->SwAddressLength == 0) ||
62 (ConfigData->StationAddress == NULL) ||
63 (ConfigData->SwAddressType <= 1500))) {
64 return EFI_INVALID_PARAMETER;
65 }
66
67 Instance = ARP_INSTANCE_DATA_FROM_THIS (This);
68
69 OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
70
71 //
72 // Configure this instance, the ConfigData has already passed the basic checks.
73 //
74 Status = ArpConfigureInstance (Instance, ConfigData);
75
76 gBS->RestoreTPL (OldTpl);
77
78 return Status;
79 }
80
81
82 /**
83 This function is used to insert entries into the ARP cache.
84
85 @param This Pointer to the EFI_ARP_PROTOCOL instance.
86 @param DenyFlag Set to TRUE if this entry is a deny entry. Set to
87 FALSE if this entry is a normal entry.
88 @param TargetSwAddress Pointer to a protocol address to add (or deny).
89 May be set to NULL if DenyFlag is TRUE.
90 @param TargetHwAddress Pointer to a hardware address to add (or deny).
91 May be set to NULL if DenyFlag is TRUE.
92 @param TimeoutValue Time in 100-ns units that this entry will remain
93 in the ARP cache. A value of zero means that the
94 entry is permanent. A nonzero value will override
95 the one given by Configure() if the entry to be
96 added is a dynamic entry.
97 @param Overwrite If TRUE, the matching cache entry will be
98 overwritten with the supplied parameters. If
99 FALSE, EFI_ACCESS_DENIED is returned if the
100 corresponding cache entry already exists.
101
102 @retval EFI_SUCCESS The entry has been added or updated.
103 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
104 This is NULL. DenyFlag is FALSE and
105 TargetHwAddress is NULL. DenyFlag is FALSE and
106 TargetSwAddress is NULL. TargetHwAddress is NULL
107 and TargetSwAddress is NULL. Both TargetSwAddress
108 and TargetHwAddress are not NULL when DenyFlag is
109 TRUE.
110 @retval EFI_OUT_OF_RESOURCES The new ARP cache entry could not be allocated.
111 @retval EFI_ACCESS_DENIED The ARP cache entry already exists and Overwrite
112 is not true.
113 @retval EFI_NOT_STARTED The ARP driver instance has not been configured.
114
115 **/
116 EFI_STATUS
117 EFIAPI
118 ArpAdd (
119 IN EFI_ARP_PROTOCOL *This,
120 IN BOOLEAN DenyFlag,
121 IN VOID *TargetSwAddress OPTIONAL,
122 IN VOID *TargetHwAddress OPTIONAL,
123 IN UINT32 TimeoutValue,
124 IN BOOLEAN Overwrite
125 )
126 {
127 EFI_STATUS Status;
128 ARP_INSTANCE_DATA *Instance;
129 ARP_SERVICE_DATA *ArpService;
130 ARP_CACHE_ENTRY *CacheEntry;
131 EFI_SIMPLE_NETWORK_MODE *SnpMode;
132 NET_ARP_ADDRESS MatchAddress[2];
133 EFI_TPL OldTpl;
134
135 if (This == NULL) {
136 return EFI_INVALID_PARAMETER;
137 }
138
139 if (((!DenyFlag) && ((TargetHwAddress == NULL) || (TargetSwAddress == NULL))) ||
140 (DenyFlag && (TargetHwAddress != NULL) && (TargetSwAddress != NULL)) ||
141 ((TargetHwAddress == NULL) && (TargetSwAddress == NULL))) {
142 return EFI_INVALID_PARAMETER;
143 }
144
145 Instance = ARP_INSTANCE_DATA_FROM_THIS (This);
146
147 if (!Instance->Configured) {
148 return EFI_NOT_STARTED;
149 }
150
151 Status = EFI_SUCCESS;
152 ArpService = Instance->ArpService;
153 SnpMode = &Instance->ArpService->SnpMode;
154
155 //
156 // Fill the hardware address part in the MatchAddress.
157 //
158 MatchAddress[Hardware].Type = SnpMode->IfType;
159 MatchAddress[Hardware].Length = (UINT8) SnpMode->HwAddressSize;
160 MatchAddress[Hardware].AddressPtr = TargetHwAddress;
161
162 //
163 // Fill the software address part in the MatchAddress.
164 //
165 MatchAddress[Protocol].Type = Instance->ConfigData.SwAddressType;
166 MatchAddress[Protocol].Length = Instance->ConfigData.SwAddressLength;
167 MatchAddress[Protocol].AddressPtr = TargetSwAddress;
168
169 OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
170
171 //
172 // See whether the entry to add exists. Check the DeinedCacheTable first.
173 //
174 CacheEntry = ArpFindDeniedCacheEntry (
175 ArpService,
176 &MatchAddress[Protocol],
177 &MatchAddress[Hardware]
178 );
179
180 if (CacheEntry == NULL) {
181 //
182 // Check the ResolvedCacheTable
183 //
184 CacheEntry = ArpFindNextCacheEntryInTable (
185 &ArpService->ResolvedCacheTable,
186 NULL,
187 ByBoth,
188 &MatchAddress[Protocol],
189 &MatchAddress[Hardware]
190 );
191 }
192
193 if ((CacheEntry != NULL) && !Overwrite) {
194 //
195 // The entry to add exists, if not Overwirte, deny this add request.
196 //
197 Status = EFI_ACCESS_DENIED;
198 goto UNLOCK_EXIT;
199 }
200
201 if ((CacheEntry == NULL) && (TargetSwAddress != NULL)) {
202 //
203 // Check whether there are pending requests matching the entry to be added.
204 //
205 CacheEntry = ArpFindNextCacheEntryInTable (
206 &ArpService->PendingRequestTable,
207 NULL,
208 ByProtoAddress,
209 &MatchAddress[Protocol],
210 NULL
211 );
212 }
213
214 if (CacheEntry != NULL) {
215 //
216 // Remove it from the Table.
217 //
218 RemoveEntryList (&CacheEntry->List);
219 } else {
220 //
221 // It's a new entry, allocate memory for the entry.
222 //
223 CacheEntry = ArpAllocCacheEntry (Instance);
224
225 if (CacheEntry == NULL) {
226 DEBUG ((EFI_D_ERROR, "ArpAdd: Failed to allocate pool for CacheEntry.\n"));
227 Status = EFI_OUT_OF_RESOURCES;
228 goto UNLOCK_EXIT;
229 }
230 }
231
232 //
233 // Overwrite these parameters.
234 //
235 CacheEntry->DefaultDecayTime = TimeoutValue;
236 CacheEntry->DecayTime = TimeoutValue;
237
238 //
239 // Fill in the addresses.
240 //
241 ArpFillAddressInCacheEntry (
242 CacheEntry,
243 &MatchAddress[Hardware],
244 &MatchAddress[Protocol]
245 );
246
247 //
248 // Inform the user if there is any.
249 //
250 ArpAddressResolved (CacheEntry, NULL, NULL);
251
252 //
253 // Add this CacheEntry to the corresponding CacheTable.
254 //
255 if (DenyFlag) {
256 InsertHeadList (&ArpService->DeniedCacheTable, &CacheEntry->List);
257 } else {
258 InsertHeadList (&ArpService->ResolvedCacheTable, &CacheEntry->List);
259 }
260
261 UNLOCK_EXIT:
262
263 gBS->RestoreTPL (OldTpl);
264
265 return Status;
266 }
267
268
269 /**
270 This function searches the ARP cache for matching entries and allocates a buffer into
271 which those entries are copied.
272
273 @param This Pointer to the EFI_ARP_PROTOCOL instance.
274 @param BySwAddress Set to TRUE to look for matching software protocol
275 addresses. Set to FALSE to look for matching
276 hardware protocol addresses.
277 @param AddressBuffer Pointer to address buffer. Set to NULL to match
278 all addresses.
279 @param EntryLength The size of an entry in the entries buffer.
280 @param EntryCount The number of ARP cache entries that are found by
281 the specified criteria.
282 @param Entries Pointer to the buffer that will receive the ARP
283 cache entries.
284 @param Refresh Set to TRUE to refresh the timeout value of the
285 matching ARP cache entry.
286
287 @retval EFI_SUCCESS The requested ARP cache entries were copied into
288 the buffer.
289 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
290 This is NULL. Both EntryCount and EntryLength are
291 NULL, when Refresh is FALSE.
292 @retval EFI_NOT_FOUND No matching entries were found.
293 @retval EFI_NOT_STARTED The ARP driver instance has not been configured.
294
295 **/
296 EFI_STATUS
297 EFIAPI
298 ArpFind (
299 IN EFI_ARP_PROTOCOL *This,
300 IN BOOLEAN BySwAddress,
301 IN VOID *AddressBuffer OPTIONAL,
302 OUT UINT32 *EntryLength OPTIONAL,
303 OUT UINT32 *EntryCount OPTIONAL,
304 OUT EFI_ARP_FIND_DATA **Entries OPTIONAL,
305 IN BOOLEAN Refresh
306 )
307 {
308 EFI_STATUS Status;
309 ARP_INSTANCE_DATA *Instance;
310 EFI_TPL OldTpl;
311
312 if ((This == NULL) ||
313 (!Refresh && (EntryCount == NULL) && (EntryLength == NULL)) ||
314 ((Entries != NULL) && ((EntryLength == NULL) || (EntryCount == NULL)))) {
315 return EFI_INVALID_PARAMETER;
316 }
317
318 Instance = ARP_INSTANCE_DATA_FROM_THIS (This);
319
320 if (!Instance->Configured) {
321 return EFI_NOT_STARTED;
322 }
323
324 OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
325
326 //
327 // All the check passed, find the cache entries now.
328 //
329 Status = ArpFindCacheEntry (
330 Instance,
331 BySwAddress,
332 AddressBuffer,
333 EntryLength,
334 EntryCount,
335 Entries,
336 Refresh
337 );
338
339 gBS->RestoreTPL (OldTpl);
340
341 return Status;
342 }
343
344
345 /**
346 This function removes specified ARP cache entries.
347
348 @param This Pointer to the EFI_ARP_PROTOCOL instance.
349 @param BySwAddress Set to TRUE to delete matching protocol addresses.
350 Set to FALSE to delete matching hardware
351 addresses.
352 @param AddressBuffer Pointer to the address buffer that is used as a
353 key to look for the cache entry. Set to NULL to
354 delete all entries.
355
356 @retval EFI_SUCCESS The entry was removed from the ARP cache.
357 @retval EFI_INVALID_PARAMETER This is NULL.
358 @retval EFI_NOT_FOUND The specified deletion key was not found.
359 @retval EFI_NOT_STARTED The ARP driver instance has not been configured.
360
361 **/
362 EFI_STATUS
363 EFIAPI
364 ArpDelete (
365 IN EFI_ARP_PROTOCOL *This,
366 IN BOOLEAN BySwAddress,
367 IN VOID *AddressBuffer OPTIONAL
368 )
369 {
370 ARP_INSTANCE_DATA *Instance;
371 UINTN Count;
372 EFI_TPL OldTpl;
373
374 if (This == NULL) {
375 return EFI_INVALID_PARAMETER;
376 }
377
378 Instance = ARP_INSTANCE_DATA_FROM_THIS (This);
379
380 if (!Instance->Configured) {
381 return EFI_NOT_STARTED;
382 }
383
384 OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
385
386 //
387 // Delete the specified cache entries.
388 //
389 Count = ArpDeleteCacheEntry (Instance, BySwAddress, AddressBuffer, TRUE);
390
391 gBS->RestoreTPL (OldTpl);
392
393 return (Count == 0) ? EFI_NOT_FOUND : EFI_SUCCESS;
394 }
395
396
397 /**
398 This function delete all dynamic entries from the ARP cache that match the specified
399 software protocol type.
400
401 @param This Pointer to the EFI_ARP_PROTOCOL instance.
402
403 @retval EFI_SUCCESS The cache has been flushed.
404 @retval EFI_INVALID_PARAMETER This is NULL.
405 @retval EFI_NOT_FOUND There are no matching dynamic cache entries.
406 @retval EFI_NOT_STARTED The ARP driver instance has not been configured.
407
408 **/
409 EFI_STATUS
410 EFIAPI
411 ArpFlush (
412 IN EFI_ARP_PROTOCOL *This
413 )
414 {
415 ARP_INSTANCE_DATA *Instance;
416 UINTN Count;
417 EFI_TPL OldTpl;
418
419 if (This == NULL) {
420 return EFI_INVALID_PARAMETER;
421 }
422
423 Instance = ARP_INSTANCE_DATA_FROM_THIS (This);
424
425 if (!Instance->Configured) {
426 return EFI_NOT_STARTED;
427 }
428
429 OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
430
431 //
432 // Delete the dynamic entries from the cache table.
433 //
434 Count = ArpDeleteCacheEntry (Instance, FALSE, NULL, FALSE);
435
436 gBS->RestoreTPL (OldTpl);
437
438 return (Count == 0) ? EFI_NOT_FOUND : EFI_SUCCESS;
439 }
440
441
442 /**
443 This function tries to resolve the TargetSwAddress and optionally returns a
444 TargetHwAddress if it already exists in the ARP cache.
445
446 @param This Pointer to the EFI_ARP_PROTOCOL instance.
447 @param TargetSwAddress Pointer to the protocol address to resolve.
448 @param ResolvedEvent Pointer to the event that will be signaled when
449 the address is resolved or some error occurs.
450 @param TargetHwAddress Pointer to the buffer for the resolved hardware
451 address in network byte order.
452
453 @retval EFI_SUCCESS The data is copied from the ARP cache into the
454 TargetHwAddress buffer.
455 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
456 This is NULL. TargetHwAddress is NULL.
457 @retval EFI_ACCESS_DENIED The requested address is not present in the normal
458 ARP cache but is present in the deny address list.
459 Outgoing traffic to that address is forbidden.
460 @retval EFI_NOT_STARTED The ARP driver instance has not been configured.
461 @retval EFI_NOT_READY The request has been started and is not finished.
462
463 **/
464 EFI_STATUS
465 EFIAPI
466 ArpRequest (
467 IN EFI_ARP_PROTOCOL *This,
468 IN VOID *TargetSwAddress OPTIONAL,
469 IN EFI_EVENT ResolvedEvent OPTIONAL,
470 OUT VOID *TargetHwAddress
471 )
472 {
473 EFI_STATUS Status;
474 ARP_INSTANCE_DATA *Instance;
475 ARP_SERVICE_DATA *ArpService;
476 EFI_SIMPLE_NETWORK_MODE *SnpMode;
477 ARP_CACHE_ENTRY *CacheEntry;
478 NET_ARP_ADDRESS HardwareAddress;
479 NET_ARP_ADDRESS ProtocolAddress;
480 USER_REQUEST_CONTEXT *RequestContext;
481 EFI_TPL OldTpl;
482
483 if ((This == NULL) || (TargetHwAddress == NULL)) {
484 return EFI_INVALID_PARAMETER;
485 }
486
487 Instance = ARP_INSTANCE_DATA_FROM_THIS (This);
488
489 if (!Instance->Configured) {
490 return EFI_NOT_STARTED;
491 }
492
493 Status = EFI_SUCCESS;
494 ArpService = Instance->ArpService;
495 SnpMode = &ArpService->SnpMode;
496
497 if ((TargetSwAddress == NULL) ||
498 ((Instance->ConfigData.SwAddressType == IPv4_ETHER_PROTO_TYPE) &&
499 IP4_IS_LOCAL_BROADCAST (*((UINT32 *)TargetSwAddress)))) {
500 //
501 // Return the hardware broadcast address.
502 //
503 CopyMem (TargetHwAddress, &SnpMode->BroadcastAddress, SnpMode->HwAddressSize);
504
505 goto SIGNAL_USER;
506 }
507
508 if ((Instance->ConfigData.SwAddressType == IPv4_ETHER_PROTO_TYPE) &&
509 IP4_IS_MULTICAST (NTOHL (*((UINT32 *)TargetSwAddress)))) {
510 //
511 // If the software address is an IPv4 multicast address, invoke Mnp to
512 // resolve the address.
513 //
514 Status = ArpService->Mnp->McastIpToMac (
515 ArpService->Mnp,
516 FALSE,
517 TargetSwAddress,
518 TargetHwAddress
519 );
520 goto SIGNAL_USER;
521 }
522
523 HardwareAddress.Type = SnpMode->IfType;
524 HardwareAddress.Length = (UINT8)SnpMode->HwAddressSize;
525 HardwareAddress.AddressPtr = NULL;
526
527 ProtocolAddress.Type = Instance->ConfigData.SwAddressType;
528 ProtocolAddress.Length = Instance->ConfigData.SwAddressLength;
529 ProtocolAddress.AddressPtr = TargetSwAddress;
530
531 //
532 // Initialize the TargetHwAddrss to a zero address.
533 //
534 ZeroMem (TargetHwAddress, SnpMode->HwAddressSize);
535
536 OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
537
538 //
539 // Check whether the software address is in the denied table.
540 //
541 CacheEntry = ArpFindDeniedCacheEntry (ArpService, &ProtocolAddress, NULL);
542 if (CacheEntry != NULL) {
543 Status = EFI_ACCESS_DENIED;
544 goto UNLOCK_EXIT;
545 }
546
547 //
548 // Check whether the software address is already resolved.
549 //
550 CacheEntry = ArpFindNextCacheEntryInTable (
551 &ArpService->ResolvedCacheTable,
552 NULL,
553 ByProtoAddress,
554 &ProtocolAddress,
555 NULL
556 );
557 if (CacheEntry != NULL) {
558 //
559 // Resolved, copy the address into the user buffer.
560 //
561 CopyMem (
562 TargetHwAddress,
563 CacheEntry->Addresses[Hardware].AddressPtr,
564 CacheEntry->Addresses[Hardware].Length
565 );
566
567 goto UNLOCK_EXIT;
568 }
569
570 if (ResolvedEvent == NULL) {
571 Status = EFI_NOT_READY;
572 goto UNLOCK_EXIT;
573 }
574
575 //
576 // Create a request context for this arp request.
577 //
578 RequestContext = AllocatePool (sizeof(USER_REQUEST_CONTEXT));
579 if (RequestContext == NULL) {
580 DEBUG ((EFI_D_ERROR, "ArpRequest: Allocate memory for RequestContext failed.\n"));
581
582 Status = EFI_OUT_OF_RESOURCES;
583 goto UNLOCK_EXIT;
584 }
585
586 RequestContext->Instance = Instance;
587 RequestContext->UserRequestEvent = ResolvedEvent;
588 RequestContext->UserHwAddrBuffer = TargetHwAddress;
589 InitializeListHead (&RequestContext->List);
590
591 //
592 // Check whether there is a same request.
593 //
594 CacheEntry = ArpFindNextCacheEntryInTable (
595 &ArpService->PendingRequestTable,
596 NULL,
597 ByProtoAddress,
598 &ProtocolAddress,
599 NULL
600 );
601 if (CacheEntry != NULL) {
602
603 CacheEntry->NextRetryTime = Instance->ConfigData.RetryTimeOut;
604 CacheEntry->RetryCount = Instance->ConfigData.RetryCount;
605 } else {
606 //
607 // Allocate a cache entry for this request.
608 //
609 CacheEntry = ArpAllocCacheEntry (Instance);
610 if (CacheEntry == NULL) {
611 DEBUG ((EFI_D_ERROR, "ArpRequest: Allocate memory for CacheEntry failed.\n"));
612 gBS->FreePool (RequestContext);
613
614 Status = EFI_OUT_OF_RESOURCES;
615 goto UNLOCK_EXIT;
616 }
617
618 //
619 // Fill the software address.
620 //
621 ArpFillAddressInCacheEntry (CacheEntry, &HardwareAddress, &ProtocolAddress);
622
623 //
624 // Add this entry into the PendingRequestTable.
625 //
626 InsertTailList (&ArpService->PendingRequestTable, &CacheEntry->List);
627 }
628
629 //
630 // Link this request context into the cache entry.
631 //
632 InsertHeadList (&CacheEntry->UserRequestList, &RequestContext->List);
633
634 //
635 // Send out the ARP Request frame.
636 //
637 ArpSendFrame (Instance, CacheEntry, ARP_OPCODE_REQUEST);
638 Status = EFI_NOT_READY;
639
640 UNLOCK_EXIT:
641
642 gBS->RestoreTPL (OldTpl);
643
644 SIGNAL_USER:
645
646 if ((ResolvedEvent != NULL) && (Status == EFI_SUCCESS)) {
647 gBS->SignalEvent (ResolvedEvent);
648
649 //
650 // Dispatch the DPC queued by the NotifyFunction of ResolvedEvent.
651 //
652 NetLibDispatchDpc ();
653 }
654
655 return Status;
656 }
657
658
659 /**
660 This function aborts the previous ARP request (identified by This, TargetSwAddress
661 and ResolvedEvent) that is issued by EFI_ARP_PROTOCOL.Request().
662
663 @param This Pointer to the EFI_ARP_PROTOCOL instance.
664 @param TargetSwAddress Pointer to the protocol address in previous
665 request session.
666 @param ResolvedEvent Pointer to the event that is used as the
667 notification event in previous request session.
668
669 @retval EFI_SUCCESS The pending request session(s) is/are aborted and
670 corresponding event(s) is/are signaled.
671 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
672 This is NULL. TargetSwAddress is not NULL and
673 ResolvedEvent is NULL. TargetSwAddress is NULL and
674 ResolvedEvent is not NULL.
675 @retval EFI_NOT_STARTED The ARP driver instance has not been configured.
676 @retval EFI_NOT_FOUND The request is not issued by
677 EFI_ARP_PROTOCOL.Request().
678
679 **/
680 EFI_STATUS
681 EFIAPI
682 ArpCancel (
683 IN EFI_ARP_PROTOCOL *This,
684 IN VOID *TargetSwAddress OPTIONAL,
685 IN EFI_EVENT ResolvedEvent OPTIONAL
686 )
687 {
688 ARP_INSTANCE_DATA *Instance;
689 UINTN Count;
690 EFI_TPL OldTpl;
691
692 if ((This == NULL) ||
693 ((TargetSwAddress != NULL) && (ResolvedEvent == NULL)) ||
694 ((TargetSwAddress == NULL) && (ResolvedEvent != NULL))) {
695 return EFI_INVALID_PARAMETER;
696 }
697
698 Instance = ARP_INSTANCE_DATA_FROM_THIS (This);
699
700 if (!Instance->Configured) {
701 return EFI_NOT_STARTED;
702 }
703
704 OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
705
706 //
707 // Cancel the specified request.
708 //
709 Count = ArpCancelRequest (Instance, TargetSwAddress, ResolvedEvent);
710
711 //
712 // Dispatch the DPCs queued by the NotifyFunction of the events signaled
713 // by ArpCancleRequest.
714 //
715 NetLibDispatchDpc ();
716
717 gBS->RestoreTPL (OldTpl);
718
719 return (Count == 0) ? EFI_NOT_FOUND : EFI_SUCCESS;
720 }