1. fixed one bug to construct config request string header used child handle instead of NIC controller handle.

2. fixed one bug to calculate buffer size.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@10617 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
vanjeff 2010-07-01 01:30:23 +00:00
parent 25400c63fa
commit 1dc1b43fc2
2 changed files with 93 additions and 4 deletions

View File

@ -20,6 +20,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <Protocol/HiiConfigRouting.h>
#include <Protocol/ComponentName.h>
#include <Protocol/ComponentName2.h>
#include <Protocol/HiiConfigAccess.h>
#include <Guid/NicIp4ConfigNvData.h>
@ -33,6 +34,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <Library/DevicePathLib.h>
#include <Library/HiiLib.h>
#include <Library/PrintLib.h>
#include <Library/UefiLib.h>
#define NIC_ITEM_CONFIG_SIZE sizeof (NIC_IP4_CONFIG_INFO) + sizeof (EFI_IP4_ROUTE_TABLE) * MAX_IP4_CONFIG_IN_VARIABLE
@ -1570,6 +1572,86 @@ NetMapIterate (
}
/**
Internal function to get the child handle of the NIC handle.
@param[in] Controller NIC controller handle.
@param[out] ChildHandle Returned child handle.
@retval EFI_SUCCESS Successfully to get child handle.
@retval Others Failed to get child handle.
**/
EFI_STATUS
NetGetChildHandle (
IN EFI_HANDLE Controller,
OUT EFI_HANDLE *ChildHandle
)
{
EFI_STATUS Status;
EFI_HANDLE *Handles;
UINTN HandleCount;
UINTN Index;
EFI_DEVICE_PATH_PROTOCOL *ChildDeviceDevicePath;
VENDOR_DEVICE_PATH *VendorDeviceNode;
//
// Locate all EFI Hii Config Access protocols
//
Status = gBS->LocateHandleBuffer (
ByProtocol,
&gEfiHiiConfigAccessProtocolGuid,
NULL,
&HandleCount,
&Handles
);
if (EFI_ERROR (Status) || (HandleCount == 0)) {
return Status;
}
Status = EFI_NOT_FOUND;
for (Index = 0; Index < HandleCount; Index++) {
Status = EfiTestChildHandle (Controller, Handles[Index], &gEfiManagedNetworkServiceBindingProtocolGuid);
if (!EFI_ERROR (Status)) {
//
// Get device path on the child handle
//
Status = gBS->HandleProtocol (
Handles[Index],
&gEfiDevicePathProtocolGuid,
(VOID **) &ChildDeviceDevicePath
);
if (!EFI_ERROR (Status)) {
while (!IsDevicePathEnd (ChildDeviceDevicePath)) {
ChildDeviceDevicePath = NextDevicePathNode (ChildDeviceDevicePath);
//
// Parse one instance
//
if (ChildDeviceDevicePath->Type == HARDWARE_DEVICE_PATH &&
ChildDeviceDevicePath->SubType == HW_VENDOR_DP) {
VendorDeviceNode = (VENDOR_DEVICE_PATH *) ChildDeviceDevicePath;
if (CompareMem (&VendorDeviceNode->Guid, &gEfiNicIp4ConfigVariableGuid, sizeof (EFI_GUID)) == 0) {
//
// Found item matched gEfiNicIp4ConfigVariableGuid
//
*ChildHandle = Handles[Index];
FreePool (Handles);
return EFI_SUCCESS;
}
}
}
}
}
}
FreePool (Handles);
return Status;
}
/**
This is the default unload handle for all the network drivers.
@ -2391,6 +2473,7 @@ NetLibDefaultAddressIsStatic (
EFI_STRING AccessProgress;
EFI_STRING AccessResults;
EFI_STRING String;
EFI_HANDLE ChildHandle;
ConfigInfo = NULL;
ConfigHdr = NULL;
@ -2408,10 +2491,15 @@ NetLibDefaultAddressIsStatic (
return TRUE;
}
Status = NetGetChildHandle (Controller, &ChildHandle);
if (EFI_ERROR (Status)) {
return TRUE;
}
//
// Construct config request string header
//
ConfigHdr = HiiConstructConfigHdr (&gEfiNicIp4ConfigVariableGuid, EFI_NIC_IP4_CONFIG_VARIABLE, Controller);
ConfigHdr = HiiConstructConfigHdr (&gEfiNicIp4ConfigVariableGuid, EFI_NIC_IP4_CONFIG_VARIABLE, ChildHandle);
if (ConfigHdr == NULL) {
return TRUE;
}
@ -2442,7 +2530,7 @@ NetLibDefaultAddressIsStatic (
goto ON_EXIT;
}
ConfigInfo = AllocateZeroPool (sizeof (NIC_ITEM_CONFIG_SIZE));
ConfigInfo = AllocateZeroPool (NIC_ITEM_CONFIG_SIZE);
if (ConfigInfo == NULL) {
goto ON_EXIT;
}
@ -2983,7 +3071,7 @@ NetLibStrToIp6andPrefix (
// If input string doesn't indicate the prefix length, return 0xff.
//
Length = 0xFF;
//
// Convert the string to prefix length
//

View File

@ -49,7 +49,7 @@
HiiLib
PrintLib
[Guids]
[Guids]
gEfiNicIp4ConfigVariableGuid
[Protocols]
@ -59,3 +59,4 @@
gEfiComponentNameProtocolGuid # PROTOCOL ALWAYS_CONSUMED
gEfiComponentName2ProtocolGuid # PROTOCOL ALWAYS_CONSUMED
gEfiHiiConfigRoutingProtocolGuid # PROTOCOL ALWAYS_CONSUMED
gEfiHiiConfigAccessProtocolGuid # PROTOCOL ALWAYS_CONSUMED