/** @file\r
This code implements the IP4Config and NicIp4Config protocols.\r
\r
-Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
which accompanies this distribution. The full text of the license may be found at<BR>\r
**/\r
\r
#include "Ip4Config.h"\r
-\r
-IP4_CONFIG_INSTANCE *mIp4ConfigNicList[MAX_IP4_CONFIG_IN_VARIABLE];\r
+#include "NicIp4Variable.h"\r
\r
\r
/**\r
Get the NIC's configure information from the IP4 configure variable.\r
It will remove the invalid variable.\r
\r
- @param NicAddr The NIC to check\r
+ @param Instance The IP4 CONFIG instance.\r
\r
@return NULL if no configure for the NIC in the variable, or it is invalid.\r
Otherwise the pointer to the NIC's IP configure parameter will be returned.\r
\r
**/\r
NIC_IP4_CONFIG_INFO *\r
-Ip4ConfigGetNicInfo (\r
- IN NIC_ADDR *NicAddr\r
+EfiNicIp4ConfigGetInfo (\r
+ IN IP4_CONFIG_INSTANCE *Instance\r
)\r
{\r
- IP4_CONFIG_VARIABLE *Variable;\r
- IP4_CONFIG_VARIABLE *NewVariable;\r
- NIC_IP4_CONFIG_INFO *Config;\r
+ NIC_IP4_CONFIG_INFO *NicConfig;\r
\r
//\r
- // Read the configuration parameter for this NicAddr from\r
+ // Read the configuration parameter for this NIC from\r
// the EFI variable\r
//\r
- Variable = Ip4ConfigReadVariable ();\r
-\r
- if (Variable == NULL) {\r
- return NULL;\r
- }\r
-\r
- Config = Ip4ConfigFindNicVariable (Variable, NicAddr);\r
-\r
- if (Config == NULL) {\r
- FreePool (Variable);\r
+ NicConfig = Ip4ConfigReadVariable (Instance);\r
+ if (NicConfig == NULL) {\r
return NULL;\r
}\r
\r
// Validate the configuration, if the configuration is invalid,\r
// remove it from the variable.\r
//\r
- if (!Ip4ConfigIsValid (Config)) {\r
- NewVariable = Ip4ConfigModifyVariable (Variable, &Config->NicAddr, NULL);\r
- Ip4ConfigWriteVariable (NewVariable);\r
-\r
- if (NewVariable != NULL) {\r
- FreePool (NewVariable);\r
- };\r
-\r
- FreePool (Config);\r
- Config = NULL;\r
- }\r
-\r
- FreePool (Variable);\r
- return Config;\r
-}\r
-\r
-\r
-/**\r
- Get the configure parameter for this NIC.\r
-\r
- @param Instance The IP4 CONFIG Instance.\r
- @param ConfigLen The length of the NicConfig buffer.\r
- @param NicConfig The buffer to receive the NIC's configure\r
- parameter.\r
-\r
- @retval EFI_SUCCESS The configure parameter for this NIC was\r
- obtained successfully .\r
- @retval EFI_INVALID_PARAMETER This or ConfigLen is NULL.\r
- @retval EFI_NOT_FOUND There is no configure parameter for the NIC in\r
- NVRam.\r
- @retval EFI_BUFFER_TOO_SMALL The ConfigLen is too small or the NicConfig is\r
- NULL.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EfiNicIp4ConfigGetInfo (\r
- IN IP4_CONFIG_INSTANCE *Instance,\r
- IN OUT UINTN *ConfigLen,\r
- OUT NIC_IP4_CONFIG_INFO *NicConfig\r
- )\r
-{\r
- NIC_IP4_CONFIG_INFO *Config;\r
- EFI_STATUS Status;\r
- UINTN Len;\r
-\r
- if ((Instance == NULL) || (ConfigLen == NULL)) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
-\r
- //\r
- // Read the Nic's configuration parameter from variable\r
- //\r
- Config = Ip4ConfigGetNicInfo (&Instance->NicAddr);\r
+ if (!Ip4ConfigIsValid (NicConfig)) {\r
+ Ip4ConfigWriteVariable (Instance, NULL);\r
\r
- if (Config == NULL) {\r
- return EFI_NOT_FOUND;\r
- }\r
-\r
- //\r
- // Copy the data to user's buffer\r
- //\r
- Len = SIZEOF_NIC_IP4_CONFIG_INFO (Config);\r
-\r
- if ((*ConfigLen < Len) || (NicConfig == NULL)) {\r
- Status = EFI_BUFFER_TOO_SMALL;\r
- } else {\r
- Status = EFI_SUCCESS;\r
- CopyMem (NicConfig, Config, Len);\r
- Ip4ConfigFixRouteTablePointer (&NicConfig->Ip4Info);\r
+ FreePool (NicConfig);\r
+ NicConfig = NULL;\r
}\r
\r
- *ConfigLen = Len;\r
-\r
- FreePool (Config);\r
- return Status;\r
+ return NicConfig;\r
}\r
\r
-\r
/**\r
Set the IP configure parameters for this NIC.\r
\r
IN BOOLEAN Reconfig\r
)\r
{\r
- IP4_CONFIG_VARIABLE *Variable;\r
- IP4_CONFIG_VARIABLE *NewVariable;\r
- EFI_STATUS Status;\r
+ EFI_STATUS Status;\r
\r
//\r
// Validate the parameters\r
//\r
// Update the parameter in the configure variable\r
//\r
- Variable = Ip4ConfigReadVariable ();\r
-\r
- if ((Variable == NULL) && (NicConfig == NULL)) {\r
- return EFI_NOT_FOUND;\r
- }\r
-\r
- NewVariable = Ip4ConfigModifyVariable (Variable, &Instance->NicAddr, NicConfig);\r
- Status = Ip4ConfigWriteVariable (NewVariable);\r
-\r
- if (NewVariable != NULL) {\r
- FreePool (NewVariable);\r
- }\r
-\r
- //\r
- // Variable is NULL when saving the first configure parameter\r
- //\r
- if (Variable != NULL) {\r
- FreePool (Variable);\r
- }\r
-\r
+ Status = Ip4ConfigWriteVariable (Instance, NicConfig);\r
if (EFI_ERROR (Status)) {\r
return Status;\r
}\r
Instance->DoneEvent = DoneEvent;\r
Instance->ReconfigEvent = ReconfigEvent;\r
\r
- Instance->NicConfig = Ip4ConfigGetNicInfo (&Instance->NicAddr);\r
+ Instance->NicConfig = EfiNicIp4ConfigGetInfo (Instance);\r
\r
if (Instance->NicConfig == NULL) {\r
Source = IP4_CONFIG_SOURCE_DHCP;\r