]> git.proxmox.com Git - mirror_edk2.git/blobdiff - NetworkPkg/IScsiDxe/IScsiMisc.c
NetworkPkg: Clean up source files
[mirror_edk2.git] / NetworkPkg / IScsiDxe / IScsiMisc.c
index 745b7ac07b972194ba1f2622ac0f83103e0d37e5..dd0d32dcda168259e7573275ffe422d95ae66074 100644 (file)
@@ -20,7 +20,7 @@ GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR8  IScsiHexString[] = "0123456789ABCDEFa
   Removes (trims) specified leading and trailing characters from a string.\r
 \r
   @param[in, out] Str   Pointer to the null-terminated string to be trimmed.\r
-                        On return, Str will hold the trimmed string. \r
+                        On return, Str will hold the trimmed string.\r
 \r
   @param[in]      CharC Character will be trimmed from str.\r
 \r
@@ -33,18 +33,18 @@ IScsiStrTrim (
 {\r
   CHAR16  *Pointer1;\r
   CHAR16  *Pointer2;\r
-  \r
+\r
   if (*Str == 0) {\r
     return ;\r
   }\r
-  \r
+\r
   //\r
   // Trim off the leading and trailing characters c\r
   //\r
   for (Pointer1 = Str; (*Pointer1 != 0) && (*Pointer1 == CharC); Pointer1++) {\r
     ;\r
   }\r
-  \r
+\r
   Pointer2 = Str;\r
   if (Pointer2 == Pointer1) {\r
     while (*Pointer1 != 0) {\r
@@ -52,19 +52,19 @@ IScsiStrTrim (
       Pointer1++;\r
     }\r
   } else {\r
-    while (*Pointer1 != 0) {    \r
-    *Pointer2 = *Pointer1;    \r
+    while (*Pointer1 != 0) {\r
+    *Pointer2 = *Pointer1;\r
     Pointer1++;\r
     Pointer2++;\r
     }\r
     *Pointer2 = 0;\r
   }\r
-  \r
-  \r
+\r
+\r
   for (Pointer1 = Str + StrLen(Str) - 1; Pointer1 >= Str && *Pointer1 == CharC; Pointer1--) {\r
     ;\r
   }\r
-  if  (Pointer1 !=  Str + StrLen(Str) - 1) { \r
+  if  (Pointer1 !=  Str + StrLen(Str) - 1) {\r
     *(Pointer1 + 1) = 0;\r
   }\r
 }\r
@@ -131,11 +131,11 @@ IScsiAsciiStrToLun (
   CHAR8   TemStr[2];\r
   UINT8   TemValue;\r
   UINT16  Value[4];\r
-  \r
+\r
   ZeroMem (Lun, 8);\r
   ZeroMem (TemStr, 2);\r
   ZeroMem ((UINT8 *) Value, sizeof (Value));\r
-  SizeStr    = AsciiStrLen (Str);  \r
+  SizeStr    = AsciiStrLen (Str);\r
   IndexValue = 0;\r
   IndexNum   = 0;\r
 \r
@@ -150,7 +150,7 @@ IScsiAsciiStrToLun (
         return EFI_INVALID_PARAMETER;\r
       }\r
     }\r
-    \r
+\r
     if ((TemValue == 0) && (TemStr[0] == '-')) {\r
       //\r
       // Next Lun value.\r
@@ -167,24 +167,24 @@ IScsiAsciiStrToLun (
       IndexNum = 0;\r
       continue;\r
     }\r
-    \r
+\r
     if (++IndexNum > 4) {\r
-      //     \r
+      //\r
       // Each Lun Str can't exceed size 4, because it will be as UINT16 value.\r
       //\r
       return EFI_INVALID_PARAMETER;\r
     }\r
-    \r
+\r
     //\r
     // Combine UINT16 value.\r
     //\r
     Value[IndexValue] = (UINT16) ((Value[IndexValue] << 4) + TemValue);\r
   }\r
\r
+\r
   for (Index = 0; Index <= IndexValue; Index ++) {\r
     *((UINT16 *) &Lun[Index * 2]) =  HTONS (Value[Index]);\r
   }\r
-  \r
+\r
   return EFI_SUCCESS;\r
 }\r
 \r
@@ -319,7 +319,7 @@ IScsiMacAddrToStr (
   @param[in, out]  HexStr      Pointer to the string.\r
   @param[in, out]  HexLength   The length of the string.\r
 \r
-  @retval EFI_SUCCESS          The binary data is converted to the hexadecimal string \r
+  @retval EFI_SUCCESS          The binary data is converted to the hexadecimal string\r
                                and the length of the string is updated.\r
   @retval EFI_BUFFER_TOO_SMALL The string is too small.\r
   @retval EFI_INVALID_PARAMETER The IP string is malformatted.\r
@@ -385,7 +385,7 @@ IScsiHexToBin (
   UINTN   Length;\r
   UINT8   Digit;\r
   CHAR8   TemStr[2];\r
-  \r
+\r
   ZeroMem (TemStr, sizeof (TemStr));\r
 \r
   //\r
@@ -394,7 +394,7 @@ IScsiHexToBin (
   if ((HexStr[0] == '0') && ((HexStr[1] == 'x') || (HexStr[1] == 'X'))) {\r
     HexStr += 2;\r
   }\r
-  \r
+\r
   Length = AsciiStrLen (HexStr);\r
 \r
   for (Index = 0; Index < Length; Index ++) {\r
@@ -412,7 +412,7 @@ IScsiHexToBin (
       BinBuffer [Index/2] = (UINT8) ((BinBuffer [Index/2] << 4) + Digit);\r
     }\r
   }\r
-  \r
+\r
   *BinLength = (UINT32) ((Index + 1)/2);\r
 \r
   return EFI_SUCCESS;\r
@@ -492,7 +492,7 @@ IScsiCheckIpv6Support (
   BOOLEAN                          Supported;\r
   VOID                             *InfoBlock;\r
   UINTN                            InfoBlockSize;\r
-  \r
+\r
   EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL *Nii;\r
 \r
   ASSERT (Ipv6Support != NULL);\r
@@ -515,7 +515,7 @@ IScsiCheckIpv6Support (
 \r
   //\r
   // Get the NIC handle by SNP protocol.\r
-  //  \r
+  //\r
   Handle = NetLibGetSnpHandle (ControllerHandle, NULL);\r
   if (Handle == NULL) {\r
     return EFI_NOT_FOUND;\r
@@ -561,11 +561,11 @@ IScsiCheckIpv6Support (
   if (EFI_ERROR (Status) || InfoBlock == NULL) {\r
     FreePool (InfoBlock);\r
     return EFI_NOT_FOUND;\r
-  }  \r
+  }\r
 \r
   *Ipv6Support = ((EFI_ADAPTER_INFO_UNDI_IPV6_SUPPORT *) InfoBlock)->Ipv6Support;\r
   FreePool (InfoBlock);\r
-  \r
+\r
   return EFI_SUCCESS;\r
 }\r
 \r
@@ -615,19 +615,19 @@ IScsiAddNic (
         CompareMem (&NicInfo->PermanentAddress, MacAddr.Addr, HwAddressSize) == 0 &&\r
         NicInfo->VlanId == VlanId) {\r
       mPrivate->CurrentNic = NicInfo->NicIndex;\r
-         \r
-           //\r
+\r
+      //\r
       // Set IPv6 available flag.\r
-      // \r
+      //\r
       Status = IScsiCheckIpv6Support (Controller, Image, &NicInfo->Ipv6Available);\r
       if (EFI_ERROR (Status)) {\r
         //\r
-        // Fail to get the data whether UNDI supports IPv6. \r
+        // Fail to get the data whether UNDI supports IPv6.\r
         // Set default value to TRUE.\r
         //\r
         NicInfo->Ipv6Available = TRUE;\r
       }\r
-         \r
+\r
       return EFI_SUCCESS;\r
     }\r
 \r
@@ -649,19 +649,19 @@ IScsiAddNic (
   NicInfo->VlanId         = VlanId;\r
   NicInfo->NicIndex       = (UINT8) (mPrivate->MaxNic + 1);\r
   mPrivate->MaxNic        = NicInfo->NicIndex;\r
-  \r
+\r
   //\r
   // Set IPv6 available flag.\r
-  // \r
+  //\r
   Status = IScsiCheckIpv6Support (Controller, Image, &NicInfo->Ipv6Available);\r
   if (EFI_ERROR (Status)) {\r
     //\r
-    // Fail to get the data whether UNDI supports IPv6. \r
+    // Fail to get the data whether UNDI supports IPv6.\r
     // Set default value to TRUE.\r
     //\r
     NicInfo->Ipv6Available = TRUE;\r
   }\r
-  \r
+\r
   //\r
   // Get the PCI location.\r
   //\r
@@ -1799,7 +1799,7 @@ IScsiCleanDriverData (
 \r
 EXIT:\r
   if (Private->ExitBootServiceEvent != NULL) {\r
-    gBS->CloseEvent (Private->ExitBootServiceEvent); \r
+    gBS->CloseEvent (Private->ExitBootServiceEvent);\r
   }\r
 \r
   mCallbackInfo->Current = NULL;\r
@@ -1813,10 +1813,10 @@ EXIT:
 \r
   @param[in]  Controller           The handle of the controller.\r
   @param[in]  IpVersion            IP_VERSION_4 or IP_VERSION_6.\r
-  \r
+\r
   @retval TRUE                     The handle of the controller need the Dhcp protocol.\r
   @retval FALSE                    The handle of the controller does not need the Dhcp protocol.\r
-  \r
+\r
 **/\r
 BOOLEAN\r
 IScsiDhcpIsConfigured (\r
@@ -1835,7 +1835,7 @@ IScsiDhcpIsConfigured (
   CHAR16                      MacString[ISCSI_MAX_MAC_STRING_LEN];\r
   CHAR16                      AttemptMacString[ISCSI_MAX_MAC_STRING_LEN];\r
   CHAR16                      AttemptName[ISCSI_NAME_IFR_MAX_SIZE];\r
-  \r
+\r
   AttemptConfigOrder = IScsiGetVariableAndSize (\r
                          L"AttemptOrder",\r
                          &gIScsiConfigGuid,\r
@@ -1844,7 +1844,7 @@ IScsiDhcpIsConfigured (
   if (AttemptConfigOrder == NULL || AttemptConfigOrderSize == 0) {\r
     return FALSE;\r
   }\r
-  \r
+\r
   //\r
   // Get MAC address of this network device.\r
   //\r
@@ -1857,7 +1857,7 @@ IScsiDhcpIsConfigured (
   //\r
   VlanId = NetLibGetVlanId (Controller);\r
   IScsiMacAddrToStr (&MacAddr, (UINT32) HwAddressSize, VlanId, MacString);\r
-  \r
+\r
   for (Index = 0; Index < AttemptConfigOrderSize / sizeof (UINT8); Index++) {\r
     UnicodeSPrint (\r
       AttemptName,\r
@@ -1874,7 +1874,7 @@ IScsiDhcpIsConfigured (
     if(AttemptTmp == NULL || EFI_ERROR (Status)) {\r
       continue;\r
     }\r
-    \r
+\r
     ASSERT (AttemptConfigOrder[Index] == AttemptTmp->AttemptConfigIndex);\r
 \r
     if (AttemptTmp->SessionConfigData.Enabled == ISCSI_DISABLED) {\r
@@ -1882,7 +1882,7 @@ IScsiDhcpIsConfigured (
       continue;\r
     }\r
 \r
-    if (AttemptTmp->SessionConfigData.IpMode != IP_MODE_AUTOCONFIG && \r
+    if (AttemptTmp->SessionConfigData.IpMode != IP_MODE_AUTOCONFIG &&\r
         AttemptTmp->SessionConfigData.IpMode != ((IpVersion == IP_VERSION_4) ? IP_MODE_IP4 : IP_MODE_IP6)) {\r
       FreePool (AttemptTmp);\r
       continue;\r
@@ -1896,7 +1896,7 @@ IScsiDhcpIsConfigured (
 \r
     if(AttemptTmp->SessionConfigData.IpMode == IP_MODE_AUTOCONFIG ||\r
        AttemptTmp->SessionConfigData.InitiatorInfoFromDhcp == TRUE ||\r
-       AttemptTmp->SessionConfigData.TargetInfoFromDhcp == TRUE) { \r
+       AttemptTmp->SessionConfigData.TargetInfoFromDhcp == TRUE) {\r
       FreePool (AttemptTmp);\r
       FreePool (AttemptConfigOrder);\r
       return TRUE;\r
@@ -1904,7 +1904,7 @@ IScsiDhcpIsConfigured (
 \r
     FreePool (AttemptTmp);\r
   }\r
-  \r
+\r
   FreePool (AttemptConfigOrder);\r
   return FALSE;\r
 }\r
@@ -1913,10 +1913,10 @@ IScsiDhcpIsConfigured (
   Check whether the Controller handle is configured to use DNS protocol.\r
 \r
   @param[in]  Controller           The handle of the controller.\r
-  \r
+\r
   @retval TRUE                     The handle of the controller need the Dns protocol.\r
   @retval FALSE                    The handle of the controller does not need the Dns protocol.\r
-  \r
+\r
 **/\r
 BOOLEAN\r
 IScsiDnsIsConfigured (\r
@@ -1934,7 +1934,7 @@ IScsiDnsIsConfigured (
   CHAR16                      AttemptMacString[ISCSI_MAX_MAC_STRING_LEN];\r
   CHAR16                      MacString[ISCSI_MAX_MAC_STRING_LEN];\r
   CHAR16                      AttemptName[ISCSI_NAME_IFR_MAX_SIZE];\r
-  \r
+\r
   AttemptConfigOrder = IScsiGetVariableAndSize (\r
                          L"AttemptOrder",\r
                          &gIScsiConfigGuid,\r
@@ -1943,7 +1943,7 @@ IScsiDnsIsConfigured (
   if (AttemptConfigOrder == NULL || AttemptConfigOrderSize == 0) {\r
     return FALSE;\r
   }\r
-  \r
+\r
   //\r
   // Get MAC address of this network device.\r
   //\r
@@ -1956,7 +1956,7 @@ IScsiDnsIsConfigured (
   //\r
   VlanId = NetLibGetVlanId (Controller);\r
   IScsiMacAddrToStr (&MacAddr, (UINT32) HwAddressSize, VlanId, MacString);\r
-  \r
+\r
   for (Index = 0; Index < AttemptConfigOrderSize / sizeof (UINT8); Index++) {\r
     UnicodeSPrint (\r
       AttemptName,\r
@@ -1974,7 +1974,7 @@ IScsiDnsIsConfigured (
     if(AttemptTmp == NULL || EFI_ERROR (Status)) {\r
       continue;\r
     }\r
-    \r
+\r
     ASSERT (AttemptConfigOrder[Index] == AttemptTmp->AttemptConfigIndex);\r
 \r
     AsciiStrToUnicodeStrS (AttemptTmp->MacString, AttemptMacString, sizeof (AttemptMacString) / sizeof (AttemptMacString[0]));\r
@@ -1983,7 +1983,7 @@ IScsiDnsIsConfigured (
       FreePool (AttemptTmp);\r
       continue;\r
     }\r
-    \r
+\r
     if (AttemptTmp->SessionConfigData.DnsMode || AttemptTmp->SessionConfigData.TargetInfoFromDhcp) {\r
       FreePool (AttemptTmp);\r
       FreePool (AttemptConfigOrder);\r
@@ -2060,7 +2060,7 @@ IScsiGetConfigData (
     //\r
     // Check whether the attempt exists in AttemptConfig.\r
     //\r
-    AttemptTmp = IScsiConfigGetAttemptByConfigIndex (AttemptConfigOrder[Index]);    \r
+    AttemptTmp = IScsiConfigGetAttemptByConfigIndex (AttemptConfigOrder[Index]);\r
     if (AttemptTmp != NULL && AttemptTmp->SessionConfigData.Enabled == ISCSI_DISABLED) {\r
       continue;\r
     } else if (AttemptTmp != NULL && AttemptTmp->SessionConfigData.Enabled != ISCSI_DISABLED) {\r
@@ -2126,11 +2126,11 @@ IScsiGetConfigData (
 \r
           continue;\r
         }\r
-      } else if (AttemptTmp->SessionConfigData.InitiatorInfoFromDhcp && \r
-                 !AttemptTmp->ValidPath && \r
+      } else if (AttemptTmp->SessionConfigData.InitiatorInfoFromDhcp &&\r
+                 !AttemptTmp->ValidPath &&\r
                  AttemptTmp->NicIndex == mPrivate->CurrentNic) {\r
         //\r
-        // If the attempt associates with the current NIC, we can \r
+        // If the attempt associates with the current NIC, we can\r
         // get DHCP information for already added, but failed, attempt.\r
         //\r
         AttemptTmp->DhcpSuccess = FALSE;\r
@@ -2213,7 +2213,7 @@ IScsiGetConfigData (
         (UINT8) (mPrivate->Ipv6Flag ? IP_MODE_AUTOCONFIG_IP6 : IP_MODE_AUTOCONFIG_IP4);\r
       AttemptConfigData->AutoConfigureSuccess = FALSE;\r
     }\r
-    \r
+\r
     //\r
     // Get some information from dhcp server.\r
     //\r
@@ -2384,7 +2384,7 @@ IScsiGetTcpConnDevicePath (
                   Conn->TcpIo.Handle,\r
                   &gEfiDevicePathProtocolGuid,\r
                   (VOID **) &DevicePath\r
-                  );  \r
+                  );\r
   if (EFI_ERROR (Status)) {\r
     return NULL;\r
   }\r
@@ -2403,7 +2403,7 @@ IScsiGetTcpConnDevicePath (
       if (!Conn->Ipv6Flag && DevicePathSubType (&DPathNode->DevPath) == MSG_IPv4_DP) {\r
         DPathNode->Ipv4.LocalPort       = 0;\r
 \r
-        DPathNode->Ipv4.StaticIpAddress = \r
+        DPathNode->Ipv4.StaticIpAddress =\r
           (BOOLEAN) (!Session->ConfigData->SessionConfigData.InitiatorInfoFromDhcp);\r
 \r
         //\r
@@ -2414,9 +2414,9 @@ IScsiGetTcpConnDevicePath (
         //\r
 \r
         PathLen = DevicePathNodeLength (&DPathNode->Ipv4);\r
-        \r
-        if (PathLen == IP4_NODE_LEN_NEW_VERSIONS) {  \r
-            \r
+\r
+        if (PathLen == IP4_NODE_LEN_NEW_VERSIONS) {\r
+\r
           IP4_COPY_ADDRESS (\r
             &DPathNode->Ipv4.GatewayIpAddress,\r
             &Session->ConfigData->SessionConfigData.Gateway\r
@@ -2427,7 +2427,7 @@ IScsiGetTcpConnDevicePath (
             &Session->ConfigData->SessionConfigData.SubnetMask\r
             );\r
         }\r
-        \r
+\r
         break;\r
       } else if (Conn->Ipv6Flag && DevicePathSubType (&DPathNode->DevPath) == MSG_IPv6_DP) {\r
         DPathNode->Ipv6.LocalPort       = 0;\r
@@ -2436,28 +2436,28 @@ IScsiGetTcpConnDevicePath (
         //  Add a judgement here to support previous versions of IPv6_DEVICE_PATH.\r
         //  In previous versions of IPv6_DEVICE_PATH, IpAddressOrigin, PrefixLength\r
         //  and GatewayIpAddress do not exist.\r
-        //  In new version of IPv6_DEVICE_PATH, structure length is 60, while in \r
+        //  In new version of IPv6_DEVICE_PATH, structure length is 60, while in\r
         //  old versions, the length is 43.\r
         //\r
 \r
         PathLen = DevicePathNodeLength (&DPathNode->Ipv6);\r
-        \r
-        if (PathLen == IP6_NODE_LEN_NEW_VERSIONS ) { \r
+\r
+        if (PathLen == IP6_NODE_LEN_NEW_VERSIONS ) {\r
 \r
           DPathNode->Ipv6.IpAddressOrigin = 0;\r
           DPathNode->Ipv6.PrefixLength    = IP6_PREFIX_LENGTH;\r
           ZeroMem (&DPathNode->Ipv6.GatewayIpAddress, sizeof (EFI_IPv6_ADDRESS));\r
         }\r
-        else if (PathLen == IP6_NODE_LEN_OLD_VERSIONS) { \r
+        else if (PathLen == IP6_NODE_LEN_OLD_VERSIONS) {\r
 \r
           //\r
-          //  StaticIPAddress is a field in old versions of IPv6_DEVICE_PATH, while ignored in new \r
+          //  StaticIPAddress is a field in old versions of IPv6_DEVICE_PATH, while ignored in new\r
           //  version. Set StaticIPAddress through its' offset in old IPv6_DEVICE_PATH.\r
           //\r
-          *((UINT8 *)(&DPathNode->Ipv6) + IP6_OLD_IPADDRESS_OFFSET) = \r
+          *((UINT8 *)(&DPathNode->Ipv6) + IP6_OLD_IPADDRESS_OFFSET) =\r
             (BOOLEAN) (!Session->ConfigData->SessionConfigData.InitiatorInfoFromDhcp);\r
         }\r
-        \r
+\r
         break;\r
       }\r
     }\r
@@ -2486,10 +2486,10 @@ IScsiOnExitBootService (
   ISCSI_DRIVER_DATA *Private;\r
 \r
   Private = (ISCSI_DRIVER_DATA *) Context;\r
-  \r
+\r
   gBS->CloseEvent (Private->ExitBootServiceEvent);\r
   Private->ExitBootServiceEvent = NULL;\r
-  \r
+\r
   if (Private->Session != NULL) {\r
     IScsiSessionAbort (Private->Session);\r
   }\r
@@ -2502,7 +2502,7 @@ IScsiOnExitBootService (
   currently managing the controller specified by ControllerHandle.  This test\r
   is performed by evaluating if the the protocol specified by ProtocolGuid is\r
   present on ControllerHandle and is was opened by DriverBindingHandle and Nic\r
-  Device handle with an attribute of EFI_OPEN_PROTOCOL_BY_DRIVER. \r
+  Device handle with an attribute of EFI_OPEN_PROTOCOL_BY_DRIVER.\r
   If ProtocolGuid is NULL, then ASSERT().\r
 \r
   @param  ControllerHandle     A handle for a controller to test.\r