diff --git a/MdeModulePkg/Include/Guid/Ip4ConfigHii.h b/MdeModulePkg/Include/Guid/Ip4ConfigHii.h deleted file mode 100644 index 87c54a0194..0000000000 --- a/MdeModulePkg/Include/Guid/Ip4ConfigHii.h +++ /dev/null @@ -1,25 +0,0 @@ -/** @file - GUIDs used as HII FormSet and HII Package list GUID in Ip4ConfigDxe driver. - -Copyright (c) 2011, 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 that accompanies this distribution. -The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php. - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#ifndef __IP4_CONFIG_HII_GUID_H__ -#define __IP4_CONFIG_HII_GUID_H__ - -#define EFI_NIC_IP4_CONFIG_NVDATA_GUID \ - { \ - 0x9d5b53f, 0xf4b0, 0x4f59, { 0xa0, 0xb1, 0x7b, 0x57, 0xd3, 0x5c, 0xe, 0x5 } \ - } - -extern EFI_GUID gNicIp4ConfigNvDataGuid; - -#endif diff --git a/MdeModulePkg/Include/Guid/NicIp4ConfigNvData.h b/MdeModulePkg/Include/Guid/NicIp4ConfigNvData.h deleted file mode 100644 index d3ce76f051..0000000000 --- a/MdeModulePkg/Include/Guid/NicIp4ConfigNvData.h +++ /dev/null @@ -1,70 +0,0 @@ -/** @file - This file defines NIC_IP4_CONFIG_INFO structure. - -Copyright (c) 2009 - 2010, 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 that accompanies this distribution. -The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php. - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#ifndef __NIC_IP4_CONFIG_NVDATA_H__ -#define __NIC_IP4_CONFIG_NVDATA_H__ - -#include - -#define EFI_NIC_IP4_CONFIG_VARIABLE_GUID \ - { \ - 0xd8944553, 0xc4dd, 0x41f4, { 0x9b, 0x30, 0xe1, 0x39, 0x7c, 0xfb, 0x26, 0x7b } \ - } - -#define EFI_NIC_IP4_CONFIG_VARIABLE L"EfiNicIp4ConfigVariable" - - -// -// Config source: dhcp or static -// -#define IP4_CONFIG_SOURCE_DHCP 0 -#define IP4_CONFIG_SOURCE_STATIC 1 -#define IP4_CONFIG_SOURCE_MAX 2 - -#define IP4_NIC_NAME_LENGTH 64 -#define MAX_IP4_CONFIG_IN_VARIABLE 16 - -// -// The following structures are used by drivers/applications other -// than EFI_IP4_PROTOCOL, such as the ifconfig shell application, to -// communicate the IP configuration information to the EFI_IP4_CONFIG_PROTOCOL. -// The EFI_IP4_PROTOCOL uses the EFI_IP4_CONFIG_PROTOCOL to get -// the default IP4 configuration. -// - -/// -/// NIC_ADDR contains the interface's type and MAC address to identify -/// a specific NIC. -/// -typedef struct { - UINT16 Type; ///< Interface type. - UINT8 Len; ///< Length of MAC address. - EFI_MAC_ADDRESS MacAddr; ///< MAC address of interface. -} NIC_ADDR; - -/// -/// NIC_IP4_CONFIG_INFO contains the IP4 configure -/// parameters for that NIC. NIC_IP4_CONFIG_INFO is -/// of variable length. -/// -typedef struct { - NIC_ADDR NicAddr; ///< Link layer address to identify the NIC. - UINT32 Source; ///< Static or DHCP. - BOOLEAN Permanent; ///< Survive the reboot or not. - EFI_IP4_IPCONFIG_DATA Ip4Info; ///< IP addresses. -} NIC_IP4_CONFIG_INFO; - -extern EFI_GUID gEfiNicIp4ConfigVariableGuid; - -#endif diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec index b5acce1dbe..623b07f9c6 100644 --- a/MdeModulePkg/MdeModulePkg.dec +++ b/MdeModulePkg/MdeModulePkg.dec @@ -198,9 +198,6 @@ # Include/Guid/Crc32GuidedSectionExtraction.h gEfiCrc32GuidedSectionExtractionGuid = { 0xFC1BCDB0, 0x7D31, 0x49aa, {0x93, 0x6A, 0xA4, 0x60, 0x0D, 0x9D, 0xD0, 0x83 } } - ## Include/Guid/NicIp4ConfigNvData.h - gEfiNicIp4ConfigVariableGuid = {0xd8944553, 0xc4dd, 0x41f4, { 0x9b, 0x30, 0xe1, 0x39, 0x7c, 0xfb, 0x26, 0x7b }} - ## Include/Guid/StatusCodeCallbackGuid.h gStatusCodeCallbackGuid = {0xe701458c, 0x4900, 0x4ca5, {0xb7, 0x72, 0x3d, 0x37, 0x94, 0x9f, 0x79, 0x27}} @@ -264,9 +261,6 @@ ## Include/Guid/PlatDriOverrideHii.h gPlatformOverridesManagerGuid = { 0x8614567d, 0x35be, 0x4415, { 0x8d, 0x88, 0xbd, 0x7d, 0xc, 0x9c, 0x70, 0xc0 }} - ## Include/Guid/Ip4ConfigHii.h - gNicIp4ConfigNvDataGuid = { 0x9d5b53f, 0xf4b0, 0x4f59, { 0xa0, 0xb1, 0x7b, 0x57, 0xd3, 0x5c, 0xe, 0x5 }} - ## Include/Guid/Ip4Config2Hii.h gIp4Config2NvDataGuid = { 0x9b942747, 0x154e, 0x4d29, { 0xa4, 0x36, 0xbf, 0x71, 0x0, 0xc8, 0xb5, 0x3b }} diff --git a/MdeModulePkg/MdeModulePkg.dsc b/MdeModulePkg/MdeModulePkg.dsc index fc518d0e97..3537ca8820 100644 --- a/MdeModulePkg/MdeModulePkg.dsc +++ b/MdeModulePkg/MdeModulePkg.dsc @@ -307,7 +307,6 @@ MdeModulePkg/Universal/Network/ArpDxe/ArpDxe.inf MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Dxe.inf MdeModulePkg/Universal/Network/DpcDxe/DpcDxe.inf - MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigDxe.inf MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Dxe.inf MdeModulePkg/Universal/Network/IScsiDxe/IScsiDxe.inf MdeModulePkg/Universal/Network/MnpDxe/MnpDxe.inf diff --git a/MdeModulePkg/Universal/Network/Ip4ConfigDxe/ComponentName.c b/MdeModulePkg/Universal/Network/Ip4ConfigDxe/ComponentName.c deleted file mode 100644 index ca6874663c..0000000000 --- a/MdeModulePkg/Universal/Network/Ip4ConfigDxe/ComponentName.c +++ /dev/null @@ -1,165 +0,0 @@ -/** @file - UEFI Component Name(2) protocol implementation for Ip4ConfigDxe driver. - -Copyright (c) 2006 - 2011, 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 -which accompanies this distribution. The full text of the license may be found at
-http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include "Ip4Config.h" - -// -// EFI Component Name Protocol -// -GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gIp4ConfigComponentName = { - Ip4ConfigComponentNameGetDriverName, - Ip4ConfigComponentNameGetControllerName, - "eng" -}; - -// -// EFI Component Name 2 Protocol -// -GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gIp4ConfigComponentName2 = { - (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) Ip4ConfigComponentNameGetDriverName, - (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) Ip4ConfigComponentNameGetControllerName, - "en" -}; - - -GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mIp4ConfigDriverNameTable[] = { - {"eng;en", L"IP4 CONFIG Network Service Driver"}, - {NULL, NULL} -}; - -// -// EFI Component Name Functions -// - -/** - Retrieves a Unicode string that is the user readable name of the driver. - - This function retrieves the user readable name of a driver in the form of a - Unicode string. If the driver specified by This has a user readable name in - the language specified by Language, then a pointer to the driver name is - returned in DriverName, and EFI_SUCCESS is returned. If the driver specified - by This does not support the language specified by Language, - then EFI_UNSUPPORTED is returned. - - @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or - EFI_COMPONENT_NAME_PROTOCOL instance. - @param Language[in] A pointer to a Null-terminated ASCII string - array indicating the language. This is the - language of the driver name that the caller is - requesting, and it must match one of the - languages specified in SupportedLanguages. The - number of languages supported by a driver is up - to the driver writer. Language is specified - in RFC 4646 or ISO 639-2 language code format. - @param DriverName[out] A pointer to the Unicode string to return. - This Unicode string is the name of the - driver specified by This in the language - specified by Language. - - @retval EFI_SUCCESS The Unicode string for the Driver specified by - This and the language specified by Language was - returned in DriverName. - @retval EFI_INVALID_PARAMETER Language is NULL. - @retval EFI_INVALID_PARAMETER DriverName is NULL. - @retval EFI_UNSUPPORTED The driver specified by This does not support - the language specified by Language. - -**/ -EFI_STATUS -EFIAPI -Ip4ConfigComponentNameGetDriverName ( - IN EFI_COMPONENT_NAME_PROTOCOL *This, - IN CHAR8 *Language, - OUT CHAR16 **DriverName - ) -{ - return LookupUnicodeString2 ( - Language, - This->SupportedLanguages, - mIp4ConfigDriverNameTable, - DriverName, - (BOOLEAN)(This == &gIp4ConfigComponentName) - ); -} - -/** - Retrieves a Unicode string that is the user readable name of the controller - that is being managed by a driver. - - This function retrieves the user readable name of the controller specified by - ControllerHandle and ChildHandle in the form of a Unicode string. If the - driver specified by This has a user readable name in the language specified by - Language, then a pointer to the controller name is returned in ControllerName, - and EFI_SUCCESS is returned. If the driver specified by This is not currently - managing the controller specified by ControllerHandle and ChildHandle, - then EFI_UNSUPPORTED is returned. If the driver specified by This does not - support the language specified by Language, then EFI_UNSUPPORTED is returned. - - @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or - EFI_COMPONENT_NAME_PROTOCOL instance. - @param ControllerHandle[in] The handle of a controller that the driver - specified by This is managing. This handle - specifies the controller whose name is to be - returned. - @param ChildHandle[in] The handle of the child controller to retrieve - the name of. This is an optional parameter that - may be NULL. It will be NULL for device - drivers. It will also be NULL for a bus drivers - that wish to retrieve the name of the bus - controller. It will not be NULL for a bus - driver that wishes to retrieve the name of a - child controller. - @param Language[in] A pointer to a Null-terminated ASCII string - array indicating the language. This is the - language of the driver name that the caller is - requesting, and it must match one of the - languages specified in SupportedLanguages. The - number of languages supported by a driver is up - to the driver writer. Language is specified in - RFC 4646 or ISO 639-2 language code format. - @param ControllerName[out] A pointer to the Unicode string to return. - This Unicode string is the name of the - controller specified by ControllerHandle and - ChildHandle in the language specified by - Language from the point of view of the driver - specified by This. - - @retval EFI_SUCCESS The Unicode string for the user readable name in - the language specified by Language for the - driver specified by This was returned in - DriverName. - @retval EFI_INVALID_PARAMETER ControllerHandle is NULL. - @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid - EFI_HANDLE. - @retval EFI_INVALID_PARAMETER Language is NULL. - @retval EFI_INVALID_PARAMETER ControllerName is NULL. - @retval EFI_UNSUPPORTED The driver specified by This is not currently - managing the controller specified by - ControllerHandle and ChildHandle. - @retval EFI_UNSUPPORTED The driver specified by This does not support - the language specified by Language. - -**/ -EFI_STATUS -EFIAPI -Ip4ConfigComponentNameGetControllerName ( - IN EFI_COMPONENT_NAME_PROTOCOL *This, - IN EFI_HANDLE ControllerHandle, - IN EFI_HANDLE ChildHandle OPTIONAL, - IN CHAR8 *Language, - OUT CHAR16 **ControllerName - ) -{ - return EFI_UNSUPPORTED; -} diff --git a/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4Config.c b/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4Config.c deleted file mode 100644 index 3d2f0a4f9b..0000000000 --- a/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4Config.c +++ /dev/null @@ -1,745 +0,0 @@ -/** @file - This code implements the IP4Config and NicIp4Config protocols. - -Copyright (c) 2014, Hewlett-Packard Development Company, L.P.
-Copyright (c) 2006 - 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 -which accompanies this distribution. The full text of the license may be found at
-http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include "Ip4Config.h" -#include "NicIp4Variable.h" - -// -// Ip4 Config Protocol -// -GLOBAL_REMOVE_IF_UNREFERENCED EFI_IP4_CONFIG_PROTOCOL mIp4ConfigProtocolTemplate = { - EfiIp4ConfigStart, - EfiIp4ConfigStop, - EfiIp4ConfigGetData -}; - -/** - Get the NIC's configure information from the IP4 configure variable. - It will remove the invalid variable. - - @param Instance The IP4 CONFIG instance. - - @return NULL if no configure for the NIC in the variable, or it is invalid. - Otherwise the pointer to the NIC's IP configure parameter will be returned. - -**/ -NIC_IP4_CONFIG_INFO * -EfiNicIp4ConfigGetInfo ( - IN IP4_CONFIG_INSTANCE *Instance - ) -{ - NIC_IP4_CONFIG_INFO *NicConfig; - - // - // Read the configuration parameter for this NIC from - // the EFI variable - // - NicConfig = Ip4ConfigReadVariable (Instance); - if (NicConfig == NULL) { - return NULL; - } - - // - // Validate the configuration, if the configuration is invalid, - // remove it from the variable. - // - if (!Ip4ConfigIsValid (NicConfig)) { - Ip4ConfigWriteVariable (Instance, NULL); - - FreePool (NicConfig); - NicConfig = NULL; - } - - return NicConfig; -} - -/** - Set the IP configure parameters for this NIC. - - If Reconfig is TRUE, the IP driver will be informed to discard current - auto configure parameter and restart the auto configuration process. - If current there is a pending auto configuration, EFI_ALREADY_STARTED is - returned. You can only change the configure setting when either - the configure has finished or not started yet. If NicConfig, the - NIC's configure parameter is removed from the variable. - - @param Instance The IP4 CONFIG instance. - @param NicConfig The new NIC IP4 configure parameter. - @param Reconfig Inform the IP4 driver to restart the auto - configuration. - - @retval EFI_SUCCESS The configure parameter for this NIC was - set successfully. - @retval EFI_INVALID_PARAMETER This is NULL or the configure parameter is - invalid. - @retval EFI_ALREADY_STARTED There is a pending auto configuration. - @retval EFI_NOT_FOUND No auto configure parameter is found. - -**/ -EFI_STATUS -EFIAPI -EfiNicIp4ConfigSetInfo ( - IN IP4_CONFIG_INSTANCE *Instance, - IN NIC_IP4_CONFIG_INFO *NicConfig OPTIONAL, - IN BOOLEAN Reconfig - ) -{ - EFI_STATUS Status; - - // - // Validate the parameters - // - if (Instance == NULL) { - return EFI_INVALID_PARAMETER; - } - - if ((NicConfig != NULL) && (!Ip4ConfigIsValid (NicConfig) || - !NIC_ADDR_EQUAL (&NicConfig->NicAddr, &Instance->NicAddr))) { - return EFI_INVALID_PARAMETER; - } - - if (Instance->State == IP4_CONFIG_STATE_STARTED) { - return EFI_ALREADY_STARTED; - } - - // - // Update the parameter in the configure variable - // - Status = Ip4ConfigWriteVariable (Instance, NicConfig); - if (EFI_ERROR (Status)) { - return Status; - } - - // - // Signal the IP4 to run the auto configuration again - // - if (Reconfig && (Instance->ReconfigEvent != NULL)) { - // - // When NicConfig is NULL, NIC IP4 configuration parameter is removed, - // the auto configuration process should stop running the configuration - // policy for the EFI IPv4 Protocol driver. - // - if (NicConfig == NULL) { - Instance->DoNotStart = TRUE; - } - - Status = gBS->SignalEvent (Instance->ReconfigEvent); - DispatchDpc (); - } - - if (NicConfig == NULL) { - return Status; - } - // - // A dedicated timer is used to poll underlying media status.In case of - // cable swap, a new round auto configuration will be initiated. The timer - // starts in DHCP policy only. STATIC policy stops the timer. - // - if (NicConfig->Source == IP4_CONFIG_SOURCE_DHCP) { - gBS->SetTimer (Instance->Timer, TimerPeriodic, TICKS_PER_SECOND); - } else if (NicConfig->Source == IP4_CONFIG_SOURCE_STATIC) { - gBS->SetTimer (Instance->Timer, TimerCancel, 0); - } - - return Status; -} - -/** - Callback function when DHCP process finished. It will save the - retrieved IP configure parameter from DHCP to the NVRam. - - @param Event The callback event - @param Context Opaque context to the callback - - @return None - -**/ -VOID -EFIAPI -Ip4ConfigOnDhcp4Complete ( - IN EFI_EVENT Event, - IN VOID *Context - ) -{ - IP4_CONFIG_INSTANCE *Instance; - EFI_DHCP4_MODE_DATA Dhcp4Mode; - EFI_IP4_IPCONFIG_DATA *Ip4Config; - EFI_STATUS Status; - BOOLEAN Permanent; - IP4_ADDR Subnet; - IP4_ADDR Ip1; - IP4_ADDR Ip2; - - Instance = (IP4_CONFIG_INSTANCE *) Context; - ASSERT (Instance->Dhcp4 != NULL); - - Instance->State = IP4_CONFIG_STATE_CONFIGURED; - Instance->Result = EFI_TIMEOUT; - - // - // Get the DHCP retrieved parameters - // - Status = Instance->Dhcp4->GetModeData (Instance->Dhcp4, &Dhcp4Mode); - - if (EFI_ERROR (Status)) { - goto ON_EXIT; - } - - if (Dhcp4Mode.State == Dhcp4Bound) { - // - // Save the new configuration retrieved by DHCP both in - // the instance and to NVRam. So, both the IP4 driver and - // other user can get that address. - // - Permanent = FALSE; - - if (Instance->NicConfig != NULL) { - ASSERT (Instance->NicConfig->Source == IP4_CONFIG_SOURCE_DHCP); - Permanent = Instance->NicConfig->Permanent; - FreePool (Instance->NicConfig); - } - - Instance->NicConfig = AllocatePool (sizeof (NIC_IP4_CONFIG_INFO) + 2* sizeof (EFI_IP4_ROUTE_TABLE)); - - if (Instance->NicConfig == NULL) { - Instance->Result = EFI_OUT_OF_RESOURCES; - goto ON_EXIT; - } - - Instance->NicConfig->Ip4Info.RouteTable = (EFI_IP4_ROUTE_TABLE *) (Instance->NicConfig + 1); - - CopyMem (&Instance->NicConfig->NicAddr, &Instance->NicAddr, sizeof (Instance->NicConfig->NicAddr)); - Instance->NicConfig->Source = IP4_CONFIG_SOURCE_DHCP; - Instance->NicConfig->Permanent = Permanent; - - Ip4Config = &Instance->NicConfig->Ip4Info; - Ip4Config->StationAddress = Dhcp4Mode.ClientAddress; - Ip4Config->SubnetMask = Dhcp4Mode.SubnetMask; - - // - // Create a route for the connected network - // - Ip4Config->RouteTableSize = 1; - - CopyMem (&Ip1, &Dhcp4Mode.ClientAddress, sizeof (IP4_ADDR)); - CopyMem (&Ip2, &Dhcp4Mode.SubnetMask, sizeof (IP4_ADDR)); - - Subnet = Ip1 & Ip2; - - CopyMem (&Ip4Config->RouteTable[0].SubnetAddress, &Subnet, sizeof (EFI_IPv4_ADDRESS)); - CopyMem (&Ip4Config->RouteTable[0].SubnetMask, &Dhcp4Mode.SubnetMask, sizeof (EFI_IPv4_ADDRESS)); - ZeroMem (&Ip4Config->RouteTable[0].GatewayAddress, sizeof (EFI_IPv4_ADDRESS)); - - // - // Create a route if there is a default router. - // - if (!EFI_IP4_EQUAL (&Dhcp4Mode.RouterAddress, &mZeroIp4Addr)) { - Ip4Config->RouteTableSize = 2; - - ZeroMem (&Ip4Config->RouteTable[1].SubnetAddress, sizeof (EFI_IPv4_ADDRESS)); - ZeroMem (&Ip4Config->RouteTable[1].SubnetMask, sizeof (EFI_IPv4_ADDRESS)); - CopyMem (&Ip4Config->RouteTable[1].GatewayAddress, &Dhcp4Mode.RouterAddress, sizeof (EFI_IPv4_ADDRESS)); - } - - Instance->Result = EFI_SUCCESS; - - // - // ignore the return status of EfiNicIp4ConfigSetInfo. Network - // stack can operate even that failed. - // - EfiNicIp4ConfigSetInfo (Instance, Instance->NicConfig, FALSE); - } - -ON_EXIT: - gBS->SignalEvent (Instance->DoneEvent); - Ip4ConfigCleanDhcp4 (Instance); - - DispatchDpc (); - - return ; -} - -/** - Starts running the configuration policy for the EFI IPv4 Protocol driver. - - The Start() function is called to determine and to begin the platform - configuration policy by the EFI IPv4 Protocol driver. This determination may - be as simple as returning EFI_UNSUPPORTED if there is no EFI IPv4 Protocol - driver configuration policy. It may be as involved as loading some defaults - from nonvolatile storage, downloading dynamic data from a DHCP server, and - checking permissions with a site policy server. - Starting the configuration policy is just the beginning. It may finish almost - instantly or it may take several minutes before it fails to retrieve configuration - information from one or more servers. Once the policy is started, drivers - should use the DoneEvent parameter to determine when the configuration policy - has completed. EFI_IP4_CONFIG_PROTOCOL.GetData() must then be called to - determine if the configuration succeeded or failed. - Until the configuration completes successfully, EFI IPv4 Protocol driver instances - that are attempting to use default configurations must return EFI_NO_MAPPING. - Once the configuration is complete, the EFI IPv4 Configuration Protocol driver - signals DoneEvent. The configuration may need to be updated in the future, - however; in this case, the EFI IPv4 Configuration Protocol driver must signal - ReconfigEvent, and all EFI IPv4 Protocol driver instances that are using default - configurations must return EFI_NO_MAPPING until the configuration policy has - been rerun. - - @param This Pointer to the EFI_IP4_CONFIG_PROTOCOL instance. - @param DoneEvent Event that will be signaled when the EFI IPv4 - Protocol driver configuration policy completes - execution. This event must be of type EVT_NOTIFY_SIGNAL. - @param ReconfigEvent Event that will be signaled when the EFI IPv4 - Protocol driver configuration needs to be updated. - This event must be of type EVT_NOTIFY_SIGNAL. - - @retval EFI_SUCCESS The configuration policy for the EFI IPv4 Protocol - driver is now running. - @retval EFI_INVALID_PARAMETER One or more of the following parameters is NULL: - This - DoneEvent - ReconfigEvent - @retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated. - @retval EFI_ALREADY_STARTED The configuration policy for the EFI IPv4 Protocol - driver was already started. - @retval EFI_DEVICE_ERROR An unexpected system error or network error occurred. - @retval EFI_UNSUPPORTED This interface does not support the EFI IPv4 Protocol - driver configuration. - -**/ -EFI_STATUS -EFIAPI -EfiIp4ConfigStart ( - IN EFI_IP4_CONFIG_PROTOCOL *This, - IN EFI_EVENT DoneEvent, - IN EFI_EVENT ReconfigEvent - ) -{ - IP4_CONFIG_INSTANCE *Instance; - EFI_DHCP4_PROTOCOL *Dhcp4; - EFI_DHCP4_MODE_DATA Dhcp4Mode; - EFI_DHCP4_PACKET_OPTION *OptionList[1]; - IP4_CONFIG_DHCP4_OPTION ParaList; - EFI_STATUS Status; - UINT32 Source; - EFI_TPL OldTpl; - - if ((This == NULL) || (DoneEvent == NULL) || (ReconfigEvent == NULL)) { - return EFI_INVALID_PARAMETER; - } - - Instance = IP4_CONFIG_INSTANCE_FROM_IP4CONFIG (This); - - OldTpl = gBS->RaiseTPL (TPL_CALLBACK); - - if (Instance->State != IP4_CONFIG_STATE_IDLE) { - Status = EFI_ALREADY_STARTED; - - goto ON_EXIT; - } - - Instance->DoneEvent = DoneEvent; - Instance->ReconfigEvent = ReconfigEvent; - - Instance->NicConfig = EfiNicIp4ConfigGetInfo (Instance); - - if (Instance->NicConfig == NULL) { - if (Instance->DoNotStart) { - Instance->DoNotStart = FALSE; - Status = EFI_SUCCESS; - goto ON_EXIT; - } - - Source = IP4_CONFIG_SOURCE_DHCP; - } else { - Source = Instance->NicConfig->Source; - } - - // - // If the source is static, the auto configuration is done. - // return now. - // - if (Source == IP4_CONFIG_SOURCE_STATIC) { - Instance->State = IP4_CONFIG_STATE_CONFIGURED; - Instance->Result = EFI_SUCCESS; - - gBS->SignalEvent (Instance->DoneEvent); - Status = EFI_SUCCESS; - goto ON_EXIT; - } - - // - // Start the dhcp process - // - ASSERT ((Source == IP4_CONFIG_SOURCE_DHCP) && (Instance->Dhcp4 == NULL)); - - Status = NetLibCreateServiceChild ( - Instance->Controller, - Instance->Image, - &gEfiDhcp4ServiceBindingProtocolGuid, - &Instance->Dhcp4Handle - ); - - if (EFI_ERROR (Status)) { - goto ON_ERROR; - } - - Status = gBS->OpenProtocol ( - Instance->Dhcp4Handle, - &gEfiDhcp4ProtocolGuid, - (VOID **) &Instance->Dhcp4, - Instance->Image, - Instance->Controller, - EFI_OPEN_PROTOCOL_BY_DRIVER - ); - - if (EFI_ERROR (Status)) { - goto ON_ERROR; - } - - // - // Check the current DHCP status, if the DHCP process has - // already finished, return now. - // - Dhcp4 = Instance->Dhcp4; - Status = Dhcp4->GetModeData (Dhcp4, &Dhcp4Mode); - - if (EFI_ERROR (Status)) { - goto ON_ERROR; - } - - if (Dhcp4Mode.State == Dhcp4Bound) { - Ip4ConfigOnDhcp4Complete (NULL, Instance); - - goto ON_EXIT; - } - - // - // Try to start the DHCP process. Use most of the current - // DHCP configuration to avoid problems if some DHCP client - // yields the control of this DHCP service to us. - // - ParaList.Head.OpCode = DHCP_TAG_PARA_LIST; - ParaList.Head.Length = 2; - ParaList.Head.Data[0] = DHCP_TAG_NETMASK; - ParaList.Route = DHCP_TAG_ROUTER; - OptionList[0] = &ParaList.Head; - Dhcp4Mode.ConfigData.OptionCount = 1; - Dhcp4Mode.ConfigData.OptionList = OptionList; - - Status = Dhcp4->Configure (Dhcp4, &Dhcp4Mode.ConfigData); - - if (EFI_ERROR (Status)) { - goto ON_ERROR; - } - - // - // Start the DHCP process - // - Status = gBS->CreateEvent ( - EVT_NOTIFY_SIGNAL, - TPL_CALLBACK, - Ip4ConfigOnDhcp4Complete, - Instance, - &Instance->Dhcp4Event - ); - - if (EFI_ERROR (Status)) { - goto ON_ERROR; - } - - Status = Dhcp4->Start (Dhcp4, Instance->Dhcp4Event); - - if (EFI_ERROR (Status)) { - goto ON_ERROR; - } - - Instance->State = IP4_CONFIG_STATE_STARTED; - Instance->Result = EFI_NOT_READY; - -ON_ERROR: - if (EFI_ERROR (Status)) { - Ip4ConfigCleanConfig (Instance); - } - -ON_EXIT: - gBS->RestoreTPL (OldTpl); - - DispatchDpc (); - - return Status; -} - - -/** - Stops running the configuration policy for the EFI IPv4 Protocol driver. - - The Stop() function stops the configuration policy for the EFI IPv4 Protocol driver. - All configuration data will be lost after calling Stop(). - - @param This Pointer to the EFI_IP4_CONFIG_PROTOCOL instance. - - @retval EFI_SUCCESS The configuration policy for the EFI IPv4 Protocol - driver has been stopped. - @retval EFI_INVALID_PARAMETER This is NULL. - @retval EFI_NOT_STARTED The configuration policy for the EFI IPv4 Protocol - driver was not started. - -**/ -EFI_STATUS -EFIAPI -EfiIp4ConfigStop ( - IN EFI_IP4_CONFIG_PROTOCOL *This - ) -{ - IP4_CONFIG_INSTANCE *Instance; - EFI_STATUS Status; - EFI_TPL OldTpl; - - if (This == NULL) { - return EFI_INVALID_PARAMETER; - } - - Instance = IP4_CONFIG_INSTANCE_FROM_IP4CONFIG (This); - - Status = EFI_SUCCESS; - OldTpl = gBS->RaiseTPL (TPL_CALLBACK); - - if (Instance->State == IP4_CONFIG_STATE_IDLE) { - Status = EFI_NOT_STARTED; - goto ON_EXIT; - } - - // - // Release all the configure parameters. Don't signal the user - // event. The user wants to abort the configuration, this isn't - // the configuration done or reconfiguration. - // - Ip4ConfigCleanConfig (Instance); - -ON_EXIT: - gBS->RestoreTPL (OldTpl); - - return Status; -} - - -/** - Returns the default configuration data (if any) for the EFI IPv4 Protocol driver. - - The GetData() function returns the current configuration data for the EFI IPv4 - Protocol driver after the configuration policy has completed. - - @param This Pointer to the EFI_IP4_CONFIG_PROTOCOL instance. - @param ConfigDataSize On input, the size of the ConfigData buffer. - On output, the count of bytes that were written - into the ConfigData buffer. - @param ConfigData Pointer to the EFI IPv4 Configuration Protocol - driver configuration data structure. - Type EFI_IP4_IPCONFIG_DATA is defined in - "Related Definitions" below. - - @retval EFI_SUCCESS The EFI IPv4 Protocol driver configuration has been returned. - @retval EFI_INVALID_PARAMETER This is NULL. - @retval EFI_NOT_STARTED The configuration policy for the EFI IPv4 Protocol - driver is not running. - @retval EFI_NOT_READY EFI IPv4 Protocol driver configuration is still running. - @retval EFI_ABORTED EFI IPv4 Protocol driver configuration could not complete. - Currently not implemented. - @retval EFI_BUFFER_TOO_SMALL *ConfigDataSize is smaller than the configuration - data buffer or ConfigData is NULL. - -**/ -EFI_STATUS -EFIAPI -EfiIp4ConfigGetData ( - IN EFI_IP4_CONFIG_PROTOCOL *This, - IN OUT UINTN *ConfigDataSize, - OUT EFI_IP4_IPCONFIG_DATA *ConfigData OPTIONAL - ) -{ - IP4_CONFIG_INSTANCE *Instance; - NIC_IP4_CONFIG_INFO *NicConfig; - EFI_STATUS Status; - EFI_TPL OldTpl; - UINTN Len; - - if ((This == NULL) || (ConfigDataSize == NULL)) { - return EFI_INVALID_PARAMETER; - } - - Instance = IP4_CONFIG_INSTANCE_FROM_IP4CONFIG (This); - - Status = EFI_SUCCESS; - OldTpl = gBS->RaiseTPL (TPL_CALLBACK); - - if (Instance->State == IP4_CONFIG_STATE_IDLE) { - Status = EFI_NOT_STARTED; - } else if (Instance->State == IP4_CONFIG_STATE_STARTED) { - Status = EFI_NOT_READY; - } - - if (EFI_ERROR (Status)) { - goto ON_EXIT; - } - - // - // Copy the configure data if auto configuration succeeds. - // - Status = Instance->Result; - - if (Status == EFI_SUCCESS) { - ASSERT (Instance->NicConfig != NULL); - - NicConfig = Instance->NicConfig; - Len = SIZEOF_IP4_CONFIG_INFO (&NicConfig->Ip4Info); - - if ((*ConfigDataSize < Len) || (ConfigData == NULL)) { - Status = EFI_BUFFER_TOO_SMALL; - } else { - CopyMem (ConfigData, &NicConfig->Ip4Info, Len); - Ip4ConfigFixRouteTablePointer (ConfigData); - } - - *ConfigDataSize = Len; - } - -ON_EXIT: - gBS->RestoreTPL (OldTpl); - - return Status; -} - -/** - Release all the DHCP related resources. - - @param This The IP4 configure instance - - @return None - -**/ -VOID -Ip4ConfigCleanDhcp4 ( - IN IP4_CONFIG_INSTANCE *This - ) -{ - if (This->Dhcp4 != NULL) { - This->Dhcp4->Stop (This->Dhcp4); - - gBS->CloseProtocol ( - This->Dhcp4Handle, - &gEfiDhcp4ProtocolGuid, - This->Image, - This->Controller - ); - - This->Dhcp4 = NULL; - } - - if (This->Dhcp4Handle != NULL) { - NetLibDestroyServiceChild ( - This->Controller, - This->Image, - &gEfiDhcp4ServiceBindingProtocolGuid, - This->Dhcp4Handle - ); - - This->Dhcp4Handle = NULL; - } - - if (This->Dhcp4Event != NULL) { - gBS->CloseEvent (This->Dhcp4Event); - This->Dhcp4Event = NULL; - } -} - - -/** - Clean up all the configuration parameters. - - @param Instance The IP4 configure instance - - @return None - -**/ -VOID -Ip4ConfigCleanConfig ( - IN IP4_CONFIG_INSTANCE *Instance - ) -{ - if (Instance->NicConfig != NULL) { - FreePool (Instance->NicConfig); - Instance->NicConfig = NULL; - } - - Instance->State = IP4_CONFIG_STATE_IDLE; - Instance->DoneEvent = NULL; - Instance->ReconfigEvent = NULL; - - Ip4ConfigCleanDhcp4 (Instance); -} - - -/** - A dedicated timer is used to poll underlying media status. In case of - cable swap, a new round auto configuration will be initiated. The timer - will signal the IP4 to run the auto configuration again. IP4 driver will free - old IP address related resource, such as route table and Interface, then - initiate a DHCP process by IP4Config->Start to acquire new IP, eventually - create route table for new IP address. - - @param[in] Event The IP4 service instance's heart beat timer. - @param[in] Context The IP4 service instance. - -**/ -VOID -EFIAPI -MediaChangeDetect ( - IN EFI_EVENT Event, - IN VOID *Context - ) -{ - BOOLEAN OldMediaPresent; - EFI_STATUS Status; - EFI_SIMPLE_NETWORK_MODE SnpModeData; - IP4_CONFIG_INSTANCE *Instance; - - Instance = (IP4_CONFIG_INSTANCE *) Context; - - OldMediaPresent = Instance->MediaPresent; - - // - // Get fresh mode data from MNP, since underlying media status may change - // - Status = Instance->Mnp->GetModeData (Instance->Mnp, NULL, &SnpModeData); - if (EFI_ERROR (Status) && (Status != EFI_NOT_STARTED)) { - return; - } - - Instance->MediaPresent = SnpModeData.MediaPresent; - // - // Media transimit Unpresent to Present means new link movement is detected. - // - if (!OldMediaPresent && Instance->MediaPresent) { - // - // Signal the IP4 to run the auto configuration again. IP4 driver will free - // old IP address related resource, such as route table and Interface, then - // initiate a DHCP round by IP4Config->Start to acquire new IP, eventually - // create route table for new IP address. - // - if (Instance->ReconfigEvent != NULL) { - Status = gBS->SignalEvent (Instance->ReconfigEvent); - DispatchDpc (); - } - } -} diff --git a/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4Config.h b/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4Config.h deleted file mode 100644 index cbe8ec5fcf..0000000000 --- a/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4Config.h +++ /dev/null @@ -1,533 +0,0 @@ -/** @file - Header file for IP4Config driver. - -Copyright (c) 2006 - 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 -which accompanies this distribution. The full text of the license may be found at
-http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#ifndef _EFI_IP4CONFIG_H_ -#define _EFI_IP4CONFIG_H_ - -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -// -// Global variables -// -extern EFI_DRIVER_BINDING_PROTOCOL gIp4ConfigDriverBinding; -extern EFI_COMPONENT_NAME_PROTOCOL gIp4ConfigComponentName; -extern EFI_COMPONENT_NAME2_PROTOCOL gIp4ConfigComponentName2; - -extern EFI_IP4_CONFIG_PROTOCOL mIp4ConfigProtocolTemplate; - -#define IP4_PROTO_ICMP 0x01 -#define IP4_CONFIG_INSTANCE_SIGNATURE SIGNATURE_32 ('I', 'P', '4', 'C') - -#define IP4_CONFIG_STATE_IDLE 0 -#define IP4_CONFIG_STATE_STARTED 1 -#define IP4_CONFIG_STATE_CONFIGURED 2 - -#define DHCP_TAG_PARA_LIST 55 -#define DHCP_TAG_NETMASK 1 -#define DHCP_TAG_ROUTER 3 - - -// -// Configure the DHCP to request the routers and netmask -// from server. The DHCP_TAG_NETMASK is included in Head. -// -#pragma pack(1) -typedef struct { - EFI_DHCP4_PACKET_OPTION Head; - UINT8 Route; -} IP4_CONFIG_DHCP4_OPTION; -#pragma pack() - -typedef struct _IP4CONFIG_CALLBACK_INFO { - BOOLEAN Configured; - BOOLEAN DhcpEnabled; - EFI_IPv4_ADDRESS LocalIp; - EFI_IPv4_ADDRESS SubnetMask; - EFI_IPv4_ADDRESS Gateway; -} IP4_SETTING_INFO; - -typedef struct _IP4_CONFIG_INSTANCE { - UINT32 Signature; - EFI_HANDLE Controller; - EFI_HANDLE Image; - EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath; - - EFI_IP4_CONFIG_PROTOCOL Ip4ConfigProtocol; - - EFI_HII_CONFIG_ACCESS_PROTOCOL HiiConfigAccessProtocol; - EFI_HANDLE ChildHandle; - EFI_DEVICE_PATH_PROTOCOL *HiiVendorDevicePath; - EFI_HII_HANDLE RegisteredHandle; - IP4_SETTING_INFO Ip4ConfigCallbackInfo; - - // - // NicConfig's state, such as IP4_CONFIG_STATE_IDLE - // - INTN State; - - // - // Mnp child to keep the connection with MNP. - // - EFI_MANAGED_NETWORK_PROTOCOL *Mnp; - EFI_HANDLE MnpHandle; - - // - // User's requests data - // - EFI_EVENT DoneEvent; - EFI_EVENT ReconfigEvent; - EFI_STATUS Result; - - // - // Identity of this interface and some configuration info. - // - NIC_ADDR NicAddr; - CHAR16 *MacString; - NIC_IP4_CONFIG_INFO *NicConfig; - - // - // DHCP handles to access DHCP - // - EFI_DHCP4_PROTOCOL *Dhcp4; - EFI_HANDLE Dhcp4Handle; - EFI_EVENT Dhcp4Event; - - // - // A dedicated timer is used to poll underlying media status - // - EFI_EVENT Timer; - - // - // Underlying media present status. - // - BOOLEAN MediaPresent; - - // - // A flag to indicate EfiIp4ConfigStart should not run - // - BOOLEAN DoNotStart; -} IP4_CONFIG_INSTANCE; - -#define IP4_CONFIG_INSTANCE_FROM_IP4CONFIG(this) \ - CR (this, IP4_CONFIG_INSTANCE, Ip4ConfigProtocol, IP4_CONFIG_INSTANCE_SIGNATURE) - -#define IP4_CONFIG_INSTANCE_FROM_CONFIG_ACCESS(this) \ - CR (this, IP4_CONFIG_INSTANCE, HiiConfigAccessProtocol, IP4_CONFIG_INSTANCE_SIGNATURE) - - -/** - Set the IP configure parameters for this NIC. - - If Reconfig is TRUE, the IP driver will be informed to discard current - auto configure parameter and restart the auto configuration process. - If current there is a pending auto configuration, EFI_ALREADY_STARTED is - returned. You can only change the configure setting when either - the configure has finished or not started yet. If NicConfig, the - NIC's configure parameter is removed from the variable. - - @param Instance The IP4 CONFIG instance. - @param NicConfig The new NIC IP4 configure parameter. - @param Reconfig Inform the IP4 driver to restart the auto - configuration. - - @retval EFI_SUCCESS The configure parameter for this NIC was - set successfully. - @retval EFI_INVALID_PARAMETER This is NULL or the configure parameter is - invalid. - @retval EFI_ALREADY_STARTED There is a pending auto configuration. - @retval EFI_NOT_FOUND No auto configure parameter is found. - -**/ -EFI_STATUS -EFIAPI -EfiNicIp4ConfigSetInfo ( - IN IP4_CONFIG_INSTANCE *Instance, - IN NIC_IP4_CONFIG_INFO *NicConfig OPTIONAL, - IN BOOLEAN Reconfig - ); - -/** - Get the NIC's configure information from the IP4 configure variable. - It will remove the invalid variable. - - @param Instance The IP4 CONFIG instance. - - @return NULL if no configure for the NIC in the variable, or it is invalid. - Otherwise the pointer to the NIC's IP configure parameter will be returned. - -**/ -NIC_IP4_CONFIG_INFO * -EfiNicIp4ConfigGetInfo ( - IN IP4_CONFIG_INSTANCE *Instance - ); - -/** - Release all the DHCP related resources. - - @param This The IP4 configure instance - - @return None - -**/ -VOID -Ip4ConfigCleanDhcp4 ( - IN IP4_CONFIG_INSTANCE *This - ); - -/** - Clean up all the configuration parameters. - - @param Instance The IP4 configure instance - - @return None - -**/ -VOID -Ip4ConfigCleanConfig ( - IN IP4_CONFIG_INSTANCE *Instance - ); - -// -// EFI Component Name Functions -// - -/** - Retrieves a Unicode string that is the user readable name of the driver. - - This function retrieves the user readable name of a driver in the form of a - Unicode string. If the driver specified by This has a user readable name in - the language specified by Language, then a pointer to the driver name is - returned in DriverName, and EFI_SUCCESS is returned. If the driver specified - by This does not support the language specified by Language, - then EFI_UNSUPPORTED is returned. - - @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or - EFI_COMPONENT_NAME_PROTOCOL instance. - @param Language[in] A pointer to a Null-terminated ASCII string - array indicating the language. This is the - language of the driver name that the caller is - requesting, and it must match one of the - languages specified in SupportedLanguages. The - number of languages supported by a driver is up - to the driver writer. Language is specified - in RFC 3066 or ISO 639-2 language code format. - @param DriverName[out] A pointer to the Unicode string to return. - This Unicode string is the name of the - driver specified by This in the language - specified by Language. - - @retval EFI_SUCCESS The Unicode string for the Driver specified by - This and the language specified by Language was - returned in DriverName. - @retval EFI_INVALID_PARAMETER Language is NULL. - @retval EFI_INVALID_PARAMETER DriverName is NULL. - @retval EFI_UNSUPPORTED The driver specified by This does not support - the language specified by Language. - -**/ -EFI_STATUS -EFIAPI -Ip4ConfigComponentNameGetDriverName ( - IN EFI_COMPONENT_NAME_PROTOCOL *This, - IN CHAR8 *Language, - OUT CHAR16 **DriverName - ); - -/** - Retrieves a Unicode string that is the user readable name of the controller - that is being managed by a driver. - - This function retrieves the user readable name of the controller specified by - ControllerHandle and ChildHandle in the form of a Unicode string. If the - driver specified by This has a user readable name in the language specified by - Language, then a pointer to the controller name is returned in ControllerName, - and EFI_SUCCESS is returned. If the driver specified by This is not currently - managing the controller specified by ControllerHandle and ChildHandle, - then EFI_UNSUPPORTED is returned. If the driver specified by This does not - support the language specified by Language, then EFI_UNSUPPORTED is returned. - - @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or - EFI_COMPONENT_NAME_PROTOCOL instance. - @param ControllerHandle[in] The handle of a controller that the driver - specified by This is managing. This handle - specifies the controller whose name is to be - returned. - @param ChildHandle[in] The handle of the child controller to retrieve - the name of. This is an optional parameter that - may be NULL. It will be NULL for device - drivers. It will also be NULL for a bus drivers - that wish to retrieve the name of the bus - controller. It will not be NULL for a bus - driver that wishes to retrieve the name of a - child controller. - @param Language[in] A pointer to a Null-terminated ASCII string - array indicating the language. This is the - language of the driver name that the caller is - requesting, and it must match one of the - languages specified in SupportedLanguages. The - number of languages supported by a driver is up - to the driver writer. Language is specified in - RFC 3066 or ISO 639-2 language code format. - @param ControllerName[out] A pointer to the Unicode string to return. - This Unicode string is the name of the - controller specified by ControllerHandle and - ChildHandle in the language specified by - Language from the point of view of the driver - specified by This. - - @retval EFI_SUCCESS The Unicode string for the user readable name in - the language specified by Language for the - driver specified by This was returned in - DriverName. - @retval EFI_INVALID_PARAMETER ControllerHandle is NULL. - @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid - EFI_HANDLE. - @retval EFI_INVALID_PARAMETER Language is NULL. - @retval EFI_INVALID_PARAMETER ControllerName is NULL. - @retval EFI_UNSUPPORTED The driver specified by This is not currently - managing the controller specified by - ControllerHandle and ChildHandle. - @retval EFI_UNSUPPORTED The driver specified by This does not support - the language specified by Language. - -**/ -EFI_STATUS -EFIAPI -Ip4ConfigComponentNameGetControllerName ( - IN EFI_COMPONENT_NAME_PROTOCOL *This, - IN EFI_HANDLE ControllerHandle, - IN EFI_HANDLE ChildHandle OPTIONAL, - IN CHAR8 *Language, - OUT CHAR16 **ControllerName - ); - -/** - Test to see if this driver supports ControllerHandle. - - @param This Protocol instance pointer. - @param ControllerHandle Handle of device to test - @param RemainingDevicePath Optional parameter use to pick a specific child - device to start. - - @retval EFI_SUCCES This driver supports this device - @retval EFI_ALREADY_STARTED This driver is already running on this device - @retval other This driver does not support this device - -**/ -EFI_STATUS -EFIAPI -Ip4ConfigDriverBindingSupported ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE ControllerHandle, - IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL - ); - -/** - Start this driver on ControllerHandle. - - @param This Protocol instance pointer. - @param ControllerHandle Handle of device to bind driver to - @param RemainingDevicePath Optional parameter use to pick a specific child - device to start. - - @retval EFI_SUCCES This driver is added to ControllerHandle - @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle - @retval other This driver does not support this device - -**/ -EFI_STATUS -EFIAPI -Ip4ConfigDriverBindingStart ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE ControllerHandle, - IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL - ); - -/** - Stop this driver on ControllerHandle. - - @param This Protocol instance pointer. - @param ControllerHandle Handle of device to stop driver on - @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of - children is zero stop the entire bus driver. - @param ChildHandleBuffer List of Child Handles to Stop. - - @retval EFI_SUCCES This driver is removed ControllerHandle - @retval other This driver was not removed from this device - -**/ -EFI_STATUS -EFIAPI -Ip4ConfigDriverBindingStop ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE ControllerHandle, - IN UINTN NumberOfChildren, - IN EFI_HANDLE *ChildHandleBuffer - ); - -/** - Starts running the configuration policy for the EFI IPv4 Protocol driver. - - The Start() function is called to determine and to begin the platform - configuration policy by the EFI IPv4 Protocol driver. This determination may - be as simple as returning EFI_UNSUPPORTED if there is no EFI IPv4 Protocol - driver configuration policy. It may be as involved as loading some defaults - from nonvolatile storage, downloading dynamic data from a DHCP server, and - checking permissions with a site policy server. - Starting the configuration policy is just the beginning. It may finish almost - instantly or it may take several minutes before it fails to retrieve configuration - information from one or more servers. Once the policy is started, drivers - should use the DoneEvent parameter to determine when the configuration policy - has completed. EFI_IP4_CONFIG_PROTOCOL.GetData() must then be called to - determine if the configuration succeeded or failed. - Until the configuration completes successfully, EFI IPv4 Protocol driver instances - that are attempting to use default configurations must return EFI_NO_MAPPING. - Once the configuration is complete, the EFI IPv4 Configuration Protocol driver - signals DoneEvent. The configuration may need to be updated in the future, - however; in this case, the EFI IPv4 Configuration Protocol driver must signal - ReconfigEvent, and all EFI IPv4 Protocol driver instances that are using default - configurations must return EFI_NO_MAPPING until the configuration policy has - been rerun. - - @param This Pointer to the EFI_IP4_CONFIG_PROTOCOL instance. - @param DoneEvent Event that will be signaled when the EFI IPv4 - Protocol driver configuration policy completes - execution. This event must be of type EVT_NOTIFY_SIGNAL. - @param ReconfigEvent Event that will be signaled when the EFI IPv4 - Protocol driver configuration needs to be updated. - This event must be of type EVT_NOTIFY_SIGNAL. - - @retval EFI_SUCCESS The configuration policy for the EFI IPv4 Protocol - driver is now running. - @retval EFI_INVALID_PARAMETER One or more of the following parameters is NULL: - This - DoneEvent - ReconfigEvent - @retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated. - @retval EFI_ALREADY_STARTED The configuration policy for the EFI IPv4 Protocol - driver was already started. - @retval EFI_DEVICE_ERROR An unexpected system error or network error occurred. - @retval EFI_UNSUPPORTED This interface does not support the EFI IPv4 Protocol - driver configuration. - -**/ -EFI_STATUS -EFIAPI -EfiIp4ConfigStart ( - IN EFI_IP4_CONFIG_PROTOCOL *This, - IN EFI_EVENT DoneEvent, - IN EFI_EVENT ReconfigEvent - ); - -/** - Stops running the configuration policy for the EFI IPv4 Protocol driver. - - The Stop() function stops the configuration policy for the EFI IPv4 Protocol driver. - All configuration data will be lost after calling Stop(). - - @param This Pointer to the EFI_IP4_CONFIG_PROTOCOL instance. - - @retval EFI_SUCCESS The configuration policy for the EFI IPv4 Protocol - driver has been stopped. - @retval EFI_INVALID_PARAMETER This is NULL. - @retval EFI_NOT_STARTED The configuration policy for the EFI IPv4 Protocol - driver was not started. - -**/ -EFI_STATUS -EFIAPI -EfiIp4ConfigStop ( - IN EFI_IP4_CONFIG_PROTOCOL *This - ); - -/** - Returns the default configuration data (if any) for the EFI IPv4 Protocol driver. - - The GetData() function returns the current configuration data for the EFI IPv4 - Protocol driver after the configuration policy has completed. - - @param This Pointer to the EFI_IP4_CONFIG_PROTOCOL instance. - @param ConfigDataSize On input, the size of the ConfigData buffer. - On output, the count of bytes that were written - into the ConfigData buffer. - @param ConfigData Pointer to the EFI IPv4 Configuration Protocol - driver configuration data structure. - Type EFI_IP4_IPCONFIG_DATA is defined in - "Related Definitions" below. - - @retval EFI_SUCCESS The EFI IPv4 Protocol driver configuration has been returned. - @retval EFI_INVALID_PARAMETER This is NULL. - @retval EFI_NOT_STARTED The configuration policy for the EFI IPv4 Protocol - driver is not running. - @retval EFI_NOT_READY EFI IPv4 Protocol driver configuration is still running. - @retval EFI_ABORTED EFI IPv4 Protocol driver configuration could not complete. - Currently not implemented. - @retval EFI_BUFFER_TOO_SMALL *ConfigDataSize is smaller than the configuration - data buffer or ConfigData is NULL. - -**/ -EFI_STATUS -EFIAPI -EfiIp4ConfigGetData ( - IN EFI_IP4_CONFIG_PROTOCOL *This, - IN OUT UINTN *ConfigDataSize, - OUT EFI_IP4_IPCONFIG_DATA *ConfigData OPTIONAL - ); - -/** - A dedicated timer is used to poll underlying media status. In case of - cable swap, a new round auto configuration will be initiated. The timer - will signal the IP4 to run the auto configuration again. IP4 driver will free - old IP address related resource, such as route table and Interface, then - initiate a DHCP round by IP4Config->Start to acquire new IP, eventually - create route table for new IP address. - - @param[in] Event The IP4 service instance's heart beat timer. - @param[in] Context The IP4 service instance. - -**/ -VOID -EFIAPI -MediaChangeDetect ( - IN EFI_EVENT Event, - IN VOID *Context - ); - -#endif diff --git a/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigDriver.c b/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigDriver.c deleted file mode 100644 index 56cce6e6f0..0000000000 --- a/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigDriver.c +++ /dev/null @@ -1,505 +0,0 @@ -/** @file - The driver binding for IP4 CONFIG protocol. - -Copyright (c) 2006 - 2013, 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 -which accompanies this distribution. The full text of the license may be found at
-http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - - -#include "Ip4Config.h" -#include "Ip4ConfigNv.h" -#include "NicIp4Variable.h" - -EFI_DRIVER_BINDING_PROTOCOL gIp4ConfigDriverBinding = { - Ip4ConfigDriverBindingSupported, - Ip4ConfigDriverBindingStart, - Ip4ConfigDriverBindingStop, - 0xa, - NULL, - NULL -}; - -// -// The intance of template of IP4 Config private data -// -IP4_CONFIG_INSTANCE mIp4ConfigTemplate = { - IP4_CONFIG_INSTANCE_SIGNATURE, - NULL, - NULL, - (EFI_DEVICE_PATH_PROTOCOL *) NULL, - { - NULL, - NULL, - NULL - }, - { - NULL, - NULL, - NULL - }, - NULL, - (EFI_DEVICE_PATH_PROTOCOL *) NULL, - NULL, - { - FALSE, - FALSE, - { - { - 0 - } - }, - { - { - 0 - } - }, - { - { - 0 - } - } - }, - 0, - (EFI_MANAGED_NETWORK_PROTOCOL *) NULL, - NULL, - NULL, - NULL, - 0, - { - 0, - 0, - { - { - 0 - } - } - }, - (CHAR16 *) NULL, - (NIC_IP4_CONFIG_INFO *) NULL, - (EFI_DHCP4_PROTOCOL *) NULL, - NULL, - NULL, - NULL, - TRUE, - FALSE -}; - -/** - The entry point for IP4 config driver which install the driver - binding and component name protocol on its image. - - @param ImageHandle The image handle of the driver. - @param SystemTable The system table. - - @retval EFI_SUCCES All the related protocols are installed on the driver. - @retval Others Failed to install protocols. - -**/ -EFI_STATUS -EFIAPI -Ip4ConfigDriverEntryPoint ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable - ) -{ - mIp4ConfigTemplate.Result = EFI_NOT_READY; - - return EfiLibInstallDriverBindingComponentName2 ( - ImageHandle, - SystemTable, - &gIp4ConfigDriverBinding, - ImageHandle, - &gIp4ConfigComponentName, - &gIp4ConfigComponentName2 - ); -} - - -/** - Test to see if this driver supports ControllerHandle. - - @param This Protocol instance pointer. - @param ControllerHandle Handle of device to test - @param RemainingDevicePath Optional parameter use to pick a specific child - device to start. - - @retval EFI_SUCCES This driver supports this device - @retval EFI_ALREADY_STARTED This driver is already running on this device - @retval other This driver does not support this device - -**/ -EFI_STATUS -EFIAPI -Ip4ConfigDriverBindingSupported ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE ControllerHandle, - IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL - ) -{ - EFI_STATUS Status; - - Status = gBS->OpenProtocol ( - ControllerHandle, - &gEfiManagedNetworkServiceBindingProtocolGuid, - NULL, - This->DriverBindingHandle, - ControllerHandle, - EFI_OPEN_PROTOCOL_TEST_PROTOCOL - ); - - return Status; -} - - -/** - Start this driver on ControllerHandle. - - @param This Protocol instance pointer. - @param ControllerHandle Handle of device to bind driver to - @param RemainingDevicePath Optional parameter use to pick a specific child - device to start. - - @retval EFI_SUCCES This driver is added to ControllerHandle - @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle - @retval other This driver does not support this device - -**/ -EFI_STATUS -EFIAPI -Ip4ConfigDriverBindingStart ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE ControllerHandle, - IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL - ) -{ - EFI_IP4_CONFIG_PROTOCOL *Ip4Config; - EFI_MANAGED_NETWORK_PROTOCOL *Mnp; - EFI_HANDLE MnpHandle; - IP4_CONFIG_INSTANCE *Instance; - EFI_SIMPLE_NETWORK_MODE SnpMode; - NIC_IP4_CONFIG_INFO *NicConfig; - EFI_STATUS Status; - EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath; - - Status = gBS->HandleProtocol ( - ControllerHandle, - &gEfiDevicePathProtocolGuid, - (VOID **) &ParentDevicePath - ); - if (EFI_ERROR (Status)) { - return Status; - } - - // - // Check for multiple start. - // - Status = gBS->OpenProtocol ( - ControllerHandle, - &gEfiIp4ConfigProtocolGuid, - (VOID **) &Ip4Config, - This->DriverBindingHandle, - ControllerHandle, - EFI_OPEN_PROTOCOL_GET_PROTOCOL - ); - - if (!EFI_ERROR (Status)) { - return EFI_ALREADY_STARTED; - } - - // - // Create a MNP child - // - Mnp = NULL; - MnpHandle = NULL; - Instance = NULL; - - Status = NetLibCreateServiceChild ( - ControllerHandle, - This->DriverBindingHandle, - &gEfiManagedNetworkServiceBindingProtocolGuid, - &MnpHandle - ); - - if (EFI_ERROR (Status)) { - return Status; - } - - Status = gBS->OpenProtocol ( - MnpHandle, - &gEfiManagedNetworkProtocolGuid, - (VOID **) &Mnp, - This->DriverBindingHandle, - ControllerHandle, - EFI_OPEN_PROTOCOL_BY_DRIVER - ); - - if (EFI_ERROR (Status)) { - goto ON_ERROR; - } - - // - // Allocate an instance then initialize it - // - Instance = AllocateCopyPool (sizeof (IP4_CONFIG_INSTANCE), &mIp4ConfigTemplate); - - if (Instance == NULL) { - Status = EFI_OUT_OF_RESOURCES; - goto ON_ERROR; - } - - Instance->Controller = ControllerHandle; - Instance->Image = This->DriverBindingHandle; - Instance->ParentDevicePath = ParentDevicePath; - - CopyMem (&Instance->Ip4ConfigProtocol, &mIp4ConfigProtocolTemplate, sizeof (mIp4ConfigProtocolTemplate)); - - Instance->State = IP4_CONFIG_STATE_IDLE; - Instance->Mnp = Mnp; - Instance->MnpHandle = MnpHandle; - - Status = Mnp->GetModeData (Mnp, NULL, &SnpMode); - - if (EFI_ERROR (Status) && (Status != EFI_NOT_STARTED)) { - goto ON_ERROR; - } - - Instance->NicAddr.Type = (UINT16) SnpMode.IfType; - Instance->NicAddr.Len = (UINT8) SnpMode.HwAddressSize; - CopyMem (&Instance->NicAddr.MacAddr, &SnpMode.CurrentAddress, Instance->NicAddr.Len); - - // - // Add it to the global list, and compose the name - // - Status = NetLibGetMacString (Instance->Controller, Instance->Image, &Instance->MacString); - if (EFI_ERROR (Status)) { - goto ON_ERROR; - } - - Status = Ip4ConfigDeviceInit (Instance); - - // - // Install the IP4_CONFIG protocols - // - Status = gBS->InstallMultipleProtocolInterfaces ( - &ControllerHandle, - &gEfiIp4ConfigProtocolGuid, - &Instance->Ip4ConfigProtocol, - NULL - ); - - if (EFI_ERROR (Status)) { - goto ON_ERROR; - } - - // - // A dedicated timer is used to poll underlying media status. - // - Status = gBS->CreateEvent ( - EVT_NOTIFY_SIGNAL | EVT_TIMER, - TPL_CALLBACK, - MediaChangeDetect, - Instance, - &Instance->Timer - ); - - if (EFI_ERROR (Status)) { - goto ON_ERROR; - } - - // - // Get the previous configure parameters. If an error happend here, - // just ignore it because the driver should be able to operate. - // - NicConfig = Ip4ConfigReadVariable (Instance); - if (NicConfig != NULL) { - if (!NicConfig->Permanent) { - // - // Delete the non-permanent configuration. - // - Ip4ConfigWriteVariable (Instance, NULL); - } - - FreePool (NicConfig); - } - - return EFI_SUCCESS; - -ON_ERROR: - if (Instance != NULL) { - FreePool (Instance); - } - - if (Mnp != NULL) { - gBS->CloseProtocol ( - MnpHandle, - &gEfiManagedNetworkProtocolGuid, - This->DriverBindingHandle, - ControllerHandle - ); - } - - NetLibDestroyServiceChild ( - ControllerHandle, - This->DriverBindingHandle, - &gEfiManagedNetworkServiceBindingProtocolGuid, - MnpHandle - ); - - return Status; -} - - -/** - Stop this driver on ControllerHandle. - - @param This Protocol instance pointer. - @param ControllerHandle Handle of device to stop driver on - @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of - children is zero stop the entire bus driver. - @param ChildHandleBuffer List of Child Handles to Stop. - - @retval EFI_SUCCES This driver is removed ControllerHandle - @retval other This driver was not removed from this device - -**/ -EFI_STATUS -EFIAPI -Ip4ConfigDriverBindingStop ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE ControllerHandle, - IN UINTN NumberOfChildren, - IN EFI_HANDLE *ChildHandleBuffer - ) -{ - IP4_CONFIG_INSTANCE *Instance; - EFI_IP4_CONFIG_PROTOCOL *Ip4Config; - EFI_HANDLE NicHandle; - EFI_STATUS Status; - - // - // IP4_CONFIG instance opens an MNP child. It may also create and open - // a DHCP child. If this is the DHCP handle, stop the DHCP process. If - // it is the MNP child, stop the whole driver. - // - // - NicHandle = NetLibGetNicHandle (ControllerHandle, &gEfiDhcp4ProtocolGuid); - - if (NicHandle != NULL) { - // - // Get our context back then clean the DHCP up. Notify the user if necessary. - // - Status = gBS->OpenProtocol ( - NicHandle, - &gEfiIp4ConfigProtocolGuid, - (VOID **) &Ip4Config, - This->DriverBindingHandle, - ControllerHandle, - EFI_OPEN_PROTOCOL_GET_PROTOCOL - ); - - if (EFI_ERROR (Status)) { - return Status; - } - - Instance = IP4_CONFIG_INSTANCE_FROM_IP4CONFIG (Ip4Config); - ASSERT (ControllerHandle == Instance->Dhcp4Handle); - - Ip4ConfigCleanDhcp4 (Instance); - - Instance->State = IP4_CONFIG_STATE_CONFIGURED; - Instance->Result = EFI_DEVICE_ERROR; - - if (Instance->DoneEvent != NULL) { - gBS->SignalEvent (Instance->DoneEvent); - } - - return EFI_SUCCESS; - } - - // - // This is a MNP handle, stop the whole driver - // - NicHandle = NetLibGetNicHandle (ControllerHandle, &gEfiManagedNetworkProtocolGuid); - - if (NicHandle == NULL) { - return EFI_SUCCESS; - } - - // - // Get our context back. - // - Status = gBS->OpenProtocol ( - NicHandle, - &gEfiIp4ConfigProtocolGuid, - (VOID **) &Ip4Config, - This->DriverBindingHandle, - ControllerHandle, - EFI_OPEN_PROTOCOL_GET_PROTOCOL - ); - - if (EFI_ERROR (Status)) { - return Status; - } - - Instance = IP4_CONFIG_INSTANCE_FROM_IP4CONFIG (Ip4Config); - - Ip4ConfigDeviceUnload (Instance); - - // - // Unload the protocols first to inform the top drivers - // - Status = gBS->UninstallMultipleProtocolInterfaces ( - NicHandle, - &gEfiIp4ConfigProtocolGuid, - &Instance->Ip4ConfigProtocol, - NULL - ); - - if (EFI_ERROR (Status)) { - return Status; - } - - // - // Release all the resources - // - if (Instance->MnpHandle != NULL) { - gBS->CloseProtocol ( - Instance->MnpHandle, - &gEfiManagedNetworkProtocolGuid, - This->DriverBindingHandle, - NicHandle - ); - - NetLibDestroyServiceChild ( - NicHandle, - Instance->Image, - &gEfiManagedNetworkServiceBindingProtocolGuid, - Instance->MnpHandle - ); - - Instance->Mnp = NULL; - Instance->MnpHandle = NULL; - } - - if (Instance->MacString != NULL) { - FreePool (Instance->MacString); - } - - if (Instance->Timer != NULL) { - gBS->SetTimer (Instance->Timer, TimerCancel, 0); - gBS->CloseEvent (Instance->Timer); - Instance->Timer = NULL; - } - - Ip4ConfigCleanConfig (Instance); - FreePool (Instance); - - return EFI_SUCCESS; -} diff --git a/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigDxe.inf b/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigDxe.inf deleted file mode 100644 index c1199828b6..0000000000 --- a/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigDxe.inf +++ /dev/null @@ -1,91 +0,0 @@ -## @file -# This module produces EFI IPv4 Configuration Protocol. -# -# This module produces EFI IPv4 Configuration Protocol upon EFI MNP Protocol, -# to performs platform- and policy-dependent configuration for the EFI IPv4 -# Protocol driver. It installs EFI HII Configuration Access Protocol to provide -# one way to configurate the IPv4 network setting. -# -# Copyright (c) 2006 - 2014, 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 -# which accompanies this distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -# -# -## - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = Ip4ConfigDxe - MODULE_UNI_FILE = Ip4ConfigDxe.uni - FILE_GUID = 26841BDE-920A-4e7a-9FBE-637F477143A6 - MODULE_TYPE = UEFI_DRIVER - VERSION_STRING = 1.0 - ENTRY_POINT = Ip4ConfigDriverEntryPoint - UNLOAD_IMAGE = NetLibDefaultUnload -# -# The following information is for reference only and not required by the build tools. -# -# VALID_ARCHITECTURES = IA32 X64 IPF EBC -# - -[Sources] - ComponentName.c - NicIp4Variable.c - Ip4ConfigDriver.c - Ip4Config.h - NicIp4Variable.h - Ip4Config.c - Ip4ConfigDxe.vfr - Ip4ConfigDxeStrings.uni - Ip4NvData.h - Ip4ConfigNv.h - Ip4ConfigNv.c - -[Packages] - MdePkg/MdePkg.dec - MdeModulePkg/MdeModulePkg.dec - - -[LibraryClasses] - UefiLib - UefiBootServicesTableLib - UefiDriverEntryPoint - UefiRuntimeServicesTableLib - DebugLib - NetLib - HiiLib - PrintLib - DpcLib - DevicePathLib - -[Protocols] - gEfiIp4ConfigProtocolGuid ## BY_START - gEfiManagedNetworkServiceBindingProtocolGuid ## TO_START - gEfiManagedNetworkProtocolGuid ## TO_START - gEfiDhcp4ServiceBindingProtocolGuid ## TO_START - gEfiDhcp4ProtocolGuid ## TO_START - gEfiHiiConfigAccessProtocolGuid ## BY_START - ## TO_START - ## BY_START - gEfiDevicePathProtocolGuid - -[Guids] - ## SOMETIMES_CONSUMES ## GUID # HiiIsConfigHdrMatch EFI_NIC_IP4_CONFIG_VARIABLE - ## SOMETIMES_PRODUCES ## GUID # HiiConstructConfigHdr EFI_NIC_IP4_CONFIG_VARIABLE - ## SOMETIMES_PRODUCES ## Variable - ## SOMETIMES_CONSUMES ## Variable - ## SOMETIMES_PRODUCES ## GUID # Device Path Node - gEfiNicIp4ConfigVariableGuid - ## SOMETIMES_CONSUMES ## GUID # HiiIsConfigHdrMatch EFI_NIC_IP4_CONFIG_VARIABLE - ## SOMETIMES_PRODUCES ## GUID # HiiConstructConfigHdr EFI_NIC_IP4_CONFIG_VARIABLE - ## SOMETIMES_PRODUCES ## GUID # HiiGetBrowserData EFI_NIC_IP4_CONFIG_VARIABLE - ## SOMETIMES_CONSUMES ## HII - gNicIp4ConfigNvDataGuid - -[UserExtensions.TianoCore."ExtraFiles"] - Ip4ConfigDxeExtra.uni diff --git a/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigDxe.uni b/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigDxe.uni deleted file mode 100644 index efd16bdebb..0000000000 Binary files a/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigDxe.uni and /dev/null differ diff --git a/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigDxe.vfr b/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigDxe.vfr deleted file mode 100644 index bd3e36ad06..0000000000 --- a/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigDxe.vfr +++ /dev/null @@ -1,89 +0,0 @@ -/** @file - Vfr file for IP4 config. - -Copyright (c) 2009 - 2010, 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 -which accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ -#include "Ip4NvData.h" - -#define EFI_NETWORK_DEVICE_CLASS 0x04 - -formset - guid = EFI_NIC_IP4_CONFIG_NVDATA_GUID, - title = STRING_TOKEN(STR_IP4_CONFIG_FORM_TITLE), - help = STRING_TOKEN(STR_IP4_CONFIG_FORM_HELP), - - varstore IP4_CONFIG_IFR_NVDATA, - name = EfiNicIp4ConfigVariable, - guid = EFI_NIC_IP4_CONFIG_NVDATA_GUID; - - 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; - - string varid = EfiNicIp4ConfigVariable.StationAddress, - prompt = STRING_TOKEN(STR_IP4_LOCAL_IP_ADDRESS), - help = STRING_TOKEN(STR_IP4_IP_ADDRESS_HELP), - flags = INTERACTIVE, - key = KEY_LOCAL_IP, - minsize = IP_MIN_SIZE, - maxsize = IP_MAX_SIZE, - endstring; - - string varid = EfiNicIp4ConfigVariable.SubnetMask, - prompt = STRING_TOKEN(STR_IP4_LOCAL_MASK), - help = STRING_TOKEN(STR_IP4_IP_ADDRESS_HELP), - flags = INTERACTIVE, - key = KEY_SUBNET_MASK, - minsize = IP_MIN_SIZE, - maxsize = IP_MAX_SIZE, - endstring; - - string varid = EfiNicIp4ConfigVariable.GatewayAddress, - prompt = STRING_TOKEN(STR_IP4_LOCAL_GATEWAY), - help = STRING_TOKEN(STR_IP4_IP_ADDRESS_HELP), - flags = INTERACTIVE, - key = KEY_GATE_WAY, - minsize = IP_MIN_SIZE, - maxsize = IP_MAX_SIZE, - endstring; - - endif; - - subtitle text = STRING_TOKEN(STR_NULL); - - text - help = STRING_TOKEN(STR_SAVE_CHANGES), - text = STRING_TOKEN(STR_SAVE_CHANGES), - flags = INTERACTIVE, - key = KEY_SAVE_CHANGES; - - endform; - -endformset; - diff --git a/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigDxeExtra.uni b/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigDxeExtra.uni deleted file mode 100644 index a0bf5a8387..0000000000 Binary files a/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigDxeExtra.uni and /dev/null differ diff --git a/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigDxeStrings.uni b/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigDxeStrings.uni deleted file mode 100644 index 5a578a421e..0000000000 Binary files a/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigDxeStrings.uni and /dev/null differ diff --git a/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigNv.c b/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigNv.c deleted file mode 100644 index 794bb79949..0000000000 --- a/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigNv.c +++ /dev/null @@ -1,909 +0,0 @@ -/** @file - Helper functions for configuring or getting the parameters relating to Ip4. - -Copyright (c) 2009 - 2015, 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 -which accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include "Ip4ConfigNv.h" -#include "NicIp4Variable.h" - -/** - Calculate the prefix length of the IPv4 subnet mask. - - @param[in] SubnetMask The IPv4 subnet mask. - - @return The prefix length of the subnet mask. - @retval 0 Other errors as indicated. -**/ -UINT8 -GetSubnetMaskPrefixLength ( - IN EFI_IPv4_ADDRESS *SubnetMask - ) -{ - UINT8 Len; - UINT32 ReverseMask; - - // - // The SubnetMask is in network byte order. - // - ReverseMask = SwapBytes32 (*(UINT32 *)&SubnetMask[0]); - - // - // Reverse it. - // - ReverseMask = ~ReverseMask; - - if ((ReverseMask & (ReverseMask + 1)) != 0) { - return 0; - } - - Len = 0; - - while (ReverseMask != 0) { - ReverseMask = ReverseMask >> 1; - Len++; - } - - return (UINT8) (32 - Len); -} - -/** - Convert the decimal dotted IPv4 address into the binary IPv4 address. - - @param[in] Str The UNICODE string. - @param[out] Ip The storage to return the IPv4 address. - - @retval EFI_SUCCESS The binary IP address is returned in Ip. - @retval EFI_INVALID_PARAMETER The IP string is malformatted. -**/ -EFI_STATUS -Ip4StrToIp ( - IN CHAR16 *Str, - OUT EFI_IPv4_ADDRESS *Ip - ) -{ - UINTN Index; - UINTN Number; - - Index = 0; - - while (*Str != L'\0') { - - if (Index > 3) { - return EFI_INVALID_PARAMETER; - } - - Number = 0; - while ((*Str >= L'0') && (*Str <= L'9')) { - Number = Number * 10 + (*Str - L'0'); - Str++; - } - - if (Number > 0xFF) { - return EFI_INVALID_PARAMETER; - } - - Ip->Addr[Index] = (UINT8) Number; - - if ((*Str != L'\0') && (*Str != L'.')) { - // - // The current character should be either the NULL terminator or - // the dot delimiter. - // - return EFI_INVALID_PARAMETER; - } - - if (*Str == L'.') { - // - // Skip the delimiter. - // - Str++; - } - - Index++; - } - - if (Index != 4) { - return EFI_INVALID_PARAMETER; - } - - return EFI_SUCCESS; -} - -/** - Convert the IPv4 address into a dotted string. - - @param[in] Ip The IPv4 address. - @param[out] Str The dotted IP string. -**/ -VOID -Ip4ConfigIpToStr ( - IN EFI_IPv4_ADDRESS *Ip, - OUT CHAR16 *Str - ) -{ - UnicodeSPrint (Str, 2 * IP4_STR_MAX_SIZE, L"%d.%d.%d.%d", Ip->Addr[0], Ip->Addr[1], Ip->Addr[2], Ip->Addr[3]); -} - - -/** - Convert the network configuration data into the IFR data. - - @param[in] Ip4ConfigInstance The IP4Config instance - @param[out] IfrFormNvData The IFR nv data. -**/ -VOID -Ip4ConfigConvertDeviceConfigDataToIfrNvData ( - IN IP4_CONFIG_INSTANCE *Ip4ConfigInstance, - OUT IP4_CONFIG_IFR_NVDATA *IfrFormNvData - ) -{ - NIC_IP4_CONFIG_INFO *NicConfig; - - NicConfig = EfiNicIp4ConfigGetInfo (Ip4ConfigInstance); - if (NicConfig != NULL) { - IfrFormNvData->Configure = 1; - Ip4ConfigInstance->Ip4ConfigCallbackInfo.Configured = TRUE; - if (NicConfig->Source == IP4_CONFIG_SOURCE_DHCP) { - IfrFormNvData->DhcpEnable = 1; - Ip4ConfigInstance->Ip4ConfigCallbackInfo.DhcpEnabled = TRUE; - } else { - IfrFormNvData->DhcpEnable = 0; - Ip4ConfigIpToStr (&NicConfig->Ip4Info.StationAddress, IfrFormNvData->StationAddress); - Ip4ConfigIpToStr (&NicConfig->Ip4Info.SubnetMask, IfrFormNvData->SubnetMask); - Ip4ConfigIpToStr (&NicConfig->Ip4Info.RouteTable[1].GatewayAddress, IfrFormNvData->GatewayAddress); - - Ip4ConfigInstance->Ip4ConfigCallbackInfo.DhcpEnabled = FALSE; - CopyMem (&Ip4ConfigInstance->Ip4ConfigCallbackInfo.LocalIp, &NicConfig->Ip4Info.StationAddress, sizeof (EFI_IPv4_ADDRESS)); - CopyMem (&Ip4ConfigInstance->Ip4ConfigCallbackInfo.SubnetMask, &NicConfig->Ip4Info.SubnetMask, sizeof (EFI_IPv4_ADDRESS)); - CopyMem (&Ip4ConfigInstance->Ip4ConfigCallbackInfo.Gateway, &NicConfig->Ip4Info.RouteTable[1].GatewayAddress, sizeof (EFI_IPv4_ADDRESS)); - } - - FreePool (NicConfig); - } else { - IfrFormNvData->Configure = 0; - Ip4ConfigInstance->Ip4ConfigCallbackInfo.Configured = FALSE; - } -} - -/** - 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 - set successfully. - @retval EFI_ALREADY_STARTED There is a pending auto configuration. - @retval EFI_NOT_FOUND No auto configure parameter is found. - -**/ -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; - EFI_INPUT_KEY Key; - NIC_IP4_CONFIG_INFO *NicInfo; - EFI_IP_ADDRESS Ip; - - ZeroMem (&Ip4ConfigInstance->Ip4ConfigCallbackInfo, sizeof (IP4_SETTING_INFO)); - - Ip4ConfigInstance->Ip4ConfigCallbackInfo.Configured = IfrFormNvData->Configure; - Ip4ConfigInstance->Ip4ConfigCallbackInfo.DhcpEnabled = IfrFormNvData->DhcpEnable; - Ip4StrToIp (IfrFormNvData->StationAddress, &Ip4ConfigInstance->Ip4ConfigCallbackInfo.LocalIp); - Ip4StrToIp (IfrFormNvData->SubnetMask, &Ip4ConfigInstance->Ip4ConfigCallbackInfo.SubnetMask); - Ip4StrToIp (IfrFormNvData->GatewayAddress, &Ip4ConfigInstance->Ip4ConfigCallbackInfo.Gateway); - - 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.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); - return EFI_INVALID_PARAMETER; - - } else if (!IP4_NET_EQUAL (HostIp.Addr[0], Gateway.Addr[0], SubnetMask.Addr[0])) { - CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Local IP and Gateway are not in the same subnet.", NULL); - return EFI_INVALID_PARAMETER; } - } - - NicInfo->Source = IP4_CONFIG_SOURCE_STATIC; - NicInfo->Ip4Info.RouteTableSize = 2; - - CopyMem (&NicInfo->Ip4Info.StationAddress, &HostIp.v4, sizeof (EFI_IPv4_ADDRESS)); - CopyMem (&NicInfo->Ip4Info.SubnetMask, &SubnetMask.v4, sizeof (EFI_IPv4_ADDRESS)); - - Ip.Addr[0] = HostIp.Addr[0] & SubnetMask.Addr[0]; - - 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->Permanent = TRUE; - CopyMem (&NicInfo->NicAddr, &Ip4ConfigInstance->NicAddr, sizeof (NIC_ADDR)); - - return EfiNicIp4ConfigSetInfo (Ip4ConfigInstance, NicInfo, TRUE); -} - -/** - This function allows the caller to request the current - configuration for one or more named elements. The resulting - string is in format. Any and all alternative - configuration strings shall also be appended to the end of the - current configuration string. If they are, they must appear - after the current configuration. They must contain the same - routing (GUID, NAME, PATH) as the current configuration string. - They must have an additional description indicating the type of - alternative configuration the string represents, - "ALTCFG=". That (when - converted from Hex UNICODE to binary) is a reference to a - string in the associated string pack. - - @param[in] This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL. - @param[in] Request A null-terminated Unicode string in - format. Note that this - includes the routing information as well as - the configurable name / value pairs. It is - invalid for this string to be in - format. - @param[out] Progress On return, points to a character in the - Request string. Points to the string's null - terminator if request was successful. Points - to the most recent "&" before the first - failing name / value pair (or the beginning - of the string if the failure is in the first - name / value pair) if the request was not - successful. - @param[out] Results A null-terminated Unicode string in - format which has all values - filled in for the names in the Request string. - String to be allocated by the called function. - - @retval EFI_SUCCESS The Results string is filled with the - values corresponding to all requested - names. - @retval EFI_OUT_OF_RESOURCES Not enough memory to store the - parts of the results that must be - stored awaiting possible future - protocols. - @retval EFI_NOT_FOUND Routing data doesn't match any - known driver. Progress set to the - first character in the routing header. - Note: There is no requirement that the - driver validate the routing data. It - must skip the in order to - process the names. - @retval EFI_INVALID_PARAMETER Illegal syntax. Progress set - to most recent & before the - error or the beginning of the - string. - @retval EFI_INVALID_PARAMETER Unknown name. Progress points - to the & before the name in - question.Currently not implemented. -**/ -EFI_STATUS -EFIAPI -Ip4DeviceExtractConfig ( - IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This, - IN CONST EFI_STRING Request, - OUT EFI_STRING *Progress, - OUT EFI_STRING *Results - ) -{ - EFI_STATUS Status; - NIC_IP4_CONFIG_INFO *IfrDeviceNvData; - NIC_IP4_CONFIG_INFO *NicConfig; - IP4_CONFIG_INSTANCE *Ip4ConfigInstance; - IP4_CONFIG_IFR_NVDATA *IfrFormNvData; - EFI_STRING ConfigRequestHdr; - EFI_STRING ConfigRequest; - EFI_STRING DeviceResult; - EFI_STRING FormResult; - CHAR16 *StrPointer; - BOOLEAN AllocatedRequest; - UINTN Size; - UINTN BufferSize; - - if (Progress == NULL || Results == NULL) { - return EFI_INVALID_PARAMETER; - } - - *Progress = Request; - Size = 0; - DeviceResult = NULL; - FormResult = NULL; - ConfigRequest = NULL; - Status = EFI_SUCCESS; - AllocatedRequest = FALSE; - Ip4ConfigInstance = IP4_CONFIG_INSTANCE_FROM_CONFIG_ACCESS (This); - - // - // Check Request data in . - // - if ((Request == NULL) || HiiIsConfigHdrMatch (Request, &gEfiNicIp4ConfigVariableGuid, EFI_NIC_IP4_CONFIG_VARIABLE)) { - IfrDeviceNvData = AllocateZeroPool (NIC_ITEM_CONFIG_SIZE); - if (IfrDeviceNvData == NULL) { - return EFI_OUT_OF_RESOURCES; - } - - NicConfig = EfiNicIp4ConfigGetInfo (Ip4ConfigInstance); - if (NicConfig == NULL) { - return EFI_NOT_FOUND; - } - CopyMem (IfrDeviceNvData, NicConfig, SIZEOF_NIC_IP4_CONFIG_INFO (NicConfig)); - FreePool (NicConfig); - - ConfigRequest = Request; - if ((Request == NULL) || (StrStr (Request, L"OFFSET") == NULL)) { - // - // Request has no request element, construct full request string. - // Allocate and fill a buffer large enough to hold the template - // followed by "&OFFSET=0&WIDTH=WWWWWWWWWWWWWWWW" followed by a Null-terminator - // - ConfigRequestHdr = HiiConstructConfigHdr (&gEfiNicIp4ConfigVariableGuid, EFI_NIC_IP4_CONFIG_VARIABLE, Ip4ConfigInstance->ChildHandle); - Size = (StrLen (ConfigRequestHdr) + 32 + 1) * sizeof (CHAR16); - ConfigRequest = AllocateZeroPool (Size); - ASSERT (ConfigRequest != NULL); - AllocatedRequest = TRUE; - BufferSize = NIC_ITEM_CONFIG_SIZE; - UnicodeSPrint (ConfigRequest, Size, L"%s&OFFSET=0&WIDTH=%016LX", ConfigRequestHdr, (UINT64)BufferSize); - FreePool (ConfigRequestHdr); - } - - // - // Convert buffer data to by helper function BlockToConfig() - // - Status = gHiiConfigRouting->BlockToConfig ( - gHiiConfigRouting, - ConfigRequest, - (UINT8 *) IfrDeviceNvData, - NIC_ITEM_CONFIG_SIZE, - &DeviceResult, - Progress - ); - - FreePool (IfrDeviceNvData); - // - // Free the allocated config request string. - // - if (AllocatedRequest) { - FreePool (ConfigRequest); - ConfigRequest = NULL; - } - - if (EFI_ERROR (Status)) { - goto Failure; - } - } - - if ((Request == NULL) || HiiIsConfigHdrMatch (Request, &gNicIp4ConfigNvDataGuid, EFI_NIC_IP4_CONFIG_VARIABLE)) { - - IfrFormNvData = AllocateZeroPool (sizeof (IP4_CONFIG_IFR_NVDATA)); - if (IfrFormNvData == NULL) { - return EFI_OUT_OF_RESOURCES; - } - - Ip4ConfigConvertDeviceConfigDataToIfrNvData (Ip4ConfigInstance, IfrFormNvData); - - ConfigRequest = Request; - if ((Request == NULL) || (StrStr (Request, L"OFFSET") == NULL)) { - // - // Request has no request element, construct full request string. - // Allocate and fill a buffer large enough to hold the template - // followed by "&OFFSET=0&WIDTH=WWWWWWWWWWWWWWWW" followed by a Null-terminator - // - ConfigRequestHdr = HiiConstructConfigHdr (&gNicIp4ConfigNvDataGuid, EFI_NIC_IP4_CONFIG_VARIABLE, Ip4ConfigInstance->ChildHandle); - Size = (StrLen (ConfigRequestHdr) + 32 + 1) * sizeof (CHAR16); - ConfigRequest = AllocateZeroPool (Size); - ASSERT (ConfigRequest != NULL); - AllocatedRequest = TRUE; - BufferSize = sizeof (IP4_CONFIG_IFR_NVDATA); - UnicodeSPrint (ConfigRequest, Size, L"%s&OFFSET=0&WIDTH=%016LX", ConfigRequestHdr, (UINT64)BufferSize); - FreePool (ConfigRequestHdr); - } - - // - // Convert buffer data to by helper function BlockToConfig() - // - Status = gHiiConfigRouting->BlockToConfig ( - gHiiConfigRouting, - ConfigRequest, - (UINT8 *) IfrFormNvData, - sizeof (IP4_CONFIG_IFR_NVDATA), - &FormResult, - Progress - ); - - FreePool (IfrFormNvData); - // - // Free the allocated config request string. - // - if (AllocatedRequest) { - FreePool (ConfigRequest); - ConfigRequest = NULL; - } - - if (EFI_ERROR (Status)) { - goto Failure; - } - } - - if (Request == NULL) { - Size = StrLen (DeviceResult); - Size = Size + 1; - Size = Size + StrLen (FormResult) + 1; - *Results = AllocateZeroPool (Size * sizeof (CHAR16)); - ASSERT (*Results != NULL); - StrPointer = *Results; - StrCpyS (StrPointer, Size, DeviceResult); - StrPointer = StrPointer + StrLen (StrPointer); - *StrPointer = L'&'; - StrCpyS (StrPointer + 1, StrLen (FormResult) + 1, FormResult); - FreePool (DeviceResult); - FreePool (FormResult); - } else if (HiiIsConfigHdrMatch (Request, &gEfiNicIp4ConfigVariableGuid, EFI_NIC_IP4_CONFIG_VARIABLE)) { - *Results = DeviceResult; - } else if (HiiIsConfigHdrMatch (Request, &gNicIp4ConfigNvDataGuid, EFI_NIC_IP4_CONFIG_VARIABLE)) { - *Results = FormResult; - } else { - return EFI_NOT_FOUND; - } - -Failure: - // - // Set Progress string to the original request string. - // - if (Request == NULL) { - *Progress = NULL; - } else if (StrStr (Request, L"OFFSET") == NULL) { - *Progress = Request + StrLen (Request); - } - - return Status; -} - -/** - This function applies changes in a driver's configuration. - Input is a Configuration, which has the routing data for this - driver followed by name / value configuration pairs. The driver - must apply those pairs to its configurable storage. If the - driver's configuration is stored in a linear block of data - and the driver's name / value pairs are in - format, it may use the ConfigToBlock helper function (above) to - simplify the job. Currently not implemented. - - @param[in] This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL. - @param[in] Configuration A null-terminated Unicode string in - format. - @param[out] Progress A pointer to a string filled in with the - offset of the most recent '&' before the - first failing name / value pair (or the - beginn ing of the string if the failure - is in the first name / value pair) or - the terminating NULL if all was - successful. - - @retval EFI_SUCCESS The results have been distributed or are - awaiting distribution. - @retval EFI_OUT_OF_MEMORY Not enough memory to store the - parts of the results that must be - stored awaiting possible future - protocols. - @retval EFI_INVALID_PARAMETERS Passing in a NULL for the - Results parameter would result - in this type of error. - @retval EFI_NOT_FOUND Target for the specified routing data - was not found. -**/ -EFI_STATUS -EFIAPI -Ip4DeviceRouteConfig ( - IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This, - IN CONST EFI_STRING Configuration, - OUT EFI_STRING *Progress - ) -{ - EFI_STATUS Status; - UINTN BufferSize; - NIC_IP4_CONFIG_INFO *IfrDeviceNvData; - IP4_CONFIG_IFR_NVDATA *IfrFormNvData; - NIC_IP4_CONFIG_INFO *NicInfo; - IP4_CONFIG_INSTANCE *Ip4ConfigInstance; - EFI_MAC_ADDRESS ZeroMac; - - if (Configuration == NULL || Progress == NULL) { - return EFI_INVALID_PARAMETER; - } - - // - // Reclaim Ip4Config variable - // - Ip4ConfigReclaimVariable (); - - *Progress = Configuration; - - Ip4ConfigInstance = IP4_CONFIG_INSTANCE_FROM_CONFIG_ACCESS (This); - - // - // Check Routing data in . - // - if (HiiIsConfigHdrMatch (Configuration, &gNicIp4ConfigNvDataGuid, EFI_NIC_IP4_CONFIG_VARIABLE)) { - // - // Convert buffer data to by helper function BlockToConfig() - // - IfrFormNvData = AllocateZeroPool (sizeof (IP4_CONFIG_IFR_NVDATA)); - if (IfrFormNvData == NULL) { - return EFI_OUT_OF_RESOURCES; - } - - BufferSize = NIC_ITEM_CONFIG_SIZE; - Status = gHiiConfigRouting->ConfigToBlock ( - gHiiConfigRouting, - Configuration, - (UINT8 *) IfrFormNvData, - &BufferSize, - Progress - ); - if (!EFI_ERROR (Status)) { - Status = Ip4ConfigConvertIfrNvDataToDeviceConfigData (IfrFormNvData, Ip4ConfigInstance); - } - - FreePool (IfrFormNvData); - - } else if (HiiIsConfigHdrMatch (Configuration, &gEfiNicIp4ConfigVariableGuid, EFI_NIC_IP4_CONFIG_VARIABLE)) { - - IfrDeviceNvData = AllocateZeroPool (NIC_ITEM_CONFIG_SIZE); - if (IfrDeviceNvData == NULL) { - return EFI_OUT_OF_RESOURCES; - } - - BufferSize = NIC_ITEM_CONFIG_SIZE; - Status = gHiiConfigRouting->ConfigToBlock ( - gHiiConfigRouting, - Configuration, - (UINT8 *) IfrDeviceNvData, - &BufferSize, - Progress - ); - if (!EFI_ERROR (Status)) { - ZeroMem (&ZeroMac, sizeof (EFI_MAC_ADDRESS)); - if (CompareMem (&IfrDeviceNvData->NicAddr.MacAddr, &ZeroMac, IfrDeviceNvData->NicAddr.Len) != 0) { - BufferSize = SIZEOF_NIC_IP4_CONFIG_INFO (IfrDeviceNvData); - NicInfo = AllocateCopyPool (BufferSize, IfrDeviceNvData); - if (NicInfo == NULL) { - return EFI_OUT_OF_RESOURCES; - } - Status = EfiNicIp4ConfigSetInfo (Ip4ConfigInstance, NicInfo, TRUE); - FreePool (NicInfo); - } else { - ZeroMem (&Ip4ConfigInstance->Ip4ConfigCallbackInfo, sizeof (IP4_SETTING_INFO)); - Status = EfiNicIp4ConfigSetInfo (Ip4ConfigInstance, NULL, TRUE); - } - } - - FreePool (IfrDeviceNvData); - - } else { - - return EFI_NOT_FOUND; - } - - return Status; - -} - -/** - 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 enerated 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_PARAMETERS Passing in wrong parameter. - @retval Others Other errors as indicated. -**/ -EFI_STATUS -EFIAPI -Ip4FormCallback ( - 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 - ) -{ - IP4_CONFIG_INSTANCE *Ip4ConfigInstance; - IP4_CONFIG_IFR_NVDATA *IfrFormNvData; - EFI_IP_ADDRESS HostIp; - EFI_IP_ADDRESS SubnetMask; - EFI_IP_ADDRESS Gateway; - EFI_STATUS Status; - EFI_INPUT_KEY Key; - - if (Action == EFI_BROWSER_ACTION_CHANGED) { - Ip4ConfigInstance = IP4_CONFIG_INSTANCE_FROM_CONFIG_ACCESS (This); - - IfrFormNvData = AllocateZeroPool (sizeof (IP4_CONFIG_IFR_NVDATA)); - if (IfrFormNvData == NULL) { - return EFI_OUT_OF_RESOURCES; - } - - // - // Retrive uncommitted data from Browser - // - if (!HiiGetBrowserData (&gNicIp4ConfigNvDataGuid, EFI_NIC_IP4_CONFIG_VARIABLE, sizeof (IP4_CONFIG_IFR_NVDATA), (UINT8 *) IfrFormNvData)) { - FreePool (IfrFormNvData); - return EFI_NOT_FOUND; - } - - Status = EFI_SUCCESS; - - switch (QuestionId) { - case KEY_LOCAL_IP: - Status = Ip4StrToIp (IfrFormNvData->StationAddress, &HostIp.v4); - if (EFI_ERROR (Status) || !NetIp4IsUnicast (NTOHL (HostIp.Addr[0]), 0)) { - CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Invalid IP address!", NULL); - Status = EFI_INVALID_PARAMETER; - } else { - CopyMem (&Ip4ConfigInstance->Ip4ConfigCallbackInfo.LocalIp, &HostIp.v4, sizeof (HostIp.v4)); - } - - break; - - case KEY_SUBNET_MASK: - Status = Ip4StrToIp (IfrFormNvData->SubnetMask, &SubnetMask.v4); - if (EFI_ERROR (Status) || ((SubnetMask.Addr[0] != 0) && (GetSubnetMaskPrefixLength (&SubnetMask.v4) == 0))) { - CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Invalid Subnet Mask!", NULL); - Status = EFI_INVALID_PARAMETER; - } else { - CopyMem (&Ip4ConfigInstance->Ip4ConfigCallbackInfo.SubnetMask, &SubnetMask.v4, sizeof (SubnetMask.v4)); - } - - break; - - case KEY_GATE_WAY: - Status = Ip4StrToIp (IfrFormNvData->GatewayAddress, &Gateway.v4); - if (EFI_ERROR (Status) || ((Gateway.Addr[0] != 0) && !NetIp4IsUnicast (NTOHL (Gateway.Addr[0]), 0))) { - CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Invalid Gateway!", NULL); - Status = EFI_INVALID_PARAMETER; - } else { - CopyMem (&Ip4ConfigInstance->Ip4ConfigCallbackInfo.Gateway, &Gateway.v4, sizeof (Gateway.v4)); - } - - break; - - case KEY_SAVE_CHANGES: - Status = Ip4ConfigConvertIfrNvDataToDeviceConfigData (IfrFormNvData, Ip4ConfigInstance); - *ActionRequest = EFI_BROWSER_ACTION_REQUEST_SUBMIT; - break; - - default: - break; - } - - FreePool (IfrFormNvData); - - return Status; - } - - // - // All other action return unsupported. - // - return EFI_UNSUPPORTED; -} - -/** - Install HII Config Access protocol for network device and allocate resource. - - @param[in] Instance The IP4 Config instance. - - @retval EFI_SUCCESS The HII Config Access protocol is installed. - @retval EFI_OUT_OF_RESOURCES Failed to allocate memory. - @retval Others Other errors as indicated. -**/ -EFI_STATUS -Ip4ConfigDeviceInit ( - IN IP4_CONFIG_INSTANCE *Instance - ) -{ - EFI_STATUS Status; - EFI_HII_CONFIG_ACCESS_PROTOCOL *ConfigAccess; - VENDOR_DEVICE_PATH VendorDeviceNode; - EFI_SERVICE_BINDING_PROTOCOL *MnpSb; - CHAR16 *MacString; - CHAR16 MenuString[128]; - CHAR16 PortString[128]; - CHAR16 *OldMenuString; - - ConfigAccess = &Instance->HiiConfigAccessProtocol; - ConfigAccess->ExtractConfig = Ip4DeviceExtractConfig; - ConfigAccess->RouteConfig = Ip4DeviceRouteConfig; - ConfigAccess->Callback = Ip4FormCallback; - - // - // Construct device path node for EFI HII Config Access protocol, - // which consists of controller physical device path and one hardware - // vendor guid node. - // - ZeroMem (&VendorDeviceNode, sizeof (VENDOR_DEVICE_PATH)); - VendorDeviceNode.Header.Type = HARDWARE_DEVICE_PATH; - VendorDeviceNode.Header.SubType = HW_VENDOR_DP; - - CopyGuid (&VendorDeviceNode.Guid, &gEfiNicIp4ConfigVariableGuid); - - SetDevicePathNodeLength (&VendorDeviceNode.Header, sizeof (VENDOR_DEVICE_PATH)); - Instance->HiiVendorDevicePath = AppendDevicePathNode ( - Instance->ParentDevicePath, - (EFI_DEVICE_PATH_PROTOCOL *) &VendorDeviceNode - ); - - Instance->ChildHandle = NULL; - // - // Install Device Path Protocol and Config Access protocol on new handle - // - Status = gBS->InstallMultipleProtocolInterfaces ( - &Instance->ChildHandle, - &gEfiDevicePathProtocolGuid, - Instance->HiiVendorDevicePath, - &gEfiHiiConfigAccessProtocolGuid, - ConfigAccess, - NULL - ); - if (!EFI_ERROR (Status)) { - // - // Open the Parent Handle for the child - // - Status = gBS->OpenProtocol ( - Instance->Controller, - &gEfiManagedNetworkServiceBindingProtocolGuid, - (VOID **) &MnpSb, - Instance->Image, - Instance->ChildHandle, - EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER - ); - } - - ASSERT_EFI_ERROR (Status); - - // - // Publish our HII data - // - Instance->RegisteredHandle = HiiAddPackages ( - &gNicIp4ConfigNvDataGuid, - Instance->ChildHandle, - Ip4ConfigDxeStrings, - Ip4ConfigDxeBin, - NULL - ); - if (Instance->RegisteredHandle == NULL) { - return EFI_OUT_OF_RESOURCES; - } - - // - // Append MAC string in the menu help string and tile help string - // - Status = NetLibGetMacString (Instance->Controller, Instance->Image, &MacString); - if (!EFI_ERROR (Status)) { - OldMenuString = HiiGetString (Instance->RegisteredHandle, STRING_TOKEN (STR_IP4_CONFIG_FORM_HELP), NULL); - UnicodeSPrint (MenuString, 128, L"%s (MAC:%s)", OldMenuString, MacString); - HiiSetString (Instance->RegisteredHandle, STRING_TOKEN (STR_IP4_CONFIG_FORM_HELP), MenuString, NULL); - - UnicodeSPrint (PortString, 128, L"MAC:%s", MacString); - HiiSetString (Instance->RegisteredHandle, STRING_TOKEN (STR_IP4_DEVICE_FORM_HELP), PortString, NULL); - FreePool (MacString); - } - - return Status; -} - -/** - Uninstall HII Config Access protocol for network device and free resource. - - @param[in] Instance The IP4 Config instance. - - @retval EFI_SUCCESS The HII Config Access protocol is uninstalled. - @retval Others Other errors as indicated. -**/ -EFI_STATUS -Ip4ConfigDeviceUnload ( - IN IP4_CONFIG_INSTANCE *Instance - ) -{ - // - // Remove HII package list - // - HiiRemovePackages (Instance->RegisteredHandle); - - // - // Close the child handle - // - gBS->CloseProtocol ( - Instance->Controller, - &gEfiManagedNetworkServiceBindingProtocolGuid, - Instance->Image, - Instance->ChildHandle - ); - - // - // Uninstall EFI_HII_CONFIG_ACCESS_PROTOCOL - // - gBS->UninstallMultipleProtocolInterfaces ( - Instance->ChildHandle, - &gEfiDevicePathProtocolGuid, - Instance->HiiVendorDevicePath, - &gEfiHiiConfigAccessProtocolGuid, - &Instance->HiiConfigAccessProtocol, - NULL - ); - - return EFI_SUCCESS; -} diff --git a/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigNv.h b/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigNv.h deleted file mode 100644 index 3b4168e974..0000000000 --- a/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigNv.h +++ /dev/null @@ -1,54 +0,0 @@ -/** @file - The header file of IP4ConfigNv.c - -Copyright (c) 2009 - 2010, 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 -which accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#ifndef _IP4_CONFIGNV_H_ -#define _IP4_CONFIGNV_H_ - -#include "Ip4Config.h" -#include "Ip4NvData.h" - -extern UINT8 Ip4ConfigDxeBin[]; -extern UINT8 Ip4ConfigDxeStrings[]; - -#define NIC_ITEM_CONFIG_SIZE (sizeof (NIC_IP4_CONFIG_INFO) + (sizeof (EFI_IP4_ROUTE_TABLE) * MAX_IP4_CONFIG_IN_VARIABLE)) - - -/** - Install HII Config Access protocol for network device and allocate resource. - - @param[in] Instance The IP4 Config instance. - - @retval EFI_SUCCESS The HII Config Access protocol is installed. - @retval EFI_OUT_OF_RESOURCES Failed to allocate memory. - @retval Others Other errors as indicated. -**/ -EFI_STATUS -Ip4ConfigDeviceInit ( - IN IP4_CONFIG_INSTANCE *Instance - ); - -/** - Uninstall HII Config Access protocol for network device and free resource. - - @param[in] Instance The IP4 Config instance. - - @retval EFI_SUCCESS The HII Config Access protocol is uninstalled. - @retval Others Other errors as indicated. -**/ -EFI_STATUS -Ip4ConfigDeviceUnload ( - IN IP4_CONFIG_INSTANCE *Instance - ); - -#endif diff --git a/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4NvData.h b/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4NvData.h deleted file mode 100644 index 2a0952706a..0000000000 --- a/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4NvData.h +++ /dev/null @@ -1,48 +0,0 @@ -/** @file - Routines used to operate the Ip4 configure variable. - -Copyright (c) 2009 - 2011, 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 -which accompanies this distribution. The full text of the license may be found at
-http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#ifndef _NIC_IP4_NV_DATA_H_ -#define _NIC_IP4_NV_DATA_H_ - -#include - -#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 -#define KEY_GATE_WAY 0x104 -#define KEY_SAVE_CHANGES 0x105 - -#define IP_MIN_SIZE 7 -#define IP_MAX_SIZE 15 -#define IP4_STR_MAX_SIZE 16 - -/// -/// NIC_IP4_CONFIG_INFO contains the IP4 configure -/// parameters for that NIC. NIC_IP4_CONFIG_INFO is -/// of variable length. -/// -typedef struct { - 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 - CHAR16 GatewayAddress[IP4_STR_MAX_SIZE]; ///< Gateway address -} IP4_CONFIG_IFR_NVDATA; - -#endif - diff --git a/MdeModulePkg/Universal/Network/Ip4ConfigDxe/NicIp4Variable.c b/MdeModulePkg/Universal/Network/Ip4ConfigDxe/NicIp4Variable.c deleted file mode 100644 index f0e03af900..0000000000 --- a/MdeModulePkg/Universal/Network/Ip4ConfigDxe/NicIp4Variable.c +++ /dev/null @@ -1,319 +0,0 @@ -/** @file - Routines used to operate the Ip4 configure variable. - -Copyright (c) 2006 - 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 -which accompanies this distribution. The full text of the license may be found at
-http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include "Ip4Config.h" -#include "NicIp4Variable.h" - -BOOLEAN mIp4ConfigVariableReclaimed = FALSE; - -/** - Check whether the configure parameter is valid. - - @param NicConfig The configure parameter to check - - @return TRUE if the parameter is valid for the interface, otherwise FALSE. - -**/ -BOOLEAN -Ip4ConfigIsValid ( - IN NIC_IP4_CONFIG_INFO *NicConfig - ) -{ - EFI_IP4_IPCONFIG_DATA *IpConfig; - IP4_ADDR Station; - IP4_ADDR Netmask; - IP4_ADDR Gateway; - UINT32 Index; - - IpConfig = &NicConfig->Ip4Info; - - if (NicConfig->Source == IP4_CONFIG_SOURCE_STATIC) { - // - // Validate that the addresses are unicast and mask - // is properly formated - // - Station = EFI_NTOHL (IpConfig->StationAddress); - Netmask = EFI_NTOHL (IpConfig->SubnetMask); - - if ((Netmask == 0) || !IP4_IS_VALID_NETMASK (Netmask) || - (Station == 0) || !NetIp4IsUnicast (Station, Netmask)) { - return FALSE; - } - - // - // Validate that the next hops are on the connected network - // or that is a direct route (Gateway == 0). - // - for (Index = 0; Index < IpConfig->RouteTableSize; Index++) { - Gateway = EFI_NTOHL (IpConfig->RouteTable[Index].GatewayAddress); - - if ((Gateway != 0) && (!IP4_NET_EQUAL (Station, Gateway, Netmask) || - !NetIp4IsUnicast (Gateway, Netmask))) { - return FALSE; - } - } - - return TRUE; - } - - // - // return false if it is an unkown configure source. Valid - // sources are static and dhcp. - // - return (BOOLEAN) (NicConfig->Source == IP4_CONFIG_SOURCE_DHCP); -} - - - -/** - Read the ip4 configure variable from the EFI variable. - - @param Instance The IP4 CONFIG instance. - - @return The IP4 configure read if it is there and is valid, otherwise NULL. - -**/ -NIC_IP4_CONFIG_INFO * -Ip4ConfigReadVariable ( - IN IP4_CONFIG_INSTANCE *Instance - ) -{ - NIC_IP4_CONFIG_INFO *NicConfig; - - GetVariable2 (Instance->MacString, &gEfiNicIp4ConfigVariableGuid, (VOID**)&NicConfig, NULL); - if (NicConfig != NULL) { - Ip4ConfigFixRouteTablePointer (&NicConfig->Ip4Info); - } - - return NicConfig; -} - -/** - Write the IP4 configure variable to the NVRAM. If Config - is NULL, remove the variable. - - @param Instance The IP4 CONFIG instance. - @param NicConfig The IP4 configure data to write. - - @retval EFI_SUCCESS The variable is written to the NVRam. - @retval Others Failed to write the variable. - -**/ -EFI_STATUS -Ip4ConfigWriteVariable ( - IN IP4_CONFIG_INSTANCE *Instance, - IN NIC_IP4_CONFIG_INFO *NicConfig OPTIONAL - ) -{ - EFI_STATUS Status; - - Status = gRT->SetVariable ( - Instance->MacString, - &gEfiNicIp4ConfigVariableGuid, - IP4_CONFIG_VARIABLE_ATTRIBUTES, - (NicConfig == NULL) ? 0 : SIZEOF_NIC_IP4_CONFIG_INFO (NicConfig), - NicConfig - ); - - return Status; -} - -/** - Check whether a NIC exist in the platform given its MAC address. - - @param NicAddr The MAC address for the NIC to be checked. - - @retval TRUE The NIC exist in the platform. - @retval FALSE The NIC doesn't exist in the platform. - -**/ -BOOLEAN -Ip4ConfigIsNicExist ( - IN NIC_ADDR *NicAddr - ) -{ - EFI_STATUS Status; - EFI_HANDLE *HandleBuffer; - UINTN NumberOfHandles; - UINTN Index; - BOOLEAN Found; - UINTN AddrSize; - EFI_MAC_ADDRESS MacAddr; - - // - // Locate Service Binding handles. - // - Status = gBS->LocateHandleBuffer ( - ByProtocol, - &gEfiManagedNetworkServiceBindingProtocolGuid, - NULL, - &NumberOfHandles, - &HandleBuffer - ); - if (EFI_ERROR (Status)) { - return FALSE; - } - - Found = FALSE; - for (Index = 0; Index < NumberOfHandles; Index++) { - // - // Get MAC address. - // - AddrSize = 0; - Status = NetLibGetMacAddress (HandleBuffer[Index], &MacAddr, &AddrSize); - if (EFI_ERROR (Status)) { - Found = FALSE; - goto Exit; - } - - if ((NicAddr->Len == AddrSize) && (CompareMem (NicAddr->MacAddr.Addr, MacAddr.Addr, AddrSize) == 0)) { - Found = TRUE; - goto Exit; - } - } - -Exit: - FreePool (HandleBuffer); - return Found; -} - -/** - Reclaim Ip4Config Variables for NIC which has been removed from the platform. - -**/ -VOID -Ip4ConfigReclaimVariable ( - VOID - ) -{ - EFI_STATUS Status; - UINTN VariableNameSize; - CHAR16 *VariableName; - CHAR16 *CurrentVariableName; - EFI_GUID VendorGuid; - UINTN VariableNameBufferSize; - NIC_IP4_CONFIG_INFO *NicConfig; - - // - // Check whether we need perform reclaim. - // - if (mIp4ConfigVariableReclaimed) { - return; - } - mIp4ConfigVariableReclaimed = TRUE; - - // - // Get all Ip4Config Variable. - // - VariableNameSize = sizeof (CHAR16); - VariableName = AllocateZeroPool (VariableNameSize); - VariableNameBufferSize = VariableNameSize; - - while (TRUE) { - Status = gRT->GetNextVariableName ( - &VariableNameSize, - VariableName, - &VendorGuid - ); - -Check: - if (Status == EFI_BUFFER_TOO_SMALL) { - VariableName = ReallocatePool (VariableNameBufferSize, VariableNameSize, VariableName); - VariableNameBufferSize = VariableNameSize; - // - // Try again using the new buffer. - // - Status = gRT->GetNextVariableName ( - &VariableNameSize, - VariableName, - &VendorGuid - ); - } - - if (EFI_ERROR (Status)) { - // - // No more variable available, finish search. - // - break; - } - - // - // Check variable GUID. - // - if (!CompareGuid (&VendorGuid, &gEfiNicIp4ConfigVariableGuid)) { - continue; - } - - GetVariable2 (VariableName, &gEfiNicIp4ConfigVariableGuid, (VOID**)&NicConfig, NULL); - if (NicConfig == NULL) { - break; - } - - if (!Ip4ConfigIsNicExist (&NicConfig->NicAddr)) { - // - // No NIC found for this Ip4Config variable, remove it. - // Since we are in loop of GetNextVariableName(), we need move on to next - // Variable first and then delete current Variable. - // - CurrentVariableName = AllocateCopyPool (VariableNameSize, VariableName); - Status = gRT->GetNextVariableName ( - &VariableNameSize, - VariableName, - &VendorGuid - ); - - gRT->SetVariable ( - CurrentVariableName, - &gEfiNicIp4ConfigVariableGuid, - IP4_CONFIG_VARIABLE_ATTRIBUTES, - 0, - NULL - ); - FreePool (CurrentVariableName); - - // - // We already get next variable, go to check it. - // - goto Check; - } - } - - FreePool (VariableName); -} - -/** - Fix the RouteTable pointer in an EFI_IP4_IPCONFIG_DATA structure. - - The pointer is set to be immediately follow the ConfigData if there're entries - in the RouteTable. Otherwise it is set to NULL. - - @param ConfigData The IP4 IP configure data. - -**/ -VOID -Ip4ConfigFixRouteTablePointer ( - IN OUT EFI_IP4_IPCONFIG_DATA *ConfigData - ) -{ - // - // The memory used for route table entries must immediately follow - // the ConfigData and be not packed. - // - if (ConfigData->RouteTableSize > 0) { - ConfigData->RouteTable = (EFI_IP4_ROUTE_TABLE *) (ConfigData + 1); - } else { - ConfigData->RouteTable = NULL; - } -} - diff --git a/MdeModulePkg/Universal/Network/Ip4ConfigDxe/NicIp4Variable.h b/MdeModulePkg/Universal/Network/Ip4ConfigDxe/NicIp4Variable.h deleted file mode 100644 index 2f8defe789..0000000000 --- a/MdeModulePkg/Universal/Network/Ip4ConfigDxe/NicIp4Variable.h +++ /dev/null @@ -1,104 +0,0 @@ -/** @file - Routines used to operate the Ip4 configure variable. - -Copyright (c) 2006 - 2010, 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 -which accompanies this distribution. The full text of the license may be found at
-http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#ifndef _NIC_IP4_VARIABLE_H_ -#define _NIC_IP4_VARIABLE_H_ - -// -// Return the size of NIC_IP4_CONFIG_INFO and EFI_IP4_IPCONFIG_DATA. -// They are of variable size -// -#define SIZEOF_IP4_CONFIG_INFO(Ip4Config) \ - (sizeof (EFI_IP4_IPCONFIG_DATA) + \ - sizeof (EFI_IP4_ROUTE_TABLE) * (Ip4Config)->RouteTableSize) - -#define SIZEOF_NIC_IP4_CONFIG_INFO(NicConfig) \ - (sizeof (NIC_IP4_CONFIG_INFO) + \ - sizeof (EFI_IP4_ROUTE_TABLE) * (NicConfig)->Ip4Info.RouteTableSize) - -// -// Compare whether two NIC address are equal includes their type and length. -// -#define NIC_ADDR_EQUAL(Nic1, Nic2) \ - (((Nic1)->Type == (Nic2)->Type) && ((Nic1)->Len == (Nic2)->Len) && \ - NET_MAC_EQUAL (&(Nic1)->MacAddr, &(Nic2)->MacAddr, (Nic1)->Len)) - -/** - Check whether the configure parameter is valid. - - @param NicConfig The configure parameter to check - - @return TRUE if the parameter is valid for the interface, otherwise FALSE. - -**/ -BOOLEAN -Ip4ConfigIsValid ( - IN NIC_IP4_CONFIG_INFO *NicConfig - ); - -/** - Read the ip4 configure variable from the EFI variable. - - @param Instance The IP4 CONFIG instance. - - @return The IP4 configure read if it is there and is valid, otherwise NULL. - -**/ -NIC_IP4_CONFIG_INFO * -Ip4ConfigReadVariable ( - IN IP4_CONFIG_INSTANCE *Instance - ); - -/** - Write the IP4 configure variable to the NVRAM. If Config - is NULL, remove the variable. - - @param Instance The IP4 CONFIG instance. - @param NicConfig The IP4 configure data to write. - - @retval EFI_SUCCESS The variable is written to the NVRam. - @retval Others Failed to write the variable. - -**/ -EFI_STATUS -Ip4ConfigWriteVariable ( - IN IP4_CONFIG_INSTANCE *Instance, - IN NIC_IP4_CONFIG_INFO *NicConfig OPTIONAL - ); - -/** - Reclaim Ip4Config Variables for NIC which has been removed from the platform. - -**/ -VOID -Ip4ConfigReclaimVariable ( - VOID - ); - -/** - Fix the RouteTable pointer in an EFI_IP4_IPCONFIG_DATA structure. - - The pointer is set to be immediately follow the ConfigData if there're entries - in the RouteTable. Otherwise it is set to NULL. - - @param ConfigData The IP4 IP configure data. - -**/ -VOID -Ip4ConfigFixRouteTablePointer ( - IN OUT EFI_IP4_IPCONFIG_DATA *ConfigData - ); - -#endif -