/** @file\r
ARP driver functions.\r
\r
-Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>\r
This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
which accompanies this distribution. The full text of the license may be found at<BR>\r
\r
ArpService->Signature = ARP_SERVICE_DATA_SIGNATURE;\r
\r
+ //\r
+ // Init the lists.\r
+ //\r
+ InitializeListHead (&ArpService->ChildrenList);\r
+ InitializeListHead (&ArpService->PendingRequestTable);\r
+ InitializeListHead (&ArpService->DeniedCacheTable);\r
+ InitializeListHead (&ArpService->ResolvedCacheTable);\r
+\r
//\r
// Init the servicebinding protocol members.\r
//\r
TimerPeriodic,\r
ARP_PERIODIC_TIMER_INTERVAL\r
);\r
- if (EFI_ERROR (Status)) {\r
- goto ERROR_EXIT;\r
- }\r
-\r
- //\r
- // Init the lists.\r
- //\r
- InitializeListHead (&ArpService->ChildrenList);\r
- InitializeListHead (&ArpService->PendingRequestTable);\r
- InitializeListHead (&ArpService->DeniedCacheTable);\r
- InitializeListHead (&ArpService->ResolvedCacheTable);\r
\r
ERROR_EXIT:\r
\r
}\r
}\r
\r
+/**\r
+ Callback function which provided by user to remove one node in NetDestroyLinkList process.\r
+ \r
+ @param[in] Entry The entry to be removed.\r
+ @param[in] Context Pointer to the callback context corresponds to the Context in NetDestroyLinkList.\r
+\r
+ @retval EFI_SUCCESS The entry has been removed successfully.\r
+ @retval Others Fail to remove the entry.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+ArpDestroyChildEntryInHandleBuffer (\r
+ IN LIST_ENTRY *Entry,\r
+ IN VOID *Context\r
+ )\r
+{\r
+ ARP_INSTANCE_DATA *Instance;\r
+ EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding;\r
+ \r
+ if (Entry == NULL || Context == NULL) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ Instance = NET_LIST_USER_STRUCT_S (Entry, ARP_INSTANCE_DATA, List, ARP_INSTANCE_DATA_SIGNATURE);\r
+ ServiceBinding = (EFI_SERVICE_BINDING_PROTOCOL *) Context;\r
+\r
+ return ServiceBinding->DestroyChild (ServiceBinding, Instance->Handle);\r
+}\r
+\r
/**\r
Tests to see if this driver supports a given controller. \r
\r
EFI_HANDLE NicHandle;\r
EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding;\r
ARP_SERVICE_DATA *ArpService;\r
- ARP_INSTANCE_DATA *Instance;\r
+ LIST_ENTRY *List;\r
\r
//\r
// Get the NicHandle which the arp servicebinding is installed on.\r
//\r
NicHandle = NetLibGetNicHandle (ControllerHandle, &gEfiManagedNetworkProtocolGuid);\r
if (NicHandle == NULL) {\r
- return EFI_DEVICE_ERROR;\r
+ return EFI_SUCCESS;\r
}\r
\r
//\r
\r
ArpService = ARP_SERVICE_DATA_FROM_THIS (ServiceBinding);\r
\r
- if (NumberOfChildren == 0) {\r
+ if (NumberOfChildren != 0) {\r
+ //\r
+ // NumberOfChildren is not zero, destroy all the ARP children instances.\r
+ //\r
+ List = &ArpService->ChildrenList;\r
+ Status = NetDestroyLinkList (\r
+ List,\r
+ ArpDestroyChildEntryInHandleBuffer,\r
+ ServiceBinding,\r
+ NULL\r
+ );\r
+ ASSERT (IsListEmpty (&ArpService->PendingRequestTable));\r
+ ASSERT (IsListEmpty (&ArpService->DeniedCacheTable));\r
+ ASSERT (IsListEmpty (&ArpService->ResolvedCacheTable));\r
+ } else if (IsListEmpty (&ArpService->ChildrenList)) {\r
//\r
// Uninstall the ARP ServiceBinding protocol.\r
//\r
ArpCleanService (ArpService);\r
\r
FreePool (ArpService);\r
- } else {\r
-\r
- while (!IsListEmpty (&ArpService->ChildrenList)) {\r
- Instance = NET_LIST_HEAD (&ArpService->ChildrenList, ARP_INSTANCE_DATA, List);\r
-\r
- ServiceBinding->DestroyChild (ServiceBinding, Instance->Handle);\r
- }\r
-\r
- ASSERT (IsListEmpty (&ArpService->PendingRequestTable));\r
- ASSERT (IsListEmpty (&ArpService->DeniedCacheTable));\r
- ASSERT (IsListEmpty (&ArpService->ResolvedCacheTable));\r
}\r
\r
return EFI_SUCCESS;\r
\r
@retval EFI_SUCCES The protocol was added to ChildHandle.\r
@retval EFI_INVALID_PARAMETER ChildHandle is NULL.\r
- @retval EFI_OUT_OF_RESOURCES There are not enough resources availabe to create\r
+ @retval EFI_OUT_OF_RESOURCES There are not enough resources available to create\r
the child\r
@retval other The child handle was not created\r
\r
@retval EFI_SUCCES The protocol was removed from ChildHandle.\r
@retval EFI_UNSUPPORTED ChildHandle does not support the protocol that is \r
being removed.\r
- @retval EFI_INVALID_PARAMETER Child handle is not a valid UEFI Handle.\r
+ @retval EFI_INVALID_PARAMETER Child handle is NULL.\r
@retval EFI_ACCESS_DENIED The protocol could not be removed from the ChildHandle\r
because its services are being used.\r
@retval other The child handle was not destroyed\r
\r
Instance = ARP_INSTANCE_DATA_FROM_THIS (Arp);\r
\r
- if (Instance->Destroyed) {\r
+ if (Instance->InDestroy) {\r
return EFI_SUCCESS;\r
}\r
\r
//\r
- // Use the Destroyed as a flag to avoid re-entrance.\r
+ // Use the InDestroy as a flag to avoid re-entrance.\r
//\r
- Instance->Destroyed = TRUE;\r
+ Instance->InDestroy = TRUE;\r
\r
//\r
// Close the Managed Network protocol.\r
DEBUG ((EFI_D_ERROR, "ArpSBDestroyChild: Failed to uninstall the arp protocol, %r.\n",\r
Status));\r
\r
- Instance->Destroyed = FALSE;\r
+ Instance->InDestroy = FALSE;\r
return Status;\r
}\r
\r