Changeset 58459 in vbox for trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/Ip6Dxe/Ip6Common.c
- Timestamp:
- Oct 28, 2015 8:17:18 PM (9 years ago)
- svn:sync-xref-src-repo-rev:
- 103761
- Location:
- trunk/src/VBox/Devices/EFI/Firmware
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/EFI/Firmware
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/Ip6Dxe/Ip6Common.c
r48674 r58459 2 2 The implementation of common functions shared by IP6 driver. 3 3 4 Copyright (c) 2009 - 201 0, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR> 5 5 6 6 This program and the accompanying materials … … 330 330 331 331 /** 332 Callback function which provided by user to remove one node in NetDestroyLinkList process. 333 334 @param[in] Entry The entry to be removed. 335 @param[in] Context Pointer to the callback context corresponds to the Context in NetDestroyLinkList. 336 337 @retval EFI_SUCCESS The entry has been removed successfully. 338 @retval Others Fail to remove the entry. 339 340 **/ 341 EFI_STATUS 342 EFIAPI 343 Ip6DestroyChildEntryByAddr ( 344 IN LIST_ENTRY *Entry, 345 IN VOID *Context 346 ) 347 { 348 IP6_PROTOCOL *Instance; 349 EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding; 350 EFI_IPv6_ADDRESS *Address; 351 352 Instance = NET_LIST_USER_STRUCT_S (Entry, IP6_PROTOCOL, Link, IP6_PROTOCOL_SIGNATURE); 353 ServiceBinding = ((IP6_DESTROY_CHILD_BY_ADDR_CALLBACK_CONTEXT*) Context)->ServiceBinding; 354 Address = ((IP6_DESTROY_CHILD_BY_ADDR_CALLBACK_CONTEXT*) Context)->Address; 355 356 if ((Instance->State == IP6_STATE_CONFIGED) && EFI_IP6_EQUAL (&Instance->ConfigData.StationAddress, Address)) { 357 return ServiceBinding->DestroyChild (ServiceBinding, Instance->Handle); 358 } 359 360 return EFI_SUCCESS; 361 } 362 363 /** 332 364 Destroy the IP instance if its StationAddress is removed. It is the help function 333 365 for Ip6RemoveAddr(). … … 343 375 ) 344 376 { 345 BOOLEAN OneDestroyed; 346 EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding; 347 LIST_ENTRY *Entry; 348 IP6_PROTOCOL *Instance; 377 LIST_ENTRY *List; 378 IP6_DESTROY_CHILD_BY_ADDR_CALLBACK_CONTEXT Context; 349 379 350 380 NET_CHECK_SIGNATURE (IpSb, IP6_SERVICE_SIGNATURE); 351 381 352 ServiceBinding = &IpSb->ServiceBinding; 353 354 // 355 // Upper layer IP protocol consumers may have tight relationship between several 356 // IP protocol instances, in other words, calling ServiceBinding->DestroyChild to 357 // destroy one IP child may cause other related IP children destroyed too. This 358 // will probably leave hole in the children list when we iterate it. So everytime 359 // we just destroy one child then back to the start point to iterate the list. 360 // 361 do { 362 OneDestroyed = FALSE; 363 364 NET_LIST_FOR_EACH (Entry, &IpSb->Children) { 365 Instance = NET_LIST_USER_STRUCT_S (Entry, IP6_PROTOCOL, Link, IP6_PROTOCOL_SIGNATURE); 366 367 if ((Instance->State == IP6_STATE_CONFIGED) && EFI_IP6_EQUAL (&Instance->ConfigData.StationAddress, Address)) { 368 ServiceBinding->DestroyChild (ServiceBinding, Instance->Handle); 369 OneDestroyed = TRUE; 370 break; 371 } 372 } 373 } while (OneDestroyed); 382 List = &IpSb->Children; 383 Context.ServiceBinding = &IpSb->ServiceBinding; 384 Context.Address = Address; 385 NetDestroyLinkList ( 386 List, 387 Ip6DestroyChildEntryByAddr, 388 &Context, 389 NULL 390 ); 374 391 } 375 392 … … 635 652 636 653 /** 637 Set the Ip6 variable data.638 639 @param[in] IpSb Points to an IP6 service binding instance.640 641 @retval EFI_OUT_OF_RESOURCES There are not enough resources to set the variable.642 @retval other Set variable failed.643 644 **/645 EFI_STATUS646 Ip6SetVariableData (647 IN IP6_SERVICE *IpSb648 )649 {650 UINT32 NumConfiguredInstance;651 LIST_ENTRY *Entry;652 UINTN VariableDataSize;653 EFI_IP6_VARIABLE_DATA *Ip6VariableData;654 EFI_IP6_ADDRESS_PAIR *Ip6AddressPair;655 IP6_PROTOCOL *IpInstance;656 CHAR16 *NewMacString;657 EFI_STATUS Status;658 659 NumConfiguredInstance = 0;660 661 //662 // Go through the children list to count the configured children.663 //664 NET_LIST_FOR_EACH (Entry, &IpSb->Children) {665 IpInstance = NET_LIST_USER_STRUCT_S (Entry, IP6_PROTOCOL, Link, IP6_PROTOCOL_SIGNATURE);666 667 if (IpInstance->State == IP6_STATE_CONFIGED) {668 NumConfiguredInstance++;669 }670 }671 672 //673 // Calculate the size of the Ip6VariableData. As there may be no IP child,674 // we should add extra buffer for the address paris only if the number of configured675 // children is more than 1.676 //677 VariableDataSize = sizeof (EFI_IP6_VARIABLE_DATA);678 679 if (NumConfiguredInstance > 1) {680 VariableDataSize += sizeof (EFI_IP6_ADDRESS_PAIR) * (NumConfiguredInstance - 1);681 }682 683 Ip6VariableData = AllocatePool (VariableDataSize);684 if (Ip6VariableData == NULL) {685 return EFI_OUT_OF_RESOURCES;686 }687 688 Ip6VariableData->DriverHandle = IpSb->Image;689 Ip6VariableData->AddressCount = NumConfiguredInstance;690 691 Ip6AddressPair = &Ip6VariableData->AddressPairs[0];692 693 //694 // Go through the children list to fill the configured children's address pairs.695 //696 NET_LIST_FOR_EACH (Entry, &IpSb->Children) {697 IpInstance = NET_LIST_USER_STRUCT_S (Entry, IP6_PROTOCOL, Link, IP6_PROTOCOL_SIGNATURE);698 699 if (IpInstance->State == IP6_STATE_CONFIGED) {700 Ip6AddressPair->InstanceHandle = IpInstance->Handle;701 Ip6AddressPair->PrefixLength = IpInstance->PrefixLength;702 IP6_COPY_ADDRESS (&Ip6AddressPair->Ip6Address, &IpInstance->ConfigData.StationAddress);703 704 Ip6AddressPair++;705 }706 }707 708 //709 // Get the mac string.710 //711 Status = NetLibGetMacString (IpSb->Controller, IpSb->Image, &NewMacString);712 if (EFI_ERROR (Status)) {713 goto Exit;714 }715 716 if (IpSb->MacString != NULL) {717 //718 // The variable is set already, we're going to update it.719 //720 if (StrCmp (IpSb->MacString, NewMacString) != 0) {721 //722 // The mac address is changed, delete the previous variable first.723 //724 gRT->SetVariable (725 IpSb->MacString,726 &gEfiIp6ServiceBindingProtocolGuid,727 EFI_VARIABLE_BOOTSERVICE_ACCESS,728 0,729 NULL730 );731 }732 733 FreePool (IpSb->MacString);734 }735 736 IpSb->MacString = NewMacString;737 738 Status = gRT->SetVariable (739 IpSb->MacString,740 &gEfiIp6ServiceBindingProtocolGuid,741 EFI_VARIABLE_BOOTSERVICE_ACCESS,742 VariableDataSize,743 (VOID *) Ip6VariableData744 );745 746 Exit:747 FreePool (Ip6VariableData);748 return Status;749 }750 751 /**752 Clear the variable and free the resource.753 754 @param[in] IpSb Ip6 service binding instance.755 756 **/757 VOID758 Ip6ClearVariableData (759 IN IP6_SERVICE *IpSb760 )761 {762 ASSERT (IpSb->MacString != NULL);763 764 gRT->SetVariable (765 IpSb->MacString,766 &gEfiIp6ServiceBindingProtocolGuid,767 EFI_VARIABLE_BOOTSERVICE_ACCESS,768 0,769 NULL770 );771 772 FreePool (IpSb->MacString);773 IpSb->MacString = NULL;774 }775 776 /**777 654 Convert the multibyte field in IP header's byter order. 778 655 In spite of its name, it can also be used to convert from
Note:
See TracChangeset
for help on using the changeset viewer.