]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Network/IScsiDxe/IScsiDhcp.c
update file header
[mirror_edk2.git] / MdeModulePkg / Universal / Network / IScsiDxe / IScsiDhcp.c
index ec8d4b2c3ced44b212a33260d58daac535067307..f02423475e6f2d22f52c4890aa468209a9d6ac1d 100644 (file)
@@ -1,7 +1,7 @@
-/**\r
+/** @file\r
   ISci DHCP related configuration routines.\r
 \r
-Copyright (c) 2004 - 2007, Intel Corporation\r
+Copyright (c) 2004 - 2007, 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
@@ -10,14 +10,6 @@ http://opensource.org/licenses/bsd-license.php
 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
 \r
-Module Name:\r
-\r
-  IScsiDhcp.c\r
-\r
-Abstract:\r
-\r
-  IScsi DHCP related configuration routines.\r
-\r
 **/\r
 \r
 #include "IScsiImpl.h"\r
@@ -25,20 +17,14 @@ Abstract:
 /**\r
   Extract the Root Path option and get the required target information.\r
 \r
-  @param  RootPath[in]          The RootPath.\r
-\r
-  @param  Length[in]            Length of the RootPath option payload.\r
-\r
-  @param  ConfigNvData[in]      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]   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
-\r
   @retval EFI_NOT_FOUND         The RootPath is not an iSCSI RootPath.\r
-\r
   @retval EFI_OUT_OF_RESOURCES  Failed to allocate memory.\r
-\r
   @retval EFI_INVALID_PARAMETER The RootPath is mal-formatted.\r
-\r
 **/\r
 EFI_STATUS\r
 IScsiDhcpExtractRootPath (\r
@@ -52,7 +38,7 @@ IScsiDhcpExtractRootPath (
   CHAR8                 *TmpStr;\r
   ISCSI_ROOT_PATH_FIELD Fields[RP_FIELD_IDX_MAX];\r
   ISCSI_ROOT_PATH_FIELD *Field;\r
-  UINT32                FieldIndex;\r
+  RP_FIELD_IDX          FieldIndex;\r
   UINT8                 Index;\r
 \r
   //\r
@@ -78,13 +64,13 @@ IScsiDhcpExtractRootPath (
   TmpStr[Length]  = '\0';\r
 \r
   Index           = 0;\r
-  FieldIndex      = 0;\r
+  FieldIndex      = RP_FIELD_IDX_SERVERNAME;\r
   ZeroMem (&Fields[0], sizeof (Fields));\r
 \r
   //\r
   // Extract the fields in the Root Path option string.\r
   //\r
-  for (FieldIndex = 0; (FieldIndex < RP_FIELD_IDX_MAX) && (Index < Length); FieldIndex++) {\r
+  for (FieldIndex = RP_FIELD_IDX_SERVERNAME; (FieldIndex < RP_FIELD_IDX_MAX) && (Index < Length); FieldIndex++) {\r
     if (TmpStr[Index] != ISCSI_ROOT_PATH_FIELD_DELIMITER) {\r
       Fields[FieldIndex].Str = &TmpStr[Index];\r
     }\r
@@ -109,19 +95,25 @@ IScsiDhcpExtractRootPath (
     Status = EFI_INVALID_PARAMETER;\r
     goto ON_EXIT;\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
-      ) {\r
-\r
+  \r
+  for (FieldIndex = RP_FIELD_IDX_SERVERNAME; FieldIndex != RP_FIELD_IDX_TARGETNAME; FieldIndex = RP_FIELD_IDX_TARGETNAME) {\r
+    if (Fields[FieldIndex].Str == NULL) {\r
+      Status = EFI_INVALID_PARAMETER;\r
+      goto ON_EXIT;\r
+    }\r
+  }\r
+  \r
+  FieldIndex = RP_FIELD_IDX_PROTOCOL;\r
+  if (Fields[RP_FIELD_IDX_PROTOCOL].Len > 1) {\r
     Status = EFI_INVALID_PARAMETER;\r
     goto ON_EXIT;\r
   }\r
+\r
   //\r
   // Get the IP address of the target.\r
   //\r
-  Field   = &Fields[RP_FIELD_IDX_SERVERNAME];\r
+  FieldIndex = RP_FIELD_IDX_SERVERNAME;\r
+  Field   = &Fields[FieldIndex];\r
   Status  = IScsiAsciiStrToIp (Field->Str, &ConfigNvData->TargetIp);\r
   if (EFI_ERROR (Status)) {\r
     goto ON_EXIT;\r
@@ -129,7 +121,8 @@ IScsiDhcpExtractRootPath (
   //\r
   // Check the protocol type.\r
   //\r
-  Field = &Fields[RP_FIELD_IDX_PROTOCOL];\r
+  FieldIndex = RP_FIELD_IDX_PROTOCOL;\r
+  Field = &Fields[FieldIndex];\r
   if ((Field->Str != NULL) && ((*(Field->Str) - '0') != EFI_IP_PROTO_TCP)) {\r
     Status = EFI_INVALID_PARAMETER;\r
     goto ON_EXIT;\r
@@ -137,7 +130,8 @@ IScsiDhcpExtractRootPath (
   //\r
   // Get the port of the iSCSI target.\r
   //\r
-  Field = &Fields[RP_FIELD_IDX_PORT];\r
+  FieldIndex = RP_FIELD_IDX_PORT;\r
+  Field = &Fields[FieldIndex];\r
   if (Field->Str != NULL) {\r
     ConfigNvData->TargetPort = (UINT16) AsciiStrDecimalToUintn (Field->Str);\r
   } else {\r
@@ -146,7 +140,8 @@ IScsiDhcpExtractRootPath (
   //\r
   // Get the LUN.\r
   //\r
-  Field = &Fields[RP_FIELD_IDX_LUN];\r
+  FieldIndex = RP_FIELD_IDX_LUN;\r
+  Field = &Fields[FieldIndex];\r
   if (Field->Str != NULL) {\r
     Status = IScsiAsciiStrToLun (Field->Str, ConfigNvData->BootLun);\r
     if (EFI_ERROR (Status)) {\r
@@ -158,8 +153,8 @@ IScsiDhcpExtractRootPath (
   //\r
   // Get the target iSCSI Name.\r
   //\r
-  Field = &Fields[RP_FIELD_IDX_TARGETNAME];\r
-\r
+  FieldIndex = RP_FIELD_IDX_TARGETNAME;  \r
+  Field = &Fields[FieldIndex];\r
   if (AsciiStrLen (Field->Str) > ISCSI_NAME_MAX_SIZE - 1) {\r
     Status = EFI_INVALID_PARAMETER;\r
     goto ON_EXIT;\r
@@ -185,23 +180,17 @@ ON_EXIT:
   The callback function registerd to the DHCP4 instance which is used to select\r
   the qualified DHCP OFFER.\r
   \r
-  @param  This[in]         The DHCP4 protocol.\r
-\r
-  @param  Context[in]      The context set when configuring the DHCP4 protocol.\r
-\r
-  @param  CurrentState[in] The current state of the DHCP4 protocol.\r
-\r
-  @param  Dhcp4Event[in]   The event occurs in the current state.\r
-\r
-  @param  Packet[in]       The DHCP packet that is to be sent or already received. \r
-\r
-  @param  NewPackt[out]    The packet used to replace the above Packet.\r
-\r
-  @retval EFI_NOT_READY    The DHCP OFFER packet doesn't match our requirements.\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[out] NewPacket    The packet used to replace the above Packet.\r
+  \r
   @retval EFI_SUCCESS      Either the DHCP OFFER is qualified or we're not intereseted\r
                            in the Dhcp4Event.\r
-\r
+  @retval EFI_NOT_READY    The DHCP OFFER packet doesn't match our requirements.\r
+  @retval Others           Some unexpected error happened.\r
 **/\r
 EFI_STATUS\r
 IScsiDhcpSelectOffer (\r
@@ -266,18 +255,13 @@ IScsiDhcpSelectOffer (
 /**\r
   Parse the DHCP ACK to get the address configuration and DNS information.\r
 \r
-  @param  Dhcp4[in]             The DHCP4 protocol.\r
-\r
-  @param  ConfigData[in]        The session configuration data.\r
+  @param[in]   Dhcp4            The DHCP4 protocol.\r
+  @param[in]   ConfigData       The session configuration data.\r
 \r
   @retval EFI_SUCCESS           The DNS information is got from the DHCP ACK.\r
-\r
   @retval EFI_NO_MAPPING        DHCP failed to acquire address and other information.\r
-\r
   @retval EFI_INVALID_PARAMETER The DHCP ACK's DNS option is mal-formatted.\r
-\r
   @retval EFI_DEVICE_ERROR      Some unexpected error happened.\r
-\r
 **/\r
 EFI_STATUS\r
 IScsiParseDhcpAck (\r
@@ -362,20 +346,13 @@ IScsiParseDhcpAck (
 /**\r
   Parse the DHCP ACK to get the address configuration and DNS information.\r
   \r
-  @param  Image[in]             The handle of the driver image.\r
-\r
-  @param  Controller[in]        The handle of the controller;\r
-\r
-  @param  ConfigData[in]        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]   ConfigData       The session configuration data.\r
 \r
   @retval EFI_SUCCESS           The DNS information is got from the DHCP ACK.\r
-\r
-  @retval EFI_NO_MAPPING        DHCP failed to acquire address and other information.\r
-\r
-  @retval EFI_INVALID_PARAMETER The DHCP ACK's DNS option is mal-formatted.\r
-\r
-  @retval EFI_DEVICE_ERROR      Some unexpected error happened.\r
-\r
+  @retval EFI_OUT_OF_RESOURCES  Failed to allocate memory.\r
+  @retval Others                Some unexpected error happened.\r
 **/\r
 EFI_STATUS\r
 IScsiDoDhcp (\r