]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Update ISID to fixed value: first 3 bytes are derived from MAC address while the...
authortye1 <tye1@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 6 Apr 2011 07:19:38 +0000 (07:19 +0000)
committertye1 <tye1@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 6 Apr 2011 07:19:38 +0000 (07:19 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11507 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Universal/Network/IScsiDxe/IScsiConfig.c
MdeModulePkg/Universal/Network/IScsiDxe/IScsiConfigDxe.vfr
MdeModulePkg/Universal/Network/IScsiDxe/IScsiConfigDxeStrings.uni
MdeModulePkg/Universal/Network/IScsiDxe/IScsiConfigNVDataStruc.h
MdeModulePkg/Universal/Network/IScsiDxe/IScsiMisc.h
MdeModulePkg/Universal/Network/IScsiDxe/IScsiProto.c
MdeModulePkg/Universal/Network/IScsiDxe/IScsiProto.h

index 2f9806e20a3b650a842d360abe5299d5995fc36e..1b4c7ad75e3b386956025d5473004ffb60448711 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Helper functions for configuring or getting the parameters relating to iSCSI.\r
 \r
-Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2011, 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
@@ -65,6 +65,121 @@ IScsiIpToStr (
   UnicodeSPrint ( Str, 2 * IP4_STR_MAX_SIZE, L"%d.%d.%d.%d", Ip->Addr[0], Ip->Addr[1], Ip->Addr[2], Ip->Addr[3]);\r
 }\r
 \r
+\r
+/**\r
+  Parse IsId in string format and convert it to binary.\r
+\r
+  @param[in]        String  The buffer of the string to be parsed.\r
+  @param[in, out]   IsId    The buffer to store IsId.\r
+\r
+  @retval EFI_SUCCESS              The operation finished successfully.\r
+  @retval EFI_INVALID_PARAMETER    Any input parameter is invalid.\r
+\r
+**/\r
+EFI_STATUS\r
+IScsiParseIsIdFromString (\r
+  IN CONST CHAR16                    *String,\r
+  IN OUT   UINT8                     *IsId\r
+  )\r
+{\r
+  UINT8                          Index;\r
+  CHAR16                         *IsIdStr;\r
+  CHAR16                         TempStr[3];\r
+  UINTN                          NodeVal;\r
+  CHAR16                         PortString[ISCSI_NAME_IFR_MAX_SIZE];\r
+  EFI_INPUT_KEY                  Key;\r
+\r
+  if ((String == NULL) || (IsId == NULL)) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  IsIdStr = (CHAR16 *) String;\r
+\r
+  if (StrLen (IsIdStr) != 6) {\r
+    UnicodeSPrint (\r
+      PortString,\r
+      (UINTN) ISCSI_NAME_IFR_MAX_SIZE,\r
+      L"Error! Input is incorrect, please input 6 hex numbers!\n"\r
+      );\r
+\r
+    CreatePopUp (\r
+      EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,\r
+      &Key,\r
+      PortString,\r
+      NULL\r
+      );\r
+\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  for (Index = 3; Index < 6; Index++) {\r
+    CopyMem (TempStr, IsIdStr, sizeof (TempStr));\r
+    TempStr[2] = L'\0';\r
+\r
+    //\r
+    // Convert the string to IsId. StrHexToUintn stops at the first character\r
+    // that is not a valid hex character, '\0' here.\r
+    //\r
+    NodeVal = StrHexToUintn (TempStr);\r
+\r
+    IsId[Index] = (UINT8) NodeVal;\r
+\r
+    IsIdStr = IsIdStr + 2;\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+/**\r
+  Convert IsId from binary to string format.\r
+\r
+  @param[out]      String  The buffer to store the converted string.\r
+  @param[in]       IsId    The buffer to store IsId.\r
+\r
+  @retval EFI_SUCCESS              The string converted successfully.\r
+  @retval EFI_INVALID_PARAMETER    Any input parameter is invalid.\r
+\r
+**/\r
+EFI_STATUS\r
+IScsiConvertIsIdToString (\r
+  OUT CHAR16                         *String,\r
+  IN  UINT8                          *IsId\r
+  )\r
+{\r
+  UINT8                          Index;\r
+  UINTN                          Number;\r
+\r
+  if ((String == NULL) || (IsId == NULL)) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  for (Index = 0; Index < 6; Index++) {\r
+    if (IsId[Index] <= 0xF) {\r
+      Number = UnicodeSPrint (\r
+                 String,\r
+                 2 * ISID_CONFIGURABLE_STORAGE,\r
+                 L"0%X",\r
+                 (UINTN) IsId[Index]\r
+                 );\r
+    } else {\r
+      Number = UnicodeSPrint (\r
+                 String,\r
+                 2 * ISID_CONFIGURABLE_STORAGE,\r
+                 L"%X",\r
+                 (UINTN) IsId[Index]\r
+                 );\r
+\r
+    }\r
+\r
+    String = String + Number;\r
+  }\r
+\r
+  *String = L'\0';\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+\r
 /**\r
   Update the list of iSCSI devices the iSCSI driver is controlling.\r
 \r
@@ -241,6 +356,7 @@ IScsiGetConfigFormEntryByIndex (
 \r
   @param[in]   ConfigFormEntry The iSCSI configuration form entry.\r
   @param[out]  IfrNvData       The IFR nv data.\r
+\r
 **/\r
 VOID\r
 IScsiConvertDeviceConfigDataToIfrNvData (\r
@@ -270,6 +386,8 @@ IScsiConvertDeviceConfigDataToIfrNvData (
 \r
   IScsiLunToUnicodeStr (SessionConfigData->BootLun, IfrNvData->BootLun);\r
 \r
+  IScsiConvertIsIdToString (IfrNvData->IsId, SessionConfigData->IsId);\r
+\r
   //\r
   // CHAP authentication parameters.\r
   //\r
@@ -688,6 +806,12 @@ IScsiFormCallback (
     IScsiUnicodeStrToAsciiStr (IfrNvData->ReverseCHAPSecret, Private->Current->AuthConfigData.ReverseCHAPSecret);\r
     break;\r
 \r
+  case KEY_CONFIG_ISID:\r
+    IScsiParseIsIdFromString (IfrNvData->IsId, Private->Current->SessionConfigData.IsId);\r
+    IScsiConvertIsIdToString (IfrNvData->IsId, Private->Current->SessionConfigData.IsId);\r
+\r
+    break;\r
+\r
   case KEY_SAVE_CHANGES:\r
     //\r
     // First, update those fields which don't have INTERACTIVE set.\r
@@ -890,6 +1014,13 @@ IScsiConfigUpdateForm (
                       );\r
       if (EFI_ERROR (Status)) {\r
         ZeroMem (&ConfigFormEntry->SessionConfigData, sizeof (ConfigFormEntry->SessionConfigData));\r
+        \r
+        //\r
+        // Generate OUI-format ISID based on MAC address.\r
+        //\r
+        CopyMem (ConfigFormEntry->SessionConfigData.IsId, &MacAddress, 6);\r
+        ConfigFormEntry->SessionConfigData.IsId[0] = \r
+          ConfigFormEntry->SessionConfigData.IsId[0] & 0x3F;\r
       }\r
       //\r
       // Get the CHAP authentication configuration data.\r
index 101902b7e9f16b757e76f603204572bbaa7a1491..fca8cfd1b2e7b42c32155c336c78dc7c46709a4e 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Vfr file for iSCSI config.\r
   \r
-Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2011, 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
@@ -193,6 +193,17 @@ formset
 \r
     subtitle text = STRING_TOKEN(STR_NULL); \r
 \r
+    string  varid   = ISCSI_CONFIG_IFR_NVDATA.IsId, \r
+            prompt  = STRING_TOKEN(STR_ISCSI_CONFIG_ISID),\r
+            help    = STRING_TOKEN(STR_ISCSI_CONFIG_ISID_HELP),\r
+            flags   = INTERACTIVE,\r
+            key     = KEY_CONFIG_ISID,\r
+            minsize = ISID_CONFIGURABLE_MIN_LEN,\r
+            maxsize = ISID_CONFIGURABLE_MAX_LEN,\r
+    endstring;\r
+\r
+    subtitle text = STRING_TOKEN(STR_NULL); \r
+\r
     goto FORMID_DEVICE_FORM,  \r
     prompt = STRING_TOKEN (STR_SAVE_CHANGES),\r
     help   = STRING_TOKEN (STR_SAVE_CHANGES),\r
index 42ca5a610df71de912effbee3ffe4c65ee937d47..140f2425a2c2af14e509fd960a65058a79cdf026 100644 (file)
Binary files a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiConfigDxeStrings.uni and b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiConfigDxeStrings.uni differ
index d51af3a92f4ad1f19e840ae96f2f8e0e01b9caa9..7c26ff377d1bccbe579514f8b5ef5a55ed00c1da 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Define NVData structures used by the iSCSI configuration component\r
 \r
-Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2011, 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
@@ -63,6 +63,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #define KEY_SAVE_CHANGES          0x10b\r
 #define KEY_TARGET_NAME           0x10c\r
 #define KEY_BOOT_LUN              0x10d\r
+#define KEY_CONFIG_ISID           0x10e\r
 \r
 #define KEY_DEVICE_ENTRY_BASE     0x1000\r
 \r
@@ -76,6 +77,10 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 #define ISCSI_CHAP_NAME_MAX_LEN   126\r
 \r
+#define ISID_CONFIGURABLE_MIN_LEN 6\r
+#define ISID_CONFIGURABLE_MAX_LEN 12\r
+#define ISID_CONFIGURABLE_STORAGE 13\r
+\r
 #pragma pack(1)\r
 typedef struct {\r
   CHAR16  InitiatorName[ISCSI_NAME_MAX_SIZE];\r
@@ -98,6 +103,8 @@ typedef struct {
   CHAR16  CHAPSecret[ISCSI_CHAP_SECRET_STORAGE];\r
   CHAR16  ReverseCHAPName[ISCSI_CHAP_NAME_MAX_LEN];\r
   CHAR16  ReverseCHAPSecret[ISCSI_CHAP_SECRET_STORAGE];\r
+\r
+  CHAR16  IsId[ISID_CONFIGURABLE_STORAGE];\r
 } ISCSI_CONFIG_IFR_NVDATA;\r
 #pragma pack()\r
 \r
index 4322bf6320e230645cf939b7dce24768a4216ffa..512c67c38c74855f635e16de9463962e2c59af67 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Miscellaneous definitions for iSCSI driver.\r
 \r
-Copyright (c) 2004 - 2009, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2011, 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
@@ -33,6 +33,8 @@ typedef struct {
   EFI_IPv4_ADDRESS  TargetIp;\r
   UINT16            TargetPort;\r
   UINT8             BootLun[8];\r
+\r
+  UINT8             IsId[6];\r
 } ISCSI_SESSION_CONFIG_NVDATA;\r
 #pragma pack()\r
 \r
index 2390737f25186d6a694642c4253aabcfbb79fe73..3836053d932e1e925e183d9c589644dcf35dd877 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   The implementation of iSCSI protocol based on RFC3720.\r
 \r
-Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2011, 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
@@ -302,6 +302,11 @@ IScsiSessionLogin (
     return EFI_NO_MEDIA;\r
   }\r
 \r
+  //\r
+  // Set session identifier\r
+  //\r
+  CopyMem (Session->Isid, Session->ConfigData.NvData.IsId, 6);\r
+\r
   //\r
   // Create a connection for the session.\r
   //\r
@@ -2681,21 +2686,10 @@ IScsiSessionInit (
   IN BOOLEAN            Recovery\r
   )\r
 {\r
-  UINT32  Random;\r
-\r
   if (!Recovery) {\r
     Session->Signature  = ISCSI_SESSION_SIGNATURE;\r
     Session->State      = SESSION_STATE_FREE;\r
 \r
-    Random              = NET_RANDOM (NetRandomInitSeed ());\r
-\r
-    Session->Isid[0]    = ISID_BYTE_0;\r
-    Session->Isid[1]    = ISID_BYTE_1;\r
-    Session->Isid[2]    = ISID_BYTE_2;\r
-    Session->Isid[3]    = ISID_BYTE_3;\r
-    Session->Isid[4]    = (UINT8) Random;\r
-    Session->Isid[5]    = (UINT8) (Random >> 8);\r
-\r
     InitializeListHead (&Session->Conns);\r
     InitializeListHead (&Session->TcbList);\r
   }\r
index e8022cb6c7cdea7176dbe34d1ad3fb98f166d173..cac98c8b3d29d358ba2487030f7f50a286ca17ad 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   The header file of iSCSI Protocol that defines many specific data structures.\r
 \r
-Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2011, 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
@@ -42,11 +42,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #define ISCSI_VERSION_MAX                       0x00\r
 #define ISCSI_VERSION_MIN                       0x00\r
 \r
-#define ISID_BYTE_0                             0 // OUI format\r
-#define ISID_BYTE_1                             0\r
-#define ISID_BYTE_2                             0xaa\r
-#define ISID_BYTE_3                             0x1\r
-\r
 #define ISCSI_KEY_AUTH_METHOD                   "AuthMethod"\r
 #define ISCSI_KEY_HEADER_DIGEST                 "HeaderDigest"\r
 #define ISCSI_KEY_DATA_DIGEST                   "DataDigest"\r