1)Remove “Back to Previous Page'”, since it cannot go back to “Device Manager page.

2)Add Configure item in page.
3)Add more security check when storing IP setting, to correctly sync the operations between Ip4ConfigDxe and ifconfig.efi


git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@9693 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
vanjeff 2010-01-08 05:00:19 +00:00
parent 1ace000135
commit c22b6cdfa7
6 changed files with 117 additions and 70 deletions

View File

@ -1,7 +1,7 @@
/** @file
Header file for IP4Config driver.
Copyright (c) 2006 - 2009, Intel Corporation.<BR>
Copyright (c) 2006 - 2010, Intel Corporation.<BR>
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at<BR>
@ -79,7 +79,8 @@ typedef struct {
#pragma pack()
typedef struct _IP4CONFIG_CALLBACK_INFO {
BOOLEAN Enabled;
BOOLEAN Configured;
BOOLEAN DhcpEnabled;
EFI_IPv4_ADDRESS LocalIp;
EFI_IPv4_ADDRESS SubnetMask;
EFI_IPv4_ADDRESS Gateway;

View File

@ -1,7 +1,7 @@
/** @file
The driver binding for IP4 CONFIG protocol.
Copyright (c) 2006 - 2009, Intel Corporation.<BR>
Copyright (c) 2006 - 2010, Intel Corporation.<BR>
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at<BR>

View File

@ -1,7 +1,7 @@
/** @file
Vfr file for IP4 config.
Copyright (c) 2009, Intel Corporation.<BR>
Copyright (c) 2009 - 2010, Intel Corporation.<BR>
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@ -29,14 +29,25 @@ formset
form formid = FORMID_MAIN_FORM,
title = STRING_TOKEN(STR_IP4_DEVICE_FORM_TITLE);
checkbox varid = EfiNicIp4ConfigVariable.Configure,
prompt = STRING_TOKEN(STR_IP4_CONFIGURE),
help = STRING_TOKEN(STR_IP4_CONFIGURE),
flags = INTERACTIVE,
key = KEY_ENABLE,
endcheckbox;
suppressif ideqval EfiNicIp4ConfigVariable.Configure == 0x00;
checkbox varid = EfiNicIp4ConfigVariable.DhcpEnable,
prompt = STRING_TOKEN(STR_IP4_ENABLE_DHCP),
help = STRING_TOKEN(STR_IP4_ENABLE_DHCP),
flags = INTERACTIVE,
key = KEY_DHCP_ENABLE,
endcheckbox;
endif;
suppressif ideqval EfiNicIp4ConfigVariable.DhcpEnable == 0x01 OR ideqval EfiNicIp4ConfigVariable.Configure == 0x00;
suppressif ideqval EfiNicIp4ConfigVariable.DhcpEnable == 0x01;
string varid = EfiNicIp4ConfigVariable.StationAddress,
prompt = STRING_TOKEN(STR_IP4_LOCAL_IP_ADDRESS),
help = STRING_TOKEN(STR_IP4_IP_ADDRESS_HELP),
@ -63,6 +74,7 @@ formset
minsize = IP_MIN_SIZE,
maxsize = IP_MAX_SIZE,
endstring;
endif;
subtitle text = STRING_TOKEN(STR_NULL);
@ -73,11 +85,6 @@ formset
flags = INTERACTIVE,
key = KEY_SAVE_CHANGES;
goto FORMID_MAIN_FORM,
prompt = STRING_TOKEN (STR_RETURN_MAIN_FORM),
help = STRING_TOKEN (STR_RETURN_MAIN_FORM),
flags = 0;
endform;
endformset;

View File

@ -1,7 +1,7 @@
/** @file
Helper functions for configuring or getting the parameters relating to Ip4.
Copyright (c) 2009, Intel Corporation.<BR>
Copyright (c) 2009 - 2010, Intel Corporation.<BR>
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@ -152,13 +152,12 @@ Ip4ConfigConvertDeviceConfigDataToIfrNvData (
NIC_IP4_CONFIG_INFO *NicConfig;
UINTN ConfigLen;
IfrFormNvData->DhcpEnable = 1;
ConfigLen = sizeof (NIC_IP4_CONFIG_INFO) + sizeof (EFI_IP4_ROUTE_TABLE) * 2;
NicConfig = AllocateZeroPool (ConfigLen);
ASSERT (NicConfig != NULL);
Status = EfiNicIp4ConfigGetInfo (Ip4ConfigInstance, &ConfigLen, NicConfig);
if (!EFI_ERROR (Status)) {
IfrFormNvData->Configure = 1;
if (NicConfig->Source == IP4_CONFIG_SOURCE_DHCP) {
IfrFormNvData->DhcpEnable = 1;
} else {
@ -167,7 +166,10 @@ Ip4ConfigConvertDeviceConfigDataToIfrNvData (
Ip4ConfigIpToStr (&NicConfig->Ip4Info.SubnetMask, IfrFormNvData->SubnetMask);
Ip4ConfigIpToStr (&NicConfig->Ip4Info.RouteTable[1].GatewayAddress, IfrFormNvData->GatewayAddress);
}
} else {
IfrFormNvData->Configure = 0;
}
FreePool (NicConfig);
}
@ -175,7 +177,6 @@ Ip4ConfigConvertDeviceConfigDataToIfrNvData (
Convert the IFR data into the network configuration data and set the IP
configure parameters for the NIC.
@param[in] IfrFormNvData The IFR nv data.
@param[in, out] Ip4ConfigInstance The IP4Config instance.
@retval EFI_SUCCESS The configure parameter for this NIC was
@ -186,10 +187,10 @@ Ip4ConfigConvertDeviceConfigDataToIfrNvData (
**/
EFI_STATUS
Ip4ConfigConvertIfrNvDataToDeviceConfigData (
IN IP4_CONFIG_IFR_NVDATA *IfrFormNvData,
IN OUT IP4_CONFIG_INSTANCE *Ip4ConfigInstance
)
{
EFI_STATUS Status;
EFI_IP_ADDRESS HostIp;
EFI_IP_ADDRESS SubnetMask;
EFI_IP_ADDRESS Gateway;
@ -197,16 +198,39 @@ Ip4ConfigConvertIfrNvDataToDeviceConfigData (
NIC_IP4_CONFIG_INFO *NicInfo;
EFI_IP_ADDRESS Ip;
if (!Ip4ConfigInstance->Ip4ConfigCallbackInfo.Configured) {
//
// Clear the variable
//
ZeroMem (&Ip4ConfigInstance->Ip4ConfigCallbackInfo, sizeof (IP4_SETTING_INFO));
Status = EfiNicIp4ConfigSetInfo (Ip4ConfigInstance, NULL, TRUE);
if (Status == EFI_NOT_FOUND) {
return EFI_SUCCESS;
}
return Status;
}
NicInfo = AllocateZeroPool (sizeof (NIC_IP4_CONFIG_INFO) + 2 * sizeof (EFI_IP4_ROUTE_TABLE));
ASSERT (NicInfo != NULL);
NicInfo->Ip4Info.RouteTable = (EFI_IP4_ROUTE_TABLE *) (NicInfo + 1);
if (!Ip4ConfigInstance->Ip4ConfigCallbackInfo.Enabled) {
if (!Ip4ConfigInstance->Ip4ConfigCallbackInfo.DhcpEnabled) {
CopyMem (&HostIp.v4, &Ip4ConfigInstance->Ip4ConfigCallbackInfo.LocalIp, sizeof (HostIp.v4));
CopyMem (&SubnetMask.v4, &Ip4ConfigInstance->Ip4ConfigCallbackInfo.SubnetMask, sizeof (SubnetMask.v4));
CopyMem (&Gateway.v4, &Ip4ConfigInstance->Ip4ConfigCallbackInfo.Gateway, sizeof (Gateway.v4));
if (!NetIp4IsUnicast (NTOHL (HostIp.Addr[0]), 0)) {
CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Invalid IP address!", NULL);
return EFI_INVALID_PARAMETER;
}
if (EFI_IP4_EQUAL (&SubnetMask, &mZeroIp4Addr)) {
CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Invalid Subnet Mask!", NULL);
return EFI_INVALID_PARAMETER;
}
if ((Gateway.Addr[0] != 0)) {
if (SubnetMask.Addr[0] == 0) {
CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Gateway address is set but subnet mask is zero.", NULL);
@ -228,8 +252,12 @@ Ip4ConfigConvertIfrNvDataToDeviceConfigData (
CopyMem (&NicInfo->Ip4Info.RouteTable[0].SubnetAddress, &Ip.v4, sizeof (EFI_IPv4_ADDRESS));
CopyMem (&NicInfo->Ip4Info.RouteTable[0].SubnetMask, &SubnetMask.v4, sizeof (EFI_IPv4_ADDRESS));
CopyMem (&NicInfo->Ip4Info.RouteTable[1].GatewayAddress, &Gateway.v4, sizeof (EFI_IPv4_ADDRESS));
} else {
NicInfo->Source = IP4_CONFIG_SOURCE_DHCP;
ZeroMem (&Ip4ConfigInstance->Ip4ConfigCallbackInfo.LocalIp, sizeof (EFI_IPv4_ADDRESS));
ZeroMem (&Ip4ConfigInstance->Ip4ConfigCallbackInfo.SubnetMask, sizeof (EFI_IPv4_ADDRESS));
ZeroMem (&Ip4ConfigInstance->Ip4ConfigCallbackInfo.Gateway, sizeof (EFI_IPv4_ADDRESS));
}
NicInfo->Perment = TRUE;
@ -462,7 +490,7 @@ Ip4DeviceRouteConfig (
Progress
);
if (!EFI_ERROR (Status)) {
Status = Ip4ConfigConvertIfrNvDataToDeviceConfigData (IfrFormNvData, Ip4ConfigInstance);
Status = Ip4ConfigConvertIfrNvDataToDeviceConfigData (Ip4ConfigInstance);
}
FreePool (IfrFormNvData);
@ -489,6 +517,7 @@ Ip4DeviceRouteConfig (
NicInfo = AllocateCopyPool (BufferSize, IfrDeviceNvData);
Status = EfiNicIp4ConfigSetInfo (Ip4ConfigInstance, NicInfo, TRUE);
} else {
ZeroMem (&Ip4ConfigInstance->Ip4ConfigCallbackInfo, sizeof (IP4_SETTING_INFO));
Status = EfiNicIp4ConfigSetInfo (Ip4ConfigInstance, NULL, TRUE);
}
}
@ -569,11 +598,19 @@ Ip4FormCallback (
switch (QuestionId) {
case KEY_ENABLE:
if (IfrFormNvData->Configure == 0) {
Ip4ConfigInstance->Ip4ConfigCallbackInfo.Configured = FALSE;
} else {
Ip4ConfigInstance->Ip4ConfigCallbackInfo.Configured = TRUE;
}
break;
case KEY_DHCP_ENABLE:
if (IfrFormNvData->DhcpEnable == 0) {
Ip4ConfigInstance->Ip4ConfigCallbackInfo.Enabled = FALSE;
Ip4ConfigInstance->Ip4ConfigCallbackInfo.DhcpEnabled = FALSE;
} else {
Ip4ConfigInstance->Ip4ConfigCallbackInfo.Enabled = TRUE;
Ip4ConfigInstance->Ip4ConfigCallbackInfo.DhcpEnabled = TRUE;
}
break;
@ -615,7 +652,8 @@ Ip4FormCallback (
break;
case KEY_SAVE_CHANGES:
Status = Ip4ConfigConvertIfrNvDataToDeviceConfigData (IfrFormNvData, Ip4ConfigInstance);
Status = Ip4ConfigConvertIfrNvDataToDeviceConfigData (Ip4ConfigInstance);
*ActionRequest = EFI_BROWSER_ACTION_REQUEST_SUBMIT;

View File

@ -1,7 +1,7 @@
/** @file
Routines used to operate the Ip4 configure variable.
Copyright (c) 2009, Intel Corporation.<BR>
Copyright (c) 2009 - 2010, Intel Corporation.<BR>
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at<BR>
@ -23,6 +23,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#define FORMID_MAIN_FORM 1
#define FORMID_DEVICE_FORM 2
#define KEY_ENABLE 0x100
#define KEY_DHCP_ENABLE 0x101
#define KEY_LOCAL_IP 0x102
#define KEY_SUBNET_MASK 0x103
@ -40,7 +41,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
///
typedef struct {
UINT16 NicAddr[3]; ///< NIC MAC address
UINT8 Reserved; ///< Reserved bits
UINT8 Configure; ///< NIC configure status
UINT8 DhcpEnable; ///< Static or DHCP
CHAR16 StationAddress[IP4_STR_MAX_SIZE]; ///< IP addresses
CHAR16 SubnetMask[IP4_STR_MAX_SIZE]; ///< Subnet address