]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Network/IScsiDxe/IScsiDhcp.c
NetworkPkg: Remove some clarification from TcpDxe.inf
[mirror_edk2.git] / MdeModulePkg / Universal / Network / IScsiDxe / IScsiDhcp.c
index c770e27631dc93f6a49e98a0adc7a76d07fdd86c..6a876c8b69ddc718fd1f934f6fffea166de67504 100644 (file)
@@ -1,8 +1,8 @@
 /** @file\r
   iSCSI DHCP related configuration routines.\r
 \r
-Copyright (c) 2004 - 2010, Intel Corporation.<BR>\r
-All rights reserved. This program and the accompanying materials\r
+Copyright (c) 2004 - 2018, 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\r
 http://opensource.org/licenses/bsd-license.php\r
@@ -95,7 +95,7 @@ IScsiDhcpExtractRootPath (
     Status = EFI_INVALID_PARAMETER;\r
     goto ON_EXIT;\r
   }\r
-  \r
+\r
     if ((Fields[RP_FIELD_IDX_SERVERNAME].Str == NULL) ||\r
       (Fields[RP_FIELD_IDX_TARGETNAME].Str == NULL) ||\r
       (Fields[RP_FIELD_IDX_PROTOCOL].Len > 1)\r
@@ -158,7 +158,7 @@ IScsiDhcpExtractRootPath (
     goto ON_EXIT;\r
   }\r
 \r
-  AsciiStrCpy (ConfigNvData->TargetName, Field->Str);\r
+  AsciiStrCpyS (ConfigNvData->TargetName, ISCSI_NAME_MAX_SIZE, Field->Str);\r
 \r
 ON_EXIT:\r
 \r
@@ -170,14 +170,14 @@ ON_EXIT:
 /**\r
   The callback function registerd to the DHCP4 instance which is used to select\r
   the qualified DHCP OFFER.\r
-  \r
+\r
   @param[in]  This         The DHCP4 protocol.\r
   @param[in]  Context      The context set when configuring the DHCP4 protocol.\r
   @param[in]  CurrentState The current state of the DHCP4 protocol.\r
   @param[in]  Dhcp4Event   The event occurs in the current state.\r
-  @param[in]  Packet       The DHCP packet that is to be sent or already received. \r
+  @param[in]  Packet       The DHCP packet that is to be sent or already received.\r
   @param[out] NewPacket    The packet used to replace the above Packet.\r
-  \r
+\r
   @retval EFI_SUCCESS      Either the DHCP OFFER is qualified or we're not intereseted\r
                            in the Dhcp4Event.\r
   @retval EFI_NOT_READY    The DHCP OFFER packet doesn't match our requirements.\r
@@ -222,7 +222,7 @@ IScsiDhcpSelectOffer (
   }\r
 \r
   for (Index = 0; Index < OptionCount; Index++) {\r
-    if (OptionList[Index]->OpCode != DHCP4_TAG_ROOT_PATH) {\r
+    if (OptionList[Index]->OpCode != DHCP4_TAG_ROOTPATH) {\r
       continue;\r
     }\r
 \r
@@ -235,7 +235,7 @@ IScsiDhcpSelectOffer (
     break;\r
   }\r
 \r
-  if ((Index == OptionCount)) {\r
+  if (Index == OptionCount) {\r
     Status = EFI_NOT_READY;\r
   }\r
 \r
@@ -303,7 +303,7 @@ IScsiParseDhcpAck (
     //\r
     // Get DNS server addresses and DHCP server address from this offer.\r
     //\r
-    if (OptionList[Index]->OpCode == DHCP4_TAG_DNS) {\r
+    if (OptionList[Index]->OpCode == DHCP4_TAG_DNS_SERVER) {\r
 \r
       if (((OptionList[Index]->Length & 0x3) != 0) || (OptionList[Index]->Length == 0)) {\r
         Status = EFI_INVALID_PARAMETER;\r
@@ -337,7 +337,7 @@ IScsiParseDhcpAck (
 \r
 /**\r
   Parse the DHCP ACK to get the address configuration and DNS information.\r
-  \r
+\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
@@ -360,7 +360,8 @@ IScsiDoDhcp (
   EFI_STATUS              Status;\r
   EFI_DHCP4_PACKET_OPTION *ParaList;\r
   EFI_DHCP4_CONFIG_DATA   Dhcp4ConfigData;\r
-  BOOLEAN                 MediaPresent;\r
+  EFI_STATUS              MediaStatus;\r
+  UINT8                   *Data;\r
 \r
   Dhcp4Handle = NULL;\r
   Dhcp4       = NULL;\r
@@ -369,9 +370,9 @@ IScsiDoDhcp (
   //\r
   // Check media status before do DHCP\r
   //\r
-  MediaPresent = TRUE;\r
-  NetLibDetectMedia (Controller, &MediaPresent);\r
-  if (!MediaPresent) {\r
+  MediaStatus = EFI_SUCCESS;\r
+  NetLibDetectMediaWaitTimeout (Controller, ISCSI_CHECK_MEDIA_GET_DHCP_WAITING_TIME, &MediaStatus);\r
+  if (MediaStatus != EFI_SUCCESS) {\r
     return EFI_NO_MEDIA;\r
   }\r
 \r
@@ -410,10 +411,11 @@ IScsiDoDhcp (
   //\r
   ParaList->OpCode  = DHCP4_TAG_PARA_LIST;\r
   ParaList->Length  = (UINT8) (ConfigData->NvData.TargetInfoFromDhcp ? 4 : 3);\r
-  ParaList->Data[0] = DHCP4_TAG_NETMASK;\r
-  ParaList->Data[1] = DHCP4_TAG_ROUTER;\r
-  ParaList->Data[2] = DHCP4_TAG_DNS;\r
-  ParaList->Data[3] = DHCP4_TAG_ROOT_PATH;\r
+  Data = &ParaList->Data[0];\r
+  Data[0] = DHCP4_TAG_NETMASK;\r
+  Data[1] = DHCP4_TAG_ROUTER;\r
+  Data[2] = DHCP4_TAG_DNS_SERVER;\r
+  Data[3] = DHCP4_TAG_ROOTPATH;\r
 \r
   ZeroMem (&Dhcp4ConfigData, sizeof (EFI_DHCP4_CONFIG_DATA));\r
   Dhcp4ConfigData.OptionCount = 1;\r