]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Network/IScsiDxe/IScsiDhcp.c
Update HiiConfigAccess.ExtractConfig interface to support NULL request string and...
[mirror_edk2.git] / MdeModulePkg / Universal / Network / IScsiDxe / IScsiDhcp.c
index 85b5dbf7450bc2490808545aa2adecaebda0ad03..c770e27631dc93f6a49e98a0adc7a76d07fdd86c 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
-  ISci DHCP related configuration routines.\r
+  iSCSI DHCP related configuration routines.\r
 \r
-Copyright (c) 2004 - 2007, Intel Corporation.<BR>\r
+Copyright (c) 2004 - 2010, Intel Corporation.<BR>\r
 All rights reserved. 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\r
@@ -17,9 +17,9 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 /**\r
   Extract the Root Path option and get the required target information.\r
 \r
-  @param[in]   RootPath         The RootPath.\r
-  @param[in]   Length           Length of the RootPath option payload.\r
-  @param[in]   ConfigNvData     The iSCSI session configuration data read from nonvolatile device.\r
+  @param[in]        RootPath         The RootPath.\r
+  @param[in]        Length           Length of the RootPath option payload.\r
+  @param[in, out]   ConfigNvData     The iSCSI session configuration data read from nonvolatile device.\r
 \r
   @retval EFI_SUCCESS           All required information is extracted from the RootPath option.\r
   @retval EFI_NOT_FOUND         The RootPath is not an iSCSI RootPath.\r
@@ -28,9 +28,9 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 **/\r
 EFI_STATUS\r
 IScsiDhcpExtractRootPath (\r
-  IN CHAR8                        *RootPath,\r
-  IN UINT8                        Length,\r
-  IN ISCSI_SESSION_CONFIG_NVDATA  *ConfigNvData\r
+  IN      CHAR8                        *RootPath,\r
+  IN      UINT8                        Length,\r
+  IN OUT  ISCSI_SESSION_CONFIG_NVDATA  *ConfigNvData\r
   )\r
 {\r
   EFI_STATUS            Status;\r
@@ -38,7 +38,7 @@ IScsiDhcpExtractRootPath (
   CHAR8                 *TmpStr;\r
   ISCSI_ROOT_PATH_FIELD Fields[RP_FIELD_IDX_MAX];\r
   ISCSI_ROOT_PATH_FIELD *Field;\r
-  RP_FIELD_IDX          FieldIndex;\r
+  UINT32                FieldIndex;\r
   UINT8                 Index;\r
 \r
   //\r
@@ -162,7 +162,7 @@ IScsiDhcpExtractRootPath (
 \r
 ON_EXIT:\r
 \r
-  gBS->FreePool (TmpStr);\r
+  FreePool (TmpStr);\r
 \r
   return Status;\r
 }\r
@@ -184,6 +184,7 @@ ON_EXIT:
   @retval Others           Other errors as indicated.\r
 **/\r
 EFI_STATUS\r
+EFIAPI\r
 IScsiDhcpSelectOffer (\r
   IN  EFI_DHCP4_PROTOCOL  * This,\r
   IN  VOID                *Context,\r
@@ -216,7 +217,7 @@ IScsiDhcpSelectOffer (
 \r
   Status = This->Parse (This, Packet, &OptionCount, OptionList);\r
   if (EFI_ERROR (Status)) {\r
-    gBS->FreePool (OptionList);\r
+    FreePool (OptionList);\r
     return EFI_NOT_READY;\r
   }\r
 \r
@@ -238,7 +239,7 @@ IScsiDhcpSelectOffer (
     Status = EFI_NOT_READY;\r
   }\r
 \r
-  gBS->FreePool (OptionList);\r
+  FreePool (OptionList);\r
 \r
   return Status;\r
 }\r
@@ -246,8 +247,8 @@ IScsiDhcpSelectOffer (
 /**\r
   Parse the DHCP ACK to get the address configuration and DNS information.\r
 \r
-  @param[in]   Dhcp4            The DHCP4 protocol.\r
-  @param[in]   ConfigData       The session configuration data.\r
+  @param[in]       Dhcp4        The DHCP4 protocol.\r
+  @param[in, out]  ConfigData   The session configuration data.\r
 \r
   @retval EFI_SUCCESS           The DNS information is got from the DHCP ACK.\r
   @retval EFI_NO_MAPPING        DHCP failed to acquire address and other information.\r
@@ -256,8 +257,8 @@ IScsiDhcpSelectOffer (
 **/\r
 EFI_STATUS\r
 IScsiParseDhcpAck (\r
-  IN EFI_DHCP4_PROTOCOL         *Dhcp4,\r
-  IN ISCSI_SESSION_CONFIG_DATA  *ConfigData\r
+  IN      EFI_DHCP4_PROTOCOL         *Dhcp4,\r
+  IN OUT  ISCSI_SESSION_CONFIG_DATA  *ConfigData\r
   )\r
 {\r
   EFI_STATUS              Status;\r
@@ -294,7 +295,7 @@ IScsiParseDhcpAck (
 \r
   Status = Dhcp4->Parse (Dhcp4, Dhcp4ModeData.ReplyPacket, &OptionCount, OptionList);\r
   if (EFI_ERROR (Status)) {\r
-    gBS->FreePool (OptionList);\r
+    FreePool (OptionList);\r
     return EFI_DEVICE_ERROR;\r
   }\r
 \r
@@ -329,7 +330,7 @@ IScsiParseDhcpAck (
     }\r
   }\r
 \r
-  gBS->FreePool (OptionList);\r
+  FreePool (OptionList);\r
 \r
   return Status;\r
 }\r
@@ -337,19 +338,21 @@ IScsiParseDhcpAck (
 /**\r
   Parse the DHCP ACK to get the address configuration and DNS information.\r
   \r
-  @param[in]   Image            The handle of the driver image.\r
-  @param[in]   Controller       The handle of the controller;\r
-  @param[in  ConfigData       The session configuration data.\r
+  @param[in]       Image            The handle of the driver image.\r
+  @param[in]       Controller       The handle of the controller;\r
+  @param[in, out]  ConfigData       The session configuration data.\r
 \r
   @retval EFI_SUCCESS           The DNS information is got from the DHCP ACK.\r
   @retval EFI_OUT_OF_RESOURCES  Failed to allocate memory.\r
+  @retval EFI_NO_MEDIA          There was a media error.\r
   @retval Others                Other errors as indicated.\r
+\r
 **/\r
 EFI_STATUS\r
 IScsiDoDhcp (\r
-  IN EFI_HANDLE                 Image,\r
-  IN EFI_HANDLE                 Controller,\r
-  IN ISCSI_SESSION_CONFIG_DATA  *ConfigData\r
+  IN     EFI_HANDLE                 Image,\r
+  IN     EFI_HANDLE                 Controller,\r
+  IN OUT ISCSI_SESSION_CONFIG_DATA  *ConfigData\r
   )\r
 {\r
   EFI_HANDLE              Dhcp4Handle;\r
@@ -357,11 +360,21 @@ IScsiDoDhcp (
   EFI_STATUS              Status;\r
   EFI_DHCP4_PACKET_OPTION *ParaList;\r
   EFI_DHCP4_CONFIG_DATA   Dhcp4ConfigData;\r
+  BOOLEAN                 MediaPresent;\r
 \r
   Dhcp4Handle = NULL;\r
   Dhcp4       = NULL;\r
   ParaList    = NULL;\r
 \r
+  //\r
+  // Check media status before do DHCP\r
+  //\r
+  MediaPresent = TRUE;\r
+  NetLibDetectMedia (Controller, &MediaPresent);\r
+  if (!MediaPresent) {\r
+    return EFI_NO_MEDIA;\r
+  }\r
+\r
   //\r
   // Create a DHCP4 child instance and get the protocol.\r
   //\r
@@ -431,7 +444,7 @@ IScsiDoDhcp (
 ON_EXIT:\r
 \r
   if (ParaList != NULL) {\r
-    gBS->FreePool (ParaList);\r
+    FreePool (ParaList);\r
   }\r
 \r
   if (Dhcp4 != NULL) {\r