/** @file\r
The implementation of common functions shared by IP6 driver.\r
\r
- Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>\r
+ Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>\r
\r
This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
IpIf->AddressCount++;\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
+Ip6DestroyChildEntryByAddr (\r
+ IN LIST_ENTRY *Entry,\r
+ IN VOID *Context\r
+)\r
+{\r
+ IP6_PROTOCOL *Instance;\r
+ EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding;\r
+ EFI_IPv6_ADDRESS *Address;\r
+ \r
+ Instance = NET_LIST_USER_STRUCT_S (Entry, IP6_PROTOCOL, Link, IP6_PROTOCOL_SIGNATURE);\r
+ ServiceBinding = ((IP6_DESTROY_CHILD_BY_ADDR_CALLBACK_CONTEXT*) Context)->ServiceBinding;\r
+ Address = ((IP6_DESTROY_CHILD_BY_ADDR_CALLBACK_CONTEXT*) Context)->Address;\r
+\r
+ if ((Instance->State == IP6_STATE_CONFIGED) && EFI_IP6_EQUAL (&Instance->ConfigData.StationAddress, Address)) {\r
+ return ServiceBinding->DestroyChild (ServiceBinding, Instance->Handle);\r
+ }\r
+ \r
+ return EFI_SUCCESS;\r
+}\r
+\r
/**\r
Destroy the IP instance if its StationAddress is removed. It is the help function\r
for Ip6RemoveAddr().\r
IN EFI_IPv6_ADDRESS *Address\r
)\r
{\r
- BOOLEAN OneDestroyed;\r
- EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding;\r
- LIST_ENTRY *Entry;\r
- IP6_PROTOCOL *Instance;\r
+ LIST_ENTRY *List;\r
+ IP6_DESTROY_CHILD_BY_ADDR_CALLBACK_CONTEXT Context;\r
\r
NET_CHECK_SIGNATURE (IpSb, IP6_SERVICE_SIGNATURE);\r
\r
- ServiceBinding = &IpSb->ServiceBinding;\r
-\r
- //\r
- // Upper layer IP protocol consumers may have tight relationship between several\r
- // IP protocol instances, in other words, calling ServiceBinding->DestroyChild to\r
- // destroy one IP child may cause other related IP children destroyed too. This\r
- // will probably leave hole in the children list when we iterate it. So everytime\r
- // we just destroy one child then back to the start point to iterate the list.\r
- //\r
- do {\r
- OneDestroyed = FALSE;\r
-\r
- NET_LIST_FOR_EACH (Entry, &IpSb->Children) {\r
- Instance = NET_LIST_USER_STRUCT_S (Entry, IP6_PROTOCOL, Link, IP6_PROTOCOL_SIGNATURE);\r
-\r
- if ((Instance->State == IP6_STATE_CONFIGED) && EFI_IP6_EQUAL (&Instance->ConfigData.StationAddress, Address)) {\r
- ServiceBinding->DestroyChild (ServiceBinding, Instance->Handle);\r
- OneDestroyed = TRUE;\r
- break;\r
- }\r
- }\r
- } while (OneDestroyed);\r
+ List = &IpSb->Children;\r
+ Context.ServiceBinding = &IpSb->ServiceBinding;\r
+ Context.Address = Address;\r
+ NetDestroyLinkList (\r
+ List,\r
+ Ip6DestroyChildEntryByAddr,\r
+ &Context,\r
+ NULL\r
+ );\r
}\r
\r
/**\r