diff options
Diffstat (limited to 'MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4Config.c')
-rw-r--r-- | MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4Config.c | 285 |
1 files changed, 136 insertions, 149 deletions
diff --git a/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4Config.c b/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4Config.c index 4c72a54045..d7672cbedf 100644 --- a/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4Config.c +++ b/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4Config.c @@ -17,24 +17,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. IP4_CONFIG_INSTANCE *mIp4ConfigNicList[MAX_IP4_CONFIG_IN_VARIABLE];
/**
- 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
- );
-
-
-/**
Return the name and MAC address for the NIC. The Name, if not NULL,
has at least IP4_NIC_NAME_LENGTH bytes.
@@ -49,9 +31,9 @@ Ip4ConfigOnDhcp4Complete ( EFI_STATUS
EFIAPI
EfiNicIp4ConfigGetName (
- IN EFI_NIC_IP4_CONFIG_PROTOCOL *This,
- IN UINT16 *Name, OPTIONAL
- IN NIC_ADDR *NicAddr OPTIONAL
+ IN EFI_NIC_IP4_CONFIG_PROTOCOL *This,
+ OUT UINT16 *Name OPTIONAL,
+ OUT NIC_ADDR *NicAddr OPTIONAL
)
{
IP4_CONFIG_INSTANCE *Instance;
@@ -75,13 +57,13 @@ EfiNicIp4ConfigGetName ( /**
- Get the NIC's configure information from the IP4 configure variable.
+ Get the NIC's configure information from the IP4 configure variable.
It will remove the invalid variable.
@param NicAddr The NIC to check
@return NULL if no configure for the NIC in the variable, or it is invalid.
- @return Otherwise the NIC's IP configure parameter.
+ Otherwise the pointer to the NIC's IP configure parameter will be returned.
**/
NIC_IP4_CONFIG_INFO *
@@ -134,14 +116,18 @@ Ip4ConfigGetNicInfo ( /**
Get the configure parameter for this NIC.
- @param This The NIC IP4 CONFIG protocol
+ @param This The NIC IP4 CONFIG protocol.
@param ConfigLen The length of the NicConfig buffer.
@param NicConfig The buffer to receive the NIC's configure
parameter.
- @retval EFI_INVALID_PARAMETER This or ConfigLen is NULL
+ @retval EFI_SUCCESS The configure parameter for this NIC was
+ obtained successfully .
+ @retval EFI_INVALID_PARAMETER This or ConfigLen is NULL.
@retval EFI_NOT_FOUND There is no configure parameter for the NIC in
NVRam.
+ @retval EFI_BUFFER_TOO_SMALL The ConfigLen is too small or the NicConfig is
+ NULL.
**/
EFI_STATUS
@@ -192,10 +178,11 @@ EfiNicIp4ConfigGetInfo ( /**
- 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
+ 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.
@@ -204,7 +191,9 @@ EfiNicIp4ConfigGetInfo ( @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.
@@ -280,6 +269,120 @@ EfiNicIp4ConfigSetInfo ( 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 Perment;
+ 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.
+ //
+ Perment = FALSE;
+
+ if (Instance->NicConfig != NULL) {
+ ASSERT (Instance->NicConfig->Source == IP4_CONFIG_SOURCE_DHCP);
+ Perment = Instance->NicConfig->Perment;
+ gBS->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->Perment = Perment;
+
+ 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->NicIp4Protocol, Instance->NicConfig, FALSE);
+ }
+
+ON_EXIT:
+ gBS->SignalEvent (Instance->DoneEvent);
+ Ip4ConfigCleanDhcp4 (Instance);
+
+ NetLibDispatchDpc ();
+
+ return ;
+}
/**
Starts running the configuration policy for the EFI IPv4 Protocol driver.
@@ -557,8 +660,9 @@ ON_EXIT: @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.
+ @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.
@@ -623,123 +727,6 @@ ON_EXIT: 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 Perment;
- 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.
- //
- Perment = FALSE;
-
- if (Instance->NicConfig != NULL) {
- ASSERT (Instance->NicConfig->Source == IP4_CONFIG_SOURCE_DHCP);
- Perment = Instance->NicConfig->Perment;
- gBS->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->Perment = Perment;
-
- 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->NicIp4Protocol, Instance->NicConfig, FALSE);
- }
-
-ON_EXIT:
- gBS->SignalEvent (Instance->DoneEvent);
- Ip4ConfigCleanDhcp4 (Instance);
-
- NetLibDispatchDpc ();
-
- return ;
-}
-
-
/**
Release all the DHCP related resources.
|