X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=NetworkPkg%2FIp6Dxe%2FIp6ConfigNv.c;h=d4f25d030147134d1898c6c6401ec98b0c22c468;hb=216f79703b8cb8dc65abdd768bedb2bcdbc1a1f8;hp=8ee756e20198be055cb14e8c731e00f12934458e;hpb=e07404fe3c328d4f34140efd1a2af1fd4c725e4a;p=mirror_edk2.git diff --git a/NetworkPkg/Ip6Dxe/Ip6ConfigNv.c b/NetworkPkg/Ip6Dxe/Ip6ConfigNv.c index 8ee756e201..d4f25d0301 100644 --- a/NetworkPkg/Ip6Dxe/Ip6ConfigNv.c +++ b/NetworkPkg/Ip6Dxe/Ip6ConfigNv.c @@ -1,7 +1,7 @@ /** @file Helper functions for configuring or obtaining the parameters relating to IP6. - Copyright (c) 2010, Intel Corporation. All rights reserved.
+ Copyright (c) 2010 - 2012, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License @@ -15,8 +15,6 @@ #include "Ip6Impl.h" -EFI_GUID mIp6HiiVendorDevicePathGuid = IP6_HII_VENDOR_DEVICE_PATH_GUID; -EFI_GUID mIp6ConfigNvDataGuid = IP6_CONFIG_NVDATA_GUID; CHAR16 mIp6ConfigStorageName[] = L"IP6_CONFIG_IFR_NVDATA"; /** @@ -556,7 +554,7 @@ Ip6ConvertAddressListToString ( Status = HiiUpdateForm ( HiiHandle, // HII handle - &mIp6ConfigNvDataGuid, // Formset GUID + &gIp6ConfigNvDataGuid, // Formset GUID FORMID_MAIN_FORM, // Form ID StartOpCodeHandle, // Label for where to insert opcodes EndOpCodeHandle // Replace data @@ -930,11 +928,11 @@ Ip6ConvertConfigNvDataToIfrNvData ( IN IP6_CONFIG_INSTANCE *Instance ) { + IP6_CONFIG_NVDATA *Ip6NvData; EFI_IP6_CONFIG_PROTOCOL *Ip6Config; UINTN DataSize; VOID *Data; EFI_STATUS Status; - EFI_IP6_CONFIG_INTERFACE_ID InterfaceId; EFI_IP6_CONFIG_POLICY Policy; EFI_IP6_CONFIG_DUP_ADDR_DETECT_TRANSMITS DadXmits; EFI_HII_HANDLE HiiHandle; @@ -946,6 +944,7 @@ Ip6ConvertConfigNvDataToIfrNvData ( NET_CHECK_SIGNATURE (Instance, IP6_CONFIG_INSTANCE_SIGNATURE); Ip6Config = &Instance->Ip6Config; + Ip6NvData = &Instance->Ip6NvData; Data = NULL; DataSize = 0; HiiHandle = Instance->CallbackInfo.RegisteredHandle; @@ -979,18 +978,18 @@ Ip6ConvertConfigNvDataToIfrNvData ( // Get the interface id. // DataSize = sizeof (EFI_IP6_CONFIG_INTERFACE_ID); - ZeroMem (&InterfaceId, DataSize); + ZeroMem (&Ip6NvData->InterfaceId, DataSize); Status = Ip6Config->GetData ( Ip6Config, Ip6ConfigDataTypeAltInterfaceId, &DataSize, - &InterfaceId + &Ip6NvData->InterfaceId ); if (EFI_ERROR (Status)) { goto Exit; } - Ip6ConvertInterfaceIdToString (IfrNvData->InterfaceId, &InterfaceId); + Ip6ConvertInterfaceIdToString (IfrNvData->InterfaceId, &Ip6NvData->InterfaceId); // // Get current policy. @@ -1447,7 +1446,7 @@ Ip6FormExtractConfig ( *Progress = Request; if ((Request != NULL) && - !HiiIsConfigHdrMatch (Request, &mIp6ConfigNvDataGuid, mIp6ConfigStorageName)) { + !HiiIsConfigHdrMatch (Request, &gIp6ConfigNvDataGuid, mIp6ConfigStorageName)) { return EFI_NOT_FOUND; } @@ -1478,7 +1477,7 @@ Ip6FormExtractConfig ( // followed by "&OFFSET=0&WIDTH=WWWWWWWWWWWWWWWW" followed by a Null-terminator. // ConfigRequestHdr = HiiConstructConfigHdr ( - &mIp6ConfigNvDataGuid, + &gIp6ConfigNvDataGuid, mIp6ConfigStorageName, Private->ChildHandle ); @@ -1578,7 +1577,7 @@ Ip6FormRouteConfig ( // Check routing data in . // Note: if only one Storage is used, then this checking could be skipped. // - if (!HiiIsConfigHdrMatch (Configuration, &mIp6ConfigNvDataGuid, mIp6ConfigStorageName)) { + if (!HiiIsConfigHdrMatch (Configuration, &gIp6ConfigNvDataGuid, mIp6ConfigStorageName)) { *Progress = Configuration; return EFI_NOT_FOUND; } @@ -1629,7 +1628,6 @@ Ip6FormCallback ( IP6_FORM_CALLBACK_INFO *Private; UINTN BufferSize; IP6_CONFIG_IFR_NVDATA *IfrNvData; - IP6_CONFIG_IFR_NVDATA OldIfrNvData; EFI_STATUS Status; EFI_INPUT_KEY Key; IP6_CONFIG_INSTANCE *Instance; @@ -1649,240 +1647,262 @@ Ip6FormCallback ( Instance = IP6_CONFIG_INSTANCE_FROM_FORM_CALLBACK (Private); Ip6NvData = &Instance->Ip6NvData; - if (Action == EFI_BROWSER_ACTION_FORM_OPEN) { - // - // Update main Form when main Form is opened. - // This will be done only in FORM_OPEN CallBack of question with KEY_INTERFACE_ID from main Form. - // - if (QuestionId != KEY_INTERFACE_ID) { - return EFI_SUCCESS; - } + if ((Action == EFI_BROWSER_ACTION_FORM_OPEN) || (Action == EFI_BROWSER_ACTION_FORM_CLOSE)){ + return EFI_SUCCESS; + } - Ip6Config = &Instance->Ip6Config; - HiiHandle = Instance->CallbackInfo.RegisteredHandle; + if (Action != EFI_BROWSER_ACTION_CHANGING && Action != EFI_BROWSER_ACTION_CHANGED) { + return EFI_UNSUPPORTED; + } - // - // Get the current interface info. - // - Status = Ip6ConfigNvGetData ( - Ip6Config, - Ip6ConfigDataTypeInterfaceInfo, - &DataSize, - (VOID **) &Data - ); - if (EFI_ERROR (Status)) { - goto Exit; - } + if ((Value == NULL) || (ActionRequest == NULL)) { + return EFI_INVALID_PARAMETER; + } - // - // Generate the dynamic text opcode for host address and draw it. - // - IfInfo = (EFI_IP6_CONFIG_INTERFACE_INFO *) Data; - Status = Ip6ConvertAddressListToString ( - PortString, - HiiHandle, - Ip6ConfigNvHostAddress, - IfInfo->AddressInfo, - IfInfo->AddressInfoCount - ); - if (EFI_ERROR (Status)) { - goto Exit; - } + // + // Retrieve uncommitted data from Browser + // - // - // Generate the dynamic text opcode for route table and draw it. - // - Status = Ip6ConvertAddressListToString ( - PortString, - HiiHandle, - Ip6ConfigNvRouteTable, - IfInfo->RouteTable, - IfInfo->RouteCount - ); - if (EFI_ERROR (Status)) { - goto Exit; - } + BufferSize = sizeof (IP6_CONFIG_IFR_NVDATA); + IfrNvData = AllocateZeroPool (BufferSize); + if (IfrNvData == NULL) { + return EFI_OUT_OF_RESOURCES; + } - // - // Get DNS server list. - // - DataSize = 0; - Status = Ip6ConfigNvGetData ( - Ip6Config, - Ip6ConfigDataTypeDnsServer, - &DataSize, - (VOID **) &Data - ); - if (EFI_ERROR (Status) && (Status != EFI_NOT_FOUND)) { - goto Exit; - } + 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; + HiiHandle = Instance->CallbackInfo.RegisteredHandle; + Data = NULL; - if (DataSize > 0) { // - // Generate the dynamic text opcode for DNS server and draw it. + // Get current interface info. // + Status = Ip6ConfigNvGetData ( + Ip6Config, + Ip6ConfigDataTypeInterfaceInfo, + &DataSize, + (VOID **) &Data + ); + if (EFI_ERROR (Status)) { + return Status; + } + + // + // Generate dynamic text opcode for host address and draw it. + // + IfInfo = (EFI_IP6_CONFIG_INTERFACE_INFO *) Data; Status = Ip6ConvertAddressListToString ( PortString, HiiHandle, - Ip6ConfigNvDnsAddress, - Data, - DataSize / sizeof (EFI_IPv6_ADDRESS) + Ip6ConfigNvHostAddress, + IfInfo->AddressInfo, + IfInfo->AddressInfoCount ); if (EFI_ERROR (Status)) { - goto Exit; + FreePool (Data); + return Status; } - } - - // - // 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) { // - // Generate the dynamic text opcode for gateway and draw it. + // Generate the dynamic text opcode for route table and draw it. // Status = Ip6ConvertAddressListToString ( PortString, HiiHandle, - Ip6ConfigNvGatewayAddress, - Data, - DataSize / sizeof (EFI_IPv6_ADDRESS) + Ip6ConfigNvRouteTable, + IfInfo->RouteTable, + IfInfo->RouteCount ); if (EFI_ERROR (Status)) { - goto Exit; + FreePool (Data); + return Status; } - } - -Exit: - FreePool (Data); - return Status; - } - - if (Action == EFI_BROWSER_ACTION_FORM_CLOSE) { - // - // Do nothing for UEFI FORM_CLOSE action - // - return EFI_SUCCESS; - } - - 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; + // + // Get DNS server list. + // + FreePool (Data); + DataSize = 0; + Data = NULL; + Status = Ip6ConfigNvGetData ( + Ip6Config, + Ip6ConfigDataTypeDnsServer, + &DataSize, + (VOID **) &Data + ); + if (EFI_ERROR (Status) && (Status != EFI_NOT_FOUND)) { + if (Data != NULL) { + FreePool (Data); + } + return Status; + } - ZeroMem (&OldIfrNvData, BufferSize); + if (DataSize > 0) { + // + // Generate the dynamic text opcode for DNS server and draw it. + // + Status = Ip6ConvertAddressListToString ( + PortString, + HiiHandle, + Ip6ConfigNvDnsAddress, + Data, + DataSize / sizeof (EFI_IPv6_ADDRESS) + ); + if (EFI_ERROR (Status)) { + FreePool (Data); + return Status; + } + } - HiiGetBrowserData (NULL, NULL, BufferSize, (UINT8 *) IfrNvData); + // + // Get gateway adderss list. + // + if (Data != NULL) { + FreePool (Data); + } - CopyMem (&OldIfrNvData, IfrNvData, BufferSize); + DataSize = 0; + Data = NULL; + Status = Ip6ConfigNvGetData ( + Ip6Config, + Ip6ConfigDataTypeGateway, + &DataSize, + (VOID **) &Data + ); + if (EFI_ERROR (Status) && (Status != EFI_NOT_FOUND)) { + if (Data != NULL) { + FreePool (Data); + } + return Status; + } - switch (QuestionId) { - case KEY_INTERFACE_ID: - Status = Ip6ParseInterfaceIdFromString (IfrNvData->InterfaceId, &Ip6NvData->InterfaceId); - if (EFI_ERROR (Status)) { - CreatePopUp ( - EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, - &Key, - L"Invalid Interface ID!", - NULL - ); - } + if (DataSize > 0) { + // + // Generate the dynamic text opcode for gateway and draw it. + // + Status = Ip6ConvertAddressListToString ( + PortString, + HiiHandle, + Ip6ConfigNvGatewayAddress, + Data, + DataSize / sizeof (EFI_IPv6_ADDRESS) + ); + if (EFI_ERROR (Status)) { + FreePool (Data); + return Status; + } + } - break; + if (Data != NULL) { + FreePool (Data); + } - case KEY_MANUAL_ADDRESS: - Status = Ip6ParseAddressListFromString ( - IfrNvData->ManualAddress, - &Ip6NvData->ManualAddress, - &Ip6NvData->ManualAddressCount - ); - if (EFI_ERROR (Status)) { - CreatePopUp ( - EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, - &Key, - L"Invalid Host Addresses!", - NULL - ); - } + Status = EFI_SUCCESS; - break; + break; - case KEY_GATEWAY_ADDRESS: - Status = Ip6ParseAddressListFromString ( - IfrNvData->GatewayAddress, - &Ip6NvData->GatewayAddress, - &Ip6NvData->GatewayAddressCount - ); - if (EFI_ERROR (Status)) { - CreatePopUp ( - EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, - &Key, - L"Invalid Gateway Addresses!", - NULL - ); + default: + break; } + } else if (Action == EFI_BROWSER_ACTION_CHANGED) { + switch (QuestionId) { + case KEY_SAVE_CONFIG_CHANGES: + *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_SUBMIT_EXIT; + break; - break; - - case KEY_DNS_ADDRESS: - Status = Ip6ParseAddressListFromString ( - IfrNvData->DnsAddress, - &Ip6NvData->DnsAddress, - &Ip6NvData->DnsAddressCount - ); - if (EFI_ERROR (Status)) { - CreatePopUp ( - EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, - &Key, - L"Invalid DNS Addresses!", - NULL - ); - } + case KEY_IGNORE_CONFIG_CHANGES: + Ip6FreeAddressInfoList (&Ip6NvData->ManualAddress); + Ip6FreeAddressInfoList (&Ip6NvData->GatewayAddress); + Ip6FreeAddressInfoList (&Ip6NvData->DnsAddress); - break; + Ip6NvData->ManualAddressCount = 0; + Ip6NvData->GatewayAddressCount = 0; + Ip6NvData->DnsAddressCount = 0; - case KEY_SAVE_CONFIG_CHANGES: - CopyMem (&OldIfrNvData, IfrNvData, sizeof (IP6_CONFIG_IFR_NVDATA)); - *ActionRequest = EFI_BROWSER_ACTION_REQUEST_SUBMIT; - break; + *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_DISCARD_EXIT; + break; - case KEY_IGNORE_CONFIG_CHANGES: - CopyMem (IfrNvData, &OldIfrNvData, sizeof (IP6_CONFIG_IFR_NVDATA)); - *ActionRequest = EFI_BROWSER_ACTION_REQUEST_SUBMIT; - break; + case KEY_SAVE_CHANGES: + Status = Ip6ConvertIfrNvDataToConfigNvData (IfrNvData, Instance); + if (EFI_ERROR (Status)) { + break; + } + *ActionRequest = EFI_BROWSER_ACTION_REQUEST_SUBMIT; + break; + + case KEY_INTERFACE_ID: + Status = Ip6ParseInterfaceIdFromString (IfrNvData->InterfaceId, &Ip6NvData->InterfaceId); + if (EFI_ERROR (Status)) { + CreatePopUp ( + EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, + &Key, + L"Invalid Interface ID!", + NULL + ); + } + + break; + + case KEY_MANUAL_ADDRESS: + Status = Ip6ParseAddressListFromString ( + IfrNvData->ManualAddress, + &Ip6NvData->ManualAddress, + &Ip6NvData->ManualAddressCount + ); + if (EFI_ERROR (Status)) { + CreatePopUp ( + EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, + &Key, + L"Invalid Host Addresses!", + NULL + ); + } + + break; + + case KEY_GATEWAY_ADDRESS: + Status = Ip6ParseAddressListFromString ( + IfrNvData->GatewayAddress, + &Ip6NvData->GatewayAddress, + &Ip6NvData->GatewayAddressCount + ); + if (EFI_ERROR (Status)) { + CreatePopUp ( + EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, + &Key, + L"Invalid Gateway Addresses!", + NULL + ); + } + + break; + + case KEY_DNS_ADDRESS: + Status = Ip6ParseAddressListFromString ( + IfrNvData->DnsAddress, + &Ip6NvData->DnsAddress, + &Ip6NvData->DnsAddressCount + ); + if (EFI_ERROR (Status)) { + CreatePopUp ( + EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, + &Key, + L"Invalid DNS Addresses!", + NULL + ); + } + + break; - case KEY_SAVE_CHANGES: - Status = Ip6ConvertIfrNvDataToConfigNvData (IfrNvData, Instance); - if (EFI_ERROR (Status)) { + default: break; } - - *ActionRequest = EFI_BROWSER_ACTION_REQUEST_EXIT; - break; - - default: - break; } if (!EFI_ERROR (Status)) { @@ -1948,7 +1968,7 @@ Ip6ConfigFormInit ( VendorDeviceNode.Header.Type = HARDWARE_DEVICE_PATH; VendorDeviceNode.Header.SubType = HW_VENDOR_DP; - CopyGuid (&VendorDeviceNode.Guid, &mIp6HiiVendorDevicePathGuid); + CopyGuid (&VendorDeviceNode.Guid, &gEfiCallerIdGuid); SetDevicePathNodeLength (&VendorDeviceNode.Header, sizeof (VENDOR_DEVICE_PATH)); CallbackInfo->HiiVendorDevicePath = AppendDevicePathNode ( @@ -1998,7 +2018,7 @@ Ip6ConfigFormInit ( // Publish our HII data // CallbackInfo->RegisteredHandle = HiiAddPackages ( - &mIp6ConfigNvDataGuid, + &gIp6ConfigNvDataGuid, CallbackInfo->ChildHandle, Ip6DxeStrings, Ip6ConfigBin, @@ -2010,7 +2030,7 @@ Ip6ConfigFormInit ( } // - // Append MAC string in the menu string and tile string + // Append MAC string in the menu help string and tile help string // Status = NetLibGetMacString (IpSb->Controller, IpSb->Image, &MacString); if (!EFI_ERROR (Status)) {