Update IPv6 configuration UI: 1) keep addresses blank when enter ‘Advanced Configuration’ page; 2) Save parameters in ‘Advanced Configuration’ immediately when user press ‘Commit Changes and Exit’ .

Signed-off-by: Ye Ting  <ting.ye@intel.com>
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
Reviewed-by: Ouyang Qian <qian.ouyang@intel.com>

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@14047 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
tye1 2013-01-15 02:19:42 +00:00
parent 5ecab66086
commit 130df89019
2 changed files with 228 additions and 259 deletions

View File

@ -1,7 +1,7 @@
/** @file /** @file
Helper functions for configuring or obtaining the parameters relating to IP6. Helper functions for configuring or obtaining the parameters relating to IP6.
Copyright (c) 2010 - 2012, Intel Corporation. All rights reserved.<BR> Copyright (c) 2010 - 2013, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License are licensed and made available under the terms and conditions of the BSD License
@ -669,9 +669,8 @@ Error:
/** /**
This function converts the interface info to string and draws it to the IP6 UI. This function converts the interface info to string and draws it to the IP6 UI.
The interface information includes interface name, interface type, hardware address, The interface information includes interface name, interface type, hardware
address info, and route table information. The address information is also used as the address and route table information.
content of manual addresses in IP6 UI.
@param[in] IfInfo The pointer of EFI_IP6_CONFIG_INTERFACE_INFO. @param[in] IfInfo The pointer of EFI_IP6_CONFIG_INTERFACE_INFO.
@param[in] HiiHandle The handle that was previously registered in the @param[in] HiiHandle The handle that was previously registered in the
@ -693,7 +692,6 @@ Ip6ConvertInterfaceInfoToString (
UINT32 Index; UINT32 Index;
UINTN Number; UINTN Number;
CHAR16 *String; CHAR16 *String;
CHAR16 *LinkLocalStr;
CHAR16 PortString[ADDRESS_STR_MAX_SIZE]; CHAR16 PortString[ADDRESS_STR_MAX_SIZE];
CHAR16 FormatString[8]; CHAR16 FormatString[8];
EFI_STRING_ID StringId; EFI_STRING_ID StringId;
@ -782,43 +780,6 @@ Ip6ConvertInterfaceInfoToString (
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
//
// Print the host address Information.
//
Status = Ip6ConvertAddressListToString (
PortString,
HiiHandle,
Ip6ConfigNvHostAddress,
IfInfo->AddressInfo,
IfInfo->AddressInfoCount
);
if (EFI_ERROR (Status)) {
return Status;
}
//
// Copy the Host Address Info to manual address field.
// Do not copy the link local address.
//
LinkLocalStr = StrStr (PortString, IP6_LINK_LOCAL_PREFIX);
if (LinkLocalStr != NULL) {
Number = LinkLocalStr - PortString;
if (Number > 0) {
CopyMem (IfrNvData->ManualAddress, PortString, Number * sizeof (CHAR16));
}
while ((*LinkLocalStr != L' ') && (*LinkLocalStr != L'\0')) {
LinkLocalStr++;
}
if (*LinkLocalStr != L'\0') {
LinkLocalStr++;
StrCat (IfrNvData->ManualAddress, LinkLocalStr);
}
} else {
StrCpy (IfrNvData->ManualAddress, PortString);
}
// //
// Print the route table information. // Print the route table information.
// //
@ -1033,75 +994,6 @@ Ip6ConvertConfigNvDataToIfrNvData (
IfrNvData->DadTransmitCount = DadXmits.DupAddrDetectTransmits; IfrNvData->DadTransmitCount = DadXmits.DupAddrDetectTransmits;
//
// Get DNS server list.
//
FreePool (Data);
Data = NULL;
DataSize = 0;
Status = Ip6ConfigNvGetData (
Ip6Config,
Ip6ConfigDataTypeDnsServer,
&DataSize,
(VOID **) &Data
);
if (EFI_ERROR (Status) && (Status != EFI_NOT_FOUND)) {
goto Exit;
}
if (DataSize > 0) {
//
// Convert the DNS server address to string and draw it to UI.
//
Status = Ip6ConvertAddressListToString (
IfrNvData->DnsAddress,
HiiHandle,
Ip6ConfigNvDnsAddress,
Data,
DataSize / sizeof (EFI_IPv6_ADDRESS)
);
if (EFI_ERROR (Status)) {
goto Exit;
}
FreePool (Data);
Data = NULL;
}
//
// Get gateway adderss list.
//
DataSize = 0;
Status = Ip6ConfigNvGetData (
Ip6Config,
Ip6ConfigDataTypeGateway,
&DataSize,
(VOID **) &Data
);
if (EFI_ERROR (Status) && (Status != EFI_NOT_FOUND)) {
goto Exit;
}
if (DataSize > 0) {
//
// Convert the gateway address to string and draw it to UI.
//
Status = Ip6ConvertAddressListToString (
IfrNvData->GatewayAddress,
HiiHandle,
Ip6ConfigNvGatewayAddress,
Data,
DataSize / sizeof (EFI_IPv6_ADDRESS)
);
if (EFI_ERROR (Status)) {
goto Exit;
}
}
Status = EFI_SUCCESS;
Exit: Exit:
if (Data != NULL) { if (Data != NULL) {
FreePool (Data); FreePool (Data);
@ -1112,8 +1004,7 @@ Exit:
/** /**
Convert IFR data into IP6 configuration data. The policy, alternative interface Convert IFR data into IP6 configuration data. The policy, alternative interface
ID, and DAD transmit counts, and will be saved. If under manual policy, the configured ID, and DAD transmit counts, and will be saved.
manual address, gateway address, and DNS server address will be saved.
@param[in] IfrNvData The IFR NV data. @param[in] IfrNvData The IFR NV data.
@param[in, out] Instance The IP6 config instance data. @param[in, out] Instance The IP6 config instance data.
@ -1124,7 +1015,7 @@ Exit:
**/ **/
EFI_STATUS EFI_STATUS
Ip6ConvertIfrNvDataToConfigNvData ( Ip6ConvertIfrNvDataToConfigNvDataGeneral (
IN IP6_CONFIG_IFR_NVDATA *IfrNvData, IN IP6_CONFIG_IFR_NVDATA *IfrNvData,
IN OUT IP6_CONFIG_INSTANCE *Instance IN OUT IP6_CONFIG_INSTANCE *Instance
) )
@ -1132,12 +1023,6 @@ Ip6ConvertIfrNvDataToConfigNvData (
IP6_CONFIG_NVDATA *Ip6NvData; IP6_CONFIG_NVDATA *Ip6NvData;
EFI_IP6_CONFIG_PROTOCOL *Ip6Config; EFI_IP6_CONFIG_PROTOCOL *Ip6Config;
EFI_STATUS Status; EFI_STATUS Status;
EFI_IP6_CONFIG_MANUAL_ADDRESS *ManualAddress;
EFI_IPv6_ADDRESS *Address;
BOOLEAN IsAddressOk;
EFI_EVENT SetAddressEvent;
EFI_EVENT TimeoutEvent;
UINTN DataSize;
if ((IfrNvData == NULL) || (Instance == NULL)) { if ((IfrNvData == NULL) || (Instance == NULL)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
@ -1197,11 +1082,67 @@ Ip6ConvertIfrNvDataToConfigNvData (
return Status; return Status;
} }
if (Ip6NvData->Policy == Ip6ConfigPolicyAutomatic) {
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/**
Convert IFR data into IP6 configuration data. The policy, configured
manual address, gateway address, and DNS server address will be saved.
@param[in] IfrNvData The IFR NV data.
@param[in, out] Instance The IP6 config instance data.
@retval EFI_SUCCESS The operation finished successfully.
@retval EFI_INVALID_PARAMETER Any input parameter is invalid.
@retval Others Other errors as indicated.
**/
EFI_STATUS
Ip6ConvertIfrNvDataToConfigNvDataAdvanced (
IN IP6_CONFIG_IFR_NVDATA *IfrNvData,
IN OUT IP6_CONFIG_INSTANCE *Instance
)
{
IP6_CONFIG_NVDATA *Ip6NvData;
EFI_IP6_CONFIG_PROTOCOL *Ip6Config;
EFI_STATUS Status;
EFI_IP6_CONFIG_MANUAL_ADDRESS *ManualAddress;
EFI_IPv6_ADDRESS *Address;
BOOLEAN IsAddressOk;
EFI_EVENT SetAddressEvent;
EFI_EVENT TimeoutEvent;
UINTN DataSize;
if ((IfrNvData == NULL) || (Instance == NULL)) {
return EFI_INVALID_PARAMETER;
}
if (IfrNvData->Policy == IP6_POLICY_AUTO) {
return EFI_SUCCESS;
}
NET_CHECK_SIGNATURE (Instance, IP6_CONFIG_INSTANCE_SIGNATURE);
Ip6NvData = &Instance->Ip6NvData;
Ip6Config = &Instance->Ip6Config;
//
// Update those fields which don't have INTERACTIVE attribute.
//
Ip6NvData->Policy = Ip6ConfigPolicyManual;
//
// Set the configured policy.
//
Status = Ip6Config->SetData (
Ip6Config,
Ip6ConfigDataTypePolicy,
sizeof (EFI_IP6_CONFIG_POLICY),
&Ip6NvData->Policy
);
if (EFI_ERROR (Status)) {
return Status;
}
// //
// Create events & timers for asynchronous settings. // Create events & timers for asynchronous settings.
// //
@ -1358,6 +1299,7 @@ Exit:
return Status; return Status;
} }
/** /**
This function allows the caller to request the current This function allows the caller to request the current
configuration for one or more named elements. The resulting configuration for one or more named elements. The resulting
@ -1588,94 +1530,29 @@ Ip6FormRouteConfig (
} }
/** /**
This function is called to provide results data to the driver. Display host addresses, route table, DNS addresses and gateway addresses in
This data consists of a unique key that is used to identify "IPv6 Current Setting" page.
which data is either being passed back or being asked for.
@param[in] This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL. @param[in] Instance The IP6 config instance data.
@param[in] Action Specifies the type of action taken by the browser.
@param[in] QuestionId A unique value which is sent to the original
exporting driver so that it can identify the type
of data to expect. The format of the data tends to
vary based on the opcode that generated the callback.
@param[in] Type The type of value for the question.
@param[in] Value A pointer to the data being sent to the original
exporting driver.
@param[out] ActionRequest On return, points to the action requested by the
callback function.
@retval EFI_SUCCESS The callback successfully handled the action. @retval EFI_SUCCESS The operation finished successfully.
@retval EFI_OUT_OF_RESOURCES Not enough storage is available to hold the
variable and its data.
@retval EFI_DEVICE_ERROR The variable could not be saved.
@retval EFI_UNSUPPORTED The specified Action is not supported by the
callback. Currently not implemented.
@retval EFI_INVALID_PARAMETER Passed in the wrong parameter.
@retval Others Other errors as indicated. @retval Others Other errors as indicated.
**/ **/
EFI_STATUS EFI_STATUS
EFIAPI Ip6GetCurrentSetting (
Ip6FormCallback ( IN IP6_CONFIG_INSTANCE *Instance
IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
IN EFI_BROWSER_ACTION Action,
IN EFI_QUESTION_ID QuestionId,
IN UINT8 Type,
IN EFI_IFR_TYPE_VALUE *Value,
OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest
) )
{ {
IP6_FORM_CALLBACK_INFO *Private;
UINTN BufferSize;
IP6_CONFIG_IFR_NVDATA *IfrNvData;
EFI_STATUS Status;
EFI_INPUT_KEY Key;
IP6_CONFIG_INSTANCE *Instance;
IP6_CONFIG_NVDATA *Ip6NvData;
EFI_IP6_CONFIG_PROTOCOL *Ip6Config; EFI_IP6_CONFIG_PROTOCOL *Ip6Config;
EFI_HII_HANDLE HiiHandle;
EFI_IP6_CONFIG_INTERFACE_INFO *Data; EFI_IP6_CONFIG_INTERFACE_INFO *Data;
UINTN DataSize; UINTN DataSize;
EFI_STATUS Status;
CHAR16 PortString[ADDRESS_STR_MAX_SIZE]; CHAR16 PortString[ADDRESS_STR_MAX_SIZE];
EFI_HII_HANDLE HiiHandle;
EFI_IP6_CONFIG_INTERFACE_INFO *IfInfo; EFI_IP6_CONFIG_INTERFACE_INFO *IfInfo;
if (This == NULL) {
return EFI_INVALID_PARAMETER;
}
Private = IP6_FORM_CALLBACK_INFO_FROM_CONFIG_ACCESS (This);
Instance = IP6_CONFIG_INSTANCE_FROM_FORM_CALLBACK (Private);
Ip6NvData = &Instance->Ip6NvData;
if ((Action == EFI_BROWSER_ACTION_FORM_OPEN) || (Action == EFI_BROWSER_ACTION_FORM_CLOSE)){
return EFI_SUCCESS;
}
if (Action != EFI_BROWSER_ACTION_CHANGING && Action != EFI_BROWSER_ACTION_CHANGED) {
return EFI_UNSUPPORTED;
}
if ((Value == NULL) || (ActionRequest == NULL)) {
return EFI_INVALID_PARAMETER;
}
//
// Retrieve uncommitted data from Browser
//
BufferSize = sizeof (IP6_CONFIG_IFR_NVDATA);
IfrNvData = AllocateZeroPool (BufferSize);
if (IfrNvData == NULL) {
return EFI_OUT_OF_RESOURCES;
}
Status = EFI_SUCCESS;
HiiGetBrowserData (NULL, NULL, BufferSize, (UINT8 *) IfrNvData);
if (Action == EFI_BROWSER_ACTION_CHANGING) {
switch (QuestionId) {
case KEY_GET_CURRENT_SETTING:
Ip6Config = &Instance->Ip6Config; Ip6Config = &Instance->Ip6Config;
HiiHandle = Instance->CallbackInfo.RegisteredHandle; HiiHandle = Instance->CallbackInfo.RegisteredHandle;
Data = NULL; Data = NULL;
@ -1803,8 +1680,93 @@ Ip6FormCallback (
FreePool (Data); FreePool (Data);
} }
return EFI_SUCCESS;
}
/**
This function is called to provide results data to the driver.
This data consists of a unique key that is used to identify
which data is either being passed back or being asked for.
@param[in] This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
@param[in] Action Specifies the type of action taken by the browser.
@param[in] QuestionId A unique value which is sent to the original
exporting driver so that it can identify the type
of data to expect. The format of the data tends to
vary based on the opcode that generated the callback.
@param[in] Type The type of value for the question.
@param[in] Value A pointer to the data being sent to the original
exporting driver.
@param[out] ActionRequest On return, points to the action requested by the
callback function.
@retval EFI_SUCCESS The callback successfully handled the action.
@retval EFI_OUT_OF_RESOURCES Not enough storage is available to hold the
variable and its data.
@retval EFI_DEVICE_ERROR The variable could not be saved.
@retval EFI_UNSUPPORTED The specified Action is not supported by the
callback. Currently not implemented.
@retval EFI_INVALID_PARAMETER Passed in the wrong parameter.
@retval Others Other errors as indicated.
**/
EFI_STATUS
EFIAPI
Ip6FormCallback (
IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
IN EFI_BROWSER_ACTION Action,
IN EFI_QUESTION_ID QuestionId,
IN UINT8 Type,
IN EFI_IFR_TYPE_VALUE *Value,
OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest
)
{
IP6_FORM_CALLBACK_INFO *Private;
UINTN BufferSize;
IP6_CONFIG_IFR_NVDATA *IfrNvData;
EFI_STATUS Status;
EFI_INPUT_KEY Key;
IP6_CONFIG_INSTANCE *Instance;
IP6_CONFIG_NVDATA *Ip6NvData;
if (This == NULL) {
return EFI_INVALID_PARAMETER;
}
Private = IP6_FORM_CALLBACK_INFO_FROM_CONFIG_ACCESS (This);
Instance = IP6_CONFIG_INSTANCE_FROM_FORM_CALLBACK (Private);
Ip6NvData = &Instance->Ip6NvData;
if ((Action == EFI_BROWSER_ACTION_FORM_OPEN) || (Action == EFI_BROWSER_ACTION_FORM_CLOSE)){
return EFI_SUCCESS;
}
if (Action != EFI_BROWSER_ACTION_CHANGING && Action != EFI_BROWSER_ACTION_CHANGED) {
return EFI_UNSUPPORTED;
}
if ((Value == NULL) || (ActionRequest == NULL)) {
return EFI_INVALID_PARAMETER;
}
//
// Retrieve uncommitted data from Browser
//
BufferSize = sizeof (IP6_CONFIG_IFR_NVDATA);
IfrNvData = AllocateZeroPool (BufferSize);
if (IfrNvData == NULL) {
return EFI_OUT_OF_RESOURCES;
}
Status = EFI_SUCCESS; Status = EFI_SUCCESS;
HiiGetBrowserData (NULL, NULL, BufferSize, (UINT8 *) IfrNvData);
if (Action == EFI_BROWSER_ACTION_CHANGING) {
switch (QuestionId) {
case KEY_GET_CURRENT_SETTING:
Status = Ip6GetCurrentSetting (Instance);
break; break;
default: default:
@ -1813,6 +1775,13 @@ Ip6FormCallback (
} else if (Action == EFI_BROWSER_ACTION_CHANGED) { } else if (Action == EFI_BROWSER_ACTION_CHANGED) {
switch (QuestionId) { switch (QuestionId) {
case KEY_SAVE_CONFIG_CHANGES: case KEY_SAVE_CONFIG_CHANGES:
Status = Ip6ConvertIfrNvDataToConfigNvDataAdvanced (IfrNvData, Instance);
if (EFI_ERROR (Status)) {
break;
}
Status = Ip6GetCurrentSetting (Instance);
*ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_SUBMIT_EXIT; *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_SUBMIT_EXIT;
break; break;
@ -1829,7 +1798,7 @@ Ip6FormCallback (
break; break;
case KEY_SAVE_CHANGES: case KEY_SAVE_CHANGES:
Status = Ip6ConvertIfrNvDataToConfigNvData (IfrNvData, Instance); Status = Ip6ConvertIfrNvDataToConfigNvDataGeneral (IfrNvData, Instance);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
break; break;
} }

View File

@ -1,7 +1,7 @@
/** @file /** @file
NVData structure used by the IP6 configuration component. NVData structure used by the IP6 configuration component.
Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR> Copyright (c) 2010 - 2013, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License are licensed and made available under the terms and conditions of the BSD License
@ -43,7 +43,7 @@
#define INTERFACE_ID_STR_MIN_SIZE 1 #define INTERFACE_ID_STR_MIN_SIZE 1
#define INTERFACE_ID_STR_MAX_SIZE 23 #define INTERFACE_ID_STR_MAX_SIZE 23
#define INTERFACE_ID_STR_STORAGE 24 #define INTERFACE_ID_STR_STORAGE 25
#define IP6_STR_MAX_SIZE 40 #define IP6_STR_MAX_SIZE 40
#define ADDRESS_STR_MIN_SIZE 2 #define ADDRESS_STR_MIN_SIZE 2
#define ADDRESS_STR_MAX_SIZE 255 #define ADDRESS_STR_MAX_SIZE 255